Beispiel #1
0
        DateTime tLimitFrom; // = checkLast_At.AddHours(-checkRetrace_Hours);
        #endregion

        public ParseOutlookItemsHandler(AppointmentPnDbContext dbContext, eFormCore.Core sdkCore, IOutlookOnlineController outlookOnlineController, OutlookExchangeOnlineAPIClient outlookExchangeOnlineAPIClient, IBus bus)
        {
            this._dbContext = dbContext;
            this.sdkCore    = sdkCore;
            this.outlookOnlineController        = outlookOnlineController;
            this.outlookExchangeOnlineAPIClient = outlookExchangeOnlineAPIClient;
            this.bus = bus;
            //checkLast_At = DateTime.Parse(sqlController.SettingRead(Settings.checkLast_At));
//            checkPreSend_Hours = double.Parse(sqlController.SettingRead(Settings.checkPreSend_Hours));
//            checkRetrace_Hours = double.Parse(sqlController.SettingRead(Settings.checkRetrace_Hours));
//            checkEvery_Mins = int.Parse(sqlController.SettingRead(Settings.checkEvery_Mins));
//            includeBlankLocations = bool.Parse(sqlController.SettingRead(Settings.includeBlankLocations));
            double checkPreSend_Hours = double.Parse(_dbContext.PluginConfigurationValues
                                                     .SingleOrDefault(x => x.Name == "AppointmentBaseSettings:checkPreSend_Hours")?.Value);
            double checkRetrace_Hours = double.Parse(_dbContext.PluginConfigurationValues
                                                     .SingleOrDefault(x => x.Name == "AppointmentBaseSettings:checkRetrace_Hours")?.Value);
            int checkEvery_Mins = int.Parse(_dbContext.PluginConfigurationValues
                                            .SingleOrDefault(x => x.Name == "AppointmentBaseSettings:checkEvery_Mins")?.Value);
            bool includeBlankLocations = bool.Parse(_dbContext.PluginConfigurationValues
                                                    .SingleOrDefault(x => x.Name == "AppointmentBaseSettings:includeBlankLocations")?.Value);

            userEmailAddess = outlookOnlineController.GetUserEmailAddress();

            timeOfRun  = DateTime.Now;
            tLimitTo   = timeOfRun.AddHours(+checkPreSend_Hours);
            tLimitFrom = timeOfRun.AddHours(-checkRetrace_Hours);
        }
 public OutlookOnlineController(SqlController sqlController, Log log, OutlookExchangeOnlineAPIClient outlookExchangeOnlineAPIClient, IBus bus)
 {
     this.sqlController = sqlController;
     this.log           = log;
     this.outlookExchangeOnlineAPIClient = outlookExchangeOnlineAPIClient;
     this.bus = bus;
 }
        public OutlookOnlineController(AppointmentPnDbContext dbContext, OutlookExchangeOnlineAPIClient outlookExchangeOnlineAPIClient, IBus bus)
        {
            this._dbContext = dbContext;
//            this.log = log;
            this._outlookExchangeOnlineApiClient = outlookExchangeOnlineAPIClient;
            this._bus = bus;
        }
Beispiel #4
0
        DateTime tLimitFrom; // = checkLast_At.AddHours(-checkRetrace_Hours);
        #endregion

        public ParseOutlookItemsHandler(SqlController sqlController, Log log, eFormCore.Core sdkCore, IOutlookOnlineController outlookOnlineController, OutlookExchangeOnlineAPIClient outlookExchangeOnlineAPIClient, IBus bus)
        {
            this.sqlController                  = sqlController;
            this.log                            = log;
            this.sdkCore                        = sdkCore;
            this.outlookOnlineController        = outlookOnlineController;
            this.outlookExchangeOnlineAPIClient = outlookExchangeOnlineAPIClient;
            this.bus                            = bus;
            //checkLast_At = DateTime.Parse(sqlController.SettingRead(Settings.checkLast_At));
            checkPreSend_Hours    = double.Parse(sqlController.SettingRead(Settings.checkPreSend_Hours));
            checkRetrace_Hours    = double.Parse(sqlController.SettingRead(Settings.checkRetrace_Hours));
            checkEvery_Mins       = int.Parse(sqlController.SettingRead(Settings.checkEvery_Mins));
            includeBlankLocations = bool.Parse(sqlController.SettingRead(Settings.includeBlankLocations));

            userEmailAddess = outlookOnlineController.GetUserEmailAddress();

            timeOfRun  = DateTime.Now;
            tLimitTo   = timeOfRun.AddHours(+checkPreSend_Hours);
            tLimitFrom = timeOfRun.AddHours(-checkRetrace_Hours);
        }
