Example #1
0
 protected override void Render(HtmlTextWriter writer)
 {
     if (this.Activity != null)
     {
         PrizeQuery page = new PrizeQuery {
             ActivityId = this.Activity.ActivityId,
             SortOrder = SortAction.Desc,
             SortBy = "PrizeTime"
         };
         IOrderedEnumerable<PrizeRecordInfo> source = from a in VshopBrowser.GetPrizeList(page)
             orderby a.PrizeTime descending
             select a;
         StringBuilder builder = new StringBuilder();
         if ((source != null) && (source.Count<PrizeRecordInfo>() > 0))
         {
             foreach (PrizeRecordInfo info in source)
             {
                 if (!string.IsNullOrEmpty(info.CellPhone) && !string.IsNullOrEmpty(info.RealName))
                 {
                     builder.AppendFormat("<p>{0}&nbsp;&nbsp;{1} &nbsp;&nbsp;{2}</p>", info.Prizelevel, this.ShowCellPhone(info.CellPhone), info.RealName);
                 }
             }
             writer.Write(builder.ToString());
         }
         else
         {
             builder.AppendFormat("<p>暂无获奖名单!</p>", new object[0]);
         }
     }
 }
Example #2
0
 protected void BindPrizeList()
 {
     PrizeQuery page = new PrizeQuery {
         ActivityId = this.activeid
     };
     List<PrizeRecordInfo> prizeList = VShopHelper.GetPrizeList(page);
     if ((prizeList != null) && (prizeList.Count > 0))
     {
         this.LitTitle.Text = prizeList[0].ActivityName;
     }
     this.rpMaterial.DataSource = prizeList;
     this.rpMaterial.DataBind();
 }
Example #3
0
 public List<PrizeRecordInfo> GetPrizeList(PrizeQuery page)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select ActivityName=(select  ActivityName from Vshop_LotteryActivity a where a.ActivityId=b.ActivityId),");
     builder.Append("UserName=(select UserName from aspnet_Members c where  c.UserId=b.UserId),");
     builder.Append(" b.* from Vshop_PrizeRecord b");
     if (page.ActivityId != 0)
     {
         builder.AppendFormat(" where b.ActivityId={0}", page.ActivityId);
     }
     builder.AppendFormat(" and b.IsPrize=1", new object[0]);
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         return (ReaderConvert.ReaderToList<PrizeRecordInfo>(reader) as List<PrizeRecordInfo>);
     }
 }
