예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ResponseModel response = new ResponseModel();
            string        op       = RequestHelper.GetFormString("op");
            var           user     = new Model.WeiXin.wp_user();

            switch (op)
            {
            case "save":
                #region 保存信息
                try
                {
                    string src      = HttpUtility.UrlDecode(RequestHelper.GetFormString("src"));
                    string name     = HttpUtility.UrlDecode(RequestHelper.GetFormString("name"));
                    string phone    = HttpUtility.UrlDecode(RequestHelper.GetFormString("phone"));
                    string content  = HttpUtility.UrlDecode(RequestHelper.GetFormString("content"));
                    string postion  = HttpUtility.UrlDecode(RequestHelper.GetFormString("postion"));
                    string addr     = HttpUtility.UrlDecode(RequestHelper.GetFormString("addr"));
                    int    typeId   = RequestHelper.GetFormInt("typeId", 1);
                    string typeName = HttpUtility.UrlDecode(RequestHelper.GetFormString("typeName"));
                    string openId   = RequestHelper.GetFormString("openId");

                    int userId = new Bll.WeChat.wp_userbll().GetUserIdByOpenId(openId);

                    //LogHandler.Info(src+ content+openId+ userId);
                    if (string.IsNullOrEmpty(src) && string.IsNullOrEmpty(content))
                    {
                        response.IsSuccess = false;
                    }
                    else
                    {
                        feedback model = new feedback();
                        model.Content  = content;
                        model.CreateOn = DateTime.Now;
                        model.Image    = src;
                        model.UserId   = userId;
                        model.name     = name;
                        model.phone    = phone;
                        model.addr     = postion + " " + addr;
                        model.typeid   = typeId;
                        model.typename = typeName;

                        response.IsSuccess = new FeedBackBll().SaveItem(model);
                    }

                    response.Msg = response.IsSuccess ? "成功" : "失败";
                }
                catch (Exception ex)
                {
                    response.IsSuccess = false;
                    response.Msg       = "信息输入有误,只能输入文字和数字";
                    LogHandler.Error(ex);
                }
                #endregion
                break;

            case "uploadImg":
                #region   图片
                string path       = RequestHelper.GetFormString("path");
                string requsetKey = "fileImage";
                var    result     = ImageHelper.UpLoadImg(path, requsetKey, false);
                response.IsSuccess = result[0] == "true";
                response.Msg       = result[1];
                #endregion
                break;

            case "joinvote":
                #region 参加投票
                try
                {
                    string src       = HttpUtility.UrlDecode(RequestHelper.GetFormString("src"));
                    string introduce = HttpUtility.UrlDecode(RequestHelper.GetFormString("introduce"));
                    string manifesto = HttpUtility.UrlDecode(RequestHelper.GetFormString("manifesto"));
                    string addr      = HttpUtility.UrlDecode(RequestHelper.GetFormString("addr"));
                    int    voteId    = RequestHelper.GetFormInt("voteId", 0);
                    string phone     = RequestHelper.GetFormString("phone");
                    string token     = RequestHelper.GetFormString("token");
                    string openId    = RequestHelper.GetFormString("openId");
                    user = new Bll.WeChat.wp_userbll().GetUserInfoByOpenId(openId);
                    int userId = user == null ? 0 : user.Id;

                    //LogHandler.Info(src+ content+openId+ userId);
                    if (string.IsNullOrEmpty(src) || voteId == 0)
                    {
                        response.IsSuccess = false;
                        response.Msg       = "请上传图片";
                    }
                    else
                    {
                        int          count = new Bll.WeChat.wp_shop_vote_optionbll().GetOptionCountByVoteId(voteId);
                        wp_shop_vote vote  = new Bll.WeChat.wp_shop_votebll().GetModel(voteId);
                        if (vote == null || vote.count <= count)
                        {
                            response.IsSuccess = false;
                            response.Msg       = "当前报名人数已满";
                        }
                        else
                        {
                            wp_picture pic = new wp_picture();
                            pic.url         = src;
                            pic.path        = src.Replace(Common.BaseClass.CurrentDomin, "/");
                            pic.create_time = (uint)BaseClass.ConvertDataTimeToLong(DateTime.Now);
                            pic.system      = 0;
                            pic.md5         = "";
                            pic.sha1        = "";
                            pic.status      = 1;
                            pic.system      = 1;

                            var pic_id = new Bll.WeChat.wp_picturebll().InsertItem(pic);

                            if (pic_id > 0)
                            {
                                wp_shop_vote_option model = new wp_shop_vote_option();
                                model.image         = (uint)pic_id;
                                model.vote_id       = voteId;
                                model.ctime         = (int)pic.create_time;
                                model.uid           = userId;
                                model.truename      = user == null ? "匿名" : user.nickname;
                                model.introduce     = introduce;
                                model.manifesto     = manifesto;
                                model.number        = 0;
                                model.token         = token;
                                model.opt_count     = 0;
                                model.phone         = phone;
                                model.option_status = 0;
                                model.phone         = phone;
                                model.option_status = 0;
                                model.address       = addr;
                                response.IsSuccess  = new wp_shop_vote_optionbll().InsertItem(model) > 0;
                            }
                            else
                            {
                                response.IsSuccess = false;
                            }
                            response.Msg = response.IsSuccess ? "成功" : "失败";
                        }
                    }
                }
                catch (Exception ex)
                {
                    response.IsSuccess = false;
                    response.Msg       = "失败,请重试";
                    LogHandler.Error(ex);
                }
                #endregion
                break;

            case "dovote":
                try
                {
                    #region 投票
                    int option_id = RequestHelper.GetFormInt("option_id", 0);
                    int vote_id   = RequestHelper.GetFormInt("vote_id", 0);
                    int uid       = RequestHelper.GetFormInt("uid", 0);
                    user = new Bll.WeChat.wp_userbll().GetItem(uid);
                    var vote                    = new Bll.WeChat.wp_shop_votebll().GetItem(vote_id);
                    var vote_log_byvote         = new List <wp_shop_vote_log>();
                    var vote_log_count_byoption = 0;
                    if (vote == null || user == null)
                    {
                        response.IsSuccess = false;
                        if (vote == null)
                        {
                            response.Msg = "未找到当前活动";
                        }
                        else
                        {
                            LogHandler.Info($"未找到用户uid:{uid}");
                            response.Msg = "未找到用户";
                        }
                    }
                    else if (BaseClass.ConvertDataTimeToLong(DateTime.Now) > vote.end_time)
                    {
                        response.IsSuccess = false;
                        response.Msg       = "投票活动已经结束";
                    }
                    else
                    {
                        //vote_log_byvote = new Bll.WeChat.wp_shop_vote_logbll().GetVoteLogTodayByVoteId(uid, vote_id);
                        vote_log_byvote = new Bll.WeChat.wp_shop_vote_logbll().GetVoteLogByVoteId(uid, vote_id);
                        int user_vote_count = vote_log_byvote == null ? 0 : vote_log_byvote.Count;
                        if (user_vote_count >= vote.multi_num && vote.multi_num > 0)
                        {
                            response.IsSuccess = false;
                            response.Msg       = "票已投完";
                        }
                        else
                        {
                            #region 限制每日每人(被投票人)一票
                            //vote_log_count_byoption = new Bll.WeChat.wp_shop_vote_logbll().GetVoteCountTodayByOptionId(uid, option_id);
                            //if (vote_log_count_byoption > 0)
                            //{
                            //    response.IsSuccess = false;
                            //    response.Msg = "已投票";
                            //}
                            //else
                            //{
                            //    wp_shop_vote_log model = new wp_shop_vote_log();
                            //    model.uid = uid;
                            //    model.vote_id = vote_id;
                            //    model.option_id = option_id;
                            //    model.token = vote.token;
                            //    model.ctime = (int)BaseClass.ConvertDataTimeToLong(DateTime.Now);
                            //    response.IsSuccess = new Bll.WeChat.wp_shop_vote_logbll().InsertModel(model) > 0;
                            //    response.Msg = response.IsSuccess ? "投票成功" : "投票失败,请重试";
                            //}
                            #endregion
                            #region  限制每日每人(被投票人)一票
                            wp_shop_vote_log model = new wp_shop_vote_log();
                            model.uid          = uid;
                            model.vote_id      = vote_id;
                            model.option_id    = option_id;
                            model.token        = vote.token;
                            model.ctime        = (int)BaseClass.ConvertDataTimeToLong(DateTime.Now);
                            response.IsSuccess = new Bll.WeChat.wp_shop_vote_logbll().InsertModel(model) > 0;
                            response.Msg       = response.IsSuccess ? "投票成功" : "投票失败,请重试";
                            #endregion
                        }
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    response.IsSuccess = false;
                    response.Msg       = response.IsSuccess ? "投票成功" : "投票失败,请重试";
                }
                break;

            default:
                break;
            }


            Response.Write(JsonConvert.SerializeObject(response));
        }
