Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            logger.Info(this.Request.Url.AbsoluteUri);

            //http%3a%2f%2f112.64.17.80%2fwechat%2fBusinessPolicyQuery.aspx%3fsearch_scope%3dvalidate%26messageType%3dnotice%26agentId%3d6
            //http%3a%2f%2f112.64.17.80%2fwechat%2fBusinessPolicyQuery.aspx%3fsearch_scope%3dvalidate%26messageType%3dnotice
            String myUrl = "http://112.64.17.80/wechat/CaseQuery.aspx?agentId=10";
             myUrl = this.Server.UrlEncode(myUrl);
            string code = Request.QueryString["code"];
            string state = Request.QueryString["state"];
           // string search_scope = Request.QueryString["search_scope"];
            string agentId = Request.QueryString["agentId"];
            logger.Info("agentId=" + Request.QueryString["agentId"]);
            logger.Info("code=" + Request.QueryString["code"]);
            logger.Info("state=" + Request.QueryString["state"]);
           // logger.Info("search_scope=" + Request.QueryString["search_scope"]);
             WechatUtil wechatUtil = new Util.WechatUtil();
             HttpResult result = wechatUtil.getUserInfoFromWechat(code, agentId, MyConstant.ScretId);
            logger.Info("result=" + result.Html);
            if (result != null && result.Html != null && result.Html.Contains("UserId"))
            {
                WechatUserId returnMessage = (WechatUserId)JsonConvert.DeserializeObject(result.Html, typeof(WechatUserId));

                AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
                AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(returnMessage.UserId);

                if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
                {
                    this.lblTitle.Text = "你的账号已被停用,请联系联通工作人员!";
                    //  sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

                }
                else if (agentWechatAccount == null)
                {
                    this.lblTitle.Text = "用户不存在,请联系联通工作人员!";
                    //sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
                }
                else
                {
                    String agentNo = agentWechatAccount.branchNo;
                    if (String.IsNullOrEmpty(agentNo))
                    {
                        agentNo = agentWechatAccount.agentNo;
                    }


                    bindDataToGrid("", agentNo, agentWechatAccount.contactId);
                }
            }
            else
            {
                //bindDataToGrid("", "P001","P001");
            }
          

        }
Esempio n. 2
0
        private void initControl()
        {
            this.Cursor = Cursors.WaitCursor;
            this.btnSave.Enabled = false;
            this.btnDelete.Enabled = false;

            this.txtUserName.Clear();
            this.txtProcessCode.Clear();
            this.txtJoinTime.Clear();
            this.txtJoinMenu.Clear();
            this.txtComplainContent.Clear();
            this.txtBranchCode.Clear();
            this.txtBranchName.Clear();
            this.cboAgentNo.ResetText();
            this.dtReplyTime.ResetText();
            this.txtComent.Clear();
            this.txtSequence.Clear();

            this.dtReplyTime.Value = DateTime.Now.AddDays(10);


            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            IList<AgentWechatAccount> agentWechatAccountList = agentWechatAccountDao.GetAllAgentOrBranch();
            this.cboAgentNo.Items.Clear();
            //  this.lstAgentType.Items.Add("所有渠道");
            foreach (AgentWechatAccount agentWechatAccount in agentWechatAccountList)
            {
                if (agentWechatAccount.type.Contains("代理商"))
                {
                    listOnit.Add(agentWechatAccount.agentNo + ":" + agentWechatAccount.agentName);
                       // this.cboAgentNo.Items.Add(agentWechatAccount.agentNo + ":" + agentWechatAccount.agentName);

                }
            }
            this.cboAgentNo.Items.AddRange(listOnit.ToArray());

            this.Cursor = Cursors.Default;
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {

            //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx31204de5a3ae758e&redirect_uri=http%3a%2f%2f112.64.17.80%2fwechat%2fMyExamQuery.aspx%3fstatus%3dnew%26messageType%3dexam%26agentId%3d11&response_type=code&scope=snsapi_base&state=new#wechat_redirect
            //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx31204de5a3ae758e&redirect_uri=http%3a%2f%2f112.64.17.80%2fwechat%2fMyExamQuery.aspx%3fstatus%3dfinish%26messageType%3dexam%26agentId%3d11&response_type=code&scope=snsapi_base&state=join#wechat_redirect
            //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx31204de5a3ae758e&redirect_uri=http%3a%2f%2f112.64.17.80%2fwechat%2fMyExamQuery.aspx%3fstatus%3dnew%26messageType%3dsurvey%26agentId%3d11&response_type=code&scope=snsapi_base&state=new#wechat_redirect
            //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx31204de5a3ae758e&redirect_uri=http%3a%2f%2f112.64.17.80%2fwechat%2fMyExamQuery.aspx%3fstatus%3dfinish%26messageType%3dsurvey%26agentId%3d11&response_type=code&scope=snsapi_base&state=join#wechat_redirect
            //String myUrl = "http://112.64.17.80/wechat/MyExamQuery.aspx?status=new&messageType=exam&agentId=11";
            // myUrl = this.Server.UrlEncode(myUrl);

            logger.Info(this.Request.Url.AbsoluteUri);
            string code = Request.QueryString["code"];
            string state = Request.QueryString["state"];
            string messageType = Request.QueryString["messageType"];
            string agentId = Request.QueryString["agentId"];
            string status = Request.QueryString["status"];
            logger.Info("agentId=" + Request.QueryString["agentId"]);
            logger.Info("code=" + Request.QueryString["code"]);
            logger.Info("state=" + Request.QueryString["state"]);
            logger.Info("messageType=" + Request.QueryString["messageType"]);
            logger.Info("status=" + Request.QueryString["status"]);
             WechatUtil wechatUtil = new Util.WechatUtil();
             HttpResult result = wechatUtil.getUserInfoFromWechat(code, agentId, MyConstant.ScretId);
            logger.Info("result=" + result.Html);
            if (result != null && result.Html != null && result.Html.Contains("UserId"))
            {
                WechatUserId returnMessage = (WechatUserId)JsonConvert.DeserializeObject(result.Html, typeof(WechatUserId));

                logger.Info("returnMessage userId=" + returnMessage.UserId);

                AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
                AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(returnMessage.UserId);

                if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
                {
                    this.lblType.Text = "你的账号已被停用,请联系联通工作人员!";
                    //  sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

                }
                else if (agentWechatAccount == null)
                {
                    this.lblType.Text = "用户不存在,请联系联通工作人员!";
                    //sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
                }
                else
                {
                    String agentNo = agentWechatAccount.branchNo;
                    if (String.IsNullOrEmpty(agentNo))
                    {
                        agentNo = agentWechatAccount.agentNo;
                    }
                   

                    //this.lblUserId.Text = agentWechatAccount.contactId;

                    this.Session.Add("userId", agentWechatAccount.contactId);
                    this.Session.Add("messageType", messageType);
                    this.Session.Add("status", status);
                    bindDataToGrid("");
                }
            }
        }
Esempio n. 4
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;


            // Queryworker.ReportProgress(4, "代理商佣金...\r\n");
            //代理商佣金
            StudyReceiverLogDao studyReceiverLogDao = new StudyReceiverLogDao();
            StudyDao studyDao = new StudyDao();
            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            IList<StudyReceiverLog> studyReceiverLogList = studyReceiverLogDao.GetList(this.txtSubjectKeyword.Text.Trim(), this.txtUserKeyword.Text.Trim(), this.dtDay.Value.ToString("yyyy-MM-dd"));
            dgStudyReadLog.Rows.Clear();
            dgStudyReadLog.Columns.Clear();
            if (studyReceiverLogList != null && studyReceiverLogList.Count > 0)
            {
                this.grpAgentFee.Text = "阅读日志(" + studyReceiverLogList.Count + ")";
                dgStudyReadLog.Columns.Add("渠道类型", "渠道类型");
                dgStudyReadLog.Columns.Add("渠道编码", "渠道编码");
                dgStudyReadLog.Columns.Add("渠道名称", "渠道名称");
                dgStudyReadLog.Columns.Add("代理商编号", "代理商编号");
                dgStudyReadLog.Columns.Add("代理商名称", "代理商名称");
                dgStudyReadLog.Columns.Add("用户账号", "用户账号");
                dgStudyReadLog.Columns.Add("用户名", "用户名");
                dgStudyReadLog.Columns.Add("用户微信", "用户微信");
                dgStudyReadLog.Columns.Add("阅读时间", "阅读时间");
                dgStudyReadLog.Columns.Add("主题", "主题");
                dgStudyReadLog.Columns.Add("内容", "内容");
               

                for (int i = 0; i < studyReceiverLogList.Count; i++)
                {

                   // Study study = studyDao.Get(Int32.Parse(studyReceiverLogList[i].studySequence));
                    //AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(studyReceiverLogList[i].userId);
                    dgStudyReadLog.Rows.Add();
                    DataGridViewRow row = dgStudyReadLog.Rows[i];
                    if (studyReceiverLogList[i].agentContact != null)
                    {
                        row.Cells[0].Value = studyReceiverLogList[i].agentContact.type;
                        row.Cells[1].Value = studyReceiverLogList[i].agentContact.branchNo;
                        row.Cells[2].Value = studyReceiverLogList[i].agentContact.branchName;
                        row.Cells[3].Value = studyReceiverLogList[i].agentContact.agentNo;
                        row.Cells[4].Value = studyReceiverLogList[i].agentContact.agentName;
                        row.Cells[5].Value = studyReceiverLogList[i].agentContact.contactId;
                        row.Cells[6].Value = studyReceiverLogList[i].agentContact.contactName;
                        row.Cells[7].Value = studyReceiverLogList[i].agentContact.contactWechat;
                    }
                    row.Cells[8].Value = studyReceiverLogList[i].readtime;
                    if (studyReceiverLogList[i].study != null)
                    {
                        row.Cells[9].Value = studyReceiverLogList[i].study.subject;
                        row.Cells[10].Value = studyReceiverLogList[i].study.content;
                    }
                   



                }
            }
            dgStudyReadLog.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;
            this.dgStudyReadLog.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
            dgStudyReadLog.AutoResizeColumns();


            this.Cursor = Cursors.Default;


        }
Esempio n. 5
0
        private void initControl()
        {
            this.Cursor = Cursors.WaitCursor;

            this.cboType.SelectedIndex = 0;
            this.cboTypeUsered.SelectedIndex = 0;
            this.dtStartDate.Value = DateTime.Now.AddMonths(-1);
            this.dtUsedStartTime.Value = DateTime.Now.AddMonths(-1);

            ArrayList attentionUseList = new ArrayList();
            ArrayList unAttentionUseList = new ArrayList();

            WechatUser fromWechatUser1 = wechatAction.getAllUserFromWechatByStatus(1, Settings.Default.Wechat_Secret, 1);

            if (fromWechatUser1 != null && fromWechatUser1.userlist != null)
            {
                this.lblAttentionUser.Text = fromWechatUser1.userlist.Count.ToString();

                attentionUseList.Clear();
                foreach (Wechat.User user in fromWechatUser1.userlist)
                {
                    attentionUseList.Add(user.userid);
                }
            }
            WechatUser fromWechatUser2 = wechatAction.getAllUserFromWechatByStatus(1, Settings.Default.Wechat_Secret, 4);
            if (fromWechatUser2 != null && fromWechatUser2.userlist != null)
            {
                this.lblUnAttentionUser.Text = fromWechatUser2.userlist.Count.ToString();

                unAttentionUseList.Clear();
                foreach (Wechat.User user in fromWechatUser2.userlist)
                {
                    unAttentionUseList.Add(user.userid);
                }
            }
            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            IList<AgentWechatAccount> agentWechatAccountList = agentWechatAccountDao.GetListByKeyword("", "");
            if (agentWechatAccountList != null)
            {
                this.lblAllUser.Text = agentWechatAccountList.Count.ToString();
            }

            this.lblUnSyncUser.Text = (int.Parse(this.lblAllUser.Text) - int.Parse(this.lblAttentionUser.Text) - int.Parse(this.lblUnAttentionUser.Text)).ToString();


            dgUser.Columns.Clear();
            dgUser.Columns.Add("联系人编号", "联系人编号");
            dgUser.Columns.Add("联系人姓名", "联系人姓名");
            dgUser.Columns.Add("联系人邮箱", "联系人邮箱");
            dgUser.Columns.Add("联系人电话", "联系人电话");
            dgUser.Columns.Add("联系人微信", "联系人微信");
            dgUser.Columns.Add("关注状态", "关注状态");
            for (int i = 0; i < agentWechatAccountList.Count; i++)
            {
                dgUser.Rows.Add();
                DataGridViewRow row = dgUser.Rows[i];
                int index = 0;
                row.Cells[index++].Value = agentWechatAccountList[i].contactId;
                row.Cells[index++].Value = agentWechatAccountList[i].contactName;
                row.Cells[index++].Value = agentWechatAccountList[i].contactEmail;
                row.Cells[index++].Value = agentWechatAccountList[i].contactTel;
                row.Cells[index++].Value = agentWechatAccountList[i].contactWechat;
                row.Cells[index].Value = "未同步";
                row.Cells[index].Style.BackColor = Color.White;
                if (attentionUseList.Contains(agentWechatAccountList[i].contactId))
                {
                    row.Cells[index].Value = "已关注";
                    row.Cells[index].Style.BackColor = Color.Blue;
                }
                if (unAttentionUseList.Contains(agentWechatAccountList[i].contactId))
                {
                    row.Cells[index].Value = "未关注";
                    row.Cells[index].Style.BackColor = Color.Red;
                }
            }
            dgUser.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;

            dgUser.AutoResizeColumns();

            this.Cursor = Cursors.Default;
        }
