예제 #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;
            }

            ZimbraAPI zimbraAPI = new ZimbraAPI(true);
            int stat = -1;
            try
            {
            stat = zimbraAPI.Logon(this.ZimbraServerHostName, this.ZimbraPort, this.ZimbraAdmin,
                this.ZimbraAdminPasswd, this.ZimbraSSL, true);
            }
            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)
            {
                UsersViewModel usersViewModel =
                    ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);
                ScheduleViewModel scheduleViewModel =
                    ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);

                string currentDomain = (usersViewModel.DomainInfoList.Count > 0) ?
                    usersViewModel.DomainInfoList[usersViewModel.CurrentDomainSelection].DomainName : "";

                usersViewModel.DomainInfoList.Clear();
                usersViewModel.DomainList.Clear();
                scheduleViewModel.CosList.Clear();

                zimbraAPI.GetAllDomains();

                foreach (DomainInfo domaininfo in ZimbraValues.GetZimbraValues().ZimbraDomains)
                {
                    string dName = domaininfo.DomainName;
                    usersViewModel.DomainInfoList.Add(new DomainInfo(domaininfo.DomainName, domaininfo.DomainID, domaininfo.zimbraDomainDefaultCOSId));
                    usersViewModel.DomainList.Add(dName);

                    if (dName == currentDomain)
                        usersViewModel.CurrentDomainSelection = usersViewModel.DomainInfoList.Count;
                }

                usersViewModel.DomainsFilledIn = true;

                zimbraAPI.GetAllCos();

                foreach (CosInfo cosinfo in ZimbraValues.GetZimbraValues().COSes)
                {
                    scheduleViewModel.CosList.Add(new CosInfo(cosinfo.CosName, cosinfo.CosID));
                }
                lb.SelectedIndex = 3;
            }
            }
            else
            {
            MessageBox.Show(string.Format("Logon Unsuccessful: {0}", zimbraAPI.LastError),
                "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #2
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;
        }

        ZimbraAPI zimbraAPI = new ZimbraAPI(true);
        int stat = -1;
        try
        {
            stat = zimbraAPI.Logon(this.ZimbraServerHostName, this.ZimbraPort, this.ZimbraAdmin,
                this.ZimbraAdminPasswd, this.ZimbraSSL, true);
        }
        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)
            {
                UsersViewModel usersViewModel =
                    ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);
                ScheduleViewModel scheduleViewModel =
                    ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);
                string currentDomain = (usersViewModel.DomainList.Count > 0) ?
                    usersViewModel.DomainList[usersViewModel.CurrentDomainSelection] : "";

                usersViewModel.DomainList.Clear();
                scheduleViewModel.CosList.Clear();
                zimbraAPI.GetAllDomains();
                for (int i = 0; i < ZimbraValues.GetZimbraValues().Domains.Count; i++)
                {
                    string s = ZimbraValues.GetZimbraValues().Domains[i];

                    usersViewModel.DomainList.Add(s);
                    // if we've loaded a config file where the domain was specified, then set it as selected
                    if (currentDomain != null)
                    {
                        if (currentDomain.Length > 0)
                        {
                            if (s == currentDomain)
                                usersViewModel.CurrentDomainSelection = i;
                            usersViewModel.DomainsFilledIn = true;
                        }
                    }
                }
                zimbraAPI.GetAllCos();
                foreach (CosInfo cosinfo in ZimbraValues.GetZimbraValues().COSes)
                {
                    scheduleViewModel.CosList.Add(new CosInfo(cosinfo.CosName, cosinfo.CosID));
                }
                lb.SelectedIndex = 3;
            }
        }
        else
        {
            MessageBox.Show(string.Format("Logon Unsuccessful: {0}", zimbraAPI.LastError),
                "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
        }
    }