Ejemplo n.º 1
0
 public TTXmlItem(string strData, long size, string oldPath, string newPath, TTXmlItemType itemType, TTXmlExtraData extraData, bool bAllowSame = false)
 {
     StrData    = strData;
     FileLength = size;
     OldPath    = oldPath;
     NewPath    = newPath;
     ItemType   = itemType;
     ExtraData  = extraData;
     BAllowSame = bAllowSame;
 }
Ejemplo n.º 2
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);
        }