예제 #1
0
        private void btnSend_Click(object sender, EventArgs e)
        {

            if (this.txtContent.Text.Trim() == "")
            {
                MessageBox.Show("请输入公告内容");
                return;
            }
            this.Cursor = Cursors.WaitCursor;
            WechatAction wechatAction = new WechatAction();
            HttpResult result = wechatAction.sendTextMessageToWechat("@all", this.txtContent.Text.Trim(), Wechat_secretId, Wechar_AppId);
           this.Cursor = Cursors.Default; 
            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                //表示访问成功,具体的大家就参考HttpStatusCode类
                MessageBox.Show("发送成功");
                this.Close();
            }
            else
            {
                MessageBox.Show(result.StatusDescription);
            }
           
        }
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码
           

            worker.ReportProgress(1, "开始导入月度绩效...\r\n");

            //导入非直供
            AgentMonthPerformanceDao agentMonthPerformanceDao = new AgentMonthPerformanceDao();
            for (int i = 0; i < dgAgentPerformanceNoDirect.RowCount; i++)
            {
                AgentMonthPerformance agentMonthPerformance = new AgentMonthPerformance();
                agentMonthPerformance.month = this.dtMonth.Value.ToString("yyyy-MM");
                agentMonthPerformance.branchNo = dgAgentPerformanceNoDirect[0, i].Value.ToString();
                agentMonthPerformance.branchName = dgAgentPerformanceNoDirect[1, i].Value.ToString();
                int index = 4;

                agentMonthPerformance.agentNo = dgAgentPerformanceNoDirect[2, i].Value.ToString();
                agentMonthPerformance.agentName = dgAgentPerformanceNoDirect[3, i].Value.ToString();
                agentMonthPerformance.type = "非直供渠道";

                for (int j = index; j <= 101 && j < dgAgentPerformanceNoDirect.Columns.Count; j++)
                {

                    FieldInfo feeNameField = agentMonthPerformance.GetType().GetField("feeName" + (j - index + 1));
                    FieldInfo feeField = agentMonthPerformance.GetType().GetField("fee" + (j - index + 1));

                    String feeNameFieldValue = dgAgentPerformanceNoDirect.Columns[j].HeaderCell.Value.ToString();
                    String feeFieldValue = dgAgentPerformanceNoDirect[j, i].Value.ToString();
                    if (feeFieldValue.Trim().Equals("0") || String.IsNullOrWhiteSpace(feeFieldValue))
                    {
                        feeFieldValue = null;
                    }
                    feeNameField.SetValue(agentMonthPerformance, feeNameFieldValue);
                    feeField.SetValue(agentMonthPerformance, feeFieldValue);

                }

                agentMonthPerformanceDao.Delete(agentMonthPerformance);
                agentMonthPerformanceDao.Add(agentMonthPerformance);

            }


            //导入直供
            //AgentMonthPerformanceDao agentMonthPerformanceDao = new AgentMonthPerformanceDao();
            for (int i = 0; i < dgAgentPerformanceDirect.RowCount; i++)
            {
                AgentMonthPerformance agentMonthPerformance = new AgentMonthPerformance();
                agentMonthPerformance.type = "直供渠道";
                agentMonthPerformance.month = this.dtMonth.Value.ToString("yyyy-MM");
                agentMonthPerformance.branchNo = dgAgentPerformanceDirect[0, i].Value.ToString();
                agentMonthPerformance.branchName = dgAgentPerformanceDirect[1, i].Value.ToString();
                int index = 2;

                // agentMonthPerformance.agentNo = dgAgentPerformanceDirect[0, i].Value.ToString();
                //agentMonthPerformance.agentName = dgAgentPerformanceDirect[1, i].Value.ToString();



                for (int j = index; j <= 101 && j < dgAgentPerformanceDirect.Columns.Count; j++)
                {

                    FieldInfo feeNameField = agentMonthPerformance.GetType().GetField("feeName" + (j - index + 1));
                    FieldInfo feeField = agentMonthPerformance.GetType().GetField("fee" + (j - index + 1));

                    String feeNameFieldValue = dgAgentPerformanceDirect.Columns[j].HeaderCell.Value.ToString();
                    String feeFieldValue = dgAgentPerformanceDirect[j, i].Value.ToString();
                    if (feeFieldValue.Trim().Equals("0") || String.IsNullOrWhiteSpace(feeFieldValue))
                    {
                        feeFieldValue = null;
                    }
                    feeNameField.SetValue(agentMonthPerformance, feeNameFieldValue);
                    feeField.SetValue(agentMonthPerformance, feeFieldValue);

                }

                agentMonthPerformanceDao.Delete(agentMonthPerformance);
                agentMonthPerformanceDao.Add(agentMonthPerformance);

            }


            WechatAction wechatAction = new WechatAction();
            wechatAction.sendTextMessageToWechat("@all", this.dtMonth.Value.ToString("yyyy年MM月") + "业绩已发布,请通过底部菜单查询业绩详情", Settings.Default.Wechat_Secret, MyConstant.APP_Performace);


            //MessageBox.Show("数据上传完毕");

        }
예제 #3
0
        private void addTagUser(List<String> RightUserIds, int tagId)
        {
            WechatAction wechatAction = new WechatAction();
            List<String> rightUserIdsBuffer = new List<string>();
            for (int i = 1; i <= RightUserIds.Count; i++)
            {
                rightUserIdsBuffer.Add(RightUserIds[i - 1]);
                if (i % 300 == 0 || i == RightUserIds.Count)
                {
                    var userTagData = new
                    {
                        tagid = tagId,
                        userlist = rightUserIdsBuffer
                    };

                    string updateTagJson = JsonConvert.SerializeObject(userTagData, Formatting.Indented);                   
                   wechatAction.addTagUsers(Settings.Default.Wechat_Secret, updateTagJson);

                    rightUserIdsBuffer.Clear();
                }

            }
        }