Esempio n. 6
0
        /// <summary>
        /// 处理企业号的信息
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {


            logger.Info(context.Request.Url.AbsoluteUri);


            string sToken = "PerformanceHandler";
            string sCorpID = Properties.Settings.Default.Wechat_CorpId;// "wx4fe8b74e01fffcbb";
            string sEncodingAESKey = "U7gOrkwP22ND4bIHSxU0WJqIestRcG2QroykyVKDUSG";

            //  string sToken = Properties.Settings.Default.Wechat_AgentFee_Token;//"AgentFee";
            //  string sCorpID = Properties.Settings.Default.Wechat_CorpId;// "wx31204de5a3ae758e";
            //  string sEncodingAESKey = Properties.Settings.Default.Wechat_AgentFee_EncodingAESKey;// "he8dYrZ5gLbDrDhfHVJkea1AfmHgRZQJq47kuKpQrSO";

            System.Collections.Specialized.NameValueCollection queryStrings = context.Request.QueryString;
            Tencent.WXBizMsgCrypt wxcpt = new Tencent.WXBizMsgCrypt(sToken, sEncodingAESKey, sCorpID);

            context.Request.ContentEncoding = Encoding.UTF8;
            string sReqMsgSig = queryStrings["msg_signature"];
            string sReqTimeStamp = queryStrings["timestamp"];
            string sReqNonce = queryStrings["nonce"];

            // 获取Post请求的密文数据
            StreamReader reader = new StreamReader(context.Request.InputStream, Encoding.GetEncoding("UTF-8"));
            string sReqData = reader.ReadToEnd();
            reader.Close();

            string sMsg = "";  // 解析之后的明文
            int ret = wxcpt.DecryptMsg(sReqMsgSig, sReqTimeStamp, sReqNonce, sReqData, ref sMsg);


            if (ret != 0)
            {
                logger.Info("ERR: Decrypt Fail, ret: " + ret);
                System.Console.WriteLine("ERR: Decrypt Fail, ret: " + ret);
                return;
            }
            // ret==0表示解密成功,sMsg表示解密之后的明文xml串           
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sMsg);
            WechatMessage wechatMessage = new WechatMessage(doc.DocumentElement);

            // 需要发送的明文
            String actionType = wechatMessage.EventKey;

            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<xml>");
            sb.AppendFormat("<ToUserName><![CDATA[{0}]]></ToUserName>", wechatMessage.FromUserName);
            sb.AppendFormat("<FromUserName><![CDATA[{0}]]></FromUserName>", wechatMessage.ToUserName);
            sb.AppendFormat("<CreateTime>{0}</CreateTime>", wechatMessage.CreateTime);

            // string sRespData = "<MsgId>1234567890123456</MsgId>";
            logger.Info("EventKey: " + wechatMessage.EventKey);

            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(wechatMessage.FromUserName);
            if (agentWechatAccount != null && wechatMessage != null && !String.IsNullOrEmpty(wechatMessage.Event) && wechatMessage.Event.Equals("enter_agent"))
            {
                WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                wechatQueryLog.agentName = "";
                wechatQueryLog.module = Util.MyConstant.module_Performance;
                wechatQueryLog.subSystem = "业绩查询";
                wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                wechatQueryLog.queryString = "成员进入应用";
                wechatQueryLog.wechatId = agentWechatAccount.contactId;
                WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                try
                {
                    wechatQueryLogDao.Add(wechatQueryLog);
                }
                catch
                {
                }
            }

            if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
            {
                sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

            }
            else if (agentWechatAccount == null)
            {
                sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
            }
            else
            {
                String agentNo = agentWechatAccount.branchNo;
                if (String.IsNullOrEmpty(agentNo))
                {
                    agentNo = agentWechatAccount.agentNo;
                }
                String agentType = agentWechatAccount.type;

                AgentMonthPerformanceDao agentMonthPerformanceDao = new ChinaUnion_DataAccess.AgentMonthPerformanceDao();
                AgentDailyPerformanceDao agentDailyPerformanceDao = new ChinaUnion_DataAccess.AgentDailyPerformanceDao();
                AgentStarDao agentStarDao = new AgentStarDao();
                IList<AgentStar> agentStarList = null;

                AgentScoreDao agentScoreDao = new AgentScoreDao();
                IList<AgentScore> agentScoreList = null;
                String dateTime = "";

                DateTime dt = DateTime.Now.AddMonths(-3);  //当前时间
                DateTime startQuarter = dt.AddMonths(0 - (dt.Month - 1) % 3).AddDays(1 - dt.Day);  //本季度初
                if (startQuarter.Month >= 1 && startQuarter.Month <= 3)
                {
                    dateTime = startQuarter.Year + "年第一季度";
                }
                if (startQuarter.Month >= 4 && startQuarter.Month <= 6)
                {
                    dateTime = startQuarter.Year + "年第二季度";
                }
                if (startQuarter.Month >= 7 && startQuarter.Month <= 9)
                {
                    dateTime = startQuarter.Year + "年第三季度";
                }
                if (startQuarter.Month >= 10 && startQuarter.Month <= 12)
                {
                    dateTime = startQuarter.Year + "年第四季度";
                }

                logger.Info("agentNo: " + agentNo);
                logger.Info("agentType: " + agentType);
                switch (actionType)
                {

                    case "curQuaterStar":
                    case "HistoryQuaterStar":
                        if (actionType.Equals("curQuaterStar"))
                        {
                            agentStarList = agentStarDao.GetLatestByKeyword(agentNo, dateTime);
                        }
                        if (actionType.Equals("HistoryQuaterStar"))
                        {
                            agentStarList = agentStarDao.GetListByKeyword(agentNo);
                        }

                      if (agentStarList != null && agentStarList.Count > 0)
                        {
                            logger.Info("Exist Record: " + agentStarList.Count);
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");

                            StringBuilder sbContent = new StringBuilder();
                            sbContent.AppendFormat("星级查询详情").Append("\n");
                            for (int i = 0; i < agentStarList.Count;i++ )
                            {
                                AgentStar agentStar = agentStarList[i];
                                sbContent.AppendFormat("\n时间:{0}", agentStar.dateTime).Append("\n");
                               // sbContent.AppendFormat("代理商编号:{0}", agentStar.agentNo).Append("\n");
                                //sbContent.AppendFormat("代理商名称:{0}", agentStar.agentName).Append("\n");
                                if (!String.IsNullOrEmpty(agentStar.branchNo))
                                {
                                    sbContent.AppendFormat("渠道编码:{0}", agentStar.branchNo).Append("\n");
                                    sbContent.AppendFormat("渠道名称:{0}", agentStar.branchName).Append("\n");
                                }
                               
                                sbContent.AppendFormat("星级:{0}", agentStar.star).Append("\n");

                            }
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", sbContent.ToString());
                            // sb.Append(sbContent.ToString());
                            // sb.Append(this.createNewsMessages(feeDate, wechatMessage.FromUserName, agentDailyPerformance));
                        }
                        else
                        {
                            logger.Info("is not Existed Record: ");
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "本期无星级或尚未发布,请耐心等候\n\n");
                        }

                        WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                        wechatQueryLog.agentName = "";
                        wechatQueryLog.module = Util.MyConstant.module_Performance;
                        wechatQueryLog.subSystem = "星级查询";
                        wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        wechatQueryLog.queryString = dateTime;
                        wechatQueryLog.wechatId = agentNo;
                        WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                        try
                        {
                            wechatQueryLogDao.Add(wechatQueryLog);
                        }
                        catch
                        {
                        }

                        break;

                    case "curScore":
                    case "HistoryScore":
                        

                        String month = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
                        if (actionType.Equals("curScore"))
                        {
                            agentScoreList = agentScoreDao.GetLatestByKeyword(agentNo, month);
                        }
                        if (actionType.Equals("HistoryScore"))
                        {
                            agentScoreList = agentScoreDao.GetListByKeyword(agentNo);
                        }

                        if (agentScoreList != null && agentScoreList.Count > 0)
                        {
                            logger.Info("Exist Record: " + agentScoreList.Count);
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");

                            StringBuilder sbContent = new StringBuilder();
                            sbContent.AppendFormat("积分查询详情").Append("\n");
                            for (int i = 0; i < agentScoreList.Count; i++)
                            {
                                AgentScore agentScore = agentScoreList[i];
                                sbContent.AppendFormat("\n时间:{0}", agentScore.dateTime).Append("\n");
                                if (!String.IsNullOrEmpty(agentScore.agentNo))
                                {
                                    sbContent.AppendFormat("代理商编号:{0}", agentScore.agentNo).Append("\n");
                                    sbContent.AppendFormat("代理商名称:{0}", agentScore.agentName).Append("\n");
                                }
                                if (!String.IsNullOrEmpty(agentScore.branchNo))
                                {
                                    sbContent.AppendFormat("渠道编码:{0}", agentScore.branchNo).Append("\n");
                                    sbContent.AppendFormat("渠道名称:{0}", agentScore.branchName).Append("\n");
                                }

                                sbContent.AppendFormat("渠道积分:{0}", agentScore.score).Append("\n");
                                sbContent.AppendFormat("本月得分:{0}", agentScore.standardScore).Append("\n");

                            }
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", sbContent.ToString());
                            // sb.Append(sbContent.ToString());
                            // sb.Append(this.createNewsMessages(feeDate, wechatMessage.FromUserName, agentDailyPerformance));
                        }
                        else
                        {
                            logger.Info("is not Existed Record: ");
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "本期无积分或尚未发布,请耐心等候\n\n");
                        }

                         wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                        wechatQueryLog.agentName = "";
                        wechatQueryLog.module = Util.MyConstant.module_Performance;
                        wechatQueryLog.subSystem = "积分查询";
                        wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        wechatQueryLog.queryString = month;
                        wechatQueryLog.wechatId = agentNo;
                         wechatQueryLogDao = new WechatQueryLogDao();
                         try
                         {
                             wechatQueryLogDao.Add(wechatQueryLog);
                         }
                         catch
                         {
                         }

                        break;

                    case "YesterdayPerformance":
                        String feeDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
                        AgentDailyPerformance agentDailyPerformance = new AgentDailyPerformance();

                        agentDailyPerformance = agentDailyPerformanceDao.GetSummary(agentNo, feeDate,agentType);

                        if (agentDailyPerformance != null)
                        {
                            logger.Info("Exist Record: " + agentNo);
                            sb.Append(this.createNewsMessages(feeDate, agentNo, agentDailyPerformance, agentType));
                        }
                        else
                        {
                            logger.Info("is not Existed Record: ");
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", DateTime.Now.AddDays(-1).ToString("yyyy年MM月dd日") + "无业绩或者业绩尚未发布\n\n");
                        }
                        break;

                    case "HistoryDayPerformance":

                        String date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToString("yyyy-MM-dd"); 

                        IList<AgentDailyPerformance> agentDailyPerformanceList = agentDailyPerformanceDao.GetAllListDate(agentNo, agentType,date);
                        if (agentDailyPerformanceList == null || agentDailyPerformanceList.Count == 0)
                        {
                            logger.Info("is not Existed Record: ");
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "近期无业绩或者业绩尚未发布!\n\n");
                        }
                        else
                        {
                            sb.Append(this.createNewsMessages(agentNo, agentDailyPerformanceList, agentType));
                        }

                        break;


                    case "LastMonthPerformance":
                        // case "YesterdayPerformance":
                        String feeMonth = DateTime.Now.AddMonths(-1).ToString("yyyy-MM");
                        AgentMonthPerformance agentMonthPerformance = new AgentMonthPerformance();

                        agentMonthPerformance = agentMonthPerformanceDao.GetSummary(agentNo, feeMonth, agentType);

                        if (agentMonthPerformance != null)
                        {
                            logger.Info("Exist Record: " + agentMonthPerformance.agentName);
                            sb.Append(this.createNewsMessages(feeMonth, agentNo, agentMonthPerformance, agentType));
                        }
                        else
                        {
                            logger.Info("is not Existed Record: ");
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", feeMonth.Substring(0,4)+"年"+feeMonth.Substring(5,2)+ "月" + "业绩尚未发布,请耐心等待!\n\n");
                        }
                        break;

                    case "HistoryMonthPerformance":

                        IList<AgentMonthPerformance> agentMonthPerformanceList = agentMonthPerformanceDao.GetAllListMonth(agentNo,agentType);
                        if (agentMonthPerformanceList == null || agentMonthPerformanceList.Count == 0)
                        {
                            logger.Info("is not Existed Record: ");
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "近期业绩尚未发布,请耐心等待!\n\n");
                        }
                        else
                        {
                            sb.Append(this.createNewsMessages(agentNo, agentMonthPerformanceList, agentType));
                        }

                        break;

                }
            }

            //  sb.AppendFormat("<AgentID>{0}</AgentID>", textMessage.AgentID);

            sb.AppendFormat("</xml>");
            string sRespData = sb.ToString();
            string sEncryptMsg = ""; //xml格式的密文
            ret = wxcpt.EncryptMsg(sRespData, sReqTimeStamp, sReqNonce, ref sEncryptMsg);
            logger.Info("sRespData=" + sRespData);
            logger.Info("ret=" + ret);
            if (ret != 0)
            {
                System.Console.WriteLine("ERR: EncryptMsg Fail, ret: " + ret);


                return;
            }

            context.Response.Write(sEncryptMsg);


        }
