|
|
@ -2963,7 +2963,7 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
public async Task<Dictionary<String, Object>> getPostCommonAES(JObject param) |
|
|
|
public async Task<Dictionary<string, object>> getPostCommonAES(JObject param) |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
@ -3047,107 +3047,178 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon |
|
|
|
// 导出Excel ExportExcel 直接下载 ExportExcel2 预下载 |
|
|
|
// 导出Excel ExportExcel 直接下载 ExportExcel2 预下载 |
|
|
|
if (_commonType == "ExportExcel" || _commonType == "ExportExcel2") |
|
|
|
if (_commonType == "ExportExcel" || _commonType == "ExportExcel2") |
|
|
|
{ |
|
|
|
{ |
|
|
|
// tisking 20240118 add 保存当前导出列 |
|
|
|
} |
|
|
|
//string SaveEEConfig = string.Format(@" |
|
|
|
|
|
|
|
// delete [dbo].[Ghrs_ExportExcelByUserConfig] where UserID = {0} and MenuName = '{1}'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// insert into [dbo].[Ghrs_ExportExcelByUserConfig] |
|
|
|
|
|
|
|
// (UserID,MenuName,ExportSet,CreateBy,CreateProg,CreateTime) |
|
|
|
|
|
|
|
// select {0} ,'{1}','{2}',{0},'GHR30.getPostCommonAES.ExportExcel2',GETDATE()", |
|
|
|
|
|
|
|
// userID, menuName, exportSet); |
|
|
|
|
|
|
|
//try |
|
|
|
|
|
|
|
//{ |
|
|
|
|
|
|
|
// await Db.Ado.ExecuteCommandAsync(SaveEEConfig); |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
//catch (Exception) |
|
|
|
|
|
|
|
//{ |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//IList<NPOIModel> list = new List<NPOIModel>(); |
|
|
|
|
|
|
|
//string TableTitle = ""; |
|
|
|
|
|
|
|
//string fileName = ""; |
|
|
|
|
|
|
|
//for (int RowNums = 0; RowNums < ds.Tables.Count; RowNums = RowNums + 2) |
|
|
|
|
|
|
|
//{ |
|
|
|
|
|
|
|
// DataTable Exdt = ds.Tables[RowNums]; |
|
|
|
|
|
|
|
// string Fileds = ds.Tables[RowNums + 1].Rows[0]["Fileds"].ToString(); |
|
|
|
|
|
|
|
// string HeaderName = ds.Tables[RowNums + 1].Rows[0]["HeaderName"].ToString(); |
|
|
|
|
|
|
|
// TableTitle = ds.Tables[RowNums + 1].Rows[0]["TableTitle"].ToString(); |
|
|
|
|
|
|
|
// string IsTitle = ds.Tables[RowNums + 1].Rows[0]["IsTitle"].ToString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// string SheetName = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// try |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// fileName = ds.Tables[RowNums + 1].Rows[0]["FileName"].ToString(); |
|
|
|
|
|
|
|
// SheetName = ds.Tables[RowNums + 1].Rows[0]["SheetName"].ToString(); |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// catch (Exception) |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (string.IsNullOrEmpty(fileName)) |
|
|
|
|
|
|
|
// fileName = TableTitle; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //关键字替换 |
|
|
|
|
|
|
|
// string invalidChars = @"[\\/:*?""<>|]"; // 使用正则表达式替换特殊符号为空字符串 |
|
|
|
|
|
|
|
// fileName = Regex.Replace(fileName, invalidChars, ""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// int TitleFontSize = Convert.ToInt32(ds.Tables[RowNums + 1].Rows[0]["TitleFontSize"].ToString()); |
|
|
|
// 此块为存储过程返回的信息 DT_ProcedureResult |
|
|
|
// int HeadFontSize = Convert.ToInt32(ds.Tables[RowNums + 1].Rows[0]["HeadFontSize"].ToString()); |
|
|
|
DataTable DT_ProcedureResult = null; |
|
|
|
// int BodyFontSize = Convert.ToInt32(ds.Tables[RowNums + 1].Rows[0]["BodyFontSize"].ToString()); |
|
|
|
DataTable dt = ds.Tables[0]; |
|
|
|
// int DefaultWidth = Convert.ToInt32(ds.Tables[RowNums + 1].Rows[0]["DefaultWidth"].ToString()); |
|
|
|
string strJson = "{"; |
|
|
|
|
|
|
|
int i = 1; |
|
|
|
|
|
|
|
foreach (DataColumn dc in dt.Columns) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (dt.Rows[0][dc.ColumnName].ToString() == "DT_ProcedureResult") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
DT_ProcedureResult = ds.Tables[i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
strJson = strJson + "\"" + dt.Rows[0][dc.ColumnName].ToString() + "\":"; |
|
|
|
|
|
|
|
String json = JsonConvert.SerializeObject(ds.Tables[i]); |
|
|
|
|
|
|
|
|
|
|
|
// DefaultWidth = 0; |
|
|
|
bool tableIsJson = false; |
|
|
|
|
|
|
|
// 根据 table 的栏位名是否为 #Json#开头来判断,是否有Json对象 |
|
|
|
|
|
|
|
foreach (DataColumn dcDetail in ds.Tables[i].Columns) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (dcDetail.ColumnName.StartsWith("#Json#")) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
tableIsJson = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (tableIsJson) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
dynamic dyn = JsonConvert.DeserializeObject(json); |
|
|
|
|
|
|
|
// DT_TableDataT1 |
|
|
|
|
|
|
|
if (ds.Tables[i].Rows.Count == 1 && (!dt.Rows[0][dc.ColumnName].ToString().StartsWith("DT_TableData")))// 单行数据 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var obj = dyn[0]; |
|
|
|
|
|
|
|
foreach (DataColumn dcDetail in ds.Tables[i].Columns) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (dcDetail.ColumnName.StartsWith("#Json#")) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
obj[dcDetail.ColumnName] = (JToken)JsonConvert.DeserializeObject((string)obj[dcDetail.ColumnName]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch { } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
dyn = obj; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (var obj in dyn) // 逐行逐列判断 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (DataColumn dcDetail in ds.Tables[i].Columns) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (dcDetail.ColumnName.StartsWith("#Json#")) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
obj[dcDetail.ColumnName] = (JToken)JsonConvert.DeserializeObject((string)obj[dcDetail.ColumnName]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch { } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
json = JsonConvert.SerializeObject(dyn); |
|
|
|
|
|
|
|
json = json.Replace("#Json#", ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
strJson = strJson + json; |
|
|
|
|
|
|
|
if (i < ds.Tables.Count - 1) // 第一个table定义 各表的内容 |
|
|
|
|
|
|
|
strJson = strJson + ","; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
i = i + 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
strJson = strJson + "}"; |
|
|
|
|
|
|
|
string isOK = "0"; |
|
|
|
|
|
|
|
string ErrorMsg = ""; |
|
|
|
|
|
|
|
string WarnMsg = ""; |
|
|
|
|
|
|
|
string SuccessMsg = ""; |
|
|
|
|
|
|
|
string type = "success"; |
|
|
|
|
|
|
|
string message = ""; |
|
|
|
|
|
|
|
if (DT_ProcedureResult.Rows.Count == 1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
isOK = DT_ProcedureResult.Rows[0]["IsOK"].ToString(); |
|
|
|
|
|
|
|
ErrorMsg = DT_ProcedureResult.Rows[0]["ErrorMsg"].ToString(); |
|
|
|
|
|
|
|
WarnMsg = DT_ProcedureResult.Rows[0]["WarnMsg"].ToString(); |
|
|
|
|
|
|
|
SuccessMsg = DT_ProcedureResult.Rows[0]["SuccessMsg"].ToString(); |
|
|
|
|
|
|
|
if (isOK == "0") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(WarnMsg)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type = "warning"; |
|
|
|
|
|
|
|
message = WarnMsg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type = "success"; |
|
|
|
|
|
|
|
message = SuccessMsg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type = "error"; |
|
|
|
|
|
|
|
message = ErrorMsg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var data = new Dictionary<string, object> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
{"result", JObject.Parse(strJson)}, |
|
|
|
|
|
|
|
{"message",message}, |
|
|
|
|
|
|
|
{"type",type}, |
|
|
|
|
|
|
|
{"code",int.Parse(isOK)} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
foreach (DataColumn dcProcedureResult in DT_ProcedureResult.Columns) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (dcProcedureResult.ColumnName != "IsOK" && dcProcedureResult.ColumnName != "ErrorMsg" && |
|
|
|
|
|
|
|
dcProcedureResult.ColumnName != "WarnMsg" && dcProcedureResult.ColumnName != "SuccessMsg") |
|
|
|
|
|
|
|
data.Add(dcProcedureResult.ColumnName, DT_ProcedureResult.Rows[0][dcProcedureResult.ColumnName].ToString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return data; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var data = new Dictionary<string, object> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
{"result", "{}"}, |
|
|
|
|
|
|
|
{"message",e.Message}, |
|
|
|
|
|
|
|
{"type","error"}, |
|
|
|
|
|
|
|
{"code",1} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return data; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<Dictionary<string, object>> getPostCommon(JObject param) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
string procName = ""; |
|
|
|
|
|
|
|
string _commonType = ""; // 类别 |
|
|
|
|
|
|
|
string userID = ""; |
|
|
|
|
|
|
|
IEnumerable<JProperty> properties = param.Properties(); |
|
|
|
|
|
|
|
var dic = new Dictionary<string, object>(); |
|
|
|
|
|
|
|
foreach (JProperty item in properties) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (item.Name == "procName") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
procName = item.Value.ToString(); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// list.Add(new NPOIModel(Exdt, |
|
|
|
if (item.Name == "commonType") |
|
|
|
// Fileds, //字段 |
|
|
|
{ |
|
|
|
// !String.IsNullOrEmpty(SheetName) ? SheetName : TableTitle, //sheetName |
|
|
|
_commonType = item.Value.ToString(); |
|
|
|
// HeaderName, //表头 |
|
|
|
continue; |
|
|
|
// IsTitle == "Y" ? TableTitle : "",// 标题 |
|
|
|
} |
|
|
|
// 0,// 是否添加序号 |
|
|
|
if (item.Name == "userId") |
|
|
|
// TitleFontSize, // 标题大小 |
|
|
|
{ |
|
|
|
// HeadFontSize, // 表头大小 |
|
|
|
userID = item.Value.ToString(); |
|
|
|
// BodyFontSize, // 正文大小 |
|
|
|
} |
|
|
|
// DefaultWidth // 默认宽度 0为自适应 其余值为默认宽度 需大于0 |
|
|
|
|
|
|
|
// )); |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
//string ExportMessage = "导出成功"; |
|
|
|
|
|
|
|
//string ExportType = "success"; |
|
|
|
|
|
|
|
//int ExportCode = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//// 文件名称 |
|
|
|
string jokey = item.Name; |
|
|
|
//fileName = fileName + "_" + userID + "_" + (DateTime.Now.ToString("yyyyMMddHHmmssfff")) + ".xls"; |
|
|
|
string joValue = item.Value.ToString(); |
|
|
|
//if (_commonType == "ExportExcel2") |
|
|
|
dic.Add(jokey, joValue); |
|
|
|
//{ |
|
|
|
|
|
|
|
// try |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// NPOIHelper.ExportPath(fileName, list, menuName); |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// catch (Exception ex) |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// ExportMessage = "导出失败:" + ex.ToString(); |
|
|
|
|
|
|
|
// ExportType = "error"; |
|
|
|
|
|
|
|
// ExportCode = 1; |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// Dictionary<String, Object> excelData = new Dictionary<String, Object>{ |
|
|
|
|
|
|
|
// {"result", ""}, |
|
|
|
|
|
|
|
// {"tableTitle", TableTitle}, |
|
|
|
|
|
|
|
// {"fileName", @"\File\DownLoad\"+fileName}, |
|
|
|
|
|
|
|
// {"message",ExportMessage}, |
|
|
|
|
|
|
|
// {"type",ExportType}, |
|
|
|
|
|
|
|
// {"code",ExportCode} |
|
|
|
|
|
|
|
// }; |
|
|
|
|
|
|
|
// return Json(excelData); |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
//// 直接下载 |
|
|
|
|
|
|
|
//if (_commonType == "ExportExcel1") |
|
|
|
|
|
|
|
//{ |
|
|
|
|
|
|
|
// return ResponseMessage(NPOIHelper.ExportResponse(fileName, list)); |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// procName = "PT_GHR30_Menu_GetWhere"; |
|
|
|
|
|
|
|
// DataTable dtResult = DataAccess.SelectDate("Demo", procName, spParaList); |
|
|
|
|
|
|
|
// DataSet ds = GetProcedureDateSet("Demo", procName, "63", "1", "", "", "", "N", "", "1", "100", "3"); |
|
|
|
|
|
|
|
DataSet ds = await Db.Ado.UseStoredProcedure().GetDataSetAllAsync(procName, dic); |
|
|
|
|
|
|
|
// 导出Excel ExportExcel 直接下载 ExportExcel2 预下载 |
|
|
|
|
|
|
|
|
|
|
|
// 此块为存储过程返回的信息 DT_ProcedureResult |
|
|
|
// 此块为存储过程返回的信息 DT_ProcedureResult |
|
|
|
DataTable DT_ProcedureResult = null; |
|
|
|
DataTable DT_ProcedureResult = null; |
|
|
|
DataTable dt = ds.Tables[0]; |
|
|
|
DataTable dt = ds.Tables[0]; |
|
|
@ -3189,7 +3260,8 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon |
|
|
|
{ |
|
|
|
{ |
|
|
|
obj[dcDetail.ColumnName] = (JToken)JsonConvert.DeserializeObject((string)obj[dcDetail.ColumnName]); |
|
|
|
obj[dcDetail.ColumnName] = (JToken)JsonConvert.DeserializeObject((string)obj[dcDetail.ColumnName]); |
|
|
|
} |
|
|
|
} |
|
|
|
catch { } |
|
|
|
catch |
|
|
|
|
|
|
|
{ } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
dyn = obj; |
|
|
|
dyn = obj; |
|
|
@ -3206,7 +3278,8 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon |
|
|
|
{ |
|
|
|
{ |
|
|
|
obj[dcDetail.ColumnName] = (JToken)JsonConvert.DeserializeObject((string)obj[dcDetail.ColumnName]); |
|
|
|
obj[dcDetail.ColumnName] = (JToken)JsonConvert.DeserializeObject((string)obj[dcDetail.ColumnName]); |
|
|
|
} |
|
|
|
} |
|
|
|
catch { } |
|
|
|
catch |
|
|
|
|
|
|
|
{ } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -3251,6 +3324,22 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon |
|
|
|
type = "error"; |
|
|
|
type = "error"; |
|
|
|
message = ErrorMsg; |
|
|
|
message = ErrorMsg; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(isOK)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type = "error"; |
|
|
|
|
|
|
|
message = ErrorMsg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (!string.IsNullOrEmpty(WarnMsg)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type = "warning"; |
|
|
|
|
|
|
|
message = WarnMsg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(SuccessMsg)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type = "success"; |
|
|
|
|
|
|
|
message = SuccessMsg; |
|
|
|
|
|
|
|
} */ |
|
|
|
} |
|
|
|
} |
|
|
|
var data = new Dictionary<string, object> |
|
|
|
var data = new Dictionary<string, object> |
|
|
|
{ |
|
|
|
{ |
|
|
@ -3279,5 +3368,4 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon |
|
|
|
return data; |
|
|
|
return data; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|