コード例 #1
0
ファイル: Migration.cs プロジェクト: TaNhoSy/zimbra-mirror
        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));
        }
コード例 #2
0
ファイル: Migration.cs プロジェクト: TaNhoSy/zimbra-mirror
        // the following method is not been used can comment it for now
        /*
         * public void MigrationClient()
         * {
         *
         *  MigrationAccount MyAcct = new MigrationAccount();
         *  MyAcct.OnChanged +=
         *     new MigrationObjectEventHandler(i_OnChanged1);
         *
         *
         *
         *  MyAcct.Accountname = "test";
         *
         *  foreach (MigrationFolder mt in MyAcct.migrationFolders)
         *  {
         *      mt.OnChanged +=
         *           new MigrationObjectEventHandler(i_OnChanged12);
         *  }
         *
         *  MigrationFolder MigFolder= new MigrationFolder();
         *  MigFolder.OnChanged +=
         *           new MigrationObjectEventHandler(i_OnChanged12);
         * MigFolder.FolderName = "Contacts";
         * MigFolder.TotalCountOFItems = 252;
         * MigFolder.CurrentCountOFItems = 0;
         *
         * MyAcct.migrationFolders.Insert(0, MigFolder);
         *
         *  MigrationFolder MigFolder1= new MigrationFolder();
         *  MigFolder1.OnChanged +=
         *           new MigrationObjectEventHandler(i_OnChanged12);
         * MigFolder1.FolderName = "Mail";
         * MigFolder1.TotalCountOFItems = 2000;
         * MigFolder1.CurrentCountOFItems = 0;
         *
         *  MyAcct.migrationFolders.Insert(1, MigFolder1);
         *
         *
         *
         * foreach(MigrationFolder mt in MyAcct.migrationFolders)
         * {
         *     mt.OnChanged +=
         *          new MigrationObjectEventHandler(i_OnChanged12);
         * }
         *
         * // MyAcct.migrationFolders = new MigrationFolder();
         * /*  MyAcct.migrationFolders.FolderName = "Contacts";
         *   MyAcct.migrationFolders.TotalCountOFItems = 252;
         *   MyAcct.migrationFolders.CurrentCountOFItems = 0;*/
        // ..this works
        // MyAcct.migrationFolders[0] = MigFolder;
        /*  MyAcct.OnChanged +=
         *    new MigrationObjectEventHandler(i_OnChanged1);*/
        // MyAcct.dateRaised = System.DateTime.Now;
        // }
        // the above method is not been used for now
        public void i_OnChanged1(object sender, MigrationObjectEventArgs e)
        {
            MigrationAccount i = (MigrationAccount)sender;
            string Message =
            " Migration started for user : {0} with TotalContacts  {1} ,TotalMails {2}, TotalRules {3}";

            Console.WriteLine(String.Format(Message, i.AccountName, i.TotalContacts,
            i.TotalMails, i.TotalRules));
        }
コード例 #3
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));
            }
            }
        }
コード例 #4
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
            }
        }
コード例 #5
0
        public void Folder_OnChanged(object sender, CssLib.MigrationObjectEventArgs e)     // See similar code in ScheduleViewModel......can we dedupe?
        {
            //while (!_shouldStop)
            {
                CssLib.MigrationFolder f = (CssLib.MigrationFolder)sender;
                string sAcccountID       = "[" + f.AccountID.ToString() + "]";

                if (e.PropertyName == "NumFolderItemsMigrated")
                {
                    if (f.FolderName != null)
                    {
                        if (e.NewValue.ToString() != "0")
                        {
                            if (f.NumFolderItemsMigrated > 0)
                            {
                                string msg1 = sAcccountID.PadRight(25, ' ') + f.FolderName.PadRight(25, ' ') + "{0,5:#} of {1,5:#} migrated successfully";
                                string msgF = String.Format(msg1, f.NumFolderItemsMigrated, f.NumFolderItemsToMigrate);
                                System.Console.WriteLine(msgF);
                            }
                        }
                    }
                }

                if (e.PropertyName == "NumFolderItemsToMigrate")      // finish up with the last folder DCB I don't think it goes down this code path
                {
                    if (f.FolderName != null)
                    {
                        if (f.NumFolderItemsMigrated > 0)
                        {
                            string msg2 = sAcccountID.PadRight(25, ' ') + f.FolderName.PadRight(25, ' ') + "{0,5:#} of {1,5:#} migrated successfully";
                            string msgF = String.Format(msg2, f.NumFolderItemsMigrated, f.NumFolderItemsToMigrate);

                            System.Console.WriteLine(msgF);
                        }
                    }
                }

                if (e.PropertyName == "FolderName")
                {
                    if (e.NewValue != null)
                    {
                        string folderName = e.NewValue.ToString();

                        string msg3 = sAcccountID.PadRight(25, ' ') + "Starting migration of folder '{0}'";
                        string msgF = String.Format(msg3, folderName);
                        System.Console.WriteLine("");
                        System.Console.WriteLine(msgF);
                        System.Console.WriteLine("");
                    }

                    if (_shouldStop)
                    {
                        System.Console.WriteLine();
                        System.Console.WriteLine();
                        string Messg = "Migration For UserAccount   Cancelled";
                        // ProgressUtil.RenderConsoleProgress(30, '\u2591', ConsoleColor.Red, "Migration For UserAccount    Cancelled");
                        System.Console.WriteLine(Messg);
                        System.Console.WriteLine();
                        System.Console.WriteLine();
                        Countdown.Signal();
                        CancelAsync();
                        Thread.CurrentThread.Abort();
                    }
                }
            }
        }
