Exemplo n.º 1
0
        private void Next()
        {
            if ((this.ZimbraServerHostName.Length == 0) || (this.ZimbraPort.Length == 0))
            {
            MessageBox.Show("Please fill in the host name and port", "Zimbra Migration",
                MessageBoxButton.OK, MessageBoxImage.Error);
            return;
            }
            try
            {
            System.Net.IPAddress address = System.Net.IPAddress.Parse(ZimbraServerHostName);
            MessageBox.Show("Please enter a valid host name rather than an IP address",
                "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
            return;
            }
            catch (Exception)
            {}
            ZimbraAPI zimbraAPI = new ZimbraAPI(false);

            int stat = -1;
            try
            {
            stat = zimbraAPI.Logon(this.ZimbraServerHostName, this.ZimbraPort, this.ZimbraUser,
                this.ZimbraUserPasswd, this.ZimbraSSL, false);
            }
            catch (Exception e)
            {
            MessageBox.Show(e.Message, "Logon", MessageBoxButton.OK, MessageBoxImage.Error);
            return;
            }

            if (stat == 0)
            {
            string authToken = ZimbraValues.GetZimbraValues().AuthToken;

            if (authToken.Length > 0)
            {
                zimbraAPI.GetInfo();
                lb.SelectedIndex = 3;
            }
            }
            else
            {
            MessageBox.Show(string.Format("Logon Unsuccessful: {0}", zimbraAPI.LastError),
                "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }