Пример #1
0
        public void PopulateConfig(bool isServer)
        {
            ConfigViewModelS     serverSourceModel = (ConfigViewModelS)ViewModelPtrs[(int)ViewType.SVRSRC];
            ConfigViewModelSDest serverDestModel   = (ConfigViewModelSDest)ViewModelPtrs[(int)ViewType.SVRDEST];
            ConfigViewModelU     userSourceModel   = (ConfigViewModelU)ViewModelPtrs[(int)ViewType.USRSRC];
            ConfigViewModelUDest userDestModel     = (ConfigViewModelUDest)ViewModelPtrs[(int)ViewType.USRDEST];
            OptionsViewModel     optionsModel      = (OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS];
            UsersViewModel       usersModel        = (UsersViewModel)ViewModelPtrs[(int)ViewType.USERS];

            m_config.SourceServer.Profile = "";
            if (isServer)
            {
                int sel = serverSourceModel.CurrentProfileSelection;
                if (sel != -1)
                {
                    if (serverSourceModel.ProfileList.Count > 0)
                    {
                        m_config.SourceServer.Profile = serverSourceModel.ProfileList[sel];
                    }
                }
                m_config.SourceServer.Hostname   = serverSourceModel.MailServerHostName;
                m_config.SourceServer.AdminID    = serverSourceModel.MailServerAdminID;
                m_config.SourceServer.AdminPwd   = serverSourceModel.MailServerAdminPwd;
                m_config.SourceServer.UseProfile = serverSourceModel.Isprofile;
                m_config.ZimbraServer.Hostname   = serverDestModel.ZimbraServerHostName;
                m_config.ZimbraServer.Port       = serverDestModel.ZimbraPort;
                m_config.ZimbraServer.AdminID    = serverDestModel.ZimbraAdmin;
                m_config.ZimbraServer.AdminPwd   = serverDestModel.ZimbraAdminPasswd;
                m_config.ZimbraServer.UseSSL     = serverDestModel.ZimbraSSL;

                // FBS bug 73500 -- 5/18/12
                if (usersModel.ZimbraDomain.Length == 0)
                {
                    if (usersModel.DomainsFilledIn)
                    {
                        m_config.UserProvision.DestinationDomain = usersModel.DomainList[usersModel.CurrentDomainSelection];
                    }
                    else
                    if (savedDomain != null)
                    {
                        if (savedDomain.Length > 0)
                        {
                            m_config.UserProvision.DestinationDomain = savedDomain;
                        }
                    }
                }
                else
                {
                    m_config.UserProvision.DestinationDomain = usersModel.ZimbraDomain;
                }
                //
            }
            else
            {
                int sel = userSourceModel.CurrentProfileSelection;
                if (sel != -1)
                {
                    if (userSourceModel.ProfileList.Count > 0)
                    {
                        m_config.SourceServer.Profile = userSourceModel.ProfileList[sel];
                    }
                }
                m_config.SourceServer.DataFile     = userSourceModel.PSTFile;
                m_config.SourceServer.UseProfile   = userSourceModel.Isprofile;
                m_config.ZimbraServer.Hostname     = userDestModel.ZimbraServerHostName;
                m_config.ZimbraServer.Port         = userDestModel.ZimbraPort;
                m_config.ZimbraServer.UserAccount  = userDestModel.ZimbraUser;
                m_config.ZimbraServer.UserPassword = userDestModel.ZimbraUserPasswd;
            }
            m_config.GeneralOptions.LogLevel                = optionsModel.LogLevel;
            m_config.GeneralOptions.Verbose                 = optionsModel.LoggingVerbose;
            m_config.GeneralOptions.MaxThreadCount          = optionsModel.MaxThreadCount;
            m_config.GeneralOptions.MaxErrorCount           = optionsModel.MaxErrorCount;
            m_config.ImportOptions.Mail                     = optionsModel.ImportMailOptions;
            m_config.ImportOptions.Calendar                 = optionsModel.ImportCalendarOptions;
            m_config.ImportOptions.Contacts                 = optionsModel.ImportContactOptions;
            m_config.ImportOptions.DeletedItems             = optionsModel.ImportDeletedItemOptions;
            m_config.ImportOptions.Junk                     = optionsModel.ImportJunkOptions;
            m_config.ImportOptions.Tasks                    = optionsModel.ImportTaskOptions;
            m_config.ImportOptions.Sent                     = optionsModel.ImportSentOptions;
            m_config.ImportOptions.Rules                    = optionsModel.ImportRuleOptions;
            m_config.ImportOptions.OOO                      = optionsModel.ImportOOOOptions;
            m_config.AdvancedImportOptions.IsOnOrAfter      = optionsModel.IsOnOrAfter;
            m_config.AdvancedImportOptions.MigrateOnOrAfter =
                (optionsModel.IsOnOrAfter) ? DateTime.Parse(optionsModel.MigrateONRAfter)
            : DateTime.Now.AddMonths(-3);
            m_config.AdvancedImportOptions.IsSkipPrevMigratedItems = optionsModel.IsSkipPrevMigratedItems;
            m_config.AdvancedImportOptions.IsMaxMessageSize        = optionsModel.IsMaxMessageSize;
            m_config.AdvancedImportOptions.MaxMessageSize          =
                (optionsModel.IsMaxMessageSize) ? optionsModel.MaxMessageSize
            : "";
            m_config.AdvancedImportOptions.DateFilterItem = optionsModel.DateFilterItem;

            m_config.AdvancedImportOptions.SpecialCharReplace = optionsModel.SpecialCharReplace;
            m_config.AdvancedImportOptions.CSVDelimiter       = optionsModel.CSVDelimiter;
            m_config.AdvancedImportOptions.LangID             = optionsModel.LangID;
            m_config.AdvancedImportOptions.IsPublicFolders    = optionsModel.IsPublicFolders;
            // deal with skip folders
            m_config.AdvancedImportOptions.IsSkipFolders = optionsModel.IsSkipFolders;
            if (optionsModel.IsSkipFolders)
            {
                if (optionsModel.FoldersToSkip != null)
                {
                    if (optionsModel.FoldersToSkip.Length > 0)
                    {
                        string[] nameTokens = optionsModel.FoldersToSkip.Split(',');
                        int      numToSkip  = nameTokens.Length;
                        if (m_config.AdvancedImportOptions.FoldersToSkip == null)
                        {
                            m_config.AdvancedImportOptions.FoldersToSkip = new Folder[numToSkip];
                        }
                        for (int i = 0; i < numToSkip; i++)
                        {
                            Folder folder = new Folder();
                            folder.FolderName = nameTokens.GetValue(i).ToString();
                            m_config.AdvancedImportOptions.FoldersToSkip[i] = folder;
                        }
                    }
                }
            }
            else
            {
                m_config.AdvancedImportOptions.FoldersToSkip = null;
            }
        }
