private static void ListCategories(KBObject obj, StreamWriter file) { //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) { PrintSectionHeader("CATEGORIES", file); foreach (string name in categories) { file.WriteLine(name); } } }
private static KBObjectCollection CreatLocationCollection(string location) { KBObjectCollection objColl = new KBObjectCollection(); IKBService kB = UIServices.KB; IOutputService output = CommonServices.Output; KBCategory mainCategory = KBCategory.Get(kB.CurrentModel, "Main Programs"); foreach (KBObject obj in mainCategory.AllMembers) { string objLocation = (string)obj.GetProperty("AppLocation").Value; if (objLocation == "") { obj.SilentSetPropertyValue("AppLocation", "WEB"); } string objAppGenerator = obj.GetPropertyValueString("AppGenerator"); string Dircopia; if (objAppGenerator.ToUpper().Contains("WEB")) { Dircopia = "Web\\bin\\"; } else { Dircopia = "bin\\"; } if (objLocation == null) { objLocation = "none"; } string letra = ""; if (location == objLocation) { output.AddLine("set DESTINO=" + objLocation); output.AddLine("XCOPY " + Dircopia + obj.Name + ".dll %DESTINO%"); if (obj is Procedure) { letra = "a"; } if (obj is WorkPanel) { letra = "u"; } if (obj is Transaction) { letra = ""; } output.AddLine("XCOPY " + Dircopia + letra + obj.Name + ".dll %DESTINO%"); AddReferencedObj(objColl, obj, ""); } } return(objColl); }
public static void CleanKBAsMuchAsPossible() { IKBService kbserv = UIServices.KB; IOutputService output = CommonServices.Output; string mensaje = "Do you have a backup?. Are you sure you want to clean the KB? Some objects will be modified and deleted."; DialogResult dr = MessageBox.Show(mensaje, "Clean KB", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { ObjectsHelper.CleanVarsNotUsed(); CleanKBHelper.RemoveAttributeWithoutTable(); ObjectsHelper.Unreachables(); KBCategory UnreachableCategory = KBCategory.Get(kbserv.CurrentModel, "KBDoctor.UnReachable"); foreach (KBObject obj in UnreachableCategory.AllMembers) { KBDoctorCore.Sources.API.CleanKBObject(obj, output); } ProcessObjectsInCategory(output, UnreachableCategory); output.AddLine("Finish"); } }
internal static KBCategory MainCategory(KBModel model) { return(KBCategory.Get(model, "Main Programs")); }
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); } } }