protected void Page_Load(object sender, EventArgs e)
        {
            string feeDate = Request.QueryString["feeDate"];
            string agentNo = Request.QueryString["agentNo"];
            string type = Request.QueryString["type"];
            logger.Info("feeDate=" + Request.QueryString["feeDate"]);
            logger.Info("agentNo=" + Request.QueryString["agentNo"]);
            logger.Info("type=" + Request.QueryString["type"]);
            try
            {
                Request.ContentEncoding = Encoding.UTF8;
               feeDate = QueryStringEncryption.Decode(feeDate, QueryStringEncryption.key);
                agentNo = QueryStringEncryption.Decode(agentNo, QueryStringEncryption.key);
                type = QueryStringEncryption.Decode(type, QueryStringEncryption.key);
                type = System.Web.HttpUtility.UrlDecode(type);
                logger.Info("feeDate=" + feeDate);
                logger.Info("agentNo=" + agentNo);
                logger.Info("type=" + type);
            }
            catch (Exception)
            {
                // return;
            }

            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 = feeDate;
            wechatQueryLog.wechatId = agentNo;
            WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
            try
            {
                wechatQueryLogDao.Add(wechatQueryLog);
            }
            catch
            {
            }

            DataTable dt = new DataTable();
            DataRow row = null;
            dt.Columns.Add("type");
            dt.Columns.Add("date");
            dt.Columns.Add("branchNo");
            dt.Columns.Add("branchName");
            dt.Columns.Add("fee1");
            dt.Columns.Add("fee2");

            dt.Columns.Add("summary");

             //agentNo = "P001";
           // feeDate = "2015-07-08";// DateTime.Now.AddMonths(-1).ToString("yyyy-MM");

            AgentDailyPerformanceDao agentPerformanceDao = new ChinaUnion_DataAccess.AgentDailyPerformanceDao();


            IList<AgentDailyPerformance> agentPerformanceList = agentPerformanceDao.GetList(agentNo, feeDate,type);

            if (agentPerformanceList != null && agentPerformanceList.Count > 0)
            {
                foreach (AgentDailyPerformance agentPerformance in agentPerformanceList)
                {
                    row = dt.NewRow();
                    row["type"] = agentPerformance.type;
                    row["date"] = agentPerformance.date;
                    row["branchNo"] = agentPerformance.branchNo;
                    row["branchName"] = agentPerformance.branchName;
                    row["fee1"] = "0";
                    row["fee2"] = "0";
                    for (int j = 1; j <= 100; j++)
                    {
                        FieldInfo feeNameField = agentPerformance.GetType().GetField("feeName" + j);
                        FieldInfo feeField = agentPerformance.GetType().GetField("fee" + j);
                        if (feeNameField != null && feeField != null)
                        {
                            String feeNameFieldValue = feeNameField.GetValue(agentPerformance) == null ? null : feeNameField.GetValue(agentPerformance).ToString();

                            String feeFieldValue = feeField.GetValue(agentPerformance) == null ? null : feeField.GetValue(agentPerformance).ToString();


                            if (!String.IsNullOrEmpty(feeFieldValue) && feeNameFieldValue.Equals("后付费发展数"))
                            {
                                row["fee1"] = feeFieldValue;
                            }
                            if (!String.IsNullOrEmpty(feeFieldValue) && feeNameFieldValue.Equals("预付费发展数"))
                            {
                                row["fee2"] = feeFieldValue;
                            }
                        }
                    }



                    row["summary"] = Int32.Parse(row["fee1"].ToString()) + Int32.Parse(row["fee2"].ToString());
                    dt.Rows.Add(row);
                }
            }
            DataView dv = dt.DefaultView;
            dv.Sort = "summary Desc";
            dt = dv.ToTable();

            AgentDailyPerformance agentPerformanceSummary = agentPerformanceDao.GetSummary(agentNo, feeDate, type);
            if (agentPerformanceSummary != null)
            {
                row = dt.NewRow();
                row["type"] = type;
                row["date"] = agentPerformanceSummary.date;

                row["branchNo"] = agentNo;
                row["branchName"] = "总计";
                row["fee1"] = "0";
                row["fee2"] = "0";
                for (int j = 1; j <= 100; j++)
                {
                    FieldInfo feeNameField = agentPerformanceSummary.GetType().GetField("feeName" + j);
                    FieldInfo feeField = agentPerformanceSummary.GetType().GetField("fee" + j);
                    if (feeNameField != null && feeField != null)
                    {
                        String feeNameFieldValue = feeNameField.GetValue(agentPerformanceSummary) == null ? null : feeNameField.GetValue(agentPerformanceSummary).ToString();

                        String feeFieldValue = feeField.GetValue(agentPerformanceSummary) == null ? null : feeField.GetValue(agentPerformanceSummary).ToString();


                        if (!String.IsNullOrEmpty(feeFieldValue) && feeNameFieldValue.Equals("后付费发展数"))
                        {
                            row["fee1"] = feeFieldValue;
                        }
                        if (!String.IsNullOrEmpty(feeFieldValue) && feeNameFieldValue.Equals("预付费发展数"))
                        {
                            row["fee2"] = feeFieldValue;
                        }
                    }
                }



                row["summary"] = Int32.Parse(row["fee1"].ToString()) + Int32.Parse(row["fee2"].ToString());
                dt.Rows.Add(row);
            }
            this.lblFeeMonth.Text = feeDate + "绩效统计";
            GridView1.DataSource = dt.DefaultView;
            GridView1.DataBind();

        }