Esempio n. 7
0
        private void initControl()
        {
            this.Cursor = Cursors.WaitCursor;
            this.btnSave.Enabled = false;
            this.btnDelete.Enabled = false;
            this.txtGroupName.Enabled = true;
            //this.btnClear.Enabled = true;
            this.txtGroupName.Clear();
            this.txtDescription.Clear();
            AgentTypeDao agentTypeDao = new AgentTypeDao();
            agentTypeList = agentTypeDao.GetDistinctType();
            this.lstAgentType.Items.Clear();
            this.lstAllType.Items.Clear();
            this.lstAssignType.Items.Clear();
          //  this.lstAgentType.Items.Add("所有渠道");
            foreach (AgentType agentType in agentTypeList)
            {
                this.lstAgentType.Items.Add(agentType.agentType);

                this.lstAllType.Items.Add(agentType.agentType);
            }


            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
             agentWechatAccountList = agentWechatAccountDao.GetAllAgentOrBranch();
            this.lstUser.Items.Clear();
            lstAllAgent.Items.Clear();
            lstAssignAgent.Items.Clear();
            //  this.lstAgentType.Items.Add("所有渠道");
            ArrayList list = new ArrayList();
            foreach (AgentWechatAccount agentWechatAccount in agentWechatAccountList)
            {
                if (!String.IsNullOrEmpty(agentWechatAccount.regionName))
                {
                    if (!list.Contains(agentWechatAccount.branchNo))
                    {
                        this.lstUser.Items.Add(agentWechatAccount.branchNo + ":" + agentWechatAccount.branchName);
                        this.lstAllAgent.Items.Add(agentWechatAccount.branchNo + ":" + agentWechatAccount.branchName);
                        list.Add(agentWechatAccount.branchNo);
                    }
                }
                else
                {
                    if (!String.IsNullOrEmpty(agentWechatAccount.branchNo))
                    {
                        if (!list.Contains(agentWechatAccount.branchNo))
                        {
                            this.lstUser.Items.Add(agentWechatAccount.branchNo + ":" + agentWechatAccount.branchName);
                            this.lstAllAgent.Items.Add(agentWechatAccount.branchNo + ":" + agentWechatAccount.branchName);
                            list.Add(agentWechatAccount.branchNo);
                        }
                    }
                    else
                    {
                        if (!list.Contains(agentWechatAccount.agentNo))
                        {
                            this.lstUser.Items.Add(agentWechatAccount.agentNo + ":" + agentWechatAccount.agentName);
                            this.lstAllAgent.Items.Add(agentWechatAccount.agentNo + ":" + agentWechatAccount.agentName);
                            list.Add(agentWechatAccount.agentNo);
                        }
                    }
                }
            }

            this.Cursor = Cursors.Default;
        }
Esempio n. 8
0
        /// <summary>
        /// 处理企业号的信息
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {


            logger.Info(context.Request.Url.AbsoluteUri);


            string sToken = "ContactUsHandler";
            string sCorpID = Properties.Settings.Default.Wechat_CorpId;// "wx4fe8b74e01fffcbb";
            string sEncodingAESKey = "Mh5NDLXhiRMu1GHitnufvEZKBdSh6c1zvOZbpdUOT2T";

            //  string sToken = Properties.Settings.Default.Wechat_AgentFee_Token;//"AgentFee";
            //  string sCorpID = Properties.Settings.Default.Wechat_CorpId;// "wx31204de5a3ae758e";
            //  string sEncodingAESKey = Properties.Settings.Default.Wechat_AgentFee_EncodingAESKey;// "he8dYrZ5gLbDrDhfHVJkea1AfmHgRZQJq47kuKpQrSO";

            System.Collections.Specialized.NameValueCollection queryStrings = context.Request.QueryString;
            Tencent.WXBizMsgCrypt wxcpt = new Tencent.WXBizMsgCrypt(sToken, sEncodingAESKey, sCorpID);

            context.Request.ContentEncoding = Encoding.UTF8;
            string sReqMsgSig = queryStrings["msg_signature"];
            string sReqTimeStamp = queryStrings["timestamp"];
            string sReqNonce = queryStrings["nonce"];

            // 获取Post请求的密文数据
            StreamReader reader = new StreamReader(context.Request.InputStream, Encoding.GetEncoding("UTF-8"));
            string sReqData = reader.ReadToEnd();
            reader.Close();

            string sMsg = "";  // 解析之后的明文
            int ret = wxcpt.DecryptMsg(sReqMsgSig, sReqTimeStamp, sReqNonce, sReqData, ref sMsg);


            if (ret != 0)
            {
                logger.Info("ERR: Decrypt Fail, ret: " + ret);
                System.Console.WriteLine("ERR: Decrypt Fail, ret: " + ret);
                return;
            }
            // ret==0表示解密成功,sMsg表示解密之后的明文xml串           
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sMsg);
            WechatMessage wechatMessage = new WechatMessage(doc.DocumentElement);
            

            // 需要发送的明文
            String actionType = wechatMessage.EventKey;

            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<xml>");
            sb.AppendFormat("<ToUserName><![CDATA[{0}]]></ToUserName>", wechatMessage.FromUserName);
            sb.AppendFormat("<FromUserName><![CDATA[{0}]]></FromUserName>", wechatMessage.ToUserName);
            sb.AppendFormat("<CreateTime>{0}</CreateTime>", wechatMessage.CreateTime);

            // string sRespData = "<MsgId>1234567890123456</MsgId>";
            logger.Info("EventKey: " + wechatMessage.EventKey);

            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(wechatMessage.FromUserName);

            if (agentWechatAccount != null && wechatMessage != null && !String.IsNullOrEmpty(wechatMessage.Event) && wechatMessage.Event.Equals("enter_agent"))
            {
                WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                wechatQueryLog.agentName = "";
                wechatQueryLog.module = Util.MyConstant.module_Contact;
                wechatQueryLog.subSystem = "联系人查询";
                wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                wechatQueryLog.queryString = "成员进入应用";
                wechatQueryLog.wechatId = agentWechatAccount.contactId;
                WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                try
                {
                    wechatQueryLogDao.Add(wechatQueryLog);
                }
                catch
                {
                }
            }

            if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
            {
                sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

            }
            else if (agentWechatAccount == null)
            {
                sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
            }
            else
            {
                String agentNo = agentWechatAccount.branchNo;
                if (String.IsNullOrEmpty(agentNo))
                {
                    agentNo = agentWechatAccount.agentNo;
                }
                AgentContactDao agentContactDao = new ChinaUnion_DataAccess.AgentContactDao();

                switch (actionType)
                {
                    case "CommonPhone":
                        sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        StringBuilder sbContent1 = new StringBuilder();

                        sbContent1.AppendFormat("1、支撑服务热线:4006186802").AppendLine();
                        sbContent1.AppendFormat("2、服务监督电话:61587555").AppendLine();
                        sbContent1.AppendFormat("3、IT服务热线:\n    18502143773\n    18502143774");
                        sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", sbContent1.ToString());


                        break;
                    case "ContactPerson":

                        //AgentContact agentContact = new AgentContact();

                        IList<AgentContact> agentContactList = agentContactDao.GetListByNo(agentNo);

                        if (agentContactList != null && agentContactList.Count > 0)
                        {



                            logger.Info("Exist Record: " + agentContactList.Count);
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");

                            StringBuilder sbContent = new StringBuilder();
                            for (int i = 0; i < agentContactList.Count; i++)
                            {
                                AgentContact agentContact = agentContactList[i];
                                if (agentContactList.Count > 1)
                                {
                                    sbContent.AppendFormat("第{0}联系人\n\n", i + 1);
                                }
                                if (!String.IsNullOrEmpty(agentContact.agentNo))
                                {
                                    sbContent.AppendFormat("代理商编号:{0}", agentContact.agentNo).Append("\n");
                                    sbContent.AppendFormat("代理商名称:{0}", agentContact.agentName).Append("\n");
                                }
                                if (!String.IsNullOrEmpty(agentContact.branchNo))
                                {
                                    sbContent.AppendFormat("渠道编码:{0}", agentContact.branchNo).Append("\n");
                                    sbContent.AppendFormat("渠道名称:{0}", agentContact.branchName).Append("\n");
                                }
                                sbContent.AppendFormat("所属区县:{0}", agentContact.area).Append("\n");
                                sbContent.AppendFormat("所属网格:{0}", agentContact.zone).Append("\n");
                                sbContent.AppendFormat("联系人:{0}", agentContact.contactName).Append("\n");
                                sbContent.AppendFormat("电话:{0}", agentContact.contactTel).Append("\n");
                                sbContent.AppendFormat("邮箱:{0}", agentContact.contactEmail).Append("\n").AppendLine();

                            }
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", sbContent.ToString());
                            // sb.Append(sbContent.ToString());
                            // sb.Append(this.createNewsMessages(feeDate, wechatMessage.FromUserName, agentDailyPerformance));
                        }
                        else
                        {
                            logger.Info("is not Existed Record: ");
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "没有找到对应的联系人,请直接与上海联通确认!\n\n");
                        }
                        break;



                }
            }

            //  sb.AppendFormat("<AgentID>{0}</AgentID>", textMessage.AgentID);

            sb.AppendFormat("</xml>");
            string sRespData = sb.ToString();
            string sEncryptMsg = ""; //xml格式的密文
            ret = wxcpt.EncryptMsg(sRespData, sReqTimeStamp, sReqNonce, ref sEncryptMsg);
            logger.Info("ret=" + ret);
            if (ret != 0)
            {
                System.Console.WriteLine("ERR: EncryptMsg Fail, ret: " + ret);


                return;
            }

            context.Response.Write(sEncryptMsg);


        }
        /// <summary>
        /// 处理企业号的信息
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {


            logger.Info(context.Request.Url.AbsoluteUri);


            string sToken = "ServiceComplainHandler";
            string sCorpID = Properties.Settings.Default.Wechat_CorpId;// "wx4fe8b74e01fffcbb";
            string sEncodingAESKey = "1cKOgDDDPDBp2yveG55gootenlqivqTcX2K0wz804x5";

            //  string sToken = Properties.Settings.Default.Wechat_AgentFee_Token;//"AgentFee";
            //  string sCorpID = Properties.Settings.Default.Wechat_CorpId;// "wx31204de5a3ae758e";
            //  string sEncodingAESKey = Properties.Settings.Default.Wechat_AgentFee_EncodingAESKey;// "he8dYrZ5gLbDrDhfHVJkea1AfmHgRZQJq47kuKpQrSO";

            System.Collections.Specialized.NameValueCollection queryStrings = context.Request.QueryString;
            Tencent.WXBizMsgCrypt wxcpt = new Tencent.WXBizMsgCrypt(sToken, sEncodingAESKey, sCorpID);

            context.Request.ContentEncoding = Encoding.UTF8;
            string sReqMsgSig = queryStrings["msg_signature"];
            string sReqTimeStamp = queryStrings["timestamp"];
            string sReqNonce = queryStrings["nonce"];

            // 获取Post请求的密文数据
            StreamReader reader = new StreamReader(context.Request.InputStream, Encoding.GetEncoding("UTF-8"));
            string sReqData = reader.ReadToEnd();
            reader.Close();

            string sMsg = "";  // 解析之后的明文
            int ret = wxcpt.DecryptMsg(sReqMsgSig, sReqTimeStamp, sReqNonce, sReqData, ref sMsg);


            if (ret != 0)
            {
                logger.Info("ERR: Decrypt Fail, ret: " + ret);
                System.Console.WriteLine("ERR: Decrypt Fail, ret: " + ret);
                return;
            }
            // ret==0表示解密成功,sMsg表示解密之后的明文xml串           
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sMsg);
            WechatMessage wechatMessage = new WechatMessage(doc.DocumentElement);


            // 需要发送的明文
            String actionType = wechatMessage.EventKey;

            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<xml>");
            sb.AppendFormat("<ToUserName><![CDATA[{0}]]></ToUserName>", wechatMessage.FromUserName);
            sb.AppendFormat("<FromUserName><![CDATA[{0}]]></FromUserName>", wechatMessage.ToUserName);
            sb.AppendFormat("<CreateTime>{0}</CreateTime>", wechatMessage.CreateTime);

            // string sRespData = "<MsgId>1234567890123456</MsgId>";
            logger.Info("EventKey: " + wechatMessage.EventKey);

            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(wechatMessage.FromUserName);

            if (agentWechatAccount != null && wechatMessage != null && !String.IsNullOrEmpty(wechatMessage.Event) && wechatMessage.Event.Equals("enter_agent"))
            {
                WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                wechatQueryLog.agentName = "";
                wechatQueryLog.module = Util.MyConstant.module_Complain;
                wechatQueryLog.subSystem = "投诉协查";
                wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                wechatQueryLog.queryString = "成员进入应用";
                wechatQueryLog.wechatId = agentWechatAccount.contactId;
                WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                try
                {
                    wechatQueryLogDao.Add(wechatQueryLog);
                }
                catch
                {
                }
            }

            if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
            {
                sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

            }
            else if (agentWechatAccount == null)
            {
                sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
            }
            else
            {
                String agentNo = agentWechatAccount.branchNo;
                if (String.IsNullOrEmpty(agentNo))
                {
                    agentNo = agentWechatAccount.agentNo;
                }
                AgentContactDao agentContactDao = new ChinaUnion_DataAccess.AgentContactDao();

                switch (actionType)
                {
                    case "ContactPerson":
                        logger.Info("is not Existed Record: ");
                        sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "没有找到对应的联系人,请直接与上海联通确认!\n\n");

                        break;



                }
            }

            //  sb.AppendFormat("<AgentID>{0}</AgentID>", textMessage.AgentID);

            sb.AppendFormat("</xml>");
            string sRespData = sb.ToString();
            string sEncryptMsg = ""; //xml格式的密文
            ret = wxcpt.EncryptMsg(sRespData, sReqTimeStamp, sReqNonce, ref sEncryptMsg);
            logger.Info("ret=" + ret);
            if (ret != 0)
            {
                System.Console.WriteLine("ERR: EncryptMsg Fail, ret: " + ret);


                return;
            }

            context.Response.Write(sEncryptMsg);
        }
