private static void AddReferencedObj(KBObjectCollection objColl, KBObject obj, string tabs) { IKBService kbserv = UIServices.KB; IOutputService output = CommonServices.Output; objColl.Add(obj); string RefTabs = tabs + " "; if (ObjectsHelper.IsCallalable(obj)) { foreach (EntityReference reference in obj.GetReferences()) { KBObject objRef = KBObject.Get(obj.Model, reference.To); if ((objRef != null) && !(objColl.Contains(objRef)) && (reference.ReferenceType == ReferenceType.Hard) && (ObjectsHelper.IsCallalable(objRef))) { if (!(objRef is Procedure)) { output.AddLine(tabs + "XCOPY " + objRef.Name + ".DLL %DESTINO% "); //+ " (" + obj.TypeDescriptor.Name + ")" ); } AddReferencedObj(objColl, objRef, RefTabs); } } } }
public AssignDomToVar(KBObject obj) { InitializeComponent(); objName.Text = obj.Name + " (" + obj.TypeDescriptor.Name + "): " + obj.Description; objSource = ObjectsHelper.ObjectSource(obj); objRules = obj.Parts.Get <RulesPart>().Source; model = obj.Model; VariablesPart vp = obj.Parts.Get <VariablesPart>(); if (vp != null) { foreach (Variable v in vp.Variables) { if ((!v.IsStandard) && (v.AttributeBasedOn == null) && (v.DomainBasedOn == null) && (v.Type != eDBType.GX_USRDEFTYP) && (v.Type != eDBType.GX_SDT) && (v.Type != eDBType.GX_EXTERNAL_OBJECT) && (v.Type != eDBType.Boolean) && v.Type != eDBType.GX_BUSCOMP && v.Type != eDBType.GX_BUSCOMP_LEVEL) { comboVar.Items.Add(new Item(v.Name + " " + Utility.FormattedTypeVariable(v), v)); } cantVariables.Text = comboVar.Items.Count.ToString() + " not based variables"; } } }
static int SpawnPage(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(string), typeof(UnityEngine.GameObject))) { string arg0 = ToLua.ToString(L, 1); string arg1 = ToLua.ToString(L, 2); UnityEngine.GameObject arg2 = (UnityEngine.GameObject)ToLua.ToObject(L, 3); UnityEngine.GameObject o = ObjectsHelper.SpawnPage(arg0, arg1, arg2); ToLua.Push(L, o); return(1); } else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(int), typeof(int), typeof(string), typeof(string))) { int arg0 = (int)LuaDLL.lua_tonumber(L, 1); int arg1 = (int)LuaDLL.lua_tonumber(L, 2); string arg2 = ToLua.ToString(L, 3); string arg3 = ToLua.ToString(L, 4); int o = ObjectsHelper.SpawnPage(arg0, arg1, arg2, arg3); LuaDLL.lua_pushinteger(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: ObjectsHelper.SpawnPage")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static void ProcesoDirNavigations(string directoryArg, IOutputService output, TextWriter writer2) { IKBService kbserv = UIServices.KB; string fileWildcard = @"*.xml"; var searchSubDirsArg = System.IO.SearchOption.AllDirectories; string[] xFiles = System.IO.Directory.GetFiles(directoryArg, fileWildcard, searchSubDirsArg); int numFiles = 0; foreach (string x in xFiles) { if (!Path.GetFileNameWithoutExtension(x).StartsWith("Gx0")) { if ((numFiles % 200) == 0) { output.AddLine(x); } numFiles += 1; string xmlstring = AddXMLHeader(x); KBObject obj = ExtractObject(xmlstring); if (!ObjectsHelper.isGeneratedbyPattern(obj)) { ProcesoNavigation(xmlstring, output, writer2, obj); } } } }
internal static void RenameVariables() { IKBService kbserv = UIServices.KB; string title = "KBDoctor - Object with variables not based on attribute/domain"; 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[] { "Type", "Name", "Variable", "Attribute", "Domain" }); Domain dom = Functions.DomainByName("Fecha"); //All useful objects are added to a collection foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { KBDoctorOutput.Message("Procesing.... " + obj.Name + " - " + obj.Type.ToString()); Boolean SaveObj = false; if (Utility.isGenerated(obj) && !ObjectsHelper.isGeneratedbyPattern(obj) && (obj is Transaction || obj is WebPanel || obj is WorkPanel)) { Functions.AddLine("RenameVariables.txt", "##" + obj.Name); List <Variable> lstVariables = VariablesToRename(obj); } } string inputFile = kbserv.CurrentKB.UserDirectory + @"\RenameVariables.txt"; // Input List <String> data = File.ReadAllLines(inputFile).Distinct(StringComparer.CurrentCultureIgnoreCase).ToList(); // Processing data.Sort(); // Output string outputFile2 = kbserv.CurrentKB.UserDirectory + @"\RenameVariables2.txt"; File.WriteAllLines(outputFile2, data.ToArray()); writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection("KBDoctor", title, success); } catch { bool success = false; KBDoctor.KBDoctorOutput.EndSection(title, success); } }
internal static void ListObjectsWithTableInOtherModule() { IKBService kbserv = UIServices.KB; KBModel model = kbserv.CurrentModel.GetDesignModel(); string title = "KBDoctor - List Objects with table in other module"; IOutputService output = CommonServices.Output; output.StartSection(title); string outputFile = Functions.CreateOutputFile(kbserv, title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Name", "Description", "Object Module", "Table ", "Table Module" }); SelectObjectOptions selectObjectOption = new SelectObjectOptions(); selectObjectOption.MultipleSelection = true; foreach (KBObject obj in UIServices.SelectObjectDialog.SelectObjects(selectObjectOption)) { string modulename = ModulesHelper.ObjectModuleName(obj); foreach (EntityReference reference in obj.GetReferences()) { KBObject objref = KBObject.Get(obj.Model, reference.To); if (objref != null && objref is Table && !ObjectsHelper.isGeneratedbyPattern(obj)) { Table t = (Table)objref; string tablemodulename = TablesHelper.TableModule(t.Model, t).Name; if (tablemodulename != modulename) { string objNameLink = Functions.linkObject(obj); output.AddLine("Processing... " + obj.Name + " reference table " + t.Name + " Object module:" + modulename + " Table module:" + tablemodulename); writer.AddTableData(new string[] { objNameLink, obj.Description, modulename, t.Name, tablemodulename }); } } } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }
//_________________________________________________________________________________________________________ //_________________________________________________________________________________________________________ private Dictionary <string, string> AddPropertiesLoaded(SearchResult r, bool bAllAtribs = false, string sOtherAttribs = "") { Dictionary <string, string> salida = new Dictionary <string, string>(); for (int i = 0; i < tAttributes.Rows.Count; i++) { string sUsage = tAttributes.Rows[i]["Usage"].ToString(); string name = tAttributes.Rows[i][Row["Alias"].ToString()].ToString(); string alias = tAttributes.Rows[i]["Alias"].ToString(); if (bAllAtribs || (sUsage.Contains("Link") || sUsage.Contains("ID") || sUsage.Contains("Alias") || sOtherAttribs.Contains(name))) { if (r.Properties[name].Count == 0) { salida.Add(alias, name == "" ? "" : "<ND>"); } if (r.Properties[name].Count == 1 && sUsage.Contains("Jpeg") && !sUsage.Contains("Guid")) { salida.Add(alias, BitConverter.ToString(r.Properties[name][0] as byte[]).Replace("-", "").Substring(0, 30)); using (MemoryStream ms = new MemoryStream(r.Properties[name][0] as byte[])) { Bitmap.FromStream(ms).Save(Config.PathImages + this.Name + "_" + alias + "_0.jpg"); } } if (r.Properties[name].Count == 1 && !sUsage.Contains("Jpeg") && !sUsage.Contains("Guid")) { salida.Add(alias, r.Properties[name][0].ToString()); } if (r.Properties[name].Count == 1 && sUsage.Contains("Guid")) { salida.Add(alias, name == "objectGUID" ? ObjectsHelper.ConvertGuidToString((byte[])r.Properties[name][0]) : r.Properties[name][0].ToString()); } if (r.Properties[name].Count == 1 && sUsage.Contains("ID") && !sUsage.Contains("Guid")) { salida.Add("#ID#", r.Properties[name][0].ToString()); } if (r.Properties[name].Count > 1) { string s = ""; for (int j = 0; j < r.Properties[name].Count; j++) { if (sUsage.Contains("Jpeg")) { s += (s == "" ? "" : Config.Separator) + BitConverter.ToString(r.Properties[name][j] as byte[]).Replace("-", "").Substring(0, 30); using (MemoryStream ms = new MemoryStream(r.Properties[name][j] as byte[])) { Bitmap.FromStream(ms).Save(Config.PathImages + this.Name + "_" + alias + "_" + j + ".jpg"); } } else { s += (s == "" ? "" : Config.Separator) + r.Properties[name][j].ToString(); } } salida.Add(alias, s); } } } return(salida); }
public bool ExecRenameVariables(CommandData cmdData) { // Cambiar las variables para que se basen en atributos o dominios. /* Thread t = new Thread(new ThreadStart(CleanKBHelper.RenameVariables)); * t.Start();*/ ObjectsHelper.TestParser(); return(true); }
private static bool isNode(KBObject obj) { if (obj != null) { return((Functions.isRunable(obj) && ObjectsHelper.isGenerated(obj)) || (obj is Table) || (obj is ExternalObject)); } else { return(false); } }
static int SetPageNull(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); int arg0 = (int)LuaDLL.luaL_checknumber(L, 1); ObjectsHelper.SetPageNull(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int LoadAB(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); string arg0 = ToLua.CheckString(L, 1); UnityEngine.AssetBundle o = ObjectsHelper.LoadAB(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetScrollbar(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); int arg0 = (int)LuaDLL.luaL_checknumber(L, 1); int arg1 = (int)LuaDLL.luaL_checknumber(L, 2); float o = ObjectsHelper.GetScrollbar(arg0, arg1); LuaDLL.lua_pushnumber(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SetInputField(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); int arg0 = (int)LuaDLL.luaL_checknumber(L, 1); int arg1 = (int)LuaDLL.luaL_checknumber(L, 2); string arg2 = ToLua.CheckString(L, 3); ObjectsHelper.SetInputField(arg0, arg1, arg2); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetInputField(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); int arg0 = (int)LuaDLL.luaL_checknumber(L, 1); int arg1 = (int)LuaDLL.luaL_checknumber(L, 2); string o = ObjectsHelper.GetInputField(arg0, arg1); LuaDLL.lua_pushstring(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetGameObject(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); int arg0 = (int)LuaDLL.luaL_checknumber(L, 1); int arg1 = (int)LuaDLL.luaL_checknumber(L, 2); UnityEngine.GameObject o = ObjectsHelper.GetGameObject(arg0, arg1); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int AddToggleClick(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); int arg0 = (int)LuaDLL.luaL_checknumber(L, 1); int arg1 = (int)LuaDLL.luaL_checknumber(L, 2); LuaFunction arg2 = ToLua.CheckLuaFunction(L, 3); ObjectsHelper.AddToggleClick(arg0, arg1, arg2); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SetIsReceiveClick(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); int arg0 = (int)LuaDLL.luaL_checknumber(L, 1); int arg1 = (int)LuaDLL.luaL_checknumber(L, 2); int arg2 = (int)LuaDLL.luaL_checknumber(L, 3); ObjectsHelper.SetIsReceiveClick(arg0, arg1, arg2); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SetToggleGroup(IntPtr L) { try { ToLua.CheckArgsCount(L, 4); int arg0 = (int)LuaDLL.luaL_checknumber(L, 1); int arg1 = (int)LuaDLL.luaL_checknumber(L, 2); int arg2 = (int)LuaDLL.luaL_checknumber(L, 3); int arg3 = (int)LuaDLL.luaL_checknumber(L, 4); ObjectsHelper.SetToggleGroup(arg0, arg1, arg2, arg3); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private static void ListParmReferences(KBObject obj, string name, KBDoctorXMLWriter writer) { string source = ObjectsHelper.ObjectSource(obj); source = Functions.ExtractComments(source); string linesWithParmName = ""; using (StringReader reader = new StringReader(source)) { string line; while ((line = reader.ReadLine()) != null) { if (line.ToUpper().Contains(name.ToUpper())) { linesWithParmName += line + Environment.NewLine + "<br>"; } } } writer.AddTableData(new string[] { Functions.linkObject(obj), name, linesWithParmName }); }
public static void List2(KBObject obj, string objLocation, Dictionary <string, KBObjectCollection> dic, KBDoctorXMLWriter writer) { string objMasterPage = obj.GetPropertyValueString("MasterPage"); writer.AddTableData(new string[] { obj.TypeDescriptor.Name, Functions.linkObject(obj), objLocation, objMasterPage }); if (ObjectsHelper.IsCallalable(obj)) { foreach (EntityReference reference in obj.GetReferences()) { KBObject objRef = KBObject.Get(obj.Model, reference.To); string typeDescriptor = obj.TypeDescriptor.Name; List <string> list = new List <string> { "WebPanel", "Transaction", "WorkPanel" }; if ((objRef != null) && list.Contains(typeDescriptor) && (reference.ReferenceType == ReferenceType.Hard)) { int count = 0; string locations = ""; KBObjectCollection objColl = new KBObjectCollection(); foreach (string loc in dic.Keys) { if ((loc != objLocation) && (list.Contains(objRef.TypeDescriptor.Name))) { dic.TryGetValue(loc, out objColl); if (objColl.Contains(obj)) { locations += " " + loc; count += 1; } } } if (count > 0) { string objRefMasterPage = objRef.GetPropertyValueString("MasterPage"); writer.AddTableData(new string[] { "+-----Called >>" + objRef.TypeDescriptor.Name, Functions.linkObject(objRef), count.ToString() + "-" + locations, objRefMasterPage }); } } } } }
static int _CreateObjectsHelper(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 0) { ObjectsHelper obj = new ObjectsHelper(); ToLua.PushObject(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: ObjectsHelper.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
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"); } }
public bool ExecObjectsWithConstants(CommandData cmdData) { ObjectsHelper.ObjectsWithConstants(); return(true); }
private static void GenerateMDGGraph(string name, string fileName) { IKBService kbserv = UIServices.KB; KBModel model = kbserv.CurrentModel; StreamWriter scriptFile = new StreamWriter(fileName); IOutputService output = CommonServices.Output; StringCollection aristas = new StringCollection(); output.AddLine("Generating MDG " + name); string objName = ""; StringCollection nodos = new StringCollection(); foreach (KBObject obj in model.Objects.GetAll()) { bool includedInGraph = (Functions.isRunable(obj) && ObjectsHelper.isGenerated(obj)) || (obj is Table); if (includedInGraph) { objName = NombreNodo(obj); string modulename = ModulesHelper.ObjectModuleName(obj); if (!nodos.Contains(objName)) { scriptFile.WriteLine(" <node id='" + objName + "' label='" + objName + "' >"); scriptFile.WriteLine(" <attvalues> <attvalue for='0' value = '" + modulename + "' /> </attvalues>"); scriptFile.WriteLine(" </node>"); nodos.Add(objName); } foreach (EntityReference r in obj.GetReferencesTo()) { KBObject objRef = KBObject.Get(obj.Model, r.From); if ((objRef != null) && (Functions.isRunable(objRef) || objRef is Table)) { string objRefName = NombreNodo(objRef); if (objName != objRefName) { String edge = " source='" + objRefName + "' target='" + objName + "' weight= '1.0' "; if (!aristas.Contains(edge)) { aristas.Add(edge); } } } } } } ; scriptFile.WriteLine(" </nodes>"); //Grabo las aristas scriptFile.WriteLine(" <edges>"); int i = 0; foreach (String s in aristas) { scriptFile.WriteLine(" <edge id=" + i.ToString() + s + " /> "); i += 1; } ; scriptFile.WriteLine(" </edges>"); scriptFile.WriteLine(" </graph>"); scriptFile.WriteLine("</gexf>"); scriptFile.Close(); }
private static void GenerateKBObjectGraph(string name, string fileName) { IKBService kbserv = UIServices.KB; KBModel model = kbserv.CurrentModel; StreamWriter scriptFile = new StreamWriter(fileName); IOutputService output = CommonServices.Output; StringCollection aristas = new StringCollection(); output.AddLine("Generating " + name); scriptFile.WriteLine("<?xml version = '1.0' encoding = 'UTF-8'?>"); scriptFile.WriteLine("<gexf xmlns='http://www.gexf.net/1.2draft' xmlns:viz='http://www.gexf.net/1.2draft/viz' "); scriptFile.WriteLine(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd' version = '1.2' > "); scriptFile.WriteLine(" <graph mode = 'static' defaultedgetype = 'directed' > "); scriptFile.WriteLine("<attributes class='node'> <attribute id='0' title = 'module' type = 'string' /> </attributes >"); scriptFile.WriteLine(" <nodes>"); string objName = ""; StringCollection nodos = new StringCollection(); foreach (KBObject obj in model.Objects.GetAll()) { if ((Functions.isRunable(obj) && ObjectsHelper.isGenerated(obj)) || (obj is Table)) { objName = NombreNodo(obj); string modulename = ModulesHelper.ObjectModuleName(obj); if (!nodos.Contains(objName)) { scriptFile.WriteLine(" <node id='" + objName + "' label='" + objName + "' >"); scriptFile.WriteLine(" <attvalues> <attvalue for='0' value = '" + modulename + "' /> </attvalues>"); scriptFile.WriteLine(" </node>"); nodos.Add(objName); } foreach (EntityReference r in obj.GetReferencesTo()) { KBObject objRef = KBObject.Get(obj.Model, r.From); if ((objRef != null) && (Functions.isRunable(objRef) || objRef is Table)) { string objRefName = NombreNodo(objRef); if (objName != objRefName) { String edge = " source='" + objRefName + "' target='" + objName + "' weight= '1.0' "; if (!aristas.Contains(edge)) { aristas.Add(edge); } } } } } } ; scriptFile.WriteLine(" </nodes>"); //Grabo las aristas scriptFile.WriteLine(" <edges>"); int i = 0; foreach (String s in aristas) { scriptFile.WriteLine(" <edge id=" + i.ToString() + s + " /> "); i += 1; } ; scriptFile.WriteLine(" </edges>"); scriptFile.WriteLine(" </graph>"); scriptFile.WriteLine("</gexf>"); scriptFile.Close(); }
public bool ExecCleanVarsNotUsed(CommandData cmdData) { ObjectsHelper.CleanVarsNotUsed(); return(true); }
public bool ExecAssignDomainToVariable(CommandData cmdData) { ObjectsHelper.AssignDomainToVariable(cmdData.Parameters); return(true); }
public bool ExecOpenKBObject(CommandData cmdData) { ObjectsHelper.OpenObject(cmdData.Parameters); return(true); }
public bool ExecRemoveObject(CommandData cmdData) { ObjectsHelper.RemoveObject(cmdData.Parameters); return(true); }
public bool ExecObjectsDiagnostics(CommandData cmdData) { ObjectsHelper.ObjectsDiagnostics(); return(true); }