예제 #4
0
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码

            worker.ReportProgress(1, "开始同步微信账号...\r\n");
         
            WechatAction wechatAction = new WechatAction();

            List<String> feeRightUserIdsAll = new List<string>();
            List<String> policyRightUserIdsAll = new List<string>();
            List<String> performanceRightUserIdsAll = new List<string>();
            List<String> studyRightUserIdsAll = new List<string>();
            List<String> complainRightUserIdsAll = new List<string>();
            List<String> monitorRightUserIdsAll = new List<string>();
            List<String> errorRightUserIdsAll = new List<string>();
            List<String> contactRightUserIdsAll = new List<string>();

            List<String> feeRightUserIds = new List<string>();
            List<String> policyRightUserIds = new List<string>();
            List<String> performanceRightUserIds = new List<string>();
            List<String> studyRightUserIds = new List<string>();
            List<String> complainRightUserIds = new List<string>();
            List<String> monitorRightUserIds = new List<string>();
            List<String> errorRightUserIds = new List<string>();
            List<String> contactRightUserIds = new List<string>();

            for (int i = 0; i < dgAgentWechatAccount.RowCount ; i++)
            {
                String userid = this.dgAgentWechatAccount[6, i].Value.ToString();
                feeRightUserIdsAll.Add(userid);
                policyRightUserIdsAll.Add(userid);
                performanceRightUserIdsAll.Add(userid);
                studyRightUserIdsAll.Add(userid);
                complainRightUserIdsAll.Add(userid);
                monitorRightUserIdsAll.Add(userid);
                errorRightUserIdsAll.Add(userid);
                contactRightUserIdsAll.Add(userid);

                

                if (this.dgAgentWechatAccount[12, i].Value.ToString().ToUpper().Equals("Y"))
                {
                    feeRightUserIds.Add(userid);
                }
                if (this.dgAgentWechatAccount[13, i].Value.ToString().ToUpper().Equals("Y"))
                {
                    policyRightUserIds.Add(userid);
                }
                if (this.dgAgentWechatAccount[14, i].Value.ToString().ToUpper().Equals("Y"))
                {
                    performanceRightUserIds.Add(userid);
                }
                if (this.dgAgentWechatAccount[15, i].Value.ToString().ToUpper().Equals("Y"))
                {
                    studyRightUserIds.Add(userid);
                }
                if (this.dgAgentWechatAccount[16, i].Value.ToString().ToUpper().Equals("Y"))
                {
                    complainRightUserIds.Add(userid);
                }
                if (this.dgAgentWechatAccount[17, i].Value.ToString().ToUpper().Equals("Y"))
                {
                    monitorRightUserIds.Add(userid);
                }
                if (this.dgAgentWechatAccount[18, i].Value.ToString().ToUpper().Equals("Y"))
                {
                    errorRightUserIds.Add(userid);
                }
                if (this.dgAgentWechatAccount[19, i].Value.ToString().ToUpper().Equals("Y"))
                {
                    contactRightUserIds.Add(userid);
                }
               
                WechatJsonUser wechatJsonUser = new WechatJsonUser();
                wechatJsonUser.userid = this.dgAgentWechatAccount[6, i].Value.ToString();
              
                wechatJsonUser.name = this.dgAgentWechatAccount[7, i].Value.ToString();
                if (string.IsNullOrEmpty(wechatJsonUser.name))
                {
                    wechatJsonUser.name = wechatJsonUser.userid;
                }
                wechatJsonUser.email = this.dgAgentWechatAccount[8, i].Value.ToString();
                wechatJsonUser.mobile = this.dgAgentWechatAccount[9, i].Value.ToString();
                wechatJsonUser.weixinid = this.dgAgentWechatAccount[10, i].Value.ToString();
                wechatJsonUser.position = this.dgAgentWechatAccount[4, i].Value.ToString();
                if (String.IsNullOrEmpty(wechatJsonUser.position))
                {
                    wechatJsonUser.position = this.dgAgentWechatAccount[1, i].Value.ToString();
                }
                wechatJsonUser.department = new List<int>();
               wechatJsonUser.department.Add(1);
               worker.ReportProgress(2, "总共" + dgAgentWechatAccount.RowCount + "条记录,正在处理第" + (i + 1) + "条,同步微信账号" + wechatJsonUser.userid + "\r\n");

               
                //Check the Wechat rule
                #region

                String mobile = wechatJsonUser.mobile;
                String weixinid = wechatJsonUser.weixinid;

                // ^[1]+[3,5,8]+\d{9}
                if (Regex.IsMatch(weixinid, @"^[1]+[3,5,8]+\d{9}"))
                {
                    mobile = weixinid;
                    weixinid = "";
                }
                else
                {
                    if (Regex.IsMatch(weixinid, @"^\d+$"))
                    {
                        weixinid = "QQ" + weixinid;
                        mobile = "";
                    }

                }



                #endregion


                var userData = new
                {
                    userid = wechatJsonUser.userid,
                    name = wechatJsonUser.name,
                    department = wechatJsonUser.department,
                    mobile = mobile,//wechatJsonUser.mobile,
                    email ="",// wechatJsonUser.email,
                    position = wechatJsonUser.position,
                    weixinid =weixinid// wechatJsonUser.weixinid
                };

                string InsertUserJson = JsonConvert.SerializeObject(userData, Formatting.Indented);

                HttpResult result = wechatAction.getUserFromWechat(wechatJsonUser.userid, Settings.Default.Wechat_Secret);
                if (result.StatusCode == System.Net.HttpStatusCode.OK)
                {
                  
                    //表示访问成功,具体的大家就参考HttpStatusCode类
                    WechatJsonUser wechatJsonUserFromWechat = JsonConvert.DeserializeObject<WechatJsonUser>(result.Html);
                    if (!String.IsNullOrEmpty(wechatJsonUserFromWechat.userid))
                    {
                        string updateUserJson = JsonConvert.SerializeObject(userData, Formatting.Indented);

                        // if (wechatJsonUser.department.Count == 0)
                        // {
                        //  result = wechatAction.deleteUserFromWechat(wechatJsonUser.userid, Settings.Default.Wechat_Secret);
                        // }
                        // else
                        // {
                        result = wechatAction.updateUserToWechat(Settings.Default.Wechat_Secret, updateUserJson);
                        if (!String.IsNullOrEmpty(wechatJsonUser.email))
                        {
                            //this.sendEmail(this.dgAgent[2, i].Value.ToString());
                        }
                        // }
                    }
                    else
                    {
                        result = wechatAction.addUserToWechat(Settings.Default.Wechat_Secret, InsertUserJson);
                        ReturnMessage returnMessage1 = (ReturnMessage)JsonConvert.DeserializeObject(result.Html, typeof(ReturnMessage));
                        if (returnMessage1 != null && returnMessage1.errcode.Equals("0"))
                        {
                            if (!String.IsNullOrEmpty(wechatJsonUser.email))
                            {
                                this.sendEmail(wechatJsonUser.email);
                            }
                        }
                        else
                        {
                            AgentWechatAccount agentWechatAccount = new ChinaUnion_BO.AgentWechatAccount();
                            agentWechatAccount.contactId = wechatJsonUser.userid;

                            agentWechatAccount.wechatImportStatus = returnMessage1.getErrorDescrition();
                            agentWechatAccountDao.UpdateWechatImportStatus(agentWechatAccount);
                        }
                    }



                    ReturnMessage returnMessage = (ReturnMessage)JsonConvert.DeserializeObject(result.Html, typeof(ReturnMessage));
                    if (returnMessage != null && returnMessage.errcode != "0")
                    {
                       

                        this.dgAgentWechatAccount[11, i].Value = returnMessage.getErrorDescrition();
                    }
                    else
                    {
                        var userInviteData = new
                        {
                            userid = wechatJsonUser.userid
                        };

                        string inviteUserJson = JsonConvert.SerializeObject(userInviteData, Formatting.Indented);

                        wechatAction.inviteUserToWechat(Settings.Default.Wechat_Secret, inviteUserJson);
                        this.dgAgentWechatAccount[11, i].Value = "同步成功";
                    }
                }



            }

            deleteTagUser(feeRightUserIdsAll, 2);
            addTagUser(feeRightUserIds, 2);

            deleteTagUser(policyRightUserIdsAll, 3);
            addTagUser(policyRightUserIds, 3);

            deleteTagUser(performanceRightUserIdsAll, 4);
            addTagUser(performanceRightUserIds, 4);

            deleteTagUser(studyRightUserIdsAll, 5);
            addTagUser(studyRightUserIds, 5);

            deleteTagUser(complainRightUserIdsAll, 6);
            addTagUser(complainRightUserIds, 6);

            deleteTagUser(monitorRightUserIdsAll, 7);
            addTagUser(monitorRightUserIds, 7);

            deleteTagUser(errorRightUserIdsAll, 8);
            addTagUser(errorRightUserIds, 8);

            deleteTagUser(contactRightUserIdsAll, 9);
            addTagUser(contactRightUserIds, 9);
           
           



            worker.ReportProgress(2, "同步微信账号完毕...\r\n");


        }
