Esempio n. 1
0
        /// <summary>
        /// 设置联系人
        /// </summary>
        /// <param name="user">The user.</param>
        public void SetContactsView(WXUser user)
        {
            if (dgvWeChatList.InvokeRequired)
            {
                this.Invoke(new Action <WXUser>(SetContactsView), new object[] { user });
            }
            else
            {
                int i = dgvWeChatList.Rows.Count;
                dgvWeChatList.Rows.Add();
                ++i;
                dgvWeChatList.Rows[i - 1].Cells["ShowName"].Value = user.ShowName;
                dgvWeChatList.Rows[i - 1].Cells["UserName"].Value = user.UserName;
                if (i % 2 == 0)
                {
                    dgvWeChatList.Rows[i - 1].DefaultCellStyle.BackColor          = ConstConfig.DataGridViewEvenRowBackColor;
                    dgvWeChatList.Rows[i - 1].DefaultCellStyle.SelectionBackColor = ConstConfig.DataGridViewEvenRowBackColor;
                }
                else
                {
                    dgvWeChatList.Rows[i - 1].DefaultCellStyle.BackColor          = ConstConfig.DataGridViewOddRowBackColor;
                    dgvWeChatList.Rows[i - 1].DefaultCellStyle.SelectionBackColor = ConstConfig.DataGridViewOddRowBackColor;
                }
                dgvWeChatList.Rows[i - 1].Height = ConstConfig.DataGridViewRowHeight;
                dgvWeChatList.Rows[i - 1].DefaultCellStyle.ForeColor = ConstConfig.DataGridViewRowForeColor;

                dgvWeChatList.CurrentCell = dgvWeChatList.Rows[dgvWeChatList.Rows.Count - 1].Cells[dgvWeChatList.CurrentCell.ColumnIndex];
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 编辑管理用户
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public WebResult <bool> Update(WXUser model)
        {
            var user = FindByOpenId(model.openid.Trim());

            if (user == null)
            {
                var addEntity = new User()
                {
                    OpenId      = model.openid.Trim(),
                    NickName    = model.nickname,
                    Sex         = model.sex.GetInt(),
                    HeadImgUrl  = model.headimgurl,
                    CreatedTime = DateTime.Now
                };

                Add(addEntity);
            }
            else
            {
                user.NickName   = model.nickname;
                user.Sex        = model.sex.GetInt();
                user.HeadImgUrl = model.headimgurl;
                Update(user);
            }
            return(Result(true));
        }
Esempio n. 3
0
 /// <summary>
 /// 聊天列表点击好友   开始聊天
 /// </summary>
 /// <param name="user"></param>
 private void wchatlist_StartChat(WXUser user)
 {
     _chat2friend.Visible = true;
     _chat2friend.BringToFront();
     _chat2friend.MeUser     = _me;
     _chat2friend.FriendUser = user;
 }
Esempio n. 4
0
        public async Task <IActionResult> PutWXUser(string id, WXUser wXUser)
        {
            if (!id.Equals(wXUser.ID))
            {
                return(BadRequest());
            }

            _context.Entry(wXUser).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WXUserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 5
0
 /// <summary>
 /// 好友信息框中点击 聊天
 /// </summary>
 /// <param name="user"></param>
 void _friendInfo_StartChat(WXUser user)
 {
     _chat2friend.Visible = true;
     _chat2friend.BringToFront();
     _chat2friend.MeUser     = _me;
     _chat2friend.FriendUser = user;
 }
        /// <summary>
        /// 权限管理
        /// </summary>
        /// <returns></returns>
        private bool NeedSendMsg()
        {
            bool result = false;

            if (IsFormMySelf())
            {
                result = true;
            }
            else
            {
                List <object> list = UserManager.GetInstance().GetAllGroup();
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i] is WXUser)
                    {
                        WXUser wX = (WXUser)list[i];
                        if (wX.UserName.Equals(RealSendTo()))
                        {
                            if (wX.NickName.Contains(@"美团,饿了么红包分享群"))
                            {
                                result = true;
                                break;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Esempio n. 7
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (groupid == "")
            {
                return;
            }
            listView2.Items.Clear();
            WXService wxs  = new WXService();
            wxcaozuo  wxcz = new wxcaozuo();

            wxcz.Delete();
            JObject contact_result = wxs.GetGroupItem(groupid); //群聊

            if (contact_result != null)
            {
                this.listView2.BeginUpdate();                                  //数据更新,UI暂时挂起,直到EndUpdate绘制控件,可以有效避免闪烁并大大提高加载速度
                foreach (JObject contactlist in contact_result["ContactList"]) //完整好友名单
                {
                    foreach (JObject contact in contactlist["MemberList"])     //完整好友名单
                    {
                        WXUser       user = new WXUser();
                        ListViewItem lvi  = new ListViewItem();
                        lvi.Text = contact["NickName"].ToString();
                        this.listView2.Items.Add(lvi);
                        wxcz.Write("<NickName>" + contact["NickName"].ToString() + "<UserName>" + contact["UserName"].ToString() + Environment.NewLine, "Append");
                    }
                }
                this.listView2.EndUpdate();  //结束数据处理,UI界面一次性绘制。
            }
        }
Esempio n. 8
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,WXUserNickName,WXUserOpenID,WXUserPhone,WXUserGender,WXUserBirthday")] WXUser wXUser)
        {
            if (id != wXUser.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(wXUser);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WXUserExists(wXUser.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(wXUser));
        }
Esempio n. 9
0
        /// <summary>
        /// 添加通讯录
        /// </summary>
        /// <param name="user">The user.</param>
        public void AddContactsView(WXUser user)
        {
            if (NotListenWeChatData == null)
            {
                NotListenWeChatData = new List <WXUser>();
            }
            if (ListenWeChatData == null)
            {
                ListenWeChatData = new List <WXUser>();
            }

            if (!NotListenWeChatData.Exists(item => { return(item.UserName == user.UserName); }) && !ListenWeChatData.Exists(item => { return(item.UserName == user.UserName); }))
            {
                NotListenWeChatData.Add(user);
                SetContactsView(user);
                //DownLoadWeChatImage(user);
            }
            ListenWeChatData.ForEach(item =>
            {
                if (item.UserName == user.UserName)
                {
                    item.NickName = user.ShowName;
                }
            });
        }
Esempio n. 10
0
 /// <summary>
 /// 下载图片
 /// </summary>
 /// <param name="user">The user.</param>
 private void DownLoadWeChatImage(WXUser user)
 {
     new System.Threading.Thread(() =>
     {
         lock (_loading)
         {
             string fileName = Environment.CurrentDirectory + "\\data\\cacheData\\img";
             if (!Directory.Exists(fileName))
             {
                 Directory.CreateDirectory(fileName);
             }
             fileName += "\\" + EncryptHelper.MD5(user.UserName) + ".jpg";
             //判断文件是否存在
             if (!File.Exists(fileName))
             {
                 Image data = mainForm.wxlogin.GetHeadImage(user.UserName);
                 if (data != null)
                 {
                     Bitmap img = new Bitmap(data, 40, 40);
                     img.Save(fileName, ImageFormat.Jpeg);
                     img.Dispose();
                     img = null;
                     SetContactsView(user);
                 }
             }
             else
             {
                 SetContactsView(user);
             }
         }
     })
     {
         IsBackground = true
     }.Start();
 }
Esempio n. 11
0
 /// <summary>
 /// 聊天对话框中点击 好友信息
 /// </summary>
 /// <param name="user"></param>
 void _chat2friend_FriendInfoView(WXUser user)
 {
     _friendInfo.FriendUser = user;
     _friendInfo.Visible    = true;
     _friendInfo.BringToFront();
     chart_main.Controls.Add(_friendInfo);
     _friendInfo.Show();
 }
Esempio n. 12
0
 /// <summary>
 /// 通讯录中点击好友 查看好友信息
 /// </summary>
 /// <param name="user"></param>
 private void wfriendlist_FriendInfoView(WXUser user)
 {
     _friendInfo.FriendUser = user;
     _friendInfo.Visible    = true;
     _friendInfo.BringToFront();
     chart_main.Controls.Add(_chat2friend);
     _chat2friend.Show();
 }
Esempio n. 13
0
        /// <summary>
        /// 好友列表绑定
        /// </summary>
        public static List <object> FriendsList()
        {
            try
            {
                List <object> contact_all    = new List <object>();
                List <Object> _contact_all   = new List <object>();
                JObject       contact_result = new JObject();
                if (friends_result == null || friends_result.ToString() == "{}")
                {
                    contact_result = MessageSync.Friends(); //通讯录
                }
                else
                {
                    contact_result = friends_result;
                }
                if (contact_result != null)
                {
                    contact_all = new List <object>();
                    foreach (JObject contact in contact_result["MemberList"])  //完整好友名单
                    {
                        if (contact["Sex"].ToString() != "0")
                        {
                            WXUser user = new WXUser();
                            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();

                            contact_all.Add(user);
                        }
                    }
                }
                IOrderedEnumerable <object> list_all = contact_all.OrderBy(ee => (ee as WXUser).ShowPinYin);

                WXUser wx; string start_char;
                foreach (object o in list_all)
                {
                    wx         = o as WXUser;
                    start_char = wx.ShowPinYin == "" ? "" : wx.ShowPinYin.Substring(0, 1);
                    if (!_contact_all.Contains(start_char.ToUpper()))
                    {
                        _contact_all.Add(start_char.ToUpper());
                    }
                    _contact_all.Add(o);
                }
                return(_contact_all);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// 初始化当前用户数据
        /// </summary>
        /// <param name="init_result">The init_result.</param>
        private void InitCurrentUserData(JObject init_result)
        {
            _me                 = new WXUser();
            _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();

            //打开主界面
            mainForm.SetWinFormTitle(_me.ShowName);

            foreach (JObject contact in init_result["ContactList"])  //部分好友名单
            {
                if (contact["UserName"].ToString().Contains("@@"))
                {
                    WXUser user = new WXUser();
                    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();
                    user.IsOwner         = Convert.ToInt32(contact["IsOwner"].ToString());
                    if (!mainForm.contact_all.Exists((item) => { return(item.UserName == user.UserName); }))
                    {
                        mainForm.contact_all.Add(user);
                        if (mainForm.listenForm != null)
                        {
                            mainForm.listenForm.AddContactsView(user);
                        }
                    }
                    else
                    {
                        mainForm.contact_all.ForEach(item =>
                        {
                            if (item.UserName == user.UserName)
                            {
                                item.NickName = user.NickName;
                                if (mainForm.listenForm != null)
                                {
                                    mainForm.listenForm.AddContactsView(user);
                                }
                            }
                        });
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //MembershipUser mu = Membership.GetUser("9F2B74B2-C586-42D1-99EB-031A2C72D72E");
            //Response.Write(mu.UserName);  new pass:*QkxtK(#RfOHui
            WXUser cu = new WXUser("455868D6-3BD9-486B-BF37-75387CD5FC9E");

            //Response.Write(cu.AspNetUser.ResetPassword());
            Response.Write(cu.AspNetUser.UnlockUser().ToString());
        }
Esempio n. 16
0
 /// <summary>
 /// 聊天列表点击好友   开始聊天
 /// </summary>
 /// <param name="user"></param>
 private void wchatlist_StartChat(WXUser user)
 {
     _chat2friend.Visible = true;
     _chat2friend.BringToFront();
     _chat2friend.MeUser     = _me;
     _chat2friend.FriendUser = user;
     chart_main.Controls.Add(_chat2friend);
     _chat2friend.Show();
 }
Esempio n. 17
0
        public async Task <IActionResult> Create([Bind("ID,WXUserNickName,WXUserOpenID,WXUserPhone,WXUserGender,WXUserBirthday")] WXUser wXUser)
        {
            if (ModelState.IsValid)
            {
                _context.Add(wXUser);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(wXUser));
        }
Esempio n. 18
0
        //根据openid,access token获得用户信息
        public WXUser Get_UserInfo(string REFRESH_TOKEN, string OPENID, ref string getjson)
        {
            //string Str = GetJson("https://api.weixin.qq.com/sns/userinfo?access_token=" + REFRESH_TOKEN + "&openid=" + OPENID);公众号接口
            string Str = GetJson("https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + REFRESH_TOKEN + "&code=" + OPENID);

            getjson = Str;
            //div1.InnerText += " <Get_UserInfo> " + Str + " <> ";

            WXUser OAuthUser_Model = JsonHelper.ParseFromJson <WXUser>(Str);

            return(OAuthUser_Model);
        }
Esempio n. 19
0
        /// <summary>
        /// 获取当前用户
        /// </summary>
        /// <returns></returns>
        public static WXUser GetCurrentWxUser()
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[Params.UserCookieName];

            if (cookie == null)
            {
                return(null);
            }
            WXUser user = (CryptoHelper.AES_Decrypt(cookie.Value, Params.SecretKey)).DeserializeJson <WXUser>();

            return(user);
        }
Esempio n. 20
0
 /// <summary>
 /// 好友信息框中点击 聊天
 /// </summary>
 /// <param name="user"></param>
 void _friendInfo_StartChat(WXUser user)
 {
     if (_chat2friend != null)
     {
         _chat2friend.Visible = true;
         _chat2friend.BringToFront();
         _chat2friend.MeUser     = _me;
         _chat2friend.FriendUser = user;
         chart_main.Controls.Add(_chat2friend);
         _chat2friend.Show();
     }
 }
Esempio n. 21
0
        /// <summary>
        /// 重绘每项
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            Rectangle bound;

            for (int i = 0; i < Items.Count; ++i)
            {
                WXUser user = Items[i] as WXUser;
                bound = GetItemRectangle(i);

                if (user != null)  //好友项
                {
                    if (!ClientRectangle.IntersectsWith(bound))
                    {
                        continue;
                    }
                    if (_mouse_over == i)
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(20, 37, 37, 37)), bound);
                    }
                    if (SelectedIndex == i)
                    {
                        e.Graphics.FillRectangle(Brushes.LightGray, bound);
                    }
                    e.Graphics.DrawLine(new Pen(Color.FromArgb(50, Color.Black)), new Point(bound.X, bound.Y + 50), new Point(bound.X + Width, bound.Y + 50));
                    using (Font f = new System.Drawing.Font("微软雅黑", 11))
                    {
                        if (user.Icon != null)
                        {
                            e.Graphics.DrawImage(user.Icon, new Rectangle(bound.X + 8, bound.Y + 8, 34, 34));           //头像
                        }
                        e.Graphics.DrawString(user.ShowName, f, Brushes.Black, new PointF(bound.X + 50, bound.Y + 16)); //昵称
                    }
                }
                else  //分类项
                {
                    if (!ClientRectangle.IntersectsWith(bound))
                    {
                        continue;
                    }

                    using (Font f = new Font("微软雅黑", 15))
                    {
                        if (!string.IsNullOrEmpty(Items[i].ToString()))
                        {
                            e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(150, Color.Gray)), bound);
                            e.Graphics.DrawString(i == 0 ? "" : Items[i].ToString(), f, Brushes.Black, new PointF(bound.X + 10, bound.Y + 3));
                        }
                    }
                }
            }
        }
Esempio n. 22
0
        public async Task <ActionResult <WXUser> > PostWXUser(WXUser wXUser)
        {
            if (WXUserExists(wXUser.WXUserOpenID))
            {
                return(null);
            }
            else
            {
                _context.WXUser.Add(wXUser);
                await _context.SaveChangesAsync();

                return(CreatedAtAction("GetWXUser", new { id = wXUser.ID }, wXUser));
            }
        }
Esempio n. 23
0
        /// <summary>
        /// 首页
        /// </summary>
        /// <param name="unid">店铺id</param>
        /// <param name="info">微信用户信息json化字符串</param>
        /// <returns>页面缓存1小时</returns>
        //[OAuthFilter]
        public ActionResult Index(string unid, string info)
        {
            var userInfoCache = CookieHelper.GetCurrentWxUser();

            if (!string.IsNullOrEmpty(info) && userInfoCache == null)
            {
                WXUser entity = info.DeserializeJson <WXUser>();
                if (entity != null)
                {
                    //更新数据
                    IUserService.Update_User(entity);
                    CookieHelper.CreateWxUser(entity);
                }
            }

            //判断是否已有订单
            ViewBag.ExistsOrder = this.Request.Cookies["had"] == null ? false : (string.IsNullOrEmpty(this.Request.Cookies["had"].Value) ? false : true);

            //店铺id
            if (string.IsNullOrEmpty(unid))
            {
                unid = CookieHelper.GetCurrentShopId();
            }
            else
            {
                CookieHelper.CreateShopId(unid);
            }

            if (string.IsNullOrEmpty(unid))
            {
                return(OAuthExpired());
            }
            else
            {
                var entity = IDinnerShopService.Find_DinnerShop(unid);
                if (entity != null)
                {
                    var startTime = DateTime.Parse(entity.StartShoptime);
                    var endTime   = DateTime.Parse(entity.EndShoptime);
                    var nowTime   = DateTime.Parse(DateTime.Now.Hour + ":" + DateTime.Now.Minute);
                    if (nowTime < startTime || nowTime > endTime)
                    {
                        return(Content("抱歉,还没到营业时间"));
                    }
                }
                var item = IDinnerCategoryService.Get_ItemByShopId(unid);
                return(View(item));
            }
        }
Esempio n. 24
0
 //更新用户的cookie
 public static void CreateWxUser(WXUser user)
 {
     try
     {
         HttpCookie cookie = new HttpCookie(Params.UserCookieName);
         using (DbRepository entities = new DbRepository())
         {
             cookie.Value   = CryptoHelper.AES_Encrypt(user.ToJson(), Params.SecretKey);
             cookie.Expires = DateTime.Now.AddMinutes(120);
         }
         // 写登录Cookie
         HttpContext.Current.Response.Cookies.Remove(cookie.Name);
         HttpContext.Current.Response.Cookies.Add(cookie);
     }
     catch { }
 }
Esempio n. 25
0
 public void BindOwer(WXUser me)
 {
     picImage.Image       = me.Icon;
     lblNick.Text         = me.NickName;
     lblArea.Text         = me.City + "," + me.Province;
     lblSignature.Text    = me.Signature;
     picSexImage.Image    = me.Sex == "1" ? Properties.Resources.male : Properties.Resources.female;
     picSexImage.Location = new Point(lblNick.Location.X + lblNick.Width + 4, picSexImage.Location.Y);
     if (me.Icon == null)
     {
         picImage.Image = picQRCode.Image;
     }
     else
     {
         picImage.Image = me.Icon;
     }
 }
Esempio n. 26
0
        static void Main(string[] args)
        {
            var dsd = DateTime.Today;

            WXUser entity = new WXUser()
            {
                openid     = "1112dsdsdsdsdsd",
                nickname   = "哈哈啊查询查询",
                city       = "福州",
                country    = "中国",
                headimgurl = "http://wx.qlogo.cn/mmopen/PYEBjepVt4IW6ibsc3I8NVLN7CSIEzlsngoKK1Rka4nfUh6ia961qEUWSBTFH5OaRaf5qxpicz2bPnictCQ0fV8Sh5sLlLoVhibF9/0",
                province   = "福建",
                sex        = "1"
            };
            string dd = "?info=" + HttpUtility.UrlEncode(entity.ToJson());
            string ss = "";
        }
Esempio n. 27
0
 /// <summary>
 /// 加载我的通讯录
 /// </summary>
 /// <param name="contact_result">The contact_result.</param>
 private void LoadMyContact(JObject contact_result, Action callback = null)
 {
     foreach (JObject contact in contact_result["MemberList"])  //完整好友名单
     {
         if (contact["UserName"].ToString().Contains("@@"))
         {
             WXUser user = new WXUser();
             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();
             user.IsOwner         = Convert.ToInt32(contact["IsOwner"].ToString());
             //判断是否存在重复
             if (!mainForm.contact_all.Exists((item) => { return(item.UserName == user.UserName); }))
             {
                 mainForm.contact_all.Add(user);
                 if (mainForm.listenForm != null)
                 {
                     mainForm.listenForm.AddContactsView(user);
                 }
             }
             else
             {
                 mainForm.contact_all.ForEach(item =>
                 {
                     if (item.UserName == user.UserName)
                     {
                         item.NickName = user.NickName;
                         if (mainForm.listenForm != null)
                         {
                             mainForm.listenForm.AddContactsView(user);
                         }
                     }
                 });
             }
         }
     }
     callback?.Invoke();
 }
Esempio n. 28
0
        /// <summary>
        /// 处理用户输入的特殊字符串
        /// Inputs the string filter.
        /// </summary>
        /// <param name="stringValue">String value.</param>
        private bool InputStringFilter(string stringValue)
        {
            if (Regex.IsMatch(stringValue, @"^\d[::]$"))
            {
                var index = int.Parse(stringValue[0].ToString());
                var user  = this._hotContract.ElementAt(index - 1);
                this._currentContract = new WXUser
                {
                    UserName = user.Key,
                    NickName = user.Value
                };

                this.LoginInfo.StringValue = $"当前联系:{this._currentContract.NickName}";
                return(false);
            }

            return(true);
        }
Esempio n. 29
0
        /// <summary>
        /// 加载微信通讯录
        /// </summary>
        /// <param name="user">The user.</param>
        private void SetContactsView(WXUser user)
        {
            if (NotListenWeChatData == null)
            {
                NotListenWeChatData = new List <WXUser>();
            }

            if (dgvWeChatList.InvokeRequired)
            {
                this.dgvWeChatList.Invoke(new Action <WXUser>(SetContactsView), new object[] { user });
            }
            else
            {
                bool result = false;
                foreach (DataGridViewRow item in dgvWeChatList.Rows)
                {
                    if (item.Cells["UserName"].Value.ToString().Equals(user.UserName))
                    {
                        result = true;
                        item.Cells["ShowName"].Value = user.ShowName;
                        item.Cells["UserName"].Value = user.UserName;
                        break;
                    }
                }
                if (!IsListenView && !result)
                {
                    int i = dgvWeChatList.Rows.Count;
                    dgvWeChatList.Rows.Add();
                    ++i;
                    dgvWeChatList.Rows[i - 1].Cells["ID"].Value       = i;
                    dgvWeChatList.Rows[i - 1].Cells["ShowName"].Value = user.ShowName;
                    dgvWeChatList.Rows[i - 1].Cells["UserName"].Value = user.UserName;

                    dgvWeChatList.Rows[i - 1].Height = 50;
                    dgvWeChatList.Rows[i - 1].DefaultCellStyle.SelectionBackColor = Color.FromArgb(236, 232, 231);
                }

                if (NotListenWeChatData.Exists(item => { return(item.UserName == user.UserName); }))
                {
                    NotListenWeChatData.RemoveAll(u => { return(u.UserName == user.UserName); });
                }
                NotListenWeChatData.Add(user);
            }
        }
Esempio n. 30
0
        /// <summary>
        /// 设置微信监控消息
        /// </summary>
        /// <param name="user"></param>
        /// <param name="msgSendUser"></param>
        /// <param name="nickName"></param>
        /// <param name="content"></param>
        public void SetWxMessageData(WXUser user, string msgSendUser, string nickName, string content, byte[] msgImageData)
        {
            WxMessageBodyModel msg = new WxMessageBodyModel();

            if (!wxMessageData.Exists(item => { return(item.MsgSendUser == msgSendUser && item.MsgUserName == user.UserName); }))
            {
                msg = new WxMessageBodyModel()
                {
                    MsgSendUser          = msgSendUser,
                    MsgShowName          = user.ShowName,
                    MsgText              = content,
                    MsgTime              = DateTime.Now,
                    NotReadCount         = 1,
                    MsgUserName          = user.UserName,
                    MsgNickName          = nickName,
                    MsgStatus            = "未回复",
                    MsgImageBase64String = msgImageData != null?Convert.ToBase64String(msgImageData) : null
                };
                wxMessageData.Add(msg);
            }
            else
            {
                wxMessageData.ForEach(data =>
                {
                    if (data.MsgSendUser == msgSendUser && data.MsgUserName == user.UserName)
                    {
                        data.MsgTime              = DateTime.Now;
                        data.MsgText              = content;
                        data.NotReadCount        += 1;
                        data.MsgStatus            = "未回复";
                        data.MsgImageBase64String = msgImageData != null ? Convert.ToBase64String(msgImageData) : null;
                    }
                });

                msg = wxMessageData.Find(m =>
                {
                    return(m.MsgSendUser == msgSendUser && m.MsgUserName == user.UserName);
                });
            }
            if (msg != null)
            {
                SetDataContentView(msg);
            }
        }