Пример #1
0
 private LastMatchStatusInfo GetOrCreateLastMatchStatusInfo(string matchCode)
 {
     if (lastMatchInfos_.ContainsKey(matchCode))
     {
         LastMatchStatusInfo lastInfo = null;
         if (lastMatchInfos_.TryGetValue(matchCode, out lastInfo))
         {
             return(lastInfo);
         }
         else
         {
             LastErrorString = "LastInfo例程字典出现错误!";
             return(null);
         }
     }
     else
     {
         LastMatchStatusInfo lastInfo = new LastMatchStatusInfo();
         lastMatchInfos_.Add(matchCode, lastInfo);
         return(lastInfo);
     }
 }
Пример #2
0
        //更新额外的任务
        public bool UpdateExtraTaskInfo(string strXml)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(strXml);
                XmlNode xmlNode = xmlDoc.SelectSingleNode("/MatchInfo");
                if (xmlNode == null)
                {
                    LastErrorString   = "查找<MatchInfo 失败";
                    ExtraTask.BTaskOK = false;
                    return(false);
                }
                XmlNode firstNode = xmlNode.FirstChild;
                if (firstNode == null)
                {
                    LastErrorString   = "查找<MatchInfo的第一子级失败";
                    ExtraTask.BTaskOK = false;
                    return(false);
                }

                //MatchInfo信息
                if (firstNode.Name == "Duel")
                {
                    ExtraTask.MatchID = GetMatchIDFromRSC(MatchCode);
                    if (ExtraTask.MatchID <= 0)
                    {
                        ExtraTask.BTaskOK = false;
                        return(false);
                    }
                    ExtraTask.TaskFlags  = (int)ExtraWorkEnum.ExtraWorkNotifyProgress;
                    ExtraTask.TaskFlags |= (int)ExtraWorkEnum.ExtraWorkNotifySplitInfo;
                    LastMatchStatusInfo lastInfo = GetOrCreateLastMatchStatusInfo(MatchCode);
                    string newStatus             = firstNode.Attributes["DuelState"].Value.ToString();
                    if (lastInfo.LastMatchStatus != newStatus)
                    {
                        if (newStatus == "4")
                        {
                            ExtraTask.TaskFlags |= (int)ExtraWorkEnum.ExtraWorkNotifyStatusRunning;
                        }
                        else if (newStatus == "5")
                        {
                            ExtraTask.TaskFlags |= (int)ExtraWorkEnum.ExtraWorkNotifyStatusUnofficial;
                        }
                        else if (newStatus == "2")
                        {
                            ExtraTask.TaskFlags |= (int)ExtraWorkEnum.ExtraWorkNotifyStatusStartList;
                        }
                        lastInfo.LastMatchStatus = newStatus;
                    }
                    else if (newStatus == "5") //unofficial永远都触发
                    {
                        ExtraTask.TaskFlags |= (int)ExtraWorkEnum.ExtraWorkNotifyStatusUnofficial;
                    }
                }
                else if (firstNode.Name == "Score")
                {
                    ExtraTask.MatchID = GetMatchIDFromRSC(MatchCode);
                    if (ExtraTask.MatchID <= 0)
                    {
                        ExtraTask.BTaskOK = false;
                        return(false);
                    }
                    ExtraTask.TaskFlags = (int)ExtraWorkEnum.ExtraWorkNotifyProgress;
                }
                else if (firstNode.Name == "Export")
                {
                    ExtraTask.TaskFlags = (int)ExtraWorkEnum.ExtraWorkNotifyExportSchedule;
                }
                else if (firstNode.Name == "Chat")
                {
                    ExtraTask.TaskFlags   = (int)ExtraWorkEnum.ExtraWorkNotifyChat;
                    ExtraTask.ChatName    = firstNode.Attributes["Name"].Value.ToString();
                    ExtraTask.ChatIP      = firstNode.Attributes["IP"].Value.ToString();
                    ExtraTask.ChatContent = firstNode.Attributes["Message"].Value.ToString();
                }
                else
                {
                    ExtraTask.BTaskOK = false;
                    return(false);
                }
            }
            catch (Exception e)
            {
                LastErrorString = e.Message;
                return(false);
            }
            ExtraTask.BTaskOK = true;
            return(true);
        }