Пример #1
0
 public EmailService(IFlexKidsConfig flexKidsConfig)
 {
     client = new SmtpClient
     {
         Port                  = flexKidsConfig.SmtpPort,
         Host                  = flexKidsConfig.SmtpHost,
         EnableSsl             = false,
         Timeout               = 10000,
         DeliveryMethod        = SmtpDeliveryMethod.Network,
         UseDefaultCredentials = false,
         Credentials           = new NetworkCredential(flexKidsConfig.SmtpUsername, flexKidsConfig.SmtpPassword)
     };
 }
        public EmailReportScheduleChange(IFlexKidsConfig flexKidsConfig, IEmailService emailService)
        {
            if (flexKidsConfig == null)
            {
                throw new ArgumentNullException("flexKidsConfig");
            }
            if (emailService == null)
            {
                throw new ArgumentNullException("emailService");
            }

            this.flexKidsConfig = flexKidsConfig;
            this.emailService   = emailService;
        }
Пример #3
0
        public GoogleCalendarScheduler(IDateTimeProvider dateTimeProvider, IFlexKidsConfig flexKidsConfig /*IGoogleCalendarService googleCalendarService*/)
        {
            //       if (googleCalendarService == null)
            //           throw new ArgumentNullException("googleCalendarService");

            //       calendarService = googleCalendarService;

            googleCalendarId      = flexKidsConfig.GoogleCalendarId;
            googleCalendarAccount = flexKidsConfig.GoogleCalendarAccount;

            //TODO Check if file exists and make it more robust.
            var certificate = new X509Certificate2(@flexKidsConfig.GoogleCalendarKeyFile, "notasecret", X509KeyStorageFlags.Exportable);

            var credential = new ServiceAccountCredential(
                new ServiceAccountCredential.Initializer(googleCalendarAccount)
            {
                Scopes = new[] { CalendarService.Scope.Calendar }
            }.FromCertificate(certificate));

            // Create the service.
            var service = new CalendarService(new BaseClientService.Initializer
            {
                HttpClientFactory     = new Google.Apis.Http.HttpClientFactory(),
                HttpClientInitializer = credential,
                ApplicationName       = "FlexKids Rooster by CoenM",
            });

            if (service == null)
            {
                throw new Exception("Cannot create service.");
            }

            calendarService = new GoogleCalendarService(service);


            var calendar = calendarService.GetCalendarById(googleCalendarId);

            if (calendar == null)
            {
                throw new Exception("Cannot find calendar");
            }
        }
 public CalendarReportScheduleChange(IDateTimeProvider dateTimeProvider, IFlexKidsConfig flexKidsConfig)
 {
     this.dateTimeProvider = dateTimeProvider;
     this.flexKidsConfig   = flexKidsConfig;
 }