private void Remove() { OptionsViewModel ovm = ((OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS]); ovm.IsSkipFolders = true; folderstoskip += UsersBKList[CurrentFolderSelection].MappedName.ToString(); folderstoskip += ","; ovm.FoldersToSkip = folderstoskip; UsersBKList.RemoveAt(CurrentFolderSelection); EnableNext = (UsersBKList.Count > 0); ScheduleViewModel scheduleViewModel = ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]); scheduleViewModel.EnableMigrate = (scheduleViewModel.SchedList.Count > 0); scheduleViewModel.EnablePreview = scheduleViewModel.EnableMigrate; }
public void Acct_OnAcctChanged(object sender, MigrationObjectEventArgs e) { string msg = ""; MigrationAccount a = (MigrationAccount)sender; AccountResultsViewModel accountResultsViewModel = ((AccountResultsViewModel)ViewModelPtrs[(int)ViewType.RESULTS]); // main one AccountResultsViewModel ar = accountResultsViewModel.AccountResultsList[a.AccountNum]; if (e.PropertyName == "TotalItems") { ar.TotalItemsToMigrate = Int32.Parse(e.NewValue.ToString()); } if (e.PropertyName == "TotalErrors") { ar.NumErrs = (int)a.TotalErrors + 1; // this happens first ar.AccountProblemsList.Add(a.LastProblemInfo); OptionsViewModel ovm = ((OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS]); if (ovm.MaxErrorCount > 0) { if (ar.NumErrs > ovm.MaxErrorCount) { for (int i = 0; i < this.BGWList.Count; i++) { this.BGWList[i].CancelAsync(); } } } } else if (e.PropertyName == "TotalWarnings") { ar.NumWarns = (int)a.TotalWarnings + 1; // this happens first ar.AccountProblemsList.Add(a.LastProblemInfo); } else { msg = "Begin {0} Migration"; ar.PBMsgValue = String.Format(msg, a.AccountName); accountResultsViewModel.PBMsgValue = String.Format(msg, a.AccountName); // for the user results window } }
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; } }
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; } } }
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); }
public bool ValidateUsersList(bool bShowWarning) { // Make sure there are no blanks or duplicates in the list; remove them if there are. // If we get down to no items, disable the Next button. OptionsViewModel ovm = ((OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS]); if (ovm.IsPublicFolders) { for (int i = UsersList.Count - 1; i >= 0; i--) { if (UsersList[i].MappedName.Length > 0) { if (isDuplicate(UsersList[i].MappedName, TYPE_MAPNAME)) { UsersList.RemoveAt(i); } } } if (UsersList.Count == 0) { if (bShowWarning) { MessageBox.Show("Please specify a source name", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Warning); } EnableNext = false; return(false); } return(true); } else { for (int i = UsersList.Count - 1; i >= 0; i--) { if (UsersList[i].Username.Length == 0) { UsersList.RemoveAt(i); } else if (isDuplicate(UsersList[i].Username, TYPE_USERNAME)) { UsersList.RemoveAt(i); } else if (UsersList[i].MappedName.Length > 0) { if (isDuplicate(UsersList[i].MappedName, TYPE_MAPNAME)) { UsersList.RemoveAt(i); } } } if (UsersList.Count == 0) { if (bShowWarning) { MessageBox.Show("Please specify a source name", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Warning); } EnableNext = false; return(false); } return(true); } }
private MigrationOptions SetOptions() { MigrationOptions importOpts = new MigrationOptions(); ItemsAndFoldersOptions itemFolderFlags = ItemsAndFoldersOptions.None; OptionsViewModel ovm = ((OptionsViewModel)ViewModelPtrs[(int)ViewType.OPTIONS]); if (ovm.ImportCalendarOptions) { itemFolderFlags = itemFolderFlags | ItemsAndFoldersOptions.Calendar; } if (ovm.ImportTaskOptions) { itemFolderFlags = itemFolderFlags | ItemsAndFoldersOptions.Tasks; } if (ovm.ImportContactOptions) { itemFolderFlags = itemFolderFlags | ItemsAndFoldersOptions.Contacts; } if (ovm.ImportMailOptions) { itemFolderFlags = itemFolderFlags | ItemsAndFoldersOptions.Mail; } if (ovm.ImportSentOptions) { itemFolderFlags = itemFolderFlags | ItemsAndFoldersOptions.Sent; } if (ovm.ImportDeletedItemOptions) { itemFolderFlags = itemFolderFlags | ItemsAndFoldersOptions.DeletedItems; } if (ovm.ImportJunkOptions) { itemFolderFlags = itemFolderFlags | ItemsAndFoldersOptions.Junk; } if (ovm.ImportRuleOptions) { itemFolderFlags = itemFolderFlags | ItemsAndFoldersOptions.Rules; } if (ovm.ImportOOOOptions) { itemFolderFlags = itemFolderFlags | ItemsAndFoldersOptions.OOO; } importOpts.ItemsAndFolders = itemFolderFlags; importOpts.DateFilter = (ovm.IsOnOrAfter) ? ovm.MigrateONRAfter : null; importOpts.MessageSizeFilter = (ovm.IsMaxMessageSize) ? ovm.MaxMessageSize : null; importOpts.SkipFolders = (ovm.IsSkipFolders) ? ovm.FoldersToSkip : null; importOpts.SkipPrevMigrated = ovm.IsSkipPrevMigratedItems; importOpts.MaxErrorCnt = ovm.MaxErrorCount; switch (ovm.LogLevel) { case "Debug": importOpts.VerboseOn = LogLevel.Debug; break; case "Info": importOpts.VerboseOn = LogLevel.Info; break; case "Trace": importOpts.VerboseOn = LogLevel.Trace; break; default: importOpts.VerboseOn = LogLevel.Info; break; } importOpts.SpecialCharRep = ovm.SpecialCharReplace; return(importOpts); }
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); } } ; }
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(); 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) == 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; } }
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); }
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); } }