private void LogKeySettings(clsSettings settings)
 {
     foreach (var s in GetKeySettings(settings))
     {
         log.Error(s);
     }
 }
Ejemplo n.º 2
0
        private IEnumerable <string> GetLogHeader(clsSettings settings)
        {
            yield return($"{AddInTitle} v{AddInVersion}");

            foreach (var s in GetKeySettings(settings))
            {
                yield return(s);
            }
        }
Ejemplo n.º 3
0
        private IEnumerable <string> GetLogHeader(clsSettings settings)
        {
            yield return($"{AddInTitle} v{AddInVersion} in Outlook version {this.Application.Version}");

            foreach (var s in GetKeySettings(settings))
            {
                yield return(s);
            }
        }
Ejemplo n.º 4
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            CurrentVersion   = Convert.ToInt32(Globals.ThisAddIn.Application.Version.Split('.')[0]);
            this.objExplorer = Globals.ThisAddIn.Application.ActiveExplorer();
            SuiteCRMClient.clsSuiteCRMHelper.InstallationPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SuiteCRMOutlookAddIn";
            this.settings = new clsSettings();
            if (this.settings.AutoArchive)
            {
                this.objExplorer.Application.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.Application_NewMail);
                this.objExplorer.Application.ItemSend  += new Outlook.ApplicationEvents_11_ItemSendEventHandler(this.Application_ItemSend);
            }
            if (CurrentVersion < 14)
            {
                this.Application.ItemContextMenuDisplay += new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(this.Application_ItemContextMenuDisplay);
                var menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar;
                objSuiteCRMMenuBar2007 = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true);
                if (objSuiteCRMMenuBar2007 != null)
                {
                    objSuiteCRMMenuBar2007.Caption = "SuiteCRM";
                    this.btnArvive               = (Office.CommandBarButton) this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                    this.btnArvive.Style         = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    this.btnArvive.Caption       = "Archive";
                    this.btnArvive.Picture       = RibbonImageHelper.Convert(Resources.SuiteCRM1);
                    this.btnArvive.Click        += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnArchive_Click);
                    this.btnArvive.Visible       = true;
                    this.btnArvive.BeginGroup    = true;
                    this.btnArvive.TooltipText   = "Archive selected emails to SuiteCRM";
                    this.btnArvive.Enabled       = true;
                    this.btnSettings             = (Office.CommandBarButton) this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                    this.btnSettings.Style       = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    this.btnSettings.Caption     = "Settings";
                    this.btnSettings.Click      += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnSettings_Click);
                    this.btnSettings.Visible     = true;
                    this.btnSettings.BeginGroup  = true;
                    this.btnSettings.TooltipText = "SuiteCRM Settings";
                    this.btnSettings.Enabled     = true;
                    this.btnSettings.Picture     = RibbonImageHelper.Convert(Resources.Settings);

                    objSuiteCRMMenuBar2007.Visible = true;
                }
            }
            else
            {
                //For Outlook version 2010 and greater
                //var app = this.Application;
                //app.FolderContextMenuDisplay += new Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHander(this.app_FolderContextMenuDisplay);
            }
            SuiteCRMAuthenticate();
        }
        private IEnumerable <string> GetLogHeader(clsSettings settings)
        {
            List <string> result = new List <string>();

            try
            {
                result.Add($"{AddInTitle} v{AddInVersion} in Outlook version {this.Application.Version}");
                result.AddRange(GetKeySettings(settings));
            }
            catch (Exception any)
            {
                result.Add($"Exception {any.GetType().Name} '{any.Message}' while printing log header");
            }

            return(result);
        }
        /// <summary>
        /// Prepare me for running.
        /// </summary>
        private void Prepare()
        {
            var outlookApp = this.Application;

            OutlookVersion = (OutlookMajorVersion)Convert.ToInt32(outlookApp.Version.Split('.')[0]);

            this.settings = new clsSettings();
            StartLogging(settings);

            synchronisationContext  = new SyncContext(outlookApp, settings);
            contactSynchroniser     = new ContactSyncing("CS", synchronisationContext);
            taskSynchroniser        = new TaskSyncing("TS", synchronisationContext);
            appointmentSynchroniser = new AppointmentSyncing("AS", synchronisationContext);
            EmailArchiver           = new EmailArchiving("EM", synchronisationContext.Log);

            var outlookExplorer = outlookApp.ActiveExplorer();

            this.objExplorer              = outlookExplorer;
            outlookExplorer.FolderSwitch -= objExplorer_FolderSwitch;
            outlookExplorer.FolderSwitch += objExplorer_FolderSwitch;

            // TODO: install/remove these event handlers when settings.AutoArchive changes:
            outlookApp.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.Application_NewMail);
            outlookApp.ItemSend  += new Outlook.ApplicationEvents_11_ItemSendEventHandler(this.Application_ItemSend);

            ((Outlook.ApplicationEvents_11_Event)Application).Quit += new Outlook.ApplicationEvents_11_QuitEventHandler(ThisAddIn_Quit);

            if (OutlookVersion < OutlookMajorVersion.Outlook2010)
            {
                outlookApp.ItemContextMenuDisplay += new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(this.Application_ItemContextMenuDisplay);
                var menuBar = outlookExplorer.CommandBars.ActiveMenuBar;
                objSuiteCRMMenuBar2007 = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true);
                if (objSuiteCRMMenuBar2007 != null)
                {
                    ConstructOutlook2007MenuBar();
                }
            }
            else
            {
                //For Outlook version 2010 and greater
                //var app = this.Application;
                //app.FolderContextMenuDisplay += new Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHander(this.app_FolderContextMenuDisplay);
            }
        }
        private IEnumerable <string> GetKeySettings(clsSettings settings)
        {
            yield return("Auto-archiving: " + (settings.AutoArchive ? "ON" : "off"));

            yield return($"Logging level: {settings.LogLevel}");
        }
 private void StartLogging(clsSettings settings)
 {
     log = Log4NetLogger.FromFilePath("add-in", LogDirPath + "suitecrmoutlook.log", () => GetLogHeader(settings), settings.LogLevel);
     clsSuiteCRMHelper.SetLog(log);
 }
