Exemple #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);
                }
            }
        }
        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);
            }
        }
Exemple #3
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);
            }
        }
Exemple #4
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;
        }
Exemple #5
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);
            }
        }
Exemple #6
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);
                }
            }
        }
        // Background thread stuff
        private void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            eventArglist.Add(e);

            int num = (int)e.Argument;

            Log.info(" In Do work for threads for user number", num);
            MigrationAccount        MyAcct                  = new MigrationAccount();
            UsersViewModel          usersViewModel          = ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);
            AccountResultsViewModel accountResultsViewModel =
                ((AccountResultsViewModel)ViewModelPtrs[(int)ViewType.RESULTS]); // main one
            string accountname = accountResultsViewModel.AccountResultsList[num].AccountName;
            string accountid   = "";

            if (isServer)
            {
                accountname = accountname + "@" + usersViewModel.ZimbraDomain;
                accountid   = usersViewModel.UsersList[num].Username;

                int idx = accountid.IndexOf("@");

                if (idx != -1)                  // domain would be Exchange domain, not Zimbra domain
                {
                    accountid = accountid.Substring(0, idx);
                }
            }
            else
            {
                ConfigViewModelU sourceModel =
                    ((ConfigViewModelU)ViewModelPtrs[(int)ViewType.USRSRC]);
                ConfigViewModelUDest destModel =
                    ((ConfigViewModelUDest)ViewModelPtrs[(int)ViewType.USRDEST]);

                accountname = ZimbraValues.GetZimbraValues().AccountName;//accountname + "@" + destModel.ZimbraServerHostName;
                accountid   = (sourceModel.IspST) ? sourceModel.PSTFile :
                              sourceModel.ProfileList[sourceModel.CurrentProfileSelection];
            }
            MyAcct.AccountName = accountname;
            MyAcct.AccountID   = accountid;
            MyAcct.AccountNum  = num;
            MyAcct.OnChanged  += new MigrationObjectEventHandler(Acct_OnAcctChanged);

            MigrationFolder MyFolder = new MigrationFolder();

            MyFolder.AccountNum = num;
            MyFolder.OnChanged += new MigrationObjectEventHandler(Folder_OnChanged);

            MyAcct.migrationFolder = MyFolder;

            CSMigrationWrapper mw         = ((IntroViewModel)ViewModelPtrs[(int)ViewType.INTRO]).mw;
            MigrationOptions   importOpts = SetOptions();
            bool isVerbose     = ((OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS]).LoggingVerbose;
            bool doRulesAndOOO = ((OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS]).OEnableRulesAndOOO;


            if (isVerbose)
            {
                if (importOpts.VerboseOn < LogLevel.Debug)
                {
                    importOpts.VerboseOn = LogLevel.Debug;
                }
            }

            Log.info(" start migration for account ", MyAcct.AccountNum);

            //mw.StartMigration(MyAcct, importOpts, isServer, (isVerbose ? (LogLevel.Debug):(LogLevel.Info)), m_isPreview);
            mw.StartMigration(MyAcct, importOpts, isServer, importOpts.VerboseOn, m_isPreview, doRulesAndOOO);



            // special case to format last user progress message
            int count = accountResultsViewModel.AccountResultsList[num].UserResultsList.Count;

            if (count > 0)
            {
                if (!m_isPreview)
                {
                    string lastmsg      = accountResultsViewModel.AccountResultsList[num].UserResultsList[count - 1].UserProgressMsg;
                    int    len          = lastmsg.Length;
                    bool   isOOOorRules = ((MyFolder.FolderView == "OOO") || (MyFolder.FolderView == "All Rules"));
                    accountResultsViewModel.AccountResultsList[num].UserResultsList[count - 1].UserProgressMsg = FormatTheLastMsg(MyFolder, isOOOorRules);
                    accountResultsViewModel.AccountResultsList[num].PBValue = 100; // to make sure
                    if (accountResultsViewModel.AccountResultsList[num].CurrentItemNum != accountResultsViewModel.AccountResultsList[num].TotalItemsToMigrate)
                    {
                        FormatGlobalMsg(accountResultsViewModel.AccountResultsList[num]);
                    }
                }
                else
                { // For preview, take the "foldername (n items)" message we constructed, extract the n, and make "Total n"
                    string msg      = "";
                    string lastmsg  = accountResultsViewModel.AccountResultsList[num].PBMsgValue;
                    int    idxParen = lastmsg.IndexOf("(");
                    int    idxItems = lastmsg.IndexOf("items");
                    if ((idxParen != -1) && (idxItems != -1))
                    {
                        int    numLen = idxItems - idxParen - 2; // for the paren and the space
                        string numStr = lastmsg.Substring(idxParen + 1, numLen);
                        msg = "Total: " + numStr;
                        accountResultsViewModel.AccountResultsList[num].UserResultsList[count - 1].UserProgressMsg = (msg.Length > 0) ? msg : "";
                    }
                }
            }
            /////

            if (!m_isPreview)
            {
                int tnum = GetThreadNum(MyAcct.AccountNum);
                //Log.info(" in worker_RunWorkerCompleted  for ThreadNum : " + tnum);

                Log.info(" in DOWORK -- Migration completed for usernum: " + MyAcct.AccountNum + " and threadnum" + tnum);
                accountResultsViewModel.AccountResultsList[num].PBMsgValue      = "Migration complete";
                accountResultsViewModel.AccountResultsList[num].AcctProgressMsg = "Complete";
            }
            else
            {
                string msg = "Total items: {0}";
                accountResultsViewModel.AccountResultsList[num].PBMsgValue = String.Format(msg, accountResultsViewModel.AccountResultsList[num].TotalItemsToMigrate);
            }

            if (importOpts.IsMaintainenceMode)
            {
                accountResultsViewModel.AccountResultsList[num].PBMsgValue      = "Migration Incomplete";
                accountResultsViewModel.AccountResultsList[num].AcctProgressMsg = "InComplete";
            }
        }
