Esempio n. 1
0
 public GameByteInfoParser(SGameByteInfo gameInfo)
 {
     gameInfo_ = gameInfo;
 }
Esempio n. 2
0
        public static string ConvertToMatchInfoXml(SGameByteInfo gameInfo)
        {
            GameByteInfoParser parser = new GameByteInfoParser(gameInfo);
            int    matchID            = parser.MatchID % 100000;
            string matchCode          = TSDataExchangeTT_Service.GetMatchCodeFromID(matchID);

            if (matchCode == null || matchCode == "")
            {
                return("");
            }
            MemoryStream  stream  = new MemoryStream();
            XmlTextWriter writter = new XmlTextWriter(stream, System.Text.Encoding.Default);

            writter.Formatting = Formatting.Indented;
            //顶层描述
            writter.WriteStartDocument();
            //第一级MatchInfo开始
            writter.WriteStartElement("MatchInfo");
            writter.WriteAttributeString("MatchCode", matchCode);
            //第二级Duel开始
            writter.WriteStartElement("Duel");
            //第二级属性
            writter.WriteAttributeString("DuelState", parser.DuelState);
            writter.WriteAttributeString("DuelScoreA", parser.TotalScoreA.ToString());
            writter.WriteAttributeString("DuelScoreB", parser.TotalScoreB.ToString());
            writter.WriteAttributeString("DuelTime", parser.GetDuelTime());
            writter.WriteAttributeString("DuelWLA", parser.DuelWLA.ToString());
            writter.WriteAttributeString("DuelWLB", parser.DuelWLB.ToString());
            writter.WriteAttributeString("DuelStatusA", parser.DuelJugeA);
            writter.WriteAttributeString("DuelStatusB", parser.DuelJugeB);

            //第三级SubMatch
            for (int iMatchNo = 1; iMatchNo <= parser.CurSubMatchNo; iMatchNo++)
            {
                //第三级开始
                writter.WriteStartElement("SubMatch");
                //第三级属性
                writter.WriteAttributeString("Match_No", iMatchNo.ToString());
                writter.WriteAttributeString("MatchScoreA", parser.GetSetScoreA(iMatchNo).ToString());
                writter.WriteAttributeString("MatchScoreB", parser.GetSetScoreB(iMatchNo).ToString());
                writter.WriteAttributeString("MatchTime", parser.GetSetTime(iMatchNo).ToString());
                writter.WriteAttributeString("MatchWLA", parser.GetSetWLA(iMatchNo).ToString());
                writter.WriteAttributeString("MatchWLB", parser.GetSetWLB(iMatchNo).ToString());
                writter.WriteAttributeString("MatchStatusA", parser.GetSetJudgeA(iMatchNo));
                writter.WriteAttributeString("MatchStatusB", parser.GetSetJudgeB(iMatchNo));
                writter.WriteAttributeString("MatchState", parser.GetSetState(iMatchNo).ToString());

                //第四级Game
                for (int iGameNo = 1; iGameNo <= parser.GetSetMaxGameCount(iMatchNo); iGameNo++)
                {
                    //第四级开始
                    writter.WriteStartElement("Game");
                    //第四级属性
                    writter.WriteAttributeString("Game_No", iGameNo.ToString());
                    writter.WriteAttributeString("GameScoreA", parser.GetGameScoreA(iMatchNo, iGameNo).ToString());
                    writter.WriteAttributeString("GameScoreB", parser.GetGameScoreB(iMatchNo, iGameNo).ToString());
                    writter.WriteAttributeString("GameTime", parser.GetGameTime(iMatchNo, iGameNo));
                    writter.WriteAttributeString("GameWLA", parser.GetGameWLA(iMatchNo, iGameNo).ToString());
                    writter.WriteAttributeString("GameWLB", parser.GetGameWLB(iMatchNo, iGameNo).ToString());
                    writter.WriteAttributeString("GameStatusA", parser.GetGameJudgeA(iMatchNo, iGameNo));
                    writter.WriteAttributeString("GameStatusB", parser.GetGameJudgeB(iMatchNo, iGameNo));
                    writter.WriteAttributeString("GameState", parser.GetGameState(iMatchNo, iGameNo).ToString());
                    writter.WriteEndElement();
                    //第四级结束
                }
                writter.WriteEndElement();
                //第三级结束
            }
            writter.WriteEndElement();
            //第二级结束
            writter.WriteEndElement();
            //第一级结束

            writter.Flush();
            writter.Close();
            byte[] data = stream.ToArray();
            stream.Close();

            string strXml = System.Text.Encoding.Default.GetString(data);

            if (parser.MatchID >= 9000000)
            {
                return("[TEMP]|" + parser.MatchID.ToString() + "|" + strXml);
            }
            return(strXml);
        }