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(AppointmentPnDbContext dbContext, OutlookExchangeOnlineAPIClient outlookExchangeOnlineAPIClient, IBus bus)
        {
            this._dbContext = dbContext;
//            this.log = log;
            this._outlookExchangeOnlineApiClient = outlookExchangeOnlineAPIClient;
            this._bus = bus;
        }
Beispiel #3
0
        public async Task Update(AppointmentPnDbContext dbContext)
        {
            AppointmentPrefillFieldValue appointmentPrefillFieldValue = dbContext.AppointmentPrefillFieldValues.FirstOrDefault(x => x.Id == Id);

            if (appointmentPrefillFieldValue == null)
            {
                throw new NullReferenceException($"Could not find AppointmentPrefillFieldValue with {Id}");
            }

            appointmentPrefillFieldValue.AppointmentId    = AppointmentId;
            appointmentPrefillFieldValue.MicrotingSiteUid = MicrotingSiteUid;
            appointmentPrefillFieldValue.FieldId          = FieldId;
            appointmentPrefillFieldValue.FieldValue       = FieldValue;
            appointmentPrefillFieldValue.AppointmentFvId  = AppointmentFvId;
            appointmentPrefillFieldValue.WorkflowState    = WorkflowState;
            appointmentPrefillFieldValue.UpdatedByUserId  = UpdatedByUserId;


            if (dbContext.ChangeTracker.HasChanges())
            {
                appointmentPrefillFieldValue.UpdatedAt = DateTime.UtcNow;
                appointmentPrefillFieldValue.Version  += 1;
                dbContext.SaveChanges();

                dbContext.AppointmentPrefillFieldValueVersions.Add(MapVersions(appointmentPrefillFieldValue));
                dbContext.SaveChanges();
            }
        }
Beispiel #4
0
        public async Task Update(AppointmentPnDbContext dbContext)
        {
            AppointmentSite appointmentSite = dbContext.AppointmentSites.FirstOrDefault(x => x.Id == Id);

            if (appointmentSite == null)
            {
                throw new NullReferenceException($"Could not find AppointmentSite with {Id}");
            }

            appointmentSite.AppointmentId    = AppointmentId;
            appointmentSite.MicrotingSiteUid = MicrotingSiteUid;
            appointmentSite.ExceptionString  = ExceptionString;
            appointmentSite.SdkCaseId        = SdkCaseId;
            appointmentSite.ProcessingState  = ProcessingState;
            appointmentSite.Completed        = Completed;
            appointmentSite.WorkflowState    = WorkflowState;
            appointmentSite.UpdatedByUserId  = UpdatedByUserId;

            if (dbContext.ChangeTracker.HasChanges())
            {
                appointmentSite.UpdatedAt = DateTime.UtcNow;
                appointmentSite.Version  += 1;
                dbContext.SaveChanges();

                dbContext.AppointmentSiteVersions.Add(MapVersions(appointmentSite));
                dbContext.SaveChanges();
            }
        }
Beispiel #5
0
        public static Appointment AppointmentFindByCaseId(AppointmentPnDbContext dbContext, string sdkCaseId)
        {
            try
            {
//                using (var db = GetContextO())
//                {
                Microting.AppointmentBase.Infrastructure.Data.Entities.AppointmentSite appointmentSite = dbContext.AppointmentSites.SingleOrDefault(x => x.SdkCaseId == sdkCaseId);

                if (appointmentSite == null)
                {
                    return(null);
                }

                Microting.AppointmentBase.Infrastructure.Data.Entities.Appointment _appo = appointmentSite.Appointment;
                Appointment appointment = new Appointment()
                {
                };
//                Appointment appo = new Appointment(_appo.global_id, (DateTime)_appo.start_at, (int)_appo.duration, _appo.subject, _appo.processing_state, _appo.body, (_appo.color_rule == 0 ? false : true), _appo.id);
//                AppoinntmentSite appo_site = new AppoinntmentSite((int)_appo_site.id, _appo_site.microting_site_uid, _appo_site.processing_state, _appo_site.sdk_case_id);
//                appo.AppointmentSites.Add(appo_site);

                return(appointment);
//                }
            }
            catch (Exception ex)
            {
//                log.LogException(t.GetMethodName("SQLController"), "failed", ex, false);
                return(null);
            }
        }
