예제 #1
0
        private void SynchronizeGroupsAndMembersToWeChat()
        {
            var allGroups = ConditionalGroupAdapter.Instance.LoadAll();
            var accounts  = AccountInfoAdapter.Instance.LoadAll();

            WeChatGroupCollection weChatGroups = WeChatGroupAdapter.Instance.LoadAll();

            foreach (var account in accounts)
            {
                WeChatRequestContext.Current.LoginInfo = WeChatHelper.ExecLogin(account.UserID, account.Password);
                Thread.Sleep(1000);

                foreach (var group in allGroups)
                {
                    var fakeIDs = WeChatFriendAdapter.Instance.GetFakeIDsByLocalGroupID(group.GroupID).ToArray(); //找到本组里成员的fakeID

                    var matchedGroup = weChatGroups.Find(p => p.Name == group.Name && p.AccountID == WeChatRequestContext.Current.LoginInfo.AccountID);

                    int groupID = 0;
                    if (matchedGroup == null)
                    {
                        var modifiedGroup = WeChatHelper.AddGroup(group.Name, WeChatRequestContext.Current.LoginInfo);
                        Thread.Sleep(1000);

                        var newGroup = new WeChatGroup()
                        {
                            AccountID = account.AccountID,
                            GroupID   = modifiedGroup.GroupId,
                            Name      = group.Name,
                            Count     = modifiedGroup.MemberCnt
                        };

                        WeChatGroupAdapter.Instance.Update(newGroup);

                        groupID = modifiedGroup.GroupId;
                    }
                    else
                    {
                        groupID = matchedGroup.GroupID;
                    }

                    if (fakeIDs.Length > 0)
                    {
                        WeChatHelper.ChangeFriendsGroup(groupID, fakeIDs, WeChatRequestContext.Current.LoginInfo);
                        Thread.Sleep(1000);
                    }
                }
            }
        }
예제 #2
0
        private void SynchronizeToWeChat()
        {
            try
            {
                ProcessProgress.Current.RegisterResponser(SubmitButtonProgressResponser.Instance);

                var allGroups = ConditionalGroupAdapter.Instance.LoadAll();
                var accounts  = AccountInfoAdapter.Instance.LoadAll();

                WeChatGroupCollection weChatGroups = WeChatGroupAdapter.Instance.LoadAll();

                ProcessProgress.Current.MaxStep     = allGroups.Count * accounts.Count;
                ProcessProgress.Current.CurrentStep = 0;
                ProcessProgress.Current.StatusText  = "开始同步...";
                ProcessProgress.Current.Response();

                foreach (var account in accounts)
                {
                    WeChatRequestContext.Current.LoginInfo = WeChatHelper.ExecLogin(account.UserID, account.Password);

                    Thread.Sleep(1000);

                    foreach (var group in allGroups)
                    {
                        var fakeIDs = WeChatFriendAdapter.Instance.GetFakeIDsByLocalGroupID(group.GroupID).ToArray(); //找到本组里成员的fakeID

                        var matchedGroup = weChatGroups.Find(p => p.Name == group.Name && p.AccountID == WeChatRequestContext.Current.LoginInfo.AccountID);

                        int groupID = 0;
                        if (matchedGroup == null)
                        {
                            var modifiedGroup = WeChatHelper.AddGroup(group.Name, WeChatRequestContext.Current.LoginInfo);
                            var newGroup      = new WeChatGroup()
                            {
                                AccountID = account.AccountID,
                                GroupID   = modifiedGroup.GroupId,
                                Name      = group.Name,
                                Count     = modifiedGroup.MemberCnt
                            };

                            WeChatGroupAdapter.Instance.Update(newGroup);
                            Thread.Sleep(1000);
                            groupID = modifiedGroup.GroupId;
                        }
                        else
                        {
                            groupID = matchedGroup.GroupID;
                        }

                        if (fakeIDs.Length > 0)
                        {
                            WeChatHelper.ChangeFriendsGroup(groupID, fakeIDs, WeChatRequestContext.Current.LoginInfo);
                        }

                        ProcessProgress.Current.Increment();
                        ProcessProgress.Current.StatusText = string.Format("帐号\"{0}\",同步组\"{1}\"完成", account.UserID, group.Name);
                        ProcessProgress.Current.Response();
                        Thread.Sleep(1000);
                    }
                }

                ProcessProgress.Current.StatusText = string.Format("同步完成");
                ProcessProgress.Current.Response();
                Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                WebUtility.ResponseShowClientErrorScriptBlock(ex);
            }
            finally
            {
                this.Response.Write(SubmitButton.GetResetAllParentButtonsScript(true));
                this.Response.End();
            }
        }
예제 #3
0
        public override void Execute(string argument)
        {
            WeChatModifyGroupRetInfo groupInfo = WeChatHelper.AddGroup(argument, WeChatRequestContext.Current.LoginInfo);

            Console.WriteLine(groupInfo);
        }