Пример #1
0
        public WKMInfo GetWKMInfo(Guid wkmId)
        {
            WKMInfo   info             = new WKMInfo();
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("select * from WKM_Main where id=@id;select * from WKM_Subject where ActivityId=@id");

            this.database.AddInParameter(sqlStringCommand, "id", DbType.Guid, wkmId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                //活动主要信息
                if (reader.Read())
                {
                    info.WKMId            = (Guid)reader["Id"];
                    info.TitleDescription = (string)reader["TitleDescription"];
                    info.ShareTitle       = (string)reader["ShareTitle"];
                    info.ShareDescription = (string)reader["ShareDescription"];
                    info.StartDate        = (reader["StartDate"] == DBNull.Value) ? DateTime.MinValue : ((DateTime)reader["StartDate"]);
                    info.EndDate          = (reader["EndDate"] == DBNull.Value ? DateTime.MinValue : (DateTime)reader["EndDate"]);
                }
                //活动题目内容
                reader.NextResult();
                int i = 0;
                while (reader.Read())
                {
                    info.SubjectInfo.WKMSubjectId.Add((Guid)reader["Id"]);
                    info.SubjectInfo.SubjectContent.Add((string)reader["SubjectContent"]);
                    info.SubjectInfo.ActivityId.Add((Guid)reader["ActivityId"]);
                    info.SubjectInfo.ImgUrl.Add(reader["imgUrl"] == DBNull.Value ? "" : (string)reader["imgUrl"]);
                    //活动题目答案内容
                    info.OptionsInfo.Add(GetWKMOptInfoBySubjectId((Guid)reader["Id"]));
                    i++;
                }
            }
            return(info);
        }