Esempio n. 10
0
        private void prepareGrid(string keyword, String type,bool isUnsync)
        {
            this.Cursor = Cursors.WaitCursor;
            if (type.Equals("全部"))
            {
                type = "";
            }
            WechatAction  wechatAction = new WechatAction();
            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();

            IList<AgentWechatAccount> agentWechatAccountList = new List<AgentWechatAccount>();
            agentWechatAccountList = agentWechatAccountDao.GetListByKeyword(keyword,type);
            this.grpWechatList.Text = "";
            dgAgentWechatAccount.Rows.Clear();

            if (agentWechatAccountList != null && agentWechatAccountList.Count > 0)
            {
                this.grpWechatList.Text = "微信用户列表(" + agentWechatAccountList.Count + ")";
                dgAgentWechatAccount.Rows.Clear();
                dgAgentWechatAccount.Columns.Clear();

                dgAgentWechatAccount.Columns.Add("类型", "类型");

                dgAgentWechatAccount.Columns.Add("代理商编号", "代理商编号");
                dgAgentWechatAccount.Columns.Add("代理商名称", "代理商名称");                
                dgAgentWechatAccount.Columns.Add("渠道编码", "渠道编码");
                dgAgentWechatAccount.Columns.Add("渠道名称", "渠道名称");
                dgAgentWechatAccount.Columns.Add("区县", "区县");
               
                dgAgentWechatAccount.Columns["渠道编码"].Visible = false;
                dgAgentWechatAccount.Columns["渠道名称"].Visible = false;
                dgAgentWechatAccount.Columns["区县"].Visible = false;
                if (!type.Equals("代理商联系人"))
                {
                    if (String.IsNullOrEmpty(type) || type.Equals("直供渠道联系人"))
                    {
                        dgAgentWechatAccount.Columns["区县"].Visible = true;

                    }
                    dgAgentWechatAccount.Columns["渠道编码"].Visible = true;
                    dgAgentWechatAccount.Columns["渠道名称"].Visible = true;

                }
                dgAgentWechatAccount.Columns.Add("联系人编号", "联系人编号");
                dgAgentWechatAccount.Columns.Add("联系人姓名", "联系人姓名");
                dgAgentWechatAccount.Columns.Add("联系人邮箱", "联系人邮箱");
                dgAgentWechatAccount.Columns.Add("联系人电话", "联系人电话");
                dgAgentWechatAccount.Columns.Add("联系人微信", "联系人微信");
                //dgAgent.Columns.Add("账号禁用", "账号禁用");
                dgAgentWechatAccount.Columns.Add("是否关注", "是否关注");
                dgAgentWechatAccount.Columns.Add("佣金结算与支付查询", "佣金结算与支付查询");
                dgAgentWechatAccount.Columns.Add("业务政策", "业务政策");
                dgAgentWechatAccount.Columns.Add("业绩查询", "业绩查询");
                dgAgentWechatAccount.Columns.Add("在线学习", "在线学习");
                dgAgentWechatAccount.Columns.Add("投诉协查", "投诉协查");
                dgAgentWechatAccount.Columns.Add("服务监督", "服务监督");
                dgAgentWechatAccount.Columns.Add("报错处理", "报错处理");
                dgAgentWechatAccount.Columns.Add("企业小助手", "企业小助手");

                for (int i = 0; i < agentWechatAccountList.Count; i++)
                {
                    Color curColor = Color.Blue;
                    String rowVlaue = "未同步";
                    HttpResult result = wechatAction.getUserFromWechat(agentWechatAccountList[i].contactId, Settings.Default.Wechat_Secret);
                    if (result.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        //表示访问成功,具体的大家就参考HttpStatusCode类
                        try
                        {
                            WechatJsonUser wechatJsonUser = JsonConvert.DeserializeObject<WechatJsonUser>(result.Html);


                            if (wechatJsonUser.status == "1")
                            {
                                curColor = Color.White;

                                rowVlaue = "已关注";
                            }
                            if (wechatJsonUser.status == "2")
                            {
                                curColor = Color.Yellow;
                                rowVlaue = "已冻结";
                            }
                            if (wechatJsonUser.status == "4")
                            {
                                curColor = Color.Red;
                                rowVlaue = "未关注";
                            }
                        }
                        catch (Exception ex)
                        {
                            //row.Cells[index].Value = "";
                            String exr = ex.Message;
                        }

                    }
                    if (!rowVlaue.Equals("未同步") && isUnsync)
                    {
                        continue;
                    }
                    dgAgentWechatAccount.Rows.Add();
                    DataGridViewRow row = dgAgentWechatAccount.Rows[dgAgentWechatAccount.RowCount-1];
                    int index = 0;
                    row.Cells[index++].Value = agentWechatAccountList[i].type;
                    row.Cells[index++].Value = agentWechatAccountList[i].agentNo;
                    row.Cells[index++].Value = agentWechatAccountList[i].agentName;



                    row.Cells[index++].Value = agentWechatAccountList[i].branchNo;
                    row.Cells[index++].Value = agentWechatAccountList[i].branchName;
                    row.Cells[index++].Value = agentWechatAccountList[i].regionName;

                    row.Cells[index++].Value = agentWechatAccountList[i].contactId;
                    row.Cells[index++].Value = agentWechatAccountList[i].contactName;
                    row.Cells[index++].Value = agentWechatAccountList[i].contactEmail;
                    row.Cells[index++].Value = agentWechatAccountList[i].contactTel;
                    row.Cells[index++].Value = agentWechatAccountList[i].contactWechat;

                    //if (!String.IsNullOrEmpty(agentWechatAccountList[i].status) && agentWechatAccountList[i].status.ToUpper().Equals("Y"))
                    //{
                    //    row.Cells[5].Value = "账号已经停用";
                    //}
                    //else
                    //{
                    //    row.Cells[5].Value = "";
                    //}
                    row.Cells[index].Value = rowVlaue;
                    row.Cells[index].Style.BackColor = curColor;


                    index++;
                    row.Cells[index++].Value = agentWechatAccountList[i].feeRight;
                    row.Cells[index++].Value = agentWechatAccountList[i].policyRight;
                    row.Cells[index++].Value = agentWechatAccountList[i].performanceRight;
                    row.Cells[index++].Value = agentWechatAccountList[i].studyRight;
                    row.Cells[index++].Value = agentWechatAccountList[i].complainRight;
                    row.Cells[index++].Value = agentWechatAccountList[i].monitorRight;
                    row.Cells[index++].Value = agentWechatAccountList[i].errorRight;
                    row.Cells[index++].Value = agentWechatAccountList[i].contactRight;

                }
                dgAgentWechatAccount.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;
                dgAgentWechatAccount.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;

                dgAgentWechatAccount.AutoResizeColumns();

            }


            this.Cursor = Cursors.Default;

        }
