Example #1
0
        /// <summary>
        /// Gets the appropriate cloud provider
        /// </summary>
        /// <returns>cloud provider</returns>
        public ICloudProvider Provider()
        {
            // Our cloud provider selection will be based on a config value "cloud"
            // that can be set in any of the configuration sources
            string cloudProvider = this.config.GetValue <string>("cloud");

            /*
             * If we have a known cloud provider then we will instantiate the configuration and
             * attempt to bind the config object to configuration values by matching
             * property names against configuration keys recursively
             * https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-2.2
             */

            if (cloudProvider == "azure")
            {
                var cloudConfig = new AzureConfiguration();
                this.config.Bind(cloudConfig);
                return(new AzureProvider(cloudConfig));
            }
            else if (cloudProvider == "gcp")
            {
                var cloudConfig = new GoogleConfiguration();
                this.config.Bind(cloudConfig);
                return(new GoogleProvider(cloudConfig));
            }
            else if (cloudProvider == "development")
            {
                // Initialize the MockCloudProvider in development to facilitate api logic testing
                return(new MockCloudProvider(true));
            }

            throw new ArgumentOutOfRangeException("cloud", "Empty or invalid");
        }
 /// <summary>
 /// Init Auth controller
 /// </summary>
 /// <param name="authService">Auth Service</param>
 /// <param name="options">Application options</param>
 /// <param name="googleOptions">Google options</param>
 /// <param name="msOptions">Microsoft options</param>
 public AuthController(IAuthService authService, IOptions <ApplicationConfiguration> options, IOptions <GoogleConfiguration> googleOptions, IOptions <MicrosoftConfiguration> msOptions)
 {
     _authService = authService;
     _applicationConfiguration = options.Value;
     _googleConfiguration      = googleOptions.Value;
     _msConfiguration          = msOptions.Value;
 }