Пример #2
0
        /*
         * public PromotionInfo GetReducedPromotion(Member member, decimal amount, int quantity, out decimal reducedAmount)
         * {
         *  DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Promotions WHERE DateDiff(DD, StartDate, getdate()) >= 0 AND DateDiff(DD, EndDate, getdate()) <= 0 AND PromoteType BETWEEN 11 AND 14 AND ActivityId IN (SELECT ActivityId FROM Hishop_PromotionMemberGrades WHERE GradeId = @GradeId)");
         *  this.database.AddInParameter(sqlStringCommand, "GradeId", DbType.Int32, member.GradeId);
         *  IList<PromotionInfo> list = new List<PromotionInfo>();
         *  using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
         *  {
         *      while (reader.Read())
         *      {
         *          list.Add(DataMapper.PopulatePromote(reader));
         *      }
         *  }
         *  PromotionInfo info = null;
         *  reducedAmount = 0M;
         *  foreach (PromotionInfo info2 in list)
         *  {
         *      switch (info2.PromoteType)
         *      {
         *          case PromoteType.FullAmountDiscount:
         *              if ((amount >= info2.Condition) && ((amount - (amount * info2.DiscountValue)) > reducedAmount))
         *              {
         *                  reducedAmount = amount - (amount * info2.DiscountValue);
         *                  info = info2;
         *              }
         *              break;
         *
         *          case PromoteType.FullAmountReduced:
         *              if ((amount >= info2.Condition) && (info2.DiscountValue > reducedAmount))
         *              {
         *                  reducedAmount = info2.DiscountValue;
         *                  info = info2;
         *              }
         *              break;
         *
         *          case PromoteType.FullQuantityDiscount:
         *              if ((quantity >= ((int) info2.Condition)) && ((amount - (amount * info2.DiscountValue)) > reducedAmount))
         *              {
         *                  reducedAmount = amount - (amount * info2.DiscountValue);
         *                  info = info2;
         *              }
         *              break;
         *
         *          case PromoteType.FullQuantityReduced:
         *              if ((quantity >= ((int) info2.Condition)) && (info2.DiscountValue > reducedAmount))
         *              {
         *                  reducedAmount = info2.DiscountValue;
         *                  info = info2;
         *              }
         *              break;
         *      }
         *  }
         *  return info;
         * }
         *
         * public PromotionInfo GetSendPromotion(Member member, decimal amount, PromoteType promoteType)
         * {
         *  DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Promotions WHERE DateDiff(DD, StartDate, getdate()) >= 0 AND DateDiff(DD, EndDate, getdate()) <= 0 AND PromoteType = @PromoteType AND Condition <= @Condition AND ActivityId IN (SELECT ActivityId FROM Hishop_PromotionMemberGrades WHERE GradeId = @GradeId) ORDER BY DiscountValue DESC");
         *  this.database.AddInParameter(sqlStringCommand, "PromoteType", DbType.Int32, (int) promoteType);
         *  this.database.AddInParameter(sqlStringCommand, "Condition", DbType.Currency, amount);
         *  this.database.AddInParameter(sqlStringCommand, "GradeId", DbType.Int32, member.GradeId);
         *  PromotionInfo info = null;
         *  using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
         *  {
         *      if (reader.Read())
         *      {
         *          info = DataMapper.PopulatePromote(reader);
         *      }
         *  }
         *  return info;
         * }
         */

        public bool AddWKM(WKMInfo info)
        {
            string WKMCommand     = "insert into WKM_Main (id,TitleDescription,ShareTitle,ShareDescription,StartDate,EndDate)values(@id,@TitleDescription,@ShareTitle,@ShareDescription,@StartDate,@EndDate);";
            string subjectCommand = string.Empty;
            string optionCommand  = string.Empty;
            string command        = string.Empty;

            for (int i = 0; i < info.SubjectInfo.WKMSubjectId.Count; i++)
            {
                //插入题目内容
                subjectCommand += string.Format("insert into WKM_Subject (id,ActivityId,SubjectContent,imgUrl) values('{0}','{1}','{2}','{3}');", info.SubjectInfo.WKMSubjectId[i], info.SubjectInfo.ActivityId[i], info.SubjectInfo.SubjectContent[i], info.SubjectInfo.ImgUrl[i]);
                //插入该题目的答案选项内容
                for (int j = 0; j < info.OptionsInfo[i].WKMOptionId.Count; j++)
                {
                    optionCommand += string.Format("insert into WKM_Options (id,TitleId,OptionContent) values('{0}','{1}','{2}');", info.OptionsInfo[i].WKMOptionId[j], info.OptionsInfo[i].TitleId[j], info.OptionsInfo[i].OptionContent[j]);
                }
            }
            command = (WKMCommand + subjectCommand + optionCommand).TrimEnd(';');//去掉末尾;

            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(command);

            this.database.AddInParameter(sqlStringCommand, "id", DbType.Guid, info.WKMId);
            this.database.AddInParameter(sqlStringCommand, "TitleDescription", DbType.String, info.TitleDescription);
            this.database.AddInParameter(sqlStringCommand, "ShareTitle", DbType.String, info.ShareTitle);
            this.database.AddInParameter(sqlStringCommand, "ShareDescription", DbType.String, info.ShareDescription);
            this.database.AddInParameter(sqlStringCommand, "StartDate", DbType.DateTime, info.StartDate);
            this.database.AddInParameter(sqlStringCommand, "EndDate", DbType.DateTime, info.EndDate);
            return(this.database.ExecuteNonQuery(sqlStringCommand) > 0);
        }