Exemplo n.º 2
0
        private StringBuilder createNewsMessages(String agentNo, IList<AgentDailyPerformance> agentPerformanceList, String type)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<MsgType><![CDATA[news]]></MsgType>");

            sb.AppendFormat("<ArticleCount>{0}</ArticleCount>", agentPerformanceList.Count > 10 ? 10 : agentPerformanceList.Count);
            sb.AppendFormat("<Articles>");
            for (int month = 0; month < 10 && month < agentPerformanceList.Count; month++)
            {
                AgentDailyPerformance agentPerformance = agentPerformanceList[month];

                sb.AppendFormat("<item>");
                sb.Append("<Title>").AppendFormat("{0}日业绩", agentPerformance.date).Append("</Title>");

                StringBuilder sbDesc = new StringBuilder();

                if (month == 0)
                {
                    AgentDailyPerformanceDao agentPerformanceDao = new ChinaUnion_DataAccess.AgentDailyPerformanceDao();
                    agentPerformance = agentPerformanceDao.GetSummary(agentNo, agentPerformance.date, type);
                    if (!String.IsNullOrEmpty(agentPerformance.agentNo))
                    {

                        sbDesc.AppendFormat("代理商编号:" + agentPerformance.agentNo + "\n代理商名称:" + agentPerformance.agentName).Append("\n");
                    }
                    if (!String.IsNullOrEmpty(agentPerformance.branchNo))
                    {

                        sbDesc.AppendFormat("渠道编号:" + agentPerformance.branchNo + "\n渠道名称:" + agentPerformance.branchName).Append("\n");
                    }

                    sbDesc.AppendLine().AppendFormat("\n业绩汇总明细:\n");
                    int i = 1;
                    for (int j = 1; j <= 100; j++)
                    {
                        FieldInfo feeNameField = agentPerformance.GetType().GetField("feeName" + j);
                        FieldInfo feeField = agentPerformance.GetType().GetField("fee" + j);
                        if (feeNameField != null && feeField != null)
                        {
                            String feeNameFieldValue = feeNameField.GetValue(agentPerformance) == null ? null : feeNameField.GetValue(agentPerformance).ToString();

                            String feeFieldValue = feeField.GetValue(agentPerformance) == null ? null : feeField.GetValue(agentPerformance).ToString();

                            if (!String.IsNullOrEmpty(feeFieldValue) && !String.IsNullOrWhiteSpace(feeFieldValue))
                            {
                                if (feeNameFieldValue.Contains("后付费发展数") || feeNameFieldValue.Contains("预付费发展数") || feeNameFieldValue.Contains("总计"))
                                {
                                    sbDesc.Append("  ").AppendFormat("{0}", feeNameFieldValue).Append(" ").AppendFormat("{0}\n", feeFieldValue);

                                }
                                else
                                {

                                    sbDesc.Append("  ").AppendFormat("     {0}", feeNameFieldValue).Append(" ").AppendFormat("{0}\n", feeFieldValue);
                                }
                            }
                        }


                    }
                }
                sbDesc.AppendFormat("\n查询时间:{0}\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                sb.Append("<Description>").AppendFormat("<![CDATA[{0}]]>", sbDesc.ToString()).Append("</Description>");


                sb.Append("<PicUrl>").AppendFormat("<![CDATA[]]>").Append("</PicUrl>");
                String tempType = System.Web.HttpUtility.UrlEncode(type);
                String url1 = String.Format("http://{0}/Wechat/PerformanceDailySummaryQuery.aspx?agentNo={1}&feeDate={2}&type={3}", Properties.Settings.Default.Host, QueryStringEncryption.Encode(agentNo, QueryStringEncryption.key), QueryStringEncryption.Encode(agentPerformance.date, QueryStringEncryption.key), QueryStringEncryption.Encode(tempType, QueryStringEncryption.key));
                logger.Info(url1);
                sb.Append("<Url>").AppendFormat("<![CDATA[{0}]]>", url1).Append("</Url>");
                sb.AppendFormat("</item>");

            }

            sb.AppendFormat("</Articles>");
            return sb;
        }
        private void btnQuery_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;


            // Queryworker.ReportProgress(4, "代理商佣金...\r\n");
            //代理商佣金
            AgentDailyPerformanceDao agentDailyPerformanceDao = new AgentDailyPerformanceDao();
            IList<AgentDailyPerformance> agentDailyPerformanceList = agentDailyPerformanceDao.GetAllList(dtDay.Value.ToString("yyyy-MM-dd"), this.cboType.Text);
            dgAgentPerformance.Rows.Clear();
            dgAgentPerformance.Columns.Clear();
            if (agentDailyPerformanceList != null && agentDailyPerformanceList.Count > 0)
            {
                this.grpAgentFee.Text = "日度绩效信息(" + agentDailyPerformanceList.Count + ")";
                dgAgentPerformance.Columns.Add("渠道类型", "渠道类型");
                dgAgentPerformance.Columns.Add("渠道编码", "渠道编码");
                dgAgentPerformance.Columns.Add("渠道名称", "渠道名称");

                dgAgentPerformance.Columns.Add("代理商编号", "代理商编号");
                dgAgentPerformance.Columns.Add("代理商名称", "代理商名称");

                if (this.cboType.Text.Equals("直供渠道"))
                {
                    dgAgentPerformance.Columns[3].Visible = false;
                    dgAgentPerformance.Columns[4].Visible = false;
                }

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

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

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




                    }


                    dgAgentPerformance.Rows.Add();
                    DataGridViewRow row = dgAgentPerformance.Rows[i];
                    row.Cells[0].Value = agentDailyPerformanceList[i].type;
                    row.Cells[1].Value = agentDailyPerformanceList[i].branchNo;
                    row.Cells[2].Value = agentDailyPerformanceList[i].branchName;


                    row.Cells[3].Value = agentDailyPerformanceList[i].agentNo;
                    row.Cells[4].Value = agentDailyPerformanceList[i].agentName;
                    int feeColIndex = 4;
                    int fixColCount = feeColIndex + 1;


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

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

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



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


            this.Cursor = Cursors.Default;


        }
