예제 #1
0
        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;
        }
예제 #2
0
 public WindowsSource(IMetadataStore store, IPlacelessconfig configuration)
 {
     _metadataStore = store;
     _configuration = configuration;
     foreach (Enum enumValue in Enum.GetValues(typeof(FileAttributes)))
     {
         enums.Add(enumValue);
     }
     _fileTypes = _configuration.GetValues(EXTENSIONS_SETTING)
                  .Where(f => !(string.IsNullOrWhiteSpace(f)))
                  .ToList();
 }
예제 #3
0
        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
                },
            };
        }
예제 #4
0
        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();
            }
        }
예제 #5
0
 public FirstTimeWizard(IPlacelessconfig config)
 {
     InitializeComponent();
     _config = config;
 }
 public FileSystemBlobStore(IPlacelessconfig config)
 {
     _config = config;
     _root   = _config.GetValue(BLOB_ROOT_PATH);
 }
예제 #7
0
 public WindowsSettings(IPlacelessconfig config)
 {
     _config = config;
     InitializeComponent();
 }
 public ConnectionString(IPlacelessconfig config)
 {
     _config = config;
     InitializeComponent();
 }