Пример #3
0
        protected void btnAddWKM_Click(object sender, System.EventArgs e)
        {
            HttpFileCollection files = Request.Files;

            IList <string> sbjList = subjectInfo.Value.Split(';'); //题目列
            IList <string> optList = optionInfo.Value.Split(';');  //选项列
            WKMInfo        wkmInfo = new WKMInfo();

            wkmInfo.WKMId            = Guid.NewGuid();
            wkmInfo.TitleDescription = txtDescription.Text.Trim();
            wkmInfo.ShareTitle       = txtShareTitle.Text.Trim();
            wkmInfo.ShareDescription = txtShareDescription.Text.Trim();
            wkmInfo.StartDate        = Convert.ToDateTime(calendarStartDate.Text);
            wkmInfo.EndDate          = Convert.ToDateTime(calendarEndDate.Text);
            //WKMSubjectInfo wkmSubjectInfo = new WKMSubjectInfo();
            //IList<WKMOptionInfo> wkmOptionInfo = new List<WKMOptionInfo>();
            for (int i = 0; i < sbjList.Count; i++)
            {
                Guid sbjGuid = Guid.NewGuid();
                wkmInfo.SubjectInfo.SubjectContent.Add(sbjList[i]);
                wkmInfo.SubjectInfo.WKMSubjectId.Add(sbjGuid);
                wkmInfo.SubjectInfo.ActivityId.Add(wkmInfo.WKMId);

                wkmInfo.OptionsInfo.Add(new WKMOptionInfo());
                IList <string> optListPerSbj = optList[i].Split('/');
                for (int j = 0; j < optListPerSbj.Count; j++)
                {
                    wkmInfo.OptionsInfo[i].OptionContent.Add(optListPerSbj[j]);
                    wkmInfo.OptionsInfo[i].WKMOptionId.Add(Guid.NewGuid());
                    wkmInfo.OptionsInfo[i].TitleId.Add(wkmInfo.SubjectInfo.WKMSubjectId[i]);
                }
                //图片实体保存到项目内
                if (files[i].ContentLength > 0)
                {
                    string fileName = sbjGuid + Path.GetExtension(files[i].FileName);
                    files[i].SaveAs(Server.MapPath("/Storage/master/topic/") + fileName);
                    wkmInfo.SubjectInfo.ImgUrl.Add("/Storage/master/topic/" + fileName);
                }
                else
                {
                    wkmInfo.SubjectInfo.ImgUrl.Add("");
                }
            }
            if (PromoteHelper.AddWKM(wkmInfo))
            {
                this.ShowMsgAndReUrl("添加成功!请将活动附加属性设置完毕后,方可推广使用!", true, "setWKMDetail.aspx?id=" + wkmInfo.WKMId);
            }
            else
            {
                this.ShowMsg("添加失败!", false);
            }
        }
Пример #4
0
        public void pageInit()
        {
            WKMInfo wkmInfo = PromoteHelper.GetWKMInfo(activityId);

            this.txtDescription.Text            = wkmInfo.TitleDescription;
            this.txtShareTitle.Text             = wkmInfo.ShareTitle;
            this.txtShareDescription.Text       = wkmInfo.ShareDescription;
            this.calendarStartDate.SelectedDate = Convert.ToDateTime(wkmInfo.StartDate);
            this.calendarEndDate.SelectedDate   = Convert.ToDateTime(wkmInfo.EndDate);
            for (int i = 0; i < wkmInfo.SubjectInfo.SubjectContent.Count; i++)
            {
                this.subjectInfo.Value += wkmInfo.SubjectInfo.SubjectContent[i] + ";";
                for (int j = 0; j < wkmInfo.OptionsInfo[i].OptionContent.Count; j++)
                {
                    this.optionInfo.Value += wkmInfo.OptionsInfo[i].OptionContent[j] + "/";
                }
                optionInfo.Value  = optionInfo.Value.TrimEnd('/');
                optionInfo.Value += ";";
            }
            subjectInfo.Value = subjectInfo.Value.Trim(';');
            optionInfo.Value  = optionInfo.Value.Trim(';');
        }