Beispiel #6
0
        public static bool AppointmentsReflected(AppointmentPnDbContext dbContext, string globalId)
        {
            try
            {
                var match = dbContext.Appointments.SingleOrDefault(x => x.GlobalId == globalId);

                if (match == null)
                {
                    return(false);
                }

                short?temp = match.Completed;

                if (match.Completed == 0)
                {
                    temp = 1;
                }

                if (match.Completed == 1)
                {
                    temp = 2;
                }

                match.Completed = temp;
                match.Update(dbContext);

                return(true);
            }
            catch (Exception ex)
            {
//                log.LogException(t.GetMethodName("SQLController"), "failed", ex, false);
                return(false);
            }
        }
        private void GetContext(string connectionStr)
        {
            AppointmentPnContextFactory contextFactory = new AppointmentPnContextFactory();

            DbContext = contextFactory.CreateDbContext(new[] { connectionStr });

            DbContext.Database.Migrate();
            DbContext.Database.EnsureCreated();
        }
 public AppointmentsService(
     AppointmentPnDbContext dbContext,
     IAppointmentLocalizationService appointmentLocalizationService,
     IHttpContextAccessor httpContextAccessor,
     IEFormCoreService coreHelper
     )
 {
     _dbContext = dbContext;
     _appointmentLocalizationService = appointmentLocalizationService;
     _httpContextAccessor            = httpContextAccessor;
     _coreHelper = coreHelper;
 }
Beispiel #9
0
        public async Task Create(AppointmentPnDbContext dbContext)
        {
            CreatedAt     = DateTime.UtcNow;
            UpdatedAt     = DateTime.UtcNow;
            Version       = 1;
            WorkflowState = Constants.WorkflowStates.Created;

            dbContext.AppointmentPrefillFieldValues.Add(this);
            dbContext.SaveChanges();

            dbContext.AppointmentPrefillFieldValueVersions.Add(MapVersions(this));
            dbContext.SaveChanges();
        }
Beispiel #10
0
        public static bool AppointmentsUpdate(AppointmentPnDbContext dbContext, string globalId,
                                              ProcessingStateOptions processingState, string body, string exceptionString, string response,
                                              bool completed, DateTime start_at, DateTime expire_at, int duration)
        {
//            log.LogEverything(t.GetMethodName("SQLController"), "AppointmentsUpdate called and globalId is " + globalId);

            try
            {
                var match = dbContext.Appointments.SingleOrDefault(x => x.GlobalId == globalId);

                if (match == null)
                {
                    return(false);
                }

                match.ProcessingState = processingState.ToString();
//                match.updated_at = DateTime.Now;
                match.StartAt  = start_at;
                match.ExpireAt = expire_at;
                match.Duration = duration;
                //match.completed = 0;
                #region match.body = body ...
                if (body != null)
                {
                    match.Body = body;
                }
                #endregion
                #region match.response = response ...
                if (response != null)
                {
                    match.Response = response;
                }
                #endregion
                #region match.expectionString = expectionString ...
                if (response != null)
                {
                    match.ExceptionString = exceptionString;
                }
                #endregion
//                match.version = match.version + 1;

                match.Update(dbContext);

                return(true);
            }
            catch (Exception ex)
            {
//                log.LogException(t.GetMethodName("SQLController"), "failed", ex, false);
                return(false);
            }
        }
Beispiel #11
0
        public static Microting.AppointmentBase.Infrastructure.Data.Entities.Appointment AppointmentsFindOne(
            AppointmentPnDbContext dbContext, int timesReflected)
        {
            try
            {
                var match = dbContext.Appointments.FirstOrDefault(x => x.Completed == timesReflected);
                return(match);
            }
            catch (Exception ex)
            {
//                log.LogException(t.GetMethodName("SQLController"), "failed", ex, false);
                return(null);
            }
        }
 public AppointmentPnSettingsService(ILogger <AppointmentPnSettingsService> logger,
                                     IAppointmentLocalizationService trashInspectionLocalizationService,
                                     AppointmentPnDbContext dbContext,
                                     IPluginDbOptions <AppointmentBaseSettings> options,
                                     IEFormCoreService coreHelper,
                                     IHttpContextAccessor httpContextAccessor)
 {
     _logger              = logger;
     _dbContext           = dbContext;
     _coreHelper          = coreHelper;
     _options             = options;
     _httpContextAccessor = httpContextAccessor;
     _trashInspectionLocalizationService = trashInspectionLocalizationService;
 }
