예제 #1
0
        public WindEnergyController(string fileName)
        {
            _fileName = fileName;
            var windGenDes = BinaryController.ReadDataFromBinary <WindGeneratorDescription>(fileName);

            WindGenDes = windGenDes.Count == 0 ? new List <WindGeneratorDescription>() : windGenDes;
        }
예제 #2
0
        public void GetWeatherExcel(string file)
        {
            ExcelController excelController = new ExcelController();
            List <Weather>  weathers        = excelController.GetWeathers(file + ".xlsx");

            BinaryController.WriteDataToBinary(file, weathers);
        }
예제 #3
0
        public HeatPumpController(string fileName)
        {
            _fileName = fileName;
            var heatPumps = BinaryController.ReadDataFromBinary <HeatPump>(fileName);

            HeatPump = heatPumps.Count == 0 ? new HeatPump() : heatPumps[0];
        }
 public WeatherController(List <string> files)
 {
     _files          = files;
     _weathersListDb = BinaryController.ReadAllWeatherFromBinary(files);
     CorrectWeather();
     Weathers = _weathersListDb.SelectMany(x => x).ToList();
 }
        public HouseController(string fileName)
        {
            _fileName = fileName;

            var houses = BinaryController.ReadDataFromBinary <House>(fileName);

            House                = houses.Count == 0 ? new House() : houses[0];
            CommonHeatLosses     = new HeatLosses();
            IndividualHeatLosses = new HeatLosses();
        }
        public static List <DeviceOptimization> Read(string fileName, List <Device> devices)
        {
            List <DeviceOptimization> list = BinaryController.ReadDataFromBinary <DeviceOptimization>(fileName);

            List <DeviceOptimization> devicesList = new List <DeviceOptimization>();

            foreach (var dev in devices)
            {
                bool isAvailable = list.Exists(x => x.Device.Name.Equals(dev.Name) && x.IsAvailable);
                devicesList.Add(new DeviceOptimization(dev, isAvailable));
            }
            return(devicesList);
        }
        public void Get_InvalidNullId()
        {
            var controller = new BinaryController(_pointerService, _apiSettings);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = HttpContexts.Valid_Search;

            var nodeServices = new Mock <INodeServices>();

            nodeServices.Setup(x => x.InvokeAsync <byte[]>(It.IsAny <string>(), It.IsAny <object[]>())).Returns(Task.Run(() => Encoding.UTF8.GetBytes("I'm a PDF!")));

            Assert.ThrowsAsync <HttpFhirException>(async() => await controller.Get(nodeServices.Object, null, "mhcp"));
        }
 public void Work()
 {
     StatusProgressBar.Value = 1;
     foreach (var weatherFile in _weatherFiles)
     {
         _convertController.GetWeatherExcel(weatherFile);
         StatusProgressBar.Value += 100 / 13;
     }
     WeatherController = new WeatherController(_weatherFiles);
     var sunConditions = _convertController.GetSunConditionsFromExcel(_sunFile);
     SunConditionController = new SunConditionController(sunConditions, WeatherController.Year);
     BinaryController.WriteDataToBinary(_sunFile, SunConditionController.SunConditions);
     StatusProgressBar.Value = 100;
     Close();
 }
        private void ChooseData()
        {
            FolderBrowserDialog folderDialog = new FolderBrowserDialog();

            folderDialog.Description  = "Виберіть каталог метеорологічних даних регіону";
            folderDialog.SelectedPath = @"киев+\";
            if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string        path  = folderDialog.SelectedPath;
                List <string> files = Directory.GetFiles(path, "*.xlsx").ToList();
                for (int i = 0; i < files.Count; i++)
                {
                    files[i] = files[i].Replace(Directory.GetCurrentDirectory(), ".").Replace(".xlsx", "");
                }
                _sunFile = files.Last(x => x.Contains("soldata"));
                files.Remove(_sunFile);
                files.Sort();
                _weatherFiles = files;
                ConvertProgressBarWindow progressBarWindow = new ConvertProgressBarWindow(_weatherFiles, _sunFile);
                progressBarWindow.Show();
                Pathes pathes = new Pathes
                {
                    SunFile      = _sunFile,
                    WeatherFiles = _weatherFiles
                };
                BinaryController.WriteDataToBinary(_fileSource, new List <Pathes> {
                    pathes
                });
                MeteorogicalAnalysisView.TimePeriodChanged -= Calculate;
                //InitData();
                // Task 1
                _weatherController = new WeatherController(_weatherFiles);
                //_weatherController.CorrectWeather();
                _sunConditionController = new SunConditionController(System.IO.Path.GetFullPath(_sunFile));
                //_sunConditionController.CorrectData(_weatherController.Year);
                MeteorogicalAnalysisView.Init(_weatherController, _sunConditionController);
                Calculate();
                MeteorogicalAnalysisView.TimePeriodChanged += Calculate;
            }
            else
            {
                Close();
            }
        }
        public async void Get_OkPdf()
        {
            var controller = new BinaryController(_pointerService, _apiSettings);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = HttpContexts.Valid_Search;

            var nodeServices = new Mock <INodeServices>();

            nodeServices.Setup(x => x.InvokeAsync <byte[]>(It.IsAny <string>(), It.IsAny <object[]>())).Returns(Task.Run(() => Encoding.UTF8.GetBytes("I'm a PDF!")));

            var response = await controller.Get(nodeServices.Object, "5a82f9ffcb969daa58d33377", "mhcp");

            Assert.IsType <FileContentResult>(response);

            var responseContent = response as FileContentResult;

            Assert.Equal(Encoding.UTF8.GetBytes("I'm a PDF!"), responseContent.FileContents);
            Assert.Equal("application/pdf", responseContent.ContentType);
        }
        public async void Get_OkFhir()
        {
            var controller = new BinaryController(_pointerService, _apiSettings);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = HttpContexts.Valid_DocumentFhir;

            var nodeServices = new Mock <INodeServices>();

            nodeServices.Setup(x => x.InvokeAsync <byte[]>(It.IsAny <string>(), It.IsAny <object[]>())).Returns(Task.Run(() => Encoding.UTF8.GetBytes("I'm a PDF!")));

            var response = await controller.Get(nodeServices.Object, "5a82f9ffcb969daa58d33377", "mhcp");

            Assert.IsType <FileContentResult>(response);

            var responseContent = response as FileContentResult;

            Assert.Equal(Encoding.UTF8.GetBytes("{\"resourceType\":\"Binary\",\"contentType\":\"application/pdf\",\"content\":\"SSdtIGEgUERGIQ==\"}"), responseContent.FileContents);
            Assert.Equal("application/xml+fhir; charset=utf-8", responseContent.ContentType);
        }
        private void StartActions()
        {
            MainTabControl.IsEnabled = false;
            var sources = BinaryController.ReadDataFromBinary <Pathes>(_fileSource);

            if (sources.Count >= 1)
            {
                Pathes pathes = sources[0];
                _weatherFiles = pathes.WeatherFiles;
                _sunFile      = pathes.SunFile;
            }
            if (_weatherFiles == null)
            {
                ChooseData();
            }
            else
            {
                InitData();
            }
            MainTabControl.IsEnabled = true;
        }
예제 #13
0
 public void Save()
 {
     BinaryController.WriteDataToBinary(_fileName, new List <HeatPump> {
         HeatPump
     });
 }
 public SunConditionController(string file, int year)
 {
     _file         = file;
     SunConditions = BinaryController.ReadDataFromBinary <Sun>(file);
     CorrectData(year);
 }
 public static void Save(string fileName, List <DeviceOptimization> list)
 {
     BinaryController.WriteDataToBinary(fileName, list);
 }
예제 #16
0
 public void Save()
 {
     BinaryController.WriteDataToBinary(_fileName, WindGenDes);
 }
 public void Save()
 {
     BinaryController.WriteDataToBinary(_fileName, new List <House> {
         House
     });
 }
 public SunConditionController(string file)
 {
     _file         = file;
     SunConditions = BinaryController.ReadDataFromBinary <Sun>(file);
 }