Esempio 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));
        }
Esempio n. 2
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
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        private void PublicFolders()
        {
            CSMigrationWrapper mw   = ((IntroViewModel)ViewModelPtrs[(int)ViewType.INTRO]).mw;
            MigrationAccount   Acct = new MigrationAccount();

            ConfigViewModelS eparams = ((ConfigViewModelS)ViewModelPtrs[(int)ViewType.SVRSRC]);

            Acct.ProfileName = eparams.OutlookProfile;

            // ----------------------------------------------------
            // User must enter target zimbra account first
            // ----------------------------------------------------
            if (ZimbraAccountName == null)
            {
                MessageBox.Show("Please specify a zimbra account name", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Warning);
                EnableNext = false;
                return;
            }

            string acctName = ZimbraAccountName + '@' + this.ZimbraDomain;

            Acct.AccountName = acctName;

            // ----------------------------------------------------
            // Get PFs from C++ layer - takes extended time
            // ----------------------------------------------------
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; // Set hourglass
            try
            {
                string[] folders = mw.GetPublicFolders(Acct);
                if (folders != null)
                {
                    // FBS rewrite -- bug 71646 -- 3/26/12
                    UsersViewModel userm;
                    userm = new UsersViewModel(ZimbraAccountName, ZimbraAccountName);

                    for (int i = 0; i < folders.Length; i++)
                    {
                        string uname = "", displayname = "", givenname = "", sn = "", zfp = "";
                        uname       = folders.GetValue(i).ToString();
                        displayname = folders.GetValue(i).ToString();
                        givenname   = folders.GetValue(i).ToString();
                        sn          = folders.GetValue(i).ToString();
                        zfp         = folders.GetValue(i).ToString();

                        PublicfoldersViewModel uvm;
                        if (uname.CompareTo(displayname) == 0)
                        {
                            uvm = new PublicfoldersViewModel(displayname, uname);
                        }
                        else
                        {
                            uvm = new PublicfoldersViewModel(uname, uname);
                        }

                        uvm.ZimbraAccountName = ZimbraAccountName;

                        UsersBKList.Add(uvm);

                        UsersList.Add(userm);

                        ScheduleViewModel scheduleViewModel = ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);

                        PlusEnabled = false;
                        //Username = ZimbraAccountName;
                        scheduleViewModel.SchedList.Add(new SchedUser(ZimbraAccountName, false));
                        scheduleViewModel.SchedfolderList.Add(new SchedUser(ZimbraAccountName, false));
                        scheduleViewModel.EnableMigrate = (scheduleViewModel.SchedfolderList.Count > 0);
                        scheduleViewModel.EnablePreview = scheduleViewModel.EnableMigrate;
                        EnableNext = (UsersList.Count > 0);
                    }
                    UsersViewModel usersViewModel = ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);

                    usersViewModel.ZimbraDomain = this.ZimbraDomain;

                    usersViewModel.UsersList.Add(userm);
                }
            }
            finally
            {
                Mouse.OverrideCursor = null;
            };
        }
Esempio n. 5
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";
            }
        }
Esempio n. 6
0
        private void PublicFolders()
        {
            EnablePopButtons = false;

            CSMigrationWrapper mw   = ((IntroViewModel)ViewModelPtrs[(int)ViewType.INTRO]).mw;
            MigrationAccount   Acct = new MigrationAccount();

            /* string userName = (UsersList[0].MappedName.Length > 0) ? UsersList[0].MappedName :
             *      UsersList[0].Username;
             * string acctName = userName + '@' + this.ZimbraDomain;
             * Acct.AccountName = acctName;
             * Acct.ProfileName = acctName;*/
            ConfigViewModelS eparams =
                ((ConfigViewModelS)ViewModelPtrs[(int)ViewType.SVRSRC]);

            Acct.ProfileName = eparams.OutlookProfile;

            if (ZimbraAccountName == null)
            {
                MessageBox.Show("Please specify a zimbra account name", "Zimbra Migration", MessageBoxButton.OK,
                                MessageBoxImage.Warning);
                EnableNext = false;
                return;
            }


            string acctName = ZimbraAccountName + '@' + this.ZimbraDomain;

            Acct.AccountName = acctName;
            //Acct.ProfileName = acctName;



            string[] folders = mw.GetPublicFolders(Acct, LogLevel.Trace);



            if (folders != null)
            {
                // FBS rewrite -- bug 71646 -- 3/26/12
                UsersViewModel userm;
                userm = new UsersViewModel(ZimbraAccountName, ZimbraAccountName);

                for (int i = 0; i < folders.Length; i++)
                {
                    /*string[] tokens = users[i].Split('~');
                     * if (tokens.Length < 5)
                     * {
                     *  MessageBox.Show("Object picker returned insufficient data", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                     *  EnablePopButtons = true;
                     *  return;
                     * }*/
                    string uname = "", displayname = "", givenname = "", sn = "", zfp = "";

                    /* for (int j = 0; j < tokens.Length; j += 5)
                     * {
                     *   uname = tokens.GetValue(j).ToString();
                     *   displayname = tokens.GetValue(j + 1).ToString();
                     *   givenname = tokens.GetValue(j + 2).ToString();
                     *   sn = tokens.GetValue(j + 3).ToString();
                     *   zfp = tokens.GetValue(j + 4).ToString();
                     * }*/
                    uname       = folders.GetValue(i).ToString();
                    displayname = folders.GetValue(i).ToString();
                    givenname   = folders.GetValue(i).ToString();
                    sn          = folders.GetValue(i).ToString();
                    zfp         = folders.GetValue(i).ToString();

                    /*if (uname.IndexOf("@") != -1)
                     * {
                     *  uname = uname.Substring(0, uname.IndexOf("@"));
                     * }*/

                    PublicfoldersViewModel uvm;


                    if (uname.CompareTo(displayname) == 0)
                    {
                        uvm = new PublicfoldersViewModel(displayname, uname);
                    }
                    else
                    {
                        uvm = new PublicfoldersViewModel(uname, uname);
                    }



                    //uvm.AddOPInfo(new ObjectPickerInfo(displayname, givenname, sn, zfp));
                    uvm.ZimbraAccountName = ZimbraAccountName;
                    UsersBKList.Add(uvm);

                    UsersList.Add(userm);


                    ScheduleViewModel scheduleViewModel =
                        ((ScheduleViewModel)ViewModelPtrs[(int)ViewType.SCHED]);


                    PlusEnabled = false;
                    //Username = ZimbraAccountName;
                    scheduleViewModel.SchedList.Add(new SchedUser(ZimbraAccountName, false));
                    scheduleViewModel.SchedfolderList.Add(new SchedUser(ZimbraAccountName, false));
                    scheduleViewModel.EnableMigrate = (scheduleViewModel.SchedfolderList.Count > 0);
                    scheduleViewModel.EnablePreview = scheduleViewModel.EnableMigrate;
                    EnableNext = (UsersList.Count > 0);
                }
                UsersViewModel usersViewModel =
                    ((UsersViewModel)ViewModelPtrs[(int)ViewType.USERS]);

                usersViewModel.ZimbraDomain = this.ZimbraDomain;

                usersViewModel.UsersList.Add(userm);
            }
            EnablePopButtons = true;
        }