public void i_OnChanged12(object sender, MigrationObjectEventArgs e) { MigrationFolder i = (MigrationFolder)sender; string Message = "Migrating {0} folder \n " + "Migrating........................... {1} of {2} {0}"; Console.WriteLine(String.Format(Message, i.FolderName, i.CurrentCountOfItems, i.TotalCountOfItems)); }
private string FormatTheLastMsg(MigrationFolder lastFolder, bool isOOOorRules) // FBS 4/13/12 -- rewrite to fix bug 71048 { string retval = (isOOOorRules) ? "1 of 1" : ""; // if it's Out of Office or Rules, just say 1 of 1 if (!isOOOorRules) { string msg = "{0} of {1}"; retval = String.Format(msg, lastFolder.CurrentCountOfItems, lastFolder.TotalCountOfItems); } return(retval); }
public void test(string accountname, object Test, string accountid, MigrationOptions opts, bool ServerMigration) { MigrationAccount MyAcct = new MigrationAccount(); MyAcct.AccountName = accountname; MyAcct.AccountID = accountid; MyAcct.OnChanged += new MigrationObjectEventHandler(i_OnChanged1); MigrationFolder MyFolder = new MigrationFolder(); MyFolder.OnChanged += new MigrationObjectEventHandler(i_OnChanged12); MyAcct.migrationFolder = MyFolder; /* CSMigrationwrapper test = new CSMigrationwrapper(); * test.StartMigration(MyAcct);*/ CSMigrationWrapper test = (CSMigrationWrapper)Test; // test.StartMigration(MyAcct,opts); test.StartMigration(MyAcct, opts, ServerMigration); }
// 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"; } }
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)); } } }