private void EnsureSheetHaveColumns(DataSheet sheet, IEnumerable<string> columnNames) { var newNames = columnNames.Except(sheet.Rows[0].Keys); foreach (var name in newNames) { foreach (var row in sheet.Rows) row.Add(name, string.Empty); } }
private void CheckSheetConsistence(DataSheet sheet) { var columnNames = new HashSet<string>(sheet.Rows[0].Keys); foreach (var row in sheet.Rows) { if (!columnNames.SetEquals(row.Keys)) { throw new Exception( string.Format("{0} columns mismatch: ({1}),({2})", sheet.Name, JsonOperation.Serialize(columnNames), JsonOperation.Serialize(row))); } } }
public void Load(DataFeed dataFeed) { Debug.Assert(this.m_DataFeed == null); this.m_DataFeed = dataFeed; this.m_FlowDiagramSheet = dataFeed.Scenario.GetDataSheet(Constants.DATASHEET_FLOW_PATHWAY_DIAGRAM_NAME); this.m_FlowDiagramData = this.m_FlowDiagramSheet.GetData(); this.m_FlowPathwaySheet = dataFeed.Scenario.GetDataSheet(Constants.DATASHEET_FLOW_PATHWAY_NAME); this.m_FlowPathwayData = this.m_FlowPathwaySheet.GetData(); this.RefreshDiagram(); }
protected override void OnDataFeedsRefreshed() { base.OnDataFeedsRefreshed(); this.m_TTData = this.GetData(); this.m_TGDataSheet = this.Project.GetDataSheet(Strings.DATASHEET_TRANSITION_GROUP_NAME); this.m_TGData = this.m_TGDataSheet.GetData(); this.m_TTGDataSheet = this.Project.GetDataSheet(Strings.DATASHEET_TRANSITION_TYPE_GROUP_NAME); this.m_TTGData = this.m_TTGDataSheet.GetData(); this.m_TTGDataSheet.RowsAdded += this.OnTTGRowsAdded; }
/// <summary> /// 找出某工作表在数据库集合中所对应的那一项,如果没有对应项,则返回Nothing /// </summary> /// <param name="DataSheet">要进行匹配的Excel工作表</param> /// <param name="DatasheetCollection">要进行搜索的数据库集合。</param> private DataSheet CorrespondingInCollection(Worksheet DataSheet, List <DataSheet> DatasheetCollection) { DataSheet dtSheet = null; foreach (DataSheet dbSheet in this.F_DbSheets) { if (ExcelFunction.SheetCompare(dbSheet.WorkSheet, DataSheet)) { dtSheet = dbSheet; break; } } return(dtSheet); }
private string GetProjectItemName(string dataSheetName, int id) { Debug.Assert(id != AttributeValueReference.TST_VALUE_NULL); if (id == AttributeValueReference.TST_GROUP_WILD) { return("NULL"); } else { DataSheet ds = this.m_Project.GetDataSheet(dataSheetName); return(ds.ValidationTable.GetDisplayName(id)); } }
/// <summary> /// Initializes tabular output options /// </summary> /// <remarks></remarks> private void InitializeTabularOutputOptions() { Func <object, int> SafeInt = (object o) => { if (o == DBNull.Value) { return(0); } else { return(Convert.ToInt32(o, CultureInfo.InvariantCulture)); } }; DataRow droo = this.ResultScenario.GetDataSheet(Strings.DATASHEET_OO_TABULAR_NAME).GetDataRow(); this.m_CreateSummaryStateClassOutput = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_SC_COLUMN_NAME]); this.m_SummaryStateClassOutputTimesteps = SafeInt(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_SC_TIMESTEPS_COLUMN_NAME]); this.m_SummaryStateClassOutputAges = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_SC_AGES_COLUMN_NAME]); this.m_SummaryStateClassZeroValues = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_SC_ZERO_VALUES_COLUMN_NAME]); this.m_CreateSummaryTransitionOutput = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_TR_COLUMN_NAME]); this.m_SummaryTransitionOutputTimesteps = SafeInt(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_TR_TIMESTEPS_COLUMN_NAME]); this.m_SummaryTransitionOutputAges = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_TR_AGES_COLUMN_NAME]); this.m_SummaryTransitionOutputAsIntervalMean = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_TR_INTERVAL_MEAN_COLUMN_NAME]); this.m_CreateSummaryTransitionByStateClassOutput = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_TRSC_COLUMN_NAME]); this.m_SummaryTransitionByStateClassOutputTimesteps = SafeInt(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_TRSC_TIMESTEPS_COLUMN_NAME]); this.m_CreateSummaryStateAttributeOutput = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_SA_COLUMN_NAME]); this.m_SummaryStateAttributeOutputTimesteps = SafeInt(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_SA_TIMESTEPS_COLUMN_NAME]); this.m_SummaryStateAttributeOutputAges = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_SA_AGES_COLUMN_NAME]); this.m_CreateSummaryTransitionAttributeOutput = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_TA_COLUMN_NAME]); this.m_SummaryTransitionAttributeOutputTimesteps = SafeInt(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_TA_TIMESTEPS_COLUMN_NAME]); this.m_SummaryTransitionAttributeOutputAges = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_TA_AGES_COLUMN_NAME]); this.m_CreateSummaryExternalVariableOutput = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_EV_COLUMN_NAME]); this.m_SummaryExternalVariableOutputTimesteps = SafeInt(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_EV_TIMESTEPS_COLUMN_NAME]); this.m_CreateSummaryTSTOutput = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_TST_COLUMN_NAME]); this.m_SummaryTSTOutputTimesteps = SafeInt(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_TST_TIMESTEPS_COLUMN_NAME]); this.m_SummaryOmitSecondaryStrata = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_OMIT_SS_COLUMN_NAME]); this.m_SummaryOmitTertiaryStrata = DataTableUtilities.GetDataBool(droo[Strings.DATASHEET_OO_SUMMARY_OUTPUT_OMIT_TS_COLUMN_NAME]); if (this.m_SummaryTransitionOutputAsIntervalMean) { DataSheet ds = this.Project.GetDataSheet(Strings.DATASHEET_SIZE_CLASS_NAME); if (ds.GetData().Rows.Count > 0) { this.RecordStatus(StatusType.Information, "Transition Summary Output won't include size information if Interval Mean selected."); } } }
private void FillInitialStocksNonSpatial() { Debug.Assert(this.m_InitialStocksNonSpatial.Count == 0); DataSheet ds = this.ResultScenario.GetDataSheet(Constants.DATASHEET_INITIAL_STOCK_NON_SPATIAL); foreach (DataRow dr in ds.GetData().Rows) { this.m_InitialStocksNonSpatial.Add( new InitialStockNonSpatial( Convert.ToInt32(dr[ds.PrimaryKeyColumn.Name], CultureInfo.InvariantCulture), Convert.ToInt32(dr[Constants.STOCK_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture), Convert.ToInt32(dr[Constants.STATE_ATTRIBUTE_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture))); } }
private void UpdateOutputDataSheet(int iteration, int timestep) { DataSheet ds = this.ResultScenario.GetDataSheet("Circuitscape_OutputFile"); string OutFolderName = this.Library.GetFolderName(LibraryFolderType.Output, ds, true); string BaseName = string.Format(CultureInfo.InvariantCulture, "Circuitscape-It{0}-Ts{1}_cum_curmap", iteration, timestep); string AsciiName = Path.Combine(OutFolderName, BaseName + ".asc"); string TifName = Path.Combine(OutFolderName, BaseName + ".tif"); Spatial.ConvertFromAAIGridFormat(AsciiName, TifName, GeoTiffCompressionType.DEFLATE); DataTable dt = ds.GetData(); dt.Rows.Add(new object[] { iteration, timestep, Path.GetFileName(TifName) }); }
private static string CreateRawChartDataQueryForGroup( DataSheet dataSheet, ChartDescriptor descriptor, string variableName) { Debug.Assert(dataSheet.Scenario.Id > 0); Debug.Assert( variableName == STOCK_GROUP_VAR_NAME || variableName == STOCK_GROUP_DENSITY_VAR_NAME || variableName == FLOW_GROUP_VAR_NAME || variableName == FLOW_GROUP_DENSITY_VAR_NAME); string ScenarioClause = string.Format(CultureInfo.InvariantCulture, "([{0}]={1})", Constants.SCENARIO_ID_COLUMN_NAME, dataSheet.Scenario.Id); string SumStatement = string.Format(CultureInfo.InvariantCulture, "SUM([{0}]) AS {1}", descriptor.ColumnName, Constants.SUM_OF_AMOUNT_COLUMN_NAME); string WhereClause = ScenarioClause; if (!string.IsNullOrEmpty(descriptor.DisaggregateFilter)) { WhereClause = string.Format(CultureInfo.InvariantCulture, "{0} AND ({1})", WhereClause, descriptor.DisaggregateFilter); } if (!string.IsNullOrEmpty(descriptor.IncludeDataFilter)) { WhereClause = string.Format(CultureInfo.InvariantCulture, "{0} AND ({1})", WhereClause, descriptor.IncludeDataFilter); } string query = string.Format(CultureInfo.InvariantCulture, "SELECT {0},{1},{2} FROM {3} WHERE {4} GROUP BY [{5}],[{6}]", Constants.ITERATION_COLUMN_NAME, Constants.TIMESTEP_COLUMN_NAME, SumStatement, descriptor.DatasheetName, WhereClause, Constants.ITERATION_COLUMN_NAME, Constants.TIMESTEP_COLUMN_NAME); return(query); }
private void FillActualDeathCollection(DateTime startDate) { Debug.Assert(this.m_ActualDeaths.Count == 0); DataSheet ds = this.ResultScenario.GetDataSheet(Shared.DATASHEET_ACTUAL_DEATH_NAME); foreach (DataRow dr in ds.GetData().Rows) { int?timestep = null; if (!TimestepFromDateTime(dr, startDate, out timestep)) { continue; } DistributionFrequency?df = null; if (dr[Shared.DISTRIBUTION_FREQUENCY_COLUMN_NAME] != DBNull.Value) { df = (DistributionFrequency)(long)dr[Shared.DISTRIBUTION_FREQUENCY_COLUMN_NAME]; } ActualDeath Item = new ActualDeath( Shared.GetNullableInt(dr, Shared.ITERATION_COLUMN_NAME), timestep, Shared.GetNullableInt(dr, Shared.JURISDICTION_COLUMN_NAME), Shared.GetNullableDouble(dr, Shared.VALUE_COLUMN_NAME), Shared.GetNullableInt(dr, Shared.DISTRIBUTION_TYPE_COLUMN_NAME), df, Shared.GetNullableDouble(dr, Shared.DISTRIBUTIONSD_COLUMN_NAME), Shared.GetNullableDouble(dr, Shared.DISTRIBUTIONMIN_COLUMN_NAME), Shared.GetNullableDouble(dr, Shared.DISTRIBUTIONMAX_COLUMN_NAME)); try { this.m_DistributionProvider.Validate( Item.DistributionTypeId, Item.DistributionValue, Item.DistributionSD, Item.DistributionMin, Item.DistributionMax); this.m_ActualDeaths.Add(Item); } catch (Exception ex) { throw new ArgumentException(ds.DisplayName + " -> " + ex.Message); } } }
/* When a new type is chosen in the dialog, switch visibilities */ private void HandleDataSheetChanged(DataSheet dataSheet) { if (dataSheet is HeatingUnitDataSheet || dataSheet is SolarCollectorDataSheet) { IsHeatingOrSolar = true; IsContainer = false; OnPropertyChanged("IsWaterContainer"); } else if (dataSheet is ContainerDataSheet) { IsContainer = true; IsHeatingOrSolar = false; IsWaterContainer = false; /* We don't know this yet, so just default it */ } }
public DataSheet Read(string name) { var sheet = mWorkbook.GetSheet(name); var dsheet = new DataSheet() { Name = sheet.SheetName }; var titles = (from cell in sheet.GetRow(mTitleRow).Cells where !string.IsNullOrEmpty(cell.StringCellValue) select new KeyValuePair<int, string>(cell.ColumnIndex, cell.StringCellValue)).ToArray(); for (int i = mContentRow, last = sheet.LastRowNum; i <= last; ++i) { var row = sheet.GetRow(i); if (row != null) dsheet.Rows.Add(ReadRow(row, titles)); } return dsheet; }
private void RefreshDateTimeControls() { DataSheet ds = this.Scenario.GetDataSheet(Shared.DATASHEET_RUN_CONTROL_NAME); DataRow dr = ds.GetDataRow(); if (dr != null && dr[Shared.DATASHEET_RUN_CONTROL_START_DATE_COLUMN_NAME] != DBNull.Value) { this.DateTimeStart.Value = (DateTime)dr[Shared.DATASHEET_RUN_CONTROL_START_DATE_COLUMN_NAME]; } if (dr != null && dr[Shared.DATASHEET_RUN_CONTROL_END_DATE_COLUMN_NAME] != DBNull.Value) { this.DateTimeEnd.Value = (DateTime)dr[Shared.DATASHEET_RUN_CONTROL_END_DATE_COLUMN_NAME]; } }
private void OnGridCellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { if (e.ColumnIndex == this.m_Grid.Columns[Strings.DATASHEET_TRANSITION_GROUP_ID_COLUMN_NAME].Index) { DataGridViewRow dgv = this.m_Grid.Rows[e.RowIndex]; DataSheet ds = this.Project.GetDataSheet(Strings.DATASHEET_TRANSITION_GROUP_NAME); string filter = "IsAuto IS NULL OR IsAuto=0"; DataView dv = new DataView(ds.GetData(), filter, ds.DisplayMember, DataViewRowState.CurrentRows); DataGridViewComboBoxCell Cell = (DataGridViewComboBoxCell)dgv.Cells[Strings.DATASHEET_TRANSITION_GROUP_ID_COLUMN_NAME]; Cell.DataSource = dv; Cell.ValueMember = ds.ValueMember; Cell.DisplayMember = ds.DisplayMember; } }
private void InitUserInteractive() { DataSheet ds = this.Library.GetDataSheet(Shared.APPLICATION_DATASHEET_NAME); DataRow dr = ds.GetDataRow(); if (dr == null || dr[Shared.APPLICATION_DATASHEET_USER_INTERACTIVE_COLUMN_NAME] == DBNull.Value) { this.m_IsUserInteractive = false; } else { this.m_IsUserInteractive = Booleans.BoolFromValue( dr[Shared.APPLICATION_DATASHEET_USER_INTERACTIVE_COLUMN_NAME]); } }
public static Dictionary <int, bool> CreateRecordLookup(DataSheet ds, string colName) { Dictionary <int, bool> d = new Dictionary <int, bool>(); DataTable dt = ds.GetData(); foreach (DataRow dr in dt.Rows) { if (dr.RowState != DataRowState.Deleted) { d.Add(Convert.ToInt32(dr[colName], CultureInfo.InvariantCulture), true); } } return(d); }
private IEnumerable <ParsedDataSet> buildDataSets(DataSheet dataSheet, IEnumerable <string> groupingParameters, Cache <string, ColumnInfo> columnInfos) { var cachedUnformattedRows = new Cache <string, List <UnformattedRow> >(); foreach (var row in dataSheet.GetRows(_ => true)) { var id = rowId(groupingParameters, dataSheet, row); if (!cachedUnformattedRows.Contains(id)) { cachedUnformattedRows.Add(id, new List <UnformattedRow>()); } cachedUnformattedRows[id].Add(row); } return(cachedUnformattedRows.Select(rows => new ParsedDataSet(groupingParameters, dataSheet, rows, parseMappings(rows, dataSheet, columnInfos)))); }
private AcukwikDataSet.AcukwikAirportsDataTable AttemptToConvertFormat(DataSheet supportedDataSheet, DataTable uploadedSheetTable) { AcukwikDataSet.AcukwikAirportsDataTable result = new AcukwikDataSet.AcukwikAirportsDataTable(); try { if (!supportedDataSheet.PopulateRowsFromData(result, uploadedSheetTable)) { return(null); } } catch (Exception exception) { throw new Exception(exception.ToString()); } return(result); }
private SchedulingDataSet.SchedulingImportsDataTable AttemptToConvertFormat(DataSheet supportedDataSheet) { SchedulingDataSet.SchedulingImportsDataTable result = new SchedulingDataSet.SchedulingImportsDataTable(); try { if (!supportedDataSheet.PopulateRowsFromData(result, _UploadedSheetTable)) { return(null); } } catch (Exception exception) { throw new Exception(exception.ToString()); } return(result); }
private void ButtonChooseTemplate_Click(object sender, System.EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Choose File"; dlg.Filter = "NetLogo Files|*.nlogo"; if (dlg.ShowDialog(this) == DialogResult.OK) { DataSheet ds = this.DataFeed.GetDataSheet("netlogo_Script"); ds.AddExternalInputFile(dlg.FileName); ds.SetSingleRowData("TemplateFile", Path.GetFileName(dlg.FileName)); this.RefreshBoundControls(); } }
private void FillFlowMultiplierTypes() { Debug.Assert(this.m_FlowMultiplierTypes.Count == 0); DataSheet ds = this.Project.GetDataSheet(Constants.DATASHEET_FLOW_MULTIPLIER_TYPE_NAME); //Always add type with a Null Id because flow multipliers can have null types. this.m_FlowMultiplierTypes.Add(new FlowMultiplierType(null, this.ResultScenario, this.m_STSimTransformer.DistributionProvider)); foreach (DataRow dr in ds.GetData().Rows) { int FlowMultiplierTypeId = Convert.ToInt32(dr[ds.PrimaryKeyColumn.Name], CultureInfo.InvariantCulture); this.m_FlowMultiplierTypes.Add(new FlowMultiplierType (FlowMultiplierTypeId, this.ResultScenario, this.m_STSimTransformer.DistributionProvider)); } }
public IEnumerable <ParsedDataSet> Parse(DataSheet dataSheet, ColumnInfoCache columnInfos) { var missingColumns = Parameters.Where(p => p.ComesFromColumn() && dataSheet.GetColumnDescription(p.ColumnName) == null).Select(p => p.ColumnName).ToList(); if (missingColumns.Any()) { throw new MissingColumnException(dataSheet.SheetName, missingColumns); } var groupingCriteria = Parameters .Where(p => p.IsGroupingCriterion()) .Select(p => p.ColumnName); return(buildDataSets(dataSheet, groupingCriteria, columnInfos)); }
private string CreateQuickViewTitle() { StringBuilder sb = new StringBuilder(); FlowPathwayDiagram d = this.GetFlowDiagram(); DataSheet ds = this.DataFeed.Project.GetDataSheet(Constants.DATASHEET_STOCK_TYPE_NAME); sb.AppendFormat(CultureInfo.InvariantCulture, "{0} - ", this.DataFeed.Scenario.DisplayName); foreach (StockTypeShape s in d.SelectedShapes) { object v = DataTableUtilities.GetTableValue(ds.GetData(), ds.ValueMember, s.StockTypeId, ds.DisplayMember); sb.AppendFormat(CultureInfo.InvariantCulture, "{0},", Convert.ToString(v, CultureInfo.InvariantCulture)); } return(sb.ToString().Trim(',')); }
protected override void Context() { sut = new MixColumnsDataFormat(); _rawDataSheet = A.Fake <DataSheet>(); A.CallTo(() => _rawDataSheet.GetHeaders()).ReturnsLazily(() => _headers); A.CallTo(() => _rawDataSheet.GetColumnDescription(A <string> .Ignored)).Returns(new ColumnDescription(0) { Level = ColumnDescription.MeasurementLevel.Numeric }); _columnInfos = new ColumnInfoCache { new ColumnInfo { DisplayName = "Time", Name = "Time" }, new ColumnInfo { DisplayName = "Concentration", Name = "Concentration" }, new ColumnInfo { DisplayName = "Error", Name = "Error", IsMandatory = false, RelatedColumnOf = "Concentration" } }; _columnInfos["Time"].SupportedDimensions.Add(DimensionFactoryForSpecs.TimeDimension); _columnInfos["Concentration"].SupportedDimensions.Add(DimensionFactoryForSpecs.ConcentrationDimension); _columnInfos["Error"].SupportedDimensions.Add(DimensionFactoryForSpecs.ConcentrationDimension); _metaDataCategories = new List <MetaDataCategory>() { new MetaDataCategory { Name = "Organ" }, new MetaDataCategory { Name = "Compartment" }, new MetaDataCategory { Name = "Species" }, new MetaDataCategory { Name = "Dose" }, new MetaDataCategory { Name = "Molecule" }, new MetaDataCategory { Name = "Route" } }; }
private void SetSpatialOutputDefaults(int MaxTimestep) { Debug.Assert(this.m_IsSpatial); DataSheet dsoo = this.ResultScenario.GetDataSheet(Strings.DATASHEET_OO_SPATIAL_NAME); DataRow droo = dsoo.GetDataRow(); if (droo == null) { droo = dsoo.GetData().NewRow(); dsoo.GetData().Rows.Add(droo); } DataTableUtilities.SetRowValue(droo, Strings.DATASHEET_OO_SPATIAL_RASTER_OUTPUT_SC_COLUMN_NAME, Booleans.BoolToInt(true)); DataTableUtilities.SetRowValue(droo, Strings.DATASHEET_OO_SPATIAL_RASTER_OUTPUT_SC_TIMESTEPS_COLUMN_NAME, MaxTimestep); DataTableUtilities.SetRowValue(droo, Strings.DATASHEET_OO_SPATIAL_RASTER_OUTPUT_TR_COLUMN_NAME, Booleans.BoolToInt(true)); DataTableUtilities.SetRowValue(droo, Strings.DATASHEET_OO_SPATIAL_RASTER_OUTPUT_TR_TIMESTEPS_COLUMN_NAME, MaxTimestep); }
private static void RefreshChartTSTClassValidationTable(string dataSheetName, Project project) { foreach (Scenario s in project.Results) { DataSheet ds = s.GetDataSheet(dataSheetName); DataSheetColumn col = ds.Columns[Strings.DATASHEET_TST_CLASS_COLUMN_NAME]; col.ValidationTable = CreateClassBinValidationTable( project, Strings.DATASHEET_TST_TYPE_NAME, Strings.DATASHEET_TST_TYPE_FREQUENCY_COLUMN_NAME, Strings.DATASHEET_TST_TYPE_MAXIMUM_COLUMN_NAME, Strings.DATASHEET_TST_GROUP_NAME, Strings.DATASHEET_TST_GROUP_MAXIMUM_COLUMN_NAME, Strings.TST_CLASS_VALIDATION_TABLE_NAME); } }
public DataSheetCollection GetDataSheetCollection(int schedulingId) { XmlDocument document = GetTemplateDocument(schedulingId); DataSheetCollection collection = new DataSheetCollection(); if (document == null) { return(collection); } foreach (XmlNode node in document.SelectNodes("//SchedulingSheets/SchedulingSheet")) { DataSheet sheet = new DataSheet(); sheet.LoadFromNode(node); collection.Add(sheet); } return(collection); }
public DataSheetCollection GetDataSheetCollection(string acukwikName) { XmlDocument document = GetTemplateDocument(acukwikName); DataSheetCollection collection = new DataSheetCollection(); if (document == null) { return(collection); } foreach (XmlNode node in document.SelectNodes("//AcukwikSheets/AcukwikSheet")) { DataSheet sheet = new DataSheet(); sheet.LoadFromNode(node); collection.Add(sheet); } return(collection); }
public DataSheetCollection GetDataSheetCollection(string clientName, string supplierName) { XmlDocument document = GetTemplateDocument(clientName, supplierName); DataSheetCollection collection = new DataSheetCollection(); if (document == null) { return(collection); } foreach (XmlNode node in document.SelectNodes("//FuelSheets/FuelSheet")) { DataSheet sheet = new DataSheet(); sheet.LoadFromNode(node); collection.Add(sheet); } return(collection); }
public static string GetJurisdictionLabel(DataSheet terminologyDataSheet) { DataRow dr = terminologyDataSheet.GetDataRow(); string JurisdictionLabel = "Jurisdiction"; if (dr != null) { if (dr[Shared.DATASHEET_TERMINOLOGY_JURISDICTION_LABEL_COLUMN_NAME] != DBNull.Value) { JurisdictionLabel = Convert.ToString( dr[Shared.DATASHEET_TERMINOLOGY_JURISDICTION_LABEL_COLUMN_NAME], CultureInfo.InvariantCulture); } } return(JurisdictionLabel); }
private void FillFlowTypes() { Debug.Assert(this.m_FlowTypes.Count == 0); DataSheet ds = this.Project.GetDataSheet(Constants.DATASHEET_FLOW_TYPE_NAME); foreach (DataRow dr in ds.GetData().Rows) { this.m_FlowTypes.Add( new FlowType( Convert.ToInt32(dr[ds.PrimaryKeyColumn.Name], CultureInfo.InvariantCulture), Convert.ToString(dr[ds.DisplayMember], CultureInfo.InvariantCulture))); } #if DEBUG this.m_FlowTypesFilled = true; #endif }
protected override UnitDescription ExtractUnits(string description, DataSheet dataSheet, List <string> keys, IReadOnlyList <IDimension> supportedDimensions, ref double rank) { var(_, unit) = UnitExtractor.ExtractNameAndUnit(description); if (string.IsNullOrEmpty(unit)) { return(new UnitDescription()); } unit = ValidateUnit(unit, supportedDimensions); if (unit != UnitDescription.InvalidUnit) { rank++; } return(new UnitDescription(unit)); }
public void Write(DataSheet dsheet) { if (dsheet.Rows.Count == 0) return; var sheet = mWorkbook.GetSheet(dsheet.Name); if (sheet == null) sheet = CreateSheet(dsheet); var titleRow = sheet.GetRow(mTitleRow); foreach (var newTitle in dsheet.Rows[0].Keys.Except(titleRow.Cells.Select(c => c.StringCellValue))) { titleRow.CreateCell(titleRow.LastCellNum).SetCellValue(newTitle); } var titles = (from cell in titleRow.Cells where !string.IsNullOrEmpty(cell.StringCellValue) select new KeyValuePair<int, string>(cell.ColumnIndex, cell.StringCellValue)).ToArray(); for (int i = mContentRow, end = mContentRow + dsheet.Rows.Count; i < end; ++i) { var row = sheet.GetRow(i); if (row == null) row = sheet.CreateRow(i); WriteRow(row, dsheet.Rows[i - mContentRow], titles); } for (int i = mContentRow + dsheet.Rows.Count, last = sheet.LastRowNum; i <= last; ++i) { var row = sheet.GetRow(i); if (row != null) sheet.RemoveRow(row); } }
private ISheet CreateSheet(DataSheet dsheet) { var sheet = mWorkbook.CreateSheet(dsheet.Name); for (var i = 0; i < mContentRow; ++i) sheet.CreateRow(i); var columnNames = dsheet.Rows[0].Keys.OrderBy(k => k).ToArray(); var titleRow = sheet.GetRow(mTitleRow); for (var i = 0; i < columnNames.Length; ++i) { titleRow.CreateCell(i).SetCellValue(columnNames[i]); } return sheet; }
private void MergeSheet(DataSheet destSheet, DataSheet srcSheet, string primaryKey) { CheckSheetConsistence(destSheet); CheckSheetConsistence(srcSheet); EnsureSheetHaveColumns(destSheet, srcSheet.Rows[0].Keys); var id2DestRow = new Dictionary<object, Dictionary<string, object>>(); foreach (var destRow in destSheet.Rows) id2DestRow[destRow[primaryKey]] = destRow; foreach (var srcRow in srcSheet.Rows) { var id = srcRow[primaryKey]; if (!id2DestRow.ContainsKey(id)) { throw new Exception(string.Format("Can't find primary key in dest sheet: {0}", id)); } Dictionary<string, object> destRow = id2DestRow[srcRow[primaryKey]]; foreach (var kv in srcRow) { destRow[kv.Key] = kv.Value; } } }
public override void Execute() { Log.Info("Start to replace string literals ..."); Log.Info("Read filter from: {0}", FilterPath); string className = Path.GetFileNameWithoutExtension(ResultPath); var filter = new HashSet<string>(File.ReadAllLines(FilterPath, Encoding.UTF8)); var str2Field = new Dictionary<string, string>(1024); foreach (var path in GetCSharpFiles(CSharpSrcDirectories)) { Log.Info("\tProcessing file: {0}", path); var encoding = Utils.DetectFileEncoding(path); var oldText = File.ReadAllText(path, encoding); var newText = NRefactoryTool.CodeTransform.ReplaceStringLiteralsWithVariables(oldText, Macros, (line, column, lineText, s) => { if (!filter.Contains(string.Format("{0}({1},{2}):{3}", path, line, column, NRefactoryTool.Utils.EscapeString(lineText)))) return null; string field; if (str2Field.TryGetValue(s, out field)) return field; field = string.Format("{0}.kString_{1}", className, str2Field.Count); str2Field.Add(s, field); return field; }); if (oldText != newText) { Log.Info("\tPerform replacement!"); File.WriteAllText(path, newText, encoding); } } Log.Info("Write sheet to: {0}", ResultPath); var sheet = new DataSheet { Name = className, Rows = (from kv in str2Field let fieldName = kv.Value.Split('.').Last() orderby fieldName select new Dictionary<string, object>(){ {kNameKey, fieldName }, {kDefaultLangKey, kv.Key} }).ToList(), }; File.WriteAllText(ResultPath, JsonOperation.SerializeSheets(new[] { sheet }), Encoding.UTF8); Log.Info("Done."); }