Exemplo n.º 1
0
 void client_GetPostTrendCompleted(object sender, GetPostTrendCompletedEventArgs e)
 {
     foreach (PostTrend item in e.Result)
     {
         PostTrendTable postTrendTable = new PostTrendTable()
         {
             Describe   = item.Describe,
             PostAffect = item.PostAffect,
             Time       = item.Time,
             UserId     = item.UserId,
             Name       = item.Name
         };
         db.PostTrends.InsertOnSubmit(postTrendTable);
     }
     db.SubmitChanges();
     dealWithPostTrend();
     callback1();
 }
Exemplo n.º 2
0
        private void  getData(PostModel postModel, PostTrendTable trend)
        {
            string name = trend.Describe.Substring(trend.Describe.LastIndexOf(' ') + 1);
            string Num  = trend.Describe.Substring(6);

            Num = Num.Substring(0, Num.IndexOf(' '));
            if (Constant.getDic_Danwei().Keys.Contains(name))
            {
                postModel.Describe = "Post " + Num + " " + Constant.getDic_Danwei()[name] + " " + name;
            }
            else
            {
                if (Int32.Parse(Num) > 1)
                {
                    postModel.Describe += "s";
                }
            }

            Affect affect;

            if (!Constant.getDictionary_Affect().ContainsKey(name))
            {
                affect = Constant.getDictionary_Affect()["other"];
            }
            else
            {
                affect = Constant.getDictionary_Affect()[name];
            }
            if (affect.carbon_emissions != 0)
            {
                postModel.Co2 = affect.carbon_emissions * Int32.Parse(Num);
            }
            if (affect.electricity != 0)
            {
                postModel.Electric = affect.electricity * Int32.Parse(Num);
            }
            if (affect.gasoline != 0)
            {
                postModel.Forest = affect.gasoline * Int32.Parse(Num);
            }

            list_PostModel.Add(postModel);
        }