public void InitializeExport(IList <DocumentSeriesItem> items, IList <ArchiveAttribute> serieAttributes) { CsvFields.Clear(); ArchiveAttribute.Clear(); ArchiveAttribute = serieAttributes; if (!items.Any()) { return; } foreach (DocumentSeriesItem item in items) { Dictionary <string, string> attributes = CurrentDocumentSeriesItemFacade().GetAttributes(item); var seriesToCsv = new SeriesToCsvFields(); seriesToCsv.Object = item.Subject; seriesToCsv.PublicationDate = item.PublishingDate; seriesToCsv.IdSeries = item.DocumentSeries.Id; seriesToCsv.Year = item.Year == null ? string.Empty : item.Year.ToString(); seriesToCsv.Number = item.Number == null ? string.Empty : item.Number.ToString(); seriesToCsv.RegistrationDate = DateTime.Parse(item.RegistrationDate.ToString()); seriesToCsv.Categorry = item.Category.GetFullName(); foreach (var data in ArchiveAttribute) { var value = string.Empty; var keyExist = attributes.Any(x => x.Key.Equals(data.Name)); if (keyExist) { value = attributes.Where(x => x.Key.Equals(data.Name)).Select(s => s.Value).SingleOrDefault(); } if (ExporterHelper.EnumTipoProcedimento.Equals(data.Name)) { value = ExporterHelper.GetTipoProcedimento(value); } var dict = new KeyValuePair <string, object>(data.Name, value); seriesToCsv.DynamicData.Add(dict); } CsvFields.Add(seriesToCsv); } }
public void InitializeExport(IList <DocumentSeriesItemWSO> itemWsos, IList <ArchiveAttributeWSO> archiveAttributeWsos) { CsvFields.Clear(); ArchiveAttribute.Clear(); ArchiveAttribute = archiveAttributeWsos; if (this._parameters.ExportDocuments) { ArchiveAttribute.Add(new ArchiveAttributeWSO() { Description = "DocumentName" }); ArchiveAttribute.Add(new ArchiveAttributeWSO() { Description = "DocumentType" }); } if (!itemWsos.Any()) { return; } foreach (var itemWso in itemWsos) { var seriesToCsv = new SeriesToCsvFields(); seriesToCsv.Object = itemWso.Subject; seriesToCsv.PublicationDate = itemWso.PublishingDate; seriesToCsv.IdSeries = itemWso.IdDocumentSeries; seriesToCsv.IdSubsection = itemWso.IdDocumentSeriesSubsection; foreach (var data in ArchiveAttribute) { var value = string.Empty; var keyExist = itemWso.DynamicData.Any(x => x.Key.Eq(data.Name)); if (keyExist) { value = itemWso.DynamicData.Where(x => x.Key.Eq(data.Name)).Select(s => s.Value).SingleOrDefault(); } if (ExporterHelper.EnumTipoProcedimento.Eq(data.Name)) { value = ExporterHelper.GetTipoProcedimento(value); } var dict = new KeyValuePair <string, object>(data.Description, value); seriesToCsv.DynamicData.Add(dict); } if (this._parameters.ExportDocuments) { DocumentSeriesItemWSO fullItem = this.WsSeriesConnector.GetFullItemWso(itemWso.Id); fullItem.MainDocs.ForEach((x) => { SeriesToCsvFields clone = seriesToCsv.DeepClone(); clone.DynamicData["DocumentName"] = x.Name; clone.DynamicData["DocumentType"] = "Documento Principale"; CsvFields.Add(clone); }); fullItem.AnnexedDocs.ForEach((x) => { SeriesToCsvFields clone = seriesToCsv.DeepClone(); clone.DynamicData["DocumentName"] = x.Name; clone.DynamicData["DocumentType"] = "Annesso"; CsvFields.Add(clone); }); if (fullItem.MainDocs.Count == 0 && fullItem.AnnexedDocs.Count == 0) { CsvFields.Add(seriesToCsv); } } else { CsvFields.Add(seriesToCsv); } } }