From f2b71fe1d3c2b7651d525a5b5bbe66fad602ea06 Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期二, 09 九月 2025 18:46:28 +0800 Subject: [PATCH] 代码清理 --- WebApi/Gs.Report/XlsInOutController.cs | 300 ++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 170 insertions(+), 130 deletions(-) diff --git a/WebApi/Gs.Report/XlsInOutController.cs b/WebApi/Gs.Report/XlsInOutController.cs index 78a536f..3606252 100644 --- a/WebApi/Gs.Report/XlsInOutController.cs +++ b/WebApi/Gs.Report/XlsInOutController.cs @@ -2,6 +2,7 @@ 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; @@ -27,9 +28,10 @@ } /// <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)) @@ -39,15 +41,17 @@ 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; } @@ -58,14 +62,13 @@ 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); @@ -77,21 +80,24 @@ { 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> @@ -132,6 +138,7 @@ dt.Fill(dset, "0"); } } + conn.Close(); } @@ -172,7 +179,7 @@ #region 鍚勭瀵煎嚭 /// <summary> - /// 瀵煎嚭棣栨 + /// 瀵煎嚭棣栨 /// </summary> /// <param name="mode"></param> /// <returns></returns> @@ -189,15 +196,18 @@ 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, "娌℃湁鏌ヨ鍒颁换浣曟暟鎹�"); @@ -216,7 +226,7 @@ } /// <summary> - /// 瀵煎嚭iqc妫� + /// 瀵煎嚭iqc妫� /// </summary> /// <param name="mode"></param> /// <returns></returns> @@ -233,12 +243,14 @@ 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"); @@ -261,7 +273,7 @@ /// <summary> - /// 瀵煎嚭宸℃ + /// 瀵煎嚭宸℃ /// </summary> /// <param name="mode"></param> /// <returns></returns> @@ -278,12 +290,14 @@ 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"); @@ -305,7 +319,7 @@ } /// <summary> - /// 瀵煎嚭鎴愬搧妫�楠屾姤鍛� + /// 瀵煎嚭鎴愬搧妫�楠屾姤鍛� /// </summary> /// <param name="mode"></param> /// <returns></returns> @@ -322,15 +336,18 @@ 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, "娌℃湁鏌ヨ鍒颁换浣曟暟鎹�"); @@ -347,52 +364,54 @@ "璇诲彇澶辫触," + ex.Message); } } + #endregion - #region 鍚勭瀵煎叆 + #region 鍚勭瀵煎叆 + /// <summary> - /// 妫�楠屽伐鍏峰鍏� + /// 妫�楠屽伐鍏峰鍏� /// </summary> /// <param name="tmpGuid"></param> /// <returns></returns> [RequestMethod(RequestMethods.POST)] public ReturnDto<int?> XlsInJygj([FromBody] dynamic mode) { - Dictionary<string, string> dic = new Dictionary<string, string> + var dic = new Dictionary<string, string> { - { "鍚嶇О", "t1" }, + { "鍚嶇О", "t1" } }; string tmpGuid = mode.tmpGuid; int? rtnInt = (int)ReturnCode.Default; - int? _it = 0;//杩斿洖鐨勮鏁� - string _msg = "";//杩斿洖鐨勪俊鎭� + int? _it = 0; //杩斿洖鐨勮鏁� + var _msg = ""; //杩斿洖鐨勪俊鎭� (_it, _msg) = getTable(tmpGuid, dic); if (_it <= 0) - return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, _msg); - System.Text.StringBuilder sbMsg = new System.Text.StringBuilder(); - using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn)) + return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, + _msg); + var sbMsg = new StringBuilder(); + using (var conn = new SqlConnection(DbHelperSQL.strConn)) { - using (SqlCommand cmd = new SqlCommand("[xlsInJygj]", conn)) + using (var cmd = new SqlCommand("[xlsInJygj]", conn)) { try { conn.Open(); cmd.CommandType = CommandType.StoredProcedure; - SqlParameter[] parameters = new SqlParameter[] { - new SqlParameter("@outGuid",SqlDbType.NVarChar,100), - new SqlParameter("@outMsg",SqlDbType.NVarChar,300), - new SqlParameter("@inEdtUserGuid",_userGuid), - new SqlParameter("@tmpGuid",tmpGuid), - }; + var parameters = new[] + { + 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 (SqlParameter parameter in parameters) - { + foreach (var parameter in parameters) cmd.Parameters.Add(parameter); - } rtnInt = cmd.ExecuteNonQuery(); - sbMsg.Append(parameters[1].Value.ToString()); + sbMsg.Append(parameters[1].Value); } catch (Exception ex) { @@ -405,54 +424,57 @@ } } } + 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) { - Dictionary<string, string> dic = new Dictionary<string, string> + var dic = new Dictionary<string, string> { - { "鍚嶇О", "t1" }, + { "鍚嶇О", "t1" } }; string tmpGuid = mode.tmpGuid; int? rtnInt = (int)ReturnCode.Default; - int? _it = 0;//杩斿洖鐨勮鏁� - string _msg = "";//杩斿洖鐨勪俊鎭� + int? _it = 0; //杩斿洖鐨勮鏁� + var _msg = ""; //杩斿洖鐨勪俊鎭� (_it, _msg) = getTable(tmpGuid, dic); if (_it <= 0) - return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, _msg); - System.Text.StringBuilder sbMsg = new System.Text.StringBuilder(); - using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn)) + return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, + _msg); + var sbMsg = new StringBuilder(); + using (var conn = new SqlConnection(DbHelperSQL.strConn)) { - using (SqlCommand cmd = new SqlCommand("[xlsInJyxm]", conn)) + using (var cmd = new SqlCommand("[xlsInJyxm]", conn)) { try { conn.Open(); cmd.CommandType = CommandType.StoredProcedure; - SqlParameter[] parameters = new SqlParameter[] { - new SqlParameter("@outGuid",SqlDbType.NVarChar,100), - new SqlParameter("@outMsg",SqlDbType.NVarChar,300), - new SqlParameter("@inEdtUserGuid",_userGuid), - new SqlParameter("@tmpGuid",tmpGuid), - }; + var parameters = new[] + { + 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 (SqlParameter parameter in parameters) - { + foreach (var parameter in parameters) cmd.Parameters.Add(parameter); - } rtnInt = cmd.ExecuteNonQuery(); - sbMsg.Append(parameters[1].Value.ToString()); + sbMsg.Append(parameters[1].Value); } catch (Exception ex) { @@ -465,54 +487,57 @@ } } } + 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) { - Dictionary<string, string> dic = new Dictionary<string, string> + var dic = new Dictionary<string, string> { - { "宸ュ崟缂栧彿", "t1" }, - { "鏉$爜", "t2" }, + { "宸ュ崟缂栧彿", "t1" }, + { "鏉$爜", "t2" } }; string tmpGuid = mode.tmpGuid; int? rtnInt = (int)ReturnCode.Default; - int? _it = 0;//杩斿洖鐨勮鏁� - string _msg = "";//杩斿洖鐨勪俊鎭� + int? _it = 0; //杩斿洖鐨勮鏁� + var _msg = ""; //杩斿洖鐨勪俊鎭� (_it, _msg) = getTable(tmpGuid, dic); if (_it <= 0) - return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, _msg); - System.Text.StringBuilder sbMsg = new System.Text.StringBuilder(); - using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn)) + return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, + _msg); + var sbMsg = new StringBuilder(); + using (var conn = new SqlConnection(DbHelperSQL.strConn)) { - using (SqlCommand cmd = new SqlCommand("[xlsInDaaHgm]", conn)) + using (var cmd = new SqlCommand("[xlsInDaaHgm]", conn)) { try { conn.Open(); cmd.CommandType = CommandType.StoredProcedure; - SqlParameter[] parameters = new SqlParameter[] { - new SqlParameter("@outGuid",SqlDbType.NVarChar,100), - new SqlParameter("@outMsg",SqlDbType.NVarChar,300), - new SqlParameter("@inEdtUserGuid",_userGuid), - new SqlParameter("@tmpGuid",tmpGuid), - }; + var parameters = new[] + { + 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 (SqlParameter parameter in parameters) - { + foreach (var parameter in parameters) cmd.Parameters.Add(parameter); - } rtnInt = cmd.ExecuteNonQuery(); - sbMsg.Append(parameters[1].Value.ToString()); + sbMsg.Append(parameters[1].Value); } catch (Exception ex) { @@ -526,21 +551,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> - /// 鐗╂枡妫�楠岄」鐩鍏� + /// 鐗╂枡妫�楠岄」鐩鍏� /// </summary> /// <param name="tmpGuid"></param> /// <returns></returns> [RequestMethod(RequestMethods.POST)] public ReturnDto<int?> XlsInItemJyxm([FromBody] dynamic mode) { - Dictionary<string, string> dic = new Dictionary<string, string> + var dic = new Dictionary<string, string> { { "浣跨敤缁勭粐缂栧彿", "t1" }, { "鐗╂枡缂栧彿", "t2" }, @@ -552,40 +580,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;//杩斿洖鐨勮鏁� - string _msg = "";//杩斿洖鐨勪俊鎭� + int? _it = 0; //杩斿洖鐨勮鏁� + var _msg = ""; //杩斿洖鐨勪俊鎭� (_it, _msg) = getTable(tmpGuid, dic); if (_it <= 0) - return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, _msg); - System.Text.StringBuilder sbMsg = new System.Text.StringBuilder(); - using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn)) + return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception, + _msg); + var sbMsg = new StringBuilder(); + using (var conn = new SqlConnection(DbHelperSQL.strConn)) { - using (SqlCommand cmd = new SqlCommand("[xlsInItemJyxm]", conn)) + using (var cmd = new SqlCommand("[xlsInItemJyxm]", conn)) { try { conn.Open(); cmd.CommandType = CommandType.StoredProcedure; - 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), - }; + 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) + }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Direction = ParameterDirection.Output; - foreach (SqlParameter parameter in parameters) - { + foreach (var parameter in parameters) cmd.Parameters.Add(parameter); - } rtnInt = cmd.ExecuteNonQuery(); - sbMsg.Append(parameters[1].Value.ToString()); + sbMsg.Append(parameters[1].Value); } catch (Exception ex) { @@ -598,24 +626,30 @@ } } } + 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 = ""; - 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 = ""; + var sbSql = new StringBuilder(); + sbSql.Append( + "select top 1 url_Path from [dbo].[MES_FILE] where parent_Guid='" + + tmpGuid + "'"); + var files = ""; try { files = DbHelperSQL.GetSingle(sbSql.ToString()).ToString(); @@ -631,9 +665,11 @@ _it = 0; _msg = "鎿嶄綔澶辫触锛氳鍏堜笂浼犳枃浠�"; } + var savePath = AppContext.BaseDirectory + - AppSettingsHelper.getValueByKey("UploadPath") + "/" + files; - System.Data.DataTable dt = new DataTable(); + AppSettingsHelper.getValueByKey("UploadPath") + "/" + + files; + var dt = new DataTable(); try { dt = ExcelHelper.ExcelToTable(savePath); @@ -644,30 +680,32 @@ _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 (int r = 0; r < dt.Rows.Count; r++) + for (var r = 0; r < dt.Rows.Count; r++) { dt.Rows[r]["tmpGuid"] = Guid.Parse(tmpGuid); dt.Rows[r]["tmpIdx"] = r + 3; } - bool flag = false; - using (SqlConnection destinationConnection = new SqlConnection(DbHelperSQL.strConn)) + + var flag = false; + using (var destinationConnection = + new SqlConnection(DbHelperSQL.strConn)) { destinationConnection.Open(); - using (SqlBulkCopy bulkCopy = new SqlBulkCopy(destinationConnection)) + using (var 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 (KeyValuePair<string, string> kvp in dic) - { + foreach (var kvp in dic) // bulkCopy.ColumnMappings.Add("鍚嶇О", "t1"); bulkCopy.ColumnMappings.Add(kvp.Key, kvp.Value); - } bulkCopy.WriteToServer(dt); flag = true; } @@ -679,11 +717,13 @@ } } } - if (flag == false) + + if (!flag) { _it = 0; _msg = "鎿嶄綔澶辫触锛宐ulkCopy璇诲彇涓婁紶鏂囦欢鍙戠敓閿欒锛�"; } + _it = 1; return (_it, _msg); } -- Gitblit v1.9.3