Пример #1
0
        //Action GamePoint MatchPoint
        bool AddActionList(Int32 nPosition, Int32 nRegisterID, Int32 nResultA, Int32 nResultB, Int32 nScore)
        {
            Int32 nPointType;
            Int32 nActionID;

            Int32 nMatchA = BDCommon.Str2Int(lb_A_GameTotal.Text);
            Int32 nMatchB = BDCommon.Str2Int(lb_B_GameTotal.Text);

            m_CurMatchRule.StatGameMatchPoint(nResultA, nResultB, nMatchA, nMatchB, out nPointType);
            nActionID = BDCommon.g_ManageDB.GetActionID(BDCommon.strAction_addScore);

            if (IsDouble())
            {
                BDCommon.g_ManageDB.AddDoubleActionList(nPosition, m_nCurMatchID, m_nCurGameID, m_nDoubleRegisterA1,
                                                        m_nDoubleRegisterA2, m_nDoubleRegisterB1, m_nDoubleRegisterB2, nScore);
            }
            else
            {
                BDCommon.g_ManageDB.AddActionList(nPosition, m_nCurMatchID, m_nCurGameID, nRegisterID, nActionID, nScore, nPointType);
            }


            BDCommon.g_BDPlugin.DataChangedNotify(OVRDataChangedType.emMatchStatistic, -1, -1, -1, m_nCurMatchID, m_nCurMatchID, null);
            return(true);
        }
Пример #2
0
        void UIGamesTotal2MatchResultsToDB()
        {
            String strGameATScore, strGameBTScore;
            Int32  nGameATScore, nGameBTScore;

            strGameATScore = lb_A_GameTotal.Text;
            strGameBTScore = lb_B_GameTotal.Text;
            nGameATScore   = BDCommon.Str2Int(strGameATScore);
            nGameBTScore   = BDCommon.Str2Int(strGameBTScore);

            if (m_nCurMatchType == BDCommon.MATCH_TYPE_TEAM && m_nCurTeamSplitID > 0)
            {
                if (!m_CurMatchRule.UpdateTeamSplitResultsToDB(m_nCurTeamSplitID, nGameATScore, nGameBTScore, m_nRegAPos, m_nRegBPos))
                {
                    UpdateTeamSplitResult(true);             // Recover if not valid
                    return;
                }

                if (m_CurMatchRule.IsGamesTotalScoreFinished(nGameATScore, nGameBTScore))
                {
                    // Statistic Match Score and Update to DB
                    Int32 nMatchScoreA = 0;
                    Int32 nMatchScoreB = 0;
                    if (m_CurMatchRule.GetMatchScoreFromTeamSplits(ref nMatchScoreA, ref nMatchScoreB))
                    {
                        // Update match result
                        if (m_CurMatchRule.UpdateMatchResultsToDB(nMatchScoreA, nMatchScoreB, m_nRegAPos, m_nRegBPos))
                        {
                            lb_Home_Score.Text = nMatchScoreA.ToString();
                            lb_Away_Score.Text = nMatchScoreB.ToString();
                        }
                    }
                    //还应该更新TeamSplit的状态
                    BDCommon.g_ManageDB.SetMatchSplitStatus(m_nCurMatchID, m_nCurTeamSplitID, BDCommon.STATUS_FINISHED);
                }
                else
                {
                    BDCommon.g_ManageDB.SetMatchSplitStatus(m_nCurMatchID, m_nCurTeamSplitID, BDCommon.STATUS_RUNNING);
                }

                EnableTeamSplitRbtn(true, false);
                EnableGamesRbtnsAndLabels(true, false);
            }
            else
            {
                // Update match result
                if (m_CurMatchRule.UpdateMatchResultsToDB(nGameATScore, nGameBTScore, m_nRegAPos, m_nRegBPos))
                {
                    lb_Home_Score.Text = strGameATScore;
                    lb_Away_Score.Text = strGameBTScore;
                }
                else         // Recover from Match result
                {
                    UI_MatchScoreToGamesTotal();
                }

                EnableGamesRbtnsAndLabels(true, false);
            }
        }
