/// <summary> /// Cambia los objetos transaction y webpanels y los WebForms. /// </summary> /// <param name="obj">Objeto a cambiar</param> /// <param name="txtfind">texto a buscar</param> /// <param name="txtreplace">texto a remplazar</param> public static bool ReplaceWebForm(KBObject obj, string txtfind, string txtreplace) { bool cambio = false; if ((obj is Transaction) || (obj is WebPanel)) { WebFormPart wfPart = obj.Parts.Get <WebFormPart>(); if (wfPart != null) { XmlDocument xmldoc = wfPart.Document; if (xmldoc != null) { string source = xmldoc.OuterXml; string source2 = source.Replace(txtfind, txtreplace); source2 = source2.Replace(txtfind.ToLower(), txtreplace); source2 = source2.Replace(txtfind.ToUpper(), txtreplace); if (source != source2) { XmlDocument doc = new XmlDocument(); doc.LoadXml(source2); wfPart.Document = doc; cambio = true; } } } } return(cambio); }
public static StringCollection LoadUsedClasses() { StringCollection UsedClasses = new StringCollection(); foreach (KBObject obj in UIServices.KB.CurrentModel.Objects.GetAll()) { //ShowSomeMessages("Processing " + obj.Name); if (((obj is Transaction) || (obj is WebPanel)) && (obj.GetPropertyValue <bool>(Properties.TRN.GenerateObject))) { WebFormPart webForm = obj.Parts.Get <WebFormPart>(); foreach (IWebTag tag in WebFormHelper.EnumerateWebTag(webForm)) { if (tag.Properties != null) { PropertyDescriptor prop = tag.Properties.GetPropertyDescriptorByDisplayName("Class"); if (prop != null) { var val = prop.GetValue(tag); string miclstr = val.ToString(); if (!UsedClasses.Contains(miclstr)) { KBDoctorOutput.Message("Class : " + miclstr + " in " + obj.Name + " Tag: " + tag.Type.ToString()); UsedClasses.Add(miclstr); } } } } } } return(UsedClasses); }
public static void LoadAndCheckUsedClasses(IKBService kbserv, IOutputService output, StringCollection UsedClasses, StringCollection ThemeClasses, KBDoctorXMLWriter writer) { int cant = 0; foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { if ((cant % 100) == 0) { KBDoctorOutput.Message("Procesing.." + cant.ToString() + " objects "); } cant += 1; if (((obj is Transaction) || (obj is WebPanel)) && (obj.GetPropertyValue <bool>(Properties.TRN.GenerateObject))) { WebFormPart webForm = obj.Parts.Get <WebFormPart>(); foreach (IWebTag tag in WebFormHelper.EnumerateWebTag(webForm)) { if (tag.Properties != null) { PropertyDescriptor prop = tag.Properties.GetPropertyDescriptorByDisplayName("Class"); if (prop != null) { //arreglar acan cancela con la Evo3. ThemeClassReferenceList miclasslist = new ThemeClassReferenceList(); // try // { // miclasslist = (ThemeClassReferenceList)prop.GetValue(new object()); // } // catch (Exception e) { // KBDoctorOutput.Error("LoadAndCheckUsedClasses:" + e.Message + " " + e.InnerException); // throw e; // }; foreach (ThemeClass miclass in miclasslist.GetThemeClasses(obj.Model)) { if (miclass != null) { string miclstr = miclass.Name.ToLower(); if (!UsedClasses.Contains(miclstr)) { UsedClasses.Add(miclstr); } if (!ThemeClasses.Contains(miclstr)) { bool classEstaEnElTheme = VeoSiClassEstaContenidaEnAlgunaClassDelTheme(ThemeClasses, miclstr); if (!classEstaEnElTheme) { string objName = obj.Name; KBDoctorOutput.Message(" Object : " + obj.Name + " reference class " + miclstr + " which not exist in Theme"); string objNameLink = Functions.linkObject(obj); writer.AddTableData(new string[] { objNameLink, miclstr, " does not exist in theme" }); } } } } } } } } } }
public static void LoadUsedClasses(IKBService kbserv, IOutputService output, StringCollection UsedClasses) { int cant = 0; foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { if ((cant % 100) == 0) { output.AddLine("Procesing.." + cant.ToString() + " objects "); } cant += 1; if (((obj is Transaction) || (obj is WebPanel) || obj is ThemeClass) && (obj.GetPropertyValue <bool>(Properties.TRN.GenerateObject))) { WebFormPart webForm = obj.Parts.Get <WebFormPart>(); output.AddLine(" Object : " + obj.Name); foreach (IWebTag tag in WebFormHelper.EnumerateWebTag(webForm)) { if (tag.Properties != null) { PropertyDescriptor prop = tag.Properties.GetPropertyDescriptorByDisplayName("Class"); if (prop != null) { ThemeClassReferenceList miclasslist = new ThemeClassReferenceList(); try { miclasslist = (ThemeClassReferenceList)prop.GetValue(new object()); } catch (Exception e) { Console.WriteLine(e.InnerException); }; foreach (ThemeClass miclass in miclasslist.GetThemeClasses(obj.Model)) { if (miclass != null) { string miclstr = miclass.Root.Description + '-' + miclass.Name.ToLower(); if (!UsedClasses.Contains(miclstr)) { UsedClasses.Add(miclstr); } } } } } } } } }
public static bool CheckObjUsesVariable(Variable v, KBObject obj) { bool varused = true; if (!v.IsStandard) { varused = false; ProcedurePart pp = obj.Parts.Get <ProcedurePart>(); if (pp != null) { varused = VariableIsUsedInText(pp.Source, v.Name); } if (!varused) { RulesPart rp = obj.Parts.Get <RulesPart>(); if (rp != null) { varused = VariableIsUsedInText(rp.Source, v.Name); } } if (!varused) { ConditionsPart cp = obj.Parts.Get <ConditionsPart>(); if (cp != null) { varused = VariableIsUsedInText(cp.Source, v.Name); } } if (!varused) { EventsPart ep = obj.Parts.Get <EventsPart>(); if (ep != null) { varused = VariableIsUsedInText(ep.Source, v.Name); } } if (!varused) { WebFormPart fp = obj.Parts.Get <WebFormPart>(); if (fp != null) { varused = VariableIsUsedInWebForm(fp, v.Id);; } } } return(varused); }
public static void ListDynamicCombo() { IKBService kbserv = UIServices.KB; string title = "KBDoctor - List objects with dynamic combobox in grid columns"; try { string outputFile = Functions.CreateOutputFile(kbserv, title); IOutputService output = CommonServices.Output; output.StartSection("KBDoctor", title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Object", "Description", "Control Name", "Col Visible", "Suggest" }); //All useful objects are added to a collection foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { string objName = obj.Name; if (obj is WebPanel) { //KBDoctorOutput.Message( "Procesing.." + obj.Name); WebFormPart webForm = obj.Parts.Get <WebFormPart>(); foreach (IWebTag current in WebFormHelper.EnumerateWebTag(webForm)) { if (current.Node.ParentNode.Name == "gxGrid" && current.Type == WebTagType.Column) { string controlName = current.Properties.GetPropertyValueString("ControlName"); string controltype = current.Properties.GetPropertyValueString("ControlType"); bool hidden = current.Properties.GetPropertyValue <bool>("ColVisible"); // string att = current.Properties.GetPropertyValueString("Attribute"); if (controltype == "Dynamic Combo Box") { KBDoctorOutput.Message(">>>>Procesing.." + obj.Name + "-" + current.Type); writer.AddTableData(new string[] { Functions.linkObject(obj), obj.Description, controlName, hidden.ToString(), "N/A" }); } string suggest = current.Properties.GetPropertyValueString("EditAutocomplete"); object suggest_obj = current.Properties.GetPropertyValue("EditAutocomplete"); string read_only = current.Properties.GetPropertyValueString("ColReadOnly"); if (controltype == "Edit" && suggest != "No" && read_only == "True") { current.Properties.SilentSetPropertyValue("EditAutocomplete", 0); webForm.Save(); writer.AddTableData(new string[] { Functions.linkObject(obj), obj.Description, controlName, hidden.ToString(), suggest }); } } } } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection("KBDoctor", title, success); } catch { bool success = false; KBDoctor.KBDoctorOutput.EndSection(title, success); } }
private static bool VariableIsUsedInWebForm(WebFormPart wF, int varId) { return(wF.GetVariable(varId) != null); }
internal int MergeWebForm(WebFormPart obj, PatternInstanceElement c, string template,bool overwrite) { if (!String.IsNullOrEmpty(template)) { return MergeWebForm(obj, AppendTemplateOutput(obj.KBObject, obj, c, template)); } return 0; }
internal static int MergeWebForm(WebFormPart obj, string webform) { string oldValue = obj.EditableContent; try { obj.EditableContent = webform; obj.EditableToStored(); } catch (Exception ex) { throw new TemplateException(obj.KBObject.Name, ex); } return (oldValue != obj.EditableContent ? 1 : 0); }
public static void ObjectsWithVarNotBasedOnAtt() { IKBService kbserv = UIServices.KB; string title = "KBDoctor - Object with variables not based on attribute/domain"; 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[] { "Type", "Name", "Variable", "Attribute", "Domain" }); //All useful objects are added to a collection foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { output.AddLine("Procesing.." + obj.Name); if ((obj is Transaction) || (obj is WebPanel)) { WebFormPart webForm = obj.Parts.Get <WebFormPart>(); foreach (IWebTag current in WebFormHelper.EnumerateWebTag(webForm)) { output.AddLine("Procesing.." + obj.Name + "-"); } } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); /* * type = obj.TypeDescriptor.Description; * name = obj.Name; * primerVarObj = true; * if (isGenerated(obj)) * { * VariablesPart vp = obj.Parts.Get<VariablesPart>(); * if (vp != null) * { * foreach (Variable v in vp.Variables) * { * if ((!v.IsStandard) && (v.AttributeBasedOn == null) && (v.DomainBasedOn) == null) * { * varName = v.Name; * if (primerVarObj) * { * primerVarObj = false; * writer.AddTableData(new string[] { type, name, "", "", "" }); * } * string suggestedDomains = ""; * foreach (Domain d in Domain.GetAll(kbserv.CurrentModel)) * { * if ((v.Type == d.Type) && (v.Length == d.Length) && (v.Decimals == d.Decimals) && (v.Signed == d.Signed)) * { * if (suggestedDomains != "") * { * suggestedDomains += ", "; * } * suggestedDomains += "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;AssignDomainToVariable&objName=" + obj.Name + "&objtype=" + type + "&varId=" + v.Id.ToString() + "&domainName=" + d.Name + "\">" + d.Name + "</a>"; * } * } * string suggestedAttribute = ""; * foreach (Artech.Genexus.Common.Objects.Attribute a in Artech.Genexus.Common.Objects.Attribute.GetAll(kbserv.CurrentModel)) * { * if ((v.Type == a.Type) && (v.Length == a.Length) && (v.Decimals == a.Decimals) && (v.Signed == a.Signed)) * { * if (suggestedAttribute != "") * { * suggestedAttribute += ", "; * } * suggestedAttribute += "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;AssignAttributeToVariable&objName=" + obj.Name + "&objtype=" + type + "&varId=" + v.Id.ToString() + "&attId=" + a.Id.ToString() + "\">" + a.Name + "</a>"; * } * } * writer.AddTableData(new string[] { "", "", varName, suggestedAttribute, suggestedDomains }); * } * } * } * } * } * * * */ }
/* private static string TrnWebForm3(Artech.Architecture.Common.Objects.KBObject Object, Heurys.Patterns.HPattern.HPatternSettings Settings, Heurys.Patterns.HPattern.HPatternInstance Instance, Boolean geraBC, String tabBC, Boolean Component, TransactionElement trnInstance) { FileStream f = File.OpenRead("c:\temptrn.txt"); StringBuilder ret = new StringBuilder(); byte[] buffer = new byte[100]; while (f.Read(buffer, 100, 100) == 0) { ret.Append(buffer); } return ret.ToString(); } */ internal static string getUserTables(WebFormPart obj,string nome) { XmlNode xn = obj.Document.SelectSingleNode("//TABLE[@id=\"" + nome + "\"]"); if (xn == null) { xn = obj.Document.SelectSingleNode("//table[@id=\"" + nome + "\"]"); } if (xn != null) { return xn.OuterXml; } return ""; }
private static void AddUserTable(UserTableElement userTable, StringBuilder atts, WebFormPart obj, bool overwrite) { string tabela = (overwrite ? String.Empty : getUserTables(obj, userTable.Name)); if (String.IsNullOrEmpty(tabela)) { atts.AppendLine(WebForm.BeginTable(userTable.Name, "Table")); atts.AppendLine("<tr><td>" + userTable.Name + "</td></tr>"); atts.AppendLine(WebForm.EndTable()); } else { atts.AppendLine(tabela); } }