예제 #2
0
        //public infolist()
        //{
        //    this.IsNeedUserInfo = false;
        //}

        protected void Page_Load(object sender, EventArgs e)
        {
            type = RequestHelper.GetQueryInt("type", 2);
            //type = type == 1 ? 2 : type;
            pageIndex = RequestHelper.GetQueryInt("pageIndex", 1);
            pageSize  = RequestHelper.GetQueryInt("pageSize", 5000);
            pageSize  = 5000;
            var article_type = RequestHelper.GetQueryInt("article_type", 0);

            if (article_type > 0)
            {
                type = 1;
            }
            if (type > 4 || type < 1)
            {
                type = 1;
            }
            typename = Common.EnumHelper.GetEnumDesc((InfoTypeEnum)type);
            int    count = 0;
            string url   = "";

            switch ((InfoTypeEnum)type)
            {
            case InfoTypeEnum.文章列表:
                IsArticle = true;
                int type_id = RequestHelper.GetQueryInt("article_type", 5);
                count = 0;
                wp_article_new query = new wp_article_new();
                query.type_id = type_id;
                var article_list = new Bll.WeChat.wp_article_newbll().GetList(query, out count, pageIndex, pageSize);
                list      = list_info.Instance.GetFromArticle(article_list);
                url       = $"{BaseClass.CurrentDomin}home/infodetail.aspx?id=";
                list_type = new Bll.WeChat.wp_article_type_newbll().GetList();
                if (list_type != null && list_type.Count > 0)
                {
                    list_type.ForEach(s =>
                    {
                        s.url = $"{BaseClass.CurrentDomin}home/infolist.aspx?article_type={s.Id}&type={type}";
                    });
                }
                break;

            case InfoTypeEnum.投票列表:
                var vote_list = new Bll.WeChat.wp_shop_votebll().GetList(new Model.WeiXin.wp_shop_vote(), out count, pageIndex, pageSize);
                list = list_info.Instance.GetFromShopVote(vote_list);
                if (list != null && list.Count > 0)
                {
                    list.ForEach(s =>
                    {
                        s.img = "/img/vote.jpg";
                    });
                }
                url = $"{BaseClass.CurrentDomin}home/votelist.aspx?vote_id=";
                break;

            case InfoTypeEnum.活动列表:
                var reserve_list = new Bll.WeChat.wp_reservebll().GetList(new Model.WeiXin.wp_reserve(), out count, pageIndex, pageSize);
                list = list_info.Instance.GetFromReserve(reserve_list);
                url  = $"{BaseClass.CurrentDomin}index.php?s=/w16/Reserve/Wap/index/reserve_id/";
                break;

            case InfoTypeEnum.问卷列表:
                var survey_list = new Bll.WeChat.wp_surveybll().GetList(new Model.WeiXin.wp_survey(), out count, false, pageIndex, pageSize);
                list = list_info.Instance.GetFromSurvey(survey_list);
                url  = $"{BaseClass.CurrentDomin}index.php?s=/w16/Survey/Wap/index/id/";
                break;

            default:
                break;
            }

            IsData = list != null && list.Count > 0;
            if (IsData)
            {
                list.ForEach(s =>
                {
                    s.url = url + s.id;
                });
            }
        }