示例#1
0
        public async static void FillingUserInfoAsync(MailBox mailBox, ViewModel viewModel)
        {
            if (mailBox == null)
            {
                return;
            }
            string domainName = mailBox.Domain;
            string name       = mailBox.Name;
            string hostName   = viewModel.MailServer;
            string userName   = viewModel.UserNameForMailServer;
            string password   = viewModel.PasswordBox?.Password;

            if (viewModel.PasswordBox != null)
            {
                await Task.Run(() =>
                {
                    XmlGetUserInfoReq xmlGetUserInfoReq = new XmlGetUserInfoReq(domainName, name);
                    string xmlResponse      = ApiClient.Request(hostName, userName, password, xmlGetUserInfoReq.ToString());
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.LoadXml(xmlResponse);
                    XmlNodeList xmlNodeList;
                    xmlNodeList = xmlDocument.GetElementsByTagName("Password");
                    if (xmlNodeList.Count > 0)
                    {
                        mailBox.Password = xmlNodeList[0].InnerText;
                    }
                    else
                    {
                        mailBox.NoOk();
                        return;
                    }

                    xmlNodeList = xmlDocument.GetElementsByTagName("FirstName");
                    if (xmlNodeList.Count > 0)
                    {
                        mailBox.FirstName = xmlNodeList[0].InnerText;
                    }

                    xmlNodeList = xmlDocument.GetElementsByTagName("LastName");
                    if (xmlNodeList.Count > 0)
                    {
                        mailBox.LastName = xmlNodeList[0].InnerText;
                    }

                    xmlNodeList = xmlDocument.GetElementsByTagName("Frozen");
                    if (xmlNodeList.Count > 0)
                    {
                        mailBox.Frozen = xmlNodeList[0].InnerText;
                    }

                    xmlNodeList = xmlDocument.GetElementsByTagName("Disabled");
                    if (xmlNodeList.Count > 0)
                    {
                        mailBox.Disabled = xmlNodeList[0].InnerText;
                    }

                    xmlNodeList = xmlDocument.GetElementsByTagName("MailDir");
                    if (xmlNodeList.Count > 0)
                    {
                        mailBox.MailDir = xmlNodeList[0].InnerText;
                    }
                });
            }
        }