internal void LoadTab(List <object> items, object filter) { string tabName, tooltipText; if (items.Count == 0 || (items.Count > 0 && items[0] == null)) { return; } var type = items[0].GetType(); if (type == typeof(TaxonomyInfo)) { var nodes = items.Cast <TaxonomyInfo>().ToList(); if (nodes.Count == 1) { foreach (var tab in AryaTools.Instance.Forms.SchemaTabs.Where(tab => tab.Value.CurrentTaxonomies != null && tab.Value.CurrentTaxonomies.Count <= 1 && tab.Value.CurrentTaxonomies[0].Equals(nodes[0]))) { AryaTools.Instance.Forms.SchemaForm.mainTabControl.SelectedTab = tab.Key; return; } } var schemaGridView = new SchemaDataGridView(nodes); GetTabName(nodes, nodes, out tabName, out tooltipText); LoadNewTab(schemaGridView, "T:" + tabName, String.Format("{0} node(s):{1}{2}", nodes.Count, Environment.NewLine, tooltipText)); return; } if (type == typeof(Attribute)) { var atts = items.Cast <Attribute>().ToList(); if (atts.Count == 1) { foreach (var tab in AryaTools.Instance.Forms.SchemaTabs.Where(tab => tab.Value.CurrentAttributes != null && tab.Value.CurrentAttributes.Count <= 1 && tab.Value.CurrentAttributes[0].Equals(atts[0]))) { AryaTools.Instance.Forms.SchemaForm.mainTabControl.SelectedTab = tab.Key; return; } } var filterTax = filter is TaxonomyInfo ? (TaxonomyInfo)filter : null; var schemaGridView = new SchemaDataGridView(atts, filterTax); GetTabName(atts, out tabName, out tooltipText); LoadNewTab(schemaGridView, "A:" + tabName, String.Format("{0} attribute(s):{1}{2}", atts.Count, Environment.NewLine, tooltipText)); } }
private void LoadNewTab(SchemaDataGridView schemaGridView, string tabName, string tooltipText) { var newTab = new TabPage(tabName) { ToolTipText = tooltipText }; mainTabControl.TabPages.Add(newTab); mainTabControl.SelectTab(newTab); newTab.Controls.Add(schemaGridView); schemaGridView.Dock = DockStyle.Fill; AryaTools.Instance.Forms.SchemaTabs.Add(newTab, schemaGridView); UpdateTitleAndStatus(); AryaTools.Instance.Forms.SchemaForm.Show(); AryaTools.Instance.Forms.SchemaForm.BringToFront(); if (AryaTools.Instance.Forms.SchemaForm.WindowState == FormWindowState.Minimized) { AryaTools.Instance.Forms.SchemaForm.WindowState = FormWindowState.Maximized; } }
private bool Validar() { SchemaDataGridView.EndEdit(); foreach (CMData.Schemas.XsdDataBase.TBL_SchemaRow Item in DataBaseDataSet.TBL_Schema) { // Validar que las casilla no se encuentre vacias if (Item.Schema_Alias == "") { var Respuesta = MessageBox.Show("El nombre de clase del Schemao: " + Item.Schema_Name + " no puede quedar vacio, ¿desea usar el nombre del Esquema como alias de clase?", Program.AssemblyTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (Respuesta == System.Windows.Forms.DialogResult.Yes) { Item.Schema_Alias = FormatCode.ToIdentifier(Item["Schema_Name"].ToString()); } else { return(false); } } } return(true); }
public static string SetValue(TaxonomyInfo taxonomy, Attribute attribute, bool autoMapSchema, SchemaAttribute schematus, object value, bool suppressAutoMapMessage = false) { var schemaInfo = taxonomy.SchemaInfos.FirstOrDefault(si => si.Attribute.Equals(attribute)); var newSchemaInfo = false; if (schemaInfo == null) { if (suppressAutoMapMessage) { return(null); } if (!autoMapSchema && MessageBox.Show( String.Format("Attribute [{0}] is not mapped in Node [{1}]. Do you want to map it?", attribute, taxonomy.TaxonomyData.NodeName), @"Add to Schema", MessageBoxButtons.YesNo) == DialogResult.No) { return(null); } schemaInfo = new SchemaInfo { Attribute = attribute }; taxonomy.SchemaInfos.Add(schemaInfo); newSchemaInfo = true; } if (schematus == null) { //Create/Update Schema Info only var currentSchemaData = schemaInfo.SchemaData; var newSchemaData = new SchemaData(); if (value != null && value is SchemaData) { var fromSchemaData = (SchemaData)value; if (currentSchemaData != null && currentSchemaData.Equals(fromSchemaData)) { return(null); } newSchemaData.DataType = fromSchemaData.DataType; newSchemaData.DisplayOrder = fromSchemaData.DisplayOrder; newSchemaData.NavigationOrder = fromSchemaData.NavigationOrder; newSchemaData.InSchema = fromSchemaData.InSchema; } if (currentSchemaData != null) { currentSchemaData.Active = false; } schemaInfo.SchemaDatas.Add(newSchemaData); return(null); } var activeSd = schemaInfo.SchemaData; switch (schematus.AttributeType) { case SchemaAttributeType.Primary: var reallyNewSd = false; var reorderRanks = false; SchemaData newSchemaData; if (activeSd == null) { reallyNewSd = true; newSchemaData = new SchemaData(); } else { //activeSd.DeletedBy = AryaTools.Instance.InstanceData.CurrentUser.ID; activeSd.DeletedByUser = AryaTools.Instance.InstanceData.CurrentUser; //fixes Object not found error activeSd.DeletedOn = DateTime.Now; newSchemaData = new SchemaData { DataType = activeSd.DataType, InSchema = activeSd.InSchema, NavigationOrder = activeSd.NavigationOrder, DisplayOrder = activeSd.DisplayOrder }; } var propertyName = schematus.PrimarySchemaAttribute.Replace(" ", String.Empty); var valueProperty = newSchemaData.GetType().GetProperty(propertyName); var propertyType = valueProperty.PropertyType; if (propertyType == typeof(string)) { var stringValue = value ?? String.Empty; if (propertyName == "DataType") { stringValue = ValidateDataType(stringValue); } if (!(valueProperty.GetValue(newSchemaData, null) ?? String.Empty).Equals(stringValue)) { reallyNewSd = true; valueProperty.SetValue(newSchemaData, stringValue.ToString(), null); } } else if (propertyType == typeof(bool)) { var boolValue = value ?? false; string firstCharacter; try { firstCharacter = boolValue.ToString().Substring(0, 1).ToLower(); } catch (Exception) { firstCharacter = "f"; } var newValue = firstCharacter.Equals("t") || firstCharacter.Equals("y") || firstCharacter.Equals("1"); if (!((bool)valueProperty.GetValue(newSchemaData, null)).Equals(newValue)) { reallyNewSd = true; valueProperty.SetValue(newSchemaData, newValue, null); } } else if (propertyType == typeof(decimal)) { var decimalValue = value ?? 0.0; decimal newDecimalValue; if (Decimal.TryParse(decimalValue.ToString(), out newDecimalValue)) { if (!((decimal)valueProperty.GetValue(newSchemaData, null)).Equals(newDecimalValue)) { reallyNewSd = true; valueProperty.SetValue(newSchemaData, newDecimalValue, null); reorderRanks = SchemaDataGridView.AutoOrderRanks; } } else { return(String.Format("Invalid value [{0}] for [{1}] - [{2}].{3}Expected a decimal value.", decimalValue, taxonomy.NodeName, attribute, Environment.NewLine)); } } else { return(String.Format("Unknown data type for value [{0}] for [{1}] - [{2}]", value ?? String.Empty, taxonomy.NodeName, attribute)); } if (reallyNewSd) { if (activeSd != null) { activeSd.Active = false; } schemaInfo.SchemaDatas.Add(newSchemaData); if (reorderRanks) { AutoOrderRanks(newSchemaData.SchemaInfo.TaxonomyInfo, newSchemaData); } } return(null); case SchemaAttributeType.Meta: var reallyNewSmd = false; if (schematus.DataType == typeof(bool)) { value = value.ToString().StartsWith("y", StringComparison.OrdinalIgnoreCase) ? "Yes" : "No"; } //First check if there is an active SchemaData if (activeSd == null) { if (suppressAutoMapMessage) { return(null); } if (!newSchemaInfo && !autoMapSchema && MessageBox.Show( String.Format("Attribute [{0}] is not mapped in Node [{1}]. Do you want to map it?", attribute, taxonomy.TaxonomyData.NodeName), "Add to Schema", MessageBoxButtons.YesNo) == DialogResult.No) { return(null); } schemaInfo.SchemaDatas.Add(new SchemaData()); reallyNewSmd = true; } var activeSmi = (from mi in schemaInfo.SchemaMetaInfos where mi.Attribute.Equals(schematus.MetaSchemaAttribute) select mi).FirstOrDefault(); if (activeSmi == null) { activeSmi = new SchemaMetaInfo { Attribute = schematus.MetaSchemaAttribute }; schemaInfo.SchemaMetaInfos.Add(activeSmi); reallyNewSmd = true; } var activeSmd = activeSmi.SchemaMetaData; if (activeSmd == null) { reallyNewSmd = true; } else if (value == null || !activeSmd.Value.Equals(value)) { reallyNewSmd = true; activeSmd.Active = false; } if (reallyNewSmd && value != null && !String.IsNullOrEmpty(value.ToString())) { activeSmi.SchemaMetaDatas.Add(new SchemaMetaData { Value = value.ToString() }); SchemaDataGridView.UpdateAutoCompleteSource(schematus.MetaSchemaAttribute, value.ToString()); } return(null); default: return("Unknown Meta-attribute Type! Weird!!!"); } }