예제 #1
0
 public ShowStudy(Study currentStudy)
 {
     InitializeComponent();
     Title = currentStudy.Name + " | " + currentStudy.Date.ToShortDateString();
     _vMShowStudy = new ViewModels.ShowStudy(currentStudy);
     DataContext = _vMShowStudy;
 }
예제 #2
0
 public Plants(Study currentStudy)
 {
     InitializeComponent();
     _study = currentStudy;
     _vM = new ViewModels.Plants(_study);
     DataContext = _vM;
 }
예제 #3
0
 public Emissions(Study currentStudy)
 {
     _currentStudy = currentStudy;
     Types = _currentStudy.PlantTypes;
     EmissionsTypes = _currentStudy.Emissions;
     CalculateClickCommand = new Command(arg => CalculateClickMethod(arg as Window));
 }
예제 #4
0
 public ShowStudy(Models.Study currentStudy)
 {
     _currentStudy = currentStudy;
     ExcelClickCommand = new Command(arg => ExcelClickMethod(arg as Window));
     PlantsClickCommand = new Command(arg => PlantsClickMethod(arg));
     TypesClickCommand = new Command(arg => TypesClickMethod(arg));
     EmissionsClickCommand = new Command(arg => EmissionsClickMethod());
     _backgroundWorker = new BackgroundWorker();
     _backgroundWorker.DoWork += _backgroundWorker_DoWork;
     _backgroundWorker.RunWorkerCompleted += _backgroundWorker_RunWorkerCompleted;
 }
예제 #5
0
 public Types(Study currentStudy)
 {
     InitializeComponent();
     _study = currentStudy;
     DataTable.ItemsSource = _study.PlantTypes;
 }
예제 #6
0
        public AddingErrors CreateNewStudy()
        {

            Study newStudy = new Study();
            newStudy.Name = Name;
            newStudy.Date = Date;
            newStudy.PlantTypes = new List<PlantType>();
            Mersim mersim = new Mersim(PathToMersimFile);
            if (IsPlantsFromFile)
            {
                Varsys varsys = new Varsys(PathToVarsysFile);
                Fixsys fixsys = new Fixsys(PathToFixsysFile);
                PlantType type = new PlantType();
                type.Name = "Undefined type";
                type.Plants = new List<Plant>();
                try
                {
                    type.Plants.AddRange(fixsys.Parse());
                }
                catch (Exception)
                {
                    return AddingErrors.Fixsys;
                }
                try
                {
                    type.Plants.AddRange(varsys.Parse());
                    newStudy.PlantTypes.Add(type);
                }
                catch (Exception)
                {
                    return AddingErrors.Varsys;
                }
            }
            if (IsPlantsFromStudy)
            {
                newStudy.PlantTypes = SelectedStudy.PlantTypes.ToList();
            }
            try
            {
                newStudy.Scenarios = mersim.Parse();
            }
            catch (Exception)
            {
                return AddingErrors.Mersim;
            }
            
            try
            {
                _context.Studies.Add(newStudy);
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return AddingErrors.Database;
            }
            return AddingErrors.None;
        }
예제 #7
0
파일: Plants.cs 프로젝트: almarkua/WASP-F-E
 public Plants(Study currentStudy)
 {
     _currentStudy = currentStudy;
     PlantsList = GetPlants();
     if (PlantsList.Count != 0) SelectedPlant = PlantsList[0];
 }
