コード例 #1
0
ファイル: NuoMiXml.cs プロジェクト: gcgc100/gittest
 public override oneUrl getOneUrl(int pos)
 {
     try
     {
         oneUrl temp = new oneUrl();
         if (xmldoc.DocumentElement == null)
             throw new System.NullReferenceException();
         XmlNode xmlNode = xmldoc.DocumentElement.ChildNodes[pos];
         temp.url = xmlNode.ChildNodes[0].FirstChild.Value;
         temp.time = Convert.ToInt32(xmlNode.ChildNodes[1].FirstChild.ChildNodes[10].FirstChild.Value);
         temp.feat = Convert.ToInt32(xmlNode.ChildNodes[1].FirstChild.ChildNodes[15].FirstChild.Value);
         temp.discount = Convert.ToDouble(xmlNode.ChildNodes[1].FirstChild.ChildNodes[14].FirstChild.Value);
         temp.deal_title = xmlNode.ChildNodes[1].FirstChild.ChildNodes[7].FirstChild.Value;
         temp.seller = "糯米网";
         temp.description = temp.deal_title + " 原价" + Convert.ToDouble(xmlNode.ChildNodes[1].FirstChild.ChildNodes[12].FirstChild.Value) +"元,现价仅售" + Convert.ToDouble(xmlNode.ChildNodes[1].FirstChild.ChildNodes[13].FirstChild.Value) + "元";
         temp.other = "";
         foreach (XmlNode shops in xmlNode.ChildNodes[1].FirstChild.ChildNodes[16].ChildNodes)
         {
             temp.other += (shops.ChildNodes[0].FirstChild != null ? shops.ChildNodes[0].FirstChild.Value : "") +
                 (shops.ChildNodes[2].FirstChild != null ? shops.ChildNodes[2].FirstChild.Value : "") +
                 (shops.ChildNodes[3].FirstChild != null ? shops.ChildNodes[3].FirstChild.Value : "");
         }
         Console.WriteLine("Get one item.");
         return temp;
     }
     catch(System.NullReferenceException e)
     {
         Console.WriteLine(e);
         return new oneUrl();
     }
 }
コード例 #2
0
 public override oneUrl getOneUrl(int pos)
 {
     try
     {
         oneUrl temp = new oneUrl();
         if (xmldoc.DocumentElement == null)
         {
             throw new System.NullReferenceException();
         }
         XmlNode xmlNode = xmldoc.DocumentElement.ChildNodes[pos];
         temp.url         = xmlNode.ChildNodes[0].FirstChild.Value;
         temp.time        = Convert.ToInt32(xmlNode.ChildNodes[1].FirstChild.ChildNodes[10].FirstChild.Value);
         temp.feat        = Convert.ToInt32(xmlNode.ChildNodes[1].FirstChild.ChildNodes[15].FirstChild.Value);
         temp.discount    = Convert.ToDouble(xmlNode.ChildNodes[1].FirstChild.ChildNodes[14].FirstChild.Value);
         temp.deal_title  = xmlNode.ChildNodes[1].FirstChild.ChildNodes[7].FirstChild.Value;
         temp.seller      = "糯米网";
         temp.description = temp.deal_title + " 原价" + Convert.ToDouble(xmlNode.ChildNodes[1].FirstChild.ChildNodes[12].FirstChild.Value) + "元,现价仅售" + Convert.ToDouble(xmlNode.ChildNodes[1].FirstChild.ChildNodes[13].FirstChild.Value) + "元";
         temp.other       = "";
         foreach (XmlNode shops in xmlNode.ChildNodes[1].FirstChild.ChildNodes[16].ChildNodes)
         {
             temp.other += (shops.ChildNodes[0].FirstChild != null ? shops.ChildNodes[0].FirstChild.Value : "") +
                           (shops.ChildNodes[2].FirstChild != null ? shops.ChildNodes[2].FirstChild.Value : "") +
                           (shops.ChildNodes[3].FirstChild != null ? shops.ChildNodes[3].FirstChild.Value : "");
         }
         Console.WriteLine("Get one item.");
         return(temp);
     }
     catch (System.NullReferenceException e)
     {
         Console.WriteLine(e);
         return(new oneUrl());
     }
 }
コード例 #3
0
ファイル: Statistic.cs プロジェクト: gcgc100/gittest
 public Statistic(oneUrl item)
 {
     initDict();
     output = new StatisticOutput();
     output.time = item.time;
     output.feat = item.feat;
     output.discount = 100 - Convert.ToInt32(10 * Convert.ToDouble(item.discount));
     output.title = item.seller + "-" + item.deal_title;
     output.description = item.description;
     output.keywordList = new Hashtable();
     splitwords(output.title, TITLE_WEIGHT);
     splitwords(item.other, OTHER_WEIGHT);
     splitwords(item.description, DESCRIPTION_WEIGHT);
 }
コード例 #4
0
ファイル: Statistic.cs プロジェクト: gcgc100/gittest
 public StatisticOutput statistic(oneUrl item)
 {
     //统计item中存储的团购条目信息
     Console.WriteLine("Computing the statisitc data of the item...");
     StatisticOutput oneOutput = new StatisticOutput();
     oneOutput.url = item.url;
     oneOutput.time = item.time;
     oneOutput.feat = item.feat;
     oneOutput.discount = 100 - Convert.ToInt32(10 * Convert.ToDouble(item.discount));
     oneOutput.title = item.seller + "-" + item.deal_title;
     oneOutput.description = item.description;
     oneOutput.keywordList = new Hashtable();
     splitwords(ref oneOutput, oneOutput.title, TITLE_WEIGHT);
     splitwords(ref oneOutput, item.other, OTHER_WEIGHT);
     splitwords(ref oneOutput, item.description, DESCRIPTION_WEIGHT);
     Console.WriteLine("Statistic ready.");
     return oneOutput;
 }