public ProfileController(ILogger <HomeController> logger, LocalizationService localizationService, StatusService statusService, ProfileRepository profileRepository, ContentRepository contentRepository, AccountRepository accountRepository, FileStorageService fileStorageService, IHostingEnvironment environment, LocalizationRepository localizationRepository, ViewFieldsRepository viewFieldsRepository, ProfileService profileService, EmailService emailService, CityRepository cityRepository ) { _logger = logger; _localizationService = localizationService; _statusService = statusService; _profileRepository = profileRepository; _contentRepository = contentRepository; _accountRepository = accountRepository; _fileStorageService = fileStorageService; _localizationRepository = localizationRepository; _environment = environment; _viewFieldsRepository = viewFieldsRepository; _profileService = profileService; _emailService = emailService; _cityRepository = cityRepository; }
protected override void OnExit(ExitEventArgs e) { FileStorageService fileStorageService = new FileStorageService(); fileStorageService.Save(); base.OnExit(e); }
public void ListFilesOrDirectoriesTest() { FileStorageService service = new FileStorageService(_endPoint, _sasToken); var list = service.ListFilesOrDirectories(_shareFolder); Assert.AreEqual(true, list.Length > 0); }
private async Task WaitLongOperation(FileOperationWraper result, string assertError) { if (result != null && result.Finished) { Assert.That(result.Error == assertError, result.Error); return; } List <FileOperationResult> statuses; while (true) { statuses = FileStorageService.GetTasksStatuses(); if (statuses.TrueForAll(r => r.Finished)) { break; } await Task.Delay(100); } var error = string.Join(",", statuses.Select(r => r.Error)); Assert.That(error == assertError, error); }
public void Initialize( ) { try { DicomHelper = new DicomHelpers( ); DataAccessHelper = new DataAccessHelpers( ); var storagePath = DicomHelpers.GetTestDataFolder("storage", true); var mediaIdFactory = new DicomMediaIdFactory(); MediaStorageService storageService = new FileStorageService(storagePath); var factory = new Pacs.Commands.DCloudCommandFactory(storageService, DataAccessHelper.DataAccess, new DicomMediaWriterFactory(storageService, mediaIdFactory), mediaIdFactory); StoreService = new ObjectStoreService(factory); QueryService = new ObjectArchieveQueryService(DataAccessHelper.DataAccess); PopulateData( ); } catch (Exception) { Cleanup( ); throw; } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(); var config = new ServerConfig(); Configuration.Bind(config); var todoContext = new TodoContext(config.MongoDB); var repo = new TodoRepository(todoContext); services.AddSingleton <ITodoRepository>(repo); var fileContext = new StoredFileContext(config.MongoDB); var fileRepo = new StoredFileRepository(fileContext); var fileService = new FileStorageService(fileRepo); services.AddSingleton <IStoredFileRepository>(fileRepo); services.AddSingleton <IFileStorageService>(fileService); services.AddControllers(); services.AddMvc(); services.AddSwaggerGen(c => { c.SwaggerDoc(API_VERSION, new OpenApiInfo { Title = API_TITLE, Version = API_VERSION }); }); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); FileStorageService fileStorageService = new FileStorageService(); fileStorageService.Open(); }
async Task OnInputFileChange(InputFileChangeEventArgs e) { var path = Path.Combine(WebHostEnvironment.WebRootPath, imgPath); await FileStorageService.UploadFile(path, e.File); Institution.Logo = e.File.Name; }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest request, ILogger log) { Guid organisationId = Guid.Parse(request.Query["organisationId"]); Guid commissionStatementId = Guid.Parse(request.Query["commissionStatementId"]); Guid commissionStatementTemplateId = Guid.Parse(request.Query["commissionStatementTemplateId"]); var scope = new ScopeOptions(organisationId, Guid.Empty, Guid.Empty, Scope.Organisation); var statement = await CommissionStatementService.GetCommissionStatement(scope, commissionStatementId); if (statement == null) { return(new NotFoundObjectResult(commissionStatementId)); } var path = new CommissionStatementPath(scope.OrganisationId, commissionStatementId); var files = await FileStorageService.GetFilesAsync(path); if (!files.Any()) { return(Utils.GetBadRequestObject("Reimport failed as there are no existing statement files.", commissionStatementId.ToString())); } var queryOptions = new CommissionStatementTemplateQueryOptions("", "", 0, 0); queryOptions.CompanyId.Add(statement.CompanyId.Value); queryOptions.Date = statement.Date; var templates = (await CommissionStatementTemplateService.GetTemplates(queryOptions)).Items; if (!templates.Any(t => t.Id == commissionStatementTemplateId)) { return(Utils.GetBadRequestObject("Reimport failed as the commissionStatementTemplateId is not valid.", commissionStatementTemplateId.ToString())); } var template = await CommissionStatementTemplateService.GetTemplate(commissionStatementTemplateId); await CommissionStatementService.DeleteCommissions(scope, commissionStatementId); var result = new ImportResult(); foreach (var fileInfo in files) { using (var stream = new MemoryStream()) { await FileStorageService.GetFile(fileInfo.Url, stream); var vatRate = await DirectoryLookupService.GetVATRate(statement.Date ?? DateTime.Now); var reader = new CommissionImportReader(template.Config, vatRate); var items = reader.Read(stream); result = await CommissionImportService.ImportCommissions(scope, commissionStatementId, items); } } return(new OkObjectResult(result)); }
public CloudFile GetContent(string path, string fileName) { string coureseContentEndPoint = _settings.FileEndPoint; FileStorageService service = new FileStorageService(coureseContentEndPoint, _couserSASToken); var file = service.GetFile(path, fileName); return(file); }
public IEnumerable <EncryptionKeyPair> GetKeyPair <T>(T fileId, FileStorageService <T> FileStorageService) { var fileDao = DaoFactory.GetFileDao <T>(); fileDao.InvalidateCache(fileId); var file = fileDao.GetFile(fileId); if (file == null) { throw new System.IO.FileNotFoundException(FilesCommonResource.ErrorMassage_FileNotFound); } if (!FileSecurity.CanEdit(file)) { throw new System.Security.SecurityException(FilesCommonResource.ErrorMassage_SecurityException_EditFile); } if (file.RootFolderType != FolderType.Privacy) { throw new NotSupportedException(); } var fileShares = FileStorageService.GetSharedInfo(new List <T> { fileId }, new List <T> { }).ToList(); fileShares = fileShares.Where(share => !share.SubjectGroup && !share.SubjectId.Equals(FileConstant.ShareLinkId) && share.Share == FileShare.ReadWrite).ToList(); var fileKeysPair = fileShares.Select(share => { var fileKeyPairString = EncryptionLoginProvider.GetKeys(share.SubjectId); if (string.IsNullOrEmpty(fileKeyPairString)) { return(null); } var options = new JsonSerializerOptions { AllowTrailingCommas = true, PropertyNameCaseInsensitive = true }; var fileKeyPair = JsonSerializer.Deserialize <EncryptionKeyPair>(fileKeyPairString, options); if (fileKeyPair.UserId != share.SubjectId) { return(null); } fileKeyPair.PrivateKeyEnc = null; return(fileKeyPair); }) .Where(keyPair => keyPair != null); return(fileKeysPair); }
public FormFileManager() { InitializeComponent(); _fileStorageService = FileStorageService.Service; _storageFileSystem = _fileStorageService.FileSystem; _fileStorageDBPath = ConfigSpecificSettings.GetSettingsFolderPath(false); treeViewFolders.DrawMode = TreeViewDrawMode.OwnerDrawAll; treeViewFolders.DrawNode += treeViewFolders_DrawNode; }
public ScrapingService(DatabaseContext databaseContext, FileStorageService fileStorageService, IConfiguration configuration, ILogger <ScrapingService> logger) { _databaseContext = databaseContext; _fileStorageService = fileStorageService; _logger = logger; var foldersSection = configuration.GetSection("Folders"); _maxCapacityBytes = long.Parse(configuration["MaxCapacityBytes"]); }
public string ListFilesOrDirectories(string sharefolder) { string coureseContentEndPoint = _settings.FileEndPoint; FileStorageService service = new FileStorageService(coureseContentEndPoint, _couserSASToken); var list = service.ListFilesOrDirectories(sharefolder); string resultJson = service.ConvertToJson(list); return(resultJson); }
/// <summary> /// Initializes a new instance of the <see cref="MainFormLogicManager" /> class. /// </summary> /// <param name="memoStorageService">The memo storage service.</param> /// <param name="fileStorageService">The file storage service.</param> /// <param name="passwordStorage">The password storage.</param> /// <param name="scope">The scope.</param> /// <param name="appSettingsService">The application settings service.</param> public MainFormLogicManager(MemoStorageService memoStorageService, FileStorageService fileStorageService, PasswordStorage passwordStorage, ILifetimeScope scope, AppSettingsService appSettingsService) { _memoStorageService = memoStorageService; _fileStorageService = fileStorageService; _scope = scope; _appSettingsService = appSettingsService; _passwordStorage = passwordStorage; _tabPageDataCollection = TabPageDataCollection.CreateNewPageDataCollection(_appSettingsService.Settings.DefaultEmptyTabPages); }
/// <summary> /// Initializes a new instance of the <see cref="FilesController" /> class. /// </summary> /// <param name="index">The index.</param> /// <param name="storage">The storage.</param> public FilesController( FileSearchService index, FileStorageService storage, GenerateFilePreview generateFilePreview) { Index = index; Storage = storage; GenerateFilePreview = generateFilePreview; }
public void BuildUriForBlob_GivenValidFileName_ReturnValidUri() { string endpoint = UnitTestExtensions.TestUri.ToString(); string containerName = "testContainer"; string fileName = "testFile"; Uri uri = FileStorageService.BuildUriForBlob(endpoint, containerName, fileName); Assert.Equal("https://www.bing.com/testContainer/testFile.json", uri.ToString()); }
public void TestInit() { appSettings = new NameValueCollection(); connectionStrings = new ConnectionStringSettingsCollection(); settings = new AppSettings(appSettings, connectionStrings); blobStorageSettings = new BlobStorageSettings(settings); iBlobStorageSettings = new Mock <IBlobStorageSettings>(); service = new FileStorageService(settings, iBlobStorageSettings.Object); iService = new Mock <IFileStorageService>(); }
public static NodeEntryPoint StartWithOptions(NodeOptions options, Action <int> termination) { var slim = new ManualResetEventSlim(false); var list = String.Join(Environment.NewLine, options.GetPairs().Select(p => String.Format("{0} : {1}", p.Key, p.Value))); Log.Info(list); var bus = new InMemoryBus("OutputBus"); var controller = new NodeController(bus); var mainQueue = new QueuedHandler(controller, "Main Queue"); controller.SetMainQueue(mainQueue); Application.Start(i => { slim.Set(); termination(i); }); var http = new PlatformServerApiService(mainQueue, String.Format("http://{0}:{1}/", options.LocalHttpIp, options.HttpPort)); bus.Subscribe <SystemMessage.Init>(http); bus.Subscribe <SystemMessage.StartShutdown>(http); var timer = new TimerService(new ThreadBasedScheduler(new RealTimeProvider())); bus.Subscribe <TimerMessage.Schedule>(timer); // switch, based on configuration AzureStoreConfiguration azureConfig; if (AzureStoreConfiguration.TryParse(options.StoreLocation, out azureConfig)) { var storageService = new AzureStorageService(azureConfig, mainQueue); bus.Subscribe <ClientMessage.AppendEvents>(storageService); bus.Subscribe <SystemMessage.Init>(storageService); bus.Subscribe <ClientMessage.ImportEvents>(storageService); bus.Subscribe <ClientMessage.RequestStoreReset>(storageService); } else { var storageService = new FileStorageService(options.StoreLocation, mainQueue); bus.Subscribe <ClientMessage.AppendEvents>(storageService); bus.Subscribe <SystemMessage.Init>(storageService); bus.Subscribe <ClientMessage.ImportEvents>(storageService); bus.Subscribe <ClientMessage.RequestStoreReset>(storageService); } mainQueue.Start(); mainQueue.Enqueue(new SystemMessage.Init()); return(new NodeEntryPoint(mainQueue, slim)); }
public GfiController(IHostingEnvironment env, IOptions <GfiUploadOptions> options, UsersService usersService, FileStorageService fileStorageService, ILoggerFactory loggerFactory) { _env = env; _usersService = usersService; _gfiUploadOptions = options.Value; _fileStorageService = fileStorageService; _logger = loggerFactory.CreateLogger <GfiController>(); }
public static void Start(int port, string aet) { AETitle = aet; string storageConection = ConfigurationManager.AppSettings["app:PacsStorageConnection"]; if (storageConection.StartsWith("|datadirectory|", StringComparison.OrdinalIgnoreCase)) { var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); var lastIndex = storageConection.IndexOf('|', 1); var userPathPart = storageConection.Substring(lastIndex + 1); storageConection = appDataPath + userPathPart; } IDicomMediaIdFactory mediaIdFactory = new DicomMediaIdFactory(); DbSchemaProvider schemaProvider = new StorageDbSchemaProvider(); DatabaseService = new SqlDatabaseFactory(ConfigurationManager.AppSettings["app:PacsDataArchieve"]); IObjectArchieveDataAccess dataAccess = new ObjectArchieveDataAccess( schemaProvider, new ObjectArchieveDataAdapter( schemaProvider, DatabaseService ) ); IMediaStorageService storageService = new FileStorageService(storageConection); IDicomMediaWriterFactory dicomMediaWriterFactory = new DicomMediaWriterFactory( storageService, mediaIdFactory ); StorageService = new ObjectStoreService( new Pacs.Commands.DCloudCommandFactory( storageService, dataAccess, dicomMediaWriterFactory, mediaIdFactory ) ); QueryService = new ObjectArchieveQueryService(dataAccess); RetrieveService = new ObjectRetrieveService( storageService, dicomMediaWriterFactory, mediaIdFactory ); _server = DicomServer.Create <SCP>(port); }
/// <summary> /// </summary> /// <param name="context"></param> /// <param name="fileStorageService"></param> public FilesControllerHelper( ApiContext context, FileStorageService <T> fileStorageService, FileWrapperHelper fileWrapperHelper, FilesSettingsHelper filesSettingsHelper, FilesLinkUtility filesLinkUtility, FileUploader fileUploader, DocumentServiceHelper documentServiceHelper, TenantManager tenantManager, SecurityContext securityContext, FolderWrapperHelper folderWrapperHelper, FileOperationWraperHelper fileOperationWraperHelper, FileShareWrapperHelper fileShareWrapperHelper, FileShareParamsHelper fileShareParamsHelper, EntryManager entryManager, FolderContentWrapperHelper folderContentWrapperHelper, ChunkedUploadSessionHelper chunkedUploadSessionHelper, DocumentServiceTrackerHelper documentServiceTracker, IOptionsMonitor <ILog> optionMonitor, SettingsManager settingsManager, EncryptionKeyPairHelper encryptionKeyPairHelper, IHttpContextAccessor httpContextAccessor, FileConverter fileConverter, ApiDateTimeHelper apiDateTimeHelper, UserManager userManager, DisplayUserSettingsHelper displayUserSettingsHelper) { ApiContext = context; FileStorageService = fileStorageService; FileWrapperHelper = fileWrapperHelper; FilesSettingsHelper = filesSettingsHelper; FilesLinkUtility = filesLinkUtility; FileUploader = fileUploader; DocumentServiceHelper = documentServiceHelper; TenantManager = tenantManager; SecurityContext = securityContext; FolderWrapperHelper = folderWrapperHelper; FileOperationWraperHelper = fileOperationWraperHelper; FileShareWrapperHelper = fileShareWrapperHelper; FileShareParamsHelper = fileShareParamsHelper; EntryManager = entryManager; FolderContentWrapperHelper = folderContentWrapperHelper; ChunkedUploadSessionHelper = chunkedUploadSessionHelper; DocumentServiceTracker = documentServiceTracker; SettingsManager = settingsManager; EncryptionKeyPairHelper = encryptionKeyPairHelper; ApiDateTimeHelper = apiDateTimeHelper; UserManager = userManager; DisplayUserSettingsHelper = displayUserSettingsHelper; HttpContextAccessor = httpContextAccessor; FileConverter = fileConverter; Logger = optionMonitor.Get("ASC.Files"); }
public FactsBase() { _storePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N")); _options = new Mock <IOptionsSnapshot <FileSystemStorageOptions> >(); _options .Setup(o => o.Value) .Returns(() => new FileSystemStorageOptions { Path = _storePath }); _target = new FileStorageService(_options.Object); }
public byte[] GetGravatar(int memberId) { FileStorageService storage = new FileStorageService(); if (storage.FileExists(memberId.ToString())) { return(storage.ReadBytes(memberId.ToString())); } else { return(null); } }
public async Task GetDeserialized_MethodologyJson() { var blobStorageService = new Mock <IBlobStorageService>(); blobStorageService .Setup(s => s.DownloadBlobText(PublicContentContainerName, "test-path")) .ReturnsAsync(SampleContentJson.MethodologyJson); var fileStorageService = new FileStorageService(blobStorageService.Object); var result = await fileStorageService.GetDeserialized <MethodologyViewModel>("test-path"); Assert.True(result.IsRight); }
public async Task GetDeserialized_NotFound() { var blobStorageService = new Mock <IBlobStorageService>(); blobStorageService .Setup(s => s.GetDeserializedJson <TestModel>(PublicContent, "test-path")) .ThrowsAsync(new FileNotFoundException("Blob not found")); var fileStorageService = new FileStorageService(blobStorageService.Object); var result = await fileStorageService.GetDeserialized <TestModel>("test-path"); result.AssertNotFound(); }
public void DeleteFile(int file) { FilesControllerHelper.DeleteFile(file, false, true); while (true) { var statuses = FileStorageService.GetTasksStatuses(); if (statuses.TrueForAll(r => r.Finished)) { break; } Thread.Sleep(100); } }
/* * Currently used for testing, but it could be used for loading a previously taken picture * In that case replace the hardcoded url with something you saved in the playerprefs */ public void LoadPicture() { string url = Application.persistentDataPath + "/" + "test.jpg"; var bytes = FileStorageService.ReadFile(url); if (bytes != null) { OnPictureTaken(bytes); } else { Debug.LogWarning("Picture not found: " + url); } }
public void Get_Success() { var meh = new FileStorageService<TestObject>(); var testObject = new TestObject { Title = "This is a test title", Description = "This is a test description" }; meh.Set(testObject); var result = meh.Get(); Assert.AreEqual(result.Title, testObject.Title); Assert.AreEqual(result.Description, testObject.Description); }
public void DeleteFolderReturnsFolderWrapper(bool deleteAfter, bool immediately) { FilesControllerHelper.DeleteFolder(TestFolder.Id, deleteAfter, immediately); while (true) { var statuses = FileStorageService.GetTasksStatuses(); if (statuses.TrueForAll(r => r.Finished)) { break; } Thread.Sleep(100); } Assert.IsTrue(FileStorageService.GetTasksStatuses().TrueForAll(r => string.IsNullOrEmpty(r.Error))); }
public void OneTimeSetup() { var config = new ApplyConfig { FileStorage = new FileStorageConfig { StorageConnectionString = _fileStorageConnectionString, AssessorContainerName = _fileStorageContainerName } }; var _configurationService = new Mock <IConfigurationService>(); _configurationService.Setup(x => x.GetConfig()).ReturnsAsync(config); var logger = Mock.Of <ILogger <FileStorageService> >(); _fileStorageService = new FileStorageService(logger, _configurationService.Object); }
public static NodeEntryPoint StartWithOptions(NodeOptions options, Action<int> termination) { var slim = new ManualResetEventSlim(false); var list = String.Join(Environment.NewLine, options.GetPairs().Select(p => String.Format("{0} : {1}", p.Key, p.Value))); Log.Info(list); var bus = new InMemoryBus("OutputBus"); var controller = new NodeController(bus); var mainQueue = new QueuedHandler(controller, "Main Queue"); controller.SetMainQueue(mainQueue); Application.Start(i => { slim.Set(); termination(i); }); var http = new PlatformServerApiService(mainQueue, String.Format("http://{0}:{1}/", options.LocalHttpIp, options.HttpPort)); bus.Subscribe<SystemMessage.Init>(http); bus.Subscribe<SystemMessage.StartShutdown>(http); var timer = new TimerService(new ThreadBasedScheduler(new RealTimeProvider())); bus.Subscribe<TimerMessage.Schedule>(timer); // switch, based on configuration AzureStoreConfiguration azureConfig; if (AzureStoreConfiguration.TryParse(options.StoreLocation, out azureConfig)) { var storageService = new AzureStorageService(azureConfig, mainQueue); bus.Subscribe<ClientMessage.AppendEvents>(storageService); bus.Subscribe<SystemMessage.Init>(storageService); bus.Subscribe<ClientMessage.ImportEvents>(storageService); bus.Subscribe<ClientMessage.RequestStoreReset>(storageService); } else { var storageService = new FileStorageService(options.StoreLocation, mainQueue); bus.Subscribe<ClientMessage.AppendEvents>(storageService); bus.Subscribe<SystemMessage.Init>(storageService); bus.Subscribe<ClientMessage.ImportEvents>(storageService); bus.Subscribe<ClientMessage.RequestStoreReset>(storageService); } mainQueue.Start(); mainQueue.Enqueue(new SystemMessage.Init()); return new NodeEntryPoint(mainQueue,slim); }