private void repositoryDocumentAddProcess(object sender) { TreeNode node = sender as TreeNode; GProject g = GetProjectObject(node.Tag as string); int c = 1; string prefix = "c"; while (g.GProcess(prefix + c.ToString()) != null) { c++; } g.AddProcess(prefix + c.ToString()); GProcess cmain = g.GProcess(prefix + c.ToString()); cmain.AddNodeCode(1, 0, 0); cmain.Base.EntryNode = cmain.Base.NodesList[0].Name; if (g.BaseProject.ProcessList.Count() == 1) { g.BaseProject.StartUpProcess = prefix + c.ToString(); } LoadRepository(); string pathname = node.Tag as string; GraphDoc doc = null; foreach (object o in dockPanel.Documents) { if (o is GraphDoc) { GraphDoc d = o as GraphDoc; if (d.FileName == pathname) { if (d.ProcessName != node.Text) { doc = d; doc.Modified = true; } } } } if (doc == null) { SaveDocument(g, pathname); } else { RefreshDocuments(); } }
private void SetProjectObject(string name, GProject gproject) { if (m_projectObjects.ContainsKey(name)) { m_projectObjects[name] = gproject; } else { m_projectObjects.Add(name, gproject); } }
private bool repositoryDocumentRename(object sender, string newName) { TreeNode node = sender as TreeNode; if (node.Tag is Process) { string pathname = node.Parent.Tag as string; GProject g = GetProjectObject(pathname); if (g.GProcess(newName) != null) { return(false); } g.GProcess(node.Text).Name = newName; if (g.GProcess(newName) == null) { return(false); } GraphDoc doc = null; foreach (object o in dockPanel.Documents) { if (o is GraphDoc) { GraphDoc d = o as GraphDoc; if (d.FileName == pathname) { doc = d; doc.Modified = true; } } } if (doc == null) { SaveDocument(g, pathname); } else { RefreshDocuments(); } } else if (node.Tag is string) { return(false); } return(true); }
private void repositoryDocumentMark(object sender) { TreeNode node = sender as TreeNode; Process process = node.Tag as Process; Project project = process.ParentProject; string old = project.StartUpProcess; project.StartUpProcess = process.Name; node.ImageIndex = 7; node.SelectedImageIndex = 7; if (node.Parent.Nodes.ContainsKey(old)) { node.Parent.Nodes[old].ImageIndex = 5; node.Parent.Nodes[old].SelectedImageIndex = 5; } string pathname = node.Parent.Tag as string; GraphDoc doc = null; foreach (object o in dockPanel.Documents) { if (o is GraphDoc) { GraphDoc d = o as GraphDoc; if (d.FileName == pathname) { if (d.ProcessName != node.Text) { doc = d; doc.Modified = true; } } } } GProject g = GetProjectObject(pathname); if (doc == null) { SaveDocument(g, pathname); } else { RefreshDocuments(); } }
private void childDocumentSave(object sender) { GProject g = (sender as GraphDoc).GProject; SaveDocument(g, (sender as GraphDoc).FileName); foreach (object o in dockPanel.Documents) { if (o is GraphDoc) { GraphDoc gd = o as GraphDoc; gd.Modified = false; gd.UpdateText(); } } }
private void tsbFileNew_Click(object sender, EventArgs e) { Project g = new Project(); g.NewProcess("main"); g.StartUpProcess = "main"; Process cmain = g.FindProcess("main"); cmain.NewNode("start"); Node nmain = cmain.FindNode("start"); cmain.EntryNode = "start"; cmain.ExitNode = "start"; GraphDoc gd = new GraphDoc(); // ask for filename string prefix = "project"; string suffix = ""; int i = 1; //! while (m_WebService.GetProjectID(prefix + i.ToString() + suffix) > 0) i++; string FileName = prefix + i.ToString() + suffix; g.Name = prefix + i.ToString(); GProject gproject = new GProject(); gproject.Load(g); gd.FileName = FileName; gd.LoadProcess(gproject.GProcess("main")); SetProjectObject(gd.FileName, gproject); gd.OnDocumentModified += new NotifyEvent(childDocumentModified); gd.OnDocumentStructureModified += new NotifyEvent(childDocumentStructureModified); gd.OnDocumentSave += new NotifyEvent(childDocumentSave); gd.OnDocumentRun += new NotifyEvent(childDocumentRun); gd.OnSelectionChanged += new NotifyEvent(childSelectionChanged); gd.DockAreas = WeifenLuo.WinFormsUI.Docking.DockAreas.Document; gd.Show(dockPanel); gd.SaveProject(); gd.LoadProcess(GetProjectObject(gd.FileName).GProcess(gd.ProcessName)); LoadRepository(); }
private GProject GetProjectObject(string name) { if (name == null) { throw new Exception(); } if (m_projectObjects.ContainsKey(name)) { return(m_projectObjects[name]); } //string source = m_WebService.GetProjectSource(name); string source = m_WebService.Get <String[]>("repository/source/" + name)[0]; Project project = Project.Deserialize(source); GProject gproject = new GProject(); gproject.Load(project); m_projectObjects.Add(name, gproject); return(gproject); }
private void SaveDocument(GProject gproject, string pathname) { Project project = gproject.BaseProject; string s = Project.Serialize(project); try { int id = 0;//! m_WebService.Load(s); if (id == 0) { string error = "";//! m_WebService.LoadErrors(s); MessageBox.Show("Error in function: " + error); } } catch (Exception ex) { StreamWriter w = new StreamWriter("debug.cs"); w.Write(ex.Message); w.Close(); MessageBox.Show(ex.Message); } }
/// <summary> /// Program entry point /// </summary> /// <param name="args"></param> static void Main(string[] args) { #region preproceiing parsing the user inputs Console.WriteLine("Parsing given parameters..."); //Using the filename provided as the first argument string fileName = args[0]; //Using the years defined in the second argument string years = args[1]; string[] yearsSplit = years.Split(','); List<int> yearsList = new List<int>(); int temp; foreach (string y in yearsSplit) if (int.TryParse(y, out temp)) yearsList.Add(temp); //Using the pathways and mix id provided in the third argument string pm = args[2]; string[] pms = pm.Split(','); List<InputResourceReference> inRef = new List<InputResourceReference>(); foreach (string s in pms) { if (s[0] == 'p') {//this is a pathway reference if (int.TryParse(s.Substring(1, s.Length - 1), out temp)) { InputResourceReference pRef = new InputResourceReference(-1, temp, Enumerators.SourceType.Pathway); inRef.Add(pRef); } } else if (s[0] == 'm') {//this is a mix reference if (int.TryParse(s.Substring(1, s.Length - 1), out temp)) { InputResourceReference mRef = new InputResourceReference(-1, temp, Enumerators.SourceType.Mix); inRef.Add(mRef); } } } #endregion #region loading units file and data file Console.WriteLine("Building units context..."); //Build units context before loading the database Units.BuildContext(); Console.WriteLine("Loading datafile..."); //Loading the database GProject project = new GProject(); project.Load(fileName); #endregion #region preprocessing the pathways/mixes we want to record by finding their main output resource //Assign main output resource IDs to all the inputsResourceReferences foreach (InputResourceReference iref in inRef) { if (iref.SourceType == Greet.DataStructureV4.Interfaces.Enumerators.SourceType.Pathway) { if (project.Dataset.PathwaysData.ContainsKey(iref.SourceMixOrPathwayID)) iref.ResourceId = project.Dataset.PathwaysData[iref.SourceMixOrPathwayID].MainOutputResourceID; } else if (iref.SourceType == Greet.DataStructureV4.Interfaces.Enumerators.SourceType.Mix) { if (project.Dataset.MixesData.ContainsKey(iref.SourceMixOrPathwayID)) iref.ResourceId = project.Dataset.MixesData[iref.SourceMixOrPathwayID].MainOutputResourceID; } } #endregion #region running the calculations for each year and storing the results //Creating a new instance of a dictionary used to store results of the simulations Dictionary<InputResourceReference, Dictionary<int, Results>> savedResults = new Dictionary<InputResourceReference, Dictionary<int, Results>>(); //Running simulations for every provided years foreach (int simulationYear in yearsList) { Console.WriteLine("Running calculations for year " + simulationYear); //Set the current year for simulations BasicParameters.SelectedYear = project.Dataset.ParametersData.CreateUnregisteredParameter(project.Dataset, "", simulationYear); Calculator calc = new Calculator(); //Run the simulations for the loaded project and defined year, we need to wait completion as the RunCalculationMethod is Async var manualEvent = new ManualResetEvent(false); calc.CalculationDoneEvent += () => manualEvent.Set(); calc.RunCalculations(project); manualEvent.WaitOne(); //Loop over all the pathways and mixes ID that we wish to save foreach (InputResourceReference pathMixToSave in inRef) { if (!savedResults.ContainsKey(pathMixToSave)) savedResults.Add(pathMixToSave, new Dictionary<int, Results>()); if(!savedResults[pathMixToSave].ContainsKey(simulationYear)) { //Pull the results and add them to the dictionary used to store results Results results; if(pathMixToSave.SourceType == Enumerators.SourceType.Pathway) results = Convenience.Clone(project.Dataset.PathwaysData[pathMixToSave.SourceMixOrPathwayID].getMainOutputResults().Results); else results = Convenience.Clone(project.Dataset.MixesData[pathMixToSave.SourceMixOrPathwayID].getMainOutputResults().Results); savedResults[pathMixToSave].Add(simulationYear, results); } } } #endregion #region exporting all the results in a text file per pathway and per mix //Export all the desired results to an Excel spreadsheet Console.WriteLine("Export all selected results..."); string preferedMass = "g"; string preferedEnergy = "Btu"; string preferedVolume = "gal"; foreach (KeyValuePair<InputResourceReference, Dictionary<int, Results>> pair in savedResults) { DataTable dt = new DataTable(); List<string> resGroups = new List<string>() { "Total Energy", "Fossil Fuel", "Coal Fuel", "Natural Gas Fuel", "Petroleum Fuel", "Water" }; List<string> pollutants = new List<string>() { "VOC", "CO", "NOx", "PM10", "PM2.5", "SOx", "BC", "POC", "CH4", "N2O", "CO2", "CO2_Biogenic" }; List<string> polGroups = new List<string>() { "GHG-100" }; List<string> urbanPoll = new List<string>() { "VOC", "CO", "NOx", "PM10", "PM2.5", "SOx", "BC", "POC", "CH4", "N2O" }; Results resultsFU = pair.Value.Values.FirstOrDefault(); string functionalUnit = "Per "; if (resultsFU != null) functionalUnit += GetPreferedVisualizationFunctionalUnitString(project.Dataset, resultsFU, pair.Key.ResourceId); dt.Columns.Add("Items " + functionalUnit); foreach (int simulationYear in pair.Value.Keys) dt.Columns.Add(simulationYear.ToString()); List<string> rowString = new List<string>(); #region total energy and energy groups foreach (string resGrp in resGroups) { rowString = new List<string>(); if (resGrp=="Water") rowString.Add(resGrp+" ("+preferedVolume+")"); else rowString.Add(resGrp + " (" + preferedEnergy + ")"); foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); if (resGrp == "Total Energy") { LightValue totalE = results.wellToProductEnem.materialsAmounts.TotalEnergy(); rowString.Add(NiceValueWithAttribute(totalE * amountRatio, preferedEnergy)); } else { Dictionary<int, IValue> resGroupes = results.WellToProductResourcesGroups(project.Dataset); Group resGrpSelected = project.Dataset.ResourcesData.Groups.Values.SingleOrDefault(item => item.Name == resGrp); if (resGrpSelected != null) { int resGrpId = resGrpSelected.Id; LightValue groupValue = new LightValue(resGroupes[resGrpId].Value, resGroupes[resGrpId].UnitExpression); if (groupValue.Dim == DimensionUtils.ENERGY) rowString.Add(NiceValueWithAttribute(groupValue * amountRatio, preferedEnergy)); else rowString.Add(NiceValueWithAttribute(groupValue * amountRatio, preferedVolume)); } else rowString.Add("0"); } } dt.Rows.Add(rowString.ToArray()); } #endregion #region wtp emissions foreach (string poll in pollutants) { rowString = new List<string>(); rowString.Add(poll+" ("+preferedMass+")"); foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); int polId = project.Dataset.GasesData.Values.Single(item => item.Name == poll).Id; rowString.Add(NiceValueWithAttribute( new LightValue(results.wellToProductEnem.emissions[polId], DimensionUtils.MASS) * amountRatio , preferedMass)); } dt.Rows.Add(rowString.ToArray()); } #endregion #region wtp Groups (here only GHG 100) foreach (string resGrp in polGroups) { rowString = new List<string>(); rowString.Add(resGrp+ " ("+ preferedMass+")"); foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); Dictionary<int, IValue> emGroupes = pair.Value[simulationYear].WellToProductEmissionsGroups(project.Dataset); Group resGrpSelected = project.Dataset.GasesData.Groups.Values.SingleOrDefault(item => item.Name == resGrp); if (resGrpSelected != null) { int grpId = resGrpSelected.Id; rowString.Add(NiceValueWithAttribute(new LightValue(emGroupes[grpId].Value, emGroupes[grpId].UnitExpression) * amountRatio, preferedMass)); } else rowString.Add("0"); } dt.Rows.Add(rowString.ToArray()); } #endregion #region urban emissions foreach (string poll in pollutants) { rowString = new List<string>(); rowString.Add("Urban " +poll+" ("+preferedMass+")"); foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); int polId = project.Dataset.GasesData.Values.Single(item => item.Name == poll).Id; rowString.Add(NiceValueWithAttribute(new LightValue(results.wellToProductUrbanEmission[polId], DimensionUtils.MASS) * amountRatio, preferedMass)); } dt.Rows.Add(rowString.ToArray()); } #endregion string value = ConvertDataTableToString(dt); System.IO.File.WriteAllText("Results-" + pair.Key.SourceType.ToString() + "-" + pair.Key.SourceMixOrPathwayID.ToString() + ".txt", value); } #endregion }
private void repositoryDocumentDelete(object sender) { TreeNode node = sender as TreeNode; if (node.Tag is Process) { string pathname = node.Parent.Tag as string; GraphDoc doc = null, todel = null; foreach (object o in dockPanel.Documents) { if (o is GraphDoc) { GraphDoc d = o as GraphDoc; if (d.FileName == pathname) { if (d.ProcessName != node.Text) { doc = d; doc.Modified = true; } else { todel = d; } } } } if (todel != null) { todel.Modified = false; todel.Close(); } GProject g = GetProjectObject(pathname); g.RemoveProcess(node.Text); if (g.BaseProject.StartUpProcess == node.Text) { if (g.BaseProject.ProcessList.Count() > 0) { string entry = g.BaseProject.ProcessList[0].Name; g.BaseProject.StartUpProcess = entry; node.Parent.Nodes[entry].ImageIndex = 7; node.Parent.Nodes[entry].SelectedImageIndex = 7; } } if (doc == null) { SaveDocument(g, pathname); } else { RefreshDocuments(); } node.Remove(); } else if (node.Tag is string) { string pathname = node.Tag as string; List <GraphDoc> todel = new List <GraphDoc>(); foreach (object o in dockPanel.Documents) { if (o is GraphDoc) { GraphDoc d = o as GraphDoc; if (d.FileName == pathname) { todel.Add(d); } } } foreach (GraphDoc d in todel) { d.Modified = false; d.Close(); } FreeProjectObject(pathname); //! m_WebService.Unload(m_WebService.GetProjectID(pathname)); node.Remove(); } }
private void childDocumentRun(object sender) { GProject g = (sender as GraphDoc).GProject; RunProject((sender as GraphDoc).FileName); }
/// <summary> /// Program entry point /// </summary> /// <param name="args"></param> static void Main(string[] args) { #region preproceiing parsing the user inputs Console.WriteLine("Parsing given parameters..."); //Using the filename provided as the first argument string fileName = args[0]; //Using the years defined in the second argument string years = args[1]; string[] yearsSplit = years.Split(','); List <int> yearsList = new List <int>(); int temp; foreach (string y in yearsSplit) { if (int.TryParse(y, out temp)) { yearsList.Add(temp); } } //Using the pathways and mix id provided in the third argument string pm = args[2]; string[] pms = pm.Split(','); List <InputResourceReference> inRef = new List <InputResourceReference>(); foreach (string s in pms) { if (s[0] == 'p') {//this is a pathway reference if (int.TryParse(s.Substring(1, s.Length - 1), out temp)) { InputResourceReference pRef = new InputResourceReference(-1, temp, Enumerators.SourceType.Pathway); inRef.Add(pRef); } } else if (s[0] == 'm') {//this is a mix reference if (int.TryParse(s.Substring(1, s.Length - 1), out temp)) { InputResourceReference mRef = new InputResourceReference(-1, temp, Enumerators.SourceType.Mix); inRef.Add(mRef); } } } #endregion #region loading units file and data file Console.WriteLine("Building units context..."); //Build units context before loading the database Units.BuildContext(); Console.WriteLine("Loading datafile..."); //Loading the database GProject project = new GProject(); project.Load(fileName); #endregion #region preprocessing the pathways/mixes we want to record by finding their main output resource //Assign main output resource IDs to all the inputsResourceReferences foreach (InputResourceReference iref in inRef) { if (iref.SourceType == Greet.DataStructureV4.Interfaces.Enumerators.SourceType.Pathway) { if (project.Dataset.PathwaysData.ContainsKey(iref.SourceMixOrPathwayID)) { iref.ResourceId = project.Dataset.PathwaysData[iref.SourceMixOrPathwayID].MainOutputResourceID; } } else if (iref.SourceType == Greet.DataStructureV4.Interfaces.Enumerators.SourceType.Mix) { if (project.Dataset.MixesData.ContainsKey(iref.SourceMixOrPathwayID)) { iref.ResourceId = project.Dataset.MixesData[iref.SourceMixOrPathwayID].MainOutputResourceID; } } } #endregion #region running the calculations for each year and storing the results //Creating a new instance of a dictionary used to store results of the simulations Dictionary <InputResourceReference, Dictionary <int, Results> > savedResults = new Dictionary <InputResourceReference, Dictionary <int, Results> >(); //Running simulations for every provided years foreach (int simulationYear in yearsList) { Console.WriteLine("Running calculations for year " + simulationYear); //Set the current year for simulations BasicParameters.SelectedYear = project.Dataset.ParametersData.CreateUnregisteredParameter(project.Dataset, "", simulationYear); Calculator calc = new Calculator(); //Run the simulations for the loaded project and defined year, we need to wait completion as the RunCalculationMethod is Async var manualEvent = new ManualResetEvent(false); calc.CalculationDoneEvent += () => manualEvent.Set(); calc.RunCalculations(project); manualEvent.WaitOne(); //Loop over all the pathways and mixes ID that we wish to save foreach (InputResourceReference pathMixToSave in inRef) { if (!savedResults.ContainsKey(pathMixToSave)) { savedResults.Add(pathMixToSave, new Dictionary <int, Results>()); } if (!savedResults[pathMixToSave].ContainsKey(simulationYear)) { //Pull the results and add them to the dictionary used to store results Results results; if (pathMixToSave.SourceType == Enumerators.SourceType.Pathway) { results = Convenience.Clone(project.Dataset.PathwaysData[pathMixToSave.SourceMixOrPathwayID].getMainOutputResults().Results); } else { results = Convenience.Clone(project.Dataset.MixesData[pathMixToSave.SourceMixOrPathwayID].getMainOutputResults().Results); } savedResults[pathMixToSave].Add(simulationYear, results); } } } #endregion #region exporting all the results in a text file per pathway and per mix //Export all the desired results to an Excel spreadsheet Console.WriteLine("Export all selected results..."); string preferedMass = "g"; string preferedEnergy = "Btu"; string preferedVolume = "gal"; foreach (KeyValuePair <InputResourceReference, Dictionary <int, Results> > pair in savedResults) { DataTable dt = new DataTable(); List <string> resGroups = new List <string>() { "Total Energy", "Fossil Fuel", "Coal Fuel", "Natural Gas Fuel", "Petroleum Fuel", "Water" }; List <string> pollutants = new List <string>() { "VOC", "CO", "NOx", "PM10", "PM2.5", "SOx", "BC", "POC", "CH4", "N2O", "CO2", "CO2_Biogenic" }; List <string> polGroups = new List <string>() { "GHG-100" }; List <string> urbanPoll = new List <string>() { "VOC", "CO", "NOx", "PM10", "PM2.5", "SOx", "BC", "POC", "CH4", "N2O" }; Results resultsFU = pair.Value.Values.FirstOrDefault(); string functionalUnit = "Per "; if (resultsFU != null) { functionalUnit += GetPreferedVisualizationFunctionalUnitString(project.Dataset, resultsFU, pair.Key.ResourceId); } dt.Columns.Add("Items " + functionalUnit); foreach (int simulationYear in pair.Value.Keys) { dt.Columns.Add(simulationYear.ToString()); } List <string> rowString = new List <string>(); #region total energy and energy groups foreach (string resGrp in resGroups) { rowString = new List <string>(); if (resGrp == "Water") { rowString.Add(resGrp + " (" + preferedVolume + ")"); } else { rowString.Add(resGrp + " (" + preferedEnergy + ")"); } foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); if (resGrp == "Total Energy") { LightValue totalE = results.wellToProductEnem.materialsAmounts.TotalEnergy(); rowString.Add(NiceValueWithAttribute(totalE * amountRatio, preferedEnergy)); } else { Dictionary <int, IValue> resGroupes = results.WellToProductResourcesGroups(project.Dataset); Group resGrpSelected = project.Dataset.ResourcesData.Groups.Values.SingleOrDefault(item => item.Name == resGrp); if (resGrpSelected != null) { int resGrpId = resGrpSelected.Id; LightValue groupValue = new LightValue(resGroupes[resGrpId].Value, resGroupes[resGrpId].UnitExpression); if (groupValue.Dim == DimensionUtils.ENERGY) { rowString.Add(NiceValueWithAttribute(groupValue * amountRatio, preferedEnergy)); } else { rowString.Add(NiceValueWithAttribute(groupValue * amountRatio, preferedVolume)); } } else { rowString.Add("0"); } } } dt.Rows.Add(rowString.ToArray()); } #endregion #region wtp emissions foreach (string poll in pollutants) { rowString = new List <string>(); rowString.Add(poll + " (" + preferedMass + ")"); foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); int polId = project.Dataset.GasesData.Values.Single(item => item.Name == poll).Id; rowString.Add(NiceValueWithAttribute( new LightValue(results.wellToProductEnem.emissions[polId], DimensionUtils.MASS) * amountRatio , preferedMass)); } dt.Rows.Add(rowString.ToArray()); } #endregion #region wtp Groups (here only GHG 100) foreach (string resGrp in polGroups) { rowString = new List <string>(); rowString.Add(resGrp + " (" + preferedMass + ")"); foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); Dictionary <int, IValue> emGroupes = pair.Value[simulationYear].WellToProductEmissionsGroups(project.Dataset); Group resGrpSelected = project.Dataset.GasesData.Groups.Values.SingleOrDefault(item => item.Name == resGrp); if (resGrpSelected != null) { int grpId = resGrpSelected.Id; rowString.Add(NiceValueWithAttribute(new LightValue(emGroupes[grpId].Value, emGroupes[grpId].UnitExpression) * amountRatio, preferedMass)); } else { rowString.Add("0"); } } dt.Rows.Add(rowString.ToArray()); } #endregion #region urban emissions foreach (string poll in pollutants) { rowString = new List <string>(); rowString.Add("Urban " + poll + " (" + preferedMass + ")"); foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); int polId = project.Dataset.GasesData.Values.Single(item => item.Name == poll).Id; rowString.Add(NiceValueWithAttribute(new LightValue(results.wellToProductUrbanEmission[polId], DimensionUtils.MASS) * amountRatio, preferedMass)); } dt.Rows.Add(rowString.ToArray()); } #endregion string value = ConvertDataTableToString(dt); System.IO.File.WriteAllText("Results-" + pair.Key.SourceType.ToString() + "-" + pair.Key.SourceMixOrPathwayID.ToString() + ".txt", value); } #endregion }