private void AddChilds(ICategorySchemeMutableObject catSchema, string filter) { DataView viewCS = new DataView(_dtCSFull); DataTable dtCS = viewCS.ToTable(true, "IDCS", "IDCat", "CatCode", "IDParent"); DataTable dtCatNames = viewCS.ToTable(true, "IDCat", "CatLangName", "CatValueName"); filter += " AND IDParent = 0"; DataRow[] dRows = dtCS.Select(filter); ICategoryMutableObject cat; foreach (DataRow row in dRows) { cat = new CategoryMutableCore(); cat.Id = row["CatCode"].ToString(); SetNames(dtCatNames.Select("IDCat = " + row["IDCat"].ToString()), cat); AddRecursiveChilds(cat, dtCatNames, dtCS, row["IDCat"].ToString()); catSchema.Items.Add(cat); } }
/// <summary> /// Handles the CategoryScheme element child elements /// </summary> /// <param name="parent"> /// The parent ICategorySchemeMutableObject object /// </param> /// <param name="localName"> /// The name of the current xml element /// </param> /// <returns> /// The <see cref="StructureReaderBaseV20.ElementActions"/>. /// </returns> private ElementActions HandleChildElements(ICategorySchemeMutableObject parent, object localName) { ElementActions actions = null; if (NameTableCache.IsElement(localName, ElementNameTable.Category)) { ICategoryMutableObject category = HandleCategory(this.Attributes); parent.AddItem(category); actions = this.AddNameableAction(category, this.HandleChildElements); } return actions; }
/// <summary> /// Handles the Structure top level elements /// This includes Codelist /// </summary> /// <param name="parent"> /// The parent <see cref="IMutableObjects"/> /// </param> /// <param name="localName"> /// The name of the current xml element /// </param> /// <returns> /// The <see cref="StructureReaderBaseV20.ElementActions"/>. /// </returns> protected override ElementActions HandleTopLevel(IMutableObjects parent, object localName) { ElementActions actions = null; if (NameTableCache.IsElement(localName, ElementNameTable.CategoryScheme)) { var cs = new CategorySchemeMutableCore(); ParseAttributes(cs, this.Attributes); parent.AddCategoryScheme(cs); this._currentCategoryScheme = cs; actions = this.AddNameableAction(cs, this.HandleChildElements); } return actions; }
private bool SendQuerySubmit(ICategorySchemeMutableObject cs) { try { ISdmxObjects sdmxObjects = new SdmxObjectsImpl(); for (int i = 0; i < cs.Annotations.Count; ) if (cs.Annotations[i].Type.Trim() == "CategoryScheme_node_order") cs.Annotations.RemoveAt(i); else i++; sdmxObjects.AddCategoryScheme(cs.ImmutableInstance); WSModel modelCategoryScheme = new WSModel(); XmlDocument result = modelCategoryScheme.SubmitStructure(sdmxObjects); if (Utils.GetXMLResponseError(result) != "") { Utils.ShowDialog(Utils.GetXMLResponseError(result), 350, "Error"); return false; } return true; } catch (Exception ex) { throw ex; } }
private bool SaveInMemory(ICategorySchemeMutableObject cs) { if (cs == null) return false; Session[KEY_PAGE_SESSION] = cs; return true; }
private ICategorySchemeMutableObject InsertCategoryInCategoryscheme(ICategorySchemeMutableObject cs) { if (cs == null) return null; ICategoryMutableObject category = new CategoryMutableCore(); string category_id = txtNewCategoryId.Text.Trim(); IList<ITextTypeWrapperMutableObject> category_names = NewCategoryAddTextName.TextObjectList; IList<ITextTypeWrapperMutableObject> category_descs = NewCategoryAddTextDescription.TextObjectList; //string category_parent_id = txtParentCategoryNewCategory.Text.Trim(); // string code_order_str = txtOrderNewCode.Text.Trim(); ----- ORDINE #region CATEGORY ID if (ValidationUtils.CheckIdFormat(category_id)) { category.Id = category_id; } else { lblErrorOnNewInsert.Text = Resources.Messages.err_id_format; Utils.AppendScript("openPopUp('df-Dimension', 600);"); Utils.AppendScript("location.href= '#categories';"); return null; } IEnumerable<ICategoryMutableObject> categories = (from c in cs.Items where c.Id == category_id select c).OfType<ICategoryMutableObject>(); if (categories.Count() > 0) { lblErrorOnNewInsert.Text = Resources.Messages.err_id_exist; Utils.AppendScript("openPopUp('df-Dimension', 600);"); Utils.AppendScript("location.href= '#categories';"); return null; } #endregion #region CODE NAMES if (category_names != null) { foreach (var tmpName in category_names) { category.AddName(tmpName.Locale, tmpName.Value); } } else { lblErrorOnNewInsert.Text = Resources.Messages.err_list_name_format; Utils.AppendScript("openPopUp('df-Dimension', 600);"); Utils.AppendScript("location.href= '#categories';"); return null; } #endregion #region CATEGORY DESCRIPTIONS if (category_descs != null) { foreach (var tmpDescription in category_descs) { category.AddDescription(tmpDescription.Locale, tmpDescription.Value); } } #endregion #region CATEGORY ANNOTATIONS if (AnnotationNewControl.AnnotationObjectList != null) foreach (var currentAnnotation in AnnotationNewControl.AnnotationObjectList) { category.Annotations.Add(currentAnnotation); } #endregion #region PARANT ID if (TreeView1.SelectedNode != null && !TreeView1.Nodes[0].Selected) { string nodesPath = TreeView1.SelectedNode.ValuePath.ToString(); string[] elements = nodesPath.Split('/'); ICategoryMutableObject currentNodeInCategoryScheme = cs.Items.First(obj => obj.Id.Equals(elements[1])); for (int i = 2; i < elements.Length; i++) { currentNodeInCategoryScheme = currentNodeInCategoryScheme.Items.First(obj => obj.Id.Equals(elements[i])); } currentNodeInCategoryScheme.Items.Add(category); } else { cs.Items.Add(category); } #endregion try { // Ultimo controllo se ottengo Immutable istanze validazione completa var canRead = cs.ImmutableInstance; } catch (Exception ex) { //parentCategory.Items.Remove( category ); return null; } txtNewCategoryId.Text = string.Empty; NewCategoryAddTextDescription.ClearTextObjectListWithOutJS(); NewCategoryAddTextName.ClearTextObjectListWithOutJS(); lblErrorOnNewInsert.Text = string.Empty; AnnotationNewControl.ClearAnnotationsSession(); return cs; }
private ICategorySchemeMutableObject GetCategoryschemeForm(ICategorySchemeMutableObject cs) { if (cs == null) return GetCategoryschemeForm(); bool isInError = false; // Indicatore di errore string messagesGroup = string.Empty; // Stringa di raggruppamento errori int errorCounter = 1; // Contatore errori #region CATEGORYSCHEME ID if (!ValidationUtils.CheckIdFormat(txtDSDID.Text)) { messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_id_format); errorCounter++; isInError = true; } #endregion #region CATEGORYSCHEME AGENCY if (cmbAgencies.Text.Trim().Equals(string.Empty)) { messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_agency_missing + "<br /><br />"; errorCounter++; isInError = true; } #endregion #region CATEGORYSCHEME VERSION if (!ValidationUtils.CheckVersionFormat(txtVersion.Text)) { messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_version_format); errorCounter++; isInError = true; } #endregion /* URI NOT REQUIRED */ #region CATEGORYSCHEME URI if ((txtDSDURI.Text != string.Empty) && !ValidationUtils.CheckUriFormat(txtDSDURI.Text)) { messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_uri_format); errorCounter++; isInError = true; } #endregion #region CATEGORYSCHEME NAMES if (AddTextName.TextObjectList == null || AddTextName.TextObjectList.Count == 0) { messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_list_name_format); errorCounter++; isInError = true; } #endregion #region CATEGORYSCHEME START END DATE bool checkForDatesCombination = true; if (!txtValidFrom.Text.Trim().Equals(string.Empty) && !ValidationUtils.CheckDateFormat(txtValidFrom.Text)) { messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_date_from_format); errorCounter++; checkForDatesCombination = false; isInError = true; } if (!txtValidTo.Text.Trim().Equals(string.Empty) && !ValidationUtils.CheckDateFormat(txtValidTo.Text)) { messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_date_to_format); errorCounter++; checkForDatesCombination = false; isInError = true; } if (!txtValidFrom.Text.Trim().Equals(string.Empty) && !txtValidTo.Text.Trim().Equals(string.Empty)) { // Controllo congruenza date if (checkForDatesCombination) { if (!ValidationUtils.CheckDates(txtValidFrom.Text, txtValidTo.Text)) { messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_date_diff); errorCounter++; isInError = true; } } } #endregion if (isInError) { Utils.ShowDialog(messagesGroup, 300); return null; } #region CREATE CATEGORYSCHEME FROM FORM cs.AgencyId = GetAgencyValue(); cs.Id = txtDSDID.Text; cs.Version = txtVersion.Text; cs.FinalStructure = TertiaryBool.ParseBoolean(chkIsFinal.Checked); cs.Uri = (!txtDSDURI.Text.Trim().Equals(string.Empty) && ValidationUtils.CheckUriFormat(txtDSDURI.Text)) ? new Uri(txtDSDURI.Text) : null; if (!txtValidFrom.Text.Trim().Equals(string.Empty)) { cs.StartDate = DateTime.ParseExact(txtValidFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } if (!txtValidTo.Text.Trim().Equals(string.Empty)) { cs.EndDate = DateTime.ParseExact(txtValidTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } if (cs.Names.Count != 0) { cs.Names.Clear(); } if (cs.Descriptions.Count != 0) { cs.Descriptions.Clear(); } foreach (var tmpName in AddTextName.TextObjectList) { cs.AddName(tmpName.Locale, tmpName.Value); } if (AddTextDescription.TextObjectList != null) foreach (var tmpDescription in AddTextDescription.TextObjectList) { cs.AddDescription(tmpDescription.Locale, tmpDescription.Value); } if (cs.Annotations.Count != 0) { cs.Annotations.Clear(); } if (AnnotationGeneralControl.AnnotationObjectList != null) foreach (var tmpAnnotation in AnnotationGeneralControl.AnnotationObjectList) { cs.AddAnnotation(tmpAnnotation); } #endregion return cs; }
private ICategorySchemeMutableObject DeleteCategoryInCategoryscheme(ICategorySchemeMutableObject cs, string selectedNodePathValue, string selectedParentNodePathValue) { string[] elements = selectedNodePathValue.Split('/'); ICategoryMutableObject currentNodeInCategoryScheme = cs.Items.First(obj => obj.Id.Equals(elements[1])); ICategoryMutableObject currentParentNodeInCategoryScheme = null; string[] elementsParentNode = null; if (!selectedParentNodePathValue.Trim().Equals(string.Empty)) { elementsParentNode = selectedParentNodePathValue.Split('/'); currentParentNodeInCategoryScheme = cs.Items.First(obj => obj.Id.Equals(elements[1])); } if (elementsParentNode.Length > 1) { for (int i = 2; i < elements.Length; i++) { currentNodeInCategoryScheme = currentNodeInCategoryScheme.Items.First(obj => obj.Id.Equals(elements[i])); } for (int i = 2; i < elementsParentNode.Length; i++) { currentParentNodeInCategoryScheme = currentParentNodeInCategoryScheme.Items.First(obj => obj.Id.Equals(elementsParentNode[i])); } currentParentNodeInCategoryScheme.Items.Remove(currentNodeInCategoryScheme); } else { cs.Items.Remove(currentNodeInCategoryScheme); } try { // Ultimo controllo se ottengo Immutable istanze validazione completa var canRead = cs.ImmutableInstance; } catch (Exception ex) { //parentCategory.Items.Remove( category ); return null; } return cs; }
private void GetAllCategoryInformation() { try { //Devo popolare tutte e due le referenze (Category Categorisation) //DataflowsManager dfMan = new DataflowsManager(this.parsingObject.CloneForReferences(), this.versionTypeResp); //List<MSDataflow> DFs = dfMan.GetMSDataflows(new BuilderParameter() { }); //sdmxObjContainer = new SdmxObjectsImpl(); _dtCSFull = DbAccess.ExecutetoTable(DBOperationEnum.GetCategorySchemes, null); if (_dtCSFull.Rows.Count <= 0) { return; } ReferencesObject.CategoryScheme = new List <ICategorySchemeObject>(); List <ICategorySchemeObject> lCS = new List <ICategorySchemeObject>(); DataView viewCS = new DataView(_dtCSFull); DataTable dtCS = viewCS.ToTable(true, "IDCS", "CSID", "CSAgency", "CSVersion"); ICategorySchemeMutableObject catSchema = null; string filter; foreach (DataRow cs in dtCS.Rows) { catSchema = new CategorySchemeMutableCore(); catSchema.Id = cs["CSID"].ToString(); catSchema.AgencyId = cs["CSAgency"].ToString(); catSchema.Version = cs["CSVersion"].ToString(); // Get Names DataTable dtCSNames = viewCS.ToTable(true, "IDCS", "CSLangName", "CSValueName"); filter = String.Format("IDCS = {0}", cs["IDCS"].ToString()); SetNames(dtCSNames.Select(filter), catSchema); AddChilds(catSchema, filter); ReferencesObject.CategoryScheme.Add(catSchema.ImmutableInstance); } GetCategorisationDataflow(); //ICategoryMutableObject catO; //List<ICategoryMutableObject> lCatO = null; //catO = new CategoryMutableCore(); //catO.AddName("nome", "en"); //catO.Id = row["CatCode"].ToString(); // lCatO.Add(catO); // lCatO = new List<ICategoryMutableObject>(); // csb.Code = row["ID"].ToString(); // csb.CategorySchemeAgencyId = row["Agency"].ToString(); // csb.CategorySchemeVersion = row["Version"].ToString(); // csb.Names.Add(new SdmxObjectNameDescription() { Name = "nome", Lingua = "en" }); // idCS = currIDCS; //ReferencesObject.CategoryScheme.Add(csb.BuildCategorySchemeObject(lCatO)); //csb.Names = SdmxObjectNameDescription.GetNameDescriptions(CategorySchemeNode); //ReferencesObject.CategoryScheme.Add(csb.BuildCategorySchemeObject(CategoryObjects)); //this.ReferencesObject.CategoryScheme = new List<ICategorySchemeObject>(); //this.ReferencesObject.Categorisation = new List<ICategorisationObject>(); //foreach (XmlNode CategorySchemeNode in CategorySchemeList) //{ // csb.Code = CategorySchemeNode.Attributes["Code"].Value.ToString(); // csb.CategorySchemeAgencyId = CategorySchemeNode.Attributes["AgencyId"].Value; // csb.CategorySchemeVersion = CategorySchemeNode.Attributes["Version"].Value; // csb.Names = SdmxObjectNameDescription.GetNameDescriptions(CategorySchemeNode); // List<ICategoryMutableObject> CategoryObjects = RecursivePopulateTreeCategorySP(CategorySchemeNode.ChildNodes, DFs, new List<string>()); // this.ReferencesObject.CategoryScheme.Add(csb.BuildCategorySchemeObject(CategoryObjects)); //} } catch (SdmxException sEx) { throw sEx; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.InternalError, ex); } }