예제 #5
0
        private void btnPublish_Click(object sender, EventArgs e)
        {
            //this.btnSave_Click(sender, e);
          //  this.prepareGrid(this.txtSearchCondition.Text);
            if (String.IsNullOrEmpty(this.txtSequence.Text))
            {
                MessageBox.Show("请先保存,再发布");
                return;
            }
            this.Cursor = Cursors.WaitCursor;
            int appId = 0;
            switch (this.cbType.Text)
            {
                case "政策":
                    appId = MyConstant.APP_Notice;
                    break;
                case "通知公告/重点关注":
                    appId = MyConstant.APP_Notice;
                    break;
                case "服务规范":
                    appId = MyConstant.APP_Service_Monitor;
                    break;
            }

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

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

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

                        WechatAction wechatAction = new WechatAction();

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

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

                    }


                }

            }
              


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

                    WechatAction wechatAction = new WechatAction();

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

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

                }

              
            }
            this.Cursor = Cursors.Default;
            
        }
예제 #6
0
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                String client = Settings.Default.TripolisClient;
                String userName = Settings.Default.TripoisUserName;
                String password = Settings.Default.TripolisPassword;

                ChinaUnionAdapter mailAdapter = new ChinaUnionAdapter(client, userName, password, null);
                MailData mailData = new MailData();
                mailData.fromAddress = Settings.Default.MailFromAddress;
                mailData.replyAddress = Settings.Default.MailReplyAddress;
                mailData.sender = Settings.Default.MailSender;
                mailData.subject = this.subject;

                String databaseId = Settings.Default.TripolisDBId;
                String workspaceId = Settings.Default.TripolisWorkspaceId;
                String emailId = Settings.Default.TripolisDirectEmailId;
                worker.ReportProgress(1, "准备数据...\r\n");
                WechatAction wechatAction = new WechatAction();



               
               
                for (int i = 0; i < dgAgentFee.RowCount; i++)
                {
                    if (dgAgentFee[4, i].Value == null)
                    {
                        continue;
                    }
                    if (String.IsNullOrEmpty(dgAgentFee[4, i].Value.ToString()))
                    {
                        continue;
                    }

                    StringBuilder sb = new StringBuilder();

                    String url = String.Format(Settings.Default.Wechat_Message, dgAgentFee[0, i].Value.ToString(), this.dateTimePicker1.Value.ToString("yyyy-MM"));
                    wechatAction.sendTextMessageToWechat(dgAgentFee[0, i].Value.ToString(), this.feeMonth + url, Settings.Default.Wechat_Secret, Settings.Default.Wechat_Agent_AppId);

                    sb.Append("agent_no#").Append(dgAgentFee[0, i].Value == null ? "" : dgAgentFee[0, i].Value.ToString()).Append(",");
                    sb.Append("agent_name#").Append(dgAgentFee[1, i].Value == null ? "" : dgAgentFee[1, i].Value.ToString().Replace(",", "、").Replace("#", "%")).Append(",");
                    sb.Append("agent_type#").Append(dgAgentFee[2, i].Value == null ? "" : dgAgentFee[2, i].Value.ToString().Replace(",", "、").Replace("#", "%")).Append(",");
                    sb.Append("agent_type_comment#").Append(dgAgentFee[3, i].Value == null ? "" : dgAgentFee[3, i].Value.ToString().Replace(",","、").Replace("#","%")).Append(",");
                    sb.Append("email#").Append(dgAgentFee[4, i].Value == null ? "" : dgAgentFee[4, i].Value.ToString()).Append(",");
                    sb.Append("contact_name#").Append(dgAgentFee[5, i].Value == null ? "" : dgAgentFee[5, i].Value.ToString().Replace(",", "、").Replace("#", "%")).Append(",");
                    sb.Append("agent_fee_seq#").Append(dgAgentFee[6, i].Value == null ? "" : dgAgentFee[6, i].Value.ToString()).Append(",");
                    sb.Append("feemonth#").Append(this.feeMonth).Append(",");
                   
                    ///

                    Dictionary<String, Dictionary<String, String>> CategoryMap = new Dictionary<string, Dictionary<String, String>>();
                    //按结账科目分类
                    int rowIndex = i;
                    for (int j = 7; j < dgAgentFee.ColumnCount - 3; j++)
                    {

                        String headText = dgAgentFee.Columns[j].HeaderText;
                        int locationIndex = headText.IndexOf("-");
                        int endIndex = headText.IndexOf("(");
                        if (locationIndex == -1)
                        {
                            locationIndex = headText.IndexOf("-");
                        }
                        if (endIndex == -1)
                        {
                            endIndex = headText.IndexOf("(");
                        }
                        String key = dgAgentFee.Columns[j].HeaderText.Substring(locationIndex + 1);
                        if (endIndex != -1)
                        {
                            key = dgAgentFee.Columns[j].HeaderText.Substring(locationIndex + 1, endIndex - locationIndex - 1);
                        }
                        String value = dgAgentFee[j, rowIndex].Value == null ? "" : dgAgentFee[j, rowIndex].Value.ToString();
                        if (!CategoryMap.ContainsKey(key))
                        {
                            Dictionary<String, String> valueMap = new Dictionary<string, string>();
                            valueMap.Add(headText, value);
                            CategoryMap.Add(key, valueMap);
                        }
                        else
                        {
                            Dictionary<String, String> valueMap = CategoryMap[key];
                            valueMap.Add(headText, value);
                        }

                    }



                    //int index = 1;
                    int feeSeq = 1;
                    int seq = 1;
                    foreach (String itemKey in CategoryMap.Keys)
                    {
                      
                        Dictionary<String, String> valueMap = CategoryMap[itemKey];
                        float subTotal = 0;
                        foreach (String value in valueMap.Values)
                        {
                            if (!String.IsNullOrEmpty(value))
                            {
                                subTotal = subTotal + float.Parse(value);
                            }
                           
                        }
                        sb.Append("fee_seq").Append(feeSeq.ToString()).Append("#").Append("").Append(",");
                        sb.Append("fee_name").Append(feeSeq.ToString()).Append("#<b>").Append(itemKey.Replace(",", "、").Replace("#", "%")).Append("</b>,");
                        if (subTotal<=0)
                        {
                            sb.Append("fee").Append(feeSeq.ToString()).Append("#").Append("").Append(",");
                        }
                        else
                        {
                            sb.Append("fee").Append(feeSeq.ToString()).Append("#<b>").Append(subTotal).Append("</b>,");
                           
                        }
                        feeSeq++;

                        foreach (String subKey in valueMap.Keys)
                        {

                            sb.Append("fee_name").Append(feeSeq.ToString()).Append("#").Append(subKey.Replace(",", "、").Replace("#", "%")).Append(",");
                            if (String.IsNullOrEmpty(valueMap[subKey]) ||(!String.IsNullOrEmpty(valueMap[subKey]) && valueMap[subKey].Equals("0")))
                            {
                                sb.Append("fee_seq").Append(feeSeq.ToString()).Append("#").Append("").Append(",");
                                sb.Append("fee").Append(feeSeq.ToString()).Append("#").Append("").Append(",");
                            }
                            else
                            {
                                sb.Append("fee_seq").Append(feeSeq.ToString()).Append("#").Append(seq.ToString()).Append(",");
                                sb.Append("fee").Append(feeSeq.ToString()).Append("#").Append(valueMap[subKey]).Append(",");
                                seq++;
                            }
                           
                            feeSeq++;
                        }
                       
                    }




                    for (int j = feeSeq; j <= 101; j++)
                    {
                        sb.Append("fee_seq").Append(feeSeq.ToString()).Append("#").Append("").Append(",");
                        sb.Append("fee_name").Append(feeSeq.ToString()).Append("#").Append("").Append(",");
                        sb.Append("fee").Append(feeSeq.ToString()).Append("#").Append("").Append(",");
                        feeSeq++;
                    }

                    sb.Append("fee_total_seq").Append("#").Append(seq.ToString()).Append(",");
                    sb.Append("fee_total#").Append(dgAgentFee[dgAgentFee.Columns.Count - 3, i].Value.ToString()).Append(",");

                    seq++;
                    sb.Append("invoice_fee_seq").Append("#").Append(seq.ToString()).Append(",");
                    sb.Append("invoice_fee#").Append(dgAgentFee[dgAgentFee.Columns.Count - 2, i].Value.ToString()).Append(",");

                    seq++;
                    sb.Append("pre_invoice_fee_seq").Append("#").Append(seq.ToString()).Append(",");
                    sb.Append("pre_invoice_fee#").Append(dgAgentFee[dgAgentFee.Columns.Count - 1, i].Value.ToString());

                    mailData.ContactJsonList.Add(sb.ToString());

                    Cursor.Current = Cursors.Default;
                }

                worker.ReportProgress(2, "发送邮件...\r\n");
                String message = mailAdapter.sendBatchMail(databaseId, workspaceId, emailId, mailData, dateTimePicker1.Value);
                if (message.Contains("OK:"))
                {
                    String mailJobId = message.Substring(3);

                    MailJob mailJob = new MailJob();
                    mailJob.feeMonth = this.feeMonth;
                    mailJob.mailJobId = mailJobId;
                    mailJob.subject = mailData.subject;
                    if (dateTimePicker1.Value != null)
                    {
                        mailJob.sendTime = dateTimePicker1.Value.ToString("yyyy-MM-dd hh:mm:ss");
                    }

                    MailJobDao mailJobDao = new MailJobDao();
                    mailJobDao.Delete(mailJob);
                    mailJobDao.Add(mailJob);

                    MessageBox.Show("邮件发送成功");
                }
                else
                {
                    MessageBox.Show(message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //this.Close();
        }
예제 #7
0
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码

            worker.ReportProgress(1, "开始同步微信账号...\r\n");
         
            WechatAction wechatAction = new WechatAction();

            for (int i = 0; i < dgAgent.RowCount ; i++)
            {
                WechatJsonUser wechatJsonUser = new WechatJsonUser();
                wechatJsonUser.userid = this.dgAgent[0, i].Value.ToString();
                wechatJsonUser.name = this.dgAgent[1, i].Value.ToString();
                wechatJsonUser.email = this.dgAgent[2, i].Value.ToString();
                wechatJsonUser.mobile = this.dgAgent[3, i].Value.ToString();
                wechatJsonUser.weixinid = this.dgAgent[4, i].Value.ToString();
                wechatJsonUser.department = new List<int>();
                wechatJsonUser.department.Add(Settings.Default.Wechat_Agent_Department);
                worker.ReportProgress(2, "同步微信账号" + wechatJsonUser.userid + "\r\n");

                //Check the Wechat rule
                #region
                String email = "";
                String mobile = this.dgAgent[3, i].Value.ToString();
                String weixinid = this.dgAgent[4, i].Value.ToString();
              

               
                   // ^[1]+[3,5,8]+\d{9}
                    if (Regex.IsMatch(weixinid, @"^[1]+[3,5,8]+\d{9}"))
                    {
                        mobile = weixinid;
                        weixinid = "";
                    }
                    else
                    {
                        if (Regex.IsMatch(weixinid, @"^\d+$"))
                        {
                            weixinid = "QQ" + weixinid;
                            mobile = "";
                        }
                        else
                        {
                            mobile = "";
                        } 
                    }
                

               // this.dgAgent[2, i].Value = email;
               // this.dgAgent[3, i].Value = mobile;
               // this.dgAgent[4, i].Value = weixinid;

             

                   
                #endregion


                var userData = new
                {
                    userid = wechatJsonUser.userid,
                    name = wechatJsonUser.name,
                    department = wechatJsonUser.department,                    
                    mobile = mobile,
                    email = email,
                    weixinid = weixinid
                };

                string InsertUserJson = JsonConvert.SerializeObject(userData, Formatting.Indented);

                HttpResult result = wechatAction.getUserFromWechat(wechatJsonUser.userid, Settings.Default.Wechat_Secret);
                if (result.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    //表示访问成功,具体的大家就参考HttpStatusCode类
                    wechatJsonUser = JsonConvert.DeserializeObject<WechatJsonUser>(result.Html);
                    if (!String.IsNullOrEmpty(wechatJsonUser.userid))
                    {
                        if (this.dgAgent[5, i].Value.ToString().Equals("账号已经停用"))
                        {                          
                            wechatJsonUser.department.Remove(Settings.Default.Wechat_Agent_Department);                           
                        }
                        else
                        {
                            wechatJsonUser.department.Add(Settings.Default.Wechat_Agent_Department);                           
                        }
                        var updateUserData = new
                        {
                            userid = this.dgAgent[0, i].Value.ToString(),
                            name = this.dgAgent[1, i].Value.ToString(),
                            email = email,
                            mobile = mobile,
                            weixinid = weixinid,
                            department = wechatJsonUser.department
                        };

                        string updateUserJson = JsonConvert.SerializeObject(updateUserData, Formatting.Indented);

                        if (wechatJsonUser.department.Count == 0)
                        {
                            result = wechatAction.deleteUserFromWechat(wechatJsonUser.userid, Settings.Default.Wechat_Secret);
                        }
                        else
                        {
                            result = wechatAction.updateUserToWechat(Settings.Default.Wechat_Secret, updateUserJson);
                            if (!String.IsNullOrEmpty(this.dgAgent[2, i].Value.ToString()))
                            {
                              //this.sendEmail(this.dgAgent[2, i].Value.ToString());
                            }
                        }
                    }
                    else
                    {
                        result = wechatAction.addUserToWechat(Settings.Default.Wechat_Secret, InsertUserJson);
                        ReturnMessage returnMessage1 = (ReturnMessage)JsonConvert.DeserializeObject(result.Html, typeof(ReturnMessage));
                        if (returnMessage1 != null && returnMessage1.errcode .Equals( "0") && !String.IsNullOrEmpty(this.dgAgent[2, i].Value.ToString()))
                        {
                          this.sendEmail(this.dgAgent[2, i].Value.ToString());
                        }
                    }
                    ReturnMessage returnMessage = (ReturnMessage)JsonConvert.DeserializeObject(result.Html, typeof(ReturnMessage));
                    if (returnMessage != null && returnMessage.errcode != "0")
                    {
                        this.dgAgent[6, i].Value = returnMessage.getErrorDescrition();
                    }
                    else
                    {
                        this.dgAgent[6, i].Value = "同步成功";
                    }
                }

            }



            worker.ReportProgress(2, "同步微信账号完毕...\r\n");


        }
