/// <summary>
        /// Update method implmentation
        /// </summary>
        public override void Load(PSHost host)
        {
            ManagementService.Initialize(host, true);
            MFAConfig    cfg  = ManagementService.Config;
            MailProvider mail = cfg.MailProvider;

            IsDirty                     = cfg.IsDirty;
            Enabled                     = mail.Enabled;
            EnrollWizard                = mail.EnrollWizard;
            ForceWizard                 = mail.ForceWizard;
            From                        = mail.From;
            UserName                    = mail.UserName;
            Password                    = mail.Password;
            Host                        = mail.Host;
            Port                        = mail.Port;
            UseSSL                      = mail.UseSSL;
            Company                     = mail.Company;
            PinRequired                 = mail.PinRequired;
            Anonymous                   = mail.Anonymous;
            DeliveryNotifications       = mail.DeliveryNotifications;
            FullQualifiedImplementation = mail.FullQualifiedImplementation;
            Parameters                  = mail.Parameters.Data;

            AllowedDomains.Clear();
            foreach (string itm in mail.AllowedDomains)
            {
                AllowedDomains.AddDomain(itm);
            }

            BlockedDomains.Clear();
            foreach (string itm in mail.BlockedDomains)
            {
                BlockedDomains.AddDomain(itm);
            }

            MailOTPContent.Clear();
            foreach (SendMailFileName itm in mail.MailOTPContent)
            {
                MailOTPContent.Add((FlatConfigMailFileName)itm);
            }
            MailAdminContent.Clear();
            foreach (SendMailFileName itm in mail.MailAdminContent)
            {
                MailAdminContent.Add((FlatConfigMailFileName)itm);
            }
            MailKeyContent.Clear();
            foreach (SendMailFileName itm in mail.MailKeyContent)
            {
                MailKeyContent.Add((FlatConfigMailFileName)itm);
            }
            MailNotifications.Clear();
            foreach (SendMailFileName itm in mail.MailNotifications)
            {
                MailNotifications.Add((FlatConfigMailFileName)itm);
            }
        }
示例#2
0
        private static void OldReservations()
        {
            var db = new BookingContext();

            var maxTime = db.Settings.FirstOrDefault().MaxTime;

            foreach (var reservedBook in db.ReservedBook.Where(x => DateTime.Now > x.ReservedDate.AddDays(maxTime)))
            {
                var email = db.Users.FirstOrDefault(x => x.UserId == reservedBook.UserId).Email;

                MailNotifications.SendEmail(email, "Your reservation was auto-cancelled because the book was not collected on time.", "Reservation cancelled");

                db.Remove(new ReservedBook()
                {
                    ReservedBookId = reservedBook.ReservedBookId
                });
                db.SaveChanges();
            }
        }
示例#3
0
        private static void SendReminder()
        {
            var db = new BookingContext();

            var maxTime = db.Settings.FirstOrDefault().MaxTime;

            foreach (var reservedBook in db.ReservedBook.Where(x => x.ReturnDate != null && x.ReturnedDate == null))
            {
                var email = db.Users.FirstOrDefault(x => x.UserId == reservedBook.UserId).Email;

                if (reservedBook.ReturnDate.Value.Subtract(DateTime.Now).TotalDays < 0)
                {
                    MailNotifications.SendEmail(email, "Please return the book. Your time has expired.", "WARNING: OVERTIME!");
                }
                else if (reservedBook.ReturnDate.Value.Subtract(DateTime.Now).TotalDays < maxTime)
                {
                    MailNotifications.SendEmail(email, $"You have to return your book on: {reservedBook.ReturnDate}.", "Library reminder");
                }
            }
        }
示例#4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IWebHostEnvironment env,
            MailNotifications mailNotifications)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            var provider = new FileExtensionContentTypeProvider();

            provider.Mappings[".ts"]   = "video/mp2t";
            provider.Mappings[".m3u8"] = "application/vnd.apple.mpegurl";
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(
                    System.IO.Path.GetFullPath(_Config.HlsRoot)
                    ),
                RequestPath         = "/Stream",
                ContentTypeProvider = provider
            });

            app.UseMiddleware <HttpExceptionMiddleware>();

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            mailNotifications.Start();
        }