Esempio n. 11
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dgAgentWechatAccount.CurrentRow==null)
            {
                MessageBox.Show("请选择一行记录"); 
                return;
            }

            String userId= this.dgAgentWechatAccount.CurrentRow.Cells[6].Value.ToString();
            if (!String.IsNullOrEmpty(userId))
            {
                WechatAction wechatAction = new Wechat.WechatAction();
                HttpResult result = wechatAction.deleteUserFromWechat(userId, Settings.Default.Wechat_Secret);
                if (result.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
                    agentWechatAccountDao.Delete(userId);

                    this.prepareGrid(this.txtKeyword.Text.Trim(), this.cboType.Text.Trim(),this.checkUnsync.Checked);
                }
            }
        }
        /// <summary>
        /// 处理企业号的信息
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {


            logger.Info(context.Request.Url.AbsoluteUri);


            string sToken = "BusinessPolicyHandler";
            string sCorpID = Properties.Settings.Default.Wechat_CorpId;// "wx4fe8b74e01fffcbb";
            string sEncodingAESKey = "3jJb1Xr7z6fF7LJPCESk8wX8XFf8E6mK4MYIbiOY8yt";// "omiSDTqK4GjKmsQ6eCJSWpOtmqPcz6A3B41RBcg6Ey9";

            //  string sToken = Properties.Settings.Default.Wechat_AgentFee_Token;//"AgentFee";
            //  string sCorpID = Properties.Settings.Default.Wechat_CorpId;// "wx31204de5a3ae758e";
            //  string sEncodingAESKey = Properties.Settings.Default.Wechat_AgentFee_EncodingAESKey;// "he8dYrZ5gLbDrDhfHVJkea1AfmHgRZQJq47kuKpQrSO";

            System.Collections.Specialized.NameValueCollection queryStrings = context.Request.QueryString;
            Tencent.WXBizMsgCrypt wxcpt = new Tencent.WXBizMsgCrypt(sToken, sEncodingAESKey, sCorpID);

            context.Request.ContentEncoding = Encoding.UTF8;
            string sReqMsgSig = queryStrings["msg_signature"];
            string sReqTimeStamp = queryStrings["timestamp"];
            string sReqNonce = queryStrings["nonce"];

            // 获取Post请求的密文数据
            StreamReader reader = new StreamReader(context.Request.InputStream, Encoding.GetEncoding("UTF-8"));
            string sReqData = reader.ReadToEnd();
            reader.Close();

            string sMsg = "";  // 解析之后的明文
            int ret = wxcpt.DecryptMsg(sReqMsgSig, sReqTimeStamp, sReqNonce, sReqData, ref sMsg);


            if (ret != 0)
            {
                logger.Info("ERR: Decrypt Fail, ret: " + ret);
                System.Console.WriteLine("ERR: Decrypt Fail, ret: " + ret);
                return;
            }
            // ret==0表示解密成功,sMsg表示解密之后的明文xml串           
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sMsg);
            WechatMessage wechatMessage = new WechatMessage(doc.DocumentElement);

            // 需要发送的明文
            String actionType = wechatMessage.EventKey;

            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<xml>");
            sb.AppendFormat("<ToUserName><![CDATA[{0}]]></ToUserName>", wechatMessage.FromUserName);
            sb.AppendFormat("<FromUserName><![CDATA[{0}]]></FromUserName>", wechatMessage.ToUserName);
            sb.AppendFormat("<CreateTime>{0}</CreateTime>", wechatMessage.CreateTime);

            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(wechatMessage.FromUserName);

            if (agentWechatAccount != null && wechatMessage != null && !String.IsNullOrEmpty(wechatMessage.Event) && wechatMessage.Event.Equals("enter_agent"))
            {
                WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                wechatQueryLog.agentName = "";
                wechatQueryLog.module = Util.MyConstant.module_Notice;
                wechatQueryLog.subSystem = "通知公告与促销政策";
                wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                wechatQueryLog.queryString = "成员进入应用";
                wechatQueryLog.wechatId = agentWechatAccount.contactId;
                WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                try
                {
                    wechatQueryLogDao.Add(wechatQueryLog);
                }
                catch
                {
                }
            }

            // string sRespData = "<MsgId>1234567890123456</MsgId>";
            logger.Info("EventKey: " + wechatMessage.EventKey);
            String agentNo = wechatMessage.FromUserName;
            AgentDao agentDao = new AgentDao();
            Agent agent = agentDao.Get(agentNo);

            if (agent != null && !String.IsNullOrEmpty(agent.status) && agent.status.Equals("Y"))
            {
                sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

            }
            else
            {

                PolicyDao policyDao = new ChinaUnion_DataAccess.PolicyDao();

                switch (actionType)
                {

                    case "LatestPolicy":

                    case "HistoryPolicy":
                    case "LatestNotice":                  

                    case "HistoryNotice":
                         IList<Policy> policyList =null;
                         if (actionType.Equals("LatestNotice"))
                         {
                             policyList = policyDao.GetAllList("");
                         }
                         else
                         {
                             policyList = policyDao.GetAllList("");
                         }






                         if (policyList != null && policyList.Count > 0)
                        {
                            sb.Append(this.createNewsMessages(wechatMessage.FromUserName, policyList));
                        }
                        else
                        {
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "没有公告发布!\n\n");
                        }
                        break;


                    default:

                        break;
                }
            }
            //  sb.AppendFormat("<AgentID>{0}</AgentID>", textMessage.AgentID);

            sb.AppendFormat("</xml>");
            string sRespData = sb.ToString();
            string sEncryptMsg = ""; //xml格式的密文
            ret = wxcpt.EncryptMsg(sRespData, sReqTimeStamp, sReqNonce, ref sEncryptMsg);
            logger.Info("ret=" + ret);
            if (ret != 0)
            {
                System.Console.WriteLine("ERR: EncryptMsg Fail, ret: " + ret);


                return;
            }

            context.Response.Write(sEncryptMsg);


        }