예제 #8
0
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码
           

            worker.ReportProgress(1, "开始导入代理商佣金...\r\n");

            //导入代理商佣金
            AgentFeeDao agentFeeDao = new AgentFeeDao();
            for (int i = 0; i < dgAgentFee.RowCount; i++)
            {
                AgentFee agentFee = new AgentFee();
                agentFee.agentFeeMonth = this.dtFeeMonth.Value.ToString("yyyy-MM");
                agentFee.agentNo = dgAgentFee[0, i].Value.ToString();
                agentFee.agentName= dgAgentFee[1, i].Value.ToString();
                agentFee.agentFeeSeq = agentFee.agentNo + this.dtFeeMonth.Value.ToString("yyyyMM") + String.Format("{0:D5}", i+1);
                agentFee.feeTotal = dgAgentFee[dgAgentFee.Columns.Count - 3, i].Value.ToString();
                agentFee.invoiceFee = dgAgentFee[dgAgentFee.Columns.Count - 2, i].Value.ToString();
                agentFee.preInvoiceFee = dgAgentFee[dgAgentFee.Columns.Count - 1, i].Value.ToString();

                for (int j = 2; j <= 101 && j < dgAgentFee.Columns.Count-3; j++)
                {

                    FieldInfo feeNameField = agentFee.GetType().GetField("feeName" + (j-1));
                    FieldInfo feeField = agentFee.GetType().GetField("fee" + (j-1));

                    String feeNameFieldValue = dgAgentFee.Columns[j].HeaderCell.Value.ToString();
                    String feeFieldValue = dgAgentFee[j, i].Value.ToString();
                    if (feeFieldValue.Trim().Equals("0") || String.IsNullOrWhiteSpace(feeFieldValue))
                    {
                        feeFieldValue = null;
                    }
                    feeNameField.SetValue(agentFee, feeNameFieldValue);
                    feeField.SetValue(agentFee, feeFieldValue);

                }

                agentFeeDao.Delete(agentFee);
                agentFeeDao.Add(agentFee);

            }
            WechatAction wechatAction = new WechatAction();
            wechatAction.sendTextMessageToWechat("@all", this.dtFeeMonth.Value.ToString("yyyy年MM月") + "佣金已发布,请通过底部菜单查询佣金详情", Settings.Default.Wechat_Secret, MyConstant.APP_Payment);

            worker.ReportProgress(2, "导入代理商佣金完成...\r\n");
           
           

            //MessageBox.Show("数据上传完毕");

        }