Пример #2
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);
        }
Пример #3
0
        public void PopulateConfigForSaving(bool isServer)
        // Called from from ViewModel Save() methods to populate m_config before serializing to disk
        {
            using (LogBlock logblock = Log.NotTracing()?null: new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                // Get ptr to each page from ViewModelPtrs
                ConfigViewModelS     serverSourceModel = (ConfigViewModelS)ViewModelPtrs[(int)ViewType.SVRSRC];
                ConfigViewModelSDest serverDestModel   = (ConfigViewModelSDest)ViewModelPtrs[(int)ViewType.SVRDEST];

                ConfigViewModelU     userSourceModel = (ConfigViewModelU)ViewModelPtrs[(int)ViewType.USRSRC];
                ConfigViewModelUDest userDestModel   = (ConfigViewModelUDest)ViewModelPtrs[(int)ViewType.USRDEST];

                OptionsViewModel  optionsModel  = (OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS];
                UsersViewModel    usersModel    = (UsersViewModel)ViewModelPtrs[(int)ViewType.USERS];
                ScheduleViewModel scheduleModel = (ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED];

                m_config.GeneralOptions.SchemaVersion = 1; // Schema version - increment if you change any of the options
                m_config.SourceServer.Profile         = "";

                if (isServer)
                {
                    // ==============================================================
                    // Server Migration
                    // ==============================================================
                    m_config.GeneralOptions.MigType = 1;

                    // ------------------------------
                    // SourceServer
                    // ------------------------------
                    int sel = serverSourceModel.CurrentProfileSelection;
                    if (sel != -1)
                    {
                        if (serverSourceModel.ProfileList.Count > 0)
                        {
                            m_config.SourceServer.Profile = serverSourceModel.ProfileList[sel];
                        }
                    }

                    m_config.SourceServer.Hostname   = serverSourceModel.MailServerHostName;
                    m_config.SourceServer.AdminID    = serverSourceModel.MailServerAdminID;
                    m_config.SourceServer.AdminPwd   = serverSourceModel.MailServerAdminPwd;
                    m_config.SourceServer.UseProfile = serverSourceModel.Isprofile;

                    // ------------------------------
                    // ZimbraServer (= dest server)
                    // ------------------------------
                    m_config.ZimbraServer.Hostname = serverDestModel.ZimbraServerHostName;
                    m_config.ZimbraServer.Port     = serverDestModel.ZimbraPort;
                    m_config.ZimbraServer.AdminID  = serverDestModel.ZimbraAdmin;
                    m_config.ZimbraServer.AdminPwd = serverDestModel.ZimbraAdminPasswd;
                    m_config.ZimbraServer.UseSSL   = serverDestModel.ZimbraSSL;


                    // ------------------------------
                    // UserProvision
                    // ------------------------------

                    // FBS bug 73500 -- 5/18/12
                    if (usersModel.ZimbraDomain.Length == 0)
                    {
                        if (usersModel.DomainsFilledIn)
                        {
                            m_config.UserProvision.DestinationDomain = usersModel.DomainList[usersModel.CurrentDomainSelection];
                            m_config.UserProvision.COS = scheduleModel.CosList[scheduleModel.CurrentCOSSelection].CosName;
                        }
                        else
                        if (savedDomain != null)
                        {
                            if (savedDomain.Length > 0)
                            {
                                m_config.UserProvision.DestinationDomain = savedDomain;
                            }
                        }
                    }
                    else
                    {
                        m_config.UserProvision.DestinationDomain = usersModel.ZimbraDomain;
                        m_config.UserProvision.COS = scheduleModel.COS;
                    }
                }
                else
                {
                    // ==============================================================
                    // User Migration (or ZD)
                    // ==============================================================
                    m_config.GeneralOptions.MigType = 2;

                    // ------------------------------
                    // SourceServer
                    // ------------------------------
                    int sel = userSourceModel.CurrentProfileSelection;
                    if (sel != -1)
                    {
                        if (userSourceModel.ProfileList.Count > 0)
                        {
                            m_config.SourceServer.Profile = userSourceModel.ProfileList[sel];
                        }
                    }

                    m_config.SourceServer.DataFile   = userSourceModel.PSTFile;
                    m_config.SourceServer.UseProfile = userSourceModel.Isprofile;

                    // ------------------------------
                    // ZimbraServer (= dest server)
                    // ------------------------------
                    m_config.ZimbraServer.Hostname     = userDestModel.ZimbraServerHostName;
                    m_config.ZimbraServer.Port         = userDestModel.ZimbraPort;
                    m_config.ZimbraServer.UserAccount  = userDestModel.ZimbraUser;
                    m_config.ZimbraServer.UserPassword = userDestModel.ZimbraUserPasswd;
                    m_config.ZimbraServer.UseSSL       = userDestModel.ZimbraSSL;
                }

                /*
                 * DCB - Where is the block for ZD settings?!
                 */


                // ==============================================================
                // Common to Server and User migration
                // ==============================================================


                // ------------------------------
                // GeneralOptions
                // ------------------------------
                m_config.GeneralOptions.LogLevel = Log.GlobalLogLevel.ToString();

                m_config.GeneralOptions.MaxThreadCount = optionsModel.MaxThreadCount;
                m_config.GeneralOptions.MaxErrorCount  = optionsModel.MaxErrorCount;

                // ------------------------------
                // ImportOptions
                // ------------------------------
                m_config.ImportOptions.Mail         = optionsModel.ImportMailOptions;
                m_config.ImportOptions.Calendar     = optionsModel.ImportCalendarOptions;
                m_config.ImportOptions.Contacts     = optionsModel.ImportContactOptions;
                m_config.ImportOptions.DeletedItems = optionsModel.ImportDeletedItemOptions;
                m_config.ImportOptions.Junk         = optionsModel.ImportJunkOptions;
                m_config.ImportOptions.Tasks        = optionsModel.ImportTaskOptions;
                m_config.ImportOptions.Sent         = optionsModel.ImportSentOptions;
                m_config.ImportOptions.Rules        = optionsModel.ImportRuleOptions;
                m_config.ImportOptions.OOO          = optionsModel.ImportOOOOptions;

                // ------------------------------
                // AdvancedImportOptions
                // ------------------------------
                m_config.AdvancedImportOptions.IsOnOrAfter      = optionsModel.IsOnOrAfter;
                m_config.AdvancedImportOptions.MigrateOnOrAfter = (optionsModel.IsOnOrAfter) ? DateTime.Parse(optionsModel.MigrateONRAfter) : DateTime.Now.AddMonths(-3);

                m_config.AdvancedImportOptions.IsSkipPrevMigratedItems = optionsModel.IsSkipPrevMigratedItems;

                m_config.AdvancedImportOptions.IsMaxMessageSize = optionsModel.IsMaxMessageSize;
                m_config.AdvancedImportOptions.MaxMessageSize   = (optionsModel.IsMaxMessageSize) ? optionsModel.MaxMessageSize : "";

                m_config.AdvancedImportOptions.DateFilterItem = optionsModel.DateFilterItem;

                m_config.AdvancedImportOptions.SpecialCharReplace = optionsModel.SpecialCharReplace;
                m_config.AdvancedImportOptions.CSVDelimiter       = optionsModel.CSVDelimiter;
                m_config.AdvancedImportOptions.IsPublicFolders    = optionsModel.IsPublicFolders;
                m_config.AdvancedImportOptions.IsZDesktop         = optionsModel.IsZDesktop;

                // Skipped folders
                m_config.AdvancedImportOptions.IsSkipFolders = optionsModel.IsSkipFolders;
                if (optionsModel.IsSkipFolders)
                {
                    if (optionsModel.FoldersToSkip != null)
                    {
                        if (optionsModel.FoldersToSkip.Length > 0)
                        {
                            string[] nameTokens = optionsModel.FoldersToSkip.Split(',');
                            int      numToSkip  = nameTokens.Length;
                            if (m_config.AdvancedImportOptions.FoldersToSkip == null)
                            {
                                m_config.AdvancedImportOptions.FoldersToSkip = new Folder[numToSkip];
                            }

                            for (int i = 0; i < numToSkip; i++)
                            {
                                Folder folder = new Folder();
                                folder.FolderName = nameTokens.GetValue(i).ToString();
                                m_config.AdvancedImportOptions.FoldersToSkip[i] = folder;
                            }
                        }
                    }
                }
                else
                {
                    m_config.AdvancedImportOptions.FoldersToSkip = null;
                }
            }
        }
