public Status GetAllStorage() { this._logger.LogWarning("The Server execute GetAllStorage Function --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { var result = dbcontext.TStorage.ToList(); if (result.Count > 0) { StorageStatus userInfoStatus = new StorageStatus { StatusCode = 200, Message = "获取成功", ReturnTime = DateTime.Now, UserInfo = result }; return(userInfoStatus); } else { Status status = new Status { StatusCode = 0, Message = "获取失败", ReturnTime = DateTime.Now, }; return(status); } } }
public async Task <Result> Handle(CreateStorageStatusCommand request, CancellationToken cancellationToken) { Result result; var id = _identifierProvider.Generate(); var storageStatusToCreate = new StorageStatus(id, request.Code, request.Name, bool.Parse(request.Default), request.Source); storageStatusToCreate.Version = _versionProvider.Generate(); try { await _storageStatusWriteRepository.CreateAsync(storageStatusToCreate); result = Result.Ok(id, storageStatusToCreate.Version); } catch (UniqueKeyException) { result = Result.Fail(new System.Collections.Generic.List <Failure>() { new HandlerFault() { Code = HandlerFaultCode.Conflict.Name, Message = HandlerFailures.CodeSourceConflict, Target = "code-source" } } ); } catch { result = Result.Fail(CustomFailures.CreateStorageStatusFailure); } return(result); }
public Status GetConditionStorage(string productinfo) { this._logger.LogWarning("The server execute GetConditionStorage Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { var result = dbcontext.TStorage.Where(a => a.ProductInfo == productinfo).ToList(); if (result.Count > 0) { StorageStatus userInfoStatus = new StorageStatus { StatusCode = 200, Message = "查询成功", ReturnTime = DateTime.Now, UserInfo = result }; return(userInfoStatus); } else { Status status = new Status { StatusCode = 0, Message = "查询失败", ReturnTime = DateTime.Now, }; return(status); } } }
private static void PerformBalanceChecks([NotNull] HouseType houseType, [NotNull] Simulator sim) { var spaceheatinglt = sim.LoadTypes.FindFirstByName("Space Heating"); if (spaceheatinglt == null) { throw new DataIntegrityException("Could not find space heating Loadtype"); } foreach (var transformationDevice in houseType.HouseTransformationDevices) { if (transformationDevice.TransformationDevice == null) { throw new LPGException("Messed up data in " + houseType.Name); } if (transformationDevice.TransformationDevice.LoadTypeIn == spaceheatinglt) { StorageStatus status = StorageStatus.Missing; if (transformationDevice.TransformationDevice.Description.Contains("expects storage")) { status = StorageStatus.Needed; } if (transformationDevice.TransformationDevice.Description.Contains("no storage")) { status = StorageStatus.NotNeeded; } if (status == StorageStatus.Missing) { throw new DataIntegrityException("The transformation device " + transformationDevice.Name + " does not have it's storage needs in the description.", transformationDevice.TransformationDevice); } bool spaceheatingStorageExists = false; foreach (var storage in houseType.HouseEnergyStorages) { if (storage.EnergyStorage == null) { throw new LPGException("Messed up energy storage in " + houseType.Name); } if (storage.EnergyStorage.LoadType == spaceheatinglt) { spaceheatingStorageExists = true; } } if (status == StorageStatus.Needed && !spaceheatingStorageExists) { throw new DataIntegrityException("The " + houseType.Name + " has a transformation device for space heating that requires an energy storage, but no energy storage is in the house", houseType); } if (status == StorageStatus.NotNeeded && spaceheatingStorageExists) { throw new DataIntegrityException("The " + houseType.Name + " has a transformation device for space heating that requires no energy storage, but an energy storage is in the house", houseType); } } CheckAllTrafosForEnergyStorageDemands(houseType, transformationDevice); } }
protected override void ResponseCallback(HttpWebResponse webResponse) { XNamespace ns = "http://schemas.microsoft.com/windowsazure"; XDocument document = XDocument.Load(webResponse.GetResponseStream()); XElement elementStorageStatus = document.Element(ns + "StorageService").Element(ns + "StorageServiceProperties") .Element(ns + "Status"); Status = (StorageStatus)Enum.Parse(typeof(StorageStatus), elementStorageStatus.Value); SitAndWait.Set(); }
private static void CheckAllTrafosForEnergyStorageDemands([NotNull] HouseType houseType, [NotNull] HouseTypeTransformationDevice transformationDevice) { StorageStatus status = StorageStatus.Missing; Variable variable = null; if (transformationDevice.TransformationDevice == null) { throw new LPGException("Messed up data in " + houseType.Name); } if (transformationDevice.TransformationDevice.Description.Contains("expects storage")) { status = StorageStatus.Needed; if (transformationDevice.TransformationDevice.Conditions.Count == 0) { throw new DataIntegrityException("Transformation Device requires storage, but has no storage conditions: " + transformationDevice.TransformationDevice); } variable = transformationDevice.TransformationDevice.Conditions[0].Variable; } if (transformationDevice.TransformationDevice.Description.Contains("no storage")) { status = StorageStatus.NotNeeded; } bool storageExists = false; foreach (var storage in houseType.HouseEnergyStorages) { if (storage.EnergyStorage == null) { throw new LPGException("Messed up energy storage in " + houseType.Name); } if (storage.EnergyStorage.Signals.Any(x => x.Variable == variable)) { storageExists = true; } } if (status == StorageStatus.Needed && !storageExists) { throw new DataIntegrityException("The " + houseType.Name + " has a transformation device that requires an energy storage, but no energy storage is in the house", houseType); } if (status == StorageStatus.NotNeeded && storageExists) { throw new DataIntegrityException("The " + houseType.Name + " has a transformation device that requires no energy storage, but an energy storage is in the house", houseType); } }
public void LoadData(DataObject dataObject) { Stop(); Status = StorageStatus.Starting; WorkerThread = new StorageThread(this); WorkerThread.Name = "LoadThread"; WorkerThread.InitializeStorageInteraction(StorageRequestType.Load, dataObject); WorkerThread.Start(); }
public Storage CreateStorage(string storageName, StorageStatus storageStatus, bool isLoadBalanced, int agnetMaxNumber, int agnetMinNumber) { return(new Storage() { StorageName = storageName, AgentMaxNumber = agnetMaxNumber, AgentMinNumber = agnetMinNumber, StorageStatus = storageStatus, IsLoadBalanced = isLoadBalanced, Agents = new System.Collections.Concurrent.ConcurrentDictionary <string, Agent>() }); }
public void SaveInfomation() { //Arrange ReadingInfo readingInfo = new ReadingInfo(); dataAccessMock.Setup(d => d.SaveReading(It.IsAny <ReadingInfo>())); //Act StorageStatus result = this.storage.Save(readingInfo); //Assert Assert.AreEqual(StorageStatus.Saved, result); dataAccessMock.VerifyAll(); }
public void CreateStorageStatusShouldSucceed() { // Arrange Guid id = Guid.NewGuid(); string name = "StorageStatusTest"; string source = "Belgium"; bool @default = true; string code = "code"; // Act var storageStatus = new StorageStatus(id, code, name, @default, source); // Assert storageStatus.Name.Should().Be(name); }
public async Task CreateShouldSucceedWhenNameIsSame() { //Arrange var name = "TestName"; var StorageStatus = new StorageStatus(Guid.NewGuid(), "TestCode1", name, true, "TestSource1"); await _repository.CreateAsync(StorageStatus); var StorageStatus2 = new StorageStatus(Guid.NewGuid(), "TestCode2", name, true, "TestSource2"); //Act Action act = () => { _repository.CreateAsync(StorageStatus2).GetAwaiter().GetResult(); }; //Assert act.Should().NotThrow(); }
public void FileNotFound() { // IStorageStatusを作成 var testDao = new TestDao(); var status = new StorageStatus(); // 存在しないパスを指定 status.picturePath1 = @"D:\test\test.pdf"; testDao.SetStorageStatus(status); var service = new PDFService(testDao); var ex = Assert.Throws <FileNotFoundException>(() => { service.GetPDFData("", 1); }); }
public async Task CreateShouldFailWhenCodeAndSourceSame() { //Arrange var code = "TestCode"; var name = "TestName"; var source = "TestSource"; var @default = true; var StorageStatus = new StorageStatus(Guid.NewGuid(), code, name, @default, source); await _repository.CreateAsync(StorageStatus); var StorageStatus2 = new StorageStatus(Guid.NewGuid(), code, name, @default, source); //Act Action act = () => { _repository.CreateAsync(StorageStatus2).GetAwaiter().GetResult(); }; //Assert act.Should().Throw <UniqueKeyException>(); }
public List <double> GetStoredData() { try { if (controllerMode == ControllerMode.CommMode) { SetGeneralMode(); } var storeStats = new DataStorageStats(); StorageStatus currentStatus = StorageStatus.StorageActive; while (currentStatus == StorageStatus.StorageActive) { storeStats = GetStorageStatus(); currentStatus = storeStats.StorageStatus; } string dataOut = Write(dataStoreOut, 100); Write(dataStoreStop, 100); var stringList = GetData(dataOut); var outputList = new List <double>(); foreach (int ptCt in storeStats.StoredDataCount) { outputList.Add((double)ptCt); } for (int i = 0; i < stringList.Count; i++) { double result = 0; if (double.TryParse(stringList[i], out result)) { outputList.Add(result); } } return(outputList); } catch (Exception) { throw; } }
public async Task CreateShouldSucceed() { //Arrange var code = "TestCode"; var name = "TestName"; var source = "TestSource"; var @default = true; var storageStatus = new StorageStatus(Guid.NewGuid(), code, name, @default, source); //Act await _repository.CreateAsync(storageStatus); //Asssert var data = RepositoryHelper.ForStorageStatus.GetStorageStatus(); data.Should().HaveCount(1); var result = data.First(); result.Name.Should().Be(name); result.Code.Should().Be(code); result.Source.Should().Be(source); }
public void Pass() { // IStorageStatusを作成 var testDao = new TestDao(); var status = new StorageStatus(); // 存在しないパスを指定 status.picturePath1 = @"D:\test\test.pdf"; // 存在するパスを指定 var filePath = @"/opt/pdf-server/.gitignore"; status.picturePath2 = @"/opt/pdf-server/.gitignore"; testDao.SetStorageStatus(status); var service = new PDFService(testDao); // 成功するはず using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { var bytes = new byte[fs.Length]; fs.Read(bytes, 0, (int)fs.Length); Assert.Equal(bytes, service.GetPDFData("", 2)); } }
public static StorageStatus CreateStorageStatus(Guid id, string code, string name, bool @default, string source) { // prepare var writeRepository = new StorageStatusWriteRepository(new DataContext(new PersistenceConfiguration(RepositoryTestsHelper.ConnectionString))); var readRepository = new StorageStatusReadRepository(new DataContext(new PersistenceConfiguration(RepositoryTestsHelper.ConnectionString))); // create var storageStatus = new StorageStatus(id, code, name, @default, source); IEnumerable <StorageStatus> damageCodes = new List <StorageStatus>() { storageStatus }; foreach (var item in damageCodes) { writeRepository.CreateAsync(item).GetAwaiter().GetResult(); } // result var result = readRepository.GetAsync(storageStatus.Id).Result; return(result); }
private Storage GetStorage() { var drives = DriveInfo.GetDrives().Where(d => _allowedFilesystems.Contains(d.DriveFormat)); var storage = new Storage(); foreach (var drive in drives) { var totalSpace = BytesToGigabytes(drive.TotalSize); var freeSpace = BytesToGigabytes(drive.TotalFreeSpace); var storageStatus = new StorageStatus { TotalSpace = totalSpace, AvailableSpace = freeSpace, UsedSpace = totalSpace - freeSpace, CapacityPercentage = GetStoragePercentage(drive.TotalSize, drive.AvailableFreeSpace), Filesystem = drive.DriveFormat, MountedOn = drive.Name }; storage.Storages.Add(storageStatus); } return(storage); }
public void SetStorageStatus(StorageStatus status) { this.status = status; }
public StorageCheckResponse(int status, DateTime timestamp, StorageStatus storages) : base(status, timestamp) { this.storages = storages; }
public StorageEventArgs(StorageStatus status, List<DataObject> data = null) { Data = data; Status = status; }
/// <summary> /// 根据出入库类型数值获得类型名称 /// </summary> /// <param name="Status"></param> /// <returns></returns> public static string getStutusText(int Status) { StorageStatus col = (StorageStatus)Status; return(col.ToString()); }
private void Stopped() { Status = StorageStatus.Stopped; }
private void DeleteSuccessful() { Status = StorageStatus.DeleteSuccessful; }
private void WriteSuccessful() { Status = StorageStatus.WriteSuccessful; }
private void NoDataStored() { Status = StorageStatus.NoDataStored; }
private void DataFound(List<DataObject> dataList) { _dataObjects = dataList; Status = StorageStatus.DataFound; }
private void DataNotFound() { Status = StorageStatus.DataNotFound; }
public void DeleteAllData() { Stop(); Status = StorageStatus.Starting; WorkerThread = new StorageThread(this); WorkerThread.Name = "DeleteAllThread"; WorkerThread.InitializeStorageInteraction(StorageRequestType.DeleteAll); WorkerThread.Start(); }
private void StoreSuccessful(DataObject data) { _dataObjects = new List<DataObject>(); _dataObjects.Add(data); Status = StorageStatus.StoreSuccessful; }
private void ReadSuccessful() { Status = StorageStatus.ReadSuccessful; }
private void ReadFailed() { Status = StorageStatus.ReadFailed; }
private void DeleteFailed() { Status = StorageStatus.DeleteFailed; }
private void WriteFailed() { Status = StorageStatus.WriteFailed; }
private void StoreFailed() { Status = StorageStatus.StoreFailed; }