Beispiel #1
0
        private void Next()
        {
            using (LogBlock logblock = Log.NotTracing() ? null : new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                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;
                }

                Log.info("ZimbraHostName: " + this.ZimbraServerHostName + "  ZimbraPort: " + this.ZimbraPort);
                Log.info("ZimbraUser: "******"  SSL: " + this.ZimbraSSL);

                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)
                {
                }

                // ======================================================================
                // Initial server logon
                // ======================================================================
                //Debug.WriteLine("Connecting to server...");
                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);
                }
            }
        }
Beispiel #2
0
        private void Next()
        {
            if (!ValidateUsersList(true))
            {
                return;
            }
            ZimbraAPI zimbraAPI = new ZimbraAPI(isServer);

            if (ZimbraValues.zimbraValues.AuthToken.Length == 0)
            {
                MessageBox.Show("You must log on to the Zimbra server", "Zimbra Migration",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            SaveDomain();

            ScheduleViewModel scheduleViewModel =
                ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);

            scheduleViewModel.EnableProvGB = false;
            for (int i = 0; i < UsersList.Count; i++)
            {
                string userName = (UsersList[i].MappedName.Length > 0) ? UsersList[i].MappedName :
                                  UsersList[i].Username;
                string acctName = userName + '@' + ZimbraDomain;

                if (zimbraAPI.GetAccount(acctName) == 0)
                {
                    UsersList[i].IsProvisioned = true;
                    scheduleViewModel.SchedList[i].isProvisioned = true; // get (SchedList) in schedule view model will set again
                }
                else if (zimbraAPI.LastError.IndexOf("no such account") != -1)
                {
                    UsersList[i].IsProvisioned = false; // get (SchedList) in schedule view model will set again
                    scheduleViewModel.SchedList[i].isProvisioned = false;
                    if (!scheduleViewModel.EnableProvGB)
                    {
                        scheduleViewModel.EnableProvGB = true;
                    }
                }
                else
                {
                    MessageBox.Show(string.Format("Error accessing account {0}: {1}", acctName,
                                                  zimbraAPI.LastError), "Zimbra Migration", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
            lb.SelectedIndex = 5;
        }
        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);
            }
        }
Beispiel #4
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);
            }
        }
Beispiel #5
0
        private void Next()
        {
            if (!ValidateUsersList(true))
            {
                return;
            }

            ZimbraAPI zimbraAPI = new ZimbraAPI(isServer);

            if (ZimbraValues.zimbraValues.AuthToken.Length == 0)
            {
                MessageBox.Show("You must log on to the Zimbra server", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            SaveDomain();

            PublicfoldersViewModel publicfoldersViewModel = ((PublicfoldersViewModel)ViewModelPtrs[(int)ViewType.PUBFLDS]);
            ScheduleViewModel      scheduleViewModel      = ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);

            scheduleViewModel.EnableProvGB = false;

            string acctName = ZimbraAccountName + '@' + ZimbraDomain;

            if (zimbraAPI.GetAccount(acctName) == 0)
            {
                UsersList[0].IsProvisioned = true;
                {
                    SchedUser schd = new SchedUser(ZimbraAccountName, true);
                    scheduleViewModel.SchedList.Add(schd);
                    //scheduleViewModel.SchedList[0].isProvisioned = true;
                }
                scheduleViewModel.SchedfolderList[0].isProvisioned = true; // get (SchedList) in schedule view model will set again
            }
            else
            if (zimbraAPI.LastError.IndexOf("no such account") != -1)
            {
                UsersList[0].IsProvisioned = false; // get (SchedList) in schedule view model will set again
                scheduleViewModel.SchedList[0].isProvisioned       = false;
                scheduleViewModel.SchedfolderList[0].isProvisioned = false;
                if (!scheduleViewModel.EnableProvGB)
                {
                    scheduleViewModel.EnableProvGB = true;
                }
            }
            else
            {
                MessageBox.Show(string.Format("Error accessing account {0}: {1}", acctName, zimbraAPI.LastError), "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            //Logic to get the index of defaulf COS from CosList.
            for (int i = 0; i < scheduleViewModel.CosList.Count; i++)
            {
                if (scheduleViewModel.CosList[i].CosName == "default")
                {
                    ZimbraValues.GetZimbraValues().DefaultCosIndex = i;
                    break;
                }
            }

            foreach (DomainInfo domaininfo in ZimbraValues.GetZimbraValues().ZimbraDomains)
            {
                if (domaininfo.DomainName == publicfoldersViewModel.DomainList[publicfoldersViewModel.CurrentDomainSelection])
                {
                    if (domaininfo.zimbraDomainDefaultCOSId != "")
                    {
                        for (int i = 0; i < scheduleViewModel.CosList.Count; i++)
                        {
                            if (domaininfo.zimbraDomainDefaultCOSId == scheduleViewModel.CosList[i].CosID)
                            {
                                scheduleViewModel.CurrentCOSSelection = i;
                                break;
                            }
                        }
                    }
                    else
                    {
                        scheduleViewModel.CurrentCOSSelection = ZimbraValues.GetZimbraValues().DefaultCosIndex;
                    }
                    break;
                }
            }
            lb.SelectedIndex = 6;
        }
Beispiel #6
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);
            }
        }