Пример #4
0
        private void PublicFolders()
        {
            CSMigrationWrapper mw   = ((IntroViewModel)ViewModelPtrs[(int)ViewType.INTRO]).mw;
            MigrationAccount   Acct = new MigrationAccount();

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

            Acct.ProfileName = eparams.OutlookProfile;

            // ----------------------------------------------------
            // User must enter target zimbra account first
            // ----------------------------------------------------
            if (ZimbraAccountName == null)
            {
                MessageBox.Show("Please specify a zimbra account name", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Warning);
                EnableNext = false;
                return;
            }

            string acctName = ZimbraAccountName + '@' + this.ZimbraDomain;

            Acct.AccountName = acctName;

            // ----------------------------------------------------
            // Get PFs from C++ layer - takes extended time
            // ----------------------------------------------------
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; // Set hourglass
            try
            {
                string[] folders = mw.GetPublicFolders(Acct);
                if (folders != null)
                {
                    // FBS rewrite -- bug 71646 -- 3/26/12
                    UsersViewModel userm;
                    userm = new UsersViewModel(ZimbraAccountName, ZimbraAccountName);

                    for (int i = 0; i < folders.Length; i++)
                    {
                        string uname = "", displayname = "", givenname = "", sn = "", zfp = "";
                        uname       = folders.GetValue(i).ToString();
                        displayname = folders.GetValue(i).ToString();
                        givenname   = folders.GetValue(i).ToString();
                        sn          = folders.GetValue(i).ToString();
                        zfp         = folders.GetValue(i).ToString();

                        PublicfoldersViewModel uvm;
                        if (uname.CompareTo(displayname) == 0)
                        {
                            uvm = new PublicfoldersViewModel(displayname, uname);
                        }
                        else
                        {
                            uvm = new PublicfoldersViewModel(uname, uname);
                        }

                        uvm.ZimbraAccountName = ZimbraAccountName;

                        UsersBKList.Add(uvm);

                        UsersList.Add(userm);

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

                        PlusEnabled = false;
                        //Username = ZimbraAccountName;
                        scheduleViewModel.SchedList.Add(new SchedUser(ZimbraAccountName, false));
                        scheduleViewModel.SchedfolderList.Add(new SchedUser(ZimbraAccountName, false));
                        scheduleViewModel.EnableMigrate = (scheduleViewModel.SchedfolderList.Count > 0);
                        scheduleViewModel.EnablePreview = scheduleViewModel.EnableMigrate;
                        EnableNext = (UsersList.Count > 0);
                    }
                    UsersViewModel usersViewModel = ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);

                    usersViewModel.ZimbraDomain = this.ZimbraDomain;

                    usersViewModel.UsersList.Add(userm);
                }
            }
            finally
            {
                Mouse.OverrideCursor = null;
            };
        }
