// BuildItemResults(output, part, "SIS-Prof1_PageNotes_item"); protected void BuildItemResults(PdfOutput output, def_Parts part, params object[] identifiersOrPairs) { foreach (object identOrPair in identifiersOrPairs) { if (identOrPair is string) { string ident = (string)identOrPair; def_Items itm = formsRepo.GetItemByIdentifier(ident); formsRepo.GetEnterpriseItems(new def_Items[] { itm }.ToList(), formResults.EnterpriseID.Value); if (itm == null) { throw new Exception("could not find item with identifier " + ident); } string rv = GetSingleResponse(itm); output.appendItem(itm.label.Replace("*", ""), (rv == null) ? "" : rv.Replace("@", "@ ")); } else if (identOrPair is LabelValuePair) { LabelValuePair p = (LabelValuePair)identOrPair; output.appendItem(p.label, p.value); } else { throw new Exception("unrecognized object type in parameter \"identifieresOrPairs\", objects must be of type string or pair"); } } }
/// <summary> /// Funzione per la creazione di un elemento XML con le informazioni /// su un campo profilato. /// </summary> /// <param name="entry">Coppia etichetta / valore</param> /// <returns>Elemento XML da aggiungere al data source per la creazione del documento M/Text</returns> private static XElement GetValue(LabelValuePair entry) { //return new XElement( // ClearString(entry.Key), // String.Format("![CDATA[{0}]]", entry.Value)); return(new XElement( ClearString(entry.Label), entry.Value)); }
private static List <LabelValuePair> GetColumnDefinition(List <CsvDataSource> tableRecords, List <ColumnDetail> columns) { List <LabelValuePair> columnDefinition = new List <LabelValuePair>(); foreach (var column in columns) { LabelValuePair columnDetails = new LabelValuePair(); columnDetails.Label = column.Name; columnDetails.Value = ""; List <CsvDataSource> columnRecords = tableRecords.Where(e => e.ColumnName.Equals(column.Name, StringComparison.OrdinalIgnoreCase)).ToList(); foreach (var record in columnRecords) { if (!record.ColumnDefinition.Equals("")) { columnDetails.Value = record.ColumnDefinition.Replace("\"", string.Empty).Trim(); columnDetails.Value = Regex.Replace(columnDetails.Value, @"\s+", " "); break; } } columnDefinition.Add(columnDetails); } return(columnDefinition); }
public static void GenerateFile(string sqlStatement, string outputFilePath, string tableName, List <CsvDataSource> csvDataSource) { var yamlFileMetadata = new YamlFileMetadata(); yamlFileMetadata.TableDefinition = ""; yamlFileMetadata.TableName = tableName; List <CsvDataSource> tableRecords = null; yamlFileMetadata.ColumnsWithNotNullTest = new List <string>(); var nullOptionsPresent = false; try { if (csvDataSource != null) { tableRecords = csvDataSource.Where(e => e.TableName.Equals(tableName, StringComparison.OrdinalIgnoreCase)).ToList(); foreach (var record in tableRecords) { if (record.NullOption != null) { nullOptionsPresent = true; break; } } if (nullOptionsPresent) { var NotNullRecords = tableRecords.Where(e => e.NullOption.Equals("Not Null", StringComparison.OrdinalIgnoreCase)).ToList(); yamlFileMetadata.ColumnsWithNotNullTest = NotNullRecords.Select(e => e.ColumnName).Distinct().ToList(); } } var columns = DDLParser.GetDdlStatementColumns(sqlStatement); if (tableRecords == null || !tableRecords.Any()) { List <LabelValuePair> columnsDetails = new List <LabelValuePair>(); foreach (var column in columns) { LabelValuePair columnDetails = new LabelValuePair(); columnDetails.Label = column.Name; columnDetails.Value = ""; columnsDetails.Add(columnDetails); } yamlFileMetadata.ColumnDefinition = columnsDetails; } else { yamlFileMetadata.TableDefinition = GetTableDefinition(tableRecords); yamlFileMetadata.ColumnDefinition = GetColumnDefinition(tableRecords, columns); } yamlFileMetadata.TableDefinition = Regex.Replace(yamlFileMetadata.TableDefinition, @"\s+", " "); tableName = tableName.ToLowerInvariant(); Logger.LogInfo("Generating yml file for " + tableName); if (tableName.Contains(Constants.HubFileName, StringComparison.OrdinalIgnoreCase)) { outputFilePath += "hubs"; } if (tableName.Contains(Constants.LnkFileName, StringComparison.OrdinalIgnoreCase)) { outputFilePath += "links"; } if (tableName.Contains(Constants.SatFileName, StringComparison.OrdinalIgnoreCase) || tableName.Contains(Constants.MasFileName, StringComparison.OrdinalIgnoreCase)) { if (tableName.Contains(Constants.SatBrFileName, StringComparison.OrdinalIgnoreCase)) { outputFilePath += "satellitebusinessrules"; } else { outputFilePath += "satellites"; } } Utility.CreateDirectoryIfDoesNotExists(outputFilePath); var yamlFileTemplate = new YamlFileTemplate(yamlFileMetadata); var content = yamlFileTemplate.TransformText(); var pathStr = $"{outputFilePath}\\{tableName}.yml"; File.WriteAllText(pathStr, content); Logger.LogInfo("Generated yml file for " + tableName); } catch (Exception e) { Logger.LogError(e, Utility.ErrorGeneratingFileForTable("yml", tableName, e.Message)); } }