public FlickrSource(IMetadataStore store, IPlacelessconfig configuration, IUserInteraction userInteraction) { _metadataStore = store; _configuration = configuration; _userInteraction = userInteraction; _flickr = new FlickrNet.Flickr(API_KEY, API_SECRET); _flickr.InstanceCacheDisabled = true; var token = _configuration.GetValue(TOKEN_PATH); var secret = _configuration.GetValue(SECRET_PATH); token = ""; secret = ""; if (string.IsNullOrWhiteSpace(token) || string.IsNullOrWhiteSpace(secret)) { var requestToken = _flickr.OAuthGetRequestToken("oob"); string url = _flickr.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Write); _userInteraction.OpenWebPage(url); string approvalCode = _userInteraction.InputPrompt("Please approve access to your Flickr account and enter the key here:"); var accessToken = _flickr.OAuthGetAccessToken(requestToken, approvalCode); token = accessToken.Token; secret = accessToken.TokenSecret; _configuration.SetValue(TOKEN_PATH, token); _configuration.SetValue(SECRET_PATH, secret); } _flickr.OAuthAccessToken = token; _flickr.OAuthAccessTokenSecret = secret; }
private void Window_Loaded(object sender, RoutedEventArgs e) { string connectionString = _config.GetValue(SqlMetadataStore.CONNECTION_STRING_SETTING); var builder = new SqlConnectionStringBuilder(connectionString); cboDatabase.Text = builder.InitialCatalog; txtUserName.Text = builder.UserID; txtServerName.Text = builder.DataSource; cboAuthenticationMethod.Text = builder.IntegratedSecurity ? "Windows Authentication" : "SQL Server Authentication"; txtFileStorage.Text = _config.GetValue(FileSystemBlobStore.BLOB_ROOT_PATH); EnableDisable(); }
public MainWindow() { _servicecollection = new ServiceCollection(); _config = new SettingsBasedConfig(); _servicecollection.AddSingleton <IUserInteraction>(this); _servicecollection.AddSingleton <IPlacelessconfig>(_config); _servicecollection.AddTransient <IBlobStore, FileSystemBlobStore>(); _servicecollection.AddTransient <IMetadataStore, SqlMetadataStore>(); _servicecollection.AddTransient <FlickrSource>(); _servicecollection.AddTransient <WindowsSource>(); _servicecollection.AddTransient <Placeless.Generator.Generator>(); _servicecollection.AddTransient <Collector <FlickrSource> >(); _servicecollection.AddTransient <Collector <WindowsSource> >(); _serviceProvider = _servicecollection.BuildServiceProvider(); Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; InitializeComponent(); if (string.IsNullOrWhiteSpace(_config.GetValue(SqlMetadataStore.CONNECTION_STRING_SETTING))) { var wizard = new FirstTimeWizard(_config); wizard.ShowDialog(); } ProgressGroups = new ProgressReportGroup[] { new ProgressReportGroup { Category = progressCategory0, ProgressBar = progressBar0, ProgressBarText = progressBarText0 }, new ProgressReportGroup { Category = progressCategory1, ProgressBar = progressBar1, ProgressBarText = progressBarText1 }, new ProgressReportGroup { Category = progressCategory2, ProgressBar = progressBar2, ProgressBarText = progressBarText2 }, new ProgressReportGroup { Category = progressCategory3, ProgressBar = progressBar3, ProgressBarText = progressBarText3 }, new ProgressReportGroup { Category = progressCategory4, ProgressBar = progressBar4, ProgressBarText = progressBarText4 }, new ProgressReportGroup { Category = progressCategory5, ProgressBar = progressBar5, ProgressBarText = progressBarText5 }, }; }
public SqlMetadataStore(IPlacelessconfig configuration, IUserInteraction userInteraction, IBlobStore blobStore) { _configuration = configuration; _userInteraction = userInteraction; _blobStore = blobStore; if (string.IsNullOrWhiteSpace(_configuration.GetValue(CONNECTION_STRING_SETTING))) { _userInteraction.ReportError($"Missing expected configuration value: {CONNECTION_STRING_SETTING}"); } _dbContextOptions = SqlServerDbContextOptionsExtensions.UseSqlServer( new DbContextOptionsBuilder(), _configuration.GetValue(CONNECTION_STRING_SETTING), options => options.CommandTimeout(120) ).Options; using (var dbContext = new ApplicationDbContext(_dbContextOptions)) { dbContext.Database.Migrate(); } }
public FileSystemBlobStore(IPlacelessconfig config) { _config = config; _root = _config.GetValue(BLOB_ROOT_PATH); }