Пример #1
0
 public List<Maticsoft.Model.Poll.UserPoll> GetModelList(string strWhere)
 {
     DataSet set = this.dal.GetList(strWhere);
     List<Maticsoft.Model.Poll.UserPoll> list = new List<Maticsoft.Model.Poll.UserPoll>();
     int count = set.Tables[0].Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Poll.UserPoll item = new Maticsoft.Model.Poll.UserPoll();
             if (set.Tables[0].Rows[i]["UserID"].ToString() != "")
             {
                 item.UserID = int.Parse(set.Tables[0].Rows[i]["UserID"].ToString());
             }
             if (set.Tables[0].Rows[i]["TopicID"].ToString() != "")
             {
                 item.TopicID = new int?(int.Parse(set.Tables[0].Rows[i]["TopicID"].ToString()));
             }
             if (set.Tables[0].Rows[i]["OptionID"].ToString() != "")
             {
                 item.OptionID = new int?(int.Parse(set.Tables[0].Rows[i]["OptionID"].ToString()));
             }
             if (set.Tables[0].Rows[i]["CreatTime"].ToString() != "")
             {
                 item.CreatTime = new DateTime?(DateTime.Parse(set.Tables[0].Rows[i]["CreatTime"].ToString()));
             }
             item.UserIP = set.Tables[0].Rows[0]["UserIP"].ToString();
             list.Add(item);
         }
     }
     return list;
 }
Пример #2
0
 public ActionResult SubmitPoll(FormCollection fm)
 {
     string str = fm["TopicIDjson"];
     if (base.Request.Cookies["votetopic"] != null)
     {
         return base.Content("isnotnull");
     }
     if (string.IsNullOrWhiteSpace(str))
     {
         return base.Content("false");
     }
     Maticsoft.BLL.Poll.PollUsers users = new Maticsoft.BLL.Poll.PollUsers();
     Maticsoft.Model.Poll.PollUsers model = new Maticsoft.Model.Poll.PollUsers();
     int num = users.Add(model);
     if (num < 0)
     {
         return base.Content("false");
     }
     Maticsoft.Model.Poll.UserPoll poll = new Maticsoft.Model.Poll.UserPoll();
     Maticsoft.BLL.Poll.UserPoll poll2 = new Maticsoft.BLL.Poll.UserPoll();
     poll.UserIP = base.Request.UserHostAddress;
     poll.UserID = num;
     foreach (JsonObject obj2 in JsonConvert.Import<JsonArray>(str))
     {
         int num2 = Globals.SafeInt(obj2["topicid"].ToString(), 0);
         string text = obj2["topicvlaue"].ToString();
         int num3 = Globals.SafeInt(obj2["type"].ToString(), -1);
         poll.TopicID = new int?(num2);
         switch (num3)
         {
             case 0:
             {
                 poll.OptionID = new int?(Globals.SafeInt(text, -1));
                 poll2.Add(poll);
                 continue;
             }
             case 1:
             {
                 poll.OptionIDList = text;
                 if (!string.IsNullOrWhiteSpace(text))
                 {
                     poll2.Add2(poll);
                 }
                 continue;
             }
             case 2:
             {
                 continue;
             }
         }
     }
     HttpCookie cookie = new HttpCookie("votetopic");
     cookie.Values.Add("voteid", "votetopic");
     cookie.Expires = DateTime.Now.AddHours(240.0);
     base.Response.Cookies.Add(cookie);
     return base.Content("true");
 }
Пример #3
0
 public void SubmitPoll(FormCollection collection)
 {
     JsonObject obj2 = new JsonObject();
     if (base.Request.Cookies["vote" + collection["FID"]] != null)
     {
         obj2.Accumulate("STATUS", "805");
         obj2.Accumulate("DATA", "您已经投过票,请不要重复投票!");
     }
     else
     {
         Maticsoft.Model.Poll.UserPoll model = new Maticsoft.Model.Poll.UserPoll();
         Maticsoft.BLL.Poll.UserPoll poll2 = new Maticsoft.BLL.Poll.UserPoll();
         model.UserID = Globals.SafeInt(collection["UID"], 0);
         model.UserIP = base.Request.UserHostAddress;
         string str = collection["Option"];
         if (!string.IsNullOrWhiteSpace(str))
         {
             string[] strArray = str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
             int num = 0;
             foreach (string str2 in strArray)
             {
                 string[] strArray2 = str2.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                 model.TopicID = new int?(Globals.SafeInt(strArray2[0], -1));
                 model.OptionID = new int?(Globals.SafeInt(strArray2[1], -1));
                 poll2.Add(model);
                 num++;
             }
             if (num == strArray.Length)
             {
                 HttpCookie cookie = new HttpCookie("vote" + collection["FID"]);
                 cookie.Values.Add("voteid", collection["FID"]);
                 cookie.Expires = DateTime.Now.AddHours(240.0);
                 base.Response.Cookies.Add(cookie);
                 obj2.Accumulate("STATUS", "800");
             }
             else
             {
                 obj2.Accumulate("STATUS", "804");
             }
         }
         else
         {
             obj2.Accumulate("STATUS", "804");
         }
     }
     base.Response.Write(obj2.ToString());
 }