public void Update_WithNonExistingModel_ShouldThrowError() { SetUp(); var storage = new StorageOption(); Assert.ThrowsAny <Exception>(() => _storageOptionService.Update(storage)); }
//Default DataManagement public DataManagement() { _StringsDictionary = new Dictionary <string, string>(); _BoolsDictionary = new Dictionary <string, bool>(); _IntsDictionary = new Dictionary <string, int>(); _FloatsDictionary = new Dictionary <string, float>(); _storageOption = StorageOption.Persisted; }
public void InsertStorageOption_WithValidModel_ShouldBeInserted() { SetUp(); var sorageOption = new StorageOption(); _storageOptionService.InsertStorageOption(sorageOption); Assert.Equal(sorageOption, _context.StorageOptions.First()); }
protected override ICache CreateCache( DisposableDirectory testDirectory, string cacheNamespace, IAbsFileSystem fileSystem, ILogger logger, BackingOption backingOption, StorageOption storageOption, TimeSpan?expiryMinimum = null, TimeSpan?expiryRange = null) { var innerCache = base.CreateCache(testDirectory, cacheNamespace, fileSystem, logger, backingOption, storageOption, expiryMinimum, expiryRange); return(TestDistributedCacheFactory.CreateCache( logger, innerCache, cacheNamespace, nameof(DistributedWriteNeverBuildCacheSimulationTests), ReadThroughMode.None)); }
private List <StorageOption> GetStorageOptions() { StorageOption testStorageOptionOne = new StorageOption() { Model = "model1" }; StorageOption testStorageOptionTwo = new StorageOption() { Model = "model2" }; return(new List <StorageOption> { testStorageOptionOne, testStorageOptionTwo }); }
private ICache CreateBareBuildCache( DisposableDirectory testDirectory, string cacheNamespace, IAbsFileSystem fileSystem, ILogger logger, BackingOption backingOption, StorageOption storageOption, TimeSpan?expiryMinimum = null, TimeSpan?expiryRange = null) { var vssCredentialsFactory = new VssCredentialsFactory(new VsoCredentialHelper()); IBuildCacheHttpClientFactory buildCacheHttpClientFactory = new BuildCacheHttpClientFactory(new Uri(@"http://*****:*****@"http://localhost:22084"), vssCredentialsFactory, TimeSpan.FromMinutes(BuildCacheServiceConfiguration.DefaultHttpSendTimeoutMinutes), WellKnownDomainIds.OriginalDomainId, false); // Using a consistent path in the test directory allows tests to share content between // multiple callers. Using FileSystemContentStore *will* require the callers to be serialized // because of its need for exclusive access (and the DirectoryLock enforcing it). var writeThroughContentStoreFunc = backingOption == BackingOption.WriteThrough ? (Func <IContentStore>)null : () => new FileSystemContentStore( fileSystem, SystemClock.Instance, testDirectory.Path / "_writeThroughStore", new ConfigurationModel(new ContentStoreConfiguration(new MaxSizeQuota("100MB")))); return(new BuildCacheCache( fileSystem, cacheNamespace, buildCacheHttpClientFactory, backingContentStoreHttpClientFactory, BuildCacheServiceConfiguration.DefaultMaxFingerprintSelectorsToFetch, TimeSpan.FromDays(BuildCacheServiceConfiguration.DefaultDaysToKeepUnreferencedContent), TimeSpan.FromMinutes(BuildCacheServiceConfiguration.DefaultPinInlineThresholdMinutes), TimeSpan.FromMinutes(BuildCacheServiceConfiguration.DefaultIgnorePinThresholdHours), expiryMinimum.GetValueOrDefault(TimeSpan.FromDays(BuildCacheServiceConfiguration.DefaultDaysToKeepContentBags)), expiryRange.GetValueOrDefault(TimeSpan.FromDays(BuildCacheServiceConfiguration.DefaultRangeOfDaysToKeepContentBags)), logger, true, 5, 20, new ByteDomainId(BuildCacheServiceConfiguration.DefaultDomainId), forceUpdateOnAddContentHashList: false, writeThroughContentStoreFunc, backingOption == BackingOption.WriteBehind, storageOption == StorageOption.Blob)); }
public DataTable SortBasedOn(StorageOption StoOp, DateTime start, DateTime end) { DataView dv_Period = DS_QAllClients.Tables[0].DefaultView; if (start <= end) { dv_Period.RowFilter = string.Format("pStoragePeriod >= '#{0}#' AND pStoragePeriod <= '#{1}#' AND pOption like '%{2}%' ", start.ToString(), end.ToString(), StoOp.ToString()); } else if (end <= start) { dv_Period.RowFilter = string.Format("pStoragePeriod >= '#{0}#' AND pStoragePeriod <= '#{1}#' AND pOption like '%{2}%' ", end.ToString(), start.ToString(), StoOp.ToString()); } DataTable DT = dv_Period.ToTable(); return(DT); }
private ICache CreateCache( DisposableDirectory testDirectory, string cacheNamespace, IAbsFileSystem fileSystem, ILogger logger, BackingOption backingOption, StorageOption storageOption, TimeSpan?expiryMinimum, TimeSpan?expiryRange, ReadThroughMode readThroughMode) { var innerCache = base.CreateCache(testDirectory, cacheNamespace, fileSystem, logger, backingOption, storageOption, expiryMinimum, expiryRange); return(TestDistributedCacheFactory.CreateCache( logger, innerCache, cacheNamespace, nameof(ReadThroughDistributedWriteBehindBuildCacheSimulationTests), readThroughMode)); }
public IActionResult Create([Bind("StorageId,Model,Manufacturer,Price,Type,Capacity")] StorageOption storageOption) { if (ModelState.IsValid) { var image = Request.Form.Files.GetFile("image"); if (image != null) { storageOption.ImgUrl = _driveService.UploadFile(image); } else { storageOption.ImgUrl = Constants.DEFAULT_STORAGE_IMG; } _service.InsertStorageOption(storageOption); return(RedirectToAction(nameof(Index))); } return(View(storageOption)); }
public IActionResult Edit(int id, [Bind("StorageId,Model,Manufacturer,Price,Type,Capacity")] StorageOption storageOption) { if (id != storageOption.StorageOptionId) { return(NotFound()); } if (ModelState.IsValid) { var image = Request.Form.Files.GetFile("image"); if (image != null) { _driveService.DeleteFile(Request.Form["ImgUrl"]); storageOption.ImgUrl = _driveService.UploadFile(image); } _service.Update(storageOption); return(RedirectToAction(nameof(Index))); } return(View(storageOption)); }
protected override ICache CreateCache( DisposableDirectory testDirectory, string cacheNamespace, IAbsFileSystem fileSystem, ILogger logger, BackingOption backingOption, StorageOption storageOption, TimeSpan?expiryMinimum = null, TimeSpan?expiryRange = null) { return(CreateCache( testDirectory, cacheNamespace, fileSystem, logger, backingOption, storageOption, expiryMinimum, expiryRange, readThroughMode: ReadThroughMode.ReadThrough)); }
/// <summary> /// /// </summary> /// <returns></returns> /// <remarks> /// https://docs.microsoft.com/ja-jp/azure/storage/storage-dotnet-how-to-use-blobs#a-namelist-blobs-in-pages-asynchronouslyablob-%E3%82%92%E3%83%9A%E3%83%BC%E3%82%B8%E3%81%A7%E9%9D%9E%E5%90%8C%E6%9C%9F%E3%81%AB%E4%B8%80%E8%A6%A7%E8%A1%A8%E7%A4%BA%E3%81%99%E3%82%8B /// </remarks> public static async Task <List <Blob> > Get(StorageOption storage) { StorageCredentials cred = new StorageCredentials(storage.Account, storage.Key); // Retrieve storage account from connection string. CloudStorageAccount storageAccount = new CloudStorageAccount(cred, true); // Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve reference to a previously created container. CloudBlobContainer container = blobClient.GetContainerReference("mlb"); BlobContinuationToken continuationToken = null; BlobResultSegment resultSegment = null; List <Blob> blobs = new List <Blob>(); //Call ListBlobsSegmentedAsync and enumerate the result segment returned, while the continuation token is non-null. //When the continuation token is null, the last page has been returned and execution can exit the loop. do { //This overload allows control of the page size. You can return all remaining results by passing null for the maxResults parameter, //or by calling a different overload. resultSegment = await container.ListBlobsSegmentedAsync("", true, BlobListingDetails.All, 10, continuationToken, null, null); foreach (CloudBlockBlob blobItem in resultSegment.Results) { blobs.Add(new Blob { Name = blobItem.Name, Uri = blobItem.Uri, }); } //Get the continuation token. continuationToken = resultSegment.ContinuationToken; }while (continuationToken != null); return(blobs); }
public Word GetWords(StorageOption storageOption) { Word result; switch (storageOption) { case StorageOption.File: result = _wordRepo.GetFromFile(); break; case StorageOption.Db: result = _wordRepo.GetFromDb(); break; default: throw new Exception("Error"); } CalculateNumberOfWords(result); return(result); }
private IRepository <TData> Resolve <TData>(StorageOption storage, IValidator <TData> validator) { if (typeof(TData) == typeof(Person)) { var personValidator = validator as IValidator <Person>; switch (storage) { case StorageOption.Memory: return(new MemoryPersonRepository(personValidator) as IRepository <TData>); case StorageOption.Filesystem: return(new FilesystemPersonRepository(personValidator) as IRepository <TData>); case StorageOption.RelationalDatabase: return(new DbPersonRepository(personValidator) as IRepository <TData>); default: throw new ArgumentException($"No implementation available for storage option {storage}", nameof(storage)); } } throw new ArgumentException($"There is no Repository available for {typeof(TData)}", nameof(TData)); }
private void SortDataFromExcelForStudent(object[] StudentInfo_ExcelRow) { Parent addedStudent = new Parent(); DAL Data = new DAL(); try { DateTime strSubmittedTime = (DateTime)StudentInfo_ExcelRow[0]; string strName = (string)StudentInfo_ExcelRow[1]; string strSurName = (string)StudentInfo_ExcelRow[2]; string strGuardianNumber = StudentInfo_ExcelRow[3].ToString(); string stringNumTrunks = (string)StudentInfo_ExcelRow[4]; string strStorageOption = (string)StudentInfo_ExcelRow[5]; string strPaymentMethod = (string)StudentInfo_ExcelRow[6]; string strHouse = (string)StudentInfo_ExcelRow[7]; string strNumber = StudentInfo_ExcelRow[8].ToString(); string strEmail = (string)StudentInfo_ExcelRow[9]; // sorted date time if (strSubmittedTime.Month <= 4) { DateTime SubmitedTime = new DateTime(strSubmittedTime.Year, 4, 1); addedStudent.StoragePeriod = SubmitedTime; } else if (strSubmittedTime.Month <= 8) { DateTime SubmitedTime = new DateTime(strSubmittedTime.Year, 8, 1); addedStudent.StoragePeriod = SubmitedTime; } else if (strSubmittedTime.Month <= 12) { DateTime SubmitedTime = new DateTime(strSubmittedTime.Year, 12, 1); addedStudent.StoragePeriod = SubmitedTime; } //Name check for & if (strName.Contains("&")) { strName = strName.Replace(" ", ""); int index = strName.IndexOf("&"); string FirtPerson = strName.Remove(index); string ExtraPerson = strName.Remove(0, index + 1); object[] NewPerson = { strSubmittedTime, ExtraPerson, strSurName, strGuardianNumber, stringNumTrunks, strStorageOption, strPaymentMethod, strHouse, strNumber, strEmail }; SortDataFromExcelForStudent(NewPerson); addedStudent.Name = FirtPerson; } else { addedStudent.Name = strName; } //Number of trunks stringNumTrunks = stringNumTrunks.Remove(1);// removing any excess information int NumTrunks = Convert.ToInt32(stringNumTrunks); //stroage option convertion strStorageOption = strStorageOption.ToLower(); if (strStorageOption.Contains("washing")) { StorageOption StorageOpt = StorageOption.StorageAndWashing; addedStudent.Option = StorageOpt; } else if (strStorageOption.Contains("only")) { StorageOption StorageOpt = StorageOption.Storage; addedStudent.Option = StorageOpt; } //payment Method strPaymentMethod = strPaymentMethod.ToLower(); if (strPaymentMethod.Contains("cash")) { MethodOfPayment PaymentMethod = MethodOfPayment.Cash; addedStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("eco")) { MethodOfPayment PaymentMethod = MethodOfPayment.EcoCash; addedStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("student")) { MethodOfPayment PaymentMethod = MethodOfPayment.StudentAccount; addedStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("bank")) { MethodOfPayment PaymentMethod = MethodOfPayment.BankTransfer; addedStudent.MethodOfPayment = PaymentMethod; } //student house strHouse = strHouse.ToLower(); if (strHouse.Contains("founders")) { FalconCollegeHouse House = FalconCollegeHouse.Founders; addedStudent.House = House; } else if (strHouse.Contains("george")) { FalconCollegeHouse House = FalconCollegeHouse.GeorgeGrey; addedStudent.House = House; } else if (strHouse.Contains("hervey")) { FalconCollegeHouse House = FalconCollegeHouse.Hervey; addedStudent.House = House; } else if (strHouse.Contains("oates")) { FalconCollegeHouse House = FalconCollegeHouse.Oates; addedStudent.House = House; } else if (strHouse.Contains("tredgold")) { FalconCollegeHouse House = FalconCollegeHouse.Tredgold; addedStudent.House = House; } else if (strHouse.Contains("chubb")) { FalconCollegeHouse House = FalconCollegeHouse.Chubb; addedStudent.House = House; } addedStudent.Email = strEmail; addedStudent.Trunks = NumTrunks; addedStudent.Number = strNumber; addedStudent.GaurdianNumber = strGuardianNumber; addedStudent.Surname = strSurName; } catch (Exception ex) { string caption = "Error Adding Student"; MessageBoxButtons Button = MessageBoxButtons.OK; MessageBoxIcon icon = MessageBoxIcon.Error; MessageBox.Show(ex.Message, caption, Button, icon); } Data.QInsertStudent(addedStudent); }
protected virtual ICache CreateCache( DisposableDirectory testDirectory, string cacheNamespace, IAbsFileSystem fileSystem, ILogger logger, BackingOption backingOption, StorageOption storageOption, TimeSpan?expiryMinimum = null, TimeSpan?expiryRange = null) { return(CreateBareBuildCache(testDirectory, cacheNamespace, fileSystem, logger, backingOption, storageOption, expiryMinimum, expiryRange)); }
protected BuildCacheSimulationTests(ILogger logger, BackingOption backingOption, StorageOption itemStorageOption) : base(() => new PassThroughFileSystem(logger), logger) { _backingOption = backingOption; ItemStorageOption = itemStorageOption; }
protected WriteThroughBuildCacheSimulationTests(StorageOption storageOption) : base(TestGlobal.Logger, BackingOption.WriteThrough, storageOption) { }
public BlobsController(IOptions <StorageOption> _storage) { storage = _storage.Value; }
protected DistributedWriteNeverBuildCacheSimulationTests(StorageOption storageOption) : base(storageOption) { }
public void Update(StorageOption storageOption) { unitOfWork.StorageOptionsRepository.Update(storageOption); unitOfWork.Save(); }
public void InsertStorageOption(StorageOption storageOption) { unitOfWork.StorageOptionsRepository.Insert(storageOption); unitOfWork.Save(); }
protected ReadThroughDistributedWriteBehindBuildCacheSimulationTests(StorageOption storageOption) : base(storageOption) { }
public IRepository <TData> NewRepository <TData>(StorageOption storage, IValidator <TData> validator) { return(Resolve(storage, validator)); }
public static Parent SortDataGridVeiwToParentClass(DataRow Row) { Parent ConStudent = new Bulawayo_Storage.Parent(); int strId = (int)Row.ItemArray[0]; string strName = (string)Row.ItemArray[1]; string strSurName = (string)Row.ItemArray[2]; string strHouse = (string)Row.ItemArray[3]; string strEmail = (string)Row.ItemArray[4]; string strNumber = (string)Row.ItemArray[5]; string strGuardianNumber = (string)Row.ItemArray[6]; int stringNumTrunks = (int)Row.ItemArray[7]; string strStorageOption = (string)Row.ItemArray[8]; string strPaymentMethod = (string)Row.ItemArray[9]; DateTime period = (DateTime)Row.ItemArray[10]; ConStudent.Id = strId; ConStudent.Name = strName; ConStudent.Surname = strSurName; strHouse = strHouse.ToLower(); if (strHouse.Contains("founders")) { FalconCollegeHouse House = FalconCollegeHouse.Founders; ConStudent.House = House; } else if (strHouse.Contains("george")) { FalconCollegeHouse House = FalconCollegeHouse.GeorgeGrey; ConStudent.House = House; } else if (strHouse.Contains("hervey")) { FalconCollegeHouse House = FalconCollegeHouse.Hervey; ConStudent.House = House; } else if (strHouse.Contains("oates")) { FalconCollegeHouse House = FalconCollegeHouse.Oates; ConStudent.House = House; } else if (strHouse.Contains("tredgold")) { FalconCollegeHouse House = FalconCollegeHouse.Tredgold; ConStudent.House = House; } else if (strHouse.Contains("chubb")) { FalconCollegeHouse House = FalconCollegeHouse.Chubb; ConStudent.House = House; } ConStudent.Email = strEmail; ConStudent.Number = strNumber; ConStudent.GaurdianNumber = strGuardianNumber; ConStudent.Trunks = stringNumTrunks; strStorageOption = strStorageOption.ToLower(); if (strStorageOption.Contains("washing")) { StorageOption StorageOpt = StorageOption.StorageAndWashing; ConStudent.Option = StorageOpt; } else if (strStorageOption.Contains("only")) { StorageOption StorageOpt = StorageOption.Storage; ConStudent.Option = StorageOpt; } strPaymentMethod = strPaymentMethod.ToLower(); if (strPaymentMethod.Contains("cash")) { MethodOfPayment PaymentMethod = MethodOfPayment.Cash; ConStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("eco")) { MethodOfPayment PaymentMethod = MethodOfPayment.EcoCash; ConStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("student")) { MethodOfPayment PaymentMethod = MethodOfPayment.StudentAccount; ConStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("bank")) { MethodOfPayment PaymentMethod = MethodOfPayment.BankTransfer; ConStudent.MethodOfPayment = PaymentMethod; } ConStudent.StoragePeriod = period; return(ConStudent); }
public void SetStorageOption(StorageOption storageOption) { _storageOption = storageOption; }