public const string mysqlConnection = DBConstant.mysqlConnection;//"User Id=root;Host=115.29.229.134;Database=chinaunion;password=c513324665;charset=utf8"; /// <summary> /// 添加数据 /// </summary> /// <returns></returns> public int Add(AgentDailyPerformance entity) { StringBuilder sb = new StringBuilder(); sb.Append("INSERT INTO agent_daily_performance (type,branchNo, branchName,agentNo,agentName,"); for (int i = 1; i <= 100; i++) { sb.Append("feeName").Append(i.ToString()).Append(",").Append("fee").Append(i.ToString()).Append(","); } sb.Append("date) VALUE (@type,@branchNo, @branchName,@agentNo,@agentName,"); for (int i = 1; i <= 100; i++) { sb.Append("@feeName").Append(i.ToString()).Append(",").Append("@fee").Append(i.ToString()).Append(","); } sb.Append("@date)"); //string sql = "INSERT INTO agent_Fee (agentNo, agentFeeSeq,feeName1,fee1,feeName2,fee2,feeName3,fee3,feeName4,fee4,feeTotal) VALUE (@agentNo, @agentFeeSeq,@feeName1,@fee1,@feeName2,@fee2,@feeName3,@fee3,@feeName4,@fee4,@feeTotal)"; string sql = sb.ToString(); using (MySqlConnection mycn = new MySqlConnection(mysqlConnection)) { mycn.Open(); MySqlCommand command = new MySqlCommand(sql, mycn); command.Parameters.AddWithValue("@type", entity.type); command.Parameters.AddWithValue("@branchNo", entity.branchNo); command.Parameters.AddWithValue("@branchName", entity.branchName); command.Parameters.AddWithValue("@agentNo", entity.agentNo); command.Parameters.AddWithValue("@agentName", entity.agentName); for (int j = 1; j <= 100; j++) { FieldInfo feeNameField = entity.GetType().GetField("feeName" + j); FieldInfo feeField = entity.GetType().GetField("fee" + j); String feeNameFieldValue = feeNameField.GetValue(entity) == null ? null : feeNameField.GetValue(entity).ToString(); String feeFieldValue = feeField.GetValue(entity) == null ? null : feeField.GetValue(entity).ToString(); command.Parameters.AddWithValue("@feeName" + j, feeNameFieldValue); command.Parameters.AddWithValue("@fee" + j, feeFieldValue); } command.Parameters.AddWithValue("@date", entity.date); int i = command.ExecuteNonQuery(); mycn.Close(); mycn.Dispose(); return i; } }
/// <summary> /// 删除数据 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Delete(AgentDailyPerformance entity) { string sql = "DELETE FROM agent_daily_performance WHERE branchNo=@branchNo and date =@date"; using (MySqlConnection mycn = new MySqlConnection(mysqlConnection)) { mycn.Open(); MySqlCommand command = new MySqlCommand(sql, mycn); command.Parameters.AddWithValue("@branchNo", entity.branchNo); command.Parameters.AddWithValue("@date", entity.date); int i = command.ExecuteNonQuery(); mycn.Close(); mycn.Dispose(); return i; } }
/// <summary> /// 查询集合 /// </summary> /// <returns></returns> public AgentDailyPerformance GetByKey(String date, string branchNo,String type) { StringBuilder sb = new StringBuilder(); if (type.Contains("直供渠道") || type.Contains("非直供渠道")) { sb.Clear(); sb.Append("SELECT type, branchNo, branchName,agentNo,agentName,"); for (int i = 1; i <= 100; i++) { sb.Append("feeName").Append(i.ToString()).Append(",").Append("fee").Append(i.ToString()).Append(","); } sb.Append("date"); sb.Append(" FROM agent_daily_performance where date=@date"); sb.Append(" and branchNo= @branchNo "); } else { sb.Clear(); sb.Append("SELECT type, branchNo, branchName,agentNo,agentName,"); for (int i = 1; i <= 100; i++) { sb.Append("feeName").Append(i.ToString()).Append(",").Append("fee").Append(i.ToString()).Append(","); } sb.Append("date"); sb.Append(" FROM agent_daily_performance where date=@date"); sb.Append(" and agentNo= @branchNo "); } string sql = sb.ToString();// "SELECT agentNo, agentFeeSeq,feeName1,fee1,feeName2,fee2,feeName3,fee3,feeName4,fee4,feeTotal FROM agent_Fee"; using (MySqlConnection mycn = new MySqlConnection(mysqlConnection)) { mycn.Open(); MySqlCommand command = new MySqlCommand(sql, mycn); command.Parameters.AddWithValue("@branchNo", branchNo); command.Parameters.AddWithValue("@date", date); MySqlDataReader reader = command.ExecuteReader(); AgentDailyPerformance agentDailyPerformance = null; if (reader.Read()) { agentDailyPerformance = new AgentDailyPerformance(); agentDailyPerformance.type = reader["type"] == DBNull.Value ? null : reader["type"].ToString(); agentDailyPerformance.agentNo = reader["agentNo"] == DBNull.Value ? null : reader["agentNo"].ToString(); agentDailyPerformance.agentName = reader["agentName"] == DBNull.Value ? null : reader["agentName"].ToString(); agentDailyPerformance.branchNo = reader["branchNo"] == DBNull.Value ? null : reader["branchNo"].ToString(); agentDailyPerformance.branchName = reader["branchName"] == DBNull.Value ? null : reader["branchName"].ToString(); agentDailyPerformance.date = reader["date"] == DBNull.Value ? null : reader["date"].ToString(); for (int i = 1; i <= 100; i++) { FieldInfo feeNameField = agentDailyPerformance.GetType().GetField("feeName" + i); FieldInfo feeField = agentDailyPerformance.GetType().GetField("fee" + i); String feeNameFieldValue = reader["feeName"+i] == DBNull.Value ? null : reader["feeName"+i].ToString(); String feeFieldValue = reader["fee"+i] == DBNull.Value ? null : reader["fee"+i].ToString(); feeNameField.SetValue(agentDailyPerformance, feeNameFieldValue); feeField.SetValue(agentDailyPerformance, feeFieldValue); } } mycn.Close(); return agentDailyPerformance; } }
/// <summary> /// 查询集合 /// </summary> /// <returns></returns> public IList<AgentDailyPerformance> GetAllListDate(String agentNo, String type, String date) { StringBuilder sb = new StringBuilder(); if (type.Contains("直供渠道") || type.Contains("非直供渠道")) { sb.Clear(); sb.Append("SELECT distinct branchNo,branchName,date"); sb.Append(" FROM agent_daily_performance where branchNo = @branchNo "); } else { sb.Clear(); sb.Append("SELECT distinct agentNo,agentName,date"); sb.Append(" FROM agent_daily_performance where agentNo = @agentNo "); } if (!string.IsNullOrEmpty(date)) { sb.Append(" and date>=@date"); } sb.Append(" order by date desc"); string sql = sb.ToString();// "SELECT agentNo, agentFeeSeq,feeName1,fee1,feeName2,fee2,feeName3,fee3,feeName4,fee4,feeTotal FROM agent_Fee"; using (MySqlConnection mycn = new MySqlConnection(mysqlConnection)) { mycn.Open(); MySqlCommand command = new MySqlCommand(sql, mycn); if (type.Contains("直供渠道") || type.Contains("非直供渠道")) { command.Parameters.AddWithValue("@branchNo", agentNo); } else { command.Parameters.AddWithValue("@agentNo", agentNo); } command.Parameters.AddWithValue("@date", date); // command.Parameters.AddWithValue("@month", month); MySqlDataReader reader = command.ExecuteReader(); IList<AgentDailyPerformance> list = new List<AgentDailyPerformance>(); AgentDailyPerformance agentDailyPerformance = null; while (reader.Read()) { agentDailyPerformance = new AgentDailyPerformance(); if (type.Contains("直供渠道") || type.Contains("非直供渠道")) { agentDailyPerformance.branchNo = reader["branchNo"] == DBNull.Value ? null : reader["branchNo"].ToString(); agentDailyPerformance.branchName = reader["branchName"] == DBNull.Value ? null : reader["branchName"].ToString(); } else { agentDailyPerformance.agentNo = reader["agentNo"] == DBNull.Value ? null : reader["agentNo"].ToString(); agentDailyPerformance.agentName = reader["agentName"] == DBNull.Value ? null : reader["agentName"].ToString(); } agentDailyPerformance.date = reader["date"] == DBNull.Value ? null : reader["date"].ToString(); list.Add(agentDailyPerformance); } mycn.Close(); return list; } }
/// <summary> /// 查询集合 /// </summary> /// <returns></returns> public IList<AgentDailyPerformance> GetAllList(String date, String type) { StringBuilder sb = new StringBuilder(); sb.Append("SELECT type,branchNo, branchName,agentNo,agentName,"); for (int i = 1; i <= 100; i++) { sb.Append("feeName").Append(i.ToString()).Append(",").Append("fee").Append(i.ToString()).Append(","); } sb.Append("date"); sb.Append(" FROM agent_daily_performance where 1=1"); if (!String.IsNullOrEmpty(date)) { sb.Append(" and date = \"" + date + "\""); } if (!String.IsNullOrEmpty(type)) { sb.Append(" and type = \"" + type + "\""); } string sql = sb.ToString();// "SELECT agentNo, agentFeeSeq,feeName1,fee1,feeName2,fee2,feeName3,fee3,feeName4,fee4,feeTotal FROM agent_Fee"; using (MySqlConnection mycn = new MySqlConnection(mysqlConnection)) { mycn.Open(); MySqlCommand command = new MySqlCommand(sql, mycn); // command.Parameters.AddWithValue("@date", date); // command.Parameters.AddWithValue("@type", type); MySqlDataReader reader = command.ExecuteReader(); IList<AgentDailyPerformance> list = new List<AgentDailyPerformance>(); AgentDailyPerformance agentDailyPerformance = null; while (reader.Read()) { agentDailyPerformance = new AgentDailyPerformance(); agentDailyPerformance.type = reader["type"] == DBNull.Value ? null : reader["type"].ToString(); agentDailyPerformance.agentNo = reader["agentNo"] == DBNull.Value ? null : reader["agentNo"].ToString(); agentDailyPerformance.agentName = reader["agentName"] == DBNull.Value ? null : reader["agentName"].ToString(); agentDailyPerformance.branchNo = reader["branchNo"] == DBNull.Value ? null : reader["branchNo"].ToString(); agentDailyPerformance.branchName = reader["branchName"] == DBNull.Value ? null : reader["branchName"].ToString(); agentDailyPerformance.date = reader["date"] == DBNull.Value ? null : reader["date"].ToString(); for (int i = 1; i <= 100; i++) { FieldInfo feeNameField = agentDailyPerformance.GetType().GetField("feeName" + i); FieldInfo feeField = agentDailyPerformance.GetType().GetField("fee" + i); String feeNameFieldValue = reader["feeName" + i] == DBNull.Value ? null : reader["feeName" + i].ToString(); String feeFieldValue = reader["fee" + i] == DBNull.Value ? null : reader["fee" + i].ToString(); feeNameField.SetValue(agentDailyPerformance, feeNameFieldValue); feeField.SetValue(agentDailyPerformance, feeFieldValue); } list.Add(agentDailyPerformance); } mycn.Close(); return list; } }
private StringBuilder createNewsMessages(String feeDate, String agentNo, AgentDailyPerformance agentDailyPerformance, String type) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("<MsgType><![CDATA[news]]></MsgType>"); sb.AppendFormat("<ArticleCount>1</ArticleCount>"); sb.AppendFormat("<Articles>"); sb.AppendFormat("<item>"); sb.Append("<Title>").AppendFormat("{0}日业绩详情", feeDate).Append("</Title>"); StringBuilder sbDesc = new StringBuilder(); //sbDesc.AppendFormat("本月佣金告知单({0})", feeMonth); // sbDesc.AppendFormat("总共处理了:{0}次发票信息\n", agentMonthPerformanceList.Count); if (!String.IsNullOrEmpty(agentDailyPerformance.agentNo)) { sbDesc.AppendFormat("代理商编号:" + agentDailyPerformance.agentNo + "\n代理商名称:" + agentDailyPerformance.agentName).Append("\n"); } if (!String.IsNullOrEmpty(agentDailyPerformance.branchNo)) { sbDesc.AppendFormat("渠道编号:" + agentDailyPerformance.branchNo + "\n渠道名称:" + agentDailyPerformance.branchName).Append("\n"); } sbDesc.AppendLine().AppendFormat("\n业绩汇总明细:\n"); int i = 1; for (int j = 1; j <= 100; j++) { FieldInfo feeNameField = agentDailyPerformance.GetType().GetField("feeName" + j); FieldInfo feeField = agentDailyPerformance.GetType().GetField("fee" + j); if (feeNameField != null && feeField != null) { String feeNameFieldValue = feeNameField.GetValue(agentDailyPerformance) == null ? null : feeNameField.GetValue(agentDailyPerformance).ToString(); String feeFieldValue = feeField.GetValue(agentDailyPerformance) == null ? null : feeField.GetValue(agentDailyPerformance).ToString(); if (!String.IsNullOrEmpty(feeFieldValue) && !String.IsNullOrWhiteSpace(feeFieldValue)) { // sbDesc.Append(" ").Append(i++).AppendFormat(".{0}", feeNameFieldValue).Append(" ").AppendFormat("{0}\n", 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>"); 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(feeDate, 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; }
/// <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(); }