Exemplo n.º 4
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);


        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string feeDate = Request.QueryString["date"];
            string branchNo = Request.QueryString["branchNo"];
            string branchName = Request.QueryString["branchName"];
            string type = Request.QueryString["type"];
            logger.Info("feeDate=" + Request.QueryString["date"]);
            logger.Info("branchNo=" + Request.QueryString["branchNo"]);
            logger.Info("branchName=" + Request.QueryString["branchName"]);
            logger.Info("type=" + Request.QueryString["type"]);
            try
            {
                Request.ContentEncoding = Encoding.UTF8;
                // feeMonth = QueryStringEncryption.Decode(feeMonth, QueryStringEncryption.key);
                // agentNo = QueryStringEncryption.Decode(agentNo, QueryStringEncryption.key);
                logger.Info("feeMonth=" + feeDate);
                logger.Info("branchNo=" + branchNo);
            }
            catch (Exception)
            {
                // return;
            }

            DataTable dt = new DataTable();
            DataRow row = null;
            dt.Columns.Add("name");
            dt.Columns.Add("value");

            AgentDailyPerformanceDao agentPerformanceDao = new ChinaUnion_DataAccess.AgentDailyPerformanceDao();
            AgentDailyPerformance agentPerformance = new AgentDailyPerformance();

            if (!branchName.Equals("总计"))
            {
                agentPerformance = agentPerformanceDao.GetByKey(feeDate, branchNo, type);
            }
            else
            {
                agentPerformance = agentPerformanceDao.GetSummary(branchNo, feeDate, type);
            }

            if (agentPerformance != null)
            {
                if (!String.IsNullOrEmpty(agentPerformance.branchNo))
                {
                    row = dt.NewRow();
                    row["name"] = "门店编号";
                    row["value"] = agentPerformance.branchNo;
                    dt.Rows.Add(row);

                    row = dt.NewRow();
                    row["name"] = "门店名称";
                    row["value"] = agentPerformance.branchName;
                    dt.Rows.Add(row);
                }
                else
                {
                    row = dt.NewRow();
                    row["name"] = "代理商编号";
                    row["value"] = agentPerformance.agentNo;
                    dt.Rows.Add(row);

                    row = dt.NewRow();
                    row["name"] = "代理商名称";
                    row["value"] = agentPerformance.agentName;
                    dt.Rows.Add(row);
                }


                for (int j = 1; j <= 100; j++)
                {
                    FieldInfo feeNameField = agentPerformance.GetType().GetField("feeName" + j);
                    FieldInfo feeField = agentPerformance.GetType().GetField("fee" + j);
                    if (feeNameField != null && feeField != null)
                    {
                        String feeNameFieldValue = feeNameField.GetValue(agentPerformance) == null ? null : feeNameField.GetValue(agentPerformance).ToString();

                        String feeFieldValue = feeField.GetValue(agentPerformance) == null ? null : feeField.GetValue(agentPerformance).ToString();

                        if (!String.IsNullOrEmpty(feeFieldValue) && !String.IsNullOrWhiteSpace(feeFieldValue))
                        {
                            row = dt.NewRow();
                            row["name"] = feeNameFieldValue;
                            row["value"] = feeFieldValue;
                            dt.Rows.Add(row);

                        }
                    }


                }
            }
            this.lblFeeMonth.Text = feeDate + "绩效详情";
            GridView1.DataSource = dt.DefaultView;
            GridView1.DataBind();

        }