예제 #9
0
        private void prepareGrid(string keyword, String type,bool isUnsync)
        {
            this.Cursor = Cursors.WaitCursor;
            if (type.Equals("全部"))
            {
                type = "";
            }
            WechatAction  wechatAction = new WechatAction();
            AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();

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

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

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

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

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

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

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


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

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

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



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

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

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


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

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

                dgAgentWechatAccount.AutoResizeColumns();

            }


            this.Cursor = Cursors.Default;

        }
예제 #10
0
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码


           


            worker.ReportProgress(3, "开始导入支付记录...\r\n");
            //导入代理商
            InvoicePaymentDao agentInvoicePaymentDao = new InvoicePaymentDao();
            AgentDao agentDao = new AgentDao();
            WechatAction wechatAction = new WechatAction();
            for (int i = 0; i < dgInvoicePayment.RowCount; i++)
            {
                InvoicePayment agentInvoicePayment = new InvoicePayment();
                agentInvoicePayment.month = dgInvoicePayment[0, i].Value.ToString();
                agentInvoicePayment.receivedTime = dgInvoicePayment[1, i].Value.ToString();
                agentInvoicePayment.processTime = dgInvoicePayment[2, i].Value.ToString();
                agentInvoicePayment.agentNo = dgInvoicePayment[3, i].Value.ToString();
                agentInvoicePayment.agentName = dgInvoicePayment[4, i].Value.ToString();
                agentInvoicePayment.content = dgInvoicePayment[5, i].Value.ToString();
                agentInvoicePayment.invoiceFee = dgInvoicePayment[6, i].Value.ToString();

                agentInvoicePayment.invoiceType = dgInvoicePayment[7, i].Value.ToString();
                agentInvoicePayment.invoiceNo = dgInvoicePayment[8, i].Value.ToString();
                agentInvoicePayment.payStatus = dgInvoicePayment[9, i].Value.ToString();

                agentInvoicePaymentDao.Delete(agentInvoicePayment);
                agentInvoicePaymentDao.Add(agentInvoicePayment);
                dgInvoicePayment["result", i].Value = "导入成功";


            }
            worker.ReportProgress(4, "导入支付记录完成...\r\n");
            
            wechatAction.sendTextMessageToWechat("@all", "结算支付信息已发布,请通过底部菜单查询结算支付详情", Settings.Default.Wechat_Secret, MyConstant.APP_Payment);



            //MessageBox.Show("数据上传完毕");

        }
