public frmImportMatchInfo(string strImportDir, XmlTypeEnum xmlType) { InitializeComponent(); OVRDataBaseUtils.SetDataGridViewStyle(dgMatchInfo); importDir_ = strImportDir; xmlType_ = xmlType; if (xmlType_ == XmlTypeEnum.XmlTypeMatchInfo) { btnImportAllAction.Visible = false; this.Text = "Import Match Result"; } else { this.Text = "Import Match Action"; } }
private bool ImportMatchInfoXml(XmlTypeEnum type, string strMatchCode, string strXml) { SqlConnection sqlConnection = new SqlConnection(); sqlConnection.ConnectionString = sqlConnection_.ConnectionString; try { if (sqlConnection.State != ConnectionState.Open) { sqlConnection.Open(); } } catch (System.Exception e) { LastErrorString = e.Message; BDCommon.Writelog("打开数据库失败!", e.Message); return(false); } try { SqlCommand sqlCmd = sqlConnection.CreateCommand(); sqlCmd.CommandType = CommandType.StoredProcedure; SqlParameter sqlParam = null; if (type == XmlTypeEnum.XmlTypeMatchInfo) { sqlCmd.CommandText = string.Format("Proc_{0}_ImportMatchInfoXML", BDCommon.g_strDisplnCode); sqlCmd.Parameters.Add("@MatchRsc", SqlDbType.NVarChar, 30).Value = strMatchCode; sqlCmd.Parameters.Add("@MatchInfoXML", SqlDbType.NVarChar, 2000000).Value = strXml; sqlCmd.Parameters.Add("@BForce", SqlDbType.Int).Value = 0;//非强制导入时,official状态下不允许导入数据 sqlParam = sqlCmd.Parameters.Add("@Result", SqlDbType.Int); sqlParam.Direction = ParameterDirection.Output; } else if (type == XmlTypeEnum.XmlTypeAcitonListAll) { sqlCmd.CommandText = string.Format("Proc_{0}_ImportActionAll", BDCommon.g_strDisplnCode); sqlCmd.Parameters.Add("@MatchRsc", SqlDbType.NVarChar, 30).Value = strMatchCode; sqlCmd.Parameters.Add("@MatchInfoXML", SqlDbType.NVarChar, 2000000).Value = strXml; sqlParam = sqlCmd.Parameters.Add("@Result", SqlDbType.Int); sqlParam.Direction = ParameterDirection.Output; } else { LastErrorString = "错误的XML枚举类型!"; return(false); } sqlCmd.ExecuteNonQuery(); ErrorIntDes = (int)sqlParam.Value; if ((int)sqlParam.Value > 0) { return(true); } if (type == XmlTypeEnum.XmlTypeMatchInfo) { if (ErrorIntDes == -2) { LastErrorString = string.Format("Official之后拒绝再次导入,matchCode:{0}", strMatchCode); } else { LastErrorString = string.Format("Proc_TT_ImportMatchInfoXML错误,错误码:{0}", sqlParam.Value); } } else { LastErrorString = string.Format("Proc_TT_ImportActionAll错误,错误码:{0}", sqlParam.Value); } BDCommon.Writelog(LastErrorString); return(false); } catch (System.Exception e) { LastErrorString = e.Message; BDCommon.Writelog("导入Match xml数据异常", e.Message); return(false); } finally { if (sqlConnection != null) { sqlConnection.Close(); } } }