コード例 #6
0
        public void Acct_OnChanged(object sender, CssLib.MigrationObjectEventArgs e)     // See similar code in ScheduleViewModel......can we dedupe?
        {
            // while (!_shouldStop)
            {
                //string msg = "";
                CssLib.MigrationAccount a = (CssLib.MigrationAccount)sender;

                if (e.PropertyName == "NumAccountItemsToMigrate")
                {
                    /*System.Console.WriteLine();
                    *  ProgressUtil.RenderConsoleProgress(30, '\u2591', ConsoleColor.Yellow, "TotalItems to Migrate For UserAccount   " + a.AccountID.ToString() + " is " + e.NewValue.ToString());
                    *  System.Console.WriteLine();*/
                    // a.TotalItems = Convert.ToInt32(e.NewValue);

                    Currentuser.StatusMessage = "Total Items to Migrate For UserAccount   " + a.AccountID + " is " + e.NewValue.ToString();

                    /*System.Console.WriteLine();
                    *  System.Console.WriteLine();*/
                }
                else
                if (e.PropertyName == "NumAccountErrs")
                {
                    this.NumofErrors = (int)a.NumAccountErrs + 1;      // this happens first
                    System.Console.WriteLine();
                    if (a.MaxErrorCount > 0)
                    {
                        if (this.NumofErrors >= a.MaxErrorCount)
                        {
                            System.Console.WriteLine();
                            if (a.LastProblemInfo != null)
                            {
                                System.Console.WriteLine();
                                string mesg = a.LastProblemInfo.Msg;
                                System.Console.WriteLine(mesg);
                                System.Console.WriteLine();
                            }
                            System.Console.WriteLine();
                            Currentuser.StatusMessage = "Total Errors For UserAccount " + a.AccountID.ToString() + " are " + this.NumofErrors.ToString();
                            System.Console.WriteLine(Currentuser.StatusMessage);
                            string Messg = "Migration For UserAccount Cancelled because MaxErrorCount has been reached";
                            // ProgressUtil.RenderConsoleProgress(30, '\u2591', ConsoleColor.Red, "Migration For UserAccount    Cancelled");
                            System.Console.WriteLine(Messg);
                            System.Console.WriteLine();
                            System.Console.WriteLine();
                            //this.countdown.Signal();

                            //this.RequestCancel();

                            // this.RequestStop();
                            //Countdown.Signal();
                            CancelAsync();
                            //Thread.CurrentThread.Abort();
                        }
                    }

                    if (a.LastProblemInfo != null)
                    {
                        System.Console.WriteLine();
                        string mesg = a.LastProblemInfo.Msg;
                        System.Console.WriteLine(mesg);
                        System.Console.WriteLine();
                    }

                    /* ProgressUtil.RenderConsoleProgress(30, '\u2591', ConsoleColor.Yellow, "TotalErrors For UserAccount   " + a.AccountID.ToString() + Numoferrors.ToString());*/
                    //donot use progressutil we want to have consistent logging.

                    /*Currentuser.StatusMessage = "Total Errors For UserAccount " + a.AccountID.ToString() + "are" + NumofErrors.ToString();
                     * System.Console.WriteLine(Currentuser.StatusMessage);
                     * System.Console.WriteLine();
                     * System.Console.WriteLine();*/
                }
                else
                if (e.PropertyName == "NumAccountWarns")
                {
                    NumofWarns = (int)a.NumAccountWarns + 1;
                    System.Console.WriteLine();

                    /* ProgressUtil.RenderConsoleProgress(30, '\u2591', ConsoleColor.Yellow, "TotalWarnings For UserAccount   " + a.AccountID.ToString() + NumofWarns.ToString());*/
                    //donot use progressutil we want to have consistent logging.

                    Currentuser.StatusMessage = "Total Warnings For UserAccount   " + a.AccountID.ToString() + NumofWarns.ToString();
                    System.Console.WriteLine(Currentuser.StatusMessage);
                    System.Console.WriteLine();
                }
                else
                {
                    /* System.Console.WriteLine();
                     * ProgressUtil.RenderConsoleProgress(30, '\u2591', ConsoleColor.Yellow, "TotalItems to Migrate For UserAccount   " + a.AccountName.ToString() + " is " + e.NewValue.ToString());
                     * System.Console.WriteLine();/*
                     * msg = "Begin {0} Migration";
                     * string msgF = String.Format(msg, a.AccountName);
                     * System.Console.WriteLine(msgF);*/
                }
            }
        }