Example #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Yo, the Bacterio Crawler is startin' baby.");

            string inputFileName = GetInputFileName();

            if (inputFileName == null)
            {
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
                return;
            }

            string inputDelimiterStr = GetInputDelimiter();

            if (inputDelimiterStr == null)
            {
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
                return;
            }
            char inputDelimiter = inputDelimiterStr[0];

            string[] sourceLines = LoadFileByLines(inputFileName);
            if (sourceLines == null)
            {
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
                return;
            }
            Dictionary <string, string[]> keywords            = LoadKeywords(KEYWORD_FILE_NAME);
            GoogleConfiguration           googleConfiguration = LoadGoogleConfiguration();

            if (sourceLines != null && sourceLines.Length > 0 && keywords != null && googleConfiguration != null)
            {
                PrintParameters(inputFileName, inputDelimiter, KEYWORD_FILE_NAME);

                try
                {
                    PrepareTmpHtmlFolder(TEMP_FOLDER);

                    PrepareOutFile(OUT_FILE_NAME, keywords, inputDelimiter);

                    DoSearch(sourceLines, keywords, googleConfiguration, inputDelimiter);

                    Console.WriteLine("Done.");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Unexpected exception: {0}.", ex.Message);
                    Console.WriteLine("Cause: {0}.", ex.Source);
                    Console.WriteLine("Stack trace: {0}.", ex.StackTrace);
                }
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Example #4
0
 public GoogleFitLogic(
     IOptions <GoogleConfiguration> googleConfiguration,
     CosmosDbLogic cosmosDbLogic,
     HttpClient httpClient)
 {
     _googleConfiguration = googleConfiguration.Value;
     _cosmosDbLogic       = cosmosDbLogic;
     _httpClient          = httpClient;
 }
Example #5
0
        public void Remove(AppointmentDto meeting, LightPatientDto patient, GoogleConfiguration config)
        {
            var entity = this.Session.Get <Appointment>(meeting.Id);

            if (config.IsActive)
            {
                new GoogleService(config).RemoveAppointment(entity);
            }
            this.Remove(meeting, patient);
        }
 /// <summary>
 /// Init Auth Service
 /// </summary>
 /// <param name="userService">User Service</param>
 /// <param name="tokenService">Token Service</param>
 /// <param name="userManager">User Manager</param>
 /// <param name="roleManager">Role Manager</param>
 /// <param name="googleOptions">Google options</param>
 /// <param name="microsoftOptions">Microsoft options</param>
 /// <param name="clientFactory">HTTP Client factory</param>
 public AuthService(IUserService userService, ITokenService tokenService, UserManager <User> userManager, RoleManager <Role> roleManager, IOptions <GoogleConfiguration> googleOptions, IOptions <MicrosoftConfiguration> microsoftOptions, IHttpClientFactory clientFactory)
 {
     _userService            = userService;
     _tokenService           = tokenService;
     _userManager            = userManager;
     _roleManager            = roleManager;
     _googleConfiguration    = googleOptions.Value;
     _microsoftConfiguration = microsoftOptions.Value;
     _httpClientFactory      = clientFactory;
 }
Example #7
0
        public Map(SiteContext siteContext, IConfiguration configuration, IStringLocalizer <Map> localizer, ILogger <Map> logger)
        {
            _siteContext   = siteContext;
            _appDb         = siteContext.AppDb;
            _configuration = configuration;
            _localizer     = localizer;
            _logger        = logger;

            _googleConfig = new GoogleConfiguration();
            _configuration.Bind(nameof(GoogleConfiguration), _googleConfig);
        }
Example #8
0
        /// <summary>
        /// Gets the appointments for the specified day and add all the appointments from Google Calendar.
        /// </summary>
        /// <param name="day">The day.</param>
        /// <returns>A list of appointments</returns>
        public IList <AppointmentDto> GetAppointments(DateTime day, GoogleConfiguration config)
        {
            var result = (from a in this.Session.Query <Appointment>()
                          where a.StartTime >= day.Date &&
                          a.EndTime <= day.Date.AddDays(1)
                          select a).ToList();

            if (config.IsActive)
            {
                result.AddRange(new GoogleService(config).GetAppointments(day, this.GetGoogleTag()));
            }

            return(Mapper.Map <IList <Appointment>, IList <AppointmentDto> >(result));
        }
Example #9
0
 public Venue(ITenantContext tenantContext, IAuthorizationService authorizationService,
              IStringLocalizer <Venue> localizer, RegionInfo regionInfo,
              IConfiguration configuration, ILogger <Venue> logger)
 {
     _defaultReturnUrl     = "/";
     _tenantContext        = tenantContext;
     _appDb                = tenantContext.DbContext.AppDb;
     _authorizationService = authorizationService;
     _localizer            = localizer;
     _regionInfo           = regionInfo;
     _configuration        = configuration;
     _logger               = logger;
     _googleConfig         = new GoogleConfiguration();
     _configuration.Bind(nameof(ConfigurationPoco.GoogleConfiguration), _googleConfig);
 }
Example #10
0
        public MeetingPreloader(GoogleConfiguration configuration,
                                DemoConfiguration demoConfiguration,
                                INotify notifications,
                                GoogleService googleService,
                                RoomSubscriptionService roomSubscriptionService,
                                IHubContext <RoomHub> roomHubContext)
        {
            _google           = googleService;
            _roomSubscription = roomSubscriptionService;
            _notifications    = notifications;
            _demo             = demoConfiguration;
            _roomHubContext   = roomHubContext;

            _maxEvents = configuration.MaxCalendarEvents;
        }
 public GoogleAuthenticationController(
     GoogleConfiguration configuration,
     IGoogleClient googleClient,
     IJwtService jwtService,
     IMapper mapper,
     IRngUtil rngUtil,
     ISocialMediaUserLinkService socialMediaUserLinkService
     )
 {
     _configuration = configuration;
     _googleClient  = googleClient;
     _jwtService    = jwtService;
     _mapper        = mapper;
     _rngUtil       = rngUtil;
     _socialMediaUserLinkService = socialMediaUserLinkService;
 }
Example #12
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="cosmosDbConfiguration"></param>
        /// <param name="healthPlanetConfiguration"></param>
        /// <param name="googleConfiguration"></param>
        /// <param name="initializeCosmosDbLogic"></param>
        /// <param name="healthPlanetLogic"></param>
        /// <param name="googleFitLogic"></param>
        public InitializeFunctions(
            IOptions <CosmosDbConfiguration> cosmosDbConfiguration,
            IOptions <HealthPlanetConfiguration> healthPlanetConfiguration,
            IOptions <GoogleConfiguration> googleConfiguration,
            InitializeCosmosDbLogic initializeCosmosDbLogic,
            HealthPlanetLogic healthPlanetLogic,
            GoogleFitLogic googleFitLogic
            )
        {
            _cosmosDbConfiguration     = cosmosDbConfiguration.Value;
            _healthPlanetConfiguration = healthPlanetConfiguration.Value;
            _googleConfiguration       = googleConfiguration.Value;

            _initializeCosmosDbLogic = initializeCosmosDbLogic;
            _healthPlanetLogic       = healthPlanetLogic;
            _googleFitLogic          = googleFitLogic;
        }
Example #13
0
 public TeamApplication(ITenantContext tenantContext,
                        Axuno.Tools.DateAndTime.TimeZoneConverter timeZoneConverter,
                        IStringLocalizer <TeamApplication> localizer, IAuthorizationService authorizationService,
                        RegionInfo regionInfo,
                        IConfiguration configuration, Axuno.BackgroundTask.IBackgroundQueue queue,
                        SendEmailTask sendEmailTask, ILogger <TeamApplication> logger)
 {
     _tenantContext     = tenantContext;
     _timeZoneConverter = timeZoneConverter;
     _regionInfo        = regionInfo;
     _googleConfig      = new GoogleConfiguration();
     configuration.Bind(nameof(GoogleConfiguration), _googleConfig);
     _queue                = queue;
     _sendEmailTask        = sendEmailTask;
     _appDb                = tenantContext.DbContext.AppDb;
     _authorizationService = authorizationService;
     _logger               = logger;
 }
Example #14
0
        /// <summary>
        /// Creates the specified appointment and use create it in Google Calendar if the binding is active.
        /// </summary>
        /// <param name="appointment">The appointment.</param>
        /// <param name="patient">The patient.</param>
        /// <param name="config">The config.</param>
        public void Create(AppointmentDto appointment, LightPatientDto patient, GoogleConfiguration config)
        {
            var patientEntity = this.Session.Get <Patient>(patient.Id);
            var meetingEntity = Mapper.Map <AppointmentDto, Appointment>(appointment);

            meetingEntity.GoogleSynchronisationId = (config.IsActive)
                ? Guid.NewGuid() //This id allows to find Google appointments
                : new Guid();    //Empty Guid indicates this appointments is not binded with Google Calendar

            meetingEntity.User = this.Session.Get <User>(meetingEntity.User.Id);

            patientEntity.Appointments.Add(meetingEntity);
            this.Session.SaveOrUpdate(patientEntity);

            if (config.IsActive)
            {
                new GoogleService(config).AddAppointment(meetingEntity);
            }
        }
Example #15
0
        private void RegisterConfigurations(IServiceCollection services)
        {
            var mailConfiguration = new MailConfiguration();

            _configuration.Bind("Mail", mailConfiguration);
            services.AddSingleton <IMailConfiguration>(mailConfiguration);

            var authenticationConfiguration = new AuthenticationConfiguration();

            _configuration.Bind("Authentication", authenticationConfiguration);
            services.AddSingleton <IAuthenticationConfiguration>(authenticationConfiguration);

            var googleConfiguration = new GoogleConfiguration();

            _configuration.Bind("Authentication:Google", googleConfiguration);
            services.AddSingleton(googleConfiguration);

            var facebookConfiguration = new FacebookConfiguration();

            _configuration.Bind("Authentication:Facebook", facebookConfiguration);
            services.AddSingleton(facebookConfiguration);

            var twitterConfiguration = new TwitterConfiguration();

            _configuration.Bind("Authentication:Twitter", twitterConfiguration);
            services.AddSingleton(twitterConfiguration);

            var microsoftConfiguration = new MicrosoftGraphConfiguration();

            _configuration.Bind("Authentication:MicrosoftGraph", microsoftConfiguration);
            services.AddSingleton(microsoftConfiguration);

            var mapImageConfiguration = new MapImageConfiguration();

            _configuration.Bind("MapImage", mapImageConfiguration);
            services.AddSingleton(mapImageConfiguration);
        }
Example #16
0
 public GoogleService(GoogleConfiguration config)
 {
     this.UserName    = config.UserName;
     this.Password    = config.Password;
     this.CalendarUri = config.CalendarUri;
 }
Example #17
0
 public GoogleService(GoogleConfiguration configuration)
 {
     _configuration = configuration;
 }
Example #18
0
 public GoogleGeocodeController(IOptions <GoogleConfiguration> googleConfigurationOption)
 {
     this.googleConfiguration = googleConfigurationOption.Value;
 }
 public CalendarEventProvider(IConfiguration configuration, ICalendarServiceProvider calendarServiceProvider, IClock clock)
 {
     this.configuration           = configuration.GetSection(GoogleConfiguration.SectionKey).Get <GoogleConfiguration>();
     this.calendarServiceProvider = calendarServiceProvider;
     this.clock = clock;
 }
Example #20
0
 public void Create(AppointmentDto appointment, LightPatientDto patient, GoogleConfiguration config)
 {
     new Creator(this.Session).Create(appointment, patient, config);
 }
Example #21
0
 public GoogleSearcher()
 {
     Config = new GoogleConfiguration();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GoogleStorageProvider" /> class
 /// </summary>
 /// <param name="cloud">Google cloud config</param>
 public GoogleStorageProvider(GoogleConfiguration cloud)
 {
     this.cloud = cloud;
 }
Example #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GoogleProvider" /> class
 /// </summary>
 /// <param name="cloud">Azure cloud configuration</param>
 public GoogleProvider(GoogleConfiguration cloud)
 {
     this.cloud = cloud;
     this.cloud.LogConfiguration();
 }
Example #24
0
        private static void DoSearch(string[] sourceLines, Dictionary <string, string[]> keywords, GoogleConfiguration googleConfiguration, char inputDelimiter)
        {
            Console.WriteLine("Performing search.");
            BacterioSearcher bacterioSearcher = new BacterioSearcher(new SearchService(googleConfiguration),
                                                                     keywords,
                                                                     new CsvFileResultsSaver(OUT_FILE_NAME, inputDelimiter),
                                                                     new Parser(inputDelimiter),
                                                                     new HtmlFileTempDataCache(TEMP_FOLDER)
                                                                     );

            bacterioSearcher.DoSearch(sourceLines);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GoogleQueueProvider" /> class
 /// </summary>
 /// <param name="cloud">Google Cloud configuration</param>
 public GoogleQueueProvider(GoogleConfiguration cloud)
 {
     this.cloud              = cloud;
     this.SubscriptionName   = this.CreateSubscriptionIfNotExists();
     this.SubscriptionClient = SubscriberServiceApiClient.Create();
 }
 public SearchService(GoogleConfiguration configuration)
 {
     this.configuration = configuration;
 }
Example #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GoogleAuthMiddleware" /> class
 /// </summary>
 /// <param name="cloud">Google config</param>
 public GoogleAuthMiddleware(GoogleConfiguration cloud)
 {
     this.cloud = cloud;
 }
 public GoogleDistanceMatrixController(IOptions <GoogleConfiguration> googleConfigurationOption)
 {
     this.googleConfiguration = googleConfigurationOption.Value;
 }
Example #29
0
 /// <summary>
 /// Execute a dummy query to Google Calendar to spin it up.
 /// If an error occured, it is gracefully swallowed and logged.
 /// </summary>
 public void SpinUpGoogle(GoogleConfiguration config)
 {
     new GoogleService(config).SpinUp();
 }