Esempio n. 1
0
        /// <summary>
        /// 更新转发人带来的UV
        /// </summary>
        /// <param name="monitorId"></param>
        /// <param name="spreadUserId"></param>
        /// <returns></returns>
        public bool UpdateUV(int monitorId, string spreadUserId)
        {
            MonitorLinkInfo linkInfo = Get <MonitorLinkInfo>(string.Format("[LinkName]='{0}' And [MonitorPlanID]={1}", spreadUserId, monitorId));
            //int count = GetCount<UserInfo>(string.Format(" WebsiteOwner='{0}' AND ArticleId='{1}' AND DistributionOwner='{2}'", WebsiteOwner, linkInfo.ActivityId, linkInfo.LinkName));
            int uv = GetCount <MonitorEventDetailsInfo>("EventUserID", string.Format(" WebsiteOwner='{0}' AND MonitorPlanID={1} AND SpreadUserID='{2}'", WebsiteOwner, linkInfo.MonitorPlanID, linkInfo.LinkName));

            linkInfo.UV = uv;
            //linkInfo.PowderCount = count;
            return(Update(linkInfo));
        }
Esempio n. 2
0
        /// <summary>
        /// 编辑链接
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string EditLink(HttpContext context)
        {
            string          jsonData = context.Request["JsonData"];
            MonitorLinkInfo model    = ZentCloud.Common.JSONHelper.JsonToModel <MonitorLinkInfo>(jsonData);

            //相关检查


            if (!string.IsNullOrEmpty(model.RealLink))
            {
                if (!Common.PageValidate.IsUrl(model.RealLink))
                {
                    return("请输入正确的链接地址,格式如 http://www.baidu.com");
                }
            }
            //相关检查

            int count = bll.Update(model, string.Format("RealLink='{0}',LinkName='{1}'", model.RealLink, model.LinkName), string.Format("LinkID='{0}'", model.LinkID));

            return(count > 0 ? "true" : "false");
        }
Esempio n. 3
0
        /// <summary>
        /// 添加链接
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string AddLink(HttpContext context)
        {
            string          jsonData = context.Request["JsonData"];
            MonitorLinkInfo model    = ZentCloud.Common.JSONHelper.JsonToModel <MonitorLinkInfo>(jsonData);

            //相关检查


            if (!string.IsNullOrEmpty(model.RealLink))
            {
                if (!Common.PageValidate.IsUrl(model.RealLink))
                {
                    return("请输入正确的链接地址,格式如 http://www.baidu.com");
                }
            }
            //相关检查
            model.LinkID           = int.Parse(bll.GetGUID(ZentCloud.BLLJIMP.TransacType.MonitorLinkID));
            model.InsertDate       = DateTime.Now;
            model.EncryptParameter = Common.Base64Change.EncodeBase64ByUTF8(string.Format("{0}{1}{2}", model.MonitorPlanID, model.LinkID, model.RealLink));
            return(bll.Add(model).ToString().ToLower());
        }
