/// <summary> /// The configuration profile method. /// </summary> /// <param name="app"></param> public void Configuration(IAppBuilder app) { // Configuration ConfigureAuth(app); // Database initialization using (var db = new BodyShapeContext()) db.Database.Initialize(true); }
/// <summary> /// The constructor. /// </summary> public BodyRecorder() { this.dbContext = new BodyShapeContext(); // Automapper mapperConfig = new MapperConfiguration(cfg => { cfg.AddProfile <BodyMapProfile>(); }); this.mapper = mapperConfig.CreateMapper(); }
/// <summary> /// The Start method. /// </summary> public void Start() { try { // Configuration configuration = GetBodyShapeConfiguration(); phoneRecipients = new List <string>(); foreach (var rec in configuration.Recipients) { phoneRecipients.Add(((RecipientPhoneElementConfiguration)rec).Phone); } // Twilio SMS client TwilioClient.Init(configuration.SmsApiSid, configuration.SmsApiToken); // The stored generations guid storedGuids = new List <Guid>(); // Logger var path = Path.Combine(configuration.FolderLog, "bodyshapeWatcher-{Date}.txt"); logger = new LoggerConfiguration() .WriteTo.RollingFile(path, shared: true) .CreateLogger(); logger.Information("**************************** START ****************************"); logger.Information("Getting watcher configuration..."); // Database context dbContext = new BodyShapeContext(); logger.Information("Database context instanciated..."); // Store bases generation guids storedGuids = dbContext.Generations.Select(d => d.Id).ToList(); logger.Information("Storing bases generation guids..."); // Timer var timer = new Timer(); timer.Interval = configuration.TimerInterval * 1000; // To milliseconds timer.Elapsed += Timer_Elapsed; timer.Start(); logger.Information("Timer created..."); // Wait... logger.Information("Waiting for new BodyShape users generations..."); } catch (Exception ex) { logger.Error($"An error occured\n\t{ ex }"); } }