protected void Page_Load(object sender, EventArgs e)
        {
            string sequence = Request.QueryString["seq"];
            string userId = Request.QueryString["userId"];
            PolicyDao policyDao = new ChinaUnion_DataAccess.PolicyDao();
            Policy policy = policyDao.Get(Int32.Parse(sequence));

            if (policy != null)
            {
                PolicyReceiverLogDao policyReceiverLogDao = new PolicyReceiverLogDao();
                PolicyReceiverLog policyReceiverLog = new PolicyReceiverLog();
                policyReceiverLog.policySequence = policy.sequence;
                policyReceiverLog.readtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                policyReceiverLog.userId = userId;
                policyReceiverLogDao.Add(policyReceiverLog);

                Response.ContentType = "Application/pdf";
                this.Response.Clear();

                System.IO.Stream fs = this.Response.OutputStream;
                fs.Write(policy.attachment, 0, policy.attachment.Length);

                fs.Close();
                this.Response.End();
            }

        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sequence =  Request.QueryString["seq"];
            string userId =  Request.QueryString["userId"];
            logger.Info("sequence=" + sequence);
            logger.Info("userId=" + userId);

            
            if (!String.IsNullOrEmpty(sequence))
            {
                PolicyDao policyDao = new ChinaUnion_DataAccess.PolicyDao();
                Policy policy = policyDao.Get(Int32.Parse(sequence));
                if (policy != null)
                {
                    this.lblSubject.Text = policy.subject;
                   // this.lblSendTime.Text = policy.creatTime;
                    if (!String.IsNullOrEmpty(policy.content))
                    {
                        this.lblContent.Text = " <br>"+policy.content.Replace("\r\n", " <br>").Replace("\n", " <br>"); ;
                    }
                    logger.Info("sequence=" + sequence);
                    logger.Info("userId=" + userId);
                    PolicyReceiverLogDao policyReceiverLogDao = new PolicyReceiverLogDao();
                    PolicyReceiverLog policyReceiverLog = new PolicyReceiverLog();
                    policyReceiverLog.policySequence = policy.sequence;
                    policyReceiverLog.readtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    policyReceiverLog.userId = userId;
                    policyReceiverLogDao.Add(policyReceiverLog);
                }
            }
        }
Esempio n. 3
0
        void bindDataToGrid(String subject,  String agentNo,String userId)
        {
            logger.Info("bindDataToGrid=");
            logger.Info("subject=" + subject);
           
           
            logger.Info("agentNo=" + agentNo);
            logger.Info("userId=" + userId);
            PolicyDao policyDao = new ChinaUnion_DataAccess.PolicyDao();

            IList<Policy> policyList = null;



            policyList = policyDao.GetAllList(subject,"案例分享");
             
          
            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"))
                    {
                        IList<String> UserIdList = policyDao.GetAllAgentNoListBySeq(policy.sequence);
                        if (!UserIdList.Contains(userId))
                        {
                            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 > 20)
                    {
                        row["content"] =policy.subject+":"+ policy.content.Substring(0, 20) + "......";
                    }
                    else
                    {
                        row["content"] = policy.subject + ":" + policy.content;
                    }
                  
                    dt.Rows.Add(row);
                }
            }
            else
            {
                this.lblMessag.Text = "未找到"  + "记录!";
            }
            GridView1.DataSource = dt.DefaultView;
            GridView1.DataBind();
        }
        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();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string sequence =  Request.QueryString["seq"];
            string userId =  Request.QueryString["userId"];
            logger.Info("sequence=" + sequence);
            logger.Info("userId=" + userId);

            if (String.IsNullOrEmpty(sequence))
            {
                string code = Request.QueryString["code"];
                sequence = 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));
                    userId = returnMessage.UserId;
                }
                
            }
            if (!String.IsNullOrEmpty(sequence))
            {
                PolicyDao policyDao = new ChinaUnion_DataAccess.PolicyDao();
                Policy policy = policyDao.Get(Int32.Parse(sequence));
                if (policy != null)
                {
                    this.lblSubject.Text = policy.subject;
                    this.lblSendTime.Text = policy.creatTime;
                    if (!String.IsNullOrEmpty(policy.content))
                    {
                        this.lblContent.Text = policy.content.Replace("\r\n"," <br>").Replace("\n"," <br>");
                    }
                    this.lblValidateStartTime.Text = policy.validateStartTime;
                    this.lblValidateEndTime.Text = policy.validateEndTime;
                    this.lblAttachment.Text = policy.attachmentName;
                    this.lblAttachment.NavigateUrl = "BusinessPolicyAttachmentDetail.aspx?seq=" + policy.sequence + "&userId=" + userId;

                    logger.Info("sequence=" + sequence);
                    logger.Info("userId=" + userId);
                    PolicyReceiverLogDao policyReceiverLogDao = new PolicyReceiverLogDao();
                    PolicyReceiverLog policyReceiverLog = new PolicyReceiverLog();
                    policyReceiverLog.policySequence = policy.sequence;
                    policyReceiverLog.readtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    policyReceiverLog.userId = userId;
                    policyReceiverLogDao.Add(policyReceiverLog);


                    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 = policy.type;
                    wechatQueryLog.wechatId = userId;
                    WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                    try
                    {
                        wechatQueryLogDao.Add(wechatQueryLog);
                    }
                    catch
                    {
                    }
                }
            }
        }
Esempio n. 6
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;


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

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

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



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


            this.Cursor = Cursors.Default;


        }
        /// <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);


        }