コード例 #1
0
ファイル: UCController.cs プロジェクト: github4n/caicai
 public XmlResult nonhighfreq()
 {
     try
     {
         XmlDocument   xmlDoc     = new XmlDocument();
         XmlSerializer serializer = new XmlSerializer(typeof(XmlDocument));
         var           b          = RedisManager.DB_Other.Get <byte[]>("UC_nonhighfreq");
         if (b == null || b.Length == 0)
         {
             xmlDoc = LoadXmlDocument("http://lottery.jdddata.com/uc/nonhighfreq");
             if (xmlDoc == null || xmlDoc.DocumentElement.ChildNodes.Count == 0)
             {
                 return(new XmlResult(xmlDoc));
             }
             var commonConfig = ConfigFileHelper.Get <List <NoHeightLottery> >("NoHeightLottery");
             var nodes        = xmlDoc.DocumentElement.ChildNodes;
             foreach (XmlElement element in nodes)
             {
                 var Common = commonConfig.Where(x => x.key == element.FirstChild.InnerText).FirstOrDefault();
                 if (Common == null)
                 {
                     continue;
                 }
                 //var Issue = ((XmlElement)element.GetElementsByTagName("qihao")[0]).InnerText;
                 //if (string.IsNullOrEmpty(Issue))
                 //{
                 //    continue;
                 //}
                 // + Issue
                 var titelUrl = Common.title_url;
                 var morelink = Common.morelink;
                 foreach (XmlElement Sub_element in element.LastChild)
                 {
                     if (Sub_element.Name == "source")
                     {
                         Sub_element.InnerText = Source;
                     }
                     if (Sub_element.Name == "title_url")
                     {
                         Sub_element.InnerText = titelUrl;
                     }
                     if (Sub_element.Name == "bet")
                     {
                         var remark = Common.foot_group.Where(x => x.remark == Sub_element.FirstChild.InnerText).FirstOrDefault();
                         if (remark == null)
                         {
                             continue;
                         }
                         ((XmlElement)Sub_element.LastChild).InnerText = remark.url;
                     }
                     if (Sub_element.Name == "foot_group")
                     {
                         foreach (XmlElement Sub_foot_group in Sub_element.ChildNodes)
                         {
                             if (Sub_foot_group.Attributes["name"].InnerText == "开奖详情")
                             {
                                 Sub_foot_group.SetAttribute("url", titelUrl);
                             }
                             else if (Sub_foot_group.Attributes["name"].InnerText == "玩法说明")
                             {
                                 Sub_foot_group.SetAttribute("url", Common.foot_group.Where(x => x.remark == Sub_foot_group.Attributes["name"].InnerText).FirstOrDefault().url);
                             }
                         }
                     }
                     if (Sub_element.Name == "morelink")
                     {
                         Sub_element.SetAttribute("url", morelink);
                     }
                 }
             }
             MemoryStream ms = new MemoryStream();
             serializer.Serialize(ms, xmlDoc);
             RedisManager.DB_Other.Set("UC_nonhighfreq", ms.ToArray(), 60 * 3);
         }
         else
         {
             MemoryStream ms1 = new MemoryStream(b);
             xmlDoc = serializer.Deserialize(ms1) as XmlDocument;
         }
         return(new XmlResult(xmlDoc));
     }
     catch (Exception ex)
     {
         XmlDocument xmlDoc = new XmlDocument();
         return(new XmlResult(xmlDoc));
     }
 }
コード例 #2
0
 public void UCNohighfreq_Redis()
 {
     try
     {
         XmlDocument   xmlDoc     = new XmlDocument();
         XmlSerializer serializer = new XmlSerializer(typeof(XmlDocument));
         xmlDoc = LoadXmlDocument("http://lottery.jdddata.com/uc/nonhighfreq");
         var commonConfig = ConfigFileHelper.Get <List <NoHeightLottery> >("NoHeightLottery");
         if (xmlDoc == null || xmlDoc.DocumentElement.ChildNodes.Count == 0)
         {
             return;
         }
         var nodes = xmlDoc.DocumentElement.ChildNodes;
         foreach (XmlElement element in nodes)
         {
             var Common = commonConfig.Where(x => x.key == element.FirstChild.InnerText).FirstOrDefault();
             if (Common == null)
             {
                 continue;
             }
             var titelUrl = Common.title_url;
             var morelink = Common.morelink;
             foreach (XmlElement Sub_element in element.LastChild)
             {
                 if (Sub_element.Name == "source")
                 {
                     Sub_element.InnerText = Source;
                 }
                 if (Sub_element.Name == "title_url")
                 {
                     Sub_element.InnerText = titelUrl;
                 }
                 if (Sub_element.Name == "bet")
                 {
                     var remark = Common.foot_group.Where(x => x.remark == Sub_element.FirstChild.InnerText).FirstOrDefault();
                     if (remark == null)
                     {
                         continue;
                     }
                     ((XmlElement)Sub_element.LastChild).InnerText = remark.url;
                 }
                 if (Sub_element.Name == "foot_group")
                 {
                     foreach (XmlElement Sub_foot_group in Sub_element.ChildNodes)
                     {
                         if (Sub_foot_group.Attributes["name"].InnerText == "开奖详情")
                         {
                             Sub_foot_group.SetAttribute("url", titelUrl);
                         }
                         else if (Sub_foot_group.Attributes["name"].InnerText == "玩法说明")
                         {
                             Sub_foot_group.SetAttribute("url", Common.foot_group.Where(x => x.remark == Sub_foot_group.Attributes["name"].InnerText).FirstOrDefault().url);
                         }
                     }
                 }
                 if (Sub_element.Name == "morelink")
                 {
                     Sub_element.SetAttribute("url", morelink);
                 }
             }
         }
         MemoryStream ms = new MemoryStream();
         serializer.Serialize(ms, xmlDoc);
         RedisManager.DB_Other.Set("UC_nonhighfreq", ms.ToArray());
     }
     catch (Exception ex)
     {
     }
 }