예제 #11
0
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码


            worker.ReportProgress(1, "开始导入代理商联系人...\r\n");

         
            
            //导入代理商
            AgentContactDao agentContactDao = new AgentContactDao();
            for (int i = 0; i < dgAgentContact.RowCount; i++)
            {
                AgentContact agentContact = new AgentContact();
                agentContact.agentNo = dgAgentContact[0, i].Value.ToString();
                agentContact.agentName = dgAgentContact[1, i].Value.ToString();
                agentContact.branchNo = dgAgentContact[2, i].Value.ToString();
                agentContact.branchName = dgAgentContact[3, i].Value.ToString();
                agentContact.area = dgAgentContact[4, i].Value.ToString();
                agentContact.zone = dgAgentContact[5, i].Value.ToString();


                agentContact.contactName = dgAgentContact[6, i].Value.ToString().Replace(";",";");
                agentContact.contactTel = dgAgentContact[7, i].Value.ToString().Replace(";", ";");
                agentContact.contactEmail = dgAgentContact[8, i].Value.ToString().Replace(";", ";");

                String[] contactNames = agentContact.contactName.Split(';');
                String[] contactTels = agentContact.contactTel.Split(';');
                String[] contactEmails = agentContact.contactEmail.Split(';');
                for (int j = 0; j < contactNames.Length; j++)
                {
                    String contactName = contactNames[j];
                    agentContactDao.Delete(agentContact.agentNo.Trim(), agentContact.branchNo.Trim(), contactName);
                    agentContact.contactName = contactName;

                    if (contactTels.Length >= j + 1)
                    {
                        agentContact.contactTel = contactTels[j];
                    }
                    else
                    {
                        agentContact.contactTel = "";
                    }
                    if (contactEmails.Length >= j + 1)
                    {
                        agentContact.contactEmail = contactEmails[j];
                    }
                    else
                    {
                        agentContact.contactEmail = "";
                    }
                    agentContactDao.Add(agentContact);
                }

            }
            worker.ReportProgress(4, "导入代理商联系人完成...\r\n");

            WechatAction wechatAction = new WechatAction();
            wechatAction.sendTextMessageToWechat("@all", "最新渠道经理信息已发布,请通过底部菜单联系最新渠道经理", Settings.Default.Wechat_Secret, MyConstant.APP_Contact);


            //MessageBox.Show("数据上传完毕");

        }
예제 #12
0
        private void sendMessage(int agentId, IList<String> recieveList)
        {
            
            WechatAction wechatAction = new WechatAction();
            if (recieveList == null || recieveList.Count <= 0)
            {
                HttpResult result = wechatAction.sendTextMessageToWechat("@all", this.txtContent.Text.Trim(), Wechat_secretId, agentId);
            }
            else
            {

                //var result1 = recieveList.GroupBy(i => int.Parse(i) % 10).Select(g => g.ToList()).ToList();

                

                 List<String> userIdsBuffer = new List<string>();
                 for (int i = 1; i <= recieveList.Count; i++)
                 {
                     userIdsBuffer.Add(recieveList[i - 1]);
                     if (i % 500 == 0 || i == recieveList.Count)
                     {
                         string userId = "";
                         userId = string.Join("|", userIdsBuffer.ToArray());
                         userIdsBuffer.Clear();
                         HttpResult result = wechatAction.sendTextMessageToWechat(userId, this.txtContent.Text.Trim(), Wechat_secretId, agentId);

                         
                     }
                 }
              
              

            }
                this.Cursor = Cursors.Default;
         
        }
예제 #13
0
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码

            worker.ReportProgress(3, "开始导入发票信息...\r\n");
            //导入代理商
            WechatAction wechatAction = new WechatAction();
            AgentInvoiceDao agentInvoiceDao = new AgentInvoiceDao();
            AgentDao agentDao = new AgentDao();
            for (int i = 0; i < dgInvoice.RowCount; i++)
            {
                AgentInvoice agentInvoice = new AgentInvoice();
                agentInvoice.invoiceMonth = dgInvoice[0, i].Value.ToString();
                agentInvoice.invoiceDate = DateTime.Parse( dgInvoice[1, i].Value.ToString()).ToString("yyyy-MM-dd");
                agentInvoice.agentNo = dgInvoice[2, i].Value.ToString();
                agentInvoice.agentName = dgInvoice[3, i].Value.ToString();
                agentInvoice.invoiceContent = dgInvoice[4, i].Value.ToString();               
                agentInvoice.invoiceFee = dgInvoice[5, i].Value.ToString();
                agentInvoice.invoiceType = dgInvoice[6, i].Value.ToString();
                agentInvoice.invoiceNo = dgInvoice[7, i].Value.ToString();
                agentInvoice.comment = dgInvoice[8, i].Value.ToString();

                Agent agent = agentDao.Get(agentInvoice.agentNo);
                if (agent != null && !String.IsNullOrEmpty(agent.agentName))
                {
                    agentInvoiceDao.Delete(agentInvoice);
                    agentInvoiceDao.Add(agentInvoice);
                    dgInvoice["result", i].Value = "导入成功";

                   String message = String.Format(Settings.Default.Invoice_Wechat_Message, agentInvoice.invoiceDate, agentInvoice.invoiceContent, agentInvoice.invoiceFee, agentInvoice.invoiceType, agentInvoice.invoiceNo,agentInvoice.comment);
                   wechatAction.sendTextMessageToWechat(agentInvoice.agentNo, message, Settings.Default.Wechat_Secret, Settings.Default.Wechar_Invoice_AppId);

                }
                else
                {
                    dgInvoice["result", i].Value = "导入失败,代理商编号:" + agentInvoice.agentNo+"不存在,请先导入代理商.";
                }

            }
            //dgInvoice.AutoResizeColumns();
            
            worker.ReportProgress(4, "导入发票信息完成...\r\n");



            //MessageBox.Show("数据上传完毕");

        }