Пример #5
0
        protected void btnUpdateWKM_Click(object sender, System.EventArgs e)
        {
            WKMInfo            wkmInfo = PromoteHelper.GetWKMInfo(activityId);
            HttpFileCollection files   = Request.Files;
            IList <string>     sbjList = subjectInfo.Value.Split(';'); //题目列
            IList <string>     optList = optionInfo.Value.Split(';');  //选项列

            wkmInfo.TitleDescription = txtDescription.Text.Trim();
            wkmInfo.ShareTitle       = txtShareTitle.Text.Trim();
            wkmInfo.ShareDescription = txtShareDescription.Text.Trim();
            wkmInfo.StartDate        = this.calendarStartDate.SelectedDate;
            wkmInfo.EndDate          = this.calendarEndDate.SelectedDate;
            for (int i = 0; i < sbjList.Count; i++)
            {
                if (wkmInfo.SubjectInfo.SubjectContent.Count < i + 1 && !string.IsNullOrEmpty(sbjList[i])) //添加了题目
                {
                    wkmInfo.SubjectInfo.SubjectContent.Add(sbjList[i]);
                    wkmInfo.SubjectInfo.WKMSubjectId.Add(Guid.NewGuid());
                    wkmInfo.SubjectInfo.ActivityId.Add(wkmInfo.WKMId);
                    wkmInfo.SubjectInfo.ImgUrl.Add("");

                    wkmInfo.OptionsInfo.Add(new WKMOptionInfo());
                }
                else if (wkmInfo.SubjectInfo.SubjectContent.Count >= i + 1 && !string.IsNullOrEmpty(sbjList[i]))
                {
                    wkmInfo.SubjectInfo.SubjectContent[i] = sbjList[i];
                }
                IList <string> optListPerSbj = optList[i].Split('/');
                for (int j = 0; j < optListPerSbj.Count; j++)
                {
                    if (wkmInfo.OptionsInfo[i].OptionContent.Count < j + 1 && !string.IsNullOrEmpty(optListPerSbj[j]))//如果是添加了题目选项
                    {
                        wkmInfo.OptionsInfo[i].OptionContent.Add(optListPerSbj[j]);
                        wkmInfo.OptionsInfo[i].WKMOptionId.Add(Guid.NewGuid());
                        wkmInfo.OptionsInfo[i].TitleId.Add(wkmInfo.SubjectInfo.WKMSubjectId[i]);
                    }

                    else if (wkmInfo.OptionsInfo[i].OptionContent.Count >= j + 1 && !string.IsNullOrEmpty(optListPerSbj[j]))
                    {
                        wkmInfo.OptionsInfo[i].OptionContent[j] = optListPerSbj[j];
                    }
                }
                //图片实体保存到项目内
                if (files[i].ContentLength > 0)
                {
                    if (!string.IsNullOrEmpty(wkmInfo.SubjectInfo.ImgUrl[i]) && File.Exists(Server.MapPath(wkmInfo.SubjectInfo.ImgUrl[i])))
                    {
                        File.Delete(Server.MapPath(wkmInfo.SubjectInfo.ImgUrl[i]));//先删除之前的物理图片
                    }
                    string fileName = wkmInfo.SubjectInfo.WKMSubjectId[i] + Path.GetExtension(files[i].FileName);
                    files[i].SaveAs(Server.MapPath("/Storage/master/topic/") + fileName);
                    wkmInfo.SubjectInfo.ImgUrl[i] = ("/Storage/master/topic/" + fileName);
                }
            }
            if (PromoteHelper.UpdateWKM(wkmInfo))
            {
                this.ShowMsgAndReUrl("编辑成功!", true, "ManageWhoKnowMe.aspx");
            }
            else
            {
                this.ShowMsg("编辑失败!", false);
            }
        }