Пример #3
0
        public int GetMatchIDFromRSC(string matchRsc)
        {
            if (matchRsc.Length != 9)
            {
                return(-2);
            }
            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(-1);
            }
            SqlCommand sqlCmd = sqlConnection.CreateCommand();

            sqlCmd.CommandText = "Fun_BDTT_GetMatchIDFromRsc";
            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.Parameters.Add("@MatchRsc", SqlDbType.NVarChar).Value = matchRsc;
            SqlParameter param = sqlCmd.Parameters.Add("@returnInt", SqlDbType.Int);

            param.Direction = ParameterDirection.ReturnValue;
            try
            {
                //sqlCmd.ExecuteScalar();
                //if (param.Value.GetType().Name == "DBNull")
                //{
                //    return -3;
                //}
                sqlCmd.ExecuteNonQuery();
                if (param.Value == null)
                {
                    return(-3);
                }
                return(Convert.ToInt32(param.Value));
            }
            catch (System.Exception e)
            {
                BDCommon.Writelog("Fun_BDTT_GetMatchIDFromRsc异常", e.Message);
                return(-1);
            }
            finally
            {
                if (sqlConnection != null)
                {
                    sqlConnection_.Close();
                }
            }
        }
Пример #4
0
        public string GetRscStringFromMatchID(int matchID)
        {
            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("");
            }
            SqlCommand sqlCmd = sqlConnection.CreateCommand();

            sqlCmd.CommandText = "Fun_BDTT_GetMatchRscCode";
            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.Parameters.Add("@MatchID", SqlDbType.Int).Value = matchID;
            SqlParameter param = sqlCmd.Parameters.Add("@returnString", SqlDbType.NVarChar, 100);

            param.Direction = ParameterDirection.ReturnValue;
            SqlDataReader dr = null;

            try
            {
                //sqlCmd.ExecuteScalar();
                //dr = sqlCmd.ExecuteReader();
                //if (dr.Read())
                //{
                //    return dr.GetString(0);
                //}
                //return "";
                sqlCmd.ExecuteNonQuery();
                if (param.Value == null)
                {
                    return("");
                }
                return(param.Value.ToString());
            }
            catch (System.Exception e)
            {
                BDCommon.Writelog("Fun_BDTT_GetMatchRscCode异常", e.Message);
                return("");
            }
            finally
            {
                if (sqlConnection != null)
                {
                    sqlConnection.Close();
                }
            }
        }
Пример #5
0
        private bool ImportAcitonListSingle(string matchCode, int matchNo, int gameNo, 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;
                sqlCmd.CommandText = string.Format("Proc_{0}_ImportActionSingle", BDCommon.g_strDisplnCode);
                sqlCmd.Parameters.Add("@MatchRsc", SqlDbType.NVarChar, 30).Value          = matchCode;
                sqlCmd.Parameters.Add("@MatchNo", SqlDbType.Int).Value                    = matchNo;
                sqlCmd.Parameters.Add("@GameNo", SqlDbType.Int).Value                     = gameNo;
                sqlCmd.Parameters.Add("@MatchInfoXML", SqlDbType.NVarChar, 2000000).Value = strXml;
                sqlParam           = sqlCmd.Parameters.Add("@Result", SqlDbType.Int);
                sqlParam.Direction = ParameterDirection.Output;

                sqlCmd.ExecuteNonQuery();
                ErrorIntDes = (int)sqlParam.Value;
                if ((int)sqlParam.Value > 0)
                {
                    return(true);
                }
                LastErrorString = string.Format("ImportAcitonListSingle错误,错误码:{0}", sqlParam.Value);
                BDCommon.Writelog(LastErrorString);
                return(false);
            }
            catch (System.Exception e)
            {
                LastErrorString = e.Message;
                BDCommon.Writelog("导入Match Action xml数据异常", e.Message);
                return(false);
            }
            finally
            {
                if (sqlConnection != null)
                {
                    sqlConnection.Close();
                }
            }
        }
Пример #6
0
        private void btnViewFile_Click(object sender, EventArgs e)
        {
            if (dgvTempSetData.SelectedRows.Count <= 0)
            {
                MessageBoxEx.Show("Please select a set first.");
                return;
            }
            DataGridViewRow dgvr        = dgvTempSetData.SelectedRows[0];
            string          strFileName = dgvr.Cells["FileName"].Value.ToString();

            BDCommon.ShellOpenFile(Path.Combine(BDCommon.GetTempMatchDir(), strFileName));
        }
