Exemplo n.º 1
0
        /// <summary>
        ///      Implements the OnConnection method of the IDTExtensibility2 interface.
        ///      Receives notification that the Add-in is being loaded.
        /// </summary>
        /// <param term='application'>
        ///      Root object of the host application.
        /// </param>
        /// <param term='connectMode'>
        ///      Describes how the Add-in is being loaded.
        /// </param>
        /// <param term='addInInst'>
        ///      Object representing this Add-in.
        /// </param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
        {
            try
            {
                appOutlook    = (Microsoft.Office.Interop.Outlook.Application)application;
                addInInstance = addInInst;

                syncMgr = new SyncManager(ref appOutlook);

                syncMgr.GetSettings();

                // get a connection and update the project list information from the server
                if (syncMgr.GetConnection())
                {
                    syncMgr.GetProjects(false);
                }

                syncMgr.AddAllFolderEventHandlers();

                // If we are not loaded upon startup, forward to OnStartupComplete()
                // and pass the incoming System.Array.
                if (connectMode != ext_ConnectMode.ext_cm_Startup)
                {
                    OnStartupComplete(ref custom);
                }

                // TODO: Call this dynamically based off the system settings.
                syncMgr.StartTimer();
            }
            catch (System.Exception ex)
            {
                ErrorHandler.PublishError(ex, logger);
            }
        }
Exemplo n.º 2
0
 private void btnSync_Click(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     try
     {
         if (syncMgr.GetConnection())
         {
             syncMgr.SyncTasks(false);
         }
         else
         {
             MessageBox.Show(
                 "Unable to connect to the RoundTable Server. \n" +
                 "Please review your connection settings or contact \n" +
                 "your administrator.\n",
                 "RoundTable Connection Error",
                 MessageBoxButtons.OK,
                 MessageBoxIcon.Error);
         }
     }
     catch (System.Exception ex)
     {
         ErrorHandler.PublishError(ex, logger);
     }
 }
Exemplo n.º 3
0
        public void EditSettings()
        {
            ProgressBar frmConnectionProgress = null;

            try
            {
                bool bNoConnection = false;

                // TODO: Figure out why the progress bar doesn't start moving right away
                // show the progress bar
                Thread thread;
                frmConnectionProgress = ProgressBar.ShowProgressBar(ProgressBarType.Connecting, out thread);

                // attempt to get a connection to the server using current credentials
                if (!syncMgr.GetConnection())
                {                   // if no connection, show the connection info page of the settings
                    bNoConnection = true;
                    ShowConnectionPage();

                    // if we have never had a successful login, disable the project tab
                    if (!syncMgr.Settings.IsSuccessfulConnection)
                    {
                        tabSettings.Tabs.get_Item(1).Enabled = false;
                    }
                }

                // populate the fields
                LoadProjectInfo();
                LoadConnectionInfo();

                // close the progress bar
                frmConnectionProgress.Close();
                if (thread != null && thread.ThreadState != ThreadState.Stopped)
                {
                    thread.Abort();
                }

                if (bNoConnection)
                {
                    if (syncMgr.Settings.IsSuccessfulConnection)
                    {
                        MessageBox.Show(this, Utils.MESSAGE_CONNECT_FAILURE_REVIEW, Utils.MESSAGE_CONNECT_FAILURE_TITLE,
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        MessageBox.Show(this, Utils.MESSAGE_NO_SUCCESSFUL_CONNECTION, Utils.MESSAGE_NO_SUCCESSFUL_CONNECTION_TITLE,
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }

                // show the dialog regardless of whether or not we got a connection
                this.ShowDialog();
            }
            catch (System.Exception ex)
            {
                ErrorHandler.PublishError(ex, syncMgr.Logger);
            }
            finally
            {
                // just in case the progress bar is still open (due to an exception), close it
                if (frmConnectionProgress != null)
                {
                    frmConnectionProgress.Close();
                }
            }
        }