From 94d0b18fa47a92a1cb4d1fef4520d35ef2c2c322 Mon Sep 17 00:00:00 2001
From: wbc <2597324127@qq.com>
Date: 星期二, 16 十二月 2025 21:56:49 +0800
Subject: [PATCH] 产能排产相关后端更新
---
WebApi/Gs.Report/XlsInOutController.cs | 300 ++++++++++++++++++++++++++----------------------------------
1 files changed, 130 insertions(+), 170 deletions(-)
diff --git a/WebApi/Gs.Report/XlsInOutController.cs b/WebApi/Gs.Report/XlsInOutController.cs
index 3606252..78a536f 100644
--- a/WebApi/Gs.Report/XlsInOutController.cs
+++ b/WebApi/Gs.Report/XlsInOutController.cs
@@ -2,7 +2,6 @@
using System.Data;
using System.Data.SqlClient;
using System.Dynamic;
-using System.Text;
using Gs.Toolbox;
using Gs.Toolbox.ApiCore.Abstract.Mvc;
using Gs.Toolbox.ApiCore.Common.Mvc;
@@ -28,10 +27,9 @@
}
/// <summary>
- /// 閫氱敤瀛樺偍杩囩▼鎵ц鏂规硶
+ /// 閫氱敤瀛樺偍杩囩▼鎵ц鏂规硶
/// </summary>
- private DataSet RunProcedure(string procName,
- IDictionary<string, object> paramDict)
+ private DataSet RunProcedure(string procName, IDictionary<string, object> paramDict)
{
var dset = new DataSet();
using (var conn = new SqlConnection(DbHelperSQL.strConn))
@@ -41,17 +39,15 @@
comm.CommandType = CommandType.StoredProcedure;
// 鍔ㄦ�佹坊鍔犲弬鏁�
foreach (var kvp in paramDict)
- comm.Parameters.AddWithValue("@" + kvp.Key,
- kvp.Value == null
- ? DBNull.Value
- : kvp.Value.ToString());
+ {
+ comm.Parameters.AddWithValue("@" + kvp.Key, kvp.Value == null? DBNull.Value : kvp.Value.ToString());
+ }
using (var adapter = new SqlDataAdapter(comm))
{
adapter.Fill(dset, "0");
}
}
}
-
return dset;
}
@@ -62,13 +58,14 @@
var paramDict = new Dictionary<string, object>();
// 鍔ㄦ�佽В鏋愬弬鏁�
if (mode.outParams != null)
+ {
foreach (var prop in mode.outParams)
{
string name = prop.Name;
object value = prop.Value;
paramDict.Add(name, value);
}
-
+ }
var _pdfFloder = AppSettingsHelper.getValueByKey("DownPath");
var _pdfName = Guid.NewGuid() + ".xls";
var _pdfSaveFolder = Path.Combine(AppContext.BaseDirectory, _pdfFloder);
@@ -80,24 +77,21 @@
{
var dset = RunProcedure(rptParameter, paramDict);
if (dset == null || dset.Tables.Count <= 0)
- return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception,
- "娌℃湁鏌ヨ鍒颁换浣曟暟鎹�");
+ return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception, "娌℃湁鏌ヨ鍒颁换浣曟暟鎹�");
var ary = new ArrayList();
ExcelHelper.ExportAryHead(dset.Tables[0], ary, pdfSavePath);
m.fileUrl = "down/" + _pdfName;
- return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success,
- "璇诲彇鎴愬姛锛�");
+ return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "璇诲彇鎴愬姛锛�");
}
catch (Exception ex)
{
LogHelper.Debug(ToString(), ex.Message);
- return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception,
- "璇诲彇澶辫触," + ex.Message);
+ return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception, "璇诲彇澶辫触," + ex.Message);
}
}
/// <summary>
- /// 鏁版嵁瀵煎嚭锛岄渶瑕佸瓨鍌ㄨ繃绋嬫敮鎾戯紝鐩墠娌$敤鍒�
+ /// 鏁版嵁瀵煎嚭锛岄渶瑕佸瓨鍌ㄨ繃绋嬫敮鎾戯紝鐩墠娌$敤鍒�
/// </summary>
/// <param name="mode"></param>
/// <returns></returns>
@@ -138,7 +132,6 @@
dt.Fill(dset, "0");
}
}
-
conn.Close();
}
@@ -179,7 +172,7 @@
#region 鍚勭瀵煎嚭
/// <summary>
- /// 瀵煎嚭棣栨
+ /// 瀵煎嚭棣栨
/// </summary>
/// <param name="mode"></param>
/// <returns></returns>
@@ -196,18 +189,15 @@
dynamic m = new ExpandoObject();
//璇绘暟鎹�
var dset = new DataSet();
- SqlParameter[] parameters =
- {
+ SqlParameter[] parameters ={
new("@inMainGuid", guid),
new("@inP1", ""),
new("@inP2", ""),
new("@inP3", ""),
- new("@inP4", "")
- };
+ new("@inP4", "")};
try
{
- dset = DbHelperSQL.RunProcedure("[xlsOutShouJian]", parameters,
- "0");
+ dset = DbHelperSQL.RunProcedure("[xlsOutShouJian]", parameters, "0");
if (dset == null || dset.Tables.Count <= 0)
return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception,
"娌℃湁鏌ヨ鍒颁换浣曟暟鎹�");
@@ -226,7 +216,7 @@
}
/// <summary>
- /// 瀵煎嚭iqc妫�
+ /// 瀵煎嚭iqc妫�
/// </summary>
/// <param name="mode"></param>
/// <returns></returns>
@@ -243,14 +233,12 @@
dynamic m = new ExpandoObject();
//璇绘暟鎹�
var dset = new DataSet();
- SqlParameter[] parameters =
- {
+ SqlParameter[] parameters ={
new("@inMainGuid", guid),
new("@inP1", ""),
new("@inP2", ""),
new("@inP3", ""),
- new("@inP4", "")
- };
+ new("@inP4", "")};
try
{
dset = DbHelperSQL.RunProcedure("[xlsOutIqc]", parameters, "0");
@@ -273,7 +261,7 @@
/// <summary>
- /// 瀵煎嚭宸℃
+ /// 瀵煎嚭宸℃
/// </summary>
/// <param name="mode"></param>
/// <returns></returns>
@@ -290,14 +278,12 @@
dynamic m = new ExpandoObject();
//璇绘暟鎹�
var dset = new DataSet();
- SqlParameter[] parameters =
- {
+ SqlParameter[] parameters ={
new("@inMainGuid", guid),
new("@inP1", ""),
new("@inP2", ""),
new("@inP3", ""),
- new("@inP4", "")
- };
+ new("@inP4", "")};
try
{
dset = DbHelperSQL.RunProcedure("[xlsOutXunJian]", parameters, "0");
@@ -319,7 +305,7 @@
}
/// <summary>
- /// 瀵煎嚭鎴愬搧妫�楠屾姤鍛�
+ /// 瀵煎嚭鎴愬搧妫�楠屾姤鍛�
/// </summary>
/// <param name="mode"></param>
/// <returns></returns>
@@ -336,18 +322,15 @@
dynamic m = new ExpandoObject();
//璇绘暟鎹�
var dset = new DataSet();
- SqlParameter[] parameters =
- {
+ SqlParameter[] parameters ={
new("@inMainGuid", guid),
new("@inP1", ""),
new("@inP2", ""),
new("@inP3", ""),
- new("@inP4", "")
- };
+ new("@inP4", "")};
try
{
- dset = DbHelperSQL.RunProcedure("[xlsOutChengPin]", parameters,
- "0");
+ dset = DbHelperSQL.RunProcedure("[xlsOutChengPin]", parameters, "0");
if (dset == null || dset.Tables.Count <= 0)
return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception,
"娌℃湁鏌ヨ鍒颁换浣曟暟鎹�");
@@ -364,54 +347,52 @@
"璇诲彇澶辫触," + ex.Message);
}
}
-
#endregion
- #region 鍚勭瀵煎叆
-
+ #region 鍚勭瀵煎叆
/// <summary>
- /// 妫�楠屽伐鍏峰鍏�
+ /// 妫�楠屽伐鍏峰鍏�
/// </summary>
/// <param name="tmpGuid"></param>
/// <returns></returns>
[RequestMethod(RequestMethods.POST)]
public ReturnDto<int?> XlsInJygj([FromBody] dynamic mode)
{
- var dic = new Dictionary<string, string>
+ Dictionary<string, string> dic = new Dictionary<string, string>
{
- { "鍚嶇О", "t1" }
+ { "鍚嶇О", "t1" },
};
string tmpGuid = mode.tmpGuid;
int? rtnInt = (int)ReturnCode.Default;
- int? _it = 0; //杩斿洖鐨勮鏁�
- var _msg = ""; //杩斿洖鐨勪俊鎭�
+ int? _it = 0;//杩斿洖鐨勮鏁�
+ string _msg = "";//杩斿洖鐨勪俊鎭�
(_it, _msg) = getTable(tmpGuid, dic);
if (_it <= 0)
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception,
- _msg);
- var sbMsg = new StringBuilder();
- using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, _msg);
+ System.Text.StringBuilder sbMsg = new System.Text.StringBuilder();
+ using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn))
{
- using (var cmd = new SqlCommand("[xlsInJygj]", conn))
+ using (SqlCommand cmd = new SqlCommand("[xlsInJygj]", conn))
{
try
{
conn.Open();
cmd.CommandType = CommandType.StoredProcedure;
- var parameters = new[]
- {
- new SqlParameter("@outGuid", SqlDbType.NVarChar, 100),
- new SqlParameter("@outMsg", SqlDbType.NVarChar, 300),
- new SqlParameter("@inEdtUserGuid", _userGuid),
- new SqlParameter("@tmpGuid", tmpGuid)
- };
+ SqlParameter[] parameters = new SqlParameter[] {
+ new SqlParameter("@outGuid",SqlDbType.NVarChar,100),
+ new SqlParameter("@outMsg",SqlDbType.NVarChar,300),
+ new SqlParameter("@inEdtUserGuid",_userGuid),
+ new SqlParameter("@tmpGuid",tmpGuid),
+ };
parameters[0].Direction = ParameterDirection.Output;
parameters[1].Direction = ParameterDirection.Output;
- foreach (var parameter in parameters)
+ foreach (SqlParameter parameter in parameters)
+ {
cmd.Parameters.Add(parameter);
+ }
rtnInt = cmd.ExecuteNonQuery();
- sbMsg.Append(parameters[1].Value);
+ sbMsg.Append(parameters[1].Value.ToString());
}
catch (Exception ex)
{
@@ -424,57 +405,54 @@
}
}
}
-
if (rtnInt <= 0)
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception,
- sbMsg.ToString());
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success,
- sbMsg.ToString());
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, sbMsg.ToString());
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success, sbMsg.ToString());
}
/// <summary>
- /// 妫�楠岄」鐩鍏�
+ /// 妫�楠岄」鐩鍏�
/// </summary>
/// <param name="tmpGuid"></param>
/// <returns></returns>
[RequestMethod(RequestMethods.POST)]
public ReturnDto<int?> XlsInJyxm([FromBody] dynamic mode)
{
- var dic = new Dictionary<string, string>
+ Dictionary<string, string> dic = new Dictionary<string, string>
{
- { "鍚嶇О", "t1" }
+ { "鍚嶇О", "t1" },
};
string tmpGuid = mode.tmpGuid;
int? rtnInt = (int)ReturnCode.Default;
- int? _it = 0; //杩斿洖鐨勮鏁�
- var _msg = ""; //杩斿洖鐨勪俊鎭�
+ int? _it = 0;//杩斿洖鐨勮鏁�
+ string _msg = "";//杩斿洖鐨勪俊鎭�
(_it, _msg) = getTable(tmpGuid, dic);
if (_it <= 0)
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception,
- _msg);
- var sbMsg = new StringBuilder();
- using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, _msg);
+ System.Text.StringBuilder sbMsg = new System.Text.StringBuilder();
+ using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn))
{
- using (var cmd = new SqlCommand("[xlsInJyxm]", conn))
+ using (SqlCommand cmd = new SqlCommand("[xlsInJyxm]", conn))
{
try
{
conn.Open();
cmd.CommandType = CommandType.StoredProcedure;
- var parameters = new[]
- {
- new SqlParameter("@outGuid", SqlDbType.NVarChar, 100),
- new SqlParameter("@outMsg", SqlDbType.NVarChar, 300),
- new SqlParameter("@inEdtUserGuid", _userGuid),
- new SqlParameter("@tmpGuid", tmpGuid)
- };
+ SqlParameter[] parameters = new SqlParameter[] {
+ new SqlParameter("@outGuid",SqlDbType.NVarChar,100),
+ new SqlParameter("@outMsg",SqlDbType.NVarChar,300),
+ new SqlParameter("@inEdtUserGuid",_userGuid),
+ new SqlParameter("@tmpGuid",tmpGuid),
+ };
parameters[0].Direction = ParameterDirection.Output;
parameters[1].Direction = ParameterDirection.Output;
- foreach (var parameter in parameters)
+ foreach (SqlParameter parameter in parameters)
+ {
cmd.Parameters.Add(parameter);
+ }
rtnInt = cmd.ExecuteNonQuery();
- sbMsg.Append(parameters[1].Value);
+ sbMsg.Append(parameters[1].Value.ToString());
}
catch (Exception ex)
{
@@ -487,57 +465,54 @@
}
}
}
-
if (rtnInt <= 0)
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception,
- sbMsg.ToString());
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success,
- sbMsg.ToString());
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, sbMsg.ToString());
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success, sbMsg.ToString());
}
/// <summary>
- /// 宸ュ崟鍚庣洊鐮佸鍏�
+ /// 宸ュ崟鍚庣洊鐮佸鍏�
/// </summary>
/// <param name="tmpGuid"></param>
/// <returns></returns>
[RequestMethod(RequestMethods.POST)]
public ReturnDto<int?> XlsInDaaHgm([FromBody] dynamic mode)
{
- var dic = new Dictionary<string, string>
+ Dictionary<string, string> dic = new Dictionary<string, string>
{
- { "宸ュ崟缂栧彿", "t1" },
- { "鏉$爜", "t2" }
+ { "宸ュ崟缂栧彿", "t1" },
+ { "鏉$爜", "t2" },
};
string tmpGuid = mode.tmpGuid;
int? rtnInt = (int)ReturnCode.Default;
- int? _it = 0; //杩斿洖鐨勮鏁�
- var _msg = ""; //杩斿洖鐨勪俊鎭�
+ int? _it = 0;//杩斿洖鐨勮鏁�
+ string _msg = "";//杩斿洖鐨勪俊鎭�
(_it, _msg) = getTable(tmpGuid, dic);
if (_it <= 0)
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception,
- _msg);
- var sbMsg = new StringBuilder();
- using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, _msg);
+ System.Text.StringBuilder sbMsg = new System.Text.StringBuilder();
+ using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn))
{
- using (var cmd = new SqlCommand("[xlsInDaaHgm]", conn))
+ using (SqlCommand cmd = new SqlCommand("[xlsInDaaHgm]", conn))
{
try
{
conn.Open();
cmd.CommandType = CommandType.StoredProcedure;
- var parameters = new[]
- {
- new SqlParameter("@outGuid", SqlDbType.NVarChar, 100),
- new SqlParameter("@outMsg", SqlDbType.NVarChar, 300),
- new SqlParameter("@inEdtUserGuid", _userGuid),
- new SqlParameter("@tmpGuid", tmpGuid)
- };
+ SqlParameter[] parameters = new SqlParameter[] {
+ new SqlParameter("@outGuid",SqlDbType.NVarChar,100),
+ new SqlParameter("@outMsg",SqlDbType.NVarChar,300),
+ new SqlParameter("@inEdtUserGuid",_userGuid),
+ new SqlParameter("@tmpGuid",tmpGuid),
+ };
parameters[0].Direction = ParameterDirection.Output;
parameters[1].Direction = ParameterDirection.Output;
- foreach (var parameter in parameters)
+ foreach (SqlParameter parameter in parameters)
+ {
cmd.Parameters.Add(parameter);
+ }
rtnInt = cmd.ExecuteNonQuery();
- sbMsg.Append(parameters[1].Value);
+ sbMsg.Append(parameters[1].Value.ToString());
}
catch (Exception ex)
{
@@ -551,24 +526,21 @@
}
}
}
-
if (rtnInt <= 0)
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception,
- sbMsg.ToString());
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success,
- sbMsg.ToString());
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, sbMsg.ToString());
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success, sbMsg.ToString());
}
/// <summary>
- /// 鐗╂枡妫�楠岄」鐩鍏�
+ /// 鐗╂枡妫�楠岄」鐩鍏�
/// </summary>
/// <param name="tmpGuid"></param>
/// <returns></returns>
[RequestMethod(RequestMethods.POST)]
public ReturnDto<int?> XlsInItemJyxm([FromBody] dynamic mode)
{
- var dic = new Dictionary<string, string>
+ Dictionary<string, string> dic = new Dictionary<string, string>
{
{ "浣跨敤缁勭粐缂栧彿", "t1" },
{ "鐗╂枡缂栧彿", "t2" },
@@ -580,40 +552,40 @@
{ "鏍囧噯缂栫爜", "t8" },
{ "妫�楠屾按骞�", "t9" },
{ "鎺ュ彈姘村钩", "t10" },
- { "妫�楠岃姹�", "t11" }
+ { "妫�楠岃姹�", "t11" },
};
string tmpGuid = mode.tmpGuid;
- string strType = mode.strType; //鐢ㄤ簬鍒ゆ柇iqc,ipqc棣栨锛宨pqc宸℃锛宖qc
+ string strType = mode.strType;//鐢ㄤ簬鍒ゆ柇iqc,ipqc棣栨锛宨pqc宸℃锛宖qc
int? rtnInt = (int)ReturnCode.Default;
- int? _it = 0; //杩斿洖鐨勮鏁�
- var _msg = ""; //杩斿洖鐨勪俊鎭�
+ int? _it = 0;//杩斿洖鐨勮鏁�
+ string _msg = "";//杩斿洖鐨勪俊鎭�
(_it, _msg) = getTable(tmpGuid, dic);
if (_it <= 0)
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception,
- _msg);
- var sbMsg = new StringBuilder();
- using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, _msg);
+ System.Text.StringBuilder sbMsg = new System.Text.StringBuilder();
+ using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn))
{
- using (var cmd = new SqlCommand("[xlsInItemJyxm]", conn))
+ using (SqlCommand cmd = new SqlCommand("[xlsInItemJyxm]", conn))
{
try
{
conn.Open();
cmd.CommandType = CommandType.StoredProcedure;
- var parameters = new[]
- {
- new SqlParameter("@outGuid", SqlDbType.NVarChar, 100),
- new SqlParameter("@outMsg", SqlDbType.NVarChar, 1200),
- new SqlParameter("@inEdtUserGuid", _userGuid),
- new SqlParameter("@tmpGuid", tmpGuid),
- new SqlParameter("@strType", strType)
- };
+ SqlParameter[] parameters = new SqlParameter[] {
+ new SqlParameter("@outGuid",SqlDbType.NVarChar,100),
+ new SqlParameter("@outMsg",SqlDbType.NVarChar,1200),
+ new SqlParameter("@inEdtUserGuid",_userGuid),
+ new SqlParameter("@tmpGuid",tmpGuid),
+ new SqlParameter("@strType",strType),
+ };
parameters[0].Direction = ParameterDirection.Output;
parameters[1].Direction = ParameterDirection.Output;
- foreach (var parameter in parameters)
+ foreach (SqlParameter parameter in parameters)
+ {
cmd.Parameters.Add(parameter);
+ }
rtnInt = cmd.ExecuteNonQuery();
- sbMsg.Append(parameters[1].Value);
+ sbMsg.Append(parameters[1].Value.ToString());
}
catch (Exception ex)
{
@@ -626,30 +598,24 @@
}
}
}
-
if (rtnInt <= 0)
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception,
- sbMsg.ToString());
- return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success,
- sbMsg.ToString());
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, sbMsg.ToString());
+ return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success, sbMsg.ToString());
}
/// <summary>
- /// 杩斿洖dset
+ /// 杩斿洖dset
/// </summary>
/// <param name="tmpGuid"></param>
/// <returns></returns>
- private static (int?, string?) getTable(string tmpGuid,
- Dictionary<string, string> dic)
+ private static (int?, string?) getTable(string tmpGuid, Dictionary<string, string> dic)
{
var _it = 0;
var _msg = "";
- var sbSql = new StringBuilder();
- sbSql.Append(
- "select top 1 url_Path from [dbo].[MES_FILE] where parent_Guid='" +
- tmpGuid + "'");
- var files = "";
+ System.Text.StringBuilder sbSql = new System.Text.StringBuilder();
+ sbSql.Append("select top 1 url_Path from [dbo].[MES_FILE] where parent_Guid='" + tmpGuid + "'");
+ string files = "";
try
{
files = DbHelperSQL.GetSingle(sbSql.ToString()).ToString();
@@ -665,11 +631,9 @@
_it = 0;
_msg = "鎿嶄綔澶辫触锛氳鍏堜笂浼犳枃浠�";
}
-
var savePath = AppContext.BaseDirectory +
- AppSettingsHelper.getValueByKey("UploadPath") + "/" +
- files;
- var dt = new DataTable();
+ AppSettingsHelper.getValueByKey("UploadPath") + "/" + files;
+ System.Data.DataTable dt = new DataTable();
try
{
dt = ExcelHelper.ExcelToTable(savePath);
@@ -680,32 +644,30 @@
_msg = "鎿嶄綔澶辫触锛孍xcelToTable璇诲彇涓婁紶鏂囦欢鍙戠敓閿欒锛�" + ex.Message;
LogHelper.Debug("", "getTable:" + ex.Message);
}
-
dt.Columns.Add("tmpGuid", Type.GetType("System.Guid"));
dt.Columns.Add("tmpIdx", Type.GetType("System.String"));
- for (var r = 0; r < dt.Rows.Count; r++)
+ for (int r = 0; r < dt.Rows.Count; r++)
{
dt.Rows[r]["tmpGuid"] = Guid.Parse(tmpGuid);
dt.Rows[r]["tmpIdx"] = r + 3;
}
-
- var flag = false;
- using (var destinationConnection =
- new SqlConnection(DbHelperSQL.strConn))
+ bool flag = false;
+ using (SqlConnection destinationConnection = new SqlConnection(DbHelperSQL.strConn))
{
destinationConnection.Open();
- using (var bulkCopy = new SqlBulkCopy(destinationConnection))
+ using (SqlBulkCopy bulkCopy = new SqlBulkCopy(destinationConnection))
{
try
{
- bulkCopy.DestinationTableName = "TMP_XLS"; //瑕佹彃鍏ョ殑琛ㄧ殑琛ㄥ悕
+ bulkCopy.DestinationTableName = "TMP_XLS";//瑕佹彃鍏ョ殑琛ㄧ殑琛ㄥ悕
bulkCopy.BatchSize = dt.Rows.Count;
- bulkCopy.ColumnMappings.Add("tmpGuid",
- "tmpGuid"); //鏄犲皠瀛楁鍚� DataTable鍒楀悕 ,鏁版嵁搴撳搴旂殑鍒楀悕
+ bulkCopy.ColumnMappings.Add("tmpGuid", "tmpGuid");//鏄犲皠瀛楁鍚� DataTable鍒楀悕 ,鏁版嵁搴撳搴旂殑鍒楀悕
bulkCopy.ColumnMappings.Add("tmpIdx", "tmpIdx");
- foreach (var kvp in dic)
+ foreach (KeyValuePair<string, string> kvp in dic)
+ {
// bulkCopy.ColumnMappings.Add("鍚嶇О", "t1");
bulkCopy.ColumnMappings.Add(kvp.Key, kvp.Value);
+ }
bulkCopy.WriteToServer(dt);
flag = true;
}
@@ -717,13 +679,11 @@
}
}
}
-
- if (!flag)
+ if (flag == false)
{
_it = 0;
_msg = "鎿嶄綔澶辫触锛宐ulkCopy璇诲彇涓婁紶鏂囦欢鍙戠敓閿欒锛�";
}
-
_it = 1;
return (_it, _msg);
}
--
Gitblit v1.9.3