SZDF:添加性能调测的代码 - 经营管理部合约
2017-09-19 10:14:55 访问(1189) 赞(0) 踩(0)
using eKing.EkPageCreate.Infos.HttpActions;
using eKing.EkPageCreate.Items;
using eKing.EkPageCreate.Names;
using eKing.EkPageCreate.WebCtrls;
using eKing.ExcelSlowXHelper.Classes;
using eKing.Log4Net;
using eKing.SzdfLib.Classes.Globals;
using eKing.SzdfLib.Classes.Items;
using eKing.SzdfPage.Classes.DevTracks;
using eKing.SzdfPage.Classes.ECharItems;
using eKing.SzdfPage.Classes.FileUploads;
using eKing.SzdfPage.Classes.Pages;
using eKing.SzdfPage.Classes.Powers;
using eKing.SzdfPage.Helpers;
using eKing.SzdfPage.Items.Results;
using eKing.SzdfPage.Names;
using eKing.SzdfPage.WebCtrls;
using eKing.ZnbmSessionInfo.Classes;
using eKingWGSS.Entity.Constant;
using eKingWGSS.Entity.Framework;
using NPOI.HSSF.Util;
using SlowX.Core.Business;
using SlowX.Core.Classes;
using SlowX.Core.Classes.CacheItems;
using SlowX.Core.ICoreClasses;
using SlowX.Core.Model;
using SlowX.CoreCache.Classes;
using SlowX.CoreImportData.Classes;
using SlowX.DAL.Helpers;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
namespace eKingWGSS.Website.Management.Classes.ZNBM
{
/// <summary>
/// 职能部门的逻辑操作基类
/// </summary>
public class ZnbmBaseController
:
SecurityJsonController
{
/// <summary>
///
/// </summary>
public ZnbmBaseController()
{
try
{
// 构建网站信息 //
// 判断和加载网站信息 //
ESH.EkxWebAppInfoLoad(null);
}
catch
{
}
}
/// <summary>
/// 开发调测
/// </summary>
public readonly static DevTrackContainer
devTrackContainerV
=
new DevTrackContainer();
/// <summary>
///
/// </summary>
protected string DevTrackGuid
=
System.Guid.NewGuid().ToString();
/// <summary>
/// 打印调测信息
/// </summary>
/// <returns></returns>
protected string PrintDevTrack()
{
if (devTrackContainerV == null)
return "";
List<DevTrackItem> itemList = devTrackContainerV.GetList();
if (itemList == null)
return "";
int iCount = itemList.Count;
if (iCount == 0)
return "-";
StringBuilder theResult = new StringBuilder();
theResult.Append("<table border=\"1\" width=\"100%\">");
DevTrackItem di = null;
int idx = 0;
for (int i = iCount - 1; i >= 0; --i)
{
++idx;
di = itemList[i];
theResult.Append("<tr>");
theResult.Append("<td width=\"40px\">" + idx.ToString() + "</td>");
theResult.Append("<td>");
theResult.Append(di.PrintHTML());
theResult.Append("</td>");
theResult.Append("</tr>");
}
theResult.Append("</table>");
return theResult.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="emV"></param>
/// <param name="dtStart"></param>
/// <param name="dtEnd"></param>
protected void AddDevTrackItem
(
eKing.SzdfPage.Enums.DevTrackPoint.EmDevTrackPoint emV,
DateTime dtStart,
DateTime dtEnd
)
{
if (devTrackContainerV == null)
return;
if (devTrackContainerV.ListCount() > 100)
{
devTrackContainerV.ListClear();
}
devTrackContainerV.AddItem
(
this.GetType().FullName,
DevTrackGuid,
emV,
dtStart,
dtEnd
);
}
/// <summary>
///
/// </summary>
/// <param name="emV"></param>
/// <param name="dtStart"></param>
/// <param name="dtEnd"></param>
protected void AddDevTrackItem4Token
(
)
{
if (devTrackContainerV == null)
return;
if (devTrackContainerV.ListCount() > 10)
{
devTrackContainerV.ListClear();
}
DateTime dtStart = DateTime.Now;
DateTime dtEnd = DateTime.Now;
Token tokenV
=
this.Session[WebSiteSessions.Token] as Token;
dtEnd = DateTime.Now;
string UserId = "";
if (tokenV == null || tokenV.Employee == null || tokenV.Employee.Length == 0)
{
UserId = "debug";
}
else
{
UserId = tokenV.Employee;
}
if (devTrackContainerV == null)
return;
if (devTrackContainerV.ListCount() > 100)
{
devTrackContainerV.ListClear();
}
// 登记Token //
devTrackContainerV.AddItem4Token
(
this.GetType().FullName,
DevTrackGuid,
UserId,
dtStart,
dtEnd
);
}
///// <summary>
///// 构建性能调试
///// </summary>
///// <returns></returns>
//protected DevTrackItem DevTrackItemCreate()
//{
// // 判断是否构建 //
// DevTrackItem theResult = new DevTrackItem();
// theResult.PageClassName = this.GetType().FullName;
// theResult.DT4Sessoin.StartTime = DateTime.Now;
// Token tokenV
// =
// this.Session[WebSiteSessions.Token] as Token;
// theResult.DT4Sessoin.EndTime = DateTime.Now;
// if(tokenV==null||tokenV.Employee==null||tokenV.Employee.Length == 0)
// {
// theResult.UserId = "debug";
// }
// else
// {
// theResult.UserId = tokenV.Employee;
// }
// return theResult;
//}
/// <summary>
/// 更新页面记忆功能
/// </summary>
/// <param name="emCDSA">操作模式:列表/导出(只有列表等模式才做记忆功能)</param>
/// <param name="pageSize">页码值</param>
/// <param name="xdbHelper">数据库链接串</param>
public void ListPageCmMemoryItemUpdateSave
(
eKing.EkPageCreate.Enums.DataListAction.EmDataListAction emCDSA,
int pageSize,
DBHelper xdbHelper
)
{
if (emCDSA != eKing.EkPageCreate.Enums.DataListAction.EmDataListAction.列表)
return;
ListPageCmMemoryItem cmi = new ListPageCmMemoryItem();
cmi.PageSize = pageSize;
string userId = SessionUserIdGet(xdbHelper);
if (userId == null || userId.Length == 0)
userId = "0";
ESH.ListPageCmMemoryItemSaveByPage
(
userId,
this.GetType().FullName,
cmi,
xdbHelper
);
}
/// <summary>
///
/// </summary>
/// <param name="xdbHelper"></param>
protected void SetIndexActionResult(DBHelper xdbHelper)
{
try
{
// 全局命名 //
GlobalName gN = GlobalName.instance;
// 设置权限 //
ViewData[gN.EkRolePower]
=
ZnbmRolePowerGet(xdbHelper);
string userId = SessionUserIdGet(xdbHelper);
ListPageCmMemoryItem LPCM
= null;
if (userId != null && userId.Length > 0)
{
LPCM =
ESH.ListPageCmMemoryItemGetByPage
(
userId,
this.GetType().FullName,
xdbHelper
);
}
// 记忆功能 //
if (LPCM == null)
{
LPCM = ListPageCmMemoryItem.instance;
}
// 设置权限 //
ViewData[gN.EkMemory]
=
LPCM;
}
catch (Exception err)
{
BaseWriteException(err);
throw err;
}
}
/// <summary>
/// 获得网站的项目根目录
/// </summary>
public string strPhyPath
{
get
{
return eKing.SzdfPage.Helpers.eKingSzdfPageHelper.ekInstance.PhyPath;
}
}
/// <summary>
/// 职能部门操作相关的方法
/// </summary>
public eKing.SzdfPage.Helpers.eKingSzdfPageHelper
ESH
{
get
{
return eKing.SzdfPage.Helpers.eKingSzdfPageHelper.ekInstance;
}
}
/// <summary>
///
/// </summary>
/// <param name="em"></param>
/// <param name="xdbHelper"></param>
/// <returns></returns>
public bool ZnbmCheckPower
(
SlowX.UserLib.Enums.WgssPowerName.EmWgssPowerName em,
DBHelper xdbHelper
)
{
ZnbmRolePower pz = ZnbmRolePowerGet(xdbHelper);
if (pz == null)
return false;
switch (em)
{
case SlowX.UserLib.Enums.WgssPowerName.EmWgssPowerName.删除:
return pz.AllowDelete();
case SlowX.UserLib.Enums.WgssPowerName.EmWgssPowerName.查看:
return pz.AllowView();
case SlowX.UserLib.Enums.WgssPowerName.EmWgssPowerName.编辑:
return pz.AllowEdit();
case SlowX.UserLib.Enums.WgssPowerName.EmWgssPowerName.新增:
return pz.AllowAdd();
default:
return true;
}
}
/// <summary>
/// 获得职能部门的权限
/// </summary>
/// <param name="xdbHelper"></param>
/// <returns></returns>
public ZnbmRolePower ZnbmRolePowerGet(DBHelper xdbHelper)
{
PageUserSession pu = GetUserSession(xdbHelper);
if (pu == null || pu.RolePower == null)
{
return new ZnbmRolePower
(
eKing.Szdf_Enum.Enums.WgssRolePower.EmWgssRolePower.查看员
);
}
eKing.ZnbmSessionInfo.Classes.Powers.ZnbmRolePower zrp = pu.RolePower;
eKing.Szdf_Enum.Enums.WgssRolePower.EmWgssRolePower emV
= eKing.Szdf_Enum.Enums.WgssRolePower.GetEmByInt((int)zrp.EmWgssRolePowerV);
return new ZnbmRolePower(emV);
}
/// <summary>
/// 通过DataTable导出Excel
/// </summary>
/// <param name="excelFileName"></param>
/// <param name="dt"></param>
/// <returns></returns>
protected virtual string EkExportExcel8DataTableForNPOI
(
string excelFileName,
DataTable dt
)
{
eKingSzdfPageHelper
ch
=
eKingSzdfPageHelper.ekInstance;
List<ExcelCell_Info> exList
=
new List<ExcelCell_Info>();
ExcelCell_Info info = null;
ExcelCellBuildInfo bI
=
new ExcelCellBuildInfo();
bI.StartCol = 0;
bI.StartRow = 0;
int colIdx = 0;
int rowIdx = 0;
foreach (DataColumn dc in dt.Columns)
{
info = new ExcelCell_Info();
info.ColNumber = bI.CurCol(colIdx);
info.RowNumber = bI.CurRow(rowIdx);
// info.FontSize = 14;
info.BackColor = HSSFColor.Grey25Percent.Index;
info.FontBoldWeightV = NPOI.SS.UserModel.FontBoldWeight.Bold;
info.RowSpan = 1;
info.ColSpan = 1;
info.Owner = info;
info.Text = dc.ColumnName;
exList.Add(info);
++colIdx;
}
foreach (DataRow dr in dt.Rows)
{
++rowIdx;
colIdx = 0;
foreach (DataColumn dc in dt.Columns)
{
info = new ExcelCell_Info();
info.ColNumber = bI.CurCol(colIdx);
info.RowNumber = bI.CurRow(rowIdx);
info.RowSpan = 1;
info.ColSpan = 1;
info.Owner = info;
// info.FontSize = 14;
info.Text = dr[dc.ColumnName].ToString();
exList.Add(info);
++colIdx;
}
}
eKing.ExcelSlowXHelper.Helpers.Helper exHelper
=
eKing.ExcelSlowXHelper.Helpers.Helper.instance;
excelFileName = ch.ToExcelExportFileName(excelFileName);
string fullName = Request.PhysicalApplicationPath
+
excelFileName.Replace("/", "\\");
// list转成Excel输出 //
exHelper.WriteExcelToFile
(
fullName,
exList
);
return excelFileName;
}
/// <summary>
/// 通过DataSet导出Excel文档
/// </summary>
/// <param name="excelFileName"></param>
/// <param name="ds"></param>
/// <returns></returns>
protected virtual string EkExportExcel8DataSetForNPOI
(
string excelFileName,
DataSet ds
)
{
eKingSzdfPageHelper
ch
=
eKingSzdfPageHelper.ekInstance;
List<ExcelWorkBook> wbList = new List<ExcelWorkBook>();
foreach(DataTable dt in ds.Tables)
{
ExcelWorkBook ewb = new ExcelWorkBook();
List<ExcelCell_Info> exList
=
new List<ExcelCell_Info>();
ewb.sheetName = dt.TableName;
ewb.cellList = exList;
wbList.Add(ewb);
ExcelCell_Info info = null;
ExcelCellBuildInfo bI
=
new ExcelCellBuildInfo();
bI.StartCol = 0;
bI.StartRow = 0;
int colIdx = 0;
int rowIdx = 0;
foreach (DataColumn dc in dt.Columns)
{
info = new ExcelCell_Info();
info.ColNumber = bI.CurCol(colIdx);
info.RowNumber = bI.CurRow(rowIdx);
// info.FontSize = 14;
info.BackColor = HSSFColor.Grey25Percent.Index;
info.FontBoldWeightV = NPOI.SS.UserModel.FontBoldWeight.Bold;
info.RowSpan = 1;
info.ColSpan = 1;
info.Owner = info;
info.Text = dc.ColumnName;
exList.Add(info);
++colIdx;
}
foreach (DataRow dr in dt.Rows)
{
++rowIdx;
colIdx = 0;
foreach (DataColumn dc in dt.Columns)
{
info = new ExcelCell_Info();
info.ColNumber = bI.CurCol(colIdx);
info.RowNumber = bI.CurRow(rowIdx);
info.RowSpan = 1;
info.ColSpan = 1;
info.Owner = info;
// info.FontSize = 14;
info.Text = dr[dc.ColumnName].ToString();
exList.Add(info);
++colIdx;
}
}
}
eKing.ExcelSlowXHelper.Helpers.Helper exHelper
=
eKing.ExcelSlowXHelper.Helpers.Helper.instance;
excelFileName = ch.ToExcelExportFileName(excelFileName);
string fullName = Request.PhysicalApplicationPath
+
excelFileName.Replace("/", "\\");
// list转成Excel输出 //
exHelper.WriteExcelToFile
(
fullName,
wbList
);
return excelFileName;
}
/// <summary>
/// NPOI导出Excel
/// </summary>
/// <param name="excelFileName">Excel的文件名称,如果传入(:导出),生成是系统内置的路径地址</param>
/// <param name="ec">Excel的数据源</param>
/// <returns></returns>
protected virtual string EkExportExcelForExcelCell_Container
(
string excelFileName,
ExcelCell_Container ec
)
{
eKingSzdfPageHelper
ch
=
eKingSzdfPageHelper.ekInstance;
eKing.ExcelSlowXHelper.Helpers.Helper exHelper
=
eKing.ExcelSlowXHelper.Helpers.Helper.instance;
excelFileName = ch.ToExcelExportFileName(excelFileName);
string fullName = Request.PhysicalApplicationPath
+
excelFileName.Replace("/", "\\");
// list转成Excel输出 //
exHelper.WriteExcelToFile8ExcelCellContainer
(
fullName,
ec
);
return excelFileName;
}
/// <summary>
/// NPOI导出Excel
/// </summary>
/// <param name="pgc">Excel的导出数据源</param>
/// <param name="excelFileName">Excel的文件名称,如果传入(:导出),生成是系统内置的路径地址</param>
/// <param name="ekg">配置Excel导出的项设置</param>
/// <returns></returns>
protected virtual string EkExportExcelForNPOI
(
BootstrapTableDataContainer pgc,
string excelFileName,
EkxPageTable ekg
)
{
eKingSzdfPageHelper
ch
=
eKingSzdfPageHelper.ekInstance;
List<ExcelCell_Info> exList
=
new List<ExcelCell_Info>();
List<EkxTableColumn> CM
=
ekg.ColumnListGet();
ExcelCell_Info info = null;
ExcelCellBuildInfo bI
=
new ExcelCellBuildInfo();
bI.StartCol = 0;
bI.StartRow = 0;
int idx = 0;
int colIdx = 0;
int rowIdx = 0;
foreach (EkxTableColumn col in CM)
{
// EmTableColumnStatusV == Enums.TableColumnStatus.EmTableColumnStatus.不启用 //
// 需要过滤 //
if (!col.IsEnabled4JsonData())
continue;
if (!col.IsExcelExport())
continue;
info = new ExcelCell_Info();
info.ColNumber = bI.CurCol(colIdx);
info.RowNumber = bI.CurRow(rowIdx);
// info.FontSize = 14;
info.BackColor = HSSFColor.Grey25Percent.Index;
info.FontBoldWeightV = NPOI.SS.UserModel.FontBoldWeight.Bold;
info.RowSpan = 1;
info.ColSpan = 1;
info.Owner = info;
info.Text = col.GetExcelHeadText();
exList.Add(info);
++colIdx;
}
List<List<TableCellItem>> dataList = pgc.DataList;
if (dataList != null)
{
foreach (List<TableCellItem> sonList in dataList)
{
if (sonList == null)
continue;
++rowIdx;
idx = -1;
colIdx = 0;
foreach (EkxTableColumn col in CM)
{
// EmTableColumnStatusV == Enums.TableColumnStatus.EmTableColumnStatus.不启用 //
// 需要过滤 //
// 考虑Table里面有无效的列项 //
// 这些列项要过滤,不能++idx //
if (!col.IsEnabled4JsonData())
continue;
++idx;
if (!col.IsExcelExport())
{
continue;
}
info = new ExcelCell_Info();
info.ColNumber = bI.CurCol(colIdx);
info.RowNumber = bI.CurRow(rowIdx);
info.RowSpan = 1;
info.ColSpan = 1;
info.Owner = info;
// info.FontSize = 14;
info.Text = sonList[idx].GetExcelText();
exList.Add(info);
++colIdx;
}
}
}
eKing.ExcelSlowXHelper.Helpers.Helper exHelper
=
eKing.ExcelSlowXHelper.Helpers.Helper.instance;
excelFileName = ch.ToExcelExportFileName(excelFileName);
string fullName = Request.PhysicalApplicationPath
+
excelFileName.Replace("/", "\\");
// list转成Excel输出 //
exHelper.WriteExcelToFile
(
fullName,
exList
);
return excelFileName;
}
/// <summary>
/// 统计图表相关的Excel构建
/// </summary>
/// <param name="excelList"></param>
/// <param name="bI"></param>
/// <param name="eC"></param>
/// <param name="fillTotal"></param>
protected void BuildExcelForStat
(
List<ExcelCell_Info> excelList,
ExcelCellBuildInfo bI,
ECharSeriesReport eC,
bool fillTotal
)
{
ExcelCell_Info ecInfo = null;
List<ECharBasicItem> LegendList = eC.Y.ItemListGet();
List<ECharBasicItem> XList = eC.X.ItemListGet();
double[,] ValueArray = eC.ValueArrayGet();
int countL = LegendList.Count;
int countX = XList.Count;
int rowIndex = 0;
int iCount = 0;
if (fillTotal)
{
iCount = countX + 2;
}
else
{
iCount = countX + 1;
}
for (int i = 0; i < iCount; ++i)
{
ecInfo = new ExcelCell_Info();
ecInfo.ColSpan = 1;
ecInfo.RowSpan = 1;
ecInfo.ColNumber = bI.CurCol(i);
ecInfo.RowNumber = bI.CurRow(rowIndex);
ecInfo.BackColor = HSSFColor.White.Index;
if (i == 0)
ecInfo.Text = "";
else if (i > countX)
{
ecInfo.Text = "合计";
}
else
{
ecInfo.Text = XList[i - 1].TheName;
}
// Excel标题 //
ecInfo.EmExcelCellTypeV
=
ExcelCell_Info.EmExcelCellType.String;
excelList.Add(ecInfo);
}
++rowIndex;
double trTotal = 0;
double allTotal = 0;
for (int j = 0; j < countL; ++j)
{
trTotal = 0;
for (int i = 0; i < iCount; ++i)
{
ecInfo = new ExcelCell_Info();
ecInfo.ColSpan = 1;
ecInfo.RowSpan = 1;
ecInfo.ColNumber = bI.CurCol(i);
ecInfo.RowNumber = bI.CurRow(rowIndex);
ecInfo.BackColor = HSSFColor.White.Index;
if (i == 0)
{
ecInfo.Text = LegendList[j].TheName;
}
else if (i > countX)
{
ecInfo.Text = trTotal.ToString();
}
else
{
trTotal += ValueArray[j, i - 1];
ecInfo.Text = ValueArray[j, i - 1].ToString();
}
// Excel标题 //
ecInfo.EmExcelCellTypeV
=
ExcelCell_Info.EmExcelCellType.String;
excelList.Add(ecInfo);
}
++rowIndex;
}
if (fillTotal)
{
for (int i = 0; i < iCount; ++i)
{
trTotal = 0;
ecInfo = new ExcelCell_Info();
ecInfo.ColSpan = 1;
ecInfo.RowSpan = 1;
ecInfo.ColNumber = bI.CurCol(i);
ecInfo.RowNumber = bI.CurRow(rowIndex);
ecInfo.BackColor = HSSFColor.White.Index;
if (i == 0)
{
ecInfo.Text = "合计";
}
else if (i > countX)
{
ecInfo.Text = allTotal.ToString();
}
else
{
for (int j = 0; j < countL; ++j)
{
trTotal += ValueArray[j, i - 1];
}
ecInfo.Text = trTotal.ToString();
allTotal += trTotal;
}
// Excel标题 //
ecInfo.EmExcelCellTypeV
=
ExcelCell_Info.EmExcelCellType.String;
excelList.Add(ecInfo);
}
}
++rowIndex;
}
/// <summary>
/// NPOI导出统计图表的Excel
/// </summary>
/// <param name="pgc">Excel的导出数据源</param>
/// <param name="excelFileName">Excel的文件名称,如果传入(:导出),生成是系统内置的路径地址</param>
/// <param name="ekg">配置Excel导出的项设置</param>
/// <returns></returns>
protected virtual string EkExportExcelForStat
(
ECharSeriesReport eC,
string excelFileName
)
{
eKingSzdfPageHelper
ch
=
eKingSzdfPageHelper.ekInstance;
List<ExcelCell_Info> exList
=
new List<ExcelCell_Info>();
ExcelCellBuildInfo bI
=
new ExcelCellBuildInfo();
bI.StartCol = 0;
bI.StartRow = 0;
BuildExcelForStat(exList, bI, eC, true);
eKing.ExcelSlowXHelper.Helpers.Helper exHelper
=
eKing.ExcelSlowXHelper.Helpers.Helper.instance;
excelFileName = ch.ToExcelExportFileName(excelFileName);
string fullName = Request.PhysicalApplicationPath
+
excelFileName.Replace("/", "\\");
// list转成Excel输出 //
exHelper.WriteExcelToFile
(
fullName,
exList
);
return excelFileName;
}
/// <summary>
/// 鉴定权限
/// </summary>
/// <param name="filterContext"></param>
public override void CustomVerify(AuthorizationContext filterContext)
{
if (IsDevDebug())
{
// 本地调试模式,屏蔽鉴权 //
return;
}
base.CustomVerify(filterContext);
}
/// <summary>
/// 获得用户权限的值
/// </summary>
/// <returns></returns>
private PageUserSession PageUserSessionGet()
{
try
{
return Session[WebSiteSessions.ZNBM]
as PageUserSession;
}
catch (Exception err)
{
BaseWriteException(err);
return null;
}
}
/// <summary>
/// 设置用户权限的值
/// </summary>
/// <param name="theValue"></param>
private void PageUserSessionSet(PageUserSession theValue)
{
Session[WebSiteSessions.ZNBM] = theValue;
}
/// <summary>
/// 是否调试模式
/// </summary>
/// <returns></returns>
private bool IsDevDebug()
{
return eKing.EkPageCreate.WebCtrls.EkxBase.StaticIsEmDevDebugV();
}
/// <summary>
/// 获得用户的Session
/// </summary>
/// <param name="xdbHelper">数据库链接串</param>
/// <returns></returns>
protected PageUserSession GetUserSession(DBHelper xdbHelper)
{
return GetUserSession(false, xdbHelper);
}
/// <summary>
/// 获得用户的Session
/// </summary>
/// <param name="isReload">重新加载用户信息</param>
/// <param name="xdbHelper">数据库链接串</param>
/// <returns></returns>
protected PageUserSession GetUserSession(bool isReload,DBHelper xdbHelper)
{
eKing.SzdfPage.Helpers.eKingSzdfPageHelper
wh
=
eKing.SzdfPage.Helpers.eKingSzdfPageHelper.ekInstance;
Token tokenV
=
this.Session[WebSiteSessions.Token] as Token;
PageUserSession pu = PageUserSessionGet();
eKing.Szdf_Enum.Enums.WgssRolePower.EmWgssRolePower
emWgssRolePowerV
= eKing.Szdf_Enum.Enums.WgssRolePower.EmWgssRolePower.查看员;
if (tokenV == null
|| tokenV.Employee == null
|| tokenV.Employee.Length == 0)
{
// 如果不是调试模式 //
if (!IsDevDebug())
return null;
if (!isReload)
{
if (pu != null && pu.UserId != null && pu.UserId.Length > 0)
return pu;
}
pu = new PageUserSession();
pu.IsDebug = true;
pu.UserId = "debug";
pu.UserName = "debug";
pu.DepId = wh.HDepartmentGetCode8UserCode
(
pu.UserName,
"-",
xdbHelper
);
emWgssRolePowerV
=
wh.GWgssrolepowerGetEmWgssRolePower(pu.UserId, xdbHelper);
pu.RolePower = new eKing.ZnbmSessionInfo.Classes.Powers.ZnbmRolePower();
pu.RolePower.SetEM((int)emWgssRolePowerV);
PageUserSessionSet(pu);
return pu;
}
if (!isReload)
{
// 不是重新加载登录 //
// 直接返回 //
// 因为Session在Redis服务器中,所以有配置更新不一定容易处理 //
if (pu != null && pu.UserName == tokenV.Employee)
{
return pu;
}
}
// 改成用永哥的用户账号信息 //
//eKing.SzdfLib.Model.HR.UTB_SZDF_HR_USER_ITEM model
// =
// ESH.HrUserItemFindUserModelByUserName
// (
// tokenV.Employee,
// xdbHelper
// );
//if (model == null)
//{
// // 如果不是调试模式 //
// if (!IsDevDebug())
// return null;
// pu = new PageUserSession();
// pu.UserId = tokenV.Employee;
// pu.UserName = tokenV.Employee;
// pu.DepId = wh.HDepartmentGetCode8UserCode
// (
// pu.UserName,
// "-",
// xdbHelper
// );
// pu.RolePower = new ZnbmRolePower(true);
// PageUserSessionSet(pu);
// return pu;
//}
//pu = new PageUserSession();
////pu.UserId = model.UserName;
//pu.UserId = model.ID.ToString();
//pu.UserName = model.UserName;
//pu.DepId = model.Dep_Id.ToString();
//pu.RolePower = new ZnbmRolePower(true);
pu = new PageUserSession();
pu.IsDebug = false;
pu.UserId = tokenV.Employee;
pu.UserName = tokenV.Employee;
pu.DepId = wh.HDepartmentGetCode8UserCode
(
pu.UserName,
"-",
xdbHelper
);
emWgssRolePowerV
=
wh.GWgssrolepowerGetEmWgssRolePower(pu.UserId, xdbHelper);
pu.RolePower = new eKing.ZnbmSessionInfo.Classes.Powers.ZnbmRolePower();
pu.RolePower.SetEM((int)emWgssRolePowerV);
PageUserSessionSet(pu);
return pu;
}
/// <summary>
/// Session当前用户信息ID
/// </summary>
/// <returns></returns>
public virtual string SessionUserIdGet()
{
PageUserSession pu = GetUserSession(null);
if (pu == null)
{
// 如果不是调试模式 //
if (!IsDevDebug())
return "0";
return "debug";
}
return pu.UserId;
}
/// <summary>
/// Session当前用户信息ID
/// </summary>
/// <returns></returns>
public virtual string SessionUserIdGet(DBHelper xdbHelper)
{
PageUserSession pu = GetUserSession(xdbHelper);
if (pu == null)
{
// 如果不是调试模式 //
if (!IsDevDebug())
return "0";
return "debug";
}
return pu.UserId;
}
/// <summary>
/// Session当前用户部门信息ID
/// </summary>
/// <param name="defaultValue">找不到的默认返回值</param>
/// <returns></returns>
public virtual string SessionDepIdGet(string defaultValue, DBHelper xdbHelper)
{
PageUserSession pu = GetUserSession(xdbHelper);
if (pu == null)
{
// 如果不是调试模式 //
if (!IsDevDebug())
return defaultValue;
return defaultValue;
}
return pu.DepId;
}
/// <summary>
/// Session当前用户部门ID
/// </summary>
/// <returns></returns>
public virtual string SessionDepIdGet(DBHelper xdbHelper)
{
PageUserSession pu = GetUserSession(xdbHelper);
if (pu == null)
{
// 如果不是调试模式 //
if (!IsDevDebug())
return "1";
return "1";
}
return pu.DepId;
}
/// <summary>
/// 构建用户信息
/// </summary>
/// <param name="dp"></param>
public virtual void SessionInfoToParam(DetailSaveOperDBParams dp)
{
PageUserSession pu = GetUserSession(null);
if (pu == null)
{
eKing.SzdfPage.Helpers.eKingSzdfPageHelper
wh
=
eKing.SzdfPage.Helpers.eKingSzdfPageHelper.ekInstance;
dp.UserId = "debug";
dp.UserName = "debug";
dp.DepId = wh.HDepartmentGetCode8UserCode
(
"debug",
"-",
null
);
return;
}
dp.UserId = pu.UserId;
dp.UserName = pu.UserName;
dp.DepId = pu.DepId;
}
/// <summary>
/// 构建用户信息
/// </summary>
/// <param name="dp"></param>
/// <param name="xdbHelper"></param>
public virtual void SessionInfoToParam(DetailSaveOperDBParams dp,DBHelper xdbHelper)
{
PageUserSession pu = GetUserSession(xdbHelper);
if (pu == null)
{
dp.UserId = "1";
dp.UserName = "debug";
dp.DepId = "1";
return;
}
dp.UserId = pu.UserId;
dp.UserName = pu.UserName;
dp.DepId = pu.DepId;
}
/// <summary>
/// 上传文件的封装方法(如有需要,可以重载)
/// </summary>
/// <returns></returns>
public virtual OperResult BaseUploadEkFileOper(FileUploadInfoParam fip)
{
OperResult op = new OperResult();
if (Request.Files == null)
{
op.IsSucc = false;
op.Msg = "没有指定上传控件";
return op;
}
int iCount = Request.Files.Count;
if(iCount == 0)
{
op.IsSucc = false;
op.Msg = "没有指定上传控件";
return op;
}
if (fip == null)
{
fip = new FileUploadInfoParam();
fip.InitClass();
}
HttpPostedFileBase fb = Request.Files[0];
eKing.SzdfPage.Helpers.eKingSzdfPageHelper
wh
=
eKing.SzdfPage.Helpers.eKingSzdfPageHelper.ekInstance;
FileUploadInfo fi
=
wh.FileUploadInfoCreate
(
fip.EmUploadFileExV,
fip.EmUploadFileTypeV
);
FileUploadResult fr
=
wh.FileUploadResultCreate(fi, fb);
if (fr.IsError())
{
op.IsSucc = false;
op.Msg = fr.MsgGet();
return op;
}
fr.SaveAsFile(fb, false);
if (fr.IsError())
{
op.IsSucc = false;
op.Msg = fr.MsgGet();
return op;
}
op.IsSucc = true;
op.Msg = fr.FileWebFullName;
return op;
}
#region HTML的select控件的加载 - HtmlSelectLoad
/// <summary>
/// Html的Select控件的加载操作
/// </summary>
/// <param name="xdbHelper"></param>
/// <returns></returns>
public virtual string HtmlSelectLoadOper(DBHelper xdbHelper)
{
const string emFormName = "em";
const string listAddEmFormName = "listAddEm";
// 构建一个赋值的容器 //
// 实现比如: //
// txtd_TheName:eKing //
// txtd_TheCode:SZDF //
ListControlItemContainer KVC
=
new ListControlItemContainer();
eKing.SzdfPage.Enums.LogicDataSource.EmLogicDataSource
em
=
eKing.SzdfPage.Enums.LogicDataSource.GetDefaultEmByString
(
Request.Form[emFormName],
eKing.SzdfPage.Enums.LogicDataSource.EmLogicDataSource.自定义
);
eKing.EkPageCreate.Enums.ListControlAddItem.EmListControlAddItem
emLA
=
eKing.EkPageCreate.Enums.ListControlAddItem.GetDefaultEmByString
(
Request.Form[listAddEmFormName],
eKing.EkPageCreate.Enums.ListControlAddItem.EmListControlAddItem.自定义
);
eKing.SzdfPage.Helpers.eKingSzdfPageHelper
wh
=
eKing.SzdfPage.Helpers.eKingSzdfPageHelper.ekInstance;
List<EkxInputCtrlColumn> dcList = wh.EkxInputCtrlColumnListBuid
(
em,
emLA,
xdbHelper
);
if (dcList != null)
{
foreach (EkxInputCtrlColumn item in dcList)
{
KVC.SetItem(item.CtrlText, item.CtrlValue, false);
}
if (emLA != eKing.EkPageCreate.Enums.ListControlAddItem.EmListControlAddItem.自定义)
{
KVC.SetFirstIsCtrlSelectedTrue();
}
}
return KVC.ToJson();
}
/// <summary>
/// HTML的select控件的加载(如有需要,重载实现)
/// </summary>
/// <returns></returns>
public virtual ActionResult HtmlSelectLoad()
{
string str = HtmlSelectLoadOper(null);
ContentResult theResult = new ContentResult();
theResult.ContentEncoding = UTF8Encoding.UTF8;
theResult.ContentType = MIMETypes.Json;
theResult.Content = str;
return theResult;
}
#endregion HTML的select控件的加载 - HtmlSelectLoad
#region HTML的select控件的加载 - HtmlTreeLoad
/// <summary>
/// Html的Select控件的加载操作
/// </summary>
/// <param name="xdbHelper"></param>
/// <returns></returns>
public virtual string HtmlTreeLoadOper(DBHelper xdbHelper)
{
const string emFormName = "em";
const string listAddEmFormName = "listAddEm";
eKing.SzdfPage.Helpers.eKingSzdfPageHelper
wh
=
eKing.SzdfPage.Helpers.eKingSzdfPageHelper.ekInstance;
ZTreeContainer ztc
=
new ZTreeContainer();
ZTreeItem zti = null;
bool bIsCreate = true;
if (xdbHelper == null)
{
xdbHelper
=
SlowX.DAL.Helpers.DBHelper.CreateDBHelper();
}
else
{
// 没有打开链接 //
bIsCreate = xdbHelper.IsNotOpen();
}
try
{
if (bIsCreate)
xdbHelper.OpenDBHelper();
// wh.
eKing.SzdfPage.Enums.LogicDataSource.EmLogicDataSource
em
=
eKing.SzdfPage.Enums.LogicDataSource.GetDefaultEmByString
(
Request.Form[emFormName],
eKing.SzdfPage.Enums.LogicDataSource.EmLogicDataSource.自定义
);
eKing.EkPageCreate.Enums.ListControlAddItem.EmListControlAddItem
emLA
=
eKing.EkPageCreate.Enums.ListControlAddItem.GetDefaultEmByString
(
Request.Form[listAddEmFormName],
eKing.EkPageCreate.Enums.ListControlAddItem.EmListControlAddItem.自定义
);
// 代码需要修正 //
CoreCacheDataItem dLi = wh.CoreCacheDataItemGetByEmLogicDataSource
(
em,
xdbHelper
);
if (dLi == null)
{
if (bIsCreate)
xdbHelper.EndDBHelper();
return "";
}
if (dLi.IsTree)
{
ZTreeContainerBuild8List
(
ztc,
dLi.DataTableV
);
}
else
{
DataTable dt = dLi.DataTableV;
if (dt != null)
{
foreach (DataRow dr in dt.Rows)
{
if (dr == null)
continue;
zti = new ZTreeItem();
zti.ID = dr["ID"].ToString();
zti.PID = "0";
zti.TheName = dr["TheName"].ToString();
zti.Open = true;
ztc.AddNode(zti);
}
}
}
if (bIsCreate)
xdbHelper.EndDBHelper();
}
catch (Exception err)
{
if (bIsCreate)
xdbHelper.TranDBHelper();
throw err;
}
finally
{
if (bIsCreate)
xdbHelper.FinallyDBHelper();
}
return ztc.ToJson();
}
/// <summary>
///
/// </summary>
/// <param name="ztc"></param>
/// <param name="dt"></param>
protected void ZTreeContainerBuild8List
(
ZTreeContainer ztc,
DataTable dt
)
{
if (dt == null)
return;
ZTreeItem zti = null;
foreach (DataRow dr in dt.Rows)
{
if (dr == null)
continue;
zti = new ZTreeItem();
zti.ID = dr["ID"].ToString();
zti.PID = dr["PID"].ToString();
zti.TheName = dr["TheName"].ToString();
zti.Open = true;
ztc.AddNode(zti);
// ZTreeContainerBuild8List(ztc, model.GetListSon(), parentIdName);
}
}
/// <summary>
/// HTML的select控件的加载(如有需要,重载实现)
/// </summary>
/// <returns></returns>
public virtual ActionResult HtmlTreeLoad()
{
string str = HtmlTreeLoadOper(null);
ContentResult theResult = new ContentResult();
theResult.ContentEncoding = UTF8Encoding.UTF8;
theResult.ContentType = MIMETypes.Json;
theResult.Content = str;
return theResult;
}
#endregion HTML的select控件的加载 - HtmlTreeLoad
/// <summary>
/// HTML的Ajax加载要显示的内容(如有需要,重载实现)
/// </summary>
/// <returns></returns>
public string HtmlLoadInfoOper(DBHelper xdbHelper)
{
eKingSzdfPageHelper
wh
=
eKingSzdfPageHelper.ekInstance;
LoadInfoResult theResult
=
wh.LoadInfoLogic(null, xdbHelper);
if (theResult == null)
return "";
return theResult.ToJson();
}
/// <summary>
/// HTML的Ajax加载要显示的内容(如有需要,重载实现)
/// </summary>
/// <returns></returns>
public virtual ActionResult HtmlLoadInfo()
{
string str = HtmlLoadInfoOper(null);
ContentResult theResult = new ContentResult();
theResult.ContentEncoding = UTF8Encoding.UTF8;
theResult.ContentType = MIMETypes.Json;
theResult.Content = str;
return theResult;
}
/// <summary>
///
/// </summary>
/// <param name="dtNow"></param>
/// <returns></returns>
public UserSaveDataInfo UserSaveDataInfoBuild(DateTime dtNow)
{
UserSaveDataInfo theResult = new UserSaveDataInfo();
theResult.DateTimeNow = dtNow;
PageUserSession pu = GetUserSession(null);
if (pu == null)
{
theResult.UserId = "1";
theResult.UserName = "debug";
theResult.DepId = "1";
return theResult;
}
theResult.UserId = pu.UserId;
theResult.UserName = pu.UserName;
theResult.DepId = pu.DepId;
return theResult;
}
/// <summary>
///
/// </summary>
/// <param name="dtNow"></param>
/// <returns></returns>
public UserSaveDataInfo UserSaveDataInfoBuild(DateTime dtNow,DBHelper xdbHelper)
{
UserSaveDataInfo theResult = new UserSaveDataInfo();
theResult.DateTimeNow = dtNow;
PageUserSession pu = GetUserSession(xdbHelper);
if (pu == null)
{
theResult.UserId = "1";
theResult.UserName = "debug";
theResult.DepId = "1";
return theResult;
}
theResult.UserId = pu.UserId;
theResult.UserName = pu.UserName;
theResult.DepId = pu.DepId;
return theResult;
}
#region 关联文件设置
/// <summary>
/// 保存上传文件的内容
/// </summary>
/// <param name="xdbHelper"></param>
/// <returns></returns>
protected virtual void
BaseFileUploadLinkSaveOperAfter
(
long pkId,
string dataId,
string emLinkTableV,
string fileName,
string fileUrl,
DBHelper xdbHelper
)
{
}
/// <summary>
/// 保存上传文件的内容
/// </summary>
/// <param name="xdbHelper"></param>
/// <returns></returns>
protected OperResult
BaseFileUploadLinkSaveOper(DBHelper xdbHelper)
{
// 数据格式 //
//ajxData = [];
//ajxData.push({ name: "dataid", value: "@Html.Raw(FLI.Data_Id)" });
//ajxData.push({ name: "emlinktablev", value: "@Html.Raw(FLI.EmLinkTableVToInt())" });
//ajxData.push({ name: "filename", value: rData.FileName });
//ajxData.push({ name: "fileurl", value: rData.FileUrl });
string dataId = Request.Form["dataid"];
if (dataId == null || dataId.Length == 0)
{
return OperResult.ToError("发生错误:没有获得关联文件");
}
string emLinkTableV = Request.Form["emlinktablev"];
if (emLinkTableV == null || emLinkTableV.Length == 0)
{
return OperResult.ToError("发生错误:没有获得关联文件");
}
string fileName = Request.Form["filename"];
if (fileName == null || fileName.Length == 0)
{
return OperResult.ToError("发生错误:没有获得上传文件");
}
string fileUrl = Request.Form["fileurl"];
if (fileUrl == null || fileUrl.Length == 0)
{
return OperResult.ToError("发生错误:没有获得上传文件");
}
bool bIsCreate = true;
if (xdbHelper == null)
{
// 如果没有指定数据库链接 //
// 创建数据库链接 //
xdbHelper
=
SlowX.DAL.Helpers.DBHelper.CreateDBHelper();
}
else
{
// 没有打开链接 //
bIsCreate = xdbHelper.IsNotOpen();
}
try
{
if (bIsCreate)
xdbHelper.OpenDBHelper();
OperResult op = _BaseSaveFileOper(xdbHelper);
if (!op.IsSucc)
{
if (bIsCreate)
xdbHelper.EndDBHelper();
return op;
}
// 业务逻辑 //
eKing.SzdfLib.Business.WD.UTB_SZDF_WD_LINK
bll
=
eKing.SzdfLib.Business.WD.UTB_SZDF_WD_LINK.instance;
// 表操作交互字段 //
eKing.SzdfLib.Entity.WD.UTB_SZDF_WD_LINK
entity
=
new eKing.SzdfLib.Entity.WD.UTB_SZDF_WD_LINK();
// 保存相关操作的接口 //
ISaveDriver isave = entity;
long pkId = bll.GetNewLongID();
isave.AddISaveItem(entity._Data_Id, dataId);
isave.AddISaveItem(entity._EmLinkTableV, emLinkTableV);
isave.AddISaveItem(entity._WdItem_Id, op.Msg);
isave.AddISaveItem(entity._TheName, fileName);
DateTime dtNow = bll.GetNow(xdbHelper);
PageUserSession pu = GetUserSession(xdbHelper);
isave.AddISaveItem(entity._CreateTime, dtNow);
isave.AddISaveItem(entity._UpdateTime, dtNow);
isave.AddISaveItem(entity._ShowSeq, pkId);
isave.AddISaveItem(entity._InputDepId, pu.DepId);
isave.AddISaveItem(entity._InputUserId, pu.UserId);
isave.AddISaveItem(entity._LastUpdateDepId, pu.DepId);
isave.AddISaveItem(entity._LastUpdateUserId, pu.UserId);
bll.Insert(entity, xdbHelper);
BaseFileUploadLinkSaveOperAfter
(
pkId,
dataId,
emLinkTableV,
fileName,
fileUrl,
xdbHelper
);
if (bIsCreate)
xdbHelper.EndDBHelper();
}
catch (Exception err)
{
if (bIsCreate)
xdbHelper.TranDBHelper();
throw err;
}
finally
{
if (bIsCreate)
xdbHelper.FinallyDBHelper();
}
// {"IsSucc": true,"Msg":"保存成功"}
return OperResult.ToSucc("保存成功");
}
/// <summary>
/// 保存文件的操作:(基类)
/// </summary>
/// <param name="xdbHelper"></param>
/// <returns></returns>
protected OperResult _BaseSaveFileOper(DBHelper xdbHelper)
{
// 逻辑方法 //
eKing.SzdfPage.Helpers.eKingSzdfPageHelper
wh
=
eKing.SzdfPage.Helpers.eKingSzdfPageHelper.ekInstance;
string fileUrl = Request.Form["fileurl"];
if (fileUrl == null || fileUrl.Length == 0)
{
return OperResult.ToError("发生错误:没有获得上传文件");
}
string fileName = Request.Form["filename"];
if (fileName == null || fileName.Length == 0)
{
return OperResult.ToError("发生错误:没有获得上传文件");
}
// 获得 APP应用下载的文件分类地址 的ID //
// 缺省是 1 //
long sortId = wh.WdSortId4AppUpload();
// 2.保存后的逻辑操作 //
DetailSaveOperDBParams dp
=
new DetailSaveOperDBParams();
bool bIsCreate = true;
if (xdbHelper == null)
{
// 如果没有指定数据库链接 //
// 创建数据库链接 //
xdbHelper
=
SlowX.DAL.Helpers.DBHelper.CreateDBHelper();
}
else
{
// 没有打开链接 //
bIsCreate = xdbHelper.IsNotOpen();
}
try
{
if (bIsCreate)
xdbHelper.OpenDBHelper();
// 业务逻辑 //
eKing.SzdfLib.Business.WD.UTB_SZDF_WD_ITEM
bll
=
eKing.SzdfLib.Business.WD.UTB_SZDF_WD_ITEM.instance;
// 表操作交互字段 //
eKing.SzdfLib.Entity.WD.UTB_SZDF_WD_ITEM
entity
=
new eKing.SzdfLib.Entity.WD.UTB_SZDF_WD_ITEM();
// 保存相关操作的接口 //
ISaveDriver isave = entity;
// 查询相关操作的接口 //
IQueryDriver iq = entity;
dp.DateTimeNow = bll.GetNow(xdbHelper);
SessionInfoToParam(dp);
eKing.SzdfPage.Items.FileUploads.FileWdItem
fdItem = new eKing.SzdfPage.Items.FileUploads.FileWdItem();
fdItem.FileName = fileName;
fdItem.FileUrl = fileUrl;
string newFileUrl = null;
isave.ClearAllISaveItem();
dp.IsInsert = true;
dp.PkId = bll.GetNewID(xdbHelper);
isave.AddISaveItem(entity._TheName, fdItem.FileName);
isave.AddISaveItemByBoolean(entity._IsDelete, false);
isave.AddISaveItem(entity._FileExt, fdItem.ToFileExt());
isave.AddISaveItem(entity._FileSize, fdItem.ToFileSize());
// 获得新文件的地址 //
newFileUrl = fdItem.MoveFile();
isave.AddISaveItem(entity._FileUrl, newFileUrl);
isave.AddISaveItem(entity._EmWdTypeV, (int)eKing.Szdf_Enum.Enums.WdType.EmWdType.应用上传的永久文档);
isave.AddISaveItem(entity._PowerData, dp.DepId);
isave.AddISaveItem(entity._LastUpdateUserId, dp.UserId);
isave.AddISaveItem(entity._LastUpdateDepId, dp.DepId);
isave.AddISaveItem(entity._UpdateTime, dp.DateTimeNow);
isave.AddISaveItem(entity._CreateTime, dp.DateTimeNow);
isave.AddISaveItem(entity._CreateUserName, dp.UserName);
isave.AddISaveItem(entity._InputUserId, dp.UserId);
isave.AddISaveItem(entity._InputDepId, dp.DepId);
isave.AddISaveItem(entity._Pub_Time, dp.DateTimeNow);
isave.AddISaveItem(entity._ID, dp.PkId);
isave.AddISaveItem(entity._EmWdShowV,
(int)eKing.Szdf_Enum.Enums.WdShow.EmWdShow.部门可见);
isave.AddISaveItem(entity._SortId, sortId);
isave.AddISaveItem(entity._Pub_Time, dp.DateTimeNow);
bll.Insert(entity, xdbHelper);
if (bIsCreate)
xdbHelper.EndDBHelper();
}
catch (Exception err)
{
if (bIsCreate)
xdbHelper.TranDBHelper();
throw err;
}
finally
{
if (bIsCreate)
xdbHelper.FinallyDBHelper();
}
try
{
// 多服务器同步 //
wh.FileHttpPostToOtherAPP(dp.PkId);
}
catch
{
}
try
{
// 开启线程实现文件的转义成PDF //
wh.FileConvertToPDF(dp.PkId);
}
catch
{
}
// {"IsSucc": true,"Msg":"保存成功"}
return OperResult.ToSucc(dp.PkId);
}
/// <summary>
/// 保存文件和关联
/// </summary>
public ActionResult BaseFileUploadLinkSave()
{
OperResult op = null;
try
{
op = BaseFileUploadLinkSaveOper(null);
}
catch (Exception err)
{
op = OperResult.ToError("发生异常:" + err.Message);
}
ContentResult theResult = new ContentResult();
theResult.ContentEncoding = UTF8Encoding.UTF8;
theResult.ContentType = MIMETypes.Json;
theResult.Content = op.ToJson();
return theResult;
}
#endregion 关联文件设置
/// <summary>
/// 打印和输出异常 - GetExceptionInfo
/// </summary>
/// <param name="err"></param>
/// <returns></returns>
private string GetExceptionInfo(Exception err)
{
StringBuilder theResult = new StringBuilder();
theResult.AppendLine("err.Message:" + err.Message);
theResult.AppendLine("err.Source:" + err.Source);
if (err.TargetSite != null)
{
theResult.AppendLine("err.TargetSite:"
+ err.TargetSite.ReflectedType.FullName
+ " "
+ err.TargetSite.Name);
}
theResult.AppendLine("err.StackTrace:" + err.StackTrace);
return theResult.ToString();
}
/// <summary>
/// 写入异常日志
/// </summary>
/// <param name="err"></param>
protected void BaseWriteException(Exception err)
{
if (err == null)
return;
// 登记异常 //
AppGlobalRunInfo.StaticExceptionAdd(err);
// 写入异常日志 //
try
{
string str = GetExceptionInfo(err);
Log4NetRecord.RecordText
(
str,
SlowX.Log4Net.Enums.LogFun.EmLogFun.Exception
);
}
catch(Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
/// <summary>
/// 是否职能部门管理员
/// </summary>
/// <param name="xdbHelper"></param>
/// <returns></returns>
protected bool UserIsZnbmAdmin(DBHelper xdbHelper)
{
AppConfigInfo ACI = AppConfigInfo.instance;
if (ACI == null)
return false;
string userId = SessionUserIdGet(xdbHelper);
if (ACI.IsZnbmAdmin(userId))
{
// 如果是职能部门管理员 //
// 返回全部 //
return true;
}
return false;
}
}
}
/// <summary>
/// 开发调测
/// </summary>
public readonly static DevTrackContainer
devTrackContainerV
=
new DevTrackContainer();
/// <summary>
///
/// </summary>
protected string DevTrackGuid
=
System.Guid.NewGuid().ToString();
/// <summary>
/// 打印调测信息
/// </summary>
/// <returns></returns>
protected string PrintDevTrack()
{
if (devTrackContainerV == null)
return "";
List<DevTrackItem> itemList = devTrackContainerV.GetList();
if (itemList == null)
return "";
int iCount = itemList.Count;
if (iCount == 0)
return "-";
StringBuilder theResult = new StringBuilder();
theResult.Append("<table border=\"1\" width=\"100%\">");
DevTrackItem di = null;
int idx = 0;
for (int i = iCount - 1; i >= 0; --i)
{
++idx;
di = itemList[i];
theResult.Append("<tr>");
theResult.Append("<td width=\"40px\">" + idx.ToString() + "</td>");
theResult.Append("<td>");
theResult.Append(di.PrintHTML());
theResult.Append("</td>");
theResult.Append("</tr>");
}
theResult.Append("</table>");
return theResult.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="emV"></param>
/// <param name="dtStart"></param>
/// <param name="dtEnd"></param>
protected void AddDevTrackItem
(
eKing.SzdfPage.Enums.DevTrackPoint.EmDevTrackPoint emV,
DateTime dtStart,
DateTime dtEnd
)
{
if (devTrackContainerV == null)
return;
if (devTrackContainerV.ListCount() > 100)
{
devTrackContainerV.ListClear();
}
devTrackContainerV.AddItem
(
this.GetType().FullName,
DevTrackGuid,
emV,
dtStart,
dtEnd
);
}
/// <summary>
///
/// </summary>
/// <param name="emV"></param>
/// <param name="dtStart"></param>
/// <param name="dtEnd"></param>
protected void AddDevTrackItem4Token
(
)
{
if (devTrackContainerV == null)
return;
if (devTrackContainerV.ListCount() > 10)
{
devTrackContainerV.ListClear();
}
DateTime dtStart = DateTime.Now;
DateTime dtEnd = DateTime.Now;
Token tokenV
=
this.Session[WebSiteSessions.Token] as Token;
dtEnd = DateTime.Now;
string UserId = "";
if (tokenV == null || tokenV.Employee == null || tokenV.Employee.Length == 0)
{
UserId = "debug";
}
else
{
UserId = tokenV.Employee;
}
if (devTrackContainerV == null)
return;
if (devTrackContainerV.ListCount() > 100)
{
devTrackContainerV.ListClear();
}
// 登记Token //
devTrackContainerV.AddItem4Token
(
this.GetType().FullName,
DevTrackGuid,
UserId,
dtStart,
dtEnd
);
}
///// <summary>
///// 构建性能调试
///// </summary>
///// <returns></returns>
//protected DevTrackItem DevTrackItemCreate()
//{
// // 判断是否构建 //
// DevTrackItem theResult = new DevTrackItem();
// theResult.PageClassName = this.GetType().FullName;
// theResult.DT4Sessoin.StartTime = DateTime.Now;
// Token tokenV
// =
// this.Session[WebSiteSessions.Token] as Token;
// theResult.DT4Sessoin.EndTime = DateTime.Now;
// if(tokenV==null||tokenV.Employee==null||tokenV.Employee.Length == 0)
// {
// theResult.UserId = "debug";
// }
// else
// {
// theResult.UserId = tokenV.Employee;
// }
// return theResult;
//}
上一条:
下一条:
相关评论
发表评论