static void GetTablesAttIsRedundant(KBModel model, Artech.Genexus.Common.Objects.Attribute att, out string tables, out string tablesRedundant) { tables = ""; tablesRedundant = ""; if (att.Formula == null) // attribute is not a formula { // return tables; } else { // get all references to the given ATT foreach (EntityReference entityRef in model.GetReferencesTo(att.Key)) { if (entityRef.From.Type == ObjClass.Table) { // Get the references from the tables Table table = model.Objects.Get(entityRef.From.Type, entityRef.From.Id) as Table; if (table != null) // should be an assert() { // Get the TableAttribute (info of the att in the table) Artech.Genexus.Common.Parts.TableAttribute tblAtt = table.TableStructure.GetAttribute(att.Key); if (tblAtt != null && tblAtt.IsFormula && tblAtt.IsRedundant) // IsFormula is not strictly necessary, can be asked outside of the loop (seee above) { tablesRedundant += table.Name + " "; } else { tables += table.Name + " "; } } } } } //return tables; }
internal static void AttributeWithoutTable(List <KBObject> objs, IOutputService output) { List <Artech.Genexus.Common.Objects.Attribute> attTodos = new List <Artech.Genexus.Common.Objects.Attribute>(); KBModel model = null; foreach (KBObject obj in objs) { model = obj.Model; if (obj is Artech.Genexus.Common.Objects.Attribute) { attTodos.Add((Artech.Genexus.Common.Objects.Attribute)obj); } } if (model != null) { foreach (Table t in Table.GetAll(model)) { foreach (EntityReference reference in t.GetReferences(LinkType.UsedObject)) { KBObject objRef = KBObject.Get(model, reference.To); if (objRef is Artech.Genexus.Common.Objects.Attribute) { Artech.Genexus.Common.Objects.Attribute a = (Artech.Genexus.Common.Objects.Attribute)objRef; attTodos.Remove(a); } } } } foreach (Artech.Genexus.Common.Objects.Attribute att in attTodos) { OutputError err = new OutputError("Attribute without table: " + att.Name, MessageLevel.Error, new KBObjectAnyPosition(att)); output.Add("KBDoctor", err); } }
public static void KillAttribute(Artech.Genexus.Common.Objects.Attribute a) { IOutputService output = CommonServices.Output; foreach (EntityReference reference in a.GetReferencesTo()) { KBObject objRef = KBObject.Get(a.Model, reference.From); if (objRef != null) { CleanVariablesBasedInAttribute(a, output, objRef); CleanSDT(a, output, objRef); } if (!(objRef is DataView)) { try { objRef.Save(); } catch (Exception e) { output.AddErrorLine("ERROR: Can't save object: " + objRef.Name + e.Message); } } } }
private static void CleanVariablesBasedInAttribute(Artech.Genexus.Common.Objects.Attribute a, IOutputService output, KBObject objRef) { output.AddLine("Cleaning variables references to " + a.Name + " in " + objRef.Name); VariablesPart vp = objRef.Parts.Get <VariablesPart>(); if (vp != null) { foreach (Variable v in vp.Variables) { if (!v.IsStandard) { if ((v.AttributeBasedOn != null) && (a.Name == v.AttributeBasedOn.Name)) { output.AddLine("&" + v.Name + " based on " + a.Name); eDBType type = v.Type; int length = v.Length; bool signed = v.Signed; string desc = v.Description; int dec = v.Decimals; //Modifico la variable, para que no se base en el atributo. v.AttributeBasedOn = null; v.Type = type; v.Decimals = dec; v.Description = desc; v.Length = length; v.Signed = signed; } } } } }
private static void CleanSDT(Artech.Genexus.Common.Objects.Attribute a, IOutputService output, KBObject objRef) { if (objRef is SDT) { output.AddLine("Cleaning SDT references to " + a.Name + " in " + objRef.Name); SDTStructurePart sdtstruct = objRef.Parts.Get <SDTStructurePart>(); foreach (IStructureItem structItem in sdtstruct.Root.Items) { SDTItem sdtItem = (SDTItem)structItem; if (sdtItem.BasedOn.Key == a.Key) { output.AddLine("..." + sdtItem.Name + " based on " + a.Name); eDBType type = sdtItem.Type; int length = sdtItem.Length; bool signed = sdtItem.Signed; string desc = sdtItem.Description; int dec = sdtItem.Decimals; //Modifico la variable, para que no se base en el atributo. sdtItem.AttributeBasedOn = null; sdtItem.Type = type; sdtItem.Decimals = dec; sdtItem.Description = desc; sdtItem.Length = length; sdtItem.Signed = signed; } } } }
public static void AssignDescriptionToAttribute(object[] parameters, int descriptionToSet) { foreach (object o in parameters) { Dictionary <string, string> dic = (Dictionary <string, string>)o; int cant = 0; string attName = ""; string mensaje = ""; PromptDescription pd; DialogResult dr; foreach (string s in dic.Values) { if (cant == 1) { attName = s; switch (descriptionToSet) { case 0: mensaje = "Insert description for attribute " + attName; break; case 1: mensaje = "Insert title for attribute " + attName; break; case 2: mensaje = "Insert column title for attribute " + attName; break; } pd = new PromptDescription(mensaje); dr = pd.ShowDialog(); if (dr == DialogResult.OK) { Artech.Genexus.Common.Objects.Attribute a = Artech.Genexus.Common.Objects.Attribute.Get(UIServices.KB.CurrentModel, attName); switch (descriptionToSet) { case 0: a.Description = pd.Description; break; case 1: a.Title = pd.Description; break; case 2: a.ColumnTitle = pd.Description; break; } a.Save(); } } cant++; } } }
public static string ReturnPicture(Artech.Genexus.Common.Objects.Attribute a) { string Picture = ""; Picture = a.Type.ToString() + "(" + a.Length.ToString() + (a.Decimals > 0 ? "." + a.Decimals.ToString() : "") + ")" + (a.Signed ? "-" : ""); return(Picture); }
public static void ReplaceDomain() { IKBService kbserv = UIServices.KB; bool success = true; string title = "KBDoctor - Replace domain "; IOutputService output = CommonServices.Output; ReplaceDomain rd = new ReplaceDomain(); DialogResult dr = new DialogResult(); dr = rd.ShowDialog(); if (dr == DialogResult.OK) { output.StartSection(title); Domain od = Functions.DomainByName(rd.originalDomainName); Domain ud = Functions.DomainByName(rd.destDomainName); if (od != null && ud != null) { foreach (EntityReference reference in od.GetReferencesTo()) // LinkType.UsedObject)) { KBObject objRef = KBObject.Get(UIServices.KB.CurrentModel, reference.From); output.AddLine("Procesing " + objRef.Name); if (objRef is Artech.Genexus.Common.Objects.Attribute) { Artech.Genexus.Common.Objects.Attribute att = (Artech.Genexus.Common.Objects.Attribute)objRef; att.DomainBasedOn = ud; att.Save(); } else { VariablesPart vp = objRef.Parts.Get <VariablesPart>(); if (vp != null) { foreach (Variable v in vp.Variables) { if (v.DomainBasedOn == od && !v.IsStandard) { v.DomainBasedOn = ud; } } objRef.Save(); } else { output.AddLine("Replace " + od.Name + " domain manually in object " + objRef.Name); success = false; } } } } output.EndSection(title, success); } }
public static bool AttIsSubtype(Artech.Genexus.Common.Objects.Attribute a) { if (a.SuperTypeKey != null) { return(true); } else { return(false); } }
internal static Artech.Genexus.Common.Objects.Attribute Att2SubType(Artech.Genexus.Common.Objects.Attribute a) { IKBService kbserv = UIServices.KB; EntityKey superTypeKey = a.SuperTypeKey; Artech.Genexus.Common.Objects.Attribute superType = a.GetPropertyValue <Artech.Genexus.Common.Objects.Attribute>("SuperType"); if (superTypeKey != null && (superType == null || superType.Key != superTypeKey)) { superType = Artech.Genexus.Common.Objects.Attribute.Get(kbserv.CurrentModel, superTypeKey.Id); } return(superType); }
private static void ListAttribute(KBObject obj, StreamWriter file) { Artech.Genexus.Common.Objects.Attribute att = (Artech.Genexus.Common.Objects.Attribute)obj; file.WriteLine(Functions.ReturnPicture(att)); if (att.Formula == null) { file.WriteLine(""); } else { file.WriteLine(att.Formula.ToString()); } }
internal static void RemoveAttributesWithoutTable(KBModel kbmodel, IOutputService output, out List <string[]> lineswriter) { lineswriter = new List <string[]>(); // grabo todos los atributos en una colección List <Artech.Genexus.Common.Objects.Attribute> attTodos = new List <Artech.Genexus.Common.Objects.Attribute>(); foreach (Artech.Genexus.Common.Objects.Attribute a in Artech.Genexus.Common.Objects.Attribute.GetAll(kbmodel)) { attTodos.Add(a); } // voy borrando todos los atributos que estan en alguna tabla foreach (Table t in Table.GetAll(kbmodel)) { foreach (EntityReference reference in t.GetReferences(LinkType.UsedObject)) { KBObject objRef = KBObject.Get(kbmodel, reference.To); if (objRef is Artech.Genexus.Common.Objects.Attribute) { Artech.Genexus.Common.Objects.Attribute a = (Artech.Genexus.Common.Objects.Attribute)objRef; attTodos.Remove(a); } } } // TODO: Atributos en dataviews foreach (Artech.Genexus.Common.Objects.Attribute a in attTodos) { if (!Utility.AttIsSubtype(a)) { Utility.KillAttribute(a); string strRemoved = ""; try { a.Delete(); KBDoctorOutput.Message("Atribute deleted: " + a.Name); } catch (Exception e) { output.AddErrorLine("Can't delete " + a.Name + " Msg: " + e.Message); } string attNameLink = Utility.linkObject(a); //"<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;OpenObject&name=" + a.Guid.ToString() + "\">" + a.Name + "</a>"; strRemoved = "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;RemoveObject&guid=" + a.Guid.ToString() + "\">Remove</a>"; string Picture = Utility.FormattedTypeAttribute(a); lineswriter.Add(new string[] { strRemoved, attNameLink, a.Description, Picture }); } } }
private static string DomainLinkFromAttribute(Artech.Genexus.Common.Objects.Attribute a) { string domLink = ""; if (a.DomainBasedOn != null) { KBObject dom = Domain.Get(UIServices.KB.CurrentModel, a.DomainKey); domLink = Functions.linkObject(dom); //"<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;OpenObject&name=" + dom.Guid.ToString() + "\">" + dom.Name + "</a>"; } else { domLink = ""; } return(domLink); }
private static string SuggestedDomains(IKBService kbserv, Artech.Genexus.Common.Objects.Attribute a) { string suggestedDomains = ""; foreach (Domain d in Domain.GetAll(kbserv.CurrentModel)) { if ((a.Type == d.Type) && (a.Length == d.Length) && (a.Decimals == d.Decimals) && (a.Signed == d.Signed)) { if (suggestedDomains != "") { suggestedDomains += ", "; } suggestedDomains += "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;AssignDomainToAttribute&attName=" + a.Name + "&domainName=" + d.Name + "\">" + d.Name + "</a>"; } } return(suggestedDomains); }
internal static void AttributeHasDomain(List <KBObject> objs, IOutputService output) { foreach (KBObject obj in objs) { if (obj is Artech.Genexus.Common.Objects.Attribute) { Artech.Genexus.Common.Objects.Attribute a = (Artech.Genexus.Common.Objects.Attribute)obj; string Picture = Utility.ReturnPicture(a); bool isSubtype = Utility.AttIsSubtype(a); if ((a.DomainBasedOn == null) && !isSubtype && Utility.AttHasToBeInDomain(a)) { OutputError err = new OutputError("Attribute without domain: " + a.Name, MessageLevel.Warning, new KBObjectAnyPosition(obj)); output.Add("KBDoctor", err); } } } }
public static string TableOfAtt(Artech.Genexus.Common.Objects.Attribute att) { IKBService kbserv = UIServices.KB; string tables = ""; foreach (EntityReference entityRef in kbserv.CurrentModel.GetReferencesTo(att.Key)) { if (entityRef.From.Type == ObjClass.Table) { // Get the references from the tables Table table = kbserv.CurrentModel.Objects.Get(entityRef.From.Type, entityRef.From.Id) as Table; if (table != null) // should be an assert() { tables += table.Name + " "; } } } return(tables); }
internal static void CleanSDT(Artech.Genexus.Common.Objects.Attribute a, IOutputService output, KBObject objRef) { if (objRef is SDT) { output.AddLine("Cleaning SDT references to " + a.Name + " in " + objRef.Name); SDTStructurePart sdtstruct = objRef.Parts.Get <SDTStructurePart>(); foreach (IStructureItem structItem in sdtstruct.Root.Items) { SDTItem sdtItem = (SDTItem)structItem; //Esto es para permitir trabajar con Evo3 y la 15. EntityKey myKey = new EntityKey(a.Key); #if EVO3 myKey = sdtItem.BasedOn.ObjKey; #else myKey = sdtItem.BasedOn.Key; #endif //Termina compilacion condicional. if (sdtItem.BasedOn != null && myKey == a.Key) { output.AddLine("..." + sdtItem.Name + " based on " + a.Name); eDBType type = sdtItem.Type; int length = sdtItem.Length; bool signed = sdtItem.Signed; string desc = sdtItem.Description; int dec = sdtItem.Decimals; //Modifico la variable, para que no se base en el atributo. sdtItem.AttributeBasedOn = null; sdtItem.Type = type; sdtItem.Decimals = dec; sdtItem.Description = desc; sdtItem.Length = length; sdtItem.Signed = signed; } } } }
public static void AssignDomainToAttribute(object[] parameters) { foreach (object o in parameters) { Dictionary <string, string> dic = (Dictionary <string, string>)o; int cant = 0; string attName = ""; string domainName = ""; foreach (string s in dic.Values) { switch (cant) { case 1: attName = s; break; case 2: domainName = s; break; default: break; } cant++; if ((attName != "") && (domainName != "")) { Artech.Genexus.Common.Objects.Attribute a = Artech.Genexus.Common.Objects.Attribute.Get(UIServices.KB.CurrentModel, attName); Domain d = Functions.DomainByName(domainName); a.DomainBasedOn = d; a.Save(); } } } }
public static string TransactionsOfAtt(Artech.Genexus.Common.Objects.Attribute att, out bool canDelete) { IKBService kbserv = UIServices.KB; string transactions = ""; canDelete = true; foreach (EntityReference entityRef in kbserv.CurrentModel.GetReferencesTo(att.Key)) { if (entityRef.From.Type == ObjClass.Transaction) { // Get the references from the tables Transaction Trn = kbserv.CurrentModel.Objects.Get(entityRef.From.Type, entityRef.From.Id) as Transaction; if (Trn != null) // should be an assert() { transactions += Trn.Name + " "; if (Trn.GetPropertyValue <bool>(Properties.TRN.GenerateObject)) { canDelete = false; } } } } return(transactions); }
private static void CleanSDT(Artech.Genexus.Common.Objects.Attribute a, IOutputService output, KBObject objRef) { if (objRef is SDT) { output.AddLine("Cleaning SDT references to " + a.Name + " in " + objRef.Name); SDTStructurePart sdtstruct = objRef.Parts.Get <SDTStructurePart>(); foreach (IStructureItem structItem in sdtstruct.Root.Items) { try { SDTItem sdtItem = (SDTItem)structItem; EntityKey myKey = KBDoctorCore.Sources.Utility.KeyOfBasedOn_CompatibleConEvo3(sdtItem); if (sdtItem.BasedOn != null && myKey == a.Key) { output.AddLine("..." + sdtItem.Name + " based on " + a.Name); eDBType type = sdtItem.Type; int length = sdtItem.Length; bool signed = sdtItem.Signed; string desc = sdtItem.Description; int dec = sdtItem.Decimals; //Modifico la variable, para que no se base en el atributo. sdtItem.AttributeBasedOn = null; sdtItem.Type = type; sdtItem.Decimals = dec; sdtItem.Description = desc; sdtItem.Length = length; sdtItem.Signed = signed; } } catch (Exception e) { output.AddErrorLine(e.Message); }; } } }
internal static bool AttHasToBeInDomain(Artech.Genexus.Common.Objects.Attribute a) { return(TypeHasToBeInDomain(a.Type)); }
private static void WriteObjectContent(KBObject obj, StreamWriter file) { RulesPart rp = obj.Parts.Get <RulesPart>(); if (rp != null) { file.WriteLine(Environment.NewLine + "=== RULES ==="); file.WriteLine(rp.Source); } EventsPart ep = obj.Parts.Get <EventsPart>(); if (ep != null) { file.WriteLine(Environment.NewLine + "=== EVENTS SOURCE ==="); file.WriteLine(ep.Source); } switch (obj.TypeDescriptor.Name) { case "Attribute": Artech.Genexus.Common.Objects.Attribute att = (Artech.Genexus.Common.Objects.Attribute)obj; file.WriteLine(Functions.ReturnPicture(att)); if (att.Formula == null) { file.WriteLine(""); } else { file.WriteLine(att.Formula.ToString()); } break; case "Procedure": ProcedurePart pp = obj.Parts.Get <ProcedurePart>(); if (pp != null) { file.WriteLine(Environment.NewLine + "=== PROCEDURE SOURCE ==="); file.WriteLine(pp.Source); } break; case "Transaction": StructurePart sp = obj.Parts.Get <StructurePart>(); if (sp != null) { file.WriteLine(Environment.NewLine + "=== STRUCTURE ==="); file.WriteLine(sp.ToString()); } break; case "WorkPanel": break; case "WebPanel": break; case "WebComponent": break; case "Table": Table tbl = (Table)obj; foreach (TableAttribute attr in tbl.TableStructure.Attributes) { String line = ""; if (attr.IsKey) { line = "*"; } else { line = " "; } line += attr.Name + " " + attr.GetPropertiesObject().GetPropertyValueString("DataTypeString") + "-" + attr.GetPropertiesObject().GetPropertyValueString("Formula"); if (attr.IsExternalRedundant) { line += " External_Redundant"; } line += " Null=" + attr.IsNullable; if (attr.IsRedundant) { line += " Redundant"; } file.WriteLine(line); } break; case "SDT": SDT sdtToList = (SDT)obj; if (sdtToList != null) { file.WriteLine(Environment.NewLine + "=== STRUCTURE ==="); ListStructure(sdtToList.SDTStructure.Root, 0, file); } break; default: //Unknown object. Use export format. file.Write(SerializeObject(obj).ToString()); break; } file.WriteLine(Environment.NewLine + "====== PROPERTIES ======="); foreach (Property prop in obj.Properties) { if (!prop.IsDefault) { file.WriteLine(prop.Name + " -> " + prop.Value.ToString()); } else { if ((prop.Name == "CommitOnExit") || (prop.Name == "TRNCMT") || (prop.Name == "GenerateObject")) { file.WriteLine(prop.Name + " -> " + prop.Value.ToString()); } } } //CATEGORIES IEnumerable <Artech.Udm.Framework.References.EntityReference> refe = obj.GetReferences(); string GUIDCatString = "00000000-0000-0000-0000-000000000006"; List <string> categories = new List <string>(); foreach (Artech.Udm.Framework.References.EntityReference reference in refe) { Guid GUIDRefTo = reference.To.Type; string GUIDRefToString = GUIDRefTo.ToString(); if (GUIDRefToString == GUIDCatString) { KBCategory cat = KBCategory.Get(UIServices.KB.CurrentModel, reference.To.Id); categories.Add(cat.Name); } } if (categories.Count > 0) { file.WriteLine(Environment.NewLine + "====== CATEGORIES ======="); foreach (string name in categories) { file.WriteLine(name); } } }
private void button1_Click(object sender, EventArgs e) { Item it = (Item)comboVar.SelectedItem; if (it != null) { Variable v3 = it.Var; if (v3 != null) { AttributeVariableDialogInfo info = new AttributeVariableDialogInfo(); info.Filter = TypedObjectKind.Attribute | TypedObjectKind.Domain; info.DialogTitle = "Select domain/Attribute"; info.MultiSelection = false; IList <object> selectedAtts = GenexusUIServices.SelectAttributeVariable.SelectAttributeVariable(info); if (selectedAtts.Count > 0) { Domain dom = null; try { dom = (Domain)selectedAtts[0]; } catch (Exception ee) { Console.WriteLine("{0} Exception caught.", ee); dom = null; }; if (dom != null) { if (v3.Type != dom.Type) { MessageBox.Show("Different types !! " + v3.Type.ToString() + " " + dom.TypeDescriptor.Name); } v3.DomainBasedOn = dom; v3.KBObject.Save(); comboVar.Items.Remove(it); cantVariables.Text = comboVar.Items.Count.ToString() + " not based variables"; source.Text = ""; if (comboVar.Items.Count == 0) { this.Close(); return; } else { comboVar.SelectedIndex = 0; } comboVar.SelectedIndex = 0; } else { Artech.Genexus.Common.Objects.Attribute att = (Artech.Genexus.Common.Objects.Attribute)selectedAtts[0]; if (att != null) { if (v3.Type != att.Type) { MessageBox.Show("Different types!!" + v3.Type.ToString() + " " + att.TypeDescriptor.Name); } v3.AttributeBasedOn = att; v3.KBObject.Save(); comboVar.Items.Remove(it); cantVariables.Text = comboVar.Items.Count.ToString() + " not based variables"; source.Text = ""; if (comboVar.Items.Count == 0) { this.Close(); return; } else { comboVar.SelectedIndex = 0; } } } } } } else { //Debe seleccionar una variable } }
// public static List<KBObject> ObjectsUpdateAttribute(List<KBObject> updaters, Artech.Genexus.Common.Objects.Attribute att, IOutputService output) { return Objects.ObjectsUpdateAttribute(updaters, att, output); }
public static void AttInOneTrnOnly() { IKBService kbserv = UIServices.KB; string title = "KBDoctor - Attributes in Transaction only"; string outputFile = Functions.CreateOutputFile(kbserv, title); IOutputService output = CommonServices.Output; output.StartSection(title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Attribute", "can delete", "Description", "Data type", "Tables", "Transactions" }); // grabo todos los atributos en una colección output.AddLine("Loading attributes.."); List <Artech.Genexus.Common.Objects.Attribute> attTodos = new List <Artech.Genexus.Common.Objects.Attribute>(); foreach (Artech.Genexus.Common.Objects.Attribute a in Artech.Genexus.Common.Objects.Attribute.GetAll(kbserv.CurrentModel)) { attTodos.Add(a); } output.AddLine("Procesiong objects.."); foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { // output.AddLine("Procesing .. " + obj.Name); if ((!(obj is Transaction) && !(obj is Table) && !(obj is SDT)) || obj.GetPropertyValue <bool>("idISBUSINESSCOMPONENT")) { foreach (EntityReference reference in obj.GetReferences(LinkType.UsedObject)) { KBObject objRef = KBObject.Get(kbserv.CurrentModel, reference.To); if (objRef is Artech.Genexus.Common.Objects.Attribute) { Artech.Genexus.Common.Objects.Attribute a = (Artech.Genexus.Common.Objects.Attribute)objRef; attTodos.Remove(a); } } } } foreach (Artech.Genexus.Common.Objects.Attribute a in attTodos) { output.AddLine("Procesing .. " + a.Name); string attNameLink = Functions.linkObject(a); // "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;OpenObject&name=" + a.Guid.ToString() + "\">" + a.Name + "</a>"; string Picture = Functions.ReturnPicture(a); string table = TableOfAtt(a); bool canDelete; string trns = TransactionsOfAtt(a, out canDelete); string strCanDelete = canDelete ? "Yes" : ""; writer.AddTableData(new string[] { attNameLink, strCanDelete, a.Description, Picture, table, trns }); } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }
public static void AddDescriptorIndex(object[] parameters) { foreach (object o in parameters) { Dictionary <string, string> dic = (Dictionary <string, string>)o; int cant = 0; string tabName = ""; foreach (string s in dic.Values) { if (cant == 1) { tabName = s; } cant++; } // mensaje = "Insert a name for the index:"; // pd = new PromptDescription(mensaje); // dr = pd.ShowDialog(); //if (dr == DialogResult.OK) //{ IKBService kbserv = UIServices.KB; Artech.Genexus.Common.Objects.Index i = Artech.Genexus.Common.Objects.Index.Create(kbserv.CurrentModel); try { Table t = Table.Get(kbserv.CurrentModel, tabName); if (t != null) { Artech.Genexus.Common.Objects.Attribute descAtt = t.TableStructure.DescriptionAttribute.Attribute; if (descAtt != null) { i.Name = t.Name + "_" + descAtt.Name; i.IndexType = Artech.Genexus.Common.IndexType.Unique; i.Source = IndexSource.User; i.Description = "Descriptor index"; IndexMember idxMember = new IndexMember(i.IndexStructure); idxMember.Attribute = t.TableStructure.DescriptionAttribute.Attribute; idxMember.Order = IndexOrder.Ascending; // o IndexOrder.Descending i.IndexStructure.Members.Add(idxMember); // Agregarlo a la tabla t.TableIndexes.Indexes.Add(new TableIndex(t.TableIndexes, i)); t.Save(); MessageBox.Show("Index " + i.Name + " was successfully created."); } } } catch (GxException gxe) { MessageBox.Show(gxe.Message, "Could not create index", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //} } }