public SimpleDocumentExecutor(IStorageClient storageClient, IDocumentRecognizer recognizer, IEnumerable<IResultsConverter> resultConverters) { if (storageClient == null) throw new ArgumentNullException("storageClient"); if (recognizer == null) throw new ArgumentNullException("recognizer"); StorageClient = storageClient; Recognizer = recognizer; ResultConverters = resultConverters; }
public DocumentManager(Guid userId, IStorageClient storageClient, IDocumentExecutor documentExecutor) { if (storageClient == null) throw new ArgumentNullException("storageClient"); if (documentExecutor == null) throw new ArgumentNullException("documentExecutor"); UserId = userId; StorageClient = storageClient; DocumentExecutor = documentExecutor; }
public static void SaveImagesToDatabase(Data.Guid siteGuid, IStorageClient client, String container, String folder, IList<StorageFile> images, IList<StorageFile> results) { CmsImageDao dao = new CmsImageDao(); using (Transaction tx = new Transaction()) { foreach (StorageFile file in images) { StorageFile actualFile; if (results != null) actualFile = client.GetInfo(container, folder, file.Filename); else actualFile = file; if (actualFile.Exists()) { CmsImage temp = dao.FindByUrl(actualFile.Url); if (temp == null) { FileInfo info = new FileInfo(actualFile.Filename); String mimetype = "image/png"; if (ImageMimeTypes.ContainsKey(info.Extension)) mimetype = ImageMimeTypes[info.Extension]; temp = new CmsImage(); temp.CloudUrl = actualFile.Url; temp.ContentType = mimetype; temp.Created = UtcDateTime.Now; temp.Directory = folder; temp.Filename = actualFile.Filename; temp.Guid = System.Guid.NewGuid().ToString(); temp.SubscriptionId = siteGuid.Value; temp.Length = actualFile.Size; dao.Save<CmsImage>(temp); } if (results != null) results.Add(actualFile); } } tx.Commit(); } }
//for external use only public void LoginAndEnumFiles(StorageType storageType) { if (IsBusy() || storageType==StorageType.Undefined) return; progressInfo.Visibility = Visibility.Visible; Entries.Clear(); // need to clear here for the case if authentication throws exception Action worker = () => { try { switch (storageType) { case StorageType.Dropbox: _storage = new DropStorage(webViewCallback); _navState.Reset("Dropbox"); break; case StorageType.GDrive: _storage = new GDriveStorage(webViewCallback); _navState.Reset("Google Drive"); break; default: throw new NotSupportedException(); } NavigateTo(_storage.RootFolder(), null, NavigationDirection.LevelDown, true); } catch (Exception e) { downloadProgress.Visibility = Visibility.Collapsed; MessageDlg.Show("Authentication error. Please try to connect again: \n" + e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { progressInfo.Visibility = Visibility.Collapsed; } }; this.Dispatcher.BeginInvoke(worker, DispatcherPriority.Background); }
public FaceApiController(IStorageClient storageClient, FaceApiClient faceApi, IMDbRepository repository) { this.storageClient = storageClient; this.faceApi = faceApi; this.repository = repository; }
public ChappHub(IStorageClient storageClient) { _storage = storageClient; }
public Worker(IStorageClient client, ILogger <Worker> logger) { _client = client; _logger = logger; }
public StorageContainersRepositoryBuilder WithStorageClient(IStorageClient <StorageContainer> storageClient) { StorageClient = storageClient; return(this); }
public async Task BeginJobModule(IStorageClient storageClient) { _storageClient = storageClient; _thousandsLists = new Dictionary <string, ThousandsList>(); // Get every file name in the main directory object lockObject = new object(); string[] allFileNames = _storageClient.GetAllFileNames(); Parallel.ForEach(allFileNames, async fileName => { string text = (await _storageClient.GetFileContents(fileName, FileType.Json)).Trim(); if (String.IsNullOrEmpty(text)) { return; } NYTQuery movies = null; try { movies = JsonConvert.DeserializeObject <NYTQuery>(text); } catch { } // Just continue for now if (movies == null || movies.results == null || movies.results.Count == 0) { return; } foreach (var movie in movies.results) { int yesNo; if (!int.TryParse(movie.thousand_best, out yesNo)) { continue; } DateTime date; if (!DateTime.TryParse(movie.publication_date, out date)) { continue; } string key = Convert.ToString(date.Date.Year); lock (lockObject) { if (!_thousandsLists.ContainsKey(key)) { _thousandsLists.Add(key, new ThousandsList { Yes = new Yes { Count = 0 }, No = new No { Count = 0 } }); } switch (yesNo) { case 0: _thousandsLists[key].No.Count++; break; case 1: _thousandsLists[key].Yes.Count++; break; } } } }); string json = JsonConvert.SerializeObject(_thousandsLists, Formatting.Indented); await _storageClient.WriteFileToStorageAsync(json, "thousands_list", FileType.Json, true); }
public GooglePageFetcherSequenceResolver(IStorageClient storageClient) { _storageClient = storageClient; }
public ArticleStorageService(IStorageClient storageClient) { _storageClient = storageClient; }
public async Task BeginJobModule(IStorageClient storageClient) { _storageClient = storageClient; _mpaaList = new Dictionary <string, MPAA>(); // Get every file name in the main directory object lockObject = new object(); string[] allFileNames = _storageClient.GetAllFileNames(); Parallel.ForEach(allFileNames, async fileName => { string text = (await _storageClient.GetFileContents(fileName, FileType.Json)).Trim(); if (String.IsNullOrEmpty(text)) { return; } NYTQuery movies = null; try { movies = JsonConvert.DeserializeObject <NYTQuery>(text); } catch { } // Just continue for now if (movies == null || movies.results == null || movies.results.Count == 0) { return; } foreach (var movie in movies.results) { DateTime date; if (!DateTime.TryParse(movie.publication_date, out date)) { continue; } string key = Convert.ToString(date.Date.Year); lock (lockObject) { if (!_mpaaList.ContainsKey(key)) { _mpaaList.Add(key, new MPAA { G = new G { Count = 0 }, PG = new PG { Count = 0 }, PG13 = new PG13 { Count = 0 }, R = new R { Count = 0 }, None = new None { Count = 0 } }); } switch (movie.mpaa_rating) { case "G": _mpaaList[key].G.Count++; break; case "PG": _mpaaList[key].PG.Count++; break; case "PG13": _mpaaList[key].PG13.Count++; break; case "R": _mpaaList[key].R.Count++; break; default: _mpaaList[key].None.Count++; break; } } } }); string json = JsonConvert.SerializeObject(_mpaaList, Formatting.Indented); await _storageClient.WriteFileToStorageAsync(json, "mpaa_analyzer", FileType.Json, true); }
public DeviceQueryCache(IStorageClient storage, IAppConfigurationClient tenantConfig, ILogger <IDeviceQueryCache> log) { this.storage = storage; this.tenantConfig = tenantConfig; this.log = log; }
public OperationProvider(IStorageClient storageClient, ICache cache) { _storageClient = storageClient; _cache = cache; }
public AsyncProgressReporter(IStorageClient storage, DocumentIdentifier documentId) { this.storage = storage; this.documentId = documentId; }
public AzureScanWorker(IStorageClient storage, IDocumentExecutor documentExecutor, CloudStorageAccount account) { this.storage = storage; this.documentExecutor = documentExecutor; queue = new SingleDeliveryQueueClient(account, "documents"); }
/// <summary> /// Initializes a new instance of the <see cref="FiguresStorage"/> class. /// </summary> /// <param name="storageClient">Клиент хранилища. реализация IStorageClient, должна быть зарегистрирована в DI.</param> public FiguresStorage(IStorageClient storageClient) { this.storageClient = storageClient; }
public UserStorage(IStorageClient storageClient) { _storageClient = storageClient; }
public OperationStorage(IStorageClient storageClient) { _storageClient = storageClient; }
public SubmissionManager(IStorageClient storage = null, IGitHubClient gitHub = null) { _gitHub = gitHub ?? new GitHubClient(); _storage = storage ?? new StorageClient(); }
public void StartModule <TStorage>(string directory) where TStorage : IStorageClient { // Rotten Tomatoes does not support querying by date, so query by alphabetical letter for now... char[] allLetters = new char[26]; char letterChar = 'A'; for (int i = 0; i < 26; i++) { allLetters[i] = letterChar; letterChar++; } HttpClient httpClient = new HttpClient { BaseAddress = new Uri(BaseAddress) }; httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); IStorageClient storageClient = (IStorageClient)Activator.CreateInstance(typeof(TStorage), new object[] { directory }); HttpClient closureSafeHttpClient = httpClient; IStorageClient closureSafeStorageClient = storageClient; Parallel.ForEach(allLetters, async letter => { Task <HttpResponseMessage> queryResponse; try { queryResponse = closureSafeHttpClient.GetAsync( string.Format("api/public/v1.0/movies.json?apikey={0}&q={1}", APIKey, letter)); queryResponse.Wait(); } catch { return; } // Do nothing for now if (!queryResponse.Result.IsSuccessStatusCode) { return; } RTQuery rtQuery; try { string content = await queryResponse.Result.Content.ReadAsStringAsync(); rtQuery = JsonConvert.DeserializeObject <RTQuery>(content.Trim()); } catch { return; } // Do nothing for now if (rtQuery == null || rtQuery.Movies == null || rtQuery.Movies.Count <= 0) { return; } foreach (var movie in rtQuery.Movies) { Task <HttpResponseMessage> innerQueryResponse; try { innerQueryResponse = closureSafeHttpClient.GetAsync( string.Format("api/public/v1.0/movies/{0}.json?apikey={1}", movie.id, APIKey)); innerQueryResponse.Wait(); } catch { return; } if (!innerQueryResponse.Result.IsSuccessStatusCode) { continue; } Task <string> innerContent = innerQueryResponse.Result.Content.ReadAsStringAsync(); innerContent.Wait(); try { Task <bool> writeTask = closureSafeStorageClient.WriteFileToStorageAsync(innerContent.Result.Trim(), movie.title, FileType.Json); writeTask.Wait(); } catch { return; } } }); httpClient.Dispose(); storageClient.Dispose(); }
public ETrackerStorageClient(IStorageClient storageClient) { _storageClient = storageClient; }
// TODO: Improve this /// <summary> /// Returns a BinaryReader instance for reading using an IStorageClient. /// </summary> /// <param name="fileUri">URI of the resource to read.</param> /// <param name="outputStream">Stream to read data into.</param> /// <param name="storageClient">IStorageClient implementation to use when reading from the source data store.</param> /// <param name="storageConnectionString">Connection string to the source data store.</param> /// <param name="storageContainerName">The name of the container containing the file to read.</param> /// <param name="log">Trace logger instance.</param> /// <returns>A BinaryReader instance.</returns> public static BinaryReader GetBinaryReader(string fileUri, Stream outputStream, IStorageClient storageClient, Secret storageConnectionString, string storageContainerName, ILogger log) { storageClient.ReadToStreamAsync(outputStream, storageConnectionString, storageContainerName, fileUri).Wait(); outputStream.Seek(0, SeekOrigin.Begin); return(new BinaryReader(outputStream)); }