예제 #14
0
               /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码
            Cursor.Current = Cursors.WaitCursor;
            if (dgAgentFee.RowCount <= 0)
            {
                return;
            }

            try{
             MailData mailData = new MailData();


            StringBuilder sbAgent = new StringBuilder();

            worker.ReportProgress(1, "准备数据...\r\n");
            WechatAction wechatAction = new WechatAction();
            for (int i = 0; i < dgAgentFee.RowCount; i++)
            {
                if (dgAgentFee[4, i].Value == null)
                {
                    continue;
                }
                if (String.IsNullOrEmpty(dgAgentFee[4, i].Value.ToString()))
                {
                    continue;
                }
                StringBuilder sb = new StringBuilder();
                String url = String.Format(Settings.Default.Wechat_Message, dgAgentFee[0, i].Value.ToString(), feeMonth);
                wechatAction.sendTextMessageToWechat(dgAgentFee[0, i].Value.ToString(), feeMonth + url, Settings.Default.Wechat_Secret, Settings.Default.Wechat_Agent_AppId);

                sb.Append("agent_no#").Append(dgAgentFee[0, i].Value == null ? "" : dgAgentFee[0, i].Value.ToString()).Append(",");
                sb.Append("agent_name#").Append(dgAgentFee[1, i].Value == null ? "" : dgAgentFee[1, i].Value.ToString().Replace(",", "、").Replace("#", "%")).Append(",");
                sb.Append("agent_type#").Append(dgAgentFee[2, i].Value == null ? "" : dgAgentFee[2, i].Value.ToString().Replace(",", "、").Replace("#", "%")).Append(",");
                sb.Append("agent_type_comment#").Append(dgAgentFee[3, i].Value == null ? "" : dgAgentFee[3, i].Value.ToString().Replace(",", "、").Replace("#", "%")).Append(",");
                sb.Append("email#").Append(dgAgentFee[4, i].Value == null ? "" : dgAgentFee[4, i].Value.ToString());

                mailData.ContactJsonList.Add(sb.ToString());
            }

            String client = Settings.Default.TripolisClient;
            String userName = Settings.Default.TripoisUserName;
            String password = Settings.Default.TripolisPassword;


            mailData.fromAddress = Settings.Default.MailFromAddress;
            mailData.replyAddress = Settings.Default.MailReplyAddress;
            mailData.sender = Settings.Default.MailSender;
            mailData.subject = this.subject;
            ChinaUnionAdapter mailAdapter = new ChinaUnionAdapter(client, userName, password, null);
            String databaseId = Settings.Default.TripolisDBId;
            String workspaceId = Settings.Default.TripolisWorkspaceId;
            String emailId = Settings.Default.TripolisDirectEmailId;
            worker.ReportProgress(1, "发送邮件...\r\n");
            String message = mailAdapter.sendBatchMail(databaseId, workspaceId, emailId, mailData, this.dtFeeMonth.Value);
            if (message.Contains("OK:"))
            {
                String mailJobId = message.Substring(3);

                MailJob mailJob = new MailJob();
                mailJob.feeMonth = feeMonth;
                mailJob.mailJobId = mailJobId;
                mailJob.subject = mailData.subject;

                mailJob.sendTime = this.dtFeeMonth.Value.ToString("yyyy-MM-dd hh:mm:ss");


                MailJobDao mailJobDao = new MailJobDao();
                mailJobDao.Delete(mailJob);
                mailJobDao.Add(mailJob);

             //  WechatAction wechatAction = new WechatAction();
              //  wechatAction.sendMessageToWechat("@all",this.dtFeeMonth.Value.ToString("yyyy-MM") + Settings.Default.Wechat_Message);
                MessageBox.Show("邮件重新发送成功");

            }
            else
            {
                MessageBox.Show(message);
            }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
예제 #15
0
        private void btnPublish_Click(object sender, EventArgs e)
        {
            //this.btnSave_Click(sender, e);
          //  this.prepareGrid(this.txtSearchCondition.Text);
            if (String.IsNullOrEmpty(this.txtSequence.Text))
            {
                MessageBox.Show("请先保存,再发布");
                return;
            }
            this.Cursor = Cursors.WaitCursor;
            int appId = 0;

            IList<String> UserIdList = new List<String>();//agentComplainDao.GetAllAgentNoListBySeq(this.txtSequence.Text);

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

                    WechatAction wechatAction = new WechatAction();

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

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

                }

              
            }
            this.Cursor = Cursors.Default;
            
        }
예제 #16
0
        private void prepareGrid(String condition)
        {

            WechatAction wechatAction = new WechatAction();
            int department = Settings.Default.Wechat_Error_Department;
            if (wechatType.Equals("ErrorCode"))
            {
                department = Settings.Default.Wechat_Error_Department;
            }
            if (wechatType.Equals("Agent"))
            {
                department = Settings.Default.Wechat_Agent_Department;
            }
            WechatUser wechatUser = wechatAction.getUserFromWechatByDepartment(department, Settings.Default.Wechat_Secret);

            if (wechatUser != null && wechatUser.userlist !=null&& wechatUser.userlist.Count > 0)
            {
                this.grpWechatList.Text = "微信用户列表(" + wechatUser.userlist.Count + ")";
                this.dgWechat.Rows.Clear();
                dgWechat.Columns.Clear();
                if (wechatType.Equals("ErrorCode"))
                {
                    dgWechat.Columns.Add("渠道名称", "渠道名称");
                    dgWechat.Columns.Add("门店联系人", "门店联系人");
                }
                if (wechatType.Equals("Agent"))
                {
                    dgWechat.Columns.Add("代理商编号", "代理商编号");
                    dgWechat.Columns.Add("代理商名称", "代理商名称");
                    
                }
                dgWechat.Columns.Add("微信号", "微信号");
                dgWechat.Columns.Add("手机", "手机");
                dgWechat.Columns.Add("邮箱", "邮箱");
                dgWechat.Columns.Add("是否关注", "是否关注"); 


                for (int i = 0; i < wechatUser.userlist.Count; i++)
                {    
                    HttpResult result = wechatAction.getUserFromWechat(wechatUser.userlist[i].userid, Settings.Default.Wechat_Secret);
                    if (result.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        //表示访问成功,具体的大家就参考HttpStatusCode类
                        try
                        {
                            WechatJsonUser wechatJsonUser = JsonConvert.DeserializeObject<WechatJsonUser>(result.Html);
                            bool isExist = false;

                            if (wechatType.Equals("ErrorCode"))
                            {
                                if (wechatJsonUser.position.Contains(condition) || String.IsNullOrEmpty(condition))
                                {
                                    isExist = true;
                                }
                            }
                            if (wechatType.Equals("Agent"))
                            {
                                if (wechatJsonUser.name.Contains(condition) || String.IsNullOrEmpty(condition))
                                {
                                    isExist = true;
                                }

                            }

                            if (isExist)
                            {
                                dgWechat.Rows.Add();
                                DataGridViewRow row = dgWechat.Rows[dgWechat.RowCount - 1];
                                if (wechatType.Equals("ErrorCode"))
                                {
                                    row.Cells[0].Value = wechatJsonUser.position;
                                    row.Cells[1].Value = wechatJsonUser.name;
                                }
                                if (wechatType.Equals("Agent"))
                                {
                                    row.Cells[0].Value = wechatJsonUser.userid;
                                    row.Cells[1].Value = wechatJsonUser.name;
                                }
                                row.Cells[2].Value = wechatJsonUser.weixinid;
                                row.Cells[3].Value = wechatJsonUser.mobile;
                                row.Cells[4].Value = wechatJsonUser.email;

                                if (wechatJsonUser.status == "1")
                                {

                                    row.Cells[5].Value = "已关注";
                                }
                                if (wechatJsonUser.status == "2")
                                {

                                    row.Cells[5].Value = "已冻结";
                                }
                                if (wechatJsonUser.status == "4")
                                {

                                    row.Cells[5].Value = "未关注";
                                }
                            }

                        }
                        catch (Exception ex)
                        {
                            String exr = ex.Message;
                        }
                    }

                }


            }
            dgWechat.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;// (DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);

            dgWechat.AutoResizeColumns();

        }