Пример #7
0
        private void btnOpenXml_Click(object sender, EventArgs e)
        {
            if (dgMatchInfo.SelectedRows.Count != 1)
            {
                MessageBox.Show("You can only select one row!");
                return;
            }
            string strType  = xmlType_ == XmlTypeEnum.XmlTypeMatchInfo ? "Result" : "Score";
            string fileName = Path.Combine(importDir_, string.Format("{0}_{1}.xml", dgMatchInfo.SelectedRows[0].Cells[0].Value.ToString(), strType));

            BDCommon.OpenWithNotepad(fileName);
        }
Пример #8
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (dgvTempSetData.SelectedRows.Count <= 0)
            {
                MessageBoxEx.Show("Please select a set first.");
                return;
            }
            DataGridViewRow dgvr        = dgvTempSetData.SelectedRows[0];
            string          strFileName = dgvr.Cells["FileName"].Value.ToString();
            int             setOrder    = Convert.ToInt32(dgvr.Cells["Set"].Value);
            string          strPath     = Path.Combine(BDCommon.GetTempMatchDir(), strFileName);
            string          strXml      = File.ReadAllText(strPath, System.Text.Encoding.Default);
            int             startPos    = strXml.IndexOf("<MatchInfo");

            if (startPos == -1)
            {
                MessageBoxEx.Show("Invalid file format.");
                return;
            }
            strXml = strXml.Substring(startPos);
            int res = BDCommon.g_ManageDB.ImportTempMatchData(m_iMatchID, setOrder, strXml);

            if (res == -1)
            {
                MessageBoxEx.Show("Set split id can not be found.");
                return;
            }
            else if (res == -2)
            {
                MessageBoxEx.Show("Can not import because of official status");
                return;
            }
            else if (res == -3)
            {
                MessageBoxEx.Show("The match is not a team match.");
                return;
            }
            else if (res == 0)
            {
                MessageBoxEx.Show("Imported failed");
                return;
            }
            MessageBoxEx.Show("Import succeed.");
        }
Пример #9
0
        protected override void OnMgrEvent(object sender, OVRMgr2PluginEventArgs e)
        {
            switch (e.Type)
            {
            case OVRMgr2PluginEventType.emMatchSelected:
            {
                if (m_frmBDPlugin != null)
                {
                    m_frmBDPlugin.OnMsgFlushSelMatch(0, BDCommon.Str2Int(e.Args.ToString()));
                }
                break;
            }

            case OVRMgr2PluginEventType.emRptContextQuery:
            {
                m_frmBDPlugin.QueryReportContext(e.Args as OVRReportContextQueryArgs);
                break;
            }
            }
        }
Пример #10
0
        private void frmImportTempData_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable("Sets");

            dt.Columns.Add("FileName", typeof(string));
            dt.Columns.Add("Set", typeof(string));
            string strMatchID = m_iMatchID.ToString();

            strMatchID = strMatchID.PadLeft(5, '0');
            string[] strFiles = Directory.GetFiles(BDCommon.GetTempMatchDir(), string.Format("9?{0}_Result.xml", strMatchID));
            foreach (string strFilePath in strFiles)
            {
                string  strName = Path.GetFileName(strFilePath);
                DataRow drNew   = dt.NewRow();
                drNew["FileName"] = strName;
                drNew["Set"]      = strName.Substring(1, 1);
                dt.Rows.Add(drNew);
            }
            OVRDataBaseUtils.FillDataGridView(dgvTempSetData, dt);
        }
        private void EnableTeamSplitRbtn(Boolean bEnable, Boolean bClear)
        {
            if (bClear && m_nCurTeamSplitID > 0)
            {
                if (m_rbtnCurChkedSplit != null)
                {
                    m_rbtnCurChkedSplit.Checked = false;
                }
            }

            // Get enable games count
            Int32 nEnableCount = m_nTeamSplitCount;

            if (m_CurMatchRule != null)
            {
                String strMatchScoreA, strMatchScoreB;
                BDCommon.g_ManageDB.GetMatchScore(m_nCurMatchID, out strMatchScoreA, out strMatchScoreB);
                Int32 nMatchScoreA = BDCommon.Str2Int(strMatchScoreA);
                Int32 nMatchScoreB = BDCommon.Str2Int(strMatchScoreB);

                if (m_CurMatchRule.IsMatchScoreFinished(nMatchScoreA, nMatchScoreB))
                {
                    nEnableCount = nMatchScoreA + nMatchScoreB;
                }
                else
                {
                    nEnableCount = nMatchScoreA + nMatchScoreB + 1;
                }
            }

            btnx_Split1.Enabled          = nEnableCount >= 1 ? bEnable : false;
            btnx_Split2.Enabled          = nEnableCount >= 2 ? bEnable : false;
            btnx_Split3.Enabled          = nEnableCount >= 3 ? bEnable : false;
            btnx_Split4.Enabled          = nEnableCount >= 4 ? bEnable : false;
            btnx_Split5.Enabled          = nEnableCount >= 5 ? bEnable : false;
            btnx_SubMatch_Result.Enabled = nEnableCount > 0 ? bEnable : false;
        }
