Exemplo n.º 1
0
        private void worker_RunWorkerCompleted(object sender,
                                               System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            AccountResultsViewModel accountResultsViewModel =
                ((AccountResultsViewModel)ViewModelPtrs[(int)ViewType.RESULTS]);

            if (e.Cancelled)
            {
                Log.info(" in worker_RunWorkerCompleted -- thread cancelled  ");
                for (int i = 0; i < accountResultsViewModel.AccountResultsList.Count; i++) // hate to set them all, but do it for now
                {
                    accountResultsViewModel.AccountResultsList[i].PBMsgValue = "Migration canceled";
                }
                accountResultsViewModel.PBMsgValue = "Migration canceled";
            }
            else if (e.Error != null)
            {
                Log.info(" in worker_RunWorkerCompleted -- thread errored  ");
                accountResultsViewModel.PBMsgValue = "Migration exception: " + e.Error.ToString();
                Log.info(" in worker_RunWorkerCompleted -- thread errored with message  ", e.Error.ToString());
            }
            else
            {
                if (!m_isPreview)
                {
                    accountResultsViewModel.PBMsgValue = "Migration complete";
                    Log.info(" in worker_RunWorkerCompleted -- Migration completed ");
                    Log.info(" in worker_RunWorkerCompleted -- Migration completed lets cehck overflow count and it is", overflowList.Count);
                    if (overflowList.Count == 0)
                    {
                        Log.info(" in worker_RunWorkerCompleted -- Migration completed overflowcount is zero");
                        SchedList.Clear();
                        UsersViewModel usersViewModel = ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);
                        usersViewModel.UsersList.Clear();
                    }
                }
                accountResultsViewModel.EnableStop = false;
            }
            if (!m_isPreview)
            {
                Log.info(" in worker_RunWorkerCompleted -- Migration completed ");
                m_isComplete = true;
            }
            EnablePreview = EnableMigrate = !m_isComplete;
            if (overflowList.Count > 0)
            {
                Log.info(" in worker_RunWorkerCompleted -- Migration completed overflowcount is > 0", overflowList.Count);
                int usernum = overflowList[0];
                Log.info(" in worker_RunWorkerCompleted --Check availablethread for usernum ", usernum);
                int threadnum = AvailableThread();
                if (threadnum != -1)
                {
                    Log.info(" in worker_RunWorkerCompleted --Got availablethread for usernum" + usernum + " and threadnum" + threadnum);
                    bgwlist[threadnum].usernum = usernum;
                    bgwlist[threadnum].RunWorkerAsync(usernum);
                }
                Log.info(" in worker_RunWorkerCompleted --remove the user who got a thread");
                overflowList.RemoveAt(0);
            }
        }
Exemplo n.º 2
0
        private void FormatGlobalMsg(AccountResultsViewModel ar)
        {
            string msg  = "{0} of {1} ({2}%)";
            string msgG = String.Format(msg, ar.TotalItemsToMigrate, ar.TotalItemsToMigrate, 100);

            ar.GlobalAcctProgressMsg = msgG;
        }
Exemplo n.º 3
0
        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
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 private void FormatGlobalMsg(AccountResultsViewModel ar)
 {
     string msg = "{0} of {1} ({2}%)";
     string msgG = String.Format(msg, ar.TotalItemsToMigrate, ar.TotalItemsToMigrate, 100);
     ar.GlobalAcctProgressMsg = msgG;
 }
Exemplo n.º 6
0
        // Background thread stuff
        private void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            eventArglist.Add(e);

            int num = (int)e.Argument;

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

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

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

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

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

            MigrationFolder MyFolder = new MigrationFolder();

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

            MyAcct.migrationFolder = MyFolder;

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


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

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

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



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

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

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

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

            if (importOpts.IsMaintainenceMode)
            {
                accountResultsViewModel.AccountResultsList[num].PBMsgValue      = "Migration Incomplete";
                accountResultsViewModel.AccountResultsList[num].AcctProgressMsg = "InComplete";
            }
        }
Exemplo n.º 7
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);
                }
            }
            ;
        }