Ejemplo n.º 9
0
 private IEnumerable <string> GetKeySettings(clsSettings settings)
 {
     yield return("Auto-archiving: " + (settings.AutoArchive ? "ON" : "off"));
 }
Ejemplo n.º 10
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            try
            {
                var outlookApp = this.Application;
                OutlookVersion = (OutlookMajorVersion)Convert.ToInt32(outlookApp.Version.Split('.')[0]);

                this.settings = new clsSettings();
                StartLogging(settings);

                _syncContext        = new SyncContext(outlookApp, settings);
                _contactSyncing     = new ContactSyncing(_syncContext);
                _taskSyncing        = new TaskSyncing(_syncContext);
                _appointmentSyncing = new AppointmentSyncing(_syncContext);

                var outlookExplorer = outlookApp.ActiveExplorer();
                this.objExplorer              = outlookExplorer;
                outlookExplorer.FolderSwitch -= objExplorer_FolderSwitch;
                outlookExplorer.FolderSwitch += objExplorer_FolderSwitch;

                // TODO: install/remove these event handlers when settings.AutoArchive changes:
                outlookApp.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.Application_NewMail);
                outlookApp.ItemSend  += new Outlook.ApplicationEvents_11_ItemSendEventHandler(this.Application_ItemSend);

                if (OutlookVersion < OutlookMajorVersion.Outlook2010)
                {
                    outlookApp.ItemContextMenuDisplay += new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(this.Application_ItemContextMenuDisplay);
                    var menuBar = outlookExplorer.CommandBars.ActiveMenuBar;
                    objSuiteCRMMenuBar2007 = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true);
                    if (objSuiteCRMMenuBar2007 != null)
                    {
                        objSuiteCRMMenuBar2007.Caption = "SuiteCRM";
                        this.btnArvive               = (Office.CommandBarButton) this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                        this.btnArvive.Style         = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        this.btnArvive.Caption       = "Archive";
                        this.btnArvive.Picture       = RibbonImageHelper.Convert(Resources.SuiteCRM1);
                        this.btnArvive.Click        += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnArchive_Click);
                        this.btnArvive.Visible       = true;
                        this.btnArvive.BeginGroup    = true;
                        this.btnArvive.TooltipText   = "Archive selected emails to SuiteCRM";
                        this.btnArvive.Enabled       = true;
                        this.btnSettings             = (Office.CommandBarButton) this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                        this.btnSettings.Style       = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        this.btnSettings.Caption     = "Settings";
                        this.btnSettings.Click      += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnSettings_Click);
                        this.btnSettings.Visible     = true;
                        this.btnSettings.BeginGroup  = true;
                        this.btnSettings.TooltipText = "SuiteCRM Settings";
                        this.btnSettings.Enabled     = true;
                        this.btnSettings.Picture     = RibbonImageHelper.Convert(Resources.Settings);

                        objSuiteCRMMenuBar2007.Visible = true;
                    }
                }
                else
                {
                    //For Outlook version 2010 and greater
                    //var app = this.Application;
                    //app.FolderContextMenuDisplay += new Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHander(this.app_FolderContextMenuDisplay);
                }

                while (!this.VerifyLicenceKey())
                {
                    /* if licence key does not validate, show the settings form to allow the user to enter
                     * a (new) key, and retry. */
                    this.ShowSettingsForm();
                }

                SuiteCRMAuthenticate();
                new Thread(() => SyncAndAutoArchive()).Start();
            }
            catch (Exception ex)
            {
                log.Error("ThisAddIn.ThisAddIn_Startup", ex);
            }
        }