Esempio n. 13
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            //代理商信息            
         //   Queryworker.ReportProgress(1, "代理商信息...\r\n");
           
           // Queryworker.ReportProgress(2, "代理商渠道类型...\r\n");
            //代理商渠道类型
            AgentTypeDao agentTypeDao = new AgentTypeDao();
            IList<AgentType> agentTypeList = agentTypeDao.GetList(dtFeeMonth.Value.ToString("yyyy-MM"));
            dgAgentType.Rows.Clear();
            dgAgentType.Columns.Clear();
            if (agentTypeList != null && agentTypeList.Count > 0)
            {
               
                dgAgentType.Columns.Add("代理商编号", "代理商编号");
                dgAgentType.Columns.Add("渠道类型", "渠道类型");


                for (int i = 0; i < agentTypeList.Count; i++)
                {
                    dgAgentType.Rows.Add();
                    DataGridViewRow row = dgAgentType.Rows[i];
                    row.Cells[0].Value = agentTypeList[i].agentNo;
                    row.Cells[1].Value = agentTypeList[i].agentType;

                }
            }
          //  Queryworker.ReportProgress(3, "代理商渠道类型说明...\r\n");
            //代理商渠道类型说明
            AgentTypeCommentDao agentTypeCommentDao = new AgentTypeCommentDao();
            IList<AgentTypeComment> agentTypeCommentList = agentTypeCommentDao.GetList(dtFeeMonth.Value.ToString("yyyy-MM"));
            dgAgentTypeComment.Rows.Clear();
            dgAgentTypeComment.Columns.Clear();
            if (agentTypeCommentList != null && agentTypeCommentList.Count > 0)
            {
               

                dgAgentTypeComment.Columns.Add("渠道类型", "渠道类型");
                dgAgentTypeComment.Columns.Add("佣金说明", "佣金说明");




                for (int i = 0; i < agentTypeCommentList.Count; i++)
                {
                    dgAgentTypeComment.Rows.Add();
                    DataGridViewRow row = dgAgentTypeComment.Rows[i];
                    row.Cells[0].Value = agentTypeCommentList[i].agentType;
                    row.Cells[1].Value = agentTypeCommentList[i].agentTypeComment;

                }
            }

           // Queryworker.ReportProgress(4, "代理商佣金...\r\n");
            //代理商佣金
            AgentFeeDao agentFeeDao = new AgentFeeDao();
            IList<AgentFee> agentFeeList = agentFeeDao.GetList(dtFeeMonth.Value.ToString("yyyy-MM"));

            AgentWechatAccount agentWechatAccount = new ChinaUnion_BO.AgentWechatAccount();
            AgentWechatAccountDao agentWechatAccountDao = new ChinaUnion_DataAccess.AgentWechatAccountDao();
            
            dgAgentFee.Rows.Clear();
            dgAgentFee.Columns.Clear();
            if (agentFeeList != null && agentFeeList.Count > 0)
            {
                this.grpAgentFee.Text = "月度佣金明细信息(" + agentFeeList.Count + ")";
                dgAgentFee.Columns.Add("代理商编号", "代理商编号");
                dgAgentFee.Columns.Add("代理商名称", "代理商名称");
                dgAgentFee.Columns.Add("代理商类型", "代理商类型");
                dgAgentFee.Columns.Add("代理商类型说明", "代理商类型说明");
                dgAgentFee.Columns.Add("联系人邮件", "联系人邮件");
                dgAgentFee.Columns.Add("联系人名称", "联系人名称");
                dgAgentFee.Columns.Add("告知单编号", "告知单编号");
             //   dgAgentFee.Columns["联系人邮件"].Visible = false;
              //  dgAgentFee.Columns["联系人名称"].Visible = false;
                for (int i = 0; i < agentFeeList.Count; i++)
                {
                    if (i == 0)
                    {
                        for (int j = 1; j <= 100; j++)
                        {
                            FieldInfo feeNameField = agentFeeList[i].GetType().GetField("feeName" + j);
                           // FieldInfo feeField = agentFeeList[i].GetType().GetField("fee" + j);

                            String feeNameFieldValue = feeNameField.GetValue(agentFeeList[i]) == null ? null : feeNameField.GetValue(agentFeeList[i]).ToString();
                           // String feeFieldValue = feeField.GetValue(agentFeeList[i]) == null ? null : feeField.GetValue(agentFeeList[i]).ToString(); ;

                            if (!String.IsNullOrEmpty(feeNameFieldValue) && !String.IsNullOrWhiteSpace(feeNameFieldValue))
                            {
                                dgAgentFee.Columns.Add(feeNameFieldValue, feeNameFieldValue);
                            }
                        }
                       

                        this.dgAgentFee.Columns.Add("总计", "总计");
                        this.dgAgentFee.Columns.Add("开票金额", "开票金额");
                        this.dgAgentFee.Columns.Add("过网开票金额", "过网开票金额");

                    }


                    dgAgentFee.Rows.Add();
                    DataGridViewRow row = dgAgentFee.Rows[i];

                    row.Cells[0].Value = agentFeeList[i].agentNo;
                    row.Cells[1].Value = agentFeeList[i].agent.agentName;
                    row.Cells[2].Value = agentFeeList[i].agent.agentType;
                    row.Cells[3].Value = agentFeeList[i].agent.agentTypeComment;
                    agentWechatAccount = agentWechatAccountDao.GetByAgentNo(agentFeeList[i].agentNo);
                    if (agentWechatAccount != null)
                    {
                        agentFeeList[i].agent.contactEmail = agentWechatAccount.contactEmail;
                        agentFeeList[i].agent.contactName = agentWechatAccount.contactName;
                    }
                    row.Cells[4].Value = agentFeeList[i].agent.contactEmail;
                    row.Cells[5].Value = agentFeeList[i].agent.contactName;
                    row.Cells[6].Value = agentFeeList[i].agentFeeSeq;

                    int feeColIndex = 6;
                    int fixColCount = 7;

                    for (int j = 1; j <= 100 ; j++)
                    {
                       // FieldInfo feeNameField = agentFeeList[i].GetType().GetField("feeName" + j);
                        FieldInfo feeField = agentFeeList[i].GetType().GetField("fee" + j);

                      //  String feeNameFieldValue = feeNameField.GetValue(agentFeeList[i]) == null ? null : feeNameField.GetValue(agentFeeList[i]).ToString();
                        String feeFieldValue = feeField.GetValue(agentFeeList[i]) == null ? null : feeField.GetValue(agentFeeList[i]).ToString(); ;

                        if (dgAgentFee.Columns.Count >= fixColCount + j)
                        {
                            row.Cells[feeColIndex + j].Value = feeFieldValue;
                        }
                    }
                  

                    row.Cells[dgAgentFee.Columns.Count - 3].Value = agentFeeList[i].feeTotal;
                    row.Cells[dgAgentFee.Columns.Count - 2].Value = agentFeeList[i].invoiceFee;
                    row.Cells[dgAgentFee.Columns.Count - 1].Value = agentFeeList[i].preInvoiceFee;

                }
            }
            this.dgAgentType.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
            dgAgentType.AutoResizeColumns();
            this.dgAgentTypeComment.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
            dgAgentTypeComment.AutoResizeColumns();
            //this.dgAgent.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
            //dgAgent.AutoResizeColumns();
            if (dgAgentFee.RowCount > 0)
            {
                this.btnMail.Visible = true;
            }
            else
            {
                this.btnMail.Visible = false;
            }

            this.Cursor = Cursors.Default;     
           

        }
        /// <summary>
        /// 处理企业号的信息
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {


            logger.Info(context.Request.Url.AbsoluteUri);


            // string sToken = "AgentFee";
            // string sCorpID = "wx4fe8b74e01fffcbb";
            // string sEncodingAESKey = "gvGJnhpjeljcKzvfe8B8vnmMBBLkJFuzUYSjsGcDQFE";

            string sToken ="AgentFeeAndInvoicePaymentHandler";//"AgentFee";
            string sCorpID = Properties.Settings.Default.Wechat_CorpId;// "wx31204de5a3ae758e";
            string sEncodingAESKey = "4m6avCYhQ2p4IwjtMpFWNHRd46k2uIgdLbHSAlyCQsJ";// "he8dYrZ5gLbDrDhfHVJkea1AfmHgRZQJq47kuKpQrSO";

            System.Collections.Specialized.NameValueCollection queryStrings = context.Request.QueryString;
            Tencent.WXBizMsgCrypt wxcpt = new Tencent.WXBizMsgCrypt(sToken, sEncodingAESKey, sCorpID);

            context.Request.ContentEncoding = Encoding.UTF8;
            string sReqMsgSig = queryStrings["msg_signature"];
            string sReqTimeStamp = queryStrings["timestamp"];
            string sReqNonce = queryStrings["nonce"];

            // 获取Post请求的密文数据
            StreamReader reader = new StreamReader(context.Request.InputStream, Encoding.GetEncoding("UTF-8"));
            string sReqData = reader.ReadToEnd();
            reader.Close();

            string sMsg = "";  // 解析之后的明文
            int ret = wxcpt.DecryptMsg(sReqMsgSig, sReqTimeStamp, sReqNonce, sReqData, ref sMsg);


            if (ret != 0)
            {
                logger.Info("ERR: Decrypt Fail, ret: " + ret);
                System.Console.WriteLine("ERR: Decrypt Fail, ret: " + ret);
                return;
            }
            // ret==0表示解密成功,sMsg表示解密之后的明文xml串           
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sMsg);
            WechatMessage wechatMessage = new WechatMessage(doc.DocumentElement);

            // 需要发送的明文
            String actionType = wechatMessage.EventKey;

            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<xml>");
            sb.AppendFormat("<ToUserName><![CDATA[{0}]]></ToUserName>", wechatMessage.FromUserName);
            sb.AppendFormat("<FromUserName><![CDATA[{0}]]></FromUserName>", wechatMessage.ToUserName);
            sb.AppendFormat("<CreateTime>{0}</CreateTime>", wechatMessage.CreateTime);

            // string sRespData = "<MsgId>1234567890123456</MsgId>";
            logger.Info("EventKey: " + wechatMessage.EventKey);

            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(wechatMessage.FromUserName);
            if (agentWechatAccount != null && wechatMessage != null && !String.IsNullOrEmpty(wechatMessage.Event) && wechatMessage.Event.Equals("enter_agent"))
            {
                WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                wechatQueryLog.agentName = "";
                wechatQueryLog.module = Util.MyConstant.module_Commission;
                wechatQueryLog.subSystem = "佣金结算与支付查询";
                wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                wechatQueryLog.queryString = "成员进入应用";
                wechatQueryLog.wechatId = agentWechatAccount.contactId;
                WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                try
                {
                    wechatQueryLogDao.Add(wechatQueryLog);
                }
                catch
                {
                }
            }
            if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
            {
                sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

            }
            else if (agentWechatAccount==null)
            {
                sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
            }
            else
            {
                String agentNo = agentWechatAccount.branchNo;
                if (String.IsNullOrEmpty(agentNo))
                {
                    agentNo = agentWechatAccount.agentNo;
                }
                switch (actionType)
                {
                    case "FeeQueryHelp":
                        sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "佣金查询说明\n\n");

                        break;

                    case "last6MonthBonus":
                        String strBonusList = "最近6月红包查询\n\n";
                        for (int i = 1; i <= 6; i++)
                        {
                            String tempFeeMonth = DateTime.Now.AddMonths(0 - i).ToString("yyyyMM");

                            String url1 = String.Format("http://{0}/Wechat/AgentBonusDetailQuery.aspx?agentNo={1}&feeMonth={2}", Properties.Settings.Default.Host, QueryStringEncryption.Encode(agentNo, QueryStringEncryption.key), QueryStringEncryption.Encode(tempFeeMonth, QueryStringEncryption.key));

                            strBonusList = strBonusList + "<a href=\"" + url1 + "\">" + i + ":" + tempFeeMonth + "</a>";
                            strBonusList = strBonusList + "\n\n";
                        }
                        sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", strBonusList);
                        break;

                    case "preMonthBonus":
                    case "curMonthBonus":
                        String feeMonthBonus = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
                        if (actionType.Equals("preMonthBonus"))
                        {
                            feeMonthBonus = DateTime.Now.AddMonths(-2).ToString("yyyyMM");
                        }
                        AgentBonusDao agentBonusDao = new AgentBonusDao();
                        AgentBonus agentBonus = agentBonusDao.GetByKey(feeMonthBonus, agentNo);
                        if (agentBonus != null && !String.IsNullOrEmpty(agentBonus.agentNo))
                        {
                            sb.Append(this.createAgentBonusNewsMessages(feeMonthBonus, agentBonus, agentNo));
                        }
                        else
                        {
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "本月无红包或者红包尚未发布!\n\n");
                        }
                        break;

                    case "Latest6MonthFeeQuery":
                        String strList = "最近6月佣金查询\n\n";
                        for (int i = 1; i <= 6; i++)
                        {
                            String tempFeeMonth = DateTime.Now.AddMonths(0 - i).ToString("yyyy-MM");

                            String url1 = String.Format("http://{0}/Wechat/AgentFeeQuery.aspx?agentNo={1}&feeMonth={2}", Properties.Settings.Default.Host, QueryStringEncryption.Encode(agentNo, QueryStringEncryption.key), QueryStringEncryption.Encode(tempFeeMonth, QueryStringEncryption.key));

                            strList = strList + "<a href=\"" + url1 + "\">" + i + ":" + tempFeeMonth + "</a>";
                            strList = strList + "\n\n";
                        }
                        sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", strList);
                        break;

                    case "PreMonthFeeQuery":
                    case "CurMonthFeeQuery":
                        String feeMonth = DateTime.Now.AddMonths(-1).ToString("yyyy-MM");
                        if (actionType.Equals("PreMonthFeeQuery"))
                        {
                            feeMonth = DateTime.Now.AddMonths(-2).ToString("yyyy-MM");
                        }
                        AgentFeeDao agentFeeDao = new AgentFeeDao();
                        AgentFee agentFee = agentFeeDao.GetByKey(feeMonth, agentNo);
                        if (agentFee != null && !String.IsNullOrEmpty(agentFee.agentFeeSeq))
                        {
                            sb.Append(this.createAgentFeeNewsMessages(feeMonth, agentFee, agentNo));
                        }
                        else
                        {
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "本月无佣金或者佣金尚未发布\n\n");
                        }
                        break;
                    case "PaymentQueryHelp":
                        sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "发票支付查询说明\n\n");

                        break;

                    case "Latest6MonthPaymentQuery":
                        String strList1 = "最近6月发票支付查询\n\n";
                        for (int i = 1; i <= 6; i++)
                        {
                            String tempFeeMonth = DateTime.Now.AddMonths(0 - i).ToString("yyyyMM");

                            String url1 = String.Format("http://{0}/Wechat/InvoicePaymentQuery.aspx?agentNo={1}&feeMonth={2}", Properties.Settings.Default.Host, QueryStringEncryption.Encode(agentNo, QueryStringEncryption.key), QueryStringEncryption.Encode(tempFeeMonth, QueryStringEncryption.key));

                            strList1 = strList1 + "<a href=\"" + url1 + "\">" + i + ":" + tempFeeMonth + "</a>";
                            strList1 = strList1 + "\n\n";
                        }
                        sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", strList1);
                        break;

                    case "PreMonthPaymentQuery":
                    case "CurMonthPaymentQuery":
                        feeMonth = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
                        if (actionType.Equals("PreMonthPaymentQuery"))
                        {
                            feeMonth = DateTime.Now.AddMonths(-2).ToString("yyyyMM");
                        }
                        InvoicePaymentDao agentInvoicePaymentDao = new InvoicePaymentDao();

                        IList<InvoicePayment> agentInvoicePaymentList = new List<InvoicePayment>();

                        //  agentNo = "";//"DL224049";
                        // feeMonth = "201412";
                        logger.Info("1.feeMonth=" + feeMonth);
                        logger.Info("2.agentNo=" + agentNo);

                        agentInvoicePaymentList = agentInvoicePaymentDao.GetList(agentNo, null, feeMonth, null);

                        if (agentInvoicePaymentList != null && agentInvoicePaymentList.Count > 0)
                        {
                            sb.Append(this.createPaymentNewsMessages(feeMonth, agentNo, agentInvoicePaymentList));
                        }
                        else
                        {
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", feeMonth.Substring(0, 4) + "年" + feeMonth.Substring(4, 2) + "月" + "无发票受理记录或尚未完成,请耐心等候!\n\n");
                        }
                        break;
                    default:

                        if (!Regex.IsMatch(wechatMessage.Content, "((20[0-9][0-9])|(19[0-9][0-9]))-((0[1-9])|(1[0-2]))"))
                        {
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "请输入\"yyyy-mm\"查询某月佣金,支付结算和红包,例如:\"" + DateTime.Now.ToString("yyyy-MM") + "\"查询" + DateTime.Now.ToString("yyyy年MM月") + "佣金\n\n");
                        }
                        else
                        {
                            feeMonth = wechatMessage.Content;
                            agentFeeDao = new AgentFeeDao();
                            agentFee = agentFeeDao.GetByKey(feeMonth, wechatMessage.FromUserName);

                             agentBonusDao = new AgentBonusDao();
                             feeMonthBonus = feeMonth.Replace("-", "");
                             agentBonus = agentBonusDao.GetByKey(feeMonthBonus, agentNo);

                             agentInvoicePaymentDao = new InvoicePaymentDao();
                            String feeMonthInvoice = feeMonth.Replace("-", "");
                             agentInvoicePaymentList = agentInvoicePaymentDao.GetList(agentNo, null, feeMonthInvoice, null);




                             sb.Append(this.createAllNewsMessages(feeMonth, wechatMessage.FromUserName, agentFee, agentBonus, agentInvoicePaymentList));

                          
                        }

                        break;

                   
                }
            }

            //  sb.AppendFormat("<AgentID>{0}</AgentID>", textMessage.AgentID);

            sb.AppendFormat("</xml>");
            string sRespData = sb.ToString();
            string sEncryptMsg = ""; //xml格式的密文
            ret = wxcpt.EncryptMsg(sRespData, sReqTimeStamp, sReqNonce, ref sEncryptMsg);
            logger.Info("ret=" + ret);
            if (ret != 0)
            {
                System.Console.WriteLine("ERR: EncryptMsg Fail, ret: " + ret);


                return;
            }

            context.Response.Write(sEncryptMsg);


        }
Esempio n. 15
0
        void bindDataToGrid(String subject, String type, String search_scope, String agentNo,String userId)
        {
            logger.Info("bindDataToGrid=");
            logger.Info("subject=" + subject);
            logger.Info("type=" + type);
            logger.Info("search_scope=" + search_scope);
            logger.Info("agentNo=" + agentNo);
            logger.Info("userId=" + userId);
            PolicyDao policyDao = new ChinaUnion_DataAccess.PolicyDao();

            IList<Policy> policyList = null;

            if (!String.IsNullOrEmpty(search_scope) && search_scope.Equals("validate"))
            {
                policyList = policyDao.GetAllValidatedList(subject, type);
                logger.Info("validate=");
            }


            if (!String.IsNullOrEmpty(search_scope) && search_scope.Equals("all"))
            {
                policyList = policyDao.GetList(subject, type);
                logger.Info("all=");
            }
            this.lblType.Text = type;
            this.lblScope.Text = search_scope;
            this.lblAgentNo.Text = agentNo;
            this.lblUserId.Text = userId;
            // int index = 1;
            DataTable dt = new DataTable();
            dt.Columns.Add("seq");
            dt.Columns.Add("userId");
            dt.Columns.Add("subject");
            dt.Columns.Add("content");
            dt.Columns.Add("attachment");
            dt.Columns.Add("validateStartTime");
            dt.Columns.Add("validateEndTime");

            DataRow row = null;
            if (policyList != null && policyList.Count>0)
            {
                foreach (Policy policy in policyList)
                {
                    if (!policy.toAll.Equals("Y"))
                    {
                        AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
                        AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(userId);

                        if (!String.IsNullOrEmpty(policy.agentType) )
                        {
                              IList<String> list = policy.agentType.Split(';').ToList<String>();
                              if (!list.Contains(agentWechatAccount.type))
                              {
                                  continue;
                              }
                        }
                        if (String.IsNullOrEmpty(policy.agentType))
                        {
                            IList<String> agentNoList = policyDao.GetAllAgentNoListBySeq(policy.sequence);
                            if (!agentNoList.Contains(agentNo))
                            {
                                logger.Info("userId=" + userId + " 没有权限范围" + policy.sequence);
                                continue;
                            }
                        }
                    }
                    row = dt.NewRow();
                    row["seq"] = policy.sequence;
                    row["userId"] = userId;
                    row["subject"] = policy.subject;
                    if (policy.content.Length > 10)
                    {
                        row["content"] = policy.content.Substring(0, 10) + "......";
                    }
                    else
                    {
                        row["content"] = policy.content;
                    }
                    if (!String.IsNullOrEmpty(policy.attachmentName))
                    {
                        row["attachment"] = "附件";
                    }
                    row["validateStartTime"] = policy.validateStartTime;
                    row["validateEndTime"] = policy.validateEndTime;
                    dt.Rows.Add(row);
                }
            }
            else
            {
                this.lblMessag.Text = "未找到" + type + "记录!";
            }
            GridView1.DataSource = dt.DefaultView;
            GridView1.DataBind();
        }