Пример #5
0
        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);
                }
            }
            ;
        }
Пример #6
0
        private void PublicFolders()
        {
            EnablePopButtons = false;

            CSMigrationWrapper mw   = ((IntroViewModel)ViewModelPtrs[(int)ViewType.INTRO]).mw;
            MigrationAccount   Acct = new MigrationAccount();

            /* string userName = (UsersList[0].MappedName.Length > 0) ? UsersList[0].MappedName :
             *      UsersList[0].Username;
             * string acctName = userName + '@' + this.ZimbraDomain;
             * Acct.AccountName = acctName;
             * Acct.ProfileName = acctName;*/
            ConfigViewModelS eparams =
                ((ConfigViewModelS)ViewModelPtrs[(int)ViewType.SVRSRC]);

            Acct.ProfileName = eparams.OutlookProfile;

            if (ZimbraAccountName == null)
            {
                MessageBox.Show("Please specify a zimbra account name", "Zimbra Migration", MessageBoxButton.OK,
                                MessageBoxImage.Warning);
                EnableNext = false;
                return;
            }


            string acctName = ZimbraAccountName + '@' + this.ZimbraDomain;

            Acct.AccountName = acctName;
            //Acct.ProfileName = acctName;



            string[] folders = mw.GetPublicFolders(Acct, LogLevel.Trace);



            if (folders != null)
            {
                // FBS rewrite -- bug 71646 -- 3/26/12
                UsersViewModel userm;
                userm = new UsersViewModel(ZimbraAccountName, ZimbraAccountName);

                for (int i = 0; i < folders.Length; i++)
                {
                    /*string[] tokens = users[i].Split('~');
                     * if (tokens.Length < 5)
                     * {
                     *  MessageBox.Show("Object picker returned insufficient data", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                     *  EnablePopButtons = true;
                     *  return;
                     * }*/
                    string uname = "", displayname = "", givenname = "", sn = "", zfp = "";

                    /* for (int j = 0; j < tokens.Length; j += 5)
                     * {
                     *   uname = tokens.GetValue(j).ToString();
                     *   displayname = tokens.GetValue(j + 1).ToString();
                     *   givenname = tokens.GetValue(j + 2).ToString();
                     *   sn = tokens.GetValue(j + 3).ToString();
                     *   zfp = tokens.GetValue(j + 4).ToString();
                     * }*/
                    uname       = folders.GetValue(i).ToString();
                    displayname = folders.GetValue(i).ToString();
                    givenname   = folders.GetValue(i).ToString();
                    sn          = folders.GetValue(i).ToString();
                    zfp         = folders.GetValue(i).ToString();

                    /*if (uname.IndexOf("@") != -1)
                     * {
                     *  uname = uname.Substring(0, uname.IndexOf("@"));
                     * }*/

                    PublicfoldersViewModel uvm;


                    if (uname.CompareTo(displayname) == 0)
                    {
                        uvm = new PublicfoldersViewModel(displayname, uname);
                    }
                    else
                    {
                        uvm = new PublicfoldersViewModel(uname, uname);
                    }



                    //uvm.AddOPInfo(new ObjectPickerInfo(displayname, givenname, sn, zfp));
                    uvm.ZimbraAccountName = ZimbraAccountName;
                    UsersBKList.Add(uvm);

                    UsersList.Add(userm);


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


                    PlusEnabled = false;
                    //Username = ZimbraAccountName;
                    scheduleViewModel.SchedList.Add(new SchedUser(ZimbraAccountName, false));
                    scheduleViewModel.SchedfolderList.Add(new SchedUser(ZimbraAccountName, false));
                    scheduleViewModel.EnableMigrate = (scheduleViewModel.SchedfolderList.Count > 0);
                    scheduleViewModel.EnablePreview = scheduleViewModel.EnableMigrate;
                    EnableNext = (UsersList.Count > 0);
                }
                UsersViewModel usersViewModel =
                    ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);

                usersViewModel.ZimbraDomain = this.ZimbraDomain;

                usersViewModel.UsersList.Add(userm);
            }
            EnablePopButtons = true;
        }
Пример #7
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);
        }
Пример #8
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);
            }
        }