Ejemplo n.º 11
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            CurrentVersion = Convert.ToInt32(Globals.ThisAddIn.Application.Version.Split('.')[0]);
            this.objExplorer = Globals.ThisAddIn.Application.ActiveExplorer();
            SuiteCRMClient.clsSuiteCRMHelper.InstallationPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SuiteCRMOutlookAddIn";
            this.settings = new clsSettings();
            if (this.settings.AutoArchive)
            {
                this.objExplorer.Application.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.Application_NewMail);
                this.objExplorer.Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(this.Application_ItemSend);
            }
            if (CurrentVersion < 14)
            {
                this.Application.ItemContextMenuDisplay += new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(this.Application_ItemContextMenuDisplay);
                var menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar;
                objSuiteCRMMenuBar2007 = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true);
                if (objSuiteCRMMenuBar2007 != null)
                {
                    objSuiteCRMMenuBar2007.Caption = "SuiteCRM";
                    this.btnArvive = (Office.CommandBarButton)this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                    this.btnArvive.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    this.btnArvive.Caption = "Archive";
                    this.btnArvive.Picture = RibbonImageHelper.Convert(Resources.SuiteCRM1);
                    this.btnArvive.Click += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnArchive_Click);
                    this.btnArvive.Visible = true;
                    this.btnArvive.BeginGroup = true;
                    this.btnArvive.TooltipText = "Archive selected emails to SuiteCRM";
                    this.btnArvive.Enabled = true;
                    this.btnSettings = (Office.CommandBarButton)this.objSuiteCRMMenuBar2007.Controls.Add(Office.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                    this.btnSettings.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    this.btnSettings.Caption = "Settings";
                    this.btnSettings.Click += new Office._CommandBarButtonEvents_ClickEventHandler(this.cbtnSettings_Click);
                    this.btnSettings.Visible = true;
                    this.btnSettings.BeginGroup = true;
                    this.btnSettings.TooltipText = "SuiteCRM Settings";
                    this.btnSettings.Enabled = true;
                    this.btnSettings.Picture = RibbonImageHelper.Convert(Resources.Settings);

                    objSuiteCRMMenuBar2007.Visible = true;
                }
            }
            else
            {
                //For Outlook version 2010 and greater
                //var app = this.Application;
                //app.FolderContextMenuDisplay += new Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHander(this.app_FolderContextMenuDisplay);
            }
            SuiteCRMAuthenticate();
        }