예제 #1
0
        private void sCB_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.Dispatcher.Invoke((Action)(delegate()   //等待结束
            {
                dGroup.Clear();
                //ObservableCollection<WxGroup> dGroups = new ObservableCollection<WxGroup>();
                Dictionary <string, string> dGroups = new Dictionary <string, string>();
                Dictionary <string, string> GroupsMembers = new Dictionary <string, string>();
                WxContact wxc = new WxContact(uin);
                foreach (var gm in wxc.GetGroupMemberNames(sCB.SelectedValue.ToString()).MemberUserNames)
                {
                    GroupsMembers.Add(gm.UserName, gm.NickName);
                }
                smCB.ItemsSource = GroupsMembers;
                //smCB.DisplayMemberPath = "Value";
                //smCB.SelectedValue = "Key";

                foreach (var g in wxc.GetGroupUserNames())
                {
                    if (g != sCB.SelectedValue.ToString())
                    {
                        dGroups.Add(wxc.GetOnLineGroupMember(g).UserName, wxc.GetOnLineGroupMember(g).NickName);
                    }

                    //dGroups.Add(new WxGroup { NickName = g, });
                }
                dCB.ItemsSource = dGroups;
                dCB.DisplayMemberPath = "Value";
                dCB.SelectedValuePath = "Key";
                //dLV.ItemsSource = dGroups;
            }));
        }
