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