Пример #12
0
        public bool ProcessXmlData(string strXml, object extraData)
        {
            if (strXml.Length <= 8)
            {
                LastErrorString = "xml文件字节小于等于8,为无效文件";
                return(false);
            }
            if (strXml.Substring(0, 2) == "<?")
            {
                int endIndex = strXml.IndexOf("?>");
                if (endIndex == -1)
                {
                    LastErrorString = "xml文件头非法!未找到头结束标志";
                    return(false);
                }
                strXml = strXml.Substring(endIndex + 2);
            }

            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(strXml);
                XmlNode xmlNode = xmlDoc.SelectSingleNode("/MatchInfo");
                if (xmlNode == null)
                {
                    LastErrorString = "查找<MatchInfo 失败";
                    return(false);
                }
                XmlNode firstNode = xmlNode.FirstChild;
                if (firstNode == null)
                {
                    LastErrorString = "查找<MatchInfo的第一子级失败";
                    return(false);
                }
                if (firstNode.Name == "Duel")
                {
                    XmlType = XmlTypeEnum.XmlTypeMatchInfo;
                    string matchCode = xmlNode.Attributes["MatchCode"].Value.ToString();
                    MatchCode = matchCode;
                    if (ImportMatchInfoXml(XmlTypeEnum.XmlTypeMatchInfo, matchCode, xmlNode.InnerXml))
                    {
                        UpdateExtraTaskInfo(strXml);
                        return(true);
                    }
                    {
                        return(false);
                    }
                }
                else if (firstNode.Name == "Score")
                {
                    XmlType = XmlTypeEnum.XmlTypeAcitonListSingle;
                    string matchCode = xmlNode.Attributes["MatchCode"].Value.ToString();
                    MatchCode = matchCode;
                    bool bActionAll = (bool)((extraData as TTXmlExtraData).Data);
                    int  curMatchNo = Convert.ToInt32(xmlNode.Attributes["CurSubMatch_No"].Value);
                    int  curGameNo  = Convert.ToInt32(xmlNode.Attributes["CurGame_No"].Value);

                    //TT的处理
                    if (BDCommon.g_strDisplnCode == "TT")
                    {
                        string matchStatus = xmlNode.Attributes["Match_State"].Value.ToString();
                        if (matchStatus != "5")
                        {
                            if (ImportAcitonListSingle(matchCode, curMatchNo, curGameNo, strXml))
                            {
                                UpdateExtraTaskInfo(strXml);
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (ImportMatchInfoXml(XmlTypeEnum.XmlTypeAcitonListAll, matchCode, strXml))
                            {
                                UpdateExtraTaskInfo(strXml);
                                return(true);
                            }
                            {
                                return(false);
                            }
                        }
                    }
                    else//BD的处理
                    {
                        TTXmlExtraData ttItemExtra = extraData as TTXmlExtraData;
                        if ((bool)ttItemExtra.Data)
                        {
                            if (ImportMatchInfoXml(XmlTypeEnum.XmlTypeAcitonListAll, matchCode, strXml))
                            {
                                UpdateExtraTaskInfo(strXml);
                                return(true);
                            }
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (ImportAcitonListSingle(matchCode, curMatchNo, curGameNo, strXml))
                            {
                                UpdateExtraTaskInfo(strXml);
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                }
                else if (firstNode.Name == "Export")
                {
                    XmlType = XmlTypeEnum.XmlTypeClientExportSchedule;
                    UpdateExtraTaskInfo(strXml);
                    return(true);
                }
                else if (firstNode.Name == "Chat")
                {
                    XmlType = XmlTypeEnum.XmlTypeClientChat;
                    UpdateExtraTaskInfo(strXml);
                    return(true);
                }
                else
                {
                    LastErrorString = "不能识别的协议类型";
                    return(false);
                }
            }
            catch (System.Exception e)
            {
                LastErrorString = e.Message;
                BDCommon.Writelog("解析xml文件失败!", e.Message);
                return(false);
            }


            return(true);
        }
        private void EnableGamesRbtnsAndLabels(Boolean bEnable, Boolean bClear)
        {
            if (bClear && m_rbtnCurChkedGame != null)
            {
                m_rbtnCurChkedGame.Checked = false;
            }

            // Get enable games count
            int nEnableCount = m_nGamesCount;

            if (m_CurMatchRule != null)
            {
                int nTotalScoreA = BDCommon.Str2Int(lb_A_GameTotal.Text);
                int nTotalScoreB = BDCommon.Str2Int(lb_B_GameTotal.Text);
                if (m_CurMatchRule.IsGamesTotalScoreFinished(nTotalScoreA, nTotalScoreB))
                {
                    nEnableCount = nTotalScoreA + nTotalScoreB;
                }
                else
                {
                    nEnableCount = nTotalScoreA + nTotalScoreB + 1;
                }
            }

            btnx_Game_Result.Enabled = nEnableCount > 0 ? bEnable : false;

            // Use Reflection
            Type theType = typeof(frmOVRBDDataEntry);

            for (Int32 i = 1; i < 10; i++)
            {
                String strVarNameA      = "lb_A_Game" + i.ToString();
                String strVarNameB      = "lb_B_Game" + i.ToString();
                String strVarRadBtnName = "rad_Game" + i.ToString();

                FieldInfo fi_VarA      = theType.GetField(strVarNameA, BindingFlags.Instance | BindingFlags.NonPublic);
                FieldInfo fi_VarB      = theType.GetField(strVarNameB, BindingFlags.Instance | BindingFlags.NonPublic);
                FieldInfo fi_VarRadBtn = theType.GetField(strVarRadBtnName, BindingFlags.Instance | BindingFlags.NonPublic);
                if (fi_VarA == null || fi_VarB == null || fi_VarRadBtn == null)
                {
                    break;
                }

                Label       lbTempA  = (Label)fi_VarA.GetValue(this);
                Label       lbTempB  = (Label)fi_VarB.GetValue(this);
                RadioButton rbtnTemp = (RadioButton)fi_VarRadBtn.GetValue(this);

                if (i <= nEnableCount)
                {
                    lbTempA.Enabled  = bEnable;
                    lbTempB.Enabled  = bEnable;
                    rbtnTemp.Enabled = bEnable;

                    if (bClear)
                    {
                        lbTempA.Text = "0";
                        lbTempB.Text = "0";
                    }
                }
                else
                {
                    lbTempA.Enabled  = false;
                    lbTempB.Enabled  = false;
                    rbtnTemp.Enabled = false;
                    //lbTempA.Text = "0";
                    //lbTempB.Text = "0";
                }
            }
        }
Пример #14
0
        public bool GetGamesTotalFromGames(Int32 nTeamSplitID, ref Int32 nPointsA, ref Int32 nPointsB)
        {
            if (m_nMatchID <= 0 || nTeamSplitID < 0 || m_nGamesCount <= 0)
            {
                return(false);
            }

            // nTeamSplitID=0, means not team type match
            if (nTeamSplitID == 0 && m_nMatchType == BDCommon.MATCH_TYPE_TEAM)
            {
                return(false);
            }

            Int32 nTotalScoreA = 0;
            Int32 nTotalScoreB = 0;

            STableRecordSet stRecords;

            if (!BDCommon.g_ManageDB.GetSubSplitInfo(m_nMatchID, nTeamSplitID, out stRecords))
            {
                return(false);
            }

            Int32 nCount = stRecords.GetRecordCount();

            for (Int32 i = 0; i < nCount; i++)
            {
                Int32 nGameID = Convert.ToInt32(stRecords.GetFieldValue(i, "F_MatchSplitID"));

                STableRecordSet stSplitResults;
                if (!BDCommon.g_ManageDB.GetMatchSplitResult(m_nMatchID, nGameID, out stSplitResults))
                {
                    continue;
                }

                Int32 nResultA = BDCommon.Str2Int(stSplitResults.GetFieldValue(0, "F_ResultID"));
                Int32 nResultB = BDCommon.Str2Int(stSplitResults.GetFieldValue(1, "F_ResultID"));

                if (nResultA == BDCommon.RESULT_TYPE_WIN && nResultB == BDCommon.RESULT_TYPE_LOSE)
                {
                    nTotalScoreA++;
                }
                else if (nResultB == BDCommon.RESULT_TYPE_WIN && nResultA == BDCommon.RESULT_TYPE_LOSE)
                {
                    nTotalScoreB++;
                }
                else if (nResultA == BDCommon.RESULT_TYPE_TIE && nResultB == BDCommon.RESULT_TYPE_TIE)
                {
                    nTotalScoreA++;
                    nTotalScoreB++;
                }
                else
                {
                    continue; // The Game has not been completed
                }
            }

            nPointsA = nTotalScoreA;
            nPointsB = nTotalScoreB;

            return(true);
        }
Пример #15
0
        public bool GetMatchScoreFromTeamSplits(ref Int32 nPointsA, ref Int32 nPointsB)
        {
            if (m_nMatchID <= 0 || m_nMatchType != BDCommon.MATCH_TYPE_TEAM || m_nSplitsCount <= 0)
            {
                return(false);
            }

            Int32 nMatchScoreA = 0;
            Int32 nMatchScoreB = 0;

            STableRecordSet stRecords;

            if (!BDCommon.g_ManageDB.GetSubSplitInfo(m_nMatchID, 0, out stRecords))
            {
                return(false);
            }

            Int32 nCount = stRecords.GetRecordCount();

            for (Int32 i = 0; i < nCount; i++)
            {
                Int32 nTeamSplitID = BDCommon.Str2Int(stRecords.GetFieldValue(i, "F_MatchSplitID"));

                STableRecordSet stSplitResults;
                if (!BDCommon.g_ManageDB.GetMatchSplitResult(m_nMatchID, nTeamSplitID, out stSplitResults))
                {
                    continue;
                }

                Int32 nResultA = BDCommon.Str2Int(stSplitResults.GetFieldValue(0, "F_ResultID"));
                Int32 nResultB = BDCommon.Str2Int(stSplitResults.GetFieldValue(1, "F_ResultID"));

                // Statistic the score of each valid team split
                if (nResultA == BDCommon.RESULT_TYPE_WIN && nResultB == BDCommon.RESULT_TYPE_LOSE)
                {
                    nMatchScoreA++;
                }
                else if (nResultB == BDCommon.RESULT_TYPE_WIN && nResultA == BDCommon.RESULT_TYPE_LOSE)
                {
                    nMatchScoreB++;
                }
                else if (nResultA == BDCommon.RESULT_TYPE_TIE && nResultB == BDCommon.RESULT_TYPE_TIE)
                {
                    nMatchScoreA++;
                    nMatchScoreB++;
                }
                else
                {
                    continue; // The Split has not been completed
                }
                if (IsValidMatchScore(nMatchScoreA, nMatchScoreB) && IsMatchScoreFinished(nMatchScoreA, nMatchScoreB))
                {
                    break;
                }
            }

            nPointsA = nMatchScoreA;
            nPointsB = nMatchScoreB;

            return(true);
        }
Пример #16
0
        public bool UpdateData(string xmlAction)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xmlAction);
                XmlNode xmlNode = xmlDoc.SelectSingleNode("/MatchInfo");
                if (xmlNode == null)
                {
                    LastErrorString = "查找<MatchInfo 失败";
                    return(false);
                }
                XmlNodeList xmlList = xmlNode.ChildNodes;
                if (xmlList.Count == 0)
                {
                    LastErrorString = "Acition list xml \"MatchInfo\"子节点为空";
                    return(false);
                }
                if (xmlList[0].Name != "Score")
                {
                    LastErrorString = "节点名不为Score,违反协议";
                    return(false);
                }

                string curMatch = xmlNode.Attributes["CurSubMatch_No"].Value.ToString();
                string curGame  = xmlNode.Attributes["CurGame_No"].Value.ToString();


                List <ScoreItem> scoreItems = new List <ScoreItem>();
                List <string>    gameXmlAll = new List <string>();

                //保存当前局的所有Score和xml
                foreach (XmlNode sNode in xmlList)
                {
                    if (sNode.Attributes["Match_No"].Value.ToString() == curMatch &&
                        sNode.Attributes["Game_No"].Value.ToString() == curGame)
                    {
                        ScoreItem item = new ScoreItem();
                        item.ActionOrder = Convert.ToInt32(sNode.Attributes["Order"].Value);
                        item.GameScoreA  = Convert.ToInt32(sNode.Attributes["GameScoreA"].Value);
                        item.GameScoreB  = Convert.ToInt32(sNode.Attributes["GameScoreB"].Value);
                        scoreItems.Add(item);
                        gameXmlAll.Add(sNode.OuterXml);
                    }
                }
                if (scoreItems.Count == 0)
                {
                    LastErrorString = "当前局下没有action,请检查xml文件";
                    return(false);
                }

                if (scoreItems[0].ActionOrder != 0)
                {
                    LastErrorString = "actionList_不是从1开始,请检查文件";
                    return(false);
                }

                //判断当前局是否变化,如果当前局变化则设置修改编号为0
                if (curMatch != curMatchOrder_.ToString() || curGame != curGameOrder_.ToString())
                {
                    AdvisedOrder = 0;
                }
                else
                {
                    //当前局未变化,则首先取出历史记录和新获取的记录数中最少的一个
                    int count = actionList_.Count <= scoreItems.Count ? actionList_.Count : scoreItems.Count;

                    //首先判断前面的数据是否有改变,如果有改变,则设置改变的那一条为修改编号
                    bool bChanged = false;
                    for (int i = 0; i < count; i++)
                    {
                        if (actionList_[i].ActionOrder != scoreItems[i].ActionOrder ||
                            actionList_[i].GameScoreA != scoreItems[i].GameScoreA ||
                            actionList_[i].GameScoreB != scoreItems[i].GameScoreB)
                        {
                            AdvisedOrder = actionList_[i].ActionOrder;
                            bChanged     = true;
                            break;
                        }
                    }

                    //前面的数据对比无误
                    if (!bChanged)
                    {
                        //如果数量也相等,说明完全相同,则只取最后一条用于更新比分
                        if (actionList_.Count == scoreItems.Count)
                        {
                            AdvisedOrder = -1;
                            NewXml       = gameXmlAll[gameXmlAll.Count - 1];
                            NewXml       = "<MatchInfo>" + NewXml + "</MatchInfo>";
                            return(true);
                        }
                        else
                        {
                            //数量不等,如果原记录小于新记录,则设置原记录为修改编号,如果原记录大于新记录,则从新记录设置为修改标志
                            AdvisedOrder = actionList_.Count < scoreItems.Count ? actionList_.Count: scoreItems.Count;
                        }
                    }
                }

                actionList_.Clear();
                foreach (ScoreItem sItem in scoreItems)
                {
                    actionList_.Add(sItem);
                }

                string strNewXml = "";
                //提取修改部分的xml,如果修改编号大于xml的数量,则说明是删除操作,strNewXml为空
                if (AdvisedOrder <= gameXmlAll.Count - 1)
                {
                    for (int i = AdvisedOrder; i < gameXmlAll.Count; i++)
                    {
                        strNewXml += gameXmlAll[i];
                    }
                }
                else
                {
                    strNewXml = "";
                }
                NewXml = strNewXml;
                if (NewXml.Trim() != "")
                {
                    NewXml = "<MatchInfo>" + NewXml + "</MatchInfo>";
                }

                curMatchOrder_ = Convert.ToInt32(curMatch);
                curGameOrder_  = Convert.ToInt32(curGame);
                return(true);
            }
            catch (System.Exception e)
            {
                LastErrorString = e.ToString();
                BDCommon.Writelog("ParsedActionXml异常", e.ToString());
                return(false);
            }
        }
Пример #17
0
        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();
                }
            }
        }