예제 #2
0
        public SendMsg MakeContent(WXMsg msg)
        {
            WxContact contact = new WxContact(msg.Uin);
            //需要更新群内成员信息
            var currMember = contact.GetOnLineGroupMember(msg.From);

            contact.Add(msg.From, currMember); //更新群内联系人信息
            SendMsg m = new SendMsg();

            m.context = "云客服提醒:呼呼,貌似有人退群了.....";
            m.type    = 1;
            return(m);
        }
        private void GetContactCallBack(WxContact getcontact)
        {
            foreach (User user in getcontact.MemberList)
            {
                user.SetDisplayName();
                CurrentUser.ContactTable.Add(user.UserName, user);
            }

            if (getcontact.BaseResponse.Ret != 0)
            {
                MessageBox.Show("获取通讯录失败,webwxgetcontact.BaseResponse.Ret:"
                                + getcontact.BaseResponse.Ret, "错误",
                                MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
예제 #4
0
        public SendMsg MakeContent(WXMsg msg)
        {
            SendMsg m = new SendMsg();

            m.type    = 1;
            m.context = string.Empty;
            WxContact contact = new WxContact(msg.Uin);

            var plus = new CharLogicContext(contact, msg);

            if (plus != null)
            {
                m = plus.Create().MakeLogic();
            }
            return(m);
        }
예제 #5
0
        /// <summary>
        /// 接收消息
        /// </summary>
        /// <param name="msg"></param>
        void wt_OnRevice(WXMsg msg)
        {
            try
            {
                WxContact c   = new WxContact(msg.Uin);
                string    log = "type:" + msg.Type.ToString() + "来源:" + msg.From + "[ " + c.GetNickName(msg.From) + "],发至:" + msg.To + " [" + c.GetNickName(msg.To) + "]" + msg.Msg;
                WriteLog(log);
                var m           = ReplyFactory.Create(msg).MakeContent(msg);
                var sendContext = m.context;
                if (!string.IsNullOrEmpty(sendContext))
                {
                    WXService s = new WXService();
                    s.Sid = msg.Sid;
                    s.Uin = msg.Uin;
                    s.SendMsg(sendContext, msg.To, msg.From, m.type, msg.Uin, msg.Sid);
                }
                //string afTitle = "[ " + c.GetNickName(msg.From) + "]回复[" + c.GetNickName(msg.To) + "]" + "一条消息";
                //string afContent = msg.Msg;
                //YUNkefu.AlertForm.ShowWay showWay = YUNkefu.AlertForm.ShowWay.UpDown;
                //int afShowInTime, afShowTime, afShowOutTime;
                //int afWidth, afHeigth;
                //int.TryParse("100", out afShowInTime);
                //int.TryParse("500", out afShowTime);
                //int.TryParse("100", out afShowOutTime);
                //int.TryParse("250", out afWidth);
                //int.TryParse("120", out afHeigth);
                //af = new YUNkefu.AlertForm();
                //af.Show(afContent, afTitle, showWay, afWidth, afHeigth, afShowInTime, afShowTime, afShowOutTime);
                WriteLog("【demo】" + log);
            }

            catch (Exception ex)
            {
                WriteLog("【错误】" + ex.ToString());
                Tools.WriteLog(ex.ToString());
            }
        }
예제 #6
0
파일: WxUser.cs 프로젝트: ks3dev/WechatApi
 /// <summary>
 /// 同步好友
 /// </summary>
 /// <returns></returns>
 public void SyncFriends(IWxFriendsRepository repository, WxContact wxContact)
 {
     for (int i = 0; i < this.Friends.Count; i++)
     {
         var itemfirend = this.Friends[i];
         #region 查询
         Expression <Func <WxFriendItem, bool> > where = m => true;
         if (!String.IsNullOrEmpty(itemfirend.RemarkName))
         {
             where = m => m.RemarkName.Equals(itemfirend.RemarkName);
         }
         else if (!String.IsNullOrEmpty(itemfirend.NickName))
         {
             where = m => m.NickName.Equals(itemfirend.NickName);
         }
         else
         {
             //TODO 备注和昵称均为空
             continue;
         }
         var Friend = wxContact.MemberList.FirstOrDefault(where.Compile());
         #endregion
         if (Friend == null)
         {
             //微信端删除好友
             this.Friends.Remove(itemfirend);
         }
         else
         {
             //同步好友信息
             itemfirend.UserName   = Friend.UserName;
             itemfirend.StarFriend = Friend.StarFriend;
             itemfirend.Province   = Friend.Province;
             itemfirend.City       = Friend.City;
             itemfirend.Sex        = Friend.Sex;
             itemfirend.HeadImgUrl = Friend.HeadImgUrl;
             itemfirend.Signature  = Friend.Signature;
             itemfirend.NickName   = Friend.NickName;
             itemfirend.RemarkName = Friend.RemarkName;
             wxContact.MemberList.Remove(Friend);
         }
     }
     if (wxContact.MemberList != null)
     {
         //添加好友
         this.Friends.AddRange(wxContact.MemberList.Select(m => new WxFriends
         {
             UserUin     = this.Uin,
             Uin         = m.Uin,
             UserName    = m.UserName,
             StarFriend  = m.StarFriend,
             Province    = m.Province,
             City        = m.City,
             Sex         = m.Sex,
             HeadImgUrl  = m.HeadImgUrl,
             Signature   = m.Signature,
             ContactFlag = m.ContactFlag,
             VerifyFlag  = m.VerifyFlag,
             AttrStatus  = m.AttrStatus,
             NickName    = m.NickName,
             RemarkName  = m.RemarkName,
         }));
     }
 }
예제 #7
0
        public void AddToList(string uin)
        {
            ((Action)(delegate()
            {
                string sid = LoginCore.GetPassTicket(uin).WxSid;
                string WXUser_url = LoginCore.GetPassTicket(uin).WXUser_url;//传值不同域名不同的
                WXService wx = new WXService();
                wx.Uin = uin;
                wx.Sid = sid;
                JObject init_result = wx.WxInit();
                var partUsers = new List <WXUser>();
                foreach (JObject contact in init_result["ContactList"])  //部分好友名单
                {
                    WXUser user = new WXUser();
                    //传值uin sin
                    user.uin = uin;
                    user.UserName = contact["UserName"].ToString();
                    user.City = contact["City"].ToString();
                    user.HeadImgUrl = contact["HeadImgUrl"].ToString();
                    user.NickName = contact["NickName"].ToString();
                    user.Province = contact["Province"].ToString();
                    user.PYQuanPin = contact["PYQuanPin"].ToString();
                    user.RemarkName = contact["RemarkName"].ToString();
                    user.RemarkPYQuanPin = contact["RemarkPYQuanPin"].ToString();
                    user.Sex = contact["Sex"].ToString();
                    user.Signature = contact["Signature"].ToString();
                    partUsers.Add(user);
                }

                var _me = new WXUser();
                if (init_result != null)
                {
                    _me.UserName = init_result["User"]["UserName"].ToString();
                    _me.City = "";
                    _me.HeadImgUrl = init_result["User"]["HeadImgUrl"].ToString();
                    _me.NickName = init_result["User"]["NickName"].ToString();
                    _me.Province = "";
                    _me.PYQuanPin = init_result["User"]["PYQuanPin"].ToString();
                    _me.RemarkName = init_result["User"]["RemarkName"].ToString();
                    _me.RemarkPYQuanPin = init_result["User"]["RemarkPYQuanPin"].ToString();
                    _me.Sex = init_result["User"]["Sex"].ToString();
                    _me.Signature = init_result["User"]["Signature"].ToString();
                    Tools.WriteLog("【警告】" + _me.NickName + "不能在此软件运行,请切换版本或重新扫描登陆");

                    if (string.IsNullOrEmpty(_me.NickName))
                    {
                        WriteLog("【警告】" + _me.NickName + "不能在此软件运行,请切换版本或重新扫描登陆");
                        Tools.WriteLog("【警告】" + uin + "不能在此软件运行,请切换版本或重新扫描登陆");
                        return;
                    }

                    var _syncKey = new Dictionary <string, string>();

                    foreach (JObject synckey in init_result["SyncKey"]["List"])  //同步键值
                    {
                        _syncKey.Add(synckey["Key"].ToString(), synckey["Val"].ToString());
                    }
                    //保存最新key
                    LoginCore.AddSyncKey(uin, _syncKey);
                    //更新数据库
                    var table = WeChatRobotDal.GetWxRobot(_me.NickName);
                    if (table.Rows.Count == 0)
                    {
                        WriteLog("【警告】" + _me.NickName + "没有加入系统中");
                        return;
                    }
                    partUsers.Add(_me);
                    WxContact _contact = new WxContact(uin); //记住此处不适合再开线程
                    _contact.InitContact(partUsers);         //初始联系人

                    WeChatRobotDal.UpdateUin(_me.NickName, uin);

                    #region 加入listview
                    if (!_dic.ContainsKey(uin))
                    {
                        this.BeginInvoke((Action) delegate()
                        {
                            this.WechartListView.BeginUpdate();
                            //把扫描好的微信加入到列表中
                            ListViewItem item = new ListViewItem();
                            item.Text = uin;
                            item.SubItems.Add(_me.UserName);
                            item.SubItems.Add(_me.ShowName);
                            item.SubItems.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                            item.SubItems.Add("0");
                            item.SubItems.Add(table.Rows[0]["EndDate"].ToString());
                            this.WechartListView.Items.Add(item);
                            this.WechartListView.EndUpdate();
                            //设置下高度
                            ImageList image = new ImageList();
                            image.ImageSize = new Size(10, 50);//这边设置宽和高
                            this.WechartListView.SmallImageList = image;
                            //隐藏以下按钮
                            //this.WechartListView.Columns[1].Width = 0;
                            //this.WechartListView.Columns[0].Width = 0;
                            //this.WechartListView.Columns[4].Width = 0;
                            //this.WechartListView.Columns[5].Width = 0;
                        });
                        _dic.Add(uin, uin);
                        //#region 开始任务
                        //var robotID = table.Rows[0]["RobotId"].ToString();
                        //WxTaskCore wt = new WxTaskCore(sid, uin, robotID);
                        //wt.user = _me;
                        ////接收消息事件
                        //wt.OnRevice += new WxTaskCore.Revice(wt_OnRevice);
                        ////接收修改联系人消息
                        //wt.OnModifyContact += new WxTaskCore.ModifyContact(wt_OnModifyContact);
                        ////通知发送信息
                        //wt.OnNotifySend += new WxTaskCore.NotifySend(wt_OnNotifySend);
                        ////每一个微信号,开启一个线程
                        //ThreadStart start = new ThreadStart(wt.ReviceMsg);
                        //new Thread(start).Start();
                        ////启动发送线程
                        //new Thread(new ThreadStart(wt.AutoSendMsg)).Start();
                        //#endregion
                    }
                    #endregion
                }
                if (!Uins.Contains(uin))
                {
                    Uins.Add(uin);
                }
                LoginCore.AddOnLineUin(Uins);
                UpDataFromData();
            })).BeginInvoke(null, null);
        }
예제 #8
0
        /// <summary>
        /// 进群欢迎语
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public SendMsg MakeContent(WXMsg msg)
        {
            var       SendMsg       = new SendMsg();
            WxContact contact       = new WxContact(msg.Uin);
            string    groupUserName = msg.From; //群用户名
            var       oldMember     = contact.GetGroupMemberNames(groupUserName);
            //获取当前群内所有成员信息
            var currMember = contact.GetOnLineGroupMember(groupUserName);

            var newMemberList = new List <GroupWxUser>();

            var dic_oldUserName = new Dictionary <string, string>();

            foreach (var old_s in oldMember.MemberUserNames)
            {
                dic_oldUserName.Add(old_s.UserName, old_s.UserName);
            }

            foreach (var s in currMember.MemberUserNames)
            {
                if (!dic_oldUserName.ContainsKey(s.UserName))
                {
                    newMemberList.Add(s);
                }
            }

            string nickName = string.Empty;

            foreach (var m in newMemberList)
            {
                nickName += m.NickName + "、";
            }
            //获取用户信息
            contact.Add(groupUserName, currMember); //更新群内联系人信息

            //获取系统设置的欢迎信息
            var robot = WeChatRobotDal.GetWxRobotByUin(msg.Uin);

            if (robot.Rows.Count == 0)
            {
                return(new SendMsg());
            }

            var welcomeSwitch = int.Parse(robot.Rows[0]["WelcomeSwitch"].ToString());

            var ret = string.Empty;

            switch (welcomeSwitch)
            {
            case (int)EnumContainer.CommonSwichEnum.关闭不发送:
                break;

            case (int)EnumContainer.CommonSwichEnum.自定义语句:
                ret = GetCustomWelcome(robot.Rows[0]["RobotId"].ToString());
                break;

            case (int)EnumContainer.CommonSwichEnum.通用语句:
                ret = "请遵守群规[微笑]";
                break;
            }

            ((Action) delegate()
            {
                //写进群数据库
                var b = WxOperateLogDal.AddInGroupLog(msg.Uin, groupUserName, msg.Msg);
            }).BeginInvoke(null, null);


            if (!string.IsNullOrEmpty(ret))
            {
                ret = string.Format("@{0} {1}", nickName.TrimEnd('、'), ret);
            }
            SendMsg.context = ret;
            SendMsg.type    = 1;
            return(SendMsg);
        }
예제 #9
0
        public void DoLogic()
        {
            sCB.IsEnabled   = false;
            smCB.IsEnabled  = false;
            overTimeTB.Text = "授权时间截止至 [ " + Core.Constant.overtime + " ]";
            //dLV.IsEnabled = false;
            uin = Core.Constant.Uin;
            List <Object> _contact_all = new List <object>();


            ((Action)(delegate()
            {
                LoginCore.InitCookie(uin);
                string sid = LoginCore.GetPassTicket(uin).WxSid;
                string host = LoginCore.GetPassTicket(uin).WxHost;
                WXService wxs = new WXService
                {
                    Uin = uin,
                    Sid = sid,
                    DeviceID = "e" + LoginCore.GenerateCheckCode(15),
                    BaseUrl = "https://" + LoginCore.GetPassTicket(uin).WxHost,
                    PushUrl = "https://webpush." + LoginCore.GetPassTicket(uin).WxHost,
                    UploadUrl = "https://file." + LoginCore.GetPassTicket(uin).WxHost
                };
                JObject init_result = wxs.WxInit();  //初始化
                var partUsers = new List <WXUser>();
                if (init_result != null)
                {
                    this.Dispatcher.BeginInvoke(((Action) delegate()  //等待结束
                    {
                        supLB.Content = "加载个人信息...";
                    }));
                    var _me = new WXUser
                    {
                        uin = wxs.Uin,
                        UserName = init_result["User"]["UserName"].ToString(),
                        City = "",
                        HeadImgUrl = init_result["User"]["HeadImgUrl"].ToString(),
                        NickName = init_result["User"]["NickName"].ToString(),
                        Province = "",
                        PYQuanPin = init_result["User"]["PYQuanPin"].ToString(),
                        RemarkName = init_result["User"]["RemarkName"].ToString(),
                        RemarkPYQuanPin = init_result["User"]["RemarkPYQuanPin"].ToString(),
                        Sex = init_result["User"]["Sex"].ToString(),
                        Signature = init_result["User"]["Signature"].ToString(),
                    };
                    forwardUser = _me.UserName;
                    partUsers.Add(_me);
                    this.Dispatcher.BeginInvoke((Action)(delegate()   //等待结束
                    {
                        //var aa = wxs.BaseUrl + _me.HeadImgUrl;
                        //headImage.Source = new BitmapImage(new Uri(aa));
                        headImage.Source = BitmapFrame.Create(wxs.GetIcon(_me.UserName, uin), BitmapCreateOptions.None, BitmapCacheOption.Default);
                    }));
                    this.Dispatcher.BeginInvoke(((Action) delegate()  //等待结束
                    {
                        supLB.Content = "加载最近联系人...";
                    }));
                    foreach (JObject contact in init_result["ContactList"])  //部分好友名单
                    {
                        WXUser user = new WXUser();
                        user.uin = wxs.Uin;
                        user.UserName = contact["UserName"].ToString();
                        user.City = contact["City"].ToString();
                        user.HeadImgUrl = contact["HeadImgUrl"].ToString();
                        user.NickName = contact["NickName"].ToString();
                        user.Province = contact["Province"].ToString();
                        user.PYQuanPin = contact["PYQuanPin"].ToString();
                        user.RemarkName = contact["RemarkName"].ToString();
                        user.RemarkPYQuanPin = contact["RemarkPYQuanPin"].ToString();
                        user.Sex = contact["Sex"].ToString();
                        user.Signature = contact["Signature"].ToString();
                        partUsers.Add(user);
                    }


                    var _syncKey = new Dictionary <string, string>();
                    foreach (JObject synckey in init_result["SyncKey"]["List"])  //同步键值
                    {
                        _syncKey.Add(synckey["Key"].ToString(), synckey["Val"].ToString());
                    }
                    //保存最新key
                    LoginCore.SyncKey(uin, _syncKey);
                    this.Dispatcher.BeginInvoke(((Action) delegate()  //等待结束
                    {
                        supLB.Content = "初始化联系人...";
                    }));
                    WxContact _contact = new WxContact(uin); //记住此处不适合再开线程
                    _contact.InitContact(partUsers);         //初始联系人

                    Dictionary <string, string> Groups = new Dictionary <string, string>();
                    foreach (var g in _contact.GetGroupUserNames())
                    {
                        Groups.Add(g, _contact.GetGroupMemberNames(g).NickName);
                    }
                    this.Dispatcher.BeginInvoke((Action)(delegate()   //等待结束
                    {
                        sCB.ItemsSource = Groups;
                        sCB.DisplayMemberPath = "Value";
                        sCB.SelectedValuePath = "Key";
                        smCB.DisplayMemberPath = "Value";
                        smCB.SelectedValuePath = "Key";
                        supLB.Content = "进入监听模式...";
                        sCB.IsEnabled = true;
                        smCB.IsEnabled = true;
                        //dLV.IsEnabled = true;
                    }));
                    string sync_flag = null;
                    JObject sync_result;
                    sync_flag = wxs.WxSyncCheck();  //同步检查
                    DateTime lastCheckTs = DateTime.Now;
                    while (true)
                    {
                        if (sync_flag != null)
                        {
                            var retcode = sync_flag.ToString().Split(new string[] { "\"" }, StringSplitOptions.None)[1];
                            var selector = sync_flag.ToString().Split(new string[] { "\"" }, StringSplitOptions.None)[3];
                            //this.Dispatcher.BeginInvoke((Action)(delegate ()
                            //{
                            //supLB.Content = "{retcode:" + retcode + " selector:" + selector + "}";

                            //}));
                            if (retcode == "1100")
                            {
                                this.Dispatcher.BeginInvoke((Action)(delegate()
                                {
                                    headBorder.BorderBrush = Brushes.Red;
                                }));
                                MessageBox.Show("你在手机上登出了微信,债见");
                                break;
                            }
                            if (retcode == "1101")
                            {
                                this.Dispatcher.BeginInvoke((Action)(delegate()
                                {
                                    headBorder.BorderBrush = Brushes.Red;
                                }));
                                MessageBox.Show("你在其他地方登录了 WEB 版微信,债见");
                                break;
                            }
                            else if (retcode == "0")
                            {
                                this.Dispatcher.BeginInvoke((Action)(delegate()
                                {
                                    headBorder.BorderBrush = Brushes.GreenYellow;
                                }));
                                if (selector == "2")
                                {
                                    sync_result = wxs.WxSync();  //进行同步
                                    lastCheckTs = DateTime.Now;
                                    if (sync_result != null)
                                    {
                                        handleMsg(sync_result);
                                    }
                                    //this.Dispatcher.BeginInvoke((Action)(delegate ()
                                    //{
                                    //supLB.Content = "";
                                    //}));
                                }
                                else if (selector == "0")
                                {
                                    //this.Dispatcher.BeginInvoke((Action)(delegate ()
                                    //{
                                    //supLB.Content = "";
                                    //}));

                                    Thread.Sleep(500);
                                }
                                else
                                {
                                    sync_result = wxs.WxSync();  //进行同步
                                    this.Dispatcher.BeginInvoke((Action)(delegate()
                                    {
                                        supLB.Content = "最后同步:{retcode:" + retcode + " selector:" + selector + "}";
                                    }));
                                    //this.Dispatcher.BeginInvoke((Action)(delegate ()
                                    //{
                                    //chatText.AppendText("\n" + selector + "\n-------" + sync_result.ToString() + "-------\n");
                                    //}));
                                }
                            }
                            sync_flag = null;
                            this.Dispatcher.BeginInvoke((Action)(delegate()
                            {
                                headBorder.BorderBrush = Brushes.Blue;
                            }));
                        }

                        if ((DateTime.Now - lastCheckTs).Seconds < 23)
                        {
                            var sleep = (DateTime.Now - lastCheckTs).Seconds;

                            Thread.Sleep(1000);

                            sync_flag = wxs.WxSyncCheck();  //同步检查
                        }
                        else
                        {
                            sync_flag = wxs.WxSyncCheck();
                            lastCheckTs = DateTime.Now;
                        }
                        this.Dispatcher.BeginInvoke((Action)(delegate()
                        {
                            sleepTB.Text = ((DateTime.Now - lastCheckTs).Seconds).ToString();
                            supLB.Content = "最后同步:" + DateTime.Now.ToLongTimeString().ToString();
                        }));
                    }
                }
            })).BeginInvoke(null, null);
        }
예제 #10
0
 public CustomLogic(WxContact contact, WXMsg msg, string msgContext, string userName) :
     base(contact, msg)
 {
     this.userName = userName;
     this.context  = msgContext;
 }
예제 #11
0
 public MenuLogic(WxContact contact, WXMsg msg) :
     base(contact, msg)
 {
 }
예제 #12
0
 public CharLogicContext(WxContact contact, Entity.WXMsg msg)
 {
     this.contact = contact;
     this.msg     = msg;
 }
예제 #13
0
 public AutoLogic(WxContact contact, WXMsg msg) :
     base(contact, msg)
 {
 }
예제 #14
0
 public AbsCharLogic(WxContact contact, WXMsg msg)
 {
     this.Contact = contact;
     this.Msg     = msg;
 }
예제 #15
0
        /// <summary>
        /// 自动发送消息
        /// </summary>
        public void AutoSendMsg()
        {
            try
            {
                while (true)
                {
                    var    dt       = WeChatAdvertisementDal.QueryTask(this.robotID);
                    string msgText  = string.Empty;
                    var    _taskDic = new Dictionary <int, string>();
                    foreach (DataRow dr in dt.Rows)
                    {
                        var adverId = 0;
                        adverId = int.Parse(dr["AdverId"].ToString());
                        var lastSendTime_str = dr["LastSendTime"].ToString();
                        var last             = DateTime.Now.AddDays(-2);
                        if (!string.IsNullOrEmpty(lastSendTime_str))
                        {
                            last = Convert.ToDateTime(lastSendTime_str);
                        }
                        if (int.Parse(dr["AdverCategory"].ToString()) == (int)EnumContainer.AdverCategoryEnum.公告语)
                        {
                            switch (int.Parse(dr["SendMode"].ToString()))
                            {
                            case (int)EnumContainer.SendModeEnum.每隔多少分钟:
                                if (DateTime.Now.Subtract(last).TotalMinutes > int.Parse(dr["SendModeParas"].ToString()))
                                {
                                    msgText = dr["AdverContent"].ToString();
                                    if (!_taskDic.ContainsKey(adverId))
                                    {
                                        _taskDic.Add(adverId, msgText);
                                    }
                                }
                                break;

                            case (int)EnumContainer.SendModeEnum.每天某一时刻:
                                var tempTime = Convert.ToDateTime(string.Format("{0} {1}", DateTime.Now.ToString("yyyy-MM-dd"), dr["SendModeParas"]));
                                var s_i      = tempTime.Subtract(DateTime.Now).TotalSeconds;
                                if (s_i <= 0 && s_i > -10)
                                {
                                    if (DateTime.Now.Subtract(last).TotalMinutes > 2)
                                    {
                                        msgText = dr["AdverContent"].ToString();
                                        if (!_taskDic.ContainsKey(adverId))
                                        {
                                            _taskDic.Add(adverId, msgText);
                                        }
                                    }
                                }
                                break;

                            case (int)EnumContainer.SendModeEnum.指定具体时间:
                                var temp  = Convert.ToDateTime(dr["SendModeParas"]);
                                var s_i_i = temp.Subtract(DateTime.Now).TotalSeconds;
                                if (s_i_i <= 0 && s_i_i > -10)
                                {
                                    if (DateTime.Now.Subtract(last).TotalMinutes > 2)
                                    {
                                        msgText = dr["AdverContent"].ToString();
                                        if (!_taskDic.ContainsKey(adverId))
                                        {
                                            _taskDic.Add(adverId, msgText);
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }
                    System.Threading.Thread.Sleep(1000);
                    foreach (var k in _taskDic)
                    {
                        //通知发送
                        WeChatAdvertisementDal.UpdateLastSendTime(k.Key.ToString());
                        if (OnNotifySend != null)
                        {
                            if (!string.IsNullOrEmpty(k.Value))
                            {
                                WxContact contact    = new WxContact(this.Uin);
                                var       gUserNames = contact.GetGroupUserNames();
                                var       args       = new NotifyArgs()
                                {
                                    Sid           = this.Sid,
                                    WxUin         = this.Uin,
                                    MsgContext    = k.Value,
                                    MyUserName    = this.user.UserName,
                                    GroupUserName = gUserNames
                                };
                                OnNotifySend(args);
                                System.Threading.Thread.Sleep(1500);
                            }
                        }
                    }
                    _taskDic.Clear();
                }
            }
            catch (Exception ex)
            {
                //写日志
                Tools.WriteLog(ex.ToString());
            }
        }