Beispiel #13
0
        public async Task Update(AppointmentPnDbContext dbContext)
        {
            Appointment appointment = dbContext.Appointments.FirstOrDefault(x => x.Id == Id);

            if (appointment == null)
            {
                throw new NullReferenceException($"Could not find Appointment with {Id}");
            }

            appointment.GlobalId        = GlobalId;
            appointment.StartAt         = StartAt;
            appointment.ExpireAt        = ExpireAt;
            appointment.Duration        = Duration;
            appointment.Subject         = Subject;
            appointment.ProcessingState = ProcessingState;
            appointment.Body            = Body;
            appointment.ExceptionString = ExceptionString;
            appointment.Title           = Title;
            appointment.Description     = Description;
            appointment.Info            = Info;
            appointment.MicrotingUuid   = MicrotingUuid;
            appointment.Completed       = Completed;
            appointment.Replacements    = Replacements;
            appointment.SdkeFormId      = SdkeFormId;
            appointment.Response        = Response;
            appointment.ColorRule       = ColorRule;
            appointment.ColorHex        = ColorHex;
            appointment.RepeatEvery     = RepeatEvery;
            appointment.RepeatType      = RepeatType;
            appointment.RepeatUntil     = RepeatUntil;
            appointment.UpdatedByUserId = UpdatedByUserId;

            if (dbContext.ChangeTracker.HasChanges())
            {
                appointment.UpdatedAt = DateTime.UtcNow;
                appointment.Version  += 1;
                dbContext.SaveChanges();

                dbContext.AppointmentVersions.Add(MapVersions(appointment));
                dbContext.SaveChanges();
            }
        }
Beispiel #14
0
        public static void SeedData(AppointmentPnDbContext dbContext)
        {
            var seedData          = new AppointmentConfigurationSeedData();
            var configurationList = seedData.Data;

            foreach (var configurationItem in configurationList)
            {
                if (!dbContext.PluginConfigurationValues.Any(x => x.Name == configurationItem.Name))
                {
                    var newConfigValue = new PluginConfigurationValue()
                    {
                        Name            = configurationItem.Name,
                        Value           = configurationItem.Value,
                        CreatedAt       = DateTime.UtcNow,
                        Version         = 1,
                        WorkflowState   = Constants.WorkflowStates.Created,
                        CreatedByUserId = 1
                    };
                    dbContext.PluginConfigurationValues.Add(newConfigValue);
                    dbContext.SaveChanges();
                }
            }

            // Seed plugin permissions
            var newPermissions = AppointmentPermissionsSeedData.Data
                                 .Where(p => dbContext.PluginPermissions.All(x => x.ClaimName != p.ClaimName))
                                 .Select(p => new PluginPermission
            {
                PermissionName  = p.PermissionName,
                ClaimName       = p.ClaimName,
                CreatedAt       = DateTime.UtcNow,
                Version         = 1,
                WorkflowState   = Constants.WorkflowStates.Created,
                CreatedByUserId = 1
            }
                                         );

            dbContext.PluginPermissions.AddRange(newPermissions);

            dbContext.SaveChanges();
        }
Beispiel #15
0
        public async Task Delete(AppointmentPnDbContext dbContext)
        {
            AppointmentPrefillFieldValue appointmentPrefillFieldValue = dbContext.AppointmentPrefillFieldValues.FirstOrDefault(x => x.Id == Id);

            if (appointmentPrefillFieldValue == null)
            {
                throw new NullReferenceException($"Could not find AppointmentPrefillFieldValue with {Id}");
            }

            appointmentPrefillFieldValue.WorkflowState = Constants.WorkflowStates.Removed;

            if (dbContext.ChangeTracker.HasChanges())
            {
                appointmentPrefillFieldValue.UpdatedAt = DateTime.UtcNow;
                appointmentPrefillFieldValue.Version  += 1;
                dbContext.SaveChanges();

                dbContext.AppointmentPrefillFieldValueVersions.Add(MapVersions(appointmentPrefillFieldValue));
                dbContext.SaveChanges();
            }
        }
 public EformCompletedHandler(AppointmentPnDbContext dbContext, IOutlookOnlineController outlookOnlineController)
 {
     this._dbContext = dbContext;
     this.outlookOnlineController = outlookOnlineController;
 }