Exemple #8
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");
                }
            }
        }
Exemple #9
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;
                }
            }
        }
Exemple #10
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;
        }
Exemple #11
0
        public void SetupViews(bool isBrowser)
        {
            m_isBrowser            = isBrowser;
            BaseViewModel.isServer = true;      // because we start out with Server on -- wouldn't get set by command
            IsServerMigration      = true;
            IsUserMigration        = false;
            savedDomain            = "";
            ZimbraValues.GetZimbraValues().ClientVersion = BuildNum;

            m_configViewModelS                    = new ConfigViewModelS();
            m_configViewModelS.Name               = "ConfigViewModelS";
            m_configViewModelS.ViewTitle          = "Source";
            m_configViewModelS.lb                 = lb;
            m_configViewModelS.isBrowser          = isBrowser;
            m_configViewModelS.OutlookProfile     = "";
            m_configViewModelS.MailServerHostName = "";
            m_configViewModelS.MailServerAdminID  = "";
            m_configViewModelS.MailServerAdminPwd = "";

            m_configViewModelU                = new ConfigViewModelU();
            m_configViewModelU.Name           = "ConfigViewModelU";
            m_configViewModelU.ViewTitle      = "Source";
            m_configViewModelU.lb             = lb;
            m_configViewModelU.isBrowser      = isBrowser;
            m_configViewModelU.OutlookProfile = "";
            m_configViewModelU.PSTFile        = "";
            m_configViewModelU.OutlookProfile = "";

            m_configViewModelSDest                      = new ConfigViewModelSDest();
            m_configViewModelSDest.Name                 = "ConfigViewModelSDest";
            m_configViewModelSDest.ViewTitle            = "Destination";
            m_configViewModelSDest.lb                   = lb;
            m_configViewModelSDest.isBrowser            = isBrowser;
            m_configViewModelSDest.ZimbraServerHostName = "";
            m_configViewModelSDest.ZimbraPort           = "";
            m_configViewModelSDest.ZimbraAdmin          = "";
            m_configViewModelSDest.ZimbraAdminPasswd    = "";
            m_configViewModelSDest.ZimbraSSL            = true;

            m_configViewModelUDest                      = new ConfigViewModelUDest();
            m_configViewModelUDest.Name                 = "ConfigViewModelUDest";
            m_configViewModelUDest.ViewTitle            = "Destination";
            m_configViewModelUDest.lb                   = lb;
            m_configViewModelUDest.isBrowser            = isBrowser;
            m_configViewModelUDest.ZimbraServerHostName = "";
            m_configViewModelUDest.ZimbraPort           = "";
            m_configViewModelUDest.ZimbraUser           = "";
            m_configViewModelUDest.ZimbraUserPasswd     = "";
            m_configViewModelUDest.ZimbraSSL            = true;

            m_optionsViewModel                          = new OptionsViewModel();
            m_optionsViewModel.Name                     = "OptionsViewModel";
            m_optionsViewModel.ViewTitle                = "Options";
            m_optionsViewModel.lb                       = lb;
            m_optionsViewModel.isBrowser                = isBrowser;
            m_optionsViewModel.ImportMailOptions        = true;
            m_optionsViewModel.ImportTaskOptions        = true;
            m_optionsViewModel.ImportCalendarOptions    = true;
            m_optionsViewModel.ImportContactOptions     = true;
            m_optionsViewModel.ImportRuleOptions        = true;
            m_optionsViewModel.ImportOOOOptions         = true;
            m_optionsViewModel.ImportJunkOptions        = false;
            m_optionsViewModel.ImportDeletedItemOptions = false;
            m_optionsViewModel.ImportSentOptions        = false;
            m_optionsViewModel.LoggingVerbose           = false;
            m_optionsViewModel.LogLevel                 = LogLevel.Info.ToString();
            m_optionsViewModel.MaxThreadCount           = 0;
            m_optionsViewModel.MaxErrorCount            = 0;
            m_optionsViewModel.OEnableRulesAndOOO       = true;
            m_optionsViewModel.OEnableNext              = true;
            m_optionsViewModel.MigrateONRAfter          = (DateTime.Now.AddMonths(-3)).ToShortDateString();
            m_optionsViewModel.IsMaxMessageSize         = false;
            m_optionsViewModel.IsSkipPrevMigratedItems  = false;
            m_optionsViewModel.MaxMessageSize           = "";
            m_optionsViewModel.IsSkipFolders            = false;

            m_scheduleViewModel              = new ScheduleViewModel();
            m_scheduleViewModel.Name         = "Schedule";
            m_scheduleViewModel.ViewTitle    = "Migrate";
            m_scheduleViewModel.lb           = lb;
            m_scheduleViewModel.isBrowser    = isBrowser;
            m_scheduleViewModel.COS          = "default";
            m_scheduleViewModel.DefaultPWD   = "";
            m_scheduleViewModel.ScheduleDate = DateTime.Now.ToShortDateString();
            m_scheduleViewModel.EnableProvGB = false;

            m_usersViewModel                      = new UsersViewModel("", "");
            m_usersViewModel.Name                 = "Users";
            m_usersViewModel.ViewTitle            = "Users";
            m_usersViewModel.lb                   = lb;
            m_usersViewModel.ZimbraDomain         = "";
            m_usersViewModel.isBrowser            = isBrowser;
            m_usersViewModel.CurrentUserSelection = -1;
            m_usersViewModel.svm                  = m_scheduleViewModel; // LDAP Browser needs to get to ScheduleView to set EnableMigrate

            m_resultsViewModel = new AccountResultsViewModel(m_scheduleViewModel, -1, 0, "", "", "",
                                                             0, "", 0, 0, false);
            m_resultsViewModel.Name      = "Results";
            m_resultsViewModel.ViewTitle = "Results";
            m_resultsViewModel.isBrowser = isBrowser;
            m_resultsViewModel.CurrentAccountSelection = -1;
            m_resultsViewModel.OpenLogFileEnabled      = false;

            SetupViewModelPtrs();

            TheViews = new ObservableCollection <object>();
            TheViews.Add(this);
        }