Esempio n. 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            logger.Info(this.Request.Url.AbsoluteUri);

            //bindDataToGrid("", "政策", "validate", "DL204053", "P001");
            //http%3a%2f%2f112.64.17.80%2fwechat%2fBusinessPolicyQuery.aspx%3fsearch_scope%3dvalidate%26messageType%3dnotice%26agentId%3d6
            //http%3a%2f%2f112.64.17.80%2fwechat%2fBusinessPolicyQuery.aspx%3fsearch_scope%3dvalidate%26messageType%3dnotice
            //String myUrl = "http://112.64.17.80/wechat/BusinessPolicyQuery.aspx?search_scope=validate&messageType=notice&agentId=6";
            // myUrl = this.Server.UrlEncode(myUrl);
            string code = Request.QueryString["code"];
            string state = Request.QueryString["state"];
            string search_scope = Request.QueryString["search_scope"];
            string agentId = Request.QueryString["agentId"];
            logger.Info("agentId=" + Request.QueryString["agentId"]);
            logger.Info("code=" + Request.QueryString["code"]);
            logger.Info("state=" + Request.QueryString["state"]);
            logger.Info("search_scope=" + Request.QueryString["search_scope"]);
             WechatUtil wechatUtil = new Util.WechatUtil();
             HttpResult result = wechatUtil.getUserInfoFromWechat(code, agentId, MyConstant.ScretId);
            logger.Info("result=" + result.Html);
            if (result != null && result.Html != null && result.Html.Contains("UserId"))
            {
                WechatUserId returnMessage = (WechatUserId)JsonConvert.DeserializeObject(result.Html, typeof(WechatUserId));

                AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
                AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(returnMessage.UserId);

                if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
                {
                    this.lblType.Text = "你的账号已被停用,请联系联通工作人员!";
                    //  sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

                }
                else if (agentWechatAccount == null)
                {
                    this.lblType.Text = "用户不存在,请联系联通工作人员!";
                    //sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
                }
                else
                {
                    String agentNo = agentWechatAccount.branchNo;
                    if (String.IsNullOrEmpty(agentNo))
                    {
                        agentNo = agentWechatAccount.agentNo;
                    }


                   // search_scope = "all";
                    String type = "通知公告/重点关注";
                    if (!String.IsNullOrEmpty(state) && state.Equals("myNotice"))
                    {
                        type = "通知公告/重点关注";
                    }

                    if (!String.IsNullOrEmpty(state) && state.Equals("policy"))
                    {
                        type = "政策";
                    }

                    if (!String.IsNullOrEmpty(state) && state.Equals("rule"))
                    {
                        type = "服务规范";
                    }


                    WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                    wechatQueryLog.agentName = "";
                    wechatQueryLog.module = Util.MyConstant.module_Notice;
                    wechatQueryLog.subSystem = "通知公告与促销政策";
                    wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    wechatQueryLog.queryString = type;
                    wechatQueryLog.wechatId = agentWechatAccount.contactId;
                    WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                    try
                    {
                        wechatQueryLogDao.Add(wechatQueryLog);
                    }
                    catch
                    {
                    }

                    bindDataToGrid("", type, search_scope, agentNo, agentWechatAccount.contactId);
                }
            }
          

        }
Esempio n. 17
0
        /// <summary>
        /// 处理企业号的信息
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            
            logger.Info(context.Request.Url.AbsoluteUri);


            //string sToken = "AgentFee";
            //string sCorpID = "wx4fe8b74e01fffcbb";
            //string sEncodingAESKey = "gvGJnhpjeljcKzvfe8B8vnmMBBLkJFuzUYSjsGcDQFE";

            string sToken = Properties.Settings.Default.Wechat_ErrorCode_Token;// "ErrorCode";
            string sCorpID = Properties.Settings.Default.Wechat_CorpId;// "wx31204de5a3ae758e";
            string sEncodingAESKey = Properties.Settings.Default.Wechat_ErrorCode_EncodingAESKey;// "VcEu5ijaEa6xVklONE9APWJgfvh1UhGjXGKAdeHWAWQ";

            System.Collections.Specialized.NameValueCollection queryStrings = context.Request.QueryString;
            Tencent.WXBizMsgCrypt wxcpt = new Tencent.WXBizMsgCrypt(sToken, sEncodingAESKey, sCorpID);

            context.Request.ContentEncoding = Encoding.UTF8;
            string sReqMsgSig = queryStrings["msg_signature"];
            string sReqTimeStamp = queryStrings["timestamp"];
            string sReqNonce = queryStrings["nonce"];

            // 获取Post请求的密文数据
            StreamReader reader = new StreamReader(context.Request.InputStream, Encoding.GetEncoding("UTF-8"));
            string sReqData = reader.ReadToEnd();
            reader.Close();

            string sMsg = "";  // 解析之后的明文
            int ret = wxcpt.DecryptMsg(sReqMsgSig, sReqTimeStamp, sReqNonce, sReqData, ref sMsg);
            

            if (ret != 0)
            {
                logger.Info("ERR: Decrypt Fail, ret: " + ret);
                System.Console.WriteLine("ERR: Decrypt Fail, ret: " + ret);
                return;
            }
            // ret==0表示解密成功,sMsg表示解密之后的明文xml串           
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sMsg);
            WechatMessage wechatMessage = new WechatMessage(doc.DocumentElement);



            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<xml>");
            sb.AppendFormat("<ToUserName><![CDATA[{0}]]></ToUserName>", wechatMessage.FromUserName);
            sb.AppendFormat("<FromUserName><![CDATA[{0}]]></FromUserName>", wechatMessage.ToUserName);
            sb.AppendFormat("<CreateTime>{0}</CreateTime>", wechatMessage.CreateTime);

            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(wechatMessage.FromUserName);

            if (agentWechatAccount != null && wechatMessage != null && !String.IsNullOrEmpty(wechatMessage.Event) && wechatMessage.Event.Equals("enter_agent"))
            {
                WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                wechatQueryLog.agentName = "";
                wechatQueryLog.module = Util.MyConstant.module_Error;
                wechatQueryLog.subSystem = "报错处理";
                wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                wechatQueryLog.queryString = "成员进入应用";
                wechatQueryLog.wechatId = agentWechatAccount.contactId;
                WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                try
                {
                    wechatQueryLogDao.Add(wechatQueryLog);
                }
                catch
                {
                }
            }

            try
            {


                if (String.IsNullOrEmpty(wechatMessage.Content))
                {
                    wechatMessage.Content = "help";
                }

                switch (wechatMessage.Content.ToLower())
                {
                    case "help":
                    case "?":
                    case "?":
                        sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "请输入错误关键字查询错误详细说明,例如:输入\"系统异常\"查询包含\"系统异常\"的错误信息");

                        break;

                    default:
                       
                        AgentErrorCodeDao agentErrorCodeDao = new AgentErrorCodeDao();
                        int maxArticleCnt = 10;
                        IList<AgentErrorCode> agentErrorCodeList = agentErrorCodeDao.GetList(wechatMessage.Content);
                        if (agentErrorCodeList != null && agentErrorCodeList.Count > 0)
                        {
                            sb.AppendFormat("<MsgType><![CDATA[news]]></MsgType>");
                            if (agentErrorCodeList.Count > maxArticleCnt)
                            {
                                sb.AppendFormat("<ArticleCount>{0}</ArticleCount>", maxArticleCnt);
                            }
                            else if (agentErrorCodeList.Count <= 10 && agentErrorCodeList.Count > 0)
                            {
                                sb.AppendFormat("<ArticleCount>{0}</ArticleCount>", agentErrorCodeList.Count);
                            }
                           
                            sb.AppendFormat("<Articles>");

                            int count = 0;
                            foreach (AgentErrorCode agentErrorCode in agentErrorCodeList)
                            {
                                count++;

                                if (count > maxArticleCnt)
                                {
                                    break;
                                }
                                String dir = context.Server.MapPath("~/") + @"\ErrorImages\";
                                logger.Info("Path=" + dir + agentErrorCode.seq + ".jpg");
                                if (!Directory.Exists(dir))
                                {
                                    Directory.CreateDirectory(dir);
                                }

                                String path = dir + agentErrorCode.seq + ".jpg";


                                if (!File.Exists(path) || !File.GetCreationTime(path).ToString("yyyy-MM-dd").Equals(DateTime.Now.ToString("yyyy-MM-dd")))
                                {
                                    if (agentErrorCode.errorImg != null)
                                    {
                                        logger.Info("path=" + path);

                                        System.IO.File.WriteAllBytes(path, agentErrorCode.errorImg);
                                    }
                                    else
                                    {
                                        logger.Info("path=no image");
                                    }
                                }
                                sb.AppendFormat("<item>");
                                sb.Append("<Title>").AppendFormat("{0}报错查询结果", agentErrorCode.keyword).Append("</Title>");
                                // String errorCondition = wechatMessage.Content.Substring("error:".Length);

                                StringBuilder sbDesc = new StringBuilder();
                                //sbDesc.AppendFormat("本月佣金告知单({0})", feeMonth);

                                sbDesc.AppendFormat("问题描述:\n{0}\n\n", agentErrorCode.errorDesc);
                                sbDesc.AppendFormat("处理方法:\n{0}\n\n", agentErrorCode.solution);
                                sbDesc.AppendFormat("联系人员:{0}\n\n", agentErrorCode.contactName);
                                sbDesc.AppendFormat("备注:\n{0}\n", agentErrorCode.comment);
                                sb.Append("<Description>").AppendFormat("<![CDATA[{0}]]>", sbDesc.ToString()).Append("</Description>");
                                sb.Append("<PicUrl>").AppendFormat("<![CDATA[{0}{1}{2}]]>", "http://"+Properties.Settings.Default.Host+"/Wechat/ErrorImages/", agentErrorCode.seq, ".jpg").Append("</PicUrl>");
                                //logger.Info("path=" + "http://"http://"+Properties.Settings.Default.Host+"/Wechat/ErrorCodeQuery.aspx?keyword=" + context.Server.UrlEncode(agentErrorCode.keyword));
                                sb.Append("<Url>").AppendFormat("<![CDATA[{0}{1}{2}]]>", "http://" + Properties.Settings.Default.Host + "/Wechat/ErrorCodeQuery.aspx?keyword=", context.Server.UrlEncode(agentErrorCode.keyword), "&userId=" + wechatMessage.FromUserName).Append("</Url>");
                                //           sb.Append("<Url>").AppendFormat("<![CDATA[{0}]]>", url1).Append("</Url>");
                                sb.AppendFormat("</item>");
                                //  logger.Info(sb.ToString());


                            }
                            sb.AppendFormat("</Articles>");
                        }
                        else
                        {
                            sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                            sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "没有找到与" + wechatMessage.Content+"相关的错误详细信息,请更改查询条件或者与联通相关人员确认。");
           
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
            }
            //  sb.AppendFormat("<AgentID>{0}</AgentID>", textMessage.AgentID);

            sb.AppendFormat("</xml>");
            string sRespData = sb.ToString();
            string sEncryptMsg = ""; //xml格式的密文
            ret = wxcpt.EncryptMsg(sRespData, sReqTimeStamp, sReqNonce, ref sEncryptMsg);
            logger.Info("ret=" + ret);
            if (ret != 0)
            {
                System.Console.WriteLine("ERR: EncryptMsg Fail, ret: " + ret);


                return;
            }

            context.Response.Write(sEncryptMsg);
            // TODO:
            // 加密成功,企业需要将加密之后的sEncryptMsg返回
            // HttpUtils.SetResponse(sEncryptMsg);

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            logger.Info(this.Request.Url.AbsoluteUri);

           
            string code = Request.QueryString["code"];
            string state = Request.QueryString["state"];
            
            logger.Info("code=" + Request.QueryString["code"]);
            logger.Info("state=" + Request.QueryString["state"]);

            if (!String.IsNullOrEmpty(code))
            {
                WechatUtil wechatUtil = new Util.WechatUtil();
                HttpResult result = wechatUtil.getUserInfoFromWechat(code, "9", "stkc3kfO0sCrIJTFCHzOhmEsRWAnVGHqrzBIy4le6mV6EcSkNbpY0Tt49Uci2Buu");
                logger.Info("result=" + result.Html);
                if (result != null && result.Html != null && result.Html.Contains("UserId"))
                {
                    WechatUserId returnMessage = (WechatUserId)JsonConvert.DeserializeObject(result.Html, typeof(WechatUserId));

                    AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
                    AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(returnMessage.UserId);

                    if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
                    {
                        this.lblType.Text = "你的账号已被停用,请联系联通工作人员!";
                        //  sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

                    }
                    else if (agentWechatAccount == null)
                    {
                        this.lblType.Text = "用户不存在,请联系联通工作人员!";
                        //sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
                    }
                    else
                    {
                        String agentNo = agentWechatAccount.branchNo;
                        if (String.IsNullOrEmpty(agentNo))
                        {
                            agentNo = agentWechatAccount.agentNo;
                        }
                        String type = "吐槽";
                        if (!String.IsNullOrEmpty(state) && state.Equals("complain"))
                        {
                            type = "吐槽";
                            this.lblTitle.Text = "吐槽历史";
                        }

                        if (!String.IsNullOrEmpty(state) && state.Equals("appraise"))
                        {
                            type = "点赞";
                            this.lblTitle.Text = "点赞历史";
                        }

                        if (!String.IsNullOrEmpty(state) && state.Equals("suggestion"))
                        {
                            type = "建议";
                            this.lblTitle.Text = "建议历史";
                        }
                        WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                        wechatQueryLog.agentName = "";
                        wechatQueryLog.module = Util.MyConstant.module_Service;
                        wechatQueryLog.subSystem = "服务监督";
                        wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        wechatQueryLog.queryString = type;
                        wechatQueryLog.wechatId = agentWechatAccount.contactId;
                        WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                        try
                        {
                            wechatQueryLogDao.Add(wechatQueryLog);
                        }
                        catch
                        {
                        }

                        bindDataToGrid("", type, agentNo, returnMessage.UserId);
                    }
                }
            }
            else
            {
                string type = Request.QueryString["type"];
                string agentNo = Request.QueryString["agentNo"];
                string userId = Request.QueryString["userId"];
                if (!String.IsNullOrEmpty(type) && !String.IsNullOrEmpty(agentNo))
                {
                    bindDataToGrid("", type, agentNo, userId);
                }
            }
        }