Beispiel #17
0
        public static Appointment AppointmentsFind(AppointmentPnDbContext dbContext, string globalId)
        {
//            log.LogStandard(t.GetMethodName("SQLController"), "AppointmentsFind looking for one with globalId " + globalId);

            try
            {
                var match = dbContext.Appointments.SingleOrDefault(x => x.GlobalId == globalId);
                if (match != null)
                {
                    bool        color_rule = match.ColorRule == 0 ? true : false;
                    Appointment appo       = new Appointment()
                    {
                        GlobalId        = match.GlobalId,
                        Start           = (DateTime)match.StartAt,
                        Duration        = (int)match.Duration,
                        Subject         = match.Subject,
                        ProcessingState = match.ProcessingState,
                        Body            = match.Body,
                        ColorRule       = color_rule,
                        Id = match.Id
                    };
                    appo.Completed = match.Completed == 0 ? false : true;
                    try {
                        appo.TemplateId = (int)match.SdkeFormId;
                    }
                    catch { }

                    foreach (Microting.AppointmentBase.Infrastructure.Data.Entities.AppointmentSite appointmentSite in match.AppointmentSites)
                    {
                        AppointmentSite obj = new AppointmentSite()
                        {
                            Id = appointmentSite.Id,
                            MicrotingSiteUid = appointmentSite.MicrotingSiteUid,
                            ProcessingState  = appointmentSite.ProcessingState,
                            SdkCaseId        = appointmentSite.SdkCaseId
                        };
                        appo.AppointmentSites.Add(obj);
                    }

                    foreach (Microting.AppointmentBase.Infrastructure.Data.Entities.AppointmentPrefillFieldValue pfv in match.AppointmentPrefillFieldValues)
                    {
                        AppointmentPrefillFieldValue appointmentPrefillFieldValue = new AppointmentPrefillFieldValue()
                        {
                            Id            = pfv.Id,
                            FieldId       = pfv.FieldId,
                            AppointmentId = (int)pfv.AppointmentId,
                            FieldValue    = pfv.FieldValue
                        };
                        appo.AppointmentPrefillFieldValues.Add(appointmentPrefillFieldValue);
                    }
                    return(appo);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
//                log.LogException(t.GetMethodName("SQLController"), "failed", ex, false);
                return(null);
            }
        }
Beispiel #18
0
 public ConvertRecurringEventToSingleEventHandler(AppointmentPnDbContext dbContext)
 {
     this._dbContext = dbContext;
 }
 public EformParsedByServerHandler(AppointmentPnDbContext dbContext)
 {
     this._dbContext = dbContext;
 }
Beispiel #20
0
        public bool Start(string sdkConnectionString, string serviceLocation)
        {
            Console.WriteLine("ServiceAppointmentPlugin start called");
            try
            {
                //InstallCA();

                var dbNameSection = Regex.Match(sdkConnectionString, @"(Database=\w*;)").Groups[0].Value;
                var dbPrefix      = Regex.Match(sdkConnectionString, @"Database=(\d*)_").Groups[1].Value;

                string pluginDbName     = $"Initial Catalog={dbPrefix}_eform-angular-appointment-plugin;";
                string connectionString = sdkConnectionString.Replace(dbNameSection, pluginDbName);


                if (!_coreAvailable && !_coreStatChanging)
                {
                    _serviceLocation  = serviceLocation;
                    _coreStatChanging = true;

                    if (string.IsNullOrEmpty(_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");
                    }

                    AppointmentPnContextFactory contextFactory = new AppointmentPnContextFactory();

                    _dbContext = contextFactory.CreateDbContext(new[] { connectionString });
                    _dbContext.Database.Migrate();

                    _coreAvailable    = true;
                    _coreStatChanging = false;

                    startSdkCoreSqlOnly(sdkConnectionString);

                    _container = new WindsorContainer();
                    _container.Register(Component.For <AppointmentPnDbContext>().Instance(_dbContext));
                    _container.Register(Component.For <eFormCore.Core>().Instance(_sdkCore));
                    _container.Install(
                        new RebusHandlerInstaller()
                        , new RebusInstaller(connectionString, _maxParallelism, _numberOfWorkers)
                        );
                    _container.Register(Component.For <UpdateAppointmentsJob>());


                    _bus = _container.Resolve <IBus>();

                    ConfigureScheduler();
                }
                Console.WriteLine("ServiceAppointmentPlugin started");
                return(true);
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("Start failed " + ex.Message);
                throw;
            }
        }
Beispiel #21
0
 public AppointmentDeletedInOutlookHandler(AppointmentPnDbContext dbContext)
 {
     this._dbContext = dbContext;
 }
 public EformParsingErrorHandler(AppointmentPnDbContext dbContext)
 {
     this._dbContext = dbContext;
 }
Beispiel #23
0
 public UpdateAppointmentsJob(AppointmentPnDbContext dbContext, IBus bus, eFormCore.Core core)
 {
     _dbContext = dbContext;
     _bus       = bus;
     _core      = core;
 }