예제 #8
0
파일: Excel.cs 프로젝트: almarkua/WASP-F-E
        public static void WriteStudyToExcel(Study study,string file)
        {
            bool fileSaved = false;
            Exc.Application application = null;
            Exc.Workbook workbook = null;
            Exc.Worksheet worksheet = null;
            try
            {
                application = new Exc.Application();
                workbook = application.Workbooks.Add();
                worksheet = workbook.Sheets[1];

                application.Cells[1, 1] = study.Name;
                application.Cells[2, 1] = study.Date;
                MakeTopHeader(worksheet,1,2,1);
                int offset = 3;
                for (int i = 0; i < study.Scenarios.Count; i++)
                {
                    application.Cells[offset, 1] = Headers.Year;
                    application.Cells[offset, 2] =  study.Scenarios[i].Year;
                    application.Cells[offset, 3] = Headers.Period;
                    application.Cells[offset, 4] = study.Scenarios[i].Period;
                    application.Cells[offset, 5] = Headers.Hydrocondition;
                    application.Cells[offset, 6] = study.Scenarios[i].Hydrocondition;
                    MakeHeader(application, offset, 1, 1);
                    MakeHeader(application, offset, 3, 3);
                    MakeHeader(application, offset, 5, 5);
                    offset++;
                    application.Cells[offset, 1] = Headers.PlantName;
                    application.Cells[offset, 2] = Headers.CapacityBase;
                    application.Cells[offset, 3] = Headers.CapacityPeak;
                    application.Cells[offset, 4] = Headers.CapacityTotal;
                    application.Cells[offset, 5] = Headers.EnergyBase;
                    application.Cells[offset, 6] = Headers.EnergyPeak;
                    application.Cells[offset, 7] = Headers.EnergyTotal;
                    application.Cells[offset, 8] = Headers.PeakMineng;
                    application.Cells[offset, 9] = Headers.EnergySpilled;
                    application.Cells[offset, 10] = Headers.EnergyShortage;
                    application.Cells[offset, 11] = Headers.OaM;
                    application.Cells[offset, 12] = Headers.CapacityFactor;
                    MakeHeader(application, offset, 1, 12);
                    for (int j = 0; j < study.Scenarios[i].HPlants.Count; j++)
                    {
                        offset++;
                        application.Cells[offset, 1] = study.Scenarios[i].HPlants[j].Name;
                        application.Cells[offset, 2] = study.Scenarios[i].HPlants[j].CapacityBase;
                        application.Cells[offset, 3] = study.Scenarios[i].HPlants[j].CapacityPeak;
                        application.Cells[offset, 4] = study.Scenarios[i].HPlants[j].CapacityTotal;
                        application.Cells[offset, 5] = study.Scenarios[i].HPlants[j].EnergyBase;
                        application.Cells[offset, 6] = study.Scenarios[i].HPlants[j].EnergyPeak;
                        application.Cells[offset, 7] = study.Scenarios[i].HPlants[j].EnergyTotal;
                        application.Cells[offset, 8] = study.Scenarios[i].HPlants[j].PeakMineng;
                        application.Cells[offset, 9] = study.Scenarios[i].HPlants[j].EnergySpilled;
                        application.Cells[offset, 10] = study.Scenarios[i].HPlants[j].EnergyShortage;
                        application.Cells[offset, 11] = study.Scenarios[i].HPlants[j].OaM;
                        application.Cells[offset, 12] = study.Scenarios[i].HPlants[j].CapacityFactor;
                    }

                    offset+=2;
                    application.Cells[offset, 1] = Headers.PlantName;
                    application.Cells[offset, 2] = Headers.NumberOfUnits;
                    application.Cells[offset, 3] = Headers.CapacityBase;
                    application.Cells[offset, 4] = Headers.CapacityPeak;
                    application.Cells[offset, 5] = Headers.CapacityTotal;
                    application.Cells[offset, 6] = Headers.EnergyBase;
                    application.Cells[offset, 7] = Headers.EnergyPeak;
                    application.Cells[offset, 8] = Headers.EnergyTotal;
                    application.Cells[offset, 9] = Headers.FuelDomestic;
                    application.Cells[offset, 10] = Headers.FuelForeign;
                    application.Cells[offset, 11] = Headers.FuelTotal;
                    application.Cells[offset, 12] = Headers.OaM;
                    application.Cells[offset, 13] = Headers.MainProbability;
                    application.Cells[offset, 14] = Headers.ForCell;
                    application.Cells[offset, 15] = Headers.CapacityFactor;
                    MakeHeader(application, offset, 1, 15);
                    foreach (var tPlant in study.Scenarios[i].TPlants)
                    {
                        offset++;
                        application.Cells[offset, 1] = tPlant.Name;
                        application.Cells[offset, 2] = tPlant.NumberOfUnits;
                        application.Cells[offset, 3] = tPlant.CapacityBase;
                        application.Cells[offset, 4] = tPlant.CapacityPeak;
                        application.Cells[offset, 5] = tPlant.CapacityTotal;
                        application.Cells[offset, 6] = tPlant.EnergyBase;
                        application.Cells[offset, 7] = tPlant.EnergyPeak;
                        application.Cells[offset, 8] = tPlant.EnergyTotal;
                        application.Cells[offset, 9] = tPlant.FuelDomestic;
                        application.Cells[offset, 10] = tPlant.FuelForeign;
                        application.Cells[offset, 11] = tPlant.FuelTotal;
                        application.Cells[offset, 12] = tPlant.OaM;
                        application.Cells[offset, 13] = tPlant.MainProbability;
                        application.Cells[offset, 14] = tPlant.ForCell;
                        application.Cells[offset, 15] = tPlant.CapacityFactor;
                    }
                    offset++;
                }
                workbook.SaveAs(file);
                fileSaved = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Помилка при роботі із Excel: "+ex.Message,"Помилка!",MessageBoxButton.OK,MessageBoxImage.Error);
            }
            finally
            {
                workbook.Close();
                application.Quit();
                workbook = null;
                worksheet = null;
                application = null;
                GC.Collect();
                if (fileSaved) Process.Start(file);
            }
        }
예제 #9
0
파일: Excel.cs 프로젝트: almarkua/WASP-F-E
        public static void WriteEmissionsToExcel(Study study, Dictionary<EmissionType,Dictionary<int,double>> dict, string file)
        {
            bool fileSaved = false;
            Exc.Application application = null;
            Exc.Workbook workbook = null;
            Exc.Worksheet worksheet = null;
            try
            {
                application = new Exc.Application();
                workbook = application.Workbooks.Add();
                worksheet = workbook.Sheets[1];
                worksheet.Cells[1, 1] = study.Name;
                worksheet.Cells[2, 1] = study.Date.ToShortDateString();
                MakeTopHeader(worksheet,1,3,1);
                
                int offset = 4;
                worksheet.Cells[offset, 1] = Headers.Emission;
                worksheet.Cells[offset, 2] = Headers.Year;
                worksheet.Cells[offset, 3] = Headers.ValueKG;
                MakeHeader(application, offset, 1, 3);
                foreach (var eType in dict.Keys)
                {
                    foreach (var year in dict[eType].Keys)
                    {
                        offset++;
                        worksheet.Cells[offset, 1] = eType.Name;
                        worksheet.Cells[offset, 2] = year;
                        worksheet.Cells[offset, 3] = dict[eType][year];
                    }
                    offset++;
                }

                workbook.SaveAs(file);
                fileSaved = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Excel error: " + ex.Message);
            }
            finally
            {
                workbook.Close();
                application.Quit();
                workbook = null;
                worksheet = null;
                application = null;
                GC.Collect();
                if (fileSaved) Process.Start(file);
            }
        }
예제 #10
0
 public Emissions(Study currentStudy)
 {
     InitializeComponent();
     _vM = new ViewModels.Emissions(currentStudy);
     DataContext = _vM;
 }