Пример #6
0
        protected override void AttachChildControls()
        {
            BindControls();
            MemberInfo   currentMember  = MemberProcessor.GetCurrentMember();//当前用户
            WKMInfo      wkmInfo        = new WKMInfo();
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);

            if (currentMember == null)
            {
                this.Page.Response.Redirect("UserLogin.aspx");
            }
            if (string.IsNullOrEmpty(this.Page.Request.QueryString["wkmId"]))
            {
                GotoResourceNotFound("当前活动不存在!");
            }
            else
            {
                wkmInfo = PromoteHelper.GetWKMInfo(new Guid(this.Page.Request.QueryString["wkmId"].ToString()));//当前活动
            }
            //根据url参数判断该页面类型
            string pageType = this.Page.Request.QueryString["type"];

            if (!string.IsNullOrEmpty(pageType))
            {
                hidPageType.Value = pageType;
                hosterId          = Convert.ToInt32(this.Page.Request.QueryString["hosterId"]);
                guestId           = Convert.ToInt32(this.Page.Request.QueryString["guestId"]);
                //类型和参数的非法判断
                if (pageType == "4" && hosterId == 0)//如果第四种类型下取不到hosterId,跳转到非法页面
                {
                    GotoResourceNotFound("缺少参数!");
                }
            }
            else
            {
                hidPageType.Value = "1";//如果是初始化的活动,则type为1:hoster开始设置题目
            }
            //判断该用户是否已经出完题目
            hidIsHosterExist.Value = PromoteHelper.isHosterExist(currentMember.UserId, wkmInfo.WKMId) ? "1" : "0";
            //判断该用户是否已经答过题目
            hidIsGuestExist.Value = PromoteHelper.isGuestExist(hosterId, currentMember.UserId, wkmInfo.WKMId) ? "1" : "0";
            //活动背景图和logo
            DataTable dtLogoImgAndBackImg = PromoteHelper.getBackImgUrl(wkmInfo.WKMId);

            litLogo.Text        = string.Format("<img src='{0}' />", dtLogoImgAndBackImg.Rows[0]["logoUrl"].ToString());
            hidBackImgUrl.Value = dtLogoImgAndBackImg.Rows[0]["backImgUrl"].ToString();
            //版权信息
            litCopyRight.Text = PromoteHelper.getWKMCopyRight(wkmInfo.WKMId).Replace("\r\n", "</br>");
            //关注引导页
            hidGuidePageUrl.Value = PromoteHelper.getGuidePageUrl(wkmInfo.WKMId);//masterSettings.GuidePageSet;
            //活动广告图和链接
            foreach (DataRow row in PromoteHelper.getAdImgAndUrls(wkmInfo.WKMId).Rows)
            {
                if (!string.IsNullOrEmpty(row["adlink1"].ToString()) && !string.IsNullOrEmpty(row["adimgurl1"].ToString()))
                {
                    ad1.Text = string.Format("<a href='{0}'><img src='{1}'/></a>", row["adlink1"].ToString(), row["adimgurl1"].ToString());
                }
                if (!string.IsNullOrEmpty(row["adlink2"].ToString()) && !string.IsNullOrEmpty(row["adimgurl2"].ToString()))
                {
                    ad2.Text = string.Format("<a href='{0}'><img src='{1}'/></a>", row["adlink2"].ToString(), row["adimgurl2"].ToString());
                }
            }

            //活动id
            if (this.hidWKMId != null)
            {
                this.hidWKMId.Value = wkmInfo.WKMId.ToString();
            }
            //用户id
            if (this.hidMemberId != null)
            {
                this.hidMemberId.Value = currentMember.UserId.ToString();
            }
            if (hosterId > 0 && pageType == "4")
            {
                MemberInfo hosterInfo = MemberProcessor.GetMember(hosterId);
                //hoster头像
                if (!string.IsNullOrEmpty(hosterInfo.UserHead))
                {
                    this.image.ImageUrl = hosterInfo.UserHead;
                }
                //hoster用户名
                if (this.litUserName != null)
                {
                    this.litUserName.Text = hosterInfo.UserName;
                }
                //获取答案,填写至隐藏域,用于判断guest是否选对
                string sbjOptId = string.Empty;
                foreach (DataRow row in PromoteHelper.GetHosterDetail(hosterId, wkmInfo.WKMId).Rows)
                {
                    sbjOptId += row["TitleId"] + "/" + row["OptionId"] + ";";
                }
                sbjOptId.TrimEnd(';');
                this.hidAnswer.Value = sbjOptId;
            }
            if ((hosterId < 0 && (pageType == "1" || string.IsNullOrEmpty(pageType))) || (pageType == "2"))
            {
                //自己头像
                if (!string.IsNullOrEmpty(currentMember.UserHead))
                {
                    this.image.ImageUrl = currentMember.UserHead;
                }
                //自己用户名
                if (this.litUserName != null)
                {
                    this.litUserName.Text = currentMember.UserName;
                }
            }


            //活动详情
            if (this.litContent != null)
            {
                this.litContent.Text = HttpUtility.HtmlDecode(wkmInfo.TitleDescription);
            }

            //题目进度bar生成
            string sbjBarHtml = string.Empty;

            for (int j = 0; j < wkmInfo.SubjectInfo.WKMSubjectId.Count; j++)
            {
                int widRate = Convert.ToInt32((10.00 / wkmInfo.SubjectInfo.WKMSubjectId.Count) * 10);
                sbjBarHtml += "<li style='width:" + widRate + "%'><span class='num'>" + (j + 1) + "</span></li>";
            }
            this.litSbjBarHtml.Text = sbjBarHtml;

            //题目列表html生成
            string sbjHtml = string.Empty;

            for (int i = 0; i < wkmInfo.SubjectInfo.WKMSubjectId.Count; i++)
            {
                sbjHtml += "<div name='sbjDiv' order='" + i + "'>";
                sbjHtml += string.Format("<div class='ttbox brad5' id='{0}' name='sbj'>{2} <h1>{1}</h1></div>", wkmInfo.SubjectInfo.WKMSubjectId[i], wkmInfo.SubjectInfo.SubjectContent[i], "<img src='" + wkmInfo.SubjectInfo.ImgUrl[i] + "' />");
                WKMOptionInfo optInfo = PromoteHelper.GetWKMOptInfoBySubjectId(wkmInfo.SubjectInfo.WKMSubjectId[i]);
                for (int j = 0; j < optInfo.WKMOptionId.Count; j++)
                {
                    sbjHtml += string.Format("<div class='nrbox brad5'><h1><input type='radio' name='opt' value='{0}' />{1}</h1></div>", optInfo.WKMOptionId[j], optInfo.OptionContent[j]);
                }
                sbjHtml += "</div>";
            }
            this.litSbjListHtml.Text = sbjHtml;



            string str3 = "";

            if (!string.IsNullOrEmpty(dtLogoImgAndBackImg.Rows[0]["ShareImgUrl"].ToString()))
            {
                str3 = Globals.HostPath(HttpContext.Current.Request.Url) + dtLogoImgAndBackImg.Rows[0]["ShareImgUrl"].ToString(); //Globals.HostPath(HttpContext.Current.Request.Url) + masterSettings.GoodsPic;
            }
            //设置分享参数
            if (wkmInfo != null)
            {
                string currentUrl = HttpContext.Current.Request.Url.ToString().Substring(0, HttpContext.Current.Request.Url.ToString().IndexOf('?'));
                switch (this.Page.Request.QueryString["type"])
                {
                //还没有回答,单纯的邀请别人设置问题
                case "1":
                case "3":
                case "4":
                case null:
                    currentUrl = currentUrl + "?wkmId=" + wkmInfo.WKMId;
                    break;

                //已经回答,邀请别人回答自己设置好的问题
                case "2":
                    currentUrl = currentUrl + "?wkmId=" + wkmInfo.WKMId + "&type=4&hosterId=" + currentMember.UserId;
                    break;
                }

                this.litItemParams.Text = string.Concat(new object[] {
                    str3, "|",
                    wkmInfo.ShareTitle, "|",
                    wkmInfo.ShareDescription, "$",
                    Globals.HostPath(HttpContext.Current.Request.Url), currentMember.UserHead, "|",
                    wkmInfo.TitleDescription, "|",
                    wkmInfo.ShareDescription, "|",
                    currentUrl
                });
            }
            PageTitle.AddSiteNameTitle(wkmInfo.ShareTitle);
        }
Пример #7
0
 public static bool UpdateWKM(WKMInfo info)
 {
     return(new PromotionDao().UpdateWKM(info));
 }
Пример #8
0
 /// <summary>
 /// 增加微信答题活动
 /// </summary>
 public static bool AddWKM(WKMInfo info)
 {
     return(new PromotionDao().AddWKM(info));
 }