Esempio n. 19
0
        private void btnPublish_Click(object sender, EventArgs e)
        {
            //this.btnSave_Click(sender, e);
          //  this.prepareGrid(this.txtSearchCondition.Text);
            if (String.IsNullOrEmpty(this.txtSequence.Text))
            {
                MessageBox.Show("请先保存,再发布");
                return;
            }
            this.Cursor = Cursors.WaitCursor;
            int appId = 0;
            switch (this.cbType.Text)
            {
                case "政策":
                    appId = MyConstant.APP_Notice;
                    break;
                case "通知公告/重点关注":
                    appId = MyConstant.APP_Notice;
                    break;
                case "服务规范":
                    appId = MyConstant.APP_Service_Monitor;
                    break;
            }

            AgentWechatAccountDao agentWechatAccountDao = new ChinaUnion_DataAccess.AgentWechatAccountDao();
            String agentType = "";

            foreach (object item in this.chkAgentType.CheckedItems)
            {
                agentType = item.ToString();
                IList<String> list = agentWechatAccountDao.GetListByType(agentType);

                List<String> userIdsBuffer1 = new List<string>();
                for (int i = 1; i <= list.Count; i++)
                {
                    userIdsBuffer1.Add(list[i - 1]);
                    if (i % 500 == 0 || i == list.Count)
                    {
                        string userId = "";
                        userId = string.Join("|", userIdsBuffer1.ToArray());
                        userIdsBuffer1.Clear();

                        WechatAction wechatAction = new WechatAction();

                        String content = this.txtSubject.Text.Trim();
                        String state = this.txtSequence.Text;
                        String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx31204de5a3ae758e&redirect_uri=http%3a%2f%2f112.64.17.80%2fwechat%2fBusinessPolicyDetail.aspx&response_type=code&scope=snsapi_base&state=" + state + "#wechat_redirect";

                        content = "你有新的消息,主题:" + content + ", <a href=\"" + url + "\">点击查询详情</a>";
                        HttpResult result = wechatAction.sendTextMessageToWechat(userId, content, Settings.Default.Wechat_Secret, appId);

                    }


                }

            }
              


            IList<String> UserIdList = policyDao.GetAllUserIdListBySeq(this.txtSequence.Text);
          
            List<String> userIdsBuffer = new List<string>();
            for (int i = 1; i <= UserIdList.Count; i++)
            {
                userIdsBuffer.Add(UserIdList[i - 1]);
                if (i % 500 == 0 || i == UserIdList.Count)
                {
                    string userId = "";
                    userId = string.Join("|", userIdsBuffer.ToArray());
                    userIdsBuffer.Clear();

                    WechatAction wechatAction = new WechatAction();

                    String content = this.txtSubject.Text.Trim();
                    String state = this.txtSequence.Text;
                    String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx31204de5a3ae758e&redirect_uri=http%3a%2f%2f112.64.17.80%2fwechat%2fBusinessPolicyDetail.aspx&response_type=code&scope=snsapi_base&state=" + state + "#wechat_redirect";

                    content = "你有新的消息,主题:" + content + ", <a href=\"" + url + "\">点击查询详情</a>";
                    HttpResult result = wechatAction.sendTextMessageToWechat(userId, content, Settings.Default.Wechat_Secret, appId);

                }

              
            }
            this.Cursor = Cursors.Default;
            
        }
Esempio n. 20
0
        private void btnSave_Click(object sender, EventArgs e)
        {

            if (String.IsNullOrEmpty(this.txtAgentNo.Text.Trim()))
            {
                MessageBox.Show("编号不能为空");
                this.txtAgentNo.Focus();
                return;
            }
            if (String.IsNullOrEmpty(this.txtUserId.Text.Trim()))
            {
                MessageBox.Show("账号不能为空");
                this.txtAgentName.Focus();
                return;
            }

            if (String.IsNullOrEmpty(this.txtWeixinId.Text.Trim()) && String.IsNullOrEmpty(this.txtMobile.Text.Trim()) && String.IsNullOrEmpty(this.txtEmail.Text.Trim()))
            {
                MessageBox.Show("微信号,手机和邮箱不能同时为空");
                return;
            }

            String EmailReg = @"^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$";
            if (!String.IsNullOrEmpty(txtEmail.Text.Trim()) && !Regex.IsMatch(txtEmail.Text.Trim(), EmailReg))
            {
                MessageBox.Show("请输入有效的邮箱地址");
                this.txtEmail.Focus();
                return;
            }

            String MobileReg = @"^[1]+[3,5,8]+\d{9}";
            if (!String.IsNullOrEmpty(txtMobile.Text.Trim()) && !Regex.IsMatch(this.txtMobile.Text.Trim(), MobileReg))
            {
                MessageBox.Show("请输入有效的手机号码");
                this.txtMobile.Focus();
                return;
            }
            this.Cursor = Cursors.WaitCursor;
            AgentWechatAccount agentWechatAccount = new AgentWechatAccount();
            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            agentWechatAccount = agentWechatAccountDao.Get(this.txtUserId.Text);
            agentWechatAccount.contactEmail = this.txtEmail.Text;
            agentWechatAccount.contactId = this.txtUserId.Text;
            agentWechatAccount.contactName = this.txtUserName.Text;

            agentWechatAccount.contactTel = this.txtMobile.Text;
            agentWechatAccount.contactWechat = this.txtWeixinId.Text;
            agentWechatAccount.feeRight = "N";
            agentWechatAccount.policyRight = "N";
            agentWechatAccount.performanceRight = "N";
            agentWechatAccount.studyRight = "N";
            agentWechatAccount.complainRight = "N";
            agentWechatAccount.monitorRight = "N"; ;
            agentWechatAccount.errorRight = "N";
            agentWechatAccount.contactRight = "N";
            if (this.chkFee.Checked)
            {
                agentWechatAccount.feeRight = "Y";
            }
            if (this.chkPolicy.Checked)
            {
                agentWechatAccount.policyRight = "Y";
            }
            if (this.chkPerformance.Checked)
            {
                agentWechatAccount.performanceRight = "Y";
            }
            if (this.chkStudy.Checked)
            {
                agentWechatAccount.studyRight = "Y";
            }
            if (this.chkComplain.Checked)
            {
                agentWechatAccount.complainRight = "Y";
            }
            if (this.chkService.Checked)
            {
                agentWechatAccount.monitorRight = "Y";
            }
            if (this.chkError.Checked)
            {
                agentWechatAccount.errorRight = "Y";
            }
            if (this.chkContactUs.Checked)
            {
                agentWechatAccount.contactRight = "Y";
            }
            this.retAgentWechatAccount = agentWechatAccount;
            agentWechatAccountDao.Update(agentWechatAccount);
            this.Cursor = Cursors.Default;
            DialogResult = System.Windows.Forms.DialogResult.OK;

        }
        private void saveGridData(DataGridView dg, String type)
        {
            ArrayList AgentNoList = new ArrayList();
            ArrayList WechatNoList = new ArrayList();

            for (int i = 0; i < dgAgentWechatAccount.RowCount; i++)
            {
                AgentNoList.Add(dgAgentWechatAccount[4, i].Value.ToString());
                if (!String.IsNullOrEmpty(dgAgentWechatAccount[7, i].Value.ToString()))
                {
                    WechatNoList.Add(dgAgentWechatAccount[7, i].Value.ToString());
                }
            }
            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
            for (int i = 0; i < dg.RowCount; i++)
            {
                AgentWechatAccount agentWechatAccount = new AgentWechatAccount();
                int index = 0;
                agentWechatAccount.type = type;
                if (dg.Columns[0].HeaderText.Equals("区县"))
                {
                    agentWechatAccount.regionName = dg[index++, i].Value.ToString();
                    agentWechatAccount.branchNo = dg[index++, i].Value.ToString();
                    agentWechatAccount.branchName = dg[index++, i].Value.ToString();
                    //agentWechatAccount.type = "直供渠道联系人";
                }
                else if (dg.Columns[0].HeaderText.Equals("代理商编号"))
                {
                    agentWechatAccount.agentNo = dg[index++, i].Value.ToString();
                    agentWechatAccount.agentName = dg[index++, i].Value.ToString();
                    if (dg.Columns[2].HeaderText.Equals("渠道编码"))
                    {
                        agentWechatAccount.branchNo = dg[index++, i].Value.ToString();
                        agentWechatAccount.branchName = dg[index++, i].Value.ToString();

                    }
                }


                agentWechatAccount.contactEmail = dg[index++, i].Value.ToString();
                agentWechatAccount.contactId = dg[index++, i].Value.ToString();
                agentWechatAccount.contactName = dg[index++, i].Value.ToString();
                agentWechatAccount.contactTel = dg[index++, i].Value.ToString();
                agentWechatAccount.contactWechat = dg[index++, i].Value.ToString();

                agentWechatAccount.feeRight = dg[index++, i].Value.ToString();
                agentWechatAccount.policyRight = dg[index++, i].Value.ToString();
                agentWechatAccount.performanceRight = dg[index++, i].Value.ToString();
                agentWechatAccount.studyRight = dg[index++, i].Value.ToString();
                agentWechatAccount.complainRight = dg[index++, i].Value.ToString();
                agentWechatAccount.monitorRight = dg[index++, i].Value.ToString();
                agentWechatAccount.errorRight = dg[index++, i].Value.ToString();
                agentWechatAccount.contactRight = dg[index++, i].Value.ToString();


                if (String.IsNullOrEmpty(agentWechatAccount.branchNo))
                    agentWechatAccount.branchNo = "";
                if (AgentNoList.Contains(agentWechatAccount.contactId) && !type.Equals("代理商联系人"))
                {
                    continue;
                }
                if (WechatNoList.Contains(agentWechatAccount.contactWechat) && !type.Equals("代理商联系人"))
                {
                    continue;
                }

                agentWechatAccountDao.Delete(agentWechatAccount.contactId);
                agentWechatAccountDao.Add(agentWechatAccount);



            }
        }