/// <summary> /// Get_CodeValues_From_Codelist method poulates a List from the "ID" attributes of all codes contained in Codelist object. /// </summary> /// <param name="CodeList">Codelist object to populate the List<string></param> /// <returns>List<string> populated from the Codelist object.</returns> private List<string> Get_CodeValues_From_Codelist(CodelistType Codelist) { List<string> RetVal; RetVal = new List<string>(); foreach (CodeType Code in (Codelist.Items)) { RetVal.Add(Code.id); } return RetVal; }
private ArtefactInfo Prepare_ArtefactInfo_From_Codelist(CodelistType Codelist, string FileName) { ArtefactInfo RetVal; SDMXObjectModel.Message.StructureType Structure; XmlDocument XmlContent; RetVal = null; XmlContent = null; try { Structure = this.Get_Structure_Object(Codelist); XmlContent = Serializer.SerializeToXmlDocument(typeof(SDMXObjectModel.Message.StructureType), Structure); RetVal = new ArtefactInfo(Codelist.id, Codelist.agencyID, Codelist.version, string.Empty, ArtefactTypes.CL, FileName, XmlContent); } catch (Exception ex) { throw ex; } finally { } return RetVal; }
private ArtefactInfo Generate_Unit_Codelist() { ArtefactInfo RetVal; CodelistType Codelist; CodeType Code; string Query; DataTable DtUnit; Codelist = null; Code = null; Query = string.Empty; DtUnit = null; try { Codelist = new CodelistType(Constants.CodeList.Unit.Id, this.AgencyId, Constants.CodeList.Unit.Version, Constants.CodeList.Unit.Name, Constants.CodeList.Unit.Description, Constants.DefaultLanguage, null); if (this._completeOrSummaryFlag == true) { Query = this.Get_Language_Specific_Query(CodelistTypes.Unit, FilterFieldType.None, string.Empty, this.Language); DtUnit = this.DIConnection.ExecuteDataTable(Query); foreach (DataRow DrUnit in DtUnit.Rows) { Code = this.Create_Code(DrUnit[Unit.UnitGId].ToString(), DrUnit[Unit.UnitName].ToString(), string.Empty, this.Language, string.Empty, null); if (this.MultiLanguageHandlingRequired) { this.Handle_All_Languages(Code, CodelistTypes.Unit, FilterFieldType.GId, DrUnit[Unit.UnitGId].ToString(), Unit.UnitName); } this.Add_Annotation(Code, Constants.Annotations.IsGlobal, DrUnit[Unit.UnitGlobal].ToString()); this.Add_Code(Codelist, Code); } } RetVal = this.Prepare_ArtefactInfo_From_Codelist(Codelist, this.Get_File_Name(CodelistTypes.Unit)); } catch (Exception ex) { throw ex; } finally { } return RetVal; }
private SDMXObjectModel.Message.StructureType Get_Structure_Object(CodelistType Codelist) { SDMXObjectModel.Message.StructureType RetVal; RetVal = new SDMXObjectModel.Message.StructureType(); RetVal.Header = this.Get_Appropriate_Header(); RetVal.Structures = new StructuresType(null, null, null, null, null, null, null, null, null, Codelist, null, null, null, null, null); RetVal.Footer = null; return RetVal; }
private ArtefactInfo Generate_SubgroupVal_Codelist() { ArtefactInfo RetVal; CodelistType Codelist; CodeType Code; string Query; string BreakupInfo; DataTable DtSubgroupVal; DataTable DtBreakupInfo; Codelist = null; Code = null; Query = string.Empty; BreakupInfo = string.Empty; DtSubgroupVal = null; DtBreakupInfo = null; try { Codelist = new CodelistType(Constants.CodeList.SubgroupVal.Id, this.AgencyId, Constants.CodeList.SubgroupVal.Version, Constants.CodeList.SubgroupVal.Name, Constants.CodeList.SubgroupVal.Description, Constants.DefaultLanguage, null); DtBreakupInfo = this.DIConnection.ExecuteDataTable(this.DIQueries.SubgroupValSubgroup.GetSubgroupValsWithSubgroups()); if (this._completeOrSummaryFlag == true) { Query = this.Get_Language_Specific_Query(CodelistTypes.SubgroupVal, FilterFieldType.None, string.Empty, this.Language); DtSubgroupVal = this.DIConnection.ExecuteDataTable(Query); foreach (DataRow DrSubgroupVal in DtSubgroupVal.Rows) { Code = this.Create_Code(DrSubgroupVal[SubgroupVals.SubgroupValGId].ToString(), DrSubgroupVal[SubgroupVals.SubgroupVal].ToString(), string.Empty, this.Language, string.Empty, null); if (this.MultiLanguageHandlingRequired) { this.Handle_All_Languages(Code, CodelistTypes.SubgroupVal, FilterFieldType.GId, DrSubgroupVal[SubgroupVals.SubgroupValGId].ToString(), SubgroupVals.SubgroupVal); } this.Add_Annotation(Code, Constants.Annotations.IsGlobal, DrSubgroupVal[SubgroupVals.SubgroupValGlobal].ToString()); BreakupInfo = this.Get_SubgroupVal_Breakup_Info(DtBreakupInfo, DrSubgroupVal[SubgroupVals.SubgroupValGId].ToString()); this.Add_Annotation(Code, Constants.Annotations.Breakup, BreakupInfo); this.Add_Code(Codelist, Code); } } RetVal = this.Prepare_ArtefactInfo_From_Codelist(Codelist, this.Get_File_Name(CodelistTypes.SubgroupVal)); } catch (Exception ex) { throw ex; } finally { } return RetVal; }
private List<ArtefactInfo> Generate_Subgroup_Codelist() { List<ArtefactInfo> RetVal; ArtefactInfo Artefact; CodelistType Codelist; CodeType Code; string Query; string CodelistId, CodelistName, CodelistDescription; DataTable DtSubgroupType; DataTable DtSubgroup; RetVal = null; Artefact = null; Codelist = null; Code = null; Query = string.Empty; DtSubgroupType = null; DtSubgroup = null; try { DtSubgroupType = this.DIConnection.ExecuteDataTable(this.DIQueries.SubgroupTypes.GetSubgroupTypes(FilterFieldType.None, string.Empty)); foreach (DataRow DrSubgroupType in DtSubgroupType.Rows) { CodelistId = Constants.CodelistPrefix + DrSubgroupType[SubgroupTypes.SubgroupTypeGID].ToString(); CodelistName = DrSubgroupType[SubgroupTypes.SubgroupTypeName].ToString(); CodelistDescription = Constants.CodeList.Subgroups.Description + DrSubgroupType[SubgroupTypes.SubgroupTypeName].ToString(); Codelist = new CodelistType(CodelistId, this.AgencyId, Constants.CodeList.Subgroups.Version, CodelistName, CodelistDescription, Constants.DefaultLanguage, null); if (this._completeOrSummaryFlag == true) { Query = this.Get_Language_Specific_Query(CodelistTypes.Subgroups, FilterFieldType.Type, DrSubgroupType[SubgroupTypes.SubgroupTypeNId].ToString(), this.Language); DtSubgroup = this.DIConnection.ExecuteDataTable(Query); foreach (DataRow DrSubgroup in DtSubgroup.Rows) { Code = this.Create_Code(DrSubgroup[Subgroup.SubgroupGId].ToString(), DrSubgroup[Subgroup.SubgroupName].ToString(), string.Empty, this.Language, string.Empty, null); if (this.MultiLanguageHandlingRequired) { this.Handle_All_Languages(Code, CodelistTypes.Subgroups, FilterFieldType.GId, DrSubgroup[Subgroup.SubgroupGId].ToString(), Subgroup.SubgroupName); } this.Add_Annotation(Code, Constants.Annotations.IsGlobal, DrSubgroup[Subgroup.SubgroupGlobal].ToString()); this.Add_Code(Codelist, Code); } } Artefact = this.Prepare_ArtefactInfo_From_Codelist(Codelist, DrSubgroupType[SubgroupTypes.SubgroupTypeGID].ToString() + Constants.XmlExtension); this.Add_ArtefactInfo_To_List(ref RetVal, Artefact); } } catch (Exception ex) { throw ex; } finally { } return RetVal; }
//This method will return codelist of area according to the passed area levels + the levels below given level. private ArtefactInfo Generate_Area_Codelist(string AreaLevel) { ArtefactInfo RetVal; CodelistType Codelist; CodeType Code; string Query; DataTable DtArea; DataTable DTAreaAccordingToLevel; string ParentID; Codelist = null; Code = null; Query = string.Empty; DtArea = null; ParentID = string.Empty; try { Codelist = new CodelistType(Constants.CodeList.Area.Id, this.AgencyId, Constants.CodeList.Area.Version, Constants.CodeList.Area.Name, Constants.CodeList.Area.Description, Constants.DefaultLanguage, null); if (this._completeOrSummaryFlag == true) { Query = this.Get_Language_Specific_Query(CodelistTypes.Area, FilterFieldType.None, string.Empty, this.Language); DtArea = this.DIConnection.ExecuteDataTable(Query); foreach (DataRow DrArea in DtArea.Select(Area.AreaLevel + " <= '" + AreaLevel + "'")) { ParentID = this.Get_ParentID(CodelistTypes.Area, DrArea[Area.AreaParentNId].ToString(), Area.AreaID, this.Language); Code = this.Create_Code(DrArea[Area.AreaID].ToString(), DrArea[Area.AreaName].ToString(), string.Empty, this.Language, ParentID, null); if (this.MultiLanguageHandlingRequired) { this.Handle_All_Languages(Code, CodelistTypes.Area, FilterFieldType.ID, DrArea[Area.AreaID].ToString(), Area.AreaName); } this.Add_Annotation(Code, Constants.Annotations.IsGlobal, DrArea[Area.AreaGlobal].ToString()); this.Add_Annotation(Code, Area_Level.AreaLevel, DrArea[Area_Level.AreaLevel].ToString()); this.Add_Code(Codelist, Code); } } RetVal = this.Prepare_ArtefactInfo_From_Codelist(Codelist, this.Get_File_Name(CodelistTypes.Area)); } catch (Exception ex) { throw ex; } finally { } return RetVal; }
private ArtefactInfo Generate_IUS_Codelist() { ArtefactInfo RetVal; CodelistType Codelist; CodeType Code; string BreakupInfo; DataTable DtIUS; Codelist = null; Code = null; BreakupInfo = string.Empty; DtIUS = null; try { Codelist = new CodelistType(Constants.CodeList.IUS.Id, this.AgencyId, Constants.CodeList.IUS.Version, Constants.CodeList.IUS.Name, Constants.CodeList.IUS.Description, Constants.DefaultLanguage, null); if (this._completeOrSummaryFlag == true) { DtIUS = this.DIConnection.ExecuteDataTable(this.DIQueries.IUS.GetIUS(FilterFieldType.None, string.Empty, FieldSelection.Light,true)); foreach (DataRow DrIUS in DtIUS.Rows) { Code = this.Create_Code(DrIUS[Indicator.IndicatorGId].ToString() + Constants.AtTheRate + DrIUS[Unit.UnitGId].ToString() + Constants.AtTheRate + DrIUS[SubgroupVals.SubgroupValGId].ToString(), DrIUS[Indicator.IndicatorName].ToString() + Constants.Dash + DrIUS[Unit.UnitName].ToString() + Constants.Dash + DrIUS[SubgroupVals.SubgroupVal].ToString(), string.Empty, this.Language, string.Empty, null); if (this.MultiLanguageHandlingRequired) { this.Handle_All_Languages(Code, CodelistTypes.IUS, FilterFieldType.GId, DrIUS[Indicator.IndicatorGId].ToString() + Constants.AtTheRate + DrIUS[Unit.UnitGId].ToString() + Constants.AtTheRate + DrIUS[SubgroupVals.SubgroupValGId].ToString(), Indicator.IndicatorName + Constants.AtTheRate + Unit.UnitName + Constants.AtTheRate + SubgroupVals.SubgroupVal); } if (DrIUS[Indicator_Unit_Subgroup.IsDefaultSubgroup] != null) { this.Add_Annotation(Code, Constants.Annotations.IsDefault, DrIUS[Indicator_Unit_Subgroup.IsDefaultSubgroup].ToString()); } this.Add_Code(Codelist, Code); } } RetVal = this.Prepare_ArtefactInfo_From_Codelist(Codelist, this.Get_File_Name(CodelistTypes.IUS)); } catch (Exception ex) { throw ex; } finally { } return RetVal; }
private DIExcel GenerateCodelistsComparison(string hlngcodedb, CodelistType Codelist1, CodelistType Codelist2, DIExcel ReportExcel,int SheetIndex) { List<CodeType> ListOfMatchedCodes; List<CodeType> ListOfMissingCodes; List<CodeType> ListOfAdditionalCodelist1Codes; List<String> ListOfDSD1Codes; List<String> ListOfDSD2Codes; string CodeName = string.Empty; int i, SNo, rowindex; ListOfDSD1Codes = new List<string>(); ListOfDSD2Codes = new List<string>(); ListOfMatchedCodes = new List<CodeType>(); ListOfMissingCodes = new List<CodeType>(); ListOfAdditionalCodelist1Codes = new List<CodeType>(); i = 0; SNo = 0; rowindex = 0; CodeType Code = new CodeType(); string CodeId = string.Empty; string UnmatchedCodeName = string.Empty; IWorksheet WorkbookSheet = null; try { for (i = 0; i < Codelist2.Items.Count; i++) { Code = ((CodeType)(Codelist2.Items[i])); CodeId = Code.id; ListOfDSD2Codes.Add(CodeId); } for (i = 0; i < Codelist1.Items.Count; i++) { Code = ((CodeType)(Codelist1.Items[i])); CodeId = Code.id; ListOfDSD1Codes.Add(CodeId); if (!(ListOfDSD2Codes.Contains(CodeId))) { ListOfAdditionalCodelist1Codes.Add(Code); } else { ListOfMatchedCodes.Add(Code); } } for (i = 0; i < Codelist2.Items.Count; i++) { Code = ((CodeType)(Codelist2.Items[i])); CodeId = Code.id; if (!(ListOfDSD1Codes.Contains(CodeId))) { ListOfMissingCodes.Add(Code); } } // Writing Matched Codes that exist in both Codelist1 and Codelist2 rowindex = rowindex + 1; WorkbookSheet = ReportExcel.GetWorksheet(SheetIndex); this.WriteValueInCell(ReportExcel, "Matched Codes", rowindex, 1, 14, true, 10, 0, SheetIndex); WorkbookSheet.Cells[rowindex, 1, rowindex,2].Merge(); rowindex = rowindex + 2; this.WriteValueInCell(ReportExcel, "S.No.", rowindex, 1, 12, true, 10, 0, SheetIndex); this.WriteValueInCell(ReportExcel, "ID", rowindex, 2, 12, true, 60, 0, SheetIndex); this.WriteValueInCell(ReportExcel, "Name", rowindex, 3, 12, true, 70, 0, SheetIndex); rowindex = rowindex + 1; SNo = 0; foreach (CodeType MatchedCode in ListOfMatchedCodes) { SNo = SNo + 1; this.WriteValueInCell(ReportExcel, SNo.ToString(), rowindex, 1, 10, false, 10, 0, SheetIndex); CodeName = string.Empty; CodeName = GetLangSpecificValue(ListOfMatchedCodes[SNo - 1].Name, hlngcodedb); this.WriteValueInCell(ReportExcel, MatchedCode.id, rowindex, 2, 10, false,60, 0, SheetIndex); if (CodeName != string.Empty) { this.WriteValueInCell(ReportExcel, CodeName, rowindex, 3, 10, false, 70, 0, SheetIndex); } rowindex = rowindex + 1; } // Writing Missing Codes that exist in Codelist2 but not in Codelist1 rowindex = rowindex + 2; this.WriteValueInCell(ReportExcel, "Missing Codes", rowindex, 1, 14, true,10, 0, SheetIndex); WorkbookSheet.Cells[rowindex, 1, rowindex, 2].Merge(); rowindex = rowindex + 2; this.WriteValueInCell(ReportExcel, "S.No.", rowindex, 1, 12, true, 10, 0, SheetIndex); this.WriteValueInCell(ReportExcel, "ID", rowindex, 2, 12, true, 60, 0, SheetIndex); this.WriteValueInCell(ReportExcel, "Name", rowindex, 3, 12, true, 70, 0, SheetIndex); rowindex = rowindex + 1; SNo = 0; foreach (CodeType MissingCode in ListOfMissingCodes) { SNo = SNo + 1; this.WriteValueInCell(ReportExcel, SNo.ToString(), rowindex, 1, 10, false, 10, 0, SheetIndex); CodeName = string.Empty; CodeName = GetLangSpecificValue(ListOfMissingCodes[SNo - 1].Name, hlngcodedb); this.WriteValueInCell(ReportExcel, MissingCode.id, rowindex, 2, 10, false,60, 0, SheetIndex); if (CodeName != string.Empty) { this.WriteValueInCell(ReportExcel, CodeName, rowindex, 3, 10, false, 70, 0, SheetIndex); } rowindex = rowindex + 1; } // Writing Additional Codes that exist in Codelist1 but not in Codelist2 rowindex = rowindex + 2; this.WriteValueInCell(ReportExcel, "Additional Codes", rowindex, 1, 14, true, 10, 0, SheetIndex); WorkbookSheet.Cells[rowindex, 1, rowindex, 2].Merge(); rowindex = rowindex + 2; this.WriteValueInCell(ReportExcel, "S.No.", rowindex, 1, 12, true, 10, 0, SheetIndex); this.WriteValueInCell(ReportExcel, "ID", rowindex, 2, 12, true, 60, 0, SheetIndex); this.WriteValueInCell(ReportExcel, "Name", rowindex, 3, 12, true, 70, 0, SheetIndex); rowindex = rowindex + 1; SNo = 0; foreach (CodeType AdditionalCode in ListOfAdditionalCodelist1Codes) { SNo = SNo + 1; this.WriteValueInCell(ReportExcel, SNo.ToString(), rowindex, 1, 10, false, 10, 0, SheetIndex); CodeName = string.Empty; CodeName = GetLangSpecificValue(ListOfAdditionalCodelist1Codes[SNo - 1].Name, hlngcodedb); this.WriteValueInCell(ReportExcel, AdditionalCode.id, rowindex, 2, 10, false, 60, 0, SheetIndex); if (CodeName != string.Empty) { this.WriteValueInCell(ReportExcel, CodeName, rowindex, 3, 10, false, 70, 0, SheetIndex); } rowindex = rowindex + 1; } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { } return ReportExcel; }
private void Add_Code(CodelistType Codelist, CodeType Code) { if (Codelist != null && Code != null) { Codelist.Items.Add(Code); } }
private string BindCodesComparison(CodelistType Codelist1, CodelistType Codelist2, string hlngcodedb, string ComparisonType) { StringBuilder RetVal; List<CodeType> ListOfMissingCodes; List<String> ListOfDSD2Codes; int i; RetVal = new StringBuilder(); ListOfMissingCodes = new List<CodeType>(); ListOfDSD2Codes = new List<string>(); CodeType Code = new CodeType(); string CodeId = string.Empty; string UnmatchedCodeName = string.Empty; try { for (i = 0; i < Codelist2.Items.Count; i++) { Code = ((CodeType)(Codelist2.Items[i])); CodeId = Code.id; ListOfDSD2Codes.Add(CodeId); } for (i = 0; i < Codelist1.Items.Count; i++) { Code = ((CodeType)(Codelist1.Items[i])); CodeId = Code.id; if (!(ListOfDSD2Codes.Contains(CodeId))) { ListOfMissingCodes.Add(Code); } } if (Codelist1.Items.Count > 0) { RetVal.Append("<div id=\"div_" + Codelist1.id + "\" style=\"display:none; \">"); } else { RetVal.Append("<div id=\"div_" + Codelist2.id + "\" style=\"display:none; \">"); } RetVal.Append("<br/>"); if (Codelist1.Items.Count > 0) { if (ListOfMissingCodes.Count > 0) { if (ComparisonType == "1") { RetVal.Append("<h4>Unmatched Codes that exist in Uploaded DSD1 and not in DSD2 </h4>"); } else { RetVal.Append("<h4>Unmatched Codes that exist in Uploaded DSD and not in Master DSD </h4>"); } RetVal.Append("<br/>"); RetVal.Append("<ul>"); for (i = 0; i < ListOfMissingCodes.Count; i++) { RetVal.Append("<li>"); UnmatchedCodeName = GetLangSpecificValue(ListOfMissingCodes[i].Name, hlngcodedb); RetVal.Append(ListOfMissingCodes[i].id); if (UnmatchedCodeName != string.Empty) { RetVal.Append("<span class=\"reg_li_brac_txt\" style=\"padding-left:40px;\">("); RetVal.Append(UnmatchedCodeName); RetVal.Append(")</span> "); } RetVal.Append("</li>"); } RetVal.Append("</ul>"); } else { RetVal.Append("<span class=\"reg_li_brac_txt\" style=\"padding-left:40px;\">"); RetVal.Append("No Unmatched Codes"); RetVal.Append("</span> "); } } else { RetVal.Append("<span class=\"reg_li_brac_txt\" style=\"padding-left:40px;\">"); RetVal.Append("Codelist does not exists in the Uploaded DSD."); RetVal.Append("</span> "); } RetVal.Append("</div>"); } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { } return RetVal.ToString(); }
private string BindCodelistComparison(string dsd1FileNameWPath, string dsd2FileNameWPath, string hlngcodedb, Dictionary<string, string> dictMappedIndicators, Dictionary<string, string> dictMappedAttributes, string ComparisonType) { StringBuilder RetVal; XmlDocument DSD1Xml; XmlDocument DSD2Xml; List<String> ListOfMissingDimensions; List<String> ListOfMissingAttributes; List<String> DSD2DimensionList; List<String> DSD2AttributeList; List<String> DSD1DimensionList; List<String> DSD1AttributeList; List<String> UnMappedDSD2DimensionList; List<String> UnMappedDSD2AttributeList; List<CodelistType> DSD1Codelists; List<CodelistType> DSD2Codelists; SDMXObjectModel.Structure.DimensionType Dimension; SDMXObjectModel.Structure.TimeDimensionType TimeDimension; SDMXObjectModel.Structure.AttributeType Attribute; SDMXObjectModel.Common.ConceptReferenceType ConceptIdentity; RepresentationType LocalRepresentation; SDMXObjectModel.Structure.StructuresType ConceptsObjDSD1; SDMXObjectModel.Structure.StructuresType ConceptsObjDSD2; int i, j, k; DSD1Xml = new XmlDocument(); DSD2Xml = new XmlDocument(); DSD2DimensionList = new List<string>(); DSD2AttributeList = new List<string>(); DSD1DimensionList = new List<string>(); DSD1AttributeList = new List<string>(); ListOfMissingDimensions = new List<string>(); ListOfMissingAttributes = new List<string>(); UnMappedDSD2DimensionList = new List<string>(); UnMappedDSD2AttributeList = new List<string>(); string DSD1Dimension = string.Empty; string DSD2Dimension = string.Empty; string DSD1Attribute = string.Empty; string DSD2Attribute = string.Empty; string UnmatchedDimensionName = string.Empty; string UnmatchedAttributeName = string.Empty; string DSD1CodelistId = string.Empty; string DSD2CodelistId = string.Empty; try { DSD1Xml.Load(dsd1FileNameWPath); DSD2Xml.Load(dsd2FileNameWPath); SDMXObjectModel.Message.StructureType DSD1 = new SDMXObjectModel.Message.StructureType(); SDMXObjectModel.Message.StructureType DSD2 = new SDMXObjectModel.Message.StructureType(); SDMXObjectModel.Structure.DataStructureComponentsType DSD1DSComponents = new DataStructureComponentsType(); SDMXObjectModel.Structure.DataStructureComponentsType DSD2DSComponents = new DataStructureComponentsType(); CodelistType DSD1Codelist = new CodelistType(); CodelistType DSD2Codelist = new CodelistType(); DSD1 = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), DSD1Xml); DSD2 = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), DSD2Xml); DSD1DSComponents = (SDMXObjectModel.Structure.DataStructureComponentsType)(DSD1.Structures.DataStructures[0].Item); DSD2DSComponents = (SDMXObjectModel.Structure.DataStructureComponentsType)(DSD2.Structures.DataStructures[0].Item); ConceptsObjDSD1 = DSD1.Structures; ConceptsObjDSD2 = DSD2.Structures; DSD1Codelists = DSD1.Structures.Codelists; DSD2Codelists = DSD2.Structures.Codelists; // Binding DSD2 Dimension in a list - DSD2DimensionList for (i = 0; i < DSD2DSComponents.Items[0].Items.Count; i++) { if (DSD2DSComponents.Items[0].Items[i] is SDMXObjectModel.Structure.TimeDimensionType) { TimeDimension = (SDMXObjectModel.Structure.TimeDimensionType)(DSD2DSComponents.Items[0].Items[i]); ConceptIdentity = TimeDimension.ConceptIdentity; } else { Dimension = (SDMXObjectModel.Structure.DimensionType)(DSD2DSComponents.Items[0].Items[i]); ConceptIdentity = Dimension.ConceptIdentity; } DSD2DimensionList.Add(((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString()); } // Binding DSD2 Attributes in a list - DSD2AttributeList for (i = 0; i < DSD2DSComponents.Items[1].Items.Count; i++) { Attribute = (SDMXObjectModel.Structure.AttributeType)(DSD2DSComponents.Items[1].Items[i]); ConceptIdentity = Attribute.ConceptIdentity; DSD2AttributeList.Add(((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString()); } // Binding Matched Dimensions in a dictionary- dictMappedIndicators that exist in DSD1 as well as in DSD2 for (i = 0; i < DSD1DSComponents.Items[0].Items.Count; i++) { if (DSD1DSComponents.Items[0].Items[i] is SDMXObjectModel.Structure.TimeDimensionType) { TimeDimension = (SDMXObjectModel.Structure.TimeDimensionType)(DSD1DSComponents.Items[0].Items[i]); ConceptIdentity = TimeDimension.ConceptIdentity; } else { Dimension = (SDMXObjectModel.Structure.DimensionType)(DSD1DSComponents.Items[0].Items[i]); ConceptIdentity = Dimension.ConceptIdentity; } DSD1Dimension = ((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString(); DSD1DimensionList.Add(DSD1Dimension); if ((DSD2DimensionList.Contains(DSD1Dimension))) { dictMappedIndicators.Add(DSD1Dimension, DSD1Dimension); } } // Binding Matched Attributes in a dictionary- dictMappedAttributes that exist in DSD1 as well as in DSD2 for (i = 0; i < DSD1DSComponents.Items[1].Items.Count; i++) { Attribute = (SDMXObjectModel.Structure.AttributeType)(DSD1DSComponents.Items[1].Items[i]); ConceptIdentity = Attribute.ConceptIdentity; DSD1Attribute = ((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString(); DSD1AttributeList.Add(DSD1Attribute); if ((DSD2AttributeList.Contains(DSD1Attribute))) { dictMappedAttributes.Add(DSD1Attribute, DSD1Attribute); } } //Binding Comparison of the two DSDs - DSD1 and DSD2 RetVal = new StringBuilder(); RetVal.Append("<br/>"); foreach (string Indicator in dictMappedIndicators.Keys) { DSD1CodelistId = string.Empty; for (i = 0; i < DSD1DSComponents.Items[0].Items.Count; i++) { if (DSD1DSComponents.Items[0].Items[i] is SDMXObjectModel.Structure.DimensionType) { Dimension = (SDMXObjectModel.Structure.DimensionType)(DSD1DSComponents.Items[0].Items[i]); ConceptIdentity = Dimension.ConceptIdentity; LocalRepresentation = Dimension.LocalRepresentation; DSD1Dimension = ((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString(); if (DSD1Dimension == Indicator) { DSD1CodelistId = ((CodelistRefType)((((CodelistReferenceType)(LocalRepresentation.Items[0])).Items[0]))).id; break; } } } if (string.IsNullOrEmpty(DSD1CodelistId) == false) { for (j = 0; j < DSD1Codelists.Count; j++) { if (DSD1CodelistId == DSD1Codelists[j].id) { DSD1Codelist = DSD1Codelists[j]; break; } } } for (i = 0; i < DSD2DSComponents.Items[0].Items.Count; i++) { DSD2CodelistId = string.Empty; if (DSD2DSComponents.Items[0].Items[i] is SDMXObjectModel.Structure.DimensionType) { Dimension = (SDMXObjectModel.Structure.DimensionType)(DSD2DSComponents.Items[0].Items[i]); ConceptIdentity = Dimension.ConceptIdentity; LocalRepresentation = Dimension.LocalRepresentation; DSD2Dimension = ((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString(); if (DSD2Dimension == dictMappedIndicators[Indicator]) { DSD2CodelistId = ((CodelistRefType)((((CodelistReferenceType)(LocalRepresentation.Items[0])).Items[0]))).id; break; } } } if (string.IsNullOrEmpty(DSD2CodelistId) == false) { for (j = 0; j < DSD2Codelists.Count; j++) { if (DSD2CodelistId == DSD2Codelists[j].id) { DSD2Codelist = DSD2Codelists[j]; break; } } } if ((DSD1CodelistId != string.Empty) && (DSD2CodelistId != string.Empty)) { if (DSD1Codelist.Items.Count > 0) { RetVal.Append("<a href=\"javascript:void(0);\" id=\"lnk_" + DSD1CodelistId + "\" "); } else { RetVal.Append("<a href=\"javascript:void(0);\" id=\"lnk_" + DSD2CodelistId + "\" "); } RetVal.Append(" onclick=\"ToggleExpandCollapse(event);\""); RetVal.Append(" class=\"collapse\" style=\"padding-left:40px;\">" + DSD1CodelistId + " Vs " + DSD2CodelistId + "</a>"); RetVal.Append("<br/>"); RetVal.Append(BindCodesComparison(DSD1Codelist, DSD2Codelist, hlngcodedb, ComparisonType)); RetVal.Append("<br/>"); } } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { } return RetVal.ToString(); }
private string SaveComparisonReport(string dsd1FileNameWPath, string dsd2FileNameWPath, string hlngcodedb, Dictionary<string, string> dictMappedIndicators, Dictionary<string, string> dictMappedAttributes) { string RetVal; XmlDocument DSD1Xml; XmlDocument DSD2Xml; List<String> ListOfMissingDimensions; List<String> ListOfMissingAttributes; List<String> DSD2DimensionList; List<String> DSD2AttributeList; List<String> DSD1DimensionList; List<String> DSD1AttributeList; List<String> AdditionalDSD1DimensionList; List<String> AdditionalDSD1AttributeList; List<CodelistType> DSD1Codelists; List<CodelistType> DSD2Codelists; RepresentationType LocalRepresentation; SDMXObjectModel.Structure.DimensionType Dimension; SDMXObjectModel.Structure.TimeDimensionType TimeDimension; SDMXObjectModel.Structure.AttributeType Attribute; SDMXObjectModel.Common.ConceptReferenceType ConceptIdentity; SDMXObjectModel.Structure.StructuresType ConceptsObjDSD1; SDMXObjectModel.Structure.StructuresType ConceptsObjDSD2; int i,j,SheetIndex; RetVal = string.Empty; DSD1Xml = new XmlDocument(); DSD2Xml = new XmlDocument(); DSD2DimensionList = new List<string>(); DSD2AttributeList = new List<string>(); DSD1DimensionList = new List<string>(); DSD1AttributeList = new List<string>(); ListOfMissingDimensions = new List<string>(); ListOfMissingAttributes = new List<string>(); AdditionalDSD1DimensionList = new List<string>(); AdditionalDSD1AttributeList = new List<string>(); string DSD1Dimension = string.Empty; string DSD2Dimension = string.Empty; string DSD1Attribute = string.Empty; string DSD2Attribute = string.Empty; string UnmatchedDimensionName = string.Empty; string UnmatchedAttributeName = string.Empty; string DSD1CodelistId = string.Empty; string DSD2CodelistId = string.Empty; DIExcel ReportExcel = new DIExcel(); string tempPath = string.Empty; string FileName = string.Empty; string FilePath = string.Empty; try { DSD1Xml.Load(dsd1FileNameWPath); DSD2Xml.Load(dsd2FileNameWPath); SDMXObjectModel.Message.StructureType DSD1 = new SDMXObjectModel.Message.StructureType(); SDMXObjectModel.Message.StructureType DSD2 = new SDMXObjectModel.Message.StructureType(); SDMXObjectModel.Structure.DataStructureComponentsType DSD1DSComponents = new DataStructureComponentsType(); SDMXObjectModel.Structure.DataStructureComponentsType DSD2DSComponents = new DataStructureComponentsType(); CodelistType DSD1Codelist = new CodelistType(); CodelistType DSD2Codelist = new CodelistType(); DSD1 = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), DSD1Xml); DSD2 = (SDMXObjectModel.Message.StructureType)Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.StructureType), DSD2Xml); DSD1DSComponents = (SDMXObjectModel.Structure.DataStructureComponentsType)(DSD1.Structures.DataStructures[0].Item); DSD2DSComponents = (SDMXObjectModel.Structure.DataStructureComponentsType)(DSD2.Structures.DataStructures[0].Item); ConceptsObjDSD1 = DSD1.Structures; ConceptsObjDSD2 = DSD2.Structures; DSD1Codelists = DSD1.Structures.Codelists; DSD2Codelists = DSD2.Structures.Codelists; // Binding DSD2 Dimension in a list - DSD2DimensionList for (i = 0; i < DSD2DSComponents.Items[0].Items.Count; i++) { if (DSD2DSComponents.Items[0].Items[i] is SDMXObjectModel.Structure.TimeDimensionType) { TimeDimension = (SDMXObjectModel.Structure.TimeDimensionType)(DSD2DSComponents.Items[0].Items[i]); ConceptIdentity = TimeDimension.ConceptIdentity; } else { Dimension = (SDMXObjectModel.Structure.DimensionType)(DSD2DSComponents.Items[0].Items[i]); ConceptIdentity = Dimension.ConceptIdentity; } DSD2DimensionList.Add(((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString()); } // Binding DSD2 Attributes in a list - DSD2AttributeList for (i = 0; i < DSD2DSComponents.Items[1].Items.Count; i++) { Attribute = (SDMXObjectModel.Structure.AttributeType)(DSD2DSComponents.Items[1].Items[i]); ConceptIdentity = Attribute.ConceptIdentity; DSD2AttributeList.Add(((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString()); } // Binding Matched Dimensions in a dictionary- dictMappedIndicators that exist in DSD1 as well as in DSD2 // and unmatched Dimensions in a list-AdditionalDSD1DimensionList that exist in DSD1 but not in DSD2 for (i = 0; i < DSD1DSComponents.Items[0].Items.Count; i++) { if (DSD1DSComponents.Items[0].Items[i] is SDMXObjectModel.Structure.TimeDimensionType) { TimeDimension = (SDMXObjectModel.Structure.TimeDimensionType)(DSD1DSComponents.Items[0].Items[i]); ConceptIdentity = TimeDimension.ConceptIdentity; } else { Dimension = (SDMXObjectModel.Structure.DimensionType)(DSD1DSComponents.Items[0].Items[i]); ConceptIdentity = Dimension.ConceptIdentity; } DSD1Dimension = ((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString(); DSD1DimensionList.Add(DSD1Dimension); if ((DSD2DimensionList.Contains(DSD1Dimension))) { dictMappedIndicators.Add(DSD1Dimension, DSD1Dimension); } else { AdditionalDSD1DimensionList.Add(DSD1Dimension); } } // Binding Matched Attributes in a dictionary- dictMappedAttributes that exist in DSD1 as well as in DSD2 // and unmatched Attributes in a list-AdditionalDSD1AttributeList that exist in DSD1 but not in DSD2 for (i = 0; i < DSD1DSComponents.Items[1].Items.Count; i++) { Attribute = (SDMXObjectModel.Structure.AttributeType)(DSD1DSComponents.Items[1].Items[i]); ConceptIdentity = Attribute.ConceptIdentity; DSD1Attribute = ((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString(); DSD1AttributeList.Add(DSD1Attribute); if ((DSD2AttributeList.Contains(DSD1Attribute))) { dictMappedAttributes.Add(DSD1Attribute, DSD1Attribute); } else { AdditionalDSD1AttributeList.Add(DSD1Attribute); } } //Binding Missing Dimensions in a list-ListOfMissingDimensions that exist in DSD2 but not in DSD1 for (i = 0; i < DSD2DimensionList.Count; i++) { if (!(DSD1DimensionList.Contains(DSD2DimensionList[i]))) { ListOfMissingDimensions.Add(DSD2DimensionList[i]); } } //Binding Missing Attributes in a list-ListOfMissingAttributes that exist in DSD2 but not in DSD1 for (i = 0; i < DSD2AttributeList.Count; i++) { if (!(DSD1AttributeList.Contains(DSD2AttributeList[i]))) { ListOfMissingAttributes.Add(DSD2AttributeList[i]); } } //Binding Comparison of the two DSDs - DSD1 and DSD2 tempPath= Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath,"stock\\tempSDMXFiles"); FileName = "ComparisonReport_" + Guid.NewGuid().ToString() + ".xls"; FilePath = tempPath + "\\" + FileName; ReportExcel = this.GenerateDimensionAndAttributesComparison(hlngcodedb,DSD1, DSD2, ReportExcel, dictMappedIndicators, ListOfMissingDimensions, AdditionalDSD1DimensionList, dictMappedAttributes, ListOfMissingAttributes, AdditionalDSD1AttributeList); SheetIndex = 2; foreach (string Indicator in dictMappedIndicators.Keys) { DSD1CodelistId = string.Empty; for (i = 0; i < DSD1DSComponents.Items[0].Items.Count; i++) { if (DSD1DSComponents.Items[0].Items[i] is SDMXObjectModel.Structure.DimensionType) { Dimension = (SDMXObjectModel.Structure.DimensionType)(DSD1DSComponents.Items[0].Items[i]); ConceptIdentity = Dimension.ConceptIdentity; LocalRepresentation = Dimension.LocalRepresentation; DSD1Dimension = ((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString(); if (DSD1Dimension == Indicator) { DSD1CodelistId = ((CodelistRefType)((((CodelistReferenceType)(LocalRepresentation.Items[0])).Items[0]))).id; break; } } } if (string.IsNullOrEmpty(DSD1CodelistId) == false) { for (j = 0; j < DSD1Codelists.Count; j++) { if (DSD1CodelistId == DSD1Codelists[j].id) { DSD1Codelist = DSD1Codelists[j]; break; } } } for (i = 0; i < DSD2DSComponents.Items[0].Items.Count; i++) { DSD2CodelistId = string.Empty; if (DSD2DSComponents.Items[0].Items[i] is SDMXObjectModel.Structure.DimensionType) { Dimension = (SDMXObjectModel.Structure.DimensionType)(DSD2DSComponents.Items[0].Items[i]); ConceptIdentity = Dimension.ConceptIdentity; LocalRepresentation = Dimension.LocalRepresentation; DSD2Dimension = ((SDMXObjectModel.Common.ConceptRefType)(ConceptIdentity.Items[0])).id.ToString(); if (DSD2Dimension == dictMappedIndicators[Indicator]) { DSD2CodelistId = ((CodelistRefType)((((CodelistReferenceType)(LocalRepresentation.Items[0])).Items[0]))).id; break; } } } if (string.IsNullOrEmpty(DSD2CodelistId) == false) { for (j = 0; j < DSD2Codelists.Count; j++) { if (DSD2CodelistId == DSD2Codelists[j].id) { DSD2Codelist = DSD2Codelists[j]; break; } } } if ((DSD1CodelistId != string.Empty) && (DSD2CodelistId != string.Empty)) { if( (DSD1Codelist.Items.Count > 0) && (DSD2Codelist.Items.Count > 0) ) { ReportExcel.InsertWorkSheet(DSD1Codelist.id + " Vs " + DSD2Codelist.id); ReportExcel = this.GenerateCodelistsComparison(hlngcodedb, DSD1Codelist, DSD2Codelist, ReportExcel, SheetIndex); SheetIndex = SheetIndex + 1; } } } ReportExcel.ActiveSheetIndex = 0; if (ReportExcel.AvailableWorksheetsCount > 1) { ReportExcel.SaveAs(FilePath); RetVal = FileName; } } catch (Exception ex) { Global.CreateExceptionString(ex, null); throw ex; } finally { } return RetVal; }
private DIExcel GenerateCodelistWorksheets(DIExcel ReportExcel, int SheetIndex, SDMXObjectModel.Message.StructureType CompleteStructure) { int i, j; IWorksheet CodelistWorkSheet = null; SDMXObjectModel.Structure.CodelistType Codelist; SDMXObjectModel.Structure.CodeType Code; string AttributeImportance = string.Empty; string CodelistName = string.Empty; string CodeId = string.Empty; string CodeName = string.Empty; SDMXObjectModel.Structure.StructuresType ConceptsObj; int rowindex = 0; try { ConceptsObj = CompleteStructure.Structures; for (i = 1; i <= CompleteStructure.Structures.Codelists.Count; i++) { Codelist = new CodelistType(); Codelist = CompleteStructure.Structures.Codelists[i - 1]; CodelistName = GetLangSpecificValue(Codelist.Name, this.Language); ReportExcel.InsertWorkSheet(CodelistName); CodelistWorkSheet = ReportExcel.GetWorksheet(i); rowindex = 1; this.WriteValueInCell(ReportExcel, GetLangSpecificValue(Codelist.Description, this.Language), rowindex, 1, 12, true, 30, 0, i); rowindex = rowindex + 2; this.WriteValueInCell(ReportExcel, "Code", rowindex, 1, 10, true, 60, 0, i); this.WriteValueInCell(ReportExcel, "Name", rowindex, 2, 10, true, 250, 0, i); rowindex = rowindex + 2; //Binding Codelist for (j = 0; j < Codelist.Items.Count; j++) { Code = new CodeType(); Code = ((SDMXObjectModel.Structure.CodeType)(Codelist.Items[j])); CodeId = Code.id; CodeName = GetLangSpecificValue(Code.Name, this.Language); if ((CodeId.Length + 1) <= 30) { this.WriteValueInCell(ReportExcel, CodeId, rowindex, 1, 10, false, 30, 0, i); } else { this.WriteValueInCell(ReportExcel, CodeId, rowindex, 1, 10, false, CodeId.Length + 1, 0, i); } this.WriteValueInCell(ReportExcel, CodeName, rowindex, 2, 10, false, 250, 0, i); rowindex = rowindex + 1; } } } catch (Exception ex) { throw ex; } finally { } return ReportExcel; }
public StructuresType(ProvisionAgreementType provisionAgreement, ConstraintType constraint, ProcessType process, ReportingTaxonomyType reportingTaxonomoy, StructureSetType structureSet, DataStructureType dataStructure, MetadataStructureType metadataStructure, ConceptSchemeType conceptScheme, HierarchicalCodelistType hierarchicalCodelist, CodelistType codelist, CategorisationType categorisation, CategorySchemeType categoryScheme, MetadataflowType metadataFlow, DataflowType dataFlow, OrganisationSchemeType organisationScheme) { if (provisionAgreement != null) { this.provisionAgreementsField = new List<ProvisionAgreementType>(); this.provisionAgreementsField.Add(provisionAgreement); } if (constraint != null) { this.constraintsField = new List<ConstraintType>(); this.constraintsField.Add(constraint); } if (process != null) { this.processesField = new List<ProcessType>(); this.processesField.Add(process); } if (reportingTaxonomoy != null) { this.reportingTaxonomiesField = new List<ReportingTaxonomyType>(); this.reportingTaxonomiesField.Add(reportingTaxonomoy); } if (structureSet != null) { this.structureSetsField = new List<StructureSetType>(); this.structureSetsField.Add(structureSet); } if (dataStructure != null) { this.dataStructuresField = new List<DataStructureType>(); this.dataStructuresField.Add(dataStructure); } if (metadataStructure != null) { this.metadataStructuresField = new List<MetadataStructureType>(); this.metadataStructuresField.Add(metadataStructure); } if (conceptScheme != null) { this.conceptsField = new List<ConceptSchemeType>(); this.conceptsField.Add(conceptScheme); } if (hierarchicalCodelist != null) { this.hierarchicalCodelistsField = new List<HierarchicalCodelistType>(); this.hierarchicalCodelistsField.Add(hierarchicalCodelist); } if (codelist != null) { this.codelistsField = new List<CodelistType>(); this.codelistsField.Add(codelist); } if (categorisation != null) { this.categorisationsField = new List<CategorisationType>(); this.categorisationsField.Add(categorisation); } if (categoryScheme != null) { this.categorySchemesField = new List<CategorySchemeType>(); this.categorySchemesField.Add(categoryScheme); } if (metadataFlow != null) { this.metadataflowsField = new List<MetadataflowType>(); this.metadataflowsField.Add(metadataFlow); } if (dataFlow != null) { this.dataflowsField = new List<DataflowType>(); this.dataflowsField.Add(dataFlow); } if (organisationScheme != null) { this.organisationSchemesField = new List<OrganisationSchemeType>(); this.organisationSchemesField.Add(organisationScheme); } }