예제 #17
0
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码


            worker.ReportProgress(1, "开始导入红包...\r\n");



            AgentBonusDao agentBonusDao = new AgentBonusDao();
            for (int i = 0; i < dgAgentBonus.RowCount; i++)
            {
                AgentBonus agentBonus = new AgentBonus();
                agentBonus.month = this.dtFeeMonth.Value.ToString("yyyyMM");



                agentBonus.agentNo = dgAgentBonus[0, i].Value.ToString();
                agentBonus.agentName = dgAgentBonus[1, i].Value.ToString();

                int index = 2;
                for (int j = index; j <= 101 && j < dgAgentBonus.Columns.Count; j++)
                {

                    FieldInfo feeNameField = agentBonus.GetType().GetField("feeName" + (j - index + 1));
                    FieldInfo feeField = agentBonus.GetType().GetField("fee" + (j - index + 1));

                    String feeNameFieldValue = dgAgentBonus.Columns[j].HeaderCell.Value.ToString();
                    String feeFieldValue = dgAgentBonus[j, i].Value.ToString();
                    if (feeFieldValue.Trim().Equals("0") || String.IsNullOrWhiteSpace(feeFieldValue))
                    {
                        feeFieldValue = null;
                    }
                    feeNameField.SetValue(agentBonus, feeNameFieldValue);
                    feeField.SetValue(agentBonus, feeFieldValue);

                }

                agentBonusDao.Delete(agentBonus);
                agentBonusDao.Add(agentBonus);

            }
            worker.ReportProgress(4, "导入红包完成...\r\n");

            WechatAction wechatAction = new WechatAction();
            wechatAction.sendTextMessageToWechat("@all", this.dtFeeMonth.Value.ToString("yyyy年MM月") + "红包已发布,请通过底部菜单查询红包详情", Settings.Default.Wechat_Secret, MyConstant.APP_Payment);


            //MessageBox.Show("数据上传完毕");

        }
예제 #18
0
        private void btnSave_Click(object sender, EventArgs e)
        {

            if (String.IsNullOrEmpty(this.txtReplyContent.Text.Trim()))
            {
                MessageBox.Show("请输入回复内容!");
                this.txtSubject.Focus();
                return;
            }


            this.Cursor = Cursors.WaitCursor;
            AgentComplianSuggestionDao agentComplianSuggestionDao = new ChinaUnion_DataAccess.AgentComplianSuggestionDao();
            AgentComplianSuggestion agentComplianSuggestion = new AgentComplianSuggestion();

            agentComplianSuggestion.subject = this.txtSubject.Text;
            agentComplianSuggestion.content = this.txtContent.Text;
            agentComplianSuggestion.sequence = Int32.Parse(this.txtSequence.Text);
            agentComplianSuggestion.type = this.txtType.Text;



            agentComplianSuggestion.userId = this.txtUserId.Text;
            agentComplianSuggestion.agentNo = this.txtAgent.Text;
            agentComplianSuggestion.createTime = this.txtCreatetime.Text;
            agentComplianSuggestion.agentReadtime = this.txtReadtime.Text;



            agentComplianSuggestion.ownerDepartment = this.txtOnwerDepartment.Text;
            agentComplianSuggestion.ownerReplyContent = this.txtOwnerReply.Text;
            agentComplianSuggestion.checkStatus = this.txtCheckStatus.Text;
            agentComplianSuggestion.replyContent = this.txtReplyContent.Text;
            agentComplianSuggestion.replyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            agentComplianSuggestionDao.update(agentComplianSuggestion);


            WechatAction wechatAction = new WechatAction();
            wechatAction.sendTextMessageToWechat(agentComplianSuggestion.userId, "针对您" + agentComplianSuggestion.type + "的:[" + agentComplianSuggestion.subject + "],反馈如下:\n" + agentComplianSuggestion.replyContent + " \n\n<a href=\"http://112.64.17.80/Wechat/OnlineComplainSuggestionDetail.aspx?seq=" + agentComplianSuggestion.sequence + "&from=OIC\">点击查询详情</a>", Settings.Default.Wechat_Secret, MyConstant.APP_Service_Monitor);



            prepareGrid(this.txtSearchCondition.Text.Trim(), this.cboType.Text, this.txtAgentNoSearch.Text.Trim());

            MessageBox.Show("操作完成");

            this.Cursor = Cursors.Default;
        }
예제 #19
0
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码


           


            worker.ReportProgress(3, "开始导入支付记录...\r\n");
            //导入代理商
            AgentInvoicePaymentDao agentInvoicePaymentDao = new AgentInvoicePaymentDao();
            AgentDao agentDao = new AgentDao();
            WechatAction wechatAction = new WechatAction();
            for (int i = 0; i < dgInvoicePayment.RowCount; i++)
            {
                AgentInvoicePayment agentInvoicePayment = new AgentInvoicePayment();
                agentInvoicePayment.agentNo = dgInvoicePayment[0, i].Value.ToString();
                agentInvoicePayment.agentName = dgInvoicePayment[1, i].Value.ToString();
                agentInvoicePayment.processTime = dgInvoicePayment[2, i].Value.ToString();
                agentInvoicePayment.invoiceFee = dgInvoicePayment[3, i].Value.ToString();
                agentInvoicePayment.payFee = dgInvoicePayment[4, i].Value.ToString();
                agentInvoicePayment.summary = dgInvoicePayment[5, i].Value.ToString();
                agentInvoicePayment.payStatus = dgInvoicePayment[6, i].Value.ToString();
                Agent agent = agentDao.Get(agentInvoicePayment.agentNo);
                 if (agent != null && !String.IsNullOrEmpty(agent.agentName))
                 {
                     agentInvoicePaymentDao.Delete(agentInvoicePayment);
                     agentInvoicePaymentDao.Add(agentInvoicePayment);
                     dgInvoicePayment["result", i].Value = "导入成功";
                     String message = String.Format(Settings.Default.InvoicePayment_Wechat_Message, agentInvoicePayment.processTime, agentInvoicePayment.invoiceFee, agentInvoicePayment.payFee, agentInvoicePayment.summary, agentInvoicePayment.payStatus);
                     wechatAction.sendTextMessageToWechat(agentInvoicePayment.agentNo, message, Settings.Default.Wechat_Secret, Settings.Default.Wechar_Invoice_AppId);

                 }
                 else
                 {
                     dgInvoicePayment["result", i].Value = "导入失败,代理商编号:" + agentInvoicePayment.agentNo + "不存在,请先导入代理商.";
                 }

            }
            worker.ReportProgress(4, "导入支付记录完成...\r\n");



            //MessageBox.Show("数据上传完毕");

        }