Example #4
0
 private void GetPrize(HttpContext context)
 {
     context.Response.ContentType = "application/json";
     int result = 1;
     int.TryParse(context.Request["activityid"], out result);
     LotteryActivityInfo lotteryActivity = VshopBrowser.GetLotteryActivity(result);
     int userPrizeCount = VshopBrowser.GetUserPrizeCount(result);
     if (MemberProcessor.GetCurrentMember() == null)
     {
         MemberInfo member = new MemberInfo();
         string generateId = Globals.GetGenerateId();
         member.GradeId = MemberProcessor.GetDefaultMemberGrade();
         member.UserName = "";
         member.OpenId = "";
         member.CreateDate = DateTime.Now;
         member.SessionId = generateId;
         member.SessionEndTime = DateTime.Now;
         MemberProcessor.CreateMember(member);
         member = MemberProcessor.GetMember(generateId);
         HttpCookie cookie = new HttpCookie("Vshop-Member") {
             Value = member.UserId.ToString(),
             Expires = DateTime.Now.AddYears(10)
         };
         HttpContext.Current.Response.Cookies.Add(cookie);
     }
     StringBuilder builder = new StringBuilder();
     builder.Append("{");
     if (userPrizeCount >= lotteryActivity.MaxNum)
     {
         builder.Append("\"No\":\"-1\"");
         builder.Append("}");
         context.Response.Write(builder.ToString());
     }
     else if ((DateTime.Now < lotteryActivity.StartTime) || (DateTime.Now > lotteryActivity.EndTime))
     {
         builder.Append("\"No\":\"-3\"");
         builder.Append("}");
         context.Response.Write(builder.ToString());
     }
     else
     {
         PrizeQuery page = new PrizeQuery {
             ActivityId = result
         };
         List<PrizeRecordInfo> prizeList = VshopBrowser.GetPrizeList(page);
         int num3 = 0;
         int num4 = 0;
         int num5 = 0;
         int num6 = 0;
         int num7 = 0;
         int num8 = 0;
         if ((prizeList != null) && (prizeList.Count > 0))
         {
             num3 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "一等奖");
             num4 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "二等奖");
             num5 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "三等奖");
         }
         PrizeRecordInfo model = new PrizeRecordInfo {
             PrizeTime = new DateTime?(DateTime.Now),
             UserID = Globals.GetCurrentMemberUserId(),
             ActivityName = lotteryActivity.ActivityName,
             ActivityID = result,
             IsPrize = true
         };
         List<PrizeSetting> prizeSettingList = lotteryActivity.PrizeSettingList;
         decimal num9 = prizeSettingList[0].Probability * 100M;
         decimal num10 = prizeSettingList[1].Probability * 100M;
         decimal num11 = prizeSettingList[2].Probability * 100M;
         int num15 = new Random(Guid.NewGuid().GetHashCode()).Next(1, 0x2711);
         if (prizeSettingList.Count > 3)
         {
             decimal num12 = prizeSettingList[3].Probability * 100M;
             decimal num13 = prizeSettingList[4].Probability * 100M;
             decimal num14 = prizeSettingList[5].Probability * 100M;
             num6 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "四等奖");
             num7 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "五等奖");
             num8 = prizeList.Count<PrizeRecordInfo>(a => a.Prizelevel == "六等奖");
             if ((num15 < num9) && (prizeSettingList[0].PrizeNum > num3))
             {
                 builder.Append("\"No\":\"9\"");
                 model.Prizelevel = "一等奖";
                 model.PrizeName = prizeSettingList[0].PrizeName;
             }
             else if ((num15 < num10) && (prizeSettingList[1].PrizeNum > num4))
             {
                 builder.Append("\"No\":\"11\"");
                 model.Prizelevel = "二等奖";
                 model.PrizeName = prizeSettingList[1].PrizeName;
             }
             else if ((num15 < num11) && (prizeSettingList[2].PrizeNum > num5))
             {
                 builder.Append("\"No\":\"1\"");
                 model.Prizelevel = "三等奖";
                 model.PrizeName = prizeSettingList[2].PrizeName;
             }
             else if ((num15 < num12) && (prizeSettingList[3].PrizeNum > num6))
             {
                 builder.Append("\"No\":\"3\"");
                 model.Prizelevel = "四等奖";
                 model.PrizeName = prizeSettingList[3].PrizeName;
             }
             else if ((num15 < num13) && (prizeSettingList[4].PrizeNum > num7))
             {
                 builder.Append("\"No\":\"5\"");
                 model.Prizelevel = "五等奖";
                 model.PrizeName = prizeSettingList[4].PrizeName;
             }
             else if ((num15 < num14) && (prizeSettingList[5].PrizeNum > num8))
             {
                 builder.Append("\"No\":\"7\"");
                 model.Prizelevel = "六等奖";
                 model.PrizeName = prizeSettingList[5].PrizeName;
             }
             else
             {
                 model.IsPrize = false;
                 builder.Append("\"No\":\"0\"");
             }
         }
         else if ((num15 < num9) && (prizeSettingList[0].PrizeNum > num3))
         {
             builder.Append("\"No\":\"9\"");
             model.Prizelevel = "一等奖";
             model.PrizeName = prizeSettingList[0].PrizeName;
         }
         else if ((num15 < num10) && (prizeSettingList[1].PrizeNum > num4))
         {
             builder.Append("\"No\":\"11\"");
             model.Prizelevel = "二等奖";
             model.PrizeName = prizeSettingList[1].PrizeName;
         }
         else if ((num15 < num11) && (prizeSettingList[2].PrizeNum > num5))
         {
             builder.Append("\"No\":\"1\"");
             model.Prizelevel = "三等奖";
             model.PrizeName = prizeSettingList[2].PrizeName;
         }
         else
         {
             model.IsPrize = false;
             builder.Append("\"No\":\"0\"");
         }
         builder.Append("}");
         if (context.Request["activitytype"] != "scratch")
         {
             VshopBrowser.AddPrizeRecord(model);
         }
         context.Response.Write(builder.ToString());
     }
 }
Example #5
0
 public static List<PrizeRecordInfo> GetPrizeList(PrizeQuery page)
 {
     return new LotteryActivityDao().GetPrizeList(page);
 }
Example #6
0
 public static List<PrizeRecordInfo> GetPrizeList(PrizeQuery page)
 {
     return new PrizeRecordDao().GetPrizeList(page);
 }