Exemple #12
0
        public void SetupViews(bool isBrowser)
        {
            using (LogBlock logblock = Log.NotTracing()?null: new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                m_isBrowser = isBrowser;

                BaseViewModel.isServer = true;      // because we start out with Server on -- wouldn't get set by command

                rbServerMigration = true;
                rbUserMigration   = false;

                savedDomain = "";
                ZimbraValues.GetZimbraValues().ClientVersion = BuildNum;

                // ------------------------------------------------------------
                // Source pages
                // ------------------------------------------------------------

                // Server mig version
                m_configViewModelS                    = new ConfigViewModelS();
                m_configViewModelS.Name               = "ConfigViewModelS";
                m_configViewModelS.ViewTitle          = "Source";
                m_configViewModelS.lb                 = lb;
                m_configViewModelS.isBrowser          = isBrowser;
                m_configViewModelS.OutlookProfile     = "";
                m_configViewModelS.MailServerHostName = "";
                m_configViewModelS.MailServerAdminID  = "";
                m_configViewModelS.MailServerAdminPwd = "";

                // User mig version
                m_configViewModelU                = new ConfigViewModelU();
                m_configViewModelU.Name           = "ConfigViewModelU";
                m_configViewModelU.ViewTitle      = "Source";
                m_configViewModelU.lb             = lb;
                m_configViewModelU.isBrowser      = isBrowser;
                m_configViewModelU.OutlookProfile = "";
                m_configViewModelU.PSTFile        = "";
                m_configViewModelU.OutlookProfile = "";

                // ZD mig version
                m_configViewModelZU                = new ConfigViewModelZU();
                m_configViewModelZU.Name           = "ConfigViewModelZU";
                m_configViewModelZU.ViewTitle      = "Source";
                m_configViewModelZU.lb             = lb;
                m_configViewModelZU.isBrowser      = isBrowser;
                m_configViewModelZU.OutlookProfile = "";
                m_configViewModelZU.PSTFile        = "";
                m_configViewModelZU.OutlookProfile = "";


                // ------------------------------------------------------------
                // Destination pages
                // ------------------------------------------------------------

                // Server mig version
                m_configViewModelSDest                      = new ConfigViewModelSDest();
                m_configViewModelSDest.Name                 = "ConfigViewModelSDest";
                m_configViewModelSDest.ViewTitle            = "Destination";
                m_configViewModelSDest.lb                   = lb;
                m_configViewModelSDest.isBrowser            = isBrowser;
                m_configViewModelSDest.ZimbraServerHostName = "";
                m_configViewModelSDest.ZimbraPort           = "";
                m_configViewModelSDest.ZimbraAdmin          = "";
                m_configViewModelSDest.ZimbraAdminPasswd    = "";
                m_configViewModelSDest.ZimbraSSL            = true;

                // User mig version
                m_configViewModelUDest                      = new ConfigViewModelUDest();
                m_configViewModelUDest.Name                 = "ConfigViewModelUDest";
                m_configViewModelUDest.ViewTitle            = "Destination";
                m_configViewModelUDest.lb                   = lb;
                m_configViewModelUDest.isBrowser            = isBrowser;
                m_configViewModelUDest.ZimbraServerHostName = "";
                m_configViewModelUDest.ZimbraPort           = "";
                m_configViewModelUDest.ZimbraUser           = "";
                m_configViewModelUDest.ZimbraUserPasswd     = "";
                m_configViewModelUDest.ZimbraSSL            = true;

                // ZD mig version
                // (No dest page for ZD)

                // ------------------------------------------------------------
                // Option page
                // ------------------------------------------------------------
                m_optionsViewModel                          = new OptionsViewModel();
                m_optionsViewModel.Name                     = "OptionsViewModel";
                m_optionsViewModel.ViewTitle                = "Options";
                m_optionsViewModel.lb                       = lb;
                m_optionsViewModel.isBrowser                = isBrowser;
                m_optionsViewModel.ImportMailOptions        = true;
                m_optionsViewModel.ImportTaskOptions        = true;
                m_optionsViewModel.ImportCalendarOptions    = true;
                m_optionsViewModel.ImportContactOptions     = true;
                m_optionsViewModel.ImportRuleOptions        = true;
                m_optionsViewModel.ImportOOOOptions         = true;
                m_optionsViewModel.ImportJunkOptions        = false;
                m_optionsViewModel.ImportDeletedItemOptions = false;
                m_optionsViewModel.ImportSentOptions        = false;

                m_optionsViewModel.MaxThreadCount          = 0;
                m_optionsViewModel.MaxErrorCount           = 0;
                m_optionsViewModel.OEnableRulesAndOOO      = true;
                m_optionsViewModel.OEnablePF               = true;
                m_optionsViewModel.OEnableNext             = true;
                m_optionsViewModel.MigrateONRAfter         = (DateTime.Now.AddMonths(-3)).ToShortDateString();
                m_optionsViewModel.IsMaxMessageSize        = false;
                m_optionsViewModel.IsSkipPrevMigratedItems = false;
                m_optionsViewModel.MaxMessageSize          = "";
                m_optionsViewModel.IsSkipFolders           = false;

                // ------------------------------------------------------------
                // Scedule page
                // ------------------------------------------------------------
                m_scheduleViewModel              = new ScheduleViewModel();
                m_scheduleViewModel.Name         = "Schedule";
                m_scheduleViewModel.ViewTitle    = "Migrate";
                m_scheduleViewModel.lb           = lb;
                m_scheduleViewModel.isBrowser    = isBrowser;
                m_scheduleViewModel.COS          = "default";
                m_scheduleViewModel.DefaultPWD   = "";
                m_scheduleViewModel.ScheduleDate = DateTime.Now.ToShortDateString();
                m_scheduleViewModel.EnableProvGB = false;

                // ------------------------------------------------------------
                // Users page
                // ------------------------------------------------------------
                m_usersViewModel                      = new UsersViewModel("", "");
                m_usersViewModel.Name                 = "Users";
                m_usersViewModel.ViewTitle            = "Users";
                m_usersViewModel.lb                   = lb;
                m_usersViewModel.ZimbraDomain         = "";
                m_usersViewModel.isBrowser            = isBrowser;
                m_usersViewModel.CurrentUserSelection = -1;
                m_usersViewModel.svm                  = m_scheduleViewModel;    // LDAP Browser needs to get to ScheduleView to set EnableMigrate

                // ------------------------------------------------------------
                // Public folders page
                // ------------------------------------------------------------
                m_publicfoldersViewModel              = new PublicfoldersViewModel("", "");
                m_publicfoldersViewModel.Name         = "PublicFolders";
                m_publicfoldersViewModel.ViewTitle    = "Public Folders";
                m_publicfoldersViewModel.lb           = lb;
                m_publicfoldersViewModel.ZimbraDomain = "";
                m_publicfoldersViewModel.isBrowser    = isBrowser;
                m_publicfoldersViewModel.svm          = m_scheduleViewModel;    // LDAP Browser needs to get to ScheduleView to set EnableMigrate

                // ------------------------------------------------------------
                // Results page
                // ------------------------------------------------------------
                m_resultsViewModel           = new AccountResultsViewModel(m_scheduleViewModel, -1, "", false);
                m_resultsViewModel.Name      = "Results";
                m_resultsViewModel.ViewTitle = "Results";
                m_resultsViewModel.isBrowser = isBrowser;
                m_resultsViewModel.CurrentAccountSelection = -1;
                m_resultsViewModel.OpenLogFileEnabled      = false;

                SetupViewModelPtrs();

                TheViews = new ObservableCollection <object>();
                TheViews.Add(this);
            }
        }