Exemplo n.º 8
0
        public void Folder_OnChanged(object sender, MigrationObjectEventArgs e)
        {
            MigrationFolder         f = (MigrationFolder)sender;
            AccountResultsViewModel accountResultsViewModel =
                ((AccountResultsViewModel)ViewModelPtrs[(int)ViewType.RESULTS]); // main one
            AccountResultsViewModel ar = accountResultsViewModel.AccountResultsList[f.AccountNum];

            Log.info("Schdeuleviewmodel -- Folder_OnChanged");
            int tnum = GetThreadNum(f.AccountNum);

            if (bgwlist[tnum].CancellationPending)
            {
                eventArglist[f.AccountNum].Cancel = true;
                return;
            }
            if (e.PropertyName == "CurrentCountOfItems")
            {
                if (f.FolderName != null)
                {
                    if (e.NewValue.ToString() != "0")
                    {
                        string msg1 = "{0} of {1}";
                        string msgF = String.Format(msg1, f.CurrentCountOfItems, f.TotalCountOfItems);
                        ar.AcctProgressMsg = msgF;

                        int count = ar.UserResultsList.Count;
                        ar.UserResultsList[count - 1].UserProgressMsg = msgF;
                        accountResultsViewModel.PBValue        = accountResultsViewModel.AccountResultsList[f.AccountNum].PBValue;
                        accountResultsViewModel.UserPBMsgValue = accountResultsViewModel.AccountResultsList[f.AccountNum].PBMsgValue;
                        ar.CurrentItemNum++;
                        ar.PBValue = (int)Math.Round(((Decimal)ar.CurrentItemNum /
                                                      (Decimal)ar.TotalItemsToMigrate) * 100);

                        // FBS bug 74960 -- 6/1/12
                        string msg2 = "{0} of {1} ({2}%)";
                        string msgG = String.Format(msg2, ar.CurrentItemNum, ar.TotalItemsToMigrate, ar.PBValue);
                        ar.GlobalAcctProgressMsg = msgG;

                        bgwlist[tnum].ReportProgress(ar.PBValue, f.AccountNum);
                    }
                }
            }
            if (e.PropertyName == "TotalCountOfItems")  // finish up with the last folder
            {
                if (f.FolderName != null)
                {
                    string msg2 = "";
                    string msgF = "";
                    if (!m_isPreview)
                    {
                        msg2 = "{0} of {1}";
                        msgF = String.Format(msg2, f.CurrentCountOfItems, f.TotalCountOfItems);
                        ar.AcctProgressMsg = msgF;
                    }
                    else
                    {
                        msg2 = "Total: {0}";
                        msgF = String.Format(msg2, f.TotalCountOfItems);
                    }
                    int count = ar.UserResultsList.Count;
                    ar.UserResultsList[count - 1].UserProgressMsg = msgF;
                    accountResultsViewModel.PBValue        = accountResultsViewModel.AccountResultsList[f.AccountNum].PBValue;
                    accountResultsViewModel.UserPBMsgValue = accountResultsViewModel.AccountResultsList[f.AccountNum].PBMsgValue;
                }
            }
            if (e.PropertyName == "FolderName")
            {
                if (e.NewValue != null)
                {
                    string folderName = e.NewValue.ToString();
                    string folderType = GetFolderTypeForUserResults(f.FolderView);
                    string msg3       = "";
                    if (!m_isPreview)
                    {
                        msg3          = "Migrating {0}";
                        ar.PBMsgValue = String.Format(msg3, folderName);
                        accountResultsViewModel.PBMsgValue = String.Format(msg3, folderName); // for the user results window
                    }
                    else
                    {
                        msg3          = "{0} ({1} items)";
                        ar.PBMsgValue = String.Format(msg3, folderName, f.TotalCountOfItems);
                        accountResultsViewModel.PBMsgValue = String.Format(msg3, folderName, f.TotalCountOfItems); // for the user results window
                        System.Threading.Thread.Sleep(500);                                                        // to see the message
                    }

                    f.LastFolderInfo = new FolderInfo(e.NewValue.ToString(), folderType,
                                                      string.Format("{0} of {1}", f.CurrentCountOfItems,
                                                                    f.TotalCountOfItems));

                    ar.UserResultsList.Add(new UserResultsViewModel(folderName, folderType, ar.AcctProgressMsg));
                }
            }
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
            }
        }