Example #1
0
        private void ObjectPicker()
        {
            using (LogBlock logblock = Log.NotTracing() ? null : new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                EnablePopButtons = false;

                CSMigrationWrapper mw    = ((IntroViewModel)ViewModelPtrs[(int)ViewType.INTRO]).mw;
                string[]           users = mw.GetListFromObjectPicker();
                if (users != null)
                {
                    // FBS rewrite -- bug 71646 -- 3/26/12
                    for (int i = 0; i < users.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();
                        }

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

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

                        uvm.AddOPInfo(new ObjectPickerInfo(displayname, givenname, sn, zfp));
                        UsersList.Add(uvm);

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

                        scheduleViewModel.SchedList.Add(new SchedUser(Username, false));
                        scheduleViewModel.EnableMigrate = (scheduleViewModel.SchedList.Count > 0);
                        scheduleViewModel.EnablePreview = scheduleViewModel.EnableMigrate;
                        EnableNext = (UsersList.Count > 0);
                    }
                }
                EnablePopButtons = true;
            }
        }
Example #2
0
        private void Next()
        {
            string             ret = "";
            CSMigrationWrapper mw  = ((IntroViewModel)ViewModelPtrs[(int)ViewType.INTRO]).mw;

            if (IsProfile)
            {
                if (CurrentProfileSelection == -1)
                {
                    MessageBox.Show("Please select a valid profile", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                if (iMailSvrInitialized == EXCHSVR_MODE)
                {
                    MessageBox.Show("You are already logged in via Exchange Server credentials",
                                    "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                if (iMailSvrInitialized == -1)
                {
                    ret = mw.GlobalInit(ProfileList[CurrentProfileSelection], "", "");
                }
            }
            else
            {
                if (iMailSvrInitialized == PROFILE_MODE)
                {
                    MessageBox.Show("You are already logged in via an Outlook Profile",
                                    "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                if (iMailSvrInitialized == -1)
                {
                    if ((MailServerHostName.Length == 0) || (MailServerAdminID.Length == 0) ||
                        (MailServerAdminPwd.Length == 0))
                    {
                        MessageBox.Show("Please enter all source mail server credentials",
                                        "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    ret = mw.GlobalInit(MailServerHostName, MailServerAdminID, MailServerAdminPwd);
                }
            }
            if (ret.Length > 0)
            {
                MessageBox.Show(ret, "Zimbra Migration", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                ret = mw.GlobalUninit();
                return;
            }
            iMailSvrInitialized = (IsProfile) ? PROFILE_MODE : EXCHSVR_MODE;

            lb.SelectedIndex = 2;
        }
Example #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);
        }
Example #4
0
        private void Application_Exit(object sender, ExitEventArgs e)
        {
            CSMigrationWrapper mw = (CSMigrationWrapper)Properties["mw"];

            if (mw != null)
            {
                if (mw.UmUser != null) // FBS bug 71047 -- 3/20/12
                {
                    mw.UmUser.Uninit();
                }
                string s = mw.GlobalUninit();

                if (s.Length > 0)
                {
                    bool retval = mw.AvoidInternalErrors(s);
                    if (!retval)
                    {
                        MessageBox.Show(s, "Shutdown error", MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                    }
                }
            }
        }
Example #5
0
        private void Application_Exit(object sender, ExitEventArgs e)
        {
            using (LogBlock logblock = Log.NotTracing()?null: new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                CSMigrationWrapper mw = (CSMigrationWrapper)Properties["mw"];
                if (mw != null)
                {
                    if (mw.csSourceAccount != null) // FBS bug 71047 -- 3/20/12
                    {
                        mw.csSourceAccount.UninitSourceAccount();
                    }

                    string s = mw.UninitCSMigrationWrapper();
                    if (s.Length > 0)
                    {
                        bool retval = mw.AvoidInternalErrors(s);
                        if (!retval)
                        {
                            MessageBox.Show(s, "Shutdown error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                }
            }
        }
Example #6
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;
            };
        }
        // 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";
            }
        }
Example #8
0
        private void Next()
        {
            using (LogBlock logblock = Log.NotTracing() ? null : new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                string             ret = "";
                CSMigrationWrapper mw  = ((IntroViewModel)ViewModelPtrs[(int)ViewType.INTRO]).mw;

                if (IsProfile)
                {
                    // -------------------------------------------------------------------------------------
                    // User opted for Profile
                    // -------------------------------------------------------------------------------------
                    if (CurrentProfileSelection == -1)
                    {
                        MessageBox.Show("Please select a valid profile", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    OutlookProfile = ProfileList[CurrentProfileSelection];
                    if (iMailSvrInitialized == EXCHSVR_MODE)
                    {
                        MessageBox.Show("You are already logged in via Exchange Server credentials", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    //  if ((!IscfgPublicFolder)&&(iMailSvrInitialized == -1))
                    //    ret = mw.InitCSMigrationWrapper(ProfileList[CurrentProfileSelection], "", "");
                }
                else
                {
                    // -------------------------------------------------------------------------------------
                    // User opted to enter exch credentials directly
                    // -------------------------------------------------------------------------------------
                    if (iMailSvrInitialized == PROFILE_MODE)
                    {
                        MessageBox.Show("You are already logged in via an Outlook Profile", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    // Need to init CSMigrationWrapper
                    if (iMailSvrInitialized == -1)
                    {
                        if ((MailServerHostName.Length == 0) ||
                            (MailServerAdminID.Length == 0) ||
                            (MailServerAdminPwd.Length == 0))
                        {
                            MessageBox.Show("Please enter all source mail server credentials", "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }
                        ret = mw.InitCSMigrationWrapper(MailServerHostName, MailServerAdminID, MailServerAdminPwd);
                    }
                }
                if (ret.Length > 0)
                {
                    MessageBox.Show(ret, "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    ret = mw.UninitCSMigrationWrapper();
                    return;
                }
                iMailSvrInitialized = (IsProfile) ? PROFILE_MODE : EXCHSVR_MODE;

                lb.SelectedIndex = 2;
            }
        }
Example #9
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;
        }
Example #10
0
        public void Next()
        {
            if (mw == null)
            {
                try
                {
                    mw = new CssLib.CSMigrationWrapper("MAPI");
                }
                catch (Exception e)
                {
                    string error = "Migration cannot be initialized.  ";
                    error += e.Message;
                    MessageBox.Show(error, "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                Application.Current.Properties["mw"] = mw;
            }

            // Get data to initialize the profile combo boxes
            string[] profiles = mw.GetListofMapiProfiles();

            // FBS bug 74917 -- 6/1/12
            if (profiles == null)
            {
                profiles    = new string[1];
                profiles[0] = "No profiles";
            }
            ////

            if (profiles[0].IndexOf("No profiles") != -1)
            {
                string msg = "No Exchange profiles exist.  ";
                if (isServer)
                {
                    msg += "Please enter the Exchange Server information manually.";
                    m_configViewModelS.Isprofile    = false;
                    m_configViewModelS.IsmailServer = true;
                }
                else
                {
                    msg += "Please enter a PST file.";
                    m_configViewModelU.Isprofile = false;
                    m_configViewModelU.IspST     = true;
                }
                MessageBox.Show(msg, "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Information);
                m_configViewModelS.CSEnableNext = true;
            }
            else
            {
                // FBS bug 75936 -- 7/9/12
                if (isServer)
                {
                    m_configViewModelS.ProfileList.Clear();
                }
                else
                {
                    m_configViewModelU.ProfileList.Clear();
                }
                ///////
                foreach (string s in profiles)
                {
                    if (s.IndexOf("GetListofMapiProfiles Exception") != -1)
                    {
                        MessageBox.Show(s, "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    if (isServer)
                    {
                        m_configViewModelS.ProfileList.Add(s);
                    }
                    else
                    {
                        m_configViewModelU.ProfileList.Add(s);
                    }
                }
                if (isServer)
                {
                    m_configViewModelS.CSEnableNext = (m_configViewModelS.ProfileList.Count > 0);
                }
                else
                {
                    m_configViewModelU.CSEnableNext = (m_configViewModelU.ProfileList.Count > 0);
                }
            }
            lb.SelectedIndex = 1;
        }
Example #11
0
        public void Next()
        // "Next" has been clicked on the Intro page:
        // - Create MigrationWrapper (used later to do migration)
        // - Populate profiles combo (its on next page)
        {
            using (LogBlock logblock = Log.NotTracing()?null: new LogBlock(GetType() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name))
            {
                // ================================================================
                // Create IntroViewModel's migration wrapper if not already done
                // ================================================================
                if (mw == null)
                {
                    try
                    {
                        mw = new CssLib.CSMigrationWrapper("MAPI");
                    }
                    catch (Exception e)
                    {
                        string error = "Migration cannot be initialized.  ";
                        error += e.Message;
                        MessageBox.Show(error, "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    // Store mw in the app as well as in IntroViewModel. Why?
                    Application.Current.Properties["mw"] = mw;
                }

                if (!isDesktop)
                {
                    // ================================================================
                    // Initialize the profile combo boxes
                    // ================================================================

                    // ------------------------
                    // Grab from C++ layer
                    // ------------------------
                    string[] profiles = mw.GetListofMapiProfiles();
                    if (profiles == null) // FBS bug 74917 -- 6/1/12
                    {
                        profiles    = new string[1];
                        profiles[0] = "No profiles";
                    }

                    if (profiles[0].IndexOf("No profiles") != -1)
                    {
                        // -----------------------------------
                        // No profiles -> show messagebox
                        // -----------------------------------
                        string msg = "No Exchange profiles exist.  ";
                        if (isServer)
                        {
                            msg += "Please enter the Exchange Server information manually.";
                            m_configViewModelS.Isprofile    = false;
                            m_configViewModelS.IsmailServer = true;
                        }
                        else
                        {
                            msg += "Please enter a PST file.";
                            m_configViewModelU.Isprofile = false;
                            m_configViewModelU.IspST     = true;
                        }
                        MessageBox.Show(msg, "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Information);
                        m_configViewModelS.CSEnableNext = true;
                    }
                    else
                    {
                        // --------------------------------------------
                        // Got some profiles -> populate droplist
                        // --------------------------------------------

                        // Clear existing
                        if (isServer)
                        {
                            m_configViewModelS.ProfileList.Clear();
                        }
                        else
                        {
                            m_configViewModelU.ProfileList.Clear();
                        }

                        // Fill with values from C++ layer
                        foreach (string s in profiles)
                        {
                            if (s.IndexOf("GetListofMapiProfiles Exception") != -1)
                            {
                                MessageBox.Show(s, "Zimbra Migration", MessageBoxButton.OK, MessageBoxImage.Error);
                                return;
                            }

                            if (isServer)
                            {
                                m_configViewModelS.ProfileList.Add(s);
                            }
                            else
                            {
                                m_configViewModelU.ProfileList.Add(s);
                            }
                        }

                        // ------------------------------------------------------------
                        // If user did Load config, select the one from the config file
                        // ------------------------------------------------------------
                        if (isServer)
                        {
                            m_configViewModelS.CurrentProfileSelection = (m_configViewModelS.OutlookProfile == null) ? 0 : m_configViewModelS.ProfileList.IndexOf(m_configViewModelS.OutlookProfile);
                            m_configViewModelS.CSEnableNext            = (m_configViewModelS.ProfileList.Count > 0);
                        }
                        else
                        {
                            m_configViewModelU.CurrentProfileSelection = (m_configViewModelU.OutlookProfile == null) ? 0 : m_configViewModelU.ProfileList.IndexOf(m_configViewModelU.OutlookProfile);
                            m_configViewModelU.CSEnableNext            = (m_configViewModelU.ProfileList.Count > 0);
                        }
                    }
                    lb.SelectedIndex = 1;
                }
                else
                {
                    // Its ZD
                    m_configViewModelZU.CSEnableNext = true;
                    m_configViewModelZU.Isprofile    = false;
                    m_configViewModelZU.IspST        = true;

                    lb.SelectedIndex = 1;
                }
            } //LogBlock
        }