Beispiel #7
0
        private void Next()
        {
            using (LogBlock logblock = Log.NotTracing() ? null : new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                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;
                }
                Log.info("ZimbraHostName: " + this.ZimbraServerHostName + "  ZimbraPort: " + this.ZimbraPort);
                Log.info("ZimbraAdmin: " + this.ZimbraAdmin + "  SSL: " + this.ZimbraSSL);

                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]);
                        PublicfoldersViewModel publicfoldersViewModel = ((PublicfoldersViewModel)ViewModelPtrs[(int)ViewType.PUBFLDS]);


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

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

                        // ----------------------------------------------
                        // Get domains
                        // ----------------------------------------------
                        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);

                            publicfoldersViewModel.DomainInfoList.Add(new DomainInfo(domaininfo.DomainName, domaininfo.DomainID, domaininfo.zimbraDomainDefaultCOSId));
                            publicfoldersViewModel.DomainList.Add(dName);

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

                        usersViewModel.DomainsFilledIn         = true;
                        publicfoldersViewModel.DomainsFilledIn = true;

                        // ----------------------------------------------
                        // Get COS
                        // ----------------------------------------------
                        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);
                }
            }
        }
        public void DoMigrate(bool isPreview)
        {
            bgwlist.Clear();
            if (isServer)
            {
                if (CurrentCOSSelection == -1)
                {
                    CurrentCOSSelection = 0;
                }
                UsersViewModel usersViewModel =
                    ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);

                if (ZimbraValues.zimbraValues.AuthToken.Length == 0)
                {
                    MessageBox.Show("You must log on to the Zimbra server", "Zimbra Migration",
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                ConfigViewModelS sourceModel =
                    ((ConfigViewModelS)ViewModelPtrs[(int)ViewType.SVRSRC]);

                if (!sourceModel.IsMailServerInitialized)
                {
                    MessageBox.Show("You must log on to Exchange", "Zimbra Migration",
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                string          domainName  = usersViewModel.ZimbraDomain;
                string          defaultPWD  = DefaultPWD;
                string          tempMessage = "";
                bool            bProvision  = false;
                MessageBoxImage mbi         = MessageBoxImage.Information;

                for (int i = 0; i < SchedList.Count; i++)
                {
                    string userName = (usersViewModel.UsersList[i].MappedName.Length > 0) ?
                                      usersViewModel.UsersList[i].MappedName :
                                      usersViewModel.UsersList[i].Username;
                    string accountName = userName + "@" + domainName;

                    if (!SchedList[i].isProvisioned)
                    {
                        if (!isPreview)
                        {
                            bProvision = true;
                            if (defaultPWD.Length == 0)
                            {
                                MessageBox.Show("Please provide an initial password",
                                                "Zimbra Migration", MessageBoxButton.OK,
                                                MessageBoxImage.Exclamation);
                                return;
                            }

                            string    cosID     = CosList[CurrentCOSSelection].CosID;
                            ZimbraAPI zimbraAPI = new ZimbraAPI(isServer);

                            // FBS bug 71646 -- 3/26/12
                            string displayName = "";
                            string givenName   = "";
                            string sn          = "";
                            string zfp         = "";

                            // FBS bug 73395 -- 4/25/12
                            ObjectPickerInfo opinfo = usersViewModel.GetOPInfo();
                            if (opinfo.DisplayName.Length > 0)
                            {
                                displayName = opinfo.DisplayName;
                            }
                            if (opinfo.GivenName.Length > 0)
                            {
                                givenName = opinfo.GivenName;
                            }
                            if (opinfo.Sn.Length > 0)
                            {
                                sn = opinfo.Sn;
                            }
                            if (opinfo.Zfp.Length > 0)
                            {
                                zfp = opinfo.Zfp;
                            }
                            // end 73395
                            // end 71646

                            string historyfile = Path.GetTempPath() + accountName.Substring(0, accountName.IndexOf('@')) + "history.log";
                            if (File.Exists(historyfile))
                            {
                                try
                                {
                                    File.Delete(historyfile);
                                }
                                catch (Exception e)
                                {
                                    string msg = "exception in deleteing the Histroy file " + e.Message;
                                    System.Console.WriteLine(msg);
                                }
                            }

                            bool mustChangePW = usersViewModel.UsersList[i].MustChangePassword;
                            if (zimbraAPI.CreateAccount(accountName, displayName, givenName, sn, zfp, defaultPWD, mustChangePW, cosID) == 0)
                            {
                                tempMessage += string.Format("{0} Provisioned", userName) + "\n";
                                // MessageBox.Show(string.Format("{0} Provisioned", userName), "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                            else
                            {
                                // MessageBox.Show(string.Format("Provision unsuccessful for {0}: {1}", userName, zimbraAPI.LastError), "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                                tempMessage += string.Format("Provision unsuccessful for {0}: {1}",
                                                             userName, zimbraAPI.LastError) + "\n";
                                mbi = MessageBoxImage.Error;
                            }
                        }
                    }
                }
                if (bProvision)
                {
                    MessageBox.Show(tempMessage, "Zimbra Migration", MessageBoxButton.OK, mbi);
                }
                if (mbi == MessageBoxImage.Error)
                {
                    return;
                }
                lb.SelectedIndex = 6;
            }
            else
            {
                lb.SelectedIndex = 4;
            }

            AccountResultsViewModel accountResultsViewModel =
                ((AccountResultsViewModel)ViewModelPtrs[(int)ViewType.RESULTS]);

            accountResultsViewModel.AccountResultsList.Clear();
            if (isServer)
            {
                EnableMigrate = false;
                EnablePreview = false;
            }
            else
            {
                ((OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS]).OEnableNext = false;
            }
            accountResultsViewModel.EnableStop = !EnableMigrate;

            int num = 0;

            foreach (SchedUser su in SchedList)
            {
                accountResultsViewModel.AccountResultsList.Add(new AccountResultsViewModel(this,
                                                                                           num++, 0, "", "", su.username, 0, "", 0, 0,
                                                                                           accountResultsViewModel.EnableStop));
            }
            accountResultsViewModel.OpenLogFileEnabled = true;

            // FBS bug 71048 -- 4/16/12 -- use the correct number of threads.
            // If MaxThreadCount not specified, default to 4.  If fewer users than MaxThreadCount, numThreads = numUsers
            OptionsViewModel ovm = ((OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS]);
            int maxThreads       = (ovm.MaxThreadCount > 0) ? ovm.MaxThreadCount : 4;

            maxThreads = Math.Min(maxThreads, 8); // let's make 8 the limit for now
            int numUsers   = SchedList.Count;
            int numThreads = Math.Min(numUsers, maxThreads);

            for (int i = 0; i < numUsers; i++)
            {
                Log.info("Schedule bachground workers with numusers :" + numUsers + " and maxthreads are :" + numThreads);
                if (i < numThreads)
                {
                    UserBW bgw = new UserBW(i);
                    bgw.DoWork          += new System.ComponentModel.DoWorkEventHandler(worker_DoWork);
                    bgw.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(
                        worker_ProgressChanged);
                    bgw.WorkerReportsProgress      = true;
                    bgw.WorkerSupportsCancellation = true;
                    bgw.RunWorkerCompleted        += new System.ComponentModel.RunWorkerCompletedEventHandler(
                        worker_RunWorkerCompleted);
                    bgw.usernum = i;
                    bgw.RunWorkerAsync(i);
                    bgwlist.Add(bgw);
                    Log.info("Background worker started number :", bgw.threadnum);
                }
                else
                {
                    Log.info("adding user number to overflow list", i);
                    overflowList.Add(i);
                }
            }
            ;
        }
Beispiel #9
0
        public void DesktopLoad()
        {
            using (LogBlock logblock = Log.NotTracing() ? null : new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                string appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                string filePath      = Path.Combine(appDataFolder, "Zimbra\\Zimbra Desktop\\conf\\localconfig.xml");

                if (File.Exists(filePath))
                {
                    try
                    {
                        XmlDocument xml = new XmlDocument();
                        xml.Load(filePath);  // suppose that str string contains "<Names>...</Names>"

                        XmlNodeList xnList = xml.SelectNodes("//localconfig/key[@name='zdesktop_installation_key']");
                        string      pwd    = "";
                        foreach (XmlNode xn in xnList)
                        {
                            pwd = xn.InnerText;
                        }

                        xnList = xml.SelectNodes("//localconfig/key[@name='zimbra_admin_service_port']");
                        string port = "";
                        foreach (XmlNode xn in xnList)
                        {
                            port = xn.InnerText;
                        }


                        ZimbraServerHostName = "localhost";
                        ZimbraPort           = port;
                        ZimbraUser           = "******";
                        ZimbraUserPasswd     = pwd;
                        ZimbraSSL            = false;

                        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);
                        }
                    }
                    catch (Exception e)
                    {
                        string temp = string.Format("Incorrect configuration file format.\n{0}", e.Message);
                        MessageBox.Show(temp, "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                        //fileRead.Close();
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Please Install Zimbra Desktop before executing migration ", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    lb.SelectedIndex = 1;
                    throw new Exception("Can't find Zimbra Desktop installation");
                }
            }
        }
Beispiel #10
0
        private void Next()
        {
            using (LogBlock logblock = Log.NotTracing()?null: new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                if (!ValidateUsersList(true))
                {
                    return;
                }

                ZimbraAPI zimbraAPI = new ZimbraAPI(isServer);
                if (ZimbraValues.zimbraValues.AuthToken.Length == 0)
                {
                    MessageBox.Show("You must log on to the Zimbra server", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                SaveDomain();

                UsersViewModel    usersViewModel    = ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);
                ScheduleViewModel scheduleViewModel = ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);

                scheduleViewModel.EnableProvGB = false;
                for (int i = 0; i < UsersList.Count; i++)
                {
                    string userName = (UsersList[i].MappedName.Length > 0) ? UsersList[i].MappedName : UsersList[i].Username;
                    string acctName = userName + '@' + ZimbraDomain;

                    if (zimbraAPI.GetAccount(acctName, true) == 0)
                    {
                        UsersList[i].IsProvisioned = true;
                        scheduleViewModel.SchedList[i].isProvisioned = true; // get (SchedList) in schedule view model will set again
                    }
                    else
                    if (zimbraAPI.LastError.IndexOf("no such account") != -1)
                    {
                        UsersList[i].IsProvisioned = false; // get (SchedList) in schedule view model will set again
                        scheduleViewModel.SchedList[i].isProvisioned = false;
                        if (!scheduleViewModel.EnableProvGB)
                        {
                            scheduleViewModel.EnableProvGB = true;
                        }
                    }
                    else
                    {
                        MessageBox.Show(string.Format("Error accessing account {0}: {1}", acctName, zimbraAPI.LastError), "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }

                //Logic to get the index of defaulf COS from CosList.
                for (int i = 0; i < scheduleViewModel.CosList.Count; i++)
                {
                    if (scheduleViewModel.CosList[i].CosName == "default")
                    {
                        ZimbraValues.GetZimbraValues().DefaultCosIndex = i;
                        break;
                    }
                }

                foreach (DomainInfo domaininfo in ZimbraValues.GetZimbraValues().ZimbraDomains)
                {
                    if (domaininfo.DomainName == usersViewModel.DomainList[usersViewModel.CurrentDomainSelection])
                    {
                        if (domaininfo.zimbraDomainDefaultCOSId != "")
                        {
                            for (int i = 0; i < scheduleViewModel.CosList.Count; i++)
                            {
                                if (domaininfo.zimbraDomainDefaultCOSId == scheduleViewModel.CosList[i].CosID)
                                {
                                    scheduleViewModel.CurrentCOSSelection = i;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            scheduleViewModel.CurrentCOSSelection = ZimbraValues.GetZimbraValues().DefaultCosIndex;
                        }

                        break;
                    }
                }

                OptionsViewModel OViewModel = ((OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS]);

                if (OViewModel.IsPublicFolders)
                {
                    lb.SelectedIndex = 5;
                }
                else
                {
                    lb.SelectedIndex = 6;
                }
            }
        }
Beispiel #11
0
        private void Next()
        {
            if (!ValidateUsersList(true))
            {
                return;
            }
            ZimbraAPI zimbraAPI = new ZimbraAPI(isServer);

            if (ZimbraValues.zimbraValues.AuthToken.Length == 0)
            {
                MessageBox.Show("You must log on to the Zimbra server", "Zimbra Migration",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            SaveDomain();

            PublicfoldersViewModel publicfoldersViewModel =
                ((PublicfoldersViewModel)ViewModelPtrs[(int)ViewType.PUBFLDS]);
            ScheduleViewModel scheduleViewModel =
                ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);

            scheduleViewModel.EnableProvGB = false;



            /* for (int i = 0; i < UsersBKList.Count; i++)
             * {
             *   OptionsViewModel ovm = ((OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS]);
             *   ovm.IsSkipFolders = true;
             *   m_config.AdvancedImportOptions.FoldersToSkip = new Folder[UsersBKList.Count];
             *   string folderstoskip = "";
             *   for (i = 0; i < UsersBKList.Count; i++)
             *   {
             *       Folder tempUser = new Folder();
             *       tempUser.FolderName = UsersBKList[i].MappedName.ToString();
             *       folderstoskip += UsersBKList[i].MappedName.ToString();
             *       folderstoskip += ",";
             *       m_config.AdvancedImportOptions.FoldersToSkip.SetValue(tempUser, i);
             *
             *       m_config.AdvancedImportOptions.IsSkipFolders = true;
             *   }
             *   ovm.FoldersToSkip = folderstoskip;
             * }*/

            /* for (int i = 0; i < UsersList.Count; i++)
             * {
             *   string userName = (UsersList[i].MappedName.Length > 0) ? UsersList[i].MappedName :
             *       UsersList[i].Username;
             *   string acctName = userName + '@' + ZimbraDomain;
             *
             *   if (zimbraAPI.GetAccount(acctName) == 0)
             *   {
             *       UsersList[i].IsProvisioned = true;
             *       scheduleViewModel.SchedList[i].isProvisioned = true;    // get (SchedList) in schedule view model will set again
             *   }
             *   else if (zimbraAPI.LastError.IndexOf("no such account") != -1)
             *   {
             *       UsersList[i].IsProvisioned = false;     // get (SchedList) in schedule view model will set again
             *       scheduleViewModel.SchedList[i].isProvisioned = false;
             *       if (!scheduleViewModel.EnableProvGB)
             *       {
             *           scheduleViewModel.EnableProvGB = true;
             *       }
             *   }
             *   else
             *   {
             *       MessageBox.Show(string.Format("Error accessing account {0}: {1}", acctName,
             *           zimbraAPI.LastError), "Zimbra Migration", MessageBoxButton.OK,
             *           MessageBoxImage.Error);
             *   }
             * }*/
            string acctName = ZimbraAccountName + '@' + ZimbraDomain;

            if (zimbraAPI.GetAccount(acctName) == 0)
            {
                UsersList[0].IsProvisioned = true;
                {
                    SchedUser schd = new SchedUser(ZimbraAccountName, true);
                    scheduleViewModel.SchedList.Add(schd);
                    //scheduleViewModel.SchedList[0].isProvisioned = true;
                }
                scheduleViewModel.SchedfolderList[0].isProvisioned = true; // get (SchedList) in schedule view model will set again
            }
            else if (zimbraAPI.LastError.IndexOf("no such account") != -1)
            {
                UsersList[0].IsProvisioned = false; // get (SchedList) in schedule view model will set again
                scheduleViewModel.SchedList[0].isProvisioned       = false;
                scheduleViewModel.SchedfolderList[0].isProvisioned = false;
                if (!scheduleViewModel.EnableProvGB)
                {
                    scheduleViewModel.EnableProvGB = true;
                }
            }
            else
            {
                MessageBox.Show(string.Format("Error accessing account {0}: {1}", acctName,
                                              zimbraAPI.LastError), "Zimbra Migration", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            //Logic to get the index of defaulf COS from CosList.
            for (int i = 0; i < scheduleViewModel.CosList.Count; i++)
            {
                if (scheduleViewModel.CosList[i].CosName == "default")
                {
                    ZimbraValues.GetZimbraValues().DefaultCosIndex = i;
                    break;
                }
            }

            foreach (DomainInfo domaininfo in ZimbraValues.GetZimbraValues().ZimbraDomains)
            {
                if (domaininfo.DomainName == publicfoldersViewModel.DomainList[publicfoldersViewModel.CurrentDomainSelection])
                {
                    if (domaininfo.zimbraDomainDefaultCOSId != "")
                    {
                        for (int i = 0; i < scheduleViewModel.CosList.Count; i++)
                        {
                            if (domaininfo.zimbraDomainDefaultCOSId == scheduleViewModel.CosList[i].CosID)
                            {
                                scheduleViewModel.CurrentCOSSelection = i;
                                break;
                            }
                        }
                    }
                    else
                    {
                        scheduleViewModel.CurrentCOSSelection = ZimbraValues.GetZimbraValues().DefaultCosIndex;
                    }
                    break;
                }
            }
            lb.SelectedIndex = 6;
        }