Ejemplo n.º 1
0
        // 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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo 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
            }
        }
Ejemplo n.º 4
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));
                }
            }
        }