Beispiel #5
0
        //con
        #region public state
        public bool Start(string sdkConnectionString, string serviceLocation)
        {
            try
            {
                string connectionStringPath = serviceLocation + @"\Extensions\OutlookPlugin\sql_connection_outlook.txt";
                string connectionString     = File.ReadAllText(connectionStringPath).Trim();
                if (!coreAvailable && !coreStatChanging)
                {
                    this.serviceLocation = serviceLocation;
                    coreStatChanging     = true;

                    if (string.IsNullOrEmpty(this.serviceLocation))
                    {
                        throw new ArgumentException("serviceLocation is not allowed to be null or empty");
                    }

                    if (string.IsNullOrEmpty(connectionString))
                    {
                        throw new ArgumentException("serverConnectionString is not allowed to be null or empty");
                    }

                    //sqlController
                    sqlController = new SqlController(connectionString);


                    //check settings
                    if (sqlController.SettingCheckAll().Count > 0)
                    {
                        throw new ArgumentException("Use AdminTool to setup database correctly. 'SettingCheckAll()' returned with errors");
                    }

                    if (sqlController.SettingRead(Settings.microtingDb) == "...missing...")
                    {
                        throw new ArgumentException("Use AdminTool to setup database correctly. microtingDb(connection string) not set, only default value found");
                    }

                    if (sqlController.SettingRead(Settings.firstRunDone) != "true")
                    {
                        throw new ArgumentException("Use AdminTool to setup database correctly. FirstRunDone has not completed");
                    }

                    //log
                    if (log == null)
                    {
                        log = sqlController.StartLog(this);
                    }

                    try
                    {
                        maxParallelism  = int.Parse(sqlController.SettingRead(Settings.maxParallelism));
                        numberOfWorkers = int.Parse(sqlController.SettingRead(Settings.numberOfWorkers));
                    }
                    catch { }

                    //log.LogCritical(t.GetMethodName("Core"), "###########################################################################");
                    //log.LogCritical(t.GetMethodName("Core"), "called");
                    log.LogStandard(t.GetMethodName("Core"), "SqlController and Logger started");

                    //settings read
                    this.connectionString = connectionString;
                    log.LogStandard(t.GetMethodName("Core"), "Settings read");
                    log.LogStandard(t.GetMethodName("Core"), "this.serviceLocation is " + this.serviceLocation);


                    string directoryId = sqlController.SettingRead(Settings.dirId);
                    if (string.IsNullOrEmpty(directoryId))
                    {
                        throw new ArgumentNullException("dirId in settings cannot be empty!");
                    }
                    string applicationId = sqlController.SettingRead(Settings.appId);
                    if (string.IsNullOrEmpty(directoryId))
                    {
                        throw new ArgumentNullException("appId in setting cannot be empty!");
                    }
                    outlookExchangeOnlineAPI = new OutlookExchangeOnlineAPIClient(this.serviceLocation, log, directoryId, applicationId);

                    log.LogStandard(t.GetMethodName("Core"), "OutlookController started");

                    coreAvailable    = true;
                    coreStatChanging = false;

                    //coreThread
                    string sdkCoreConnectionString = sqlController.SettingRead(Settings.microtingDb);
                    startSdkCoreSqlOnly(sdkCoreConnectionString);
                    log.LogCritical(t.GetMethodName("Core"), "started");

                    container = new WindsorContainer();
                    container.Register(Component.For <SqlController>().Instance(sqlController));
                    container.Register(Component.For <eFormCore.Core>().Instance(sdkCore));
                    container.Register(Component.For <Log>().Instance(log));
                    container.Register(Component.For <OutlookExchangeOnlineAPIClient>().Instance(outlookExchangeOnlineAPI));
                    container.Install(
                        new RebusHandlerInstaller()
                        , new RebusInstaller(connectionString, maxParallelism, numberOfWorkers)
                        );


                    this.bus = container.Resolve <IBus>();
                    outlookOnlineController = new OutlookOnlineController(sqlController, log, outlookExchangeOnlineAPI, this.bus);
                    //container.Register(Component.For<IBus>().Instance(bus));
                    container.Register(Component.For <IOutlookOnlineController>().Instance(outlookOnlineController));

                    Thread coreThread = new Thread(() => CoreThread(sdkCoreConnectionString));
                    coreThread.Start();
                    log.LogStandard(t.GetMethodName("Core"), "CoreThread started");
                }
            }
            #region catch
            catch (Exception ex)
            {
                log.LogException(t.GetMethodName("Core"), "Start failed", ex, false);
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("Start failed " + ex.Message);
                throw ex;
            }
            #endregion

            return(true);
        }