Example #1
0
        private void GetContact(string userName)
        {
            BatchRequestModel brm = BatchRequestModel.Create(userManager.UserInfo);

            brm.Count = 1;
            brm.List.AddLast(new BatchItem {
                UserName = userName
            });

            string json = JsonConvert.SerializeObject(brm);

            using (StreamWriter sw = new StreamWriter(Path + "\\batch.txt", true))
            {
                sw.WriteLine(json);
            }

            string value = HttpHelper.GetResponseValue(userManager.UserInfo.BatchContactUrl, HttpMethod.POST, json, userManager.UserInfo.Cookies);

            using (StreamWriter sw = new StreamWriter(Path + "\\member.txt", true))
            {
                sw.WriteLine(value);
            }
            InitialContactTree tree = JsonConvert.DeserializeObject <InitialContactTree>(value);

            tree.Initial();
            userManager.UserInfo.SetContact(tree.ContactList);
        }
Example #2
0
        private void InitialWeChat()
        {
            InitialTree(userManager.UserInfo.InitialUrl, true);
            StatusNotifyRequestModel snrm = StatusNotifyRequestModel.Create(userManager.UserInfo);

            string value = HttpHelper.GetResponseValue(userManager.UserInfo.StatusNotifyUrl, HttpMethod.POST, JsonConvert.SerializeObject(snrm), userManager.UserInfo.Cookies);

            value = HttpHelper.GetResponseValue(userManager.UserInfo.ContactUrl, HttpMethod.GET, null, userManager.UserInfo.Cookies);

            using (StreamWriter sw = new StreamWriter(Path + "\\getcontact.txt", true))
                sw.Write(value);

            MemberTree memberTree = JsonConvert.DeserializeObject <MemberTree>(value);

            BatchRequestModel brm = BatchRequestModel.Create(userManager.UserInfo);

            for (int i = 0; i < memberTree.MemberCount; ++i)
            {
                brm.Count++;
                brm.List.AddLast(new BatchItem {
                    UserName = memberTree.MemberList[i].UserName
                });
                if (i > 0 && i % 50 == 0)
                {
                    string json = JsonConvert.SerializeObject(brm);
                    using (StreamWriter sw = new StreamWriter(Path + "\\batch.txt", true))
                    {
                        sw.WriteLine(json);
                    }

                    value = HttpHelper.GetResponseValue(userManager.UserInfo.BatchContactUrl, HttpMethod.POST, json, userManager.UserInfo.Cookies);
                    InitialContactTree tree = JsonConvert.DeserializeObject <InitialContactTree>(value);
                    tree.Initial();
                    userManager.UserInfo.SetContact(tree.ContactList);

                    brm.Count = 0;
                    brm.List.Clear();

                    Thread.Sleep(100);
                }
            }

            if (brm.Count > 0)
            {
                string json = JsonConvert.SerializeObject(brm);
                using (StreamWriter sw = new StreamWriter(Path + "\\batch.txt", true))
                {
                    sw.WriteLine(json);
                }

                value = HttpHelper.GetResponseValue(userManager.UserInfo.BatchContactUrl, HttpMethod.POST, json, userManager.UserInfo.Cookies);
                using (StreamWriter sw = new StreamWriter(Path + "\\member.txt", true))
                {
                    sw.WriteLine(value);
                }
                InitialContactTree tree = JsonConvert.DeserializeObject <InitialContactTree>(value);
                tree.Initial();
                userManager.UserInfo.SetContact(tree.ContactList);
            }
        }