Esempio n. 4
0
        public void ProcessRequest(HttpContext context)
        {
            //try
            //{
            BLLJIMP.BLLJuActivity   bllJuactivity   = new BLLJIMP.BLLJuActivity("");
            BLLJIMP.BLLUser         bllUser         = new BLLJIMP.BLLUser("");
            BLLJIMP.BLLMonitor      bllMonitor      = new BLLJIMP.BLLMonitor();
            BLLJIMP.BLLWebSite      bllwebSite      = new BLLJIMP.BLLWebSite();
            BLLJIMP.BLLShareMonitor bllShareMonitor = new BLLJIMP.BLLShareMonitor();

            ///推广用户信息
            UserInfo spreadUser = null;

            //分享用户
            UserInfo shareUser = null;

            CompanyWebsite_Config companyConfig = bllwebSite.GetCompanyWebsiteConfig();

            currentUrl = context.Request.Url.ToString(); //当前绝对地址
            string filePath = context.Request.FilePath;  //当前相对路径

            #region 微信推广(展示文章页面)
            if (filePath.Contains(".chtml"))
            {
                ToLog(context, " monitorhandler filePath:" + filePath);
                string[] parameters = filePath.Split('/');
                if (parameters.Length > 2)
                {
                    int activityId = Convert.ToInt32(parameters[1], 16);//ZCJ_JuActivityInfo 文章ID;
                    ToLog(context, " monitorhandler 文章ID:" + activityId);
                    long memberID = 0;

                    if (parameters.Length > 3)
                    {
                        //memberID = parameters[2] == "XXX" ? 0 : Convert.ToInt32(parameters[2], 16);//ZCJ_WXMemberInfo 会员注册ID;
                        spreadUser = bllUser.GetUserInfoByAutoID(Convert.ToInt32(parameters[2], 16));
                    }


                    string currOpenerOpenID = parameters.Length > 5 ? parameters[3] : string.Empty;//当前打开者的OpenID

                    string spreadUserID = context.Request["spreadU"] == null ? "" : context.Request["spreadU"].ToString();

                    string shareTimestamp = context.Request["shareTimestamp"];

                    if (!string.IsNullOrWhiteSpace(spreadUserID))
                    {
                        spreadUserID = Common.Base64Change.DecodeBase64ByUTF8(spreadUserID);
                    }

                    string spreadUserAutoIDStr = context.Request["ua"] == null ? "" : context.Request["ua"].ToString();//推广ID,原始id*1000,16进制后进行base64,然后“=”变成“_”
                    int    spreadUserAutoID    = 0;
                    if (!string.IsNullOrWhiteSpace(spreadUserAutoIDStr))
                    {
                        spreadUserAutoID = bllJuactivity.TransmitIntDeCode(spreadUserAutoIDStr);//Convert.ToInt32(Common.Base64Change.DecodeBase64ByUTF8(spreadUserAutoIDStr.Replace("_", "=")), 16) / 1000;
                    }

                    string shareId = context.Request["comeonshareid"] == null ? "" : context.Request["comeonshareid"].ToString();

                    if (!string.IsNullOrWhiteSpace(shareId))
                    {
                        ToLog(context, " monitorhandler 执行shareId查找分享任务: " + shareId);
                        try
                        {
                            var shareInfo = bllShareMonitor.GetShareInfo(shareId);

                            if (!string.IsNullOrWhiteSpace(shareInfo.UserId))
                            {
                                shareUser = bllUser.GetUserInfo(shareInfo.UserId);
                            }
                        }
                        catch (Exception ex)
                        {
                            ToLog(context, " monitorhandler 获取shareUser异常: " + ex.Message);
                        }
                    }



                    JuActivityInfo activityInfo = bllJuactivity.Get <JuActivityInfo>(string.Format("JuActivityID={0} AND IsDelete=0 ", activityId));//文章信息

                    if (activityInfo == null)
                    {
                        context.Response.WriteFile("/Error/NotExist.html");
                        return;
                    }

                    ToLog(context, " monitorhandler 找到文章,开始构造内容: " + activityInfo.JuActivityID);

                    //if (activityInfo.ArticleType == "activity")
                    //{
                    //    if (activityInfo.ActivityStatus == 1)
                    //    {
                    //        context.Response.Redirect("/Error/CommonMsg.aspx?msg=报名已结束,有疑问请联系我们&&icon=icon iconfont icon-kulian kulian");
                    //        return;
                    //    }
                    //}

                    #region 检查是否付费活动

                    if (activityInfo.IsFee == 1 && !bllJuactivity.IsLogin)
                    {
                        context.Response.Redirect("/App/Cation/Wap/FreeActivityPage.aspx?aid=" + activityInfo.JuActivityID);
                        return;
                    }
                    #endregion

                    #region 检查访问级别
                    if (activityInfo.AccessLevel > 0)
                    {
                        if (!bllUser.IsLogin)
                        {
                            appLoginUrl = Common.ConfigHelper.GetConfigString("appLoginUrl").ToLower();
                            context.Response.Redirect(appLoginUrl + string.Format("?redirect=" + HttpUtility.UrlEncode(currentUrl)), true);
                            return;
                        }
                        //else if (!bllUser.IsMember() && activityInfo.AccessLevel == 1)
                        //{

                        //}
                        else if (bllUser.GetCurrentUserInfo().AccessLevel < activityInfo.AccessLevel)
                        {
                            //if (companyConfig.NoPermissionsPage == 0)
                            //{
                            //    context.Response.WriteFile("/Error/NoPmsMobile.htm");
                            //    return;
                            //}
                            //else if (companyConfig.NoPermissionsPage == 1)
                            //{
                            //    context.Response.Redirect("/App/Cation/Wap/UserEdit.aspx",true);
                            //    context.Response.End();
                            //    return;
                            //}
                            context.Response.WriteFile("/Error/NoPmsMobile.htm");
                            return;
                        }
                    }
                    #endregion

                    #region 检查访问级别

                    //WXMemberInfo regInfo = juactivityBll.Get<WXMemberInfo>(string.Format("MemberID={0}", memberID));//会员注册信息
                    // UserInfo userInfo = juactivityBll.Get<UserInfo>(string.Format("UserID='{0}'", activityInfo.UserID));//文章发布者信息
                    SystemSet systemset  = bllJuactivity.Get <SystemSet>(""); //系统配置信息
                    string    pageSource = "";                                //待输出的html源代码

                    if (systemset != null)
                    {
                        if (string.IsNullOrWhiteSpace(currOpenerOpenID))
                        {
                            //取得Session里的当前OpenID
                            currOpenerOpenID = context.Session[systemset.WXCurrOpenerOpenIDKey] != null ? context.Session[systemset.WXCurrOpenerOpenIDKey].ToString() : "";
                        }

                        if (string.IsNullOrWhiteSpace(currOpenerOpenID))
                        {
                            //如果再为空,由链接上面get参数获取
                            currOpenerOpenID = context.Request[systemset.WXCurrOpenerOpenIDKey] != null ? context.Request[systemset.WXCurrOpenerOpenIDKey].ToString() : "";
                        }
                    }
                    #endregion



                    //if (regInfo == null)
                    //{
                    //    regInfo = new WXMemberInfo() { Name = "none", WeixinOpenID = "" };
                    //}

                    if ((activityInfo != null))//
                    {
                        //var planInfo = bllJuactivity.Get<MonitorPlan>(string.Format("MonitorPlanID={0}", activityInfo.MonitorPlanID));
                        //if (planInfo == null)
                        //{
                        //    return;
                        //}
                        //else
                        //{
                        //    if (planInfo.PlanStatus == "0")//任务已停止
                        //    {
                        //        return;
                        //    }

                        //}

                        ToLog(context, " monitorhandler 开始执行GetJuactivityHtml: " + activityInfo.JuActivityID);
                        pageSource = bllJuactivity.GetJuactivityHtml(activityInfo, currOpenerOpenID, context.Request.Url.ToString(), spreadUser, shareUser);
                        ToLog(context, " monitorhandler 执行GetJuactivityHtml完毕: " + activityInfo.JuActivityID);

                        #region 事件记录
                        //事件
                        //int OpenCount = 0;//打开人数
                        //int DistinctOpenCount = 0;//独立IP数量
                        MonitorEventDetailsInfo detailInfo = new MonitorEventDetailsInfo();
                        detailInfo.MonitorPlanID  = activityInfo.MonitorPlanID;
                        detailInfo.EventType      = 0;
                        detailInfo.EventBrowser   = HttpContext.Current.Request.Browser == null ? "" : HttpContext.Current.Request.Browser.ToString();
                        detailInfo.EventBrowserID = HttpContext.Current.Request.Browser.Id;;
                        if (HttpContext.Current.Request.Browser.Beta)
                        {
                            detailInfo.EventBrowserIsBata = "测试版";
                        }
                        else
                        {
                            detailInfo.EventBrowserIsBata = "正式版";
                        }

                        detailInfo.EventBrowserVersion = HttpContext.Current.Request.Browser.Version;
                        detailInfo.EventDate           = DateTime.Now;
                        if (HttpContext.Current.Request.Browser.Win16)
                        {
                            detailInfo.EventSysByte = "16位系统";
                        }
                        else
                        if (HttpContext.Current.Request.Browser.Win32)
                        {
                            detailInfo.EventSysByte = "32位系统";
                        }
                        else
                        {
                            detailInfo.EventSysByte = "64位系统";
                        }

                        detailInfo.EventSysPlatform = HttpContext.Current.Request.Browser.Platform;
                        detailInfo.SourceIP         = Common.MySpider.GetClientIP();
                        detailInfo.IPLocation       = Common.MySpider.GetIPLocation(detailInfo.SourceIP);
                        detailInfo.SourceUrl        = HttpContext.Current.Request.Url.ToString();
                        detailInfo.RequesSourcetUrl = HttpContext.Current.Request.UrlReferrer != null?HttpContext.Current.Request.UrlReferrer.ToString() : "";

                        if (spreadUser != null)
                        {
                            detailInfo.SpreadUserID = spreadUser.UserID;
                        }
                        detailInfo.SpreadUserAutoID = spreadUserAutoID;
                        detailInfo.ShareTimestamp   = shareTimestamp;
                        detailInfo.WebsiteOwner     = bllJuactivity.WebsiteOwner;
                        detailInfo.ModuleType       = activityInfo.ArticleType;
                        if (bllUser.IsLogin)
                        {
                            detailInfo.EventUserID = bllUser.GetCurrUserID();
                        }


                        if (spreadUser != null)//带推广信息
                        {
                            //try
                            //{
                            //    if (!string.IsNullOrWhiteSpace(currOpenerOpenID))
                            //    {
                            //        //记录触发人
                            //        UserInfo eventUser = new BLLJIMP.BLLUser("").GetUserInfoByOpenId(currOpenerOpenID);
                            //        detailInfo.EventUserID = eventUser.UserID;
                            //    }
                            //}
                            //catch { }
                            string          url = string.Format("http://{0}{1}", context.Request.Url.Host, filePath);
                            MonitorLinkInfo linkInfo;
                            try
                            {
                                linkInfo = bllJuactivity.Get <MonitorLinkInfo>(string.Format(" LinkName='{0}' And MonitorPlanID={1}", spreadUser.UserID, activityInfo.MonitorPlanID));
                            }
                            catch (Exception ex)
                            {
                                context.Response.Write("ex" + ex.ToString());
                                return;
                            }



                            if (linkInfo != null)
                            {
                                linkInfo.ActivityName   = activityInfo.ActivityName;
                                linkInfo.ThumbnailsPath = activityInfo.ThumbnailsPath;
                                //已经为该用户建立推广链接
                                detailInfo.LinkID = linkInfo.LinkID;
                                //if (linkInfo.OpenCount != null)//增加打开人数
                                //{
                                linkInfo.OpenCount++;
                                //}
                                //else
                                //{
                                //    linkInfo.OpenCount = 1;
                                //}
                                int shareCount = bllJuactivity.GetCount <MonitorEventDetailsInfo>("ShareTimestamp", string.Format(" LinkID ={0} and ShareTimestamp is not null and ShareTimestamp <> '' and ShareTimestamp <> '0' ", linkInfo.LinkID));
                                linkInfo.ShareCount = shareCount;
                                int ipCount = bllJuactivity.GetCount <MonitorEventDetailsInfo>(" SourceIP ", string.Format(" LinkID = {0} ", linkInfo.LinkID));
                                linkInfo.DistinctOpenCount = ipCount;
                                bllJuactivity.Update(linkInfo, string.Format(" OpenCount={0},DistinctOpenCount={1},ShareCount={2}", linkInfo.OpenCount, ipCount, shareCount), string.Format("LinkID={0}", linkInfo.LinkID));
                            }
                            else
                            {
                                //还没有为该用户建立推广链接
                                MonitorLinkInfo newLinkinfo = new MonitorLinkInfo();
                                newLinkinfo.LinkID            = int.Parse(bllJuactivity.GetGUID(ZentCloud.BLLJIMP.TransacType.MonitorLinkID));
                                newLinkinfo.MonitorPlanID     = activityInfo.MonitorPlanID;
                                newLinkinfo.WXMemberID        = memberID;
                                newLinkinfo.LinkName          = spreadUser.UserID;
                                newLinkinfo.RealLink          = url;
                                newLinkinfo.InsertDate        = DateTime.Now;
                                newLinkinfo.OpenCount         = 1;
                                newLinkinfo.ActivityName      = activityInfo.ActivityName;
                                newLinkinfo.ThumbnailsPath    = activityInfo.ThumbnailsPath;
                                newLinkinfo.WebsiteOwner      = bllJuactivity.WebsiteOwner;
                                newLinkinfo.DistinctOpenCount = 1; // ip
                                newLinkinfo.ShareCount        = 0; //分享数
                                if (activityInfo.ArticleType == "article")
                                {
                                    newLinkinfo.ForwardType = "fans";
                                    newLinkinfo.ActivityId  = activityInfo.JuActivityID;
                                }
                                if (!string.IsNullOrEmpty(activityInfo.SignUpActivityID) && activityInfo.ArticleType == "activity")
                                {
                                    newLinkinfo.ActivityId = int.Parse(activityInfo.SignUpActivityID);
                                }

                                StringBuilder sqlWhere = new StringBuilder();
                                sqlWhere.AppendFormat(@"
                                if not exists(select 1 from ZCJ_MonitorLinkInfo where LinkName='{14}' and MonitorPlanID={15} ) 
                                begin
                                    insert into ZCJ_MonitorLinkInfo (LinkID,MonitorPlanID,WXMemberID,LinkName,RealLink,InsertDate,OpenCount,ActivityName,ThumbnailsPath,WebsiteOwner,DistinctOpenCount,ShareCount,ForwardType,ActivityId)
                                                values({0},{1},{2},'{3}','{4}','{5}',{6},'{7}','{8}','{9}',{10},{11},'{12}',{13})
                                end 
                                ", newLinkinfo.LinkID, newLinkinfo.MonitorPlanID, newLinkinfo.WXMemberID, newLinkinfo.LinkName, newLinkinfo.RealLink, newLinkinfo.InsertDate, newLinkinfo.OpenCount, newLinkinfo.ActivityName, newLinkinfo.ThumbnailsPath, newLinkinfo.WebsiteOwner, newLinkinfo.DistinctOpenCount, newLinkinfo.ShareCount, newLinkinfo.ForwardType, newLinkinfo.ActivityId, spreadUser.UserID, activityInfo.MonitorPlanID);


                                if (ZentCloud.ZCDALEngine.DALEngine.ExecuteSql(sqlWhere.ToString()) > 0)
                                {
                                    detailInfo.LinkID = newLinkinfo.LinkID;
                                }
                            }
                        }


                        //添加事件详细
                        //if (!filePath.Contains("?"))
                        //{
                        bllJuactivity.Add(detailInfo);
                        //DistinctOpenCount = juactivityBll.GetCount<ZentCloud.BLLJIMP.Model.MonitorEventDetailsInfo>("SourceIP", string.Format("LinkID={0} and EventType=0", detailInfo.LinkID));
                        //juactivityBll.Update(new MonitorLinkInfo(), string.Format(" OpenCount={0},DistinctOpenCount={1}", OpenCount, DistinctOpenCount), string.Format("LinkID={0}", detailInfo.LinkID));
                        #region 微转发活动加积分
                        if (bllUser.IsLogin && spreadUser != null)
                        {
                            if (activityInfo.ArticleType == "activity")
                            {
                                if (bllJuactivity.GetCount <MonitorEventDetailsInfo>(string.Format(" MonitorPlanID='{0}' And EventUserID='{1}' And SpreadUserID='{2}' And EventUserID!='{2}'", detailInfo.MonitorPlanID, bllUser.GetCurrUserID(), spreadUser.UserID)) == 1)
                                {
                                    string remark = string.Format("转发活动《{0}》", activityInfo.ActivityName);
                                    //微转发加积分
                                    bllUser.AddUserScoreDetail(spreadUser.UserID, CommonPlatform.Helper.EnumStringHelper.ToString(ZentCloud.BLLJIMP.Enums.ScoreDefineType.ForwardArticle), spreadUser.WebsiteOwner, null, remark);
                                }
                            }
                        }
                        #endregion


                        //}
                        context.Response.ClearContent();
                        //处理完成
                        context.Response.Write(pageSource);
                        //更新微信阅读人数
                        //bllJuactivity.UpdateUVCount(activityInfo.JuActivityID);
                        bllJuactivity.UpDateIPPVShareCount(activityInfo);
                        bllJuactivity.UpdateActivityForwardPVUV(activityInfo);
                        if (spreadUser != null)
                        {
                            bllMonitor.UpdateUV(activityInfo.MonitorPlanID, spreadUser.UserID);
                            //bllMonitor.UpdateSignUpCount(activityInfo.MonitorPlanID, spreadUser.UserID);
                        }
                        if (!string.IsNullOrWhiteSpace(activityInfo.RedirectUrl))
                        {
                            context.Response.Redirect(activityInfo.RedirectUrl);
                        }
                        return;

                        #endregion

                        ToLog(context, " monitorhandler 事件记录完毕: " + activityInfo.JuActivityID);
                    }
                    else
                    {
                        context.Response.Write("<html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1\" /></head><body>链接无效。</body></html>");
                        return;
                    }
                }
            }
            #endregion
            #region 注释
            //#region 微信会员注册
            //else if (filePath.StartsWith("/weixin"))
            //{

            //    //微信会员注册
            //    if (filePath.Contains("wx_reg.chtml") && (!filePath.Contains("/weixin/wx_reg.chtml")))
            //    {
            //        string[] parameters = filePath.Split('/');

            //        string weixinMemberId = Convert.ToInt32(parameters[2], 16).ToString();// ZCJ_WeixinMemberInfo WeixinMemberID
            //        var weixinmemberinfo = juactivityBll.Get<WeixinMemberInfo>(string.Format("WeixinMemberID={0}", weixinMemberId));
            //        string RegCode = Common.IOHelper.GetFileStr(context.Server.MapPath("/weixin/wx_reg.htm"), Encoding.UTF8);//注册代码

            //        if (RegCode.Contains("$CCWXOPENID$"))
            //        {
            //            RegCode = RegCode.Replace("$CCWXOPENID$", weixinmemberinfo.WeixinOpenID);
            //        }
            //        if (RegCode.Contains("$CCWXAID$"))//注册到哪个账户下
            //        {

            //            RegCode = RegCode.Replace("$CCWXAID$", Convert.ToString(juactivityBll.Get<UserInfo>(string.Format("UserID='{0}'", weixinmemberinfo.UserID)).AutoID, 16));

            //        }

            //        context.Response.Write(RegCode);//输出注册代码


            //        //微信会员注册

            //    }

            //}

            //#endregion
            #endregion

            //}
            //catch (Exception ex)
            //{
            //    using (StreamWriter sw = new StreamWriter(@"C:\MonitorHandlerException.txt", true, Encoding.UTF8))
            //    {
            //        sw.WriteLine(string.Format("{0} MonitorHandler拦截处理异常:{1}", DateTime.Now.ToString(), ex.ToString()));

            //    }
            //    context.Response.Write("exception");
            //}
        }
Esempio n. 5
0
File: BLLMQ.cs Progetto: uvbs/mmp
        /// <summary>
        /// 问卷统计及计数
        /// </summary>
        /// <param name="messageInfo"></param>
        /// <param name="ramark"></param>
        /// <param name="errMsg"></param>
        public void QuestionnaireStatistics(MessageInfo messageInfo, out string ramark, out string errMsg)
        {
            Console.WriteLine("正在处理问卷统计及计数");
            ramark = "";
            errMsg = "";

            var msgBody = JsonConvert.DeserializeObject <Model.MQ.QuestionnaireStatisticsInfo>(messageInfo.Msg);

            BLL     bll     = new BLL();
            BLLUser bllUser = new BLLUser();

            var QuestionnaireModel = bll.Get <BLLJIMP.Model.Questionnaire>(string.Format("QuestionnaireID={0}", msgBody.QuestionnaireID));

            MonitorEventDetailsInfo detailInfo = new MonitorEventDetailsInfo();

            detailInfo.MonitorPlanID      = msgBody.QuestionnaireID;
            detailInfo.EventType          = 0;
            detailInfo.EventBrowser       = msgBody.EventBrowser;
            detailInfo.EventBrowserID     = msgBody.EventBrowserID;
            detailInfo.EventBrowserIsBata = msgBody.EventBrowserIsBata;

            detailInfo.EventBrowserVersion = msgBody.EventBrowserVersion;
            detailInfo.EventDate           = DateTime.Now;
            detailInfo.EventSysByte        = msgBody.EventSysByte;

            detailInfo.EventSysPlatform = msgBody.EventSysPlatform;
            detailInfo.SourceIP         = msgBody.SourceIP;
            detailInfo.IPLocation       = msgBody.IPLocation;
            detailInfo.SourceUrl        = msgBody.SourceUrl;
            detailInfo.RequesSourcetUrl = msgBody.RequesSourcetUrl;
            detailInfo.WebsiteOwner     = messageInfo.WebsiteOwner;
            detailInfo.ModuleType       = "question";
            detailInfo.EventUserID      = msgBody.EventUserID;
            detailInfo.ShareTimestamp   = "1";

            int ipCount = bll.GetCount <MonitorEventDetailsInfo>(" SourceIP ", string.Format(" WebsiteOwner='{0}' AND MonitorPlanID={1} AND ShareTimestamp='1' ", messageInfo.WebsiteOwner, msgBody.QuestionnaireID));
            int uvCount = bll.GetCount <MonitorEventDetailsInfo>(" EventUserID ", string.Format(" EventUserID is not null AND WebsiteOwner='{0}' AND MonitorPlanID={1} AND ShareTimestamp='1' ", messageInfo.WebsiteOwner, msgBody.QuestionnaireID));
            int pvCount = bll.GetCount <MonitorEventDetailsInfo>(string.Format(" WebsiteOwner='{0}' AND MonitorPlanID={1} ", messageInfo.WebsiteOwner, msgBody.QuestionnaireID));

            QuestionnaireModel.IP = ipCount;
            QuestionnaireModel.PV = pvCount;
            QuestionnaireModel.UV = uvCount;
            bll.Update(QuestionnaireModel);

            var spreadUser = bllUser.GetUserInfo(msgBody.SpreadUserId, messageInfo.WebsiteOwner);

            if (spreadUser != null)
            {
                detailInfo.SpreadUserID = spreadUser.UserID;

                MonitorLinkInfo linkInfo = bll.Get <MonitorLinkInfo>(string.Format(" LinkName='{0}' And MonitorPlanID={1}", spreadUser.UserID, QuestionnaireModel.QuestionnaireID));
                if (linkInfo != null)
                {
                    linkInfo.ActivityName   = QuestionnaireModel.QuestionnaireName;
                    linkInfo.ThumbnailsPath = QuestionnaireModel.QuestionnaireImage;
                    //已经为该用户建立推广链接
                    detailInfo.LinkID = linkInfo.LinkID;
                    //增加打开人数
                    linkInfo.OpenCount++;
                    int shareCount = bll.GetCount <MonitorEventDetailsInfo>("ShareTimestamp", string.Format(" LinkID ={0} and ShareTimestamp is not null and ShareTimestamp <> '' and ShareTimestamp <> '0' ", linkInfo.LinkID));
                    linkInfo.ShareCount = shareCount;
                    int iCount = bll.GetCount <MonitorEventDetailsInfo>(" SourceIP ", string.Format(" MonitorPlanID='{0}' AND SpreadUserID='{1}' ", msgBody.QuestionnaireID, spreadUser.UserID));
                    linkInfo.DistinctOpenCount = ipCount;
                    int uCount = bll.GetCount <MonitorEventDetailsInfo>(" EventUserId ", string.Format(" MonitorPlanID='{0}' AND SpreadUserID='{1}' ", msgBody.QuestionnaireID, spreadUser.UserID));

                    int spreadCount = bll.GetCount <MonitorEventDetailsInfo>(string.Format(" MonitorPlanID='{0}' AND EventUserId='{1}' ", msgBody.QuestionnaireID, msgBody.EventUserID));
                    if (spreadCount == 0)
                    {
                        uCount = uCount + 1;
                    }

                    bll.Update(linkInfo, string.Format(" OpenCount={0},DistinctOpenCount={1},UV={2},ShareCount={3}", linkInfo.OpenCount, iCount, uCount, shareCount), string.Format("LinkID={0}", linkInfo.LinkID));
                }
                else
                {
                    //还没有为该用户建立推广链接
                    MonitorLinkInfo newLinkinfo = new MonitorLinkInfo();
                    newLinkinfo.LinkID            = int.Parse(bll.GetGUID(ZentCloud.BLLJIMP.TransacType.MonitorLinkID));
                    newLinkinfo.MonitorPlanID     = QuestionnaireModel.QuestionnaireID;
                    newLinkinfo.WXMemberID        = 0;
                    newLinkinfo.LinkName          = spreadUser.UserID;
                    newLinkinfo.RealLink          = msgBody.CurrfilePath;
                    newLinkinfo.InsertDate        = DateTime.Now;
                    newLinkinfo.OpenCount         = 1;
                    newLinkinfo.ActivityName      = QuestionnaireModel.QuestionnaireName;
                    newLinkinfo.ThumbnailsPath    = QuestionnaireModel.QuestionnaireImage;
                    newLinkinfo.WebsiteOwner      = messageInfo.WebsiteOwner;
                    newLinkinfo.DistinctOpenCount = 1; // ip
                    newLinkinfo.ShareCount        = 0; //分享数
                    newLinkinfo.ForwardType       = "questionnaire";
                    newLinkinfo.UV         = 1;
                    newLinkinfo.ActivityId = QuestionnaireModel.QuestionnaireID;
                    bll.Add(newLinkinfo);
                }
            }
            bll.Add(detailInfo);


            //更新ip pv uv[Questionnaire]

            int countIp = bll.GetCount <MonitorEventDetailsInfo>(" SourceIP ", string.Format(" MonitorPlanID = {0} ", QuestionnaireModel.QuestionnaireID));
            int countPv = QuestionnaireModel.PV++;
            int countUv = bll.GetCount <MonitorEventDetailsInfo>(" EventUserId ", string.Format(" MonitorPlanID = {0} ", QuestionnaireModel.QuestionnaireID));

            bll.Update(QuestionnaireModel, string.Format(" IP={0},PV={1},UV={2} ", countIp, countPv, countUv), string.Format(" QuestionnaireID={0} ", QuestionnaireModel.QuestionnaireID));

            //更新 转发表
            bll.Update(new ActivityForwardInfo(), string.Format(" PV+=1,UV={0}", countUv), string.Format(" ActivityId='{0}'", QuestionnaireModel.QuestionnaireID));//更新转发表UV.pv

            Console.WriteLine("问卷统计及计数处理完毕");
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string request   = Request["s"]; //接收的参数
                int    eventType = 0;            //默认打开
                //数据验证
                if (!string.IsNullOrEmpty(request))
                {
                    if (request.EndsWith("teq1"))
                    {
                        eventType = 1;//点击khlf
                        //request = request.TrimEnd('teq1');
                        request = request.Substring(0, request.IndexOf("teq1"));
                    }

                    MonitorLinkInfo linkInfo = bll.Get <MonitorLinkInfo>(string.Format("EncryptParameter='{0}'", request));
                    if (linkInfo != null)
                    {
                        MonitorPlan planInfo = bll.Get <MonitorPlan>(string.Format("MonitorPlanID={0}", linkInfo.MonitorPlanID));
                        if (planInfo.PlanStatus.Equals("1"))
                        {
                            MonitorEventDetailsInfo model = new MonitorEventDetailsInfo();
                            //model.DetailID = int.Parse(bll.GetGUID(ZentCloud.BLLJIMP.TransacType.MonitorDetailID));
                            model.MonitorPlanID       = planInfo.MonitorPlanID;
                            model.EventType           = eventType;
                            model.LinkID              = linkInfo.LinkID;
                            model.EventBrowser        = HttpContext.Current.Request.Browser.ToString();
                            model.EventBrowserID      = HttpContext.Current.Request.Browser.Id;
                            model.EventBrowserIsBata  = HttpContext.Current.Request.Browser.Beta.ToString();
                            model.EventBrowserVersion = HttpContext.Current.Request.Browser.Version;
                            model.EventDate           = DateTime.Now;

                            if (HttpContext.Current.Request.Browser.Win32)
                            {
                                model.EventSysByte = "32位系统";
                            }
                            else
                            {
                                model.EventSysByte = "64位系统";
                            }


                            model.EventSysPlatform = HttpContext.Current.Request.Browser.Platform;
                            model.SourceIP         = Common.MySpider.GetClientIP();
                            model.IPLocation       = Common.MySpider.GetIPLocation(model.SourceIP);
                            if (Request.UrlReferrer != null)
                            {
                                model.SourceUrl = Request.UrlReferrer.ToString();
                            }
                            bll.Add(model);
                            if (eventType.Equals(1))
                            {
                                if (linkInfo != null)
                                {
                                    Response.Redirect(linkInfo.RealLink, false);
                                }
                            }
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        Response.End();
                    }
                }
            }
            catch (Exception ex)
            {
                Response.End();
            }
        }
Esempio n. 7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            try
            {
                // UserInfo distributionOffLineCommendUser = null;//分销推荐人
                //bool isDistributionOffLineApply = false;//是否线下分销申请
                dicPar = bll.GetRequestParameter();
                string weixinOpenID = null; //微信openid
                string activityId   = null; //活动编号
                dicPar.TryGetValue("ActivityID", out activityId);
                string spreadUserId = null;
                dicPar.TryGetValue("SpreadUserID", out spreadUserId);//推广用户的用户名
                string shareUserId = string.Empty;
                dicPar.TryGetValue("ShareUserID", out shareUserId);
                string shareId = string.Empty;
                dicPar.TryGetValue("ShareID", out shareId);
                string strDistinctKeys = null; //检查重复的字段,多个字段用,分隔, //没有此参数默认用手机检查
                dicPar.TryGetValue("DistinctKeys", out strDistinctKeys);
                string monitorPlanID = null;   //监测任务ID
                dicPar.TryGetValue("MonitorPlanID", out monitorPlanID);
                string name = null;            //姓名
                dicPar.TryGetValue("Name", out name);
                string phone = null;           //手机
                dicPar.TryGetValue("Phone", out phone);
                string isSaveUserInfo = string.Empty;
                dicPar.TryGetValue("IsSaveUserInfo", out isSaveUserInfo);

                //activity = bll.Get<ActivityInfo>(string.Format("ActivityID='{0}'", activityId));

                #region IP限制
                //获取用户IP;
                string userHostAddress = context.Request.UserHostAddress;
                var    count           = DataCache.GetCache(userHostAddress);
                if (count != null)
                {
                    int newCount = int.Parse(count.ToString()) + 1;
                    DataCache.SetCache(userHostAddress, newCount);
                    int limitCount = 1000;
                    //if (activity != null)
                    //{

                    //    //limitCount = activity.LimitCount;

                    //}
                    if (newCount >= limitCount)
                    {
                        resp.Status = 14;
                        resp.Msg    = "您的提交过于频繁,请稍后再试";
                        goto outoff;
                    }
                }
                else
                {
                    DataCache.SetCache(userHostAddress, 1, DateTime.MaxValue, new TimeSpan(4, 0, 0));
                }


                #endregion

                #region 判断必填项
                if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(phone))
                {
                    resp.Status = 3;
                    resp.Msg    = "姓名和手机不能为空!";
                    goto outoff;
                }
                //if ((!Common.ValidatorHelper.PhoneNumLogicJudge(Phone))&&(!Phone.Equals("systemdefault")))//系统缺省手机号不检查
                //{
                //    resp.Status = 5;
                //    resp.Msg = "手机号码无效!";
                //    goto outoff;
                //}
                if (((!phone.StartsWith("1")) || (!phone.Length.Equals(11))) && (!phone.Equals("systemdefault")))//系统缺省手机号不检查
                {
                    resp.Status = 5;
                    resp.Msg    = "手机号码无效!";
                    goto outoff;
                }
                if (string.IsNullOrEmpty(activityId))
                {
                    resp.Status = 6;
                    resp.Msg    = "活动编号不能为空!";
                    goto outoff;
                }

                //手机注册的重复数据
                UserInfo dicUser = bllUser.Get <UserInfo>(string.Format(" WebsiteOwner='{0}' AND Phone='{1}' AND WXOpenId is null ", bllUser.WebsiteOwner, phone));
                if (dicUser != null)
                {
                    dicUser.Phone3 = phone;
                    dicUser.Phone  = "";
                    bllUser.Update(dicUser);
                }



                #endregion

                #region 活动权限验证
                //if (activity == null)
                //{
                //    resp.Status = 7;
                //    resp.Msg = "活动编号不存在!";
                //    goto outoff;
                //}
                //if (activity.ActivityStatus.Equals(0))
                //{
                //    resp.Status = 8;
                //    resp.Msg = "活动已关闭!";
                //    goto outoff;
                //}

                //if (activity.IsDelete.Equals(1))
                //{
                //    resp.Status = -1;
                //    resp.Msg = "活动已删除!";
                //    goto outoff;
                //}
                #endregion

                #region 是否可以报名
                if (bll.IsLogin)
                {
                    currentUserInfo = bll.GetCurrentUserInfo();
                    if (!string.IsNullOrEmpty(currentUserInfo.WXOpenId))
                    {
                        weixinOpenID = currentUserInfo.WXOpenId;
                    }
                }
                juActivityInfo = bll.Get <JuActivityInfo>(string.Format("SignUpActivityID={0}", dicPar["ActivityID"]));
                if (juActivityInfo != null)
                {
                    #region 活动已经停止
                    if (juActivityInfo.IsHide.Equals(1))
                    {
                        resp.Status = 14;
                        resp.Msg    = "活动已停止";
                        goto outoff;
                    }
                    #endregion

                    #region 检查报名人数
                    if (juActivityInfo.MaxSignUpTotalCount > 0)//检查报名人数
                    {
                        if (juActivityInfo.SignUpTotalCount > (juActivityInfo.MaxSignUpTotalCount - 1))
                        {
                            resp.Status = 15;
                            resp.Msg    = "报名人数已满";
                            goto outoff;
                        }
                    }
                    #endregion

                    #region 检查积分
                    if (juActivityInfo.ActivityIntegral > 0)
                    {
                        if (!bll.IsLogin)
                        {
                            resp.Status = 12;
                            resp.Msg    = "此活动必须登录才能报名";
                            goto outoff;
                        }
                        else
                        {
                            if (currentUserInfo.TotalScore < juActivityInfo.ActivityIntegral)
                            {
                                resp.Status = 13;
                                resp.Msg    = "您的积分不足,无法报名";
                                goto outoff;
                            }
                        }
                    }
                    #endregion

                    #region 指定标签的用户可以报名
                    if (!string.IsNullOrEmpty(juActivityInfo.Tags))
                    {
                        if (!bll.IsLogin)
                        {
                            resp.Status = 12;
                            resp.Msg    = "此活动必须登录才能报名";
                            goto outoff;
                        }
                        if (string.IsNullOrEmpty(currentUserInfo.TagName))
                        {
                            resp.Status = 12;
                            resp.Msg    = "此活动只接受特定用户的报名";
                            goto outoff;
                        }
                        bool checkResult = false;
                        foreach (string item in currentUserInfo.TagName.Split(','))
                        {
                            if (juActivityInfo.Tags.Contains(item))
                            {
                                checkResult = true;
                                break;
                            }
                        }
                        if (!checkResult)
                        {
                            resp.Status = 12;
                            resp.Msg    = "此活动只接受特定用户的报名";
                            goto outoff;
                        }
                    }
                    #endregion
                }
                #endregion

                #region 检查自定义必填项
                List <ActivityFieldMappingInfo> requiredFieldList = bll.GetList <ActivityFieldMappingInfo>(string.Format("ActivityID='{0}' And FieldIsNull=1", juActivityInfo.SignUpActivityID));
                if (requiredFieldList.Count > 0)
                {
                    foreach (var requiredField in requiredFieldList)
                    {
                        if (string.IsNullOrEmpty(dicPar.SingleOrDefault(p => p.Key.Equals(string.Format("K{0}", requiredField.ExFieldIndex))).Value))
                        {
                            resp.Status = 11;
                            resp.Msg    = string.Format(" {0} 必填", requiredField.MappingName);
                            goto outoff;
                        }
                    }
                }
                #endregion

                #region 检查数据格式
                //检查数据格式
                List <ActivityFieldMappingInfo> activityFieldMappingList = bll.GetList <ActivityFieldMappingInfo>(string.Format("ActivityID='{0}'", juActivityInfo.SignUpActivityID));
                foreach (var item in activityFieldMappingList)
                {
                    string value = dicPar.SingleOrDefault(p => p.Key.Equals(string.Format("K{0}", item.ExFieldIndex))).Value;

                    if (string.IsNullOrWhiteSpace(value))
                    {
                        continue;
                    }

                    //检查数据格式
                    if (item.FormatValiFunc == "email")//email检查
                    {
                        if (!Common.ValidatorHelper.EmailLogicJudge(value))
                        {
                            resp.Status = 12;
                            resp.Msg    = string.Format("{0}格式不正确", item.MappingName);
                            goto outoff;
                        }
                    }
                    if (item.FormatValiFunc == "url")                                                                                                             //url检查
                    {
                        System.Text.RegularExpressions.Regex regUrl = new System.Text.RegularExpressions.Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"); //网址
                        System.Text.RegularExpressions.Match match  = regUrl.Match(value);
                        if (!match.Success)
                        {
                            resp.Status = 13;
                            resp.Msg    = string.Format("{0}格式不正确", item.MappingName);
                            goto outoff;
                        }
                    }
                }
                #endregion

                #region 检查是否已经报名

                //if (activityId != bllDis.GetDistributionOffLineApplyActivityID())//线下分销不检查
                //{
                if (!string.IsNullOrEmpty(strDistinctKeys))
                {
                    if (!strDistinctKeys.Equals("none"))//自定义检查重复
                    {
                        System.Text.StringBuilder sbWhere = new System.Text.StringBuilder("1=1 ");
                        string[] distinctKeys             = strDistinctKeys.Split(',');
                        foreach (var item in distinctKeys)
                        {
                            sbWhere.AppendFormat("And {0}='{1}' ", item, dicPar.Single(p => p.Key.Equals(item)).Value);
                        }
                        sbWhere.Append("  and IsDelete = 0  ");
                        if (bll.GetCount <ActivityDataInfo>(sbWhere.ToString()) > 0)
                        {
                            resp.Status = 1;
                            resp.Msg    = "重复的报名!";
                            goto outoff;
                        }
                    }
                    else//不检查重复
                    {
                    }
                }
                else//默认检查
                {
                    if (bll.GetCount <ActivityDataInfo>(string.Format("ActivityID='{0}' And Phone='{1}' and IsDelete = 0 ", activityId, phone)) > 0)
                    {
                        resp.Status = 1;
                        resp.Msg    = "已经报过名了!";
                        goto outoff;
                    }
                }
                //}



                #endregion

                //if (activityId == bllDis.GetDistributionOffLineApplyActivityID())//如果当前活动是分销
                //{
                //    if (bll.GetCount<ActivityDataInfo>(string.Format("ActivityID='{0}' And UserId='{1}' and IsDelete = 0 ", activityId, currentUserInfo.UserID)) > 0)
                //    {
                //        bll.Update(new ActivityDataInfo(), string.Format("IsDelete=1"), string.Format(" ActivityID='{0}' And UserId='{1}'", activityId, currentUserInfo.UserID));
                //    }
                //}

                //#region 检查手机验证码 特殊化
                ////if (ActivityID.Equals("186135"))
                ////{
                ////    string VerCode = HttpContext.Current.Session["SmsVerificationCode"] == null ? "" : HttpContext.Current.Session["SmsVerificationCode"].ToString();
                ////    if (string.IsNullOrEmpty(context.Request["SmsVerificationCode"]))
                ////    {
                ////        resp.Status = 12;
                ////        resp.Msg = "请输入手机验证码";
                ////        goto outoff;


                ////    }
                ////    if (!context.Request["SmsVerificationCode"].ToString().Equals(VerCode))
                ////    {
                ////            resp.Status = 13;
                ////            resp.Msg = "手机验证码不正确";
                ////            goto outoff;
                ////    }
                ////}
                //#endregion

                var newActivityUID       = 1001;
                var lastActivityDataInfo = bll.Get <ActivityDataInfo>(string.Format("ActivityID='{0}' order by UID DESC", activityId));
                if (lastActivityDataInfo != null)
                {
                    newActivityUID = lastActivityDataInfo.UID + 1;
                }
                ActivityDataInfo model = bll.ConvertRequestToModel <ActivityDataInfo>(new ActivityDataInfo());
                model.UID          = newActivityUID;
                model.WeixinOpenID = weixinOpenID;
                model.SpreadUserID = spreadUserId;
                if (spreadUserId == currentUserInfo.UserID)
                {
                    model.SpreadUserID = bll.WebsiteOwner;
                }
                if (!string.IsNullOrEmpty(monitorPlanID))
                {
                    model.MonitorPlanID = int.Parse(monitorPlanID);
                }
                model.ShareUserID  = string.IsNullOrWhiteSpace(shareUserId) ? "" : shareUserId;
                model.ShareID      = string.IsNullOrWhiteSpace(shareId) ? "" : shareId;
                model.WebsiteOwner = bll.WebsiteOwner;
                if (bll.IsLogin)
                {
                    model.UserId = bll.GetCurrUserID();
                }

                //保存分销推荐码
                // model.DistributionOffLineRecommendCode = context.Request["DistributionOffLineRecommendCode"];


                //if (!string.IsNullOrWhiteSpace(model.DistributionOffLineRecommendCode))
                //{
                //    bool isTrueCode = false;
                //    int userAutoId = 0;
                //    if (int.TryParse(model.DistributionOffLineRecommendCode, out userAutoId))
                //    {
                //        distributionOffLineCommendUser = bllUser.GetUserInfoByAutoID(userAutoId);

                //        if (distributionOffLineCommendUser != null)
                //        {
                //            //是站点用户或者是当前站点的分销员才有效
                //            if (bll.WebsiteOwner.ToLower() == distributionOffLineCommendUser.UserID.ToLower())
                //            {
                //                isTrueCode = true;
                //            }
                //            else if (distributionOffLineCommendUser.WebsiteOwner.ToLower() == bll.WebsiteOwner.ToLower() && !string.IsNullOrWhiteSpace(distributionOffLineCommendUser.DistributionOffLinePreUserId))
                //            {
                //                isTrueCode = true;
                //            }
                //        }
                //    }

                //    if (!isTrueCode)
                //    {
                //        resp.Status = 1;
                //        resp.Msg = "不是有效的推荐码";
                //        goto outoff;
                //    }
                //    else
                //    {
                //        isDistributionOffLineApply = true;
                //    }

                //    ToLog("isDistributionOffLineApply:" + isDistributionOffLineApply);

                //}


                if (bll.Add(model))
                {
                    try
                    {
                        //#region 业务分销员申请消息
                        ////发送模板消息跟系统微客服和他的上级
                        //ToLog("isDistributionOffLineApply:" + isDistributionOffLineApply);
                        //if (isDistributionOffLineApply)
                        //{
                        //    ToLog("申请成为财富会员,发送消息给系统管理员");

                        //    //发送消息给他上级
                        //    //bllWeixin.SendTemplateMessageNotifyComm(distributionOffLineCommendUser.WXOpenId, "财富伙伴申请", string.Format("姓名:{0}\\n手机号:{1}", model.Name, model.Phone));

                        //    //发送消息给系统管理员
                        //    // WXKeFu kefuInfo = bllWeixin.GetDefaultKefu();
                        //    //ToLog("客服实体:" + JSONHelper.ObjectToJson(kefuInfo));
                        //    bllWeixin.SendTemplateMessageToKefu(string.Format("用户“{0}”申请成为财富会员", model.Name), string.Format("姓名:{0}\\n手机号:{1}", model.Name, model.Phone));

                        //}
                        //#endregion

                        #region 个人资料补足
                        if (bll.IsLogin)
                        {
                            //个人资料补足
                            bool isEdit = false;
                            isSaveUserInfo = "1";
                            if (string.IsNullOrWhiteSpace(currentUserInfo.TrueName))
                            {
                                isEdit = true;
                                currentUserInfo.TrueName = model.Name;
                            }
                            if (string.IsNullOrWhiteSpace(currentUserInfo.Phone))
                            {
                                isEdit = true;
                                currentUserInfo.Phone = model.Phone;
                            }
                            List <BLLJIMP.Model.ActivityFieldMappingInfo> mapingList = this.bll.GetList <BLLJIMP.Model.ActivityFieldMappingInfo>(string.Format(" ActivityID = '{0}' ", model.ActivityID));

                            foreach (var item in mapingList)
                            {
                                string value = "";
                                if (item.MappingName.IndexOf("邮箱") > -1 || item.MappingName.IndexOf("邮件") > -1 || item.MappingName.ToLower().IndexOf("email") > -1)
                                {
                                    isEdit = true;

                                    value = dicPar.SingleOrDefault(p => p.Key.Equals(string.Format("K{0}", item.ExFieldIndex))).Value;
                                    if (string.IsNullOrWhiteSpace(currentUserInfo.Email))
                                    {
                                        currentUserInfo.Email = value;
                                    }
                                    continue;
                                }

                                if (item.MappingName.IndexOf("职位") > -1)
                                {
                                    isEdit = true;
                                    value  = dicPar.SingleOrDefault(p => p.Key.Equals(string.Format("K{0}", item.ExFieldIndex))).Value;
                                    if (string.IsNullOrWhiteSpace(currentUserInfo.Postion))
                                    {
                                        currentUserInfo.Postion = value;
                                    }
                                    continue;
                                }

                                if (item.MappingName.IndexOf("公司") > -1)
                                {
                                    isEdit = true;
                                    value  = dicPar.SingleOrDefault(p => p.Key.Equals(string.Format("K{0}", item.ExFieldIndex))).Value;
                                    if (value.Length >= 255)
                                    {
                                        resp.Status = 3;
                                        resp.Msg    = "公司名称过长!";
                                        goto outoff;
                                    }
                                    if (string.IsNullOrWhiteSpace(currentUserInfo.Company))
                                    {
                                        currentUserInfo.Company = value;
                                    }
                                    continue;
                                }
                            }


                            if (isEdit)
                            {
                                this.bll.Update(new UserInfo(),
                                                string.Format(" TrueName='{0}',Phone='{1}',Email='{2}',Postion='{3}',Company='{4}'  ",
                                                              currentUserInfo.TrueName,
                                                              currentUserInfo.Phone,
                                                              currentUserInfo.Email,
                                                              currentUserInfo.Postion,
                                                              currentUserInfo.Company
                                                              ),
                                                string.Format(" AutoID = {0} ", this.currentUserInfo.AutoID)
                                                );
                            }

                            //if (isEdit && !string.IsNullOrWhiteSpace(isSaveUserInfo))
                            //{
                            //    if (isSaveUserInfo == "1")
                            //    {
                            //        this.bll.Update(new UserInfo(),
                            //                string.Format(" TrueName='{0}',Phone='{1}',Email='{2}',Postion='{3}',Company='{4}'  ",
                            //                        currentUserInfo.TrueName,
                            //                        currentUserInfo.Phone,
                            //                        currentUserInfo.Email,
                            //                        currentUserInfo.Postion,
                            //                        currentUserInfo.Company
                            //                    ),
                            //                string.Format(" AutoID = {0} ", this.currentUserInfo.AutoID)
                            //            );
                            //    }
                            //}
                            //if (bll.IsLogin)
                            //{
                            //    var websiteInfo = bll.GetWebsiteInfoModelFromDataBase();
                            //    if (websiteInfo.IsSynchronizationData != null)
                            //    {
                            //        if (websiteInfo.IsSynchronizationData.Value == 1)
                            //        {

                            //            bllUser.Update(currentUserInfo);
                            //        }
                            //    }
                            //}
                        }
                        #endregion

                        #region 检查是否向微信客服号发送通知信息

                        if (juActivityInfo != null)
                        {
                            //if (!string.IsNullOrEmpty(juActivityInfo.ActivityNoticeKeFuId))
                            //{

                            //    WXKeFu keFuInfo = bll.Get<WXKeFu>(string.Format("AutoID={0}", juActivityInfo.ActivityNoticeKeFuId));
                            //    if (keFuInfo != null)
                            //    {

                            //        #region 发送模板消息给客服
                            //        if (juActivityInfo.ArticleType != "greetingcard")
                            //        {
                            //            bllWeixin.SendTemplateMessageNotifyComm(keFuInfo.WeiXinOpenID, string.Format("{0}有新的报名", juActivityInfo.ActivityName), string.Format("姓名:{0}\\n手机号:{1}", model.Name, model.Phone));
                            //        }
                            //        #endregion


                            //    }
                            //}

                            #region 发送模板消息给客服
                            if (juActivityInfo.ArticleType != "greetingcard")
                            {
                                bllWeixin.SendTemplateMessageToKefu(string.Format("{0}有新的报名", juActivityInfo.ActivityName), string.Format("姓名:{0}\\n手机号:{1}", model.Name, model.Phone));
                            }
                            #endregion

                            juActivityInfo.SignUpCount = juActivityInfo.SignUpTotalCount + 1;
                            bll.Update(juActivityInfo);
                        }



                        #endregion

                        #region 更新转发表报名数量
                        MonitorLinkInfo linkModel   = bll.Get <MonitorLinkInfo>(string.Format(" MonitorPlanID={0} AND LinkName='{1}' ", monitorPlanID, spreadUserId));
                        int             signupCount = bll.GetCount <ActivityDataInfo>(string.Format("MonitorPlanID={0} And SpreadUserID='{1}' And IsDelete=0", int.Parse(monitorPlanID), spreadUserId));
                        if (linkModel != null)
                        {
                            linkModel.ActivitySignUpCount = signupCount;
                            bll.Update(linkModel);
                        }
                        #endregion

                        //#region 向报名人发送公众号模板消息-仅五步会有效

                        //if (bll.WebsiteOwner == "wubuhui")
                        //{
                        //    if (bllWeixin.IsLogin)
                        //    {
                        //        string accessToken = bllWeixin.GetAccessToken();
                        //        if (accessToken != string.Empty)
                        //        {
                        //            BLLWeixin.TMSignupNotification notificaiton = new BLLWeixin.TMSignupNotification();

                        //            notificaiton.Url = string.Format("http://{0}/WuBuHui/MyCenter/Index.aspx", System.Web.HttpContext.Current.Request.Url.Host);

                        //            notificaiton.TemplateId = "-eJq0w8PEFQRLnWXwqKn73zWvAah6nJxYHgEK3L4Pek";
                        //            notificaiton.First = "恭喜您成功报名我们的活动";
                        //            notificaiton.Keynote1 = juActivityInfo.ActivityName;
                        //            notificaiton.Keynote2 = juActivityInfo.ActivityStartDate.ToString();
                        //            notificaiton.Keynote3 = juActivityInfo.ActivityAddress;
                        //            notificaiton.Remark = "欢迎您届时参加!";
                        //            bllWeixin.SendTemplateMessage(accessToken, currentUserInfo.WXOpenId, notificaiton);

                        //        }
                        //    }
                        //}



                        //#endregion

                        #region 发送模板消息给用户
                        if ((currentUserInfo != null))
                        {
                            if (juActivityInfo.ArticleType != "greetingcard" && juActivityInfo.IsFee == 0)
                            {
                                bllWeixin.SendTemplateMessageNotifyComm(currentUserInfo, string.Format("您已成功报名{0}", juActivityInfo.ActivityName), string.Format("姓名:{0}\\n手机号:{1}", model.Name, model.Phone));
                            }
                            if (juActivityInfo.IsFee == 1)//收费活动
                            {
                                if (model.Amount > 0)
                                {
                                    bllWeixin.SendTemplateMessageNotifyComm(currentUserInfo, string.Format("您已报名{0},该活动收费,请尽快完成支付。", juActivityInfo.ActivityName), "");
                                }
                            }
                        }
                        #endregion

                        #region 微转发自动成为线上分销员
                        if (!string.IsNullOrEmpty(model.SpreadUserID))
                        {
                            if (bll.IsLogin)
                            {
                                try
                                {
                                    WebsiteInfo websiteInfo = bll.GetWebsiteInfoModelFromDataBase();

                                    if (websiteInfo.DistributionRelationBuildSpreadActivity == 1)
                                    {
                                        UserInfo recommentUserInfo = bllUser.GetUserInfo
                                                                         (spreadUserId);
                                        //ActivityInfo disActivityInfo = bll.GetActivityInfoByActivityID(bllDis.GetDistributionOffLineApplyActivityID());
                                        //bllDis.AutoApply(currentUserInfo, activity, disActivityInfo, recommentUserInfo, model);
                                        if (bllUser.IsDistributionMember(recommentUserInfo) || (recommentUserInfo.UserID == websiteInfo.WebsiteOwner))
                                        {
                                            bllDisOnLine.SetUserDistributionOwner(currentUserInfo.UserID, recommentUserInfo.UserID, currentUserInfo.WebsiteOwner);
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    ToLog(ex.ToString());
                                }
                            }
                        }
                        #endregion

                        juActivityInfo = bllJuactivity.GetJuActivityByActivityID(activityId);
                    }
                    catch (Exception)
                    {
                    }
                    resp.Msg = "提交成功!";
                    //Dictionary<string, object> exObj = new Dictionary<string, object>();
                    //exObj.Add("Activity", Activity);
                    //exObj.Add("ActivityData", model);
                    //exObj.Add("ActivityFieldMapping", activityFieldMapping);
                    //resp.ExObj = exObj;
                    resp.ExInt = model.UID;
                    if (juActivityInfo != null)
                    {
                        resp.ExStr = juActivityInfo.ActivitySignuptUrl;
                    }

                    // 推荐报名活动加积分
                    if (!string.IsNullOrEmpty(spreadUserId))
                    {
                        if (spreadUserId != currentUserInfo.UserID)
                        {
                            UserInfo recommentUserInfo = bllUser.GetUserInfo(spreadUserId);
                            bllUser.AddUserScoreDetail(recommentUserInfo.UserID, CommonPlatform.Helper.EnumStringHelper.ToString(ZentCloud.BLLJIMP.Enums.ScoreDefineType.RecommendSignUpActivityAddScore), recommentUserInfo.WebsiteOwner, null, null);
                        }
                    }

                    #region MyRegion
                    if (!string.IsNullOrEmpty(context.Request["AutoSignIn"]))
                    {
                        if (context.Request["AutoSignIn"].ToString() == "1")
                        {
                            try
                            {
                                WXSignInInfo signInInfo = new WXSignInInfo();
                                signInInfo.SignInUserID = currentUserInfo.UserID;
                                signInInfo.Name         = model.Name;
                                signInInfo.Phone        = model.Phone;
                                signInInfo.JuActivityID = juActivityInfo.JuActivityID;
                                signInInfo.SignInOpenID = currentUserInfo.WXOpenId;
                                signInInfo.SignInTime   = DateTime.Now;
                                //判断是否已经签到过
                                if (!bllJuactivity.Exists(signInInfo, new List <string>()
                                {
                                    "SignInUserID", "JuActivityID"
                                }))
                                {
                                    if (bllJuactivity.Add(signInInfo))
                                    {
                                        bllUser.AddUserScoreDetail(currentUserInfo.UserID, CommonPlatform.Helper.EnumStringHelper.ToString(ZentCloud.BLLJIMP.Enums.ScoreDefineType.SignIn), currentUserInfo.WebsiteOwner, null, null);
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                    #endregion


                    goto outoff;
                }
                else
                {
                    resp.Status = 2;
                    resp.Msg    = "报名失败,请重试或联系管理员!";
                    goto outoff;
                }
            }
            catch (Exception ex)
            {
                //using (StreamWriter sw = new StreamWriter(@"C:\log.txt", true, System.Text.Encoding.GetEncoding("gb2312")))
                //{
                //    sw.WriteLine(ex.Data);
                //}
                resp.Status = 10;
                resp.Msg    = "报名失败:" + ex.ToString();
                goto outoff;
                //日志记录
            }
outoff:
            context.Response.Write(Common.JSONHelper.ObjectToJson(resp));
        }