Пример #1
0
        /// #NAME#: #DESCRIPTION#
        public void f_Nuevo_proceso()
        {
            //INI CODE PRCGUID: Nuevo proceso

            ARQODE_UI.ARQODE_UI.CInputDialog CInputDialog = new ARQODE_UI.ARQODE_UI.CInputDialog(vm);
            CInputDialog.InputDialog.AcceptButton = CInputDialog.BAceptar;
            CInputDialog.InputDialog.CancelButton = CInputDialog.BCancelar;

            CInputDialog.InputDialog.Text = "Nuevo proceso";
            CInputDialog.Label1.Text      = "Nombre del proceso";

            vm.Cancel_events = false;
            DialogResult dr = CInputDialog.InputDialog.ShowDialog();

            if (dr == DialogResult.OK)
            {
                if (CInputDialog.textBox1.Text.Trim() != "")
                {
                    ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);

                    TreeView TV_Processes = (TreeView)view.getCtrl("TV_Processes");
                    String   Process_path = Path.Combine(App_globals.AppDataSection(dPATH.CODE).FullName, TV_Processes.SelectedNode.FullPath);

                    // abrir plantilla
                    DirectoryInfo pprocs = Globals.AppDataSection(dPATH.PROCESSES);
                    if (pprocs.GetFiles("base_process.json").Length > 0)
                    {
                        // crear proceso usando la plantilla

                        JSonFile jplantilla_unit_proc = new JSonFile(pprocs.GetFiles("base_unit_process.json")[0].FullName);
                        jplantilla_unit_proc.jActiveObj[dPROCESS.GUID]        = Guid.NewGuid().ToString();
                        jplantilla_unit_proc.jActiveObj[dPROCESS.NAME]        = CInputDialog.textBox1.Text;
                        jplantilla_unit_proc.jActiveObj[dPROCESS.DESCRIPTION] = "";

                        // añadir el proceso a la lista de procesos del fichero
                        JSonFile jProcessFile = new JSonFile(Process_path);
                        (jProcessFile.get("processes") as JArray).Add(jplantilla_unit_proc.jActiveObj);
                        jProcessFile.Write();
                    }
                    else
                    {
                        MessageBox.Show("Plantilla de proceso 'base_process.json' no encontrada en: " + pprocs.FullName);
                    }
                }
            }

            //END CODE PRCGUID: Nuevo proceso
        }
Пример #2
0
 private void loadBaseProcess()
 {
     pBasePrc = new JSonFile(sys.Globals.debug, sys.Globals.AppData_path(dPATH.PROCESSES), Namespace, true);
     if (!pBasePrc.hasErrors())
     {
         pBasePrc.setActiveNode(String.Format("$.{0}[?(@.{1} == '{2}')]", dPROCESS.PROCESSES, dPROCESS.GUID.ToString(), Guid));
     }
     else
     {
         sys.ProgramErrors.invalidJSON =
             String.Format("Error loading json file {0}.{1}. Details: {2}",
                           dPATH.PROCESSES,
                           Namespace,
                           pBasePrc.jErrors.ToString());
     }
 }
Пример #3
0
        /// #NAME#: #DESCRIPTION#
        public void f_a6099e20_957f_477e_9ff5_92c4fc54e87c()
        {
            //INI CODE PRCGUID: a6099e20-957f-477e-9ff5-92c4fc54e87c

            ARQODE_UI.GestorProgramas.CVentanaProgramas     CVentanaProgramas     = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);
            ARQODE_UI.GestorControles.CFormControlesEventos CFormControlesEventos = new ARQODE_UI.GestorControles.CFormControlesEventos(vm);
            if ((CFormControlesEventos.TV_Controles.SelectedNode != null) && (CFormControlesEventos.TV_Controles.SelectedNode.Nodes.Count == 0))
            {
                String view_name = CFormControlesEventos.TV_Controles.SelectedNode.Parent.FullPath.Replace("\\", ".").Replace(".json", "");
                String view_file = Path.Combine(
                    App_globals.AppDataSection(dPATH.VIEWS).FullName,
                    CFormControlesEventos.TV_Controles.SelectedNode.Parent.FullPath);
                if (File.Exists(view_file))
                {
                    JSonFile jView    = new JSonFile(view_file);
                    JToken   JControl = jView.jActiveObj.SelectToken(String.Format("$.Controls[?(@.Guid == '{0}')]", CFormControlesEventos.TV_Controles.SelectedNode.Text));

                    if (JControl != null)
                    {
                        JObject JEvents = new JObject();
                        for (int i = 0; i < CFormControlesEventos.DG_EventosControl.RowCount; i++)
                        {
                            if ((CFormControlesEventos.DG_EventosControl[0, i].Value != null) && (CFormControlesEventos.DG_EventosControl[1, i].Value != null))
                            {
                                JProperty JEvent = new JProperty(CFormControlesEventos.DG_EventosControl[0, i].Value.ToString(),
                                                                 CFormControlesEventos.DG_EventosControl[1, i].Value.ToString());
                                JEvents.Add(JEvent);
                            }
                        }

                        if (JControl["Events"] != null)
                        {
                            JControl["Events"].Replace(JEvents);
                        }
                        else
                        {
                            JControl["Events"] = JEvents;
                        }

                        jView.Write();
                    }
                }
            }


            //END CODE PRCGUID: a6099e20-957f-477e-9ff5-92c4fc54e87c
        }
Пример #4
0
        /// <summary>
        /// Get controls in view from JSON map file
        /// </summary>
        /// <param name="view"></param>
        public TBaseControls(String view)
        {
            jErrors = new JArray();
            view    = TLogic.Utils.escape_sc(view);
            String [] view_split = view.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
            String    Namespace  = "TLogic.Views." + view.Replace("." + view_split[view_split.Length - 1], "");
            String    Name       = "C" + view_split[view_split.Length - 1];
            Type      tobj       = System.Reflection.Assembly.GetExecutingAssembly().GetTypes().Where(t => t.FullName == Namespace + "." + Name).FirstOrDefault();

            System.Reflection.PropertyInfo JSON = tobj.GetProperty("_JSON");
            String json_value = JSON.GetValue(null).ToString();

            prcInfo = new JSonFile(JObject.Parse(System.Text.UTF8Encoding.UTF8.GetString(Convert.FromBase64String(json_value))));
            if (!prcInfo.hasErrors())
            {
                jErrors = prcInfo.jErrors;
            }
        }
Пример #5
0
        /// <summary>
        /// Replace prc namespace in program files by namespace
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="to_path"></param>
        private bool replace_prc_namespace_in_programs_by_namespace(FileInfo fi, String prc_namespace, String to_path)
        {
            JSonFile jProgram = new JSonFile(fi.FullName);
            bool     changed  = false;

            foreach (JToken Jnode in jProgram.getNodes(String.Format("$.Logic[?(@.Namespace == '{0}')]", prc_namespace)))
            {
                if (replace_in_programs)
                {
                    Jnode["Namespace"] = to_path;
                }
                changed = true;
            }
            if ((changed) && (replace_in_programs))
            {
                jProgram.Write();
            }
            return(changed);
        }
Пример #6
0
        public CProgram(CSystem csystem, CGlobals Globals, String program, object program_vars = null)
        {
            sys = csystem;
            // Remove program queued flag
            program_name = (program.StartsWith("&")) ? program.Substring(1) : program;
            // Read program
            progInfo = new JSonFile(Globals.AppDataSection(dPATH.PROGRAM), program_name, true);

            if (!progInfo.hasErrors())
            {
                // Init csystem.ProgramErrors and debug for program execution
                csystem.ProgramErrors = new TErrors(Globals, program);
                csystem.ProgramDebug  = new TDebug(Globals, program);
                debug = csystem.ProgramDebug;

                csystem.ProgramErrors.Name        = Name;
                csystem.ProgramErrors.Description = Description;
                debug.Name        = Name;
                debug.Description = Description;

                // Init vars
                if (program_vars == null)
                {
                    vars = new Dictionary <string, object>();
                }
                else
                {
                    vars = (Dictionary <string, object>)program_vars;
                }
                foreach (JValue var in Variables)
                {
                    if (!vars.ContainsKey(var.Value.ToString()))
                    {
                        vars.Add(var.Value.ToString(), null);
                    }
                }
            }
            else
            {
                csystem.ProgramErrors             = new TErrors(Globals, program);
                csystem.ProgramErrors.invalidJSON = progInfo.jErrors;
            }
        }
Пример #7
0
        /// #NAME#: #DESCRIPTION#
        public void f_781150d3_d1ed_4245_8fe9_9fe26a594e2f()
        {
            //INI CODE PRCGUID: 781150d3-d1ed-4245-8fe9-9fe26a594e2f

            ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);

            String nombre_programa = Clipboard.GetText();

            if (nombre_programa != "")
            {
                // montamos el proceso destino:
                JObject JNewProc_2_program = new JObject();
                JNewProc_2_program.Add("Namespace", "System.Call");
                JNewProc_2_program.Add("Guid", "Call");
                JNewProc_2_program.Add("Name", "Call " + nombre_programa);
                JNewProc_2_program.Add("Description", "");

                JObject JConf = new JObject();
                JConf.Add("program", nombre_programa);
                JNewProc_2_program.Add("Configuration", JConf);


                JObject JIn = new JObject();
                JNewProc_2_program.Add("Inputs", JIn);

                JObject JOut = new JObject();
                JNewProc_2_program.Add("Outputs", JOut);

                // obtienes el programa
                String rutaPrograma = Path.Combine(
                    App_globals.AppDataSection(dPATH.CODE).FullName,
                    CVentanaProgramas.ArbolProgramas.SelectedNode.FullPath);

                JSonFile jprograma = new JSonFile(rutaPrograma);
                (jprograma.jActiveObj["Logic"] as JArray).Add(JNewProc_2_program);
                jprograma.Write();
            }


            //END CODE PRCGUID: 781150d3-d1ed-4245-8fe9-9fe26a594e2f
        }
Пример #8
0
        /// <summary>
        /// Replace program events
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="from_path"></param>
        /// <param name="to_path"></param>
        private void replace_in_events(FileInfo fi, string from_path, string to_path)
        {
            JSonFile jView   = new JSonFile(fi.FullName);
            bool     changed = false;

            foreach (JToken Jnode in jView.getNodes("$.Controls[?(@.Events)]"))
            {
                foreach (JProperty jp in ((JObject)Jnode["Events"]).Properties())
                {
                    if (jp.Value.ToString().Equals(from_path))
                    {
                        jp.Value = to_path;
                        changed  = true;
                    }
                }
            }
            if (changed)
            {
                jView.Write();
            }
        }
Пример #9
0
        /// #NAME#: #DESCRIPTION#
        public void f_c3697a76_651b_43ca_b89e_a035993a9d23()
        {
            //INI CODE PRCGUID: c3697a76-651b-43ca-b89e-a035993a9d23

            ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas  = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);
            ARQODE_UI.GestorProcesos.CFormProcesoActivo CFormProcesoActivo = new ARQODE_UI.GestorProcesos.CFormProcesoActivo(vm);
            if ((CFormProcesoActivo.TV_ViewsVars.SelectedNode != null) &&
                (CFormProcesoActivo.TV_ViewsVars.SelectedNode.Nodes.Count == 0))
            {
                JSonFile jView = new JSonFile(Path.Combine(
                                                  App_globals.AppDataSection(dPATH.VIEWS).FullName,
                                                  CFormProcesoActivo.TV_ViewsVars.SelectedNode.Parent.FullPath));
                JToken Jnode = jView.jActiveObj["Variables"].FirstOrDefault(x => x.ToString() == CFormProcesoActivo.TV_ViewsVars.SelectedNode.Text);
                Jnode.Remove();
                jView.Write();

                CFormProcesoActivo.TV_ViewsVars.SelectedNode.Remove();
            }

            //END CODE PRCGUID: c3697a76-651b-43ca-b89e-a035993a9d23
        }
Пример #10
0
        /// <summary>
        /// Replace var list in program IOC
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="ReplacementVarList"></param>
        private void replace_in_programs_IOC(FileInfo fi, Dictionary <String, String> ReplacementVarList)
        {
            JSonFile jProgram = new JSonFile(fi.FullName);
            bool     changed  = false;

            // Loop into processes
            foreach (JToken Jnode in jProgram.getNode("$.Logic") as JArray)
            {
                // Loop into replacements
                foreach (String key in ReplacementVarList.Keys)
                {
                    // Replace Inputs, Outputs & Configuration
                    change_prop_in_array(Jnode["Inputs"] as JObject, ReplacementVarList[key], key, ref changed);
                    change_prop_in_array(Jnode["Outputs"] as JObject, ReplacementVarList[key], key, ref changed);
                    change_prop_in_array(Jnode["Configuration"] as JObject, ReplacementVarList[key], key, ref changed);
                }
            }
            if (changed)
            {
                jProgram.Write();
            }
        }
Пример #11
0
        /// <summary>
        /// Replace prc name in program files
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="to_path"></param>
        private bool replace_prc_in_programs(FileInfo fi, String prc_guid, JObject prc_base)
        {
            JSonFile jProgram = new JSonFile(fi.FullName);
            bool     changed  = false;

            foreach (JToken Jnode in jProgram.getNodes(String.Format("$.Logic[?(@.Guid == '{0}')]", prc_guid)))
            {
                if (replace_in_programs)
                {
                    Jnode["Name"] = prc_base["Name"];
                }
                changed = true;

                // update program IOC changes from prc base
                Update_program_process_IOC(prc_base, Jnode as JObject);
            }
            if ((changed) && (replace_in_programs))
            {
                jProgram.Write();
            }
            return(changed);
        }
Пример #12
0
        /// <summary>
        /// Replace in files
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="from_path"></param>
        /// <param name="to_path"></param>
        private bool replace_in_programs_calls_IOC(FileInfo fi, string from_path, string to_path)
        {
            JSonFile jProgram = new JSonFile(fi.FullName);
            bool     changed  = false;

            // Search in calls
            foreach (JToken Jnode in jProgram.getNodes("$.Logic[?(@.Guid == 'Call')]"))
            {
                if (Jnode["Configuration"]["program"].ToString().Equals(from_path))
                {
                    if (replace_in_programs)
                    {
                        Jnode["Name"] = "Call " + to_path;
                        Jnode["Configuration"]["program"] = to_path;
                    }
                    changed = true;
                }
            }

            // Search in IOC only if to_path is filled
            if ((to_path != "") && (jProgram.jActiveObj["Logic"].ToString().Contains(from_path)))
            {
                // entrarpor las configuraciones
                foreach (JToken Jnode in jProgram.getNode("$.Logic") as JArray)
                {
                    // Replace Inputs, Outputs & Configuration
                    change_prop_in_array(Jnode["Inputs"] as JObject, to_path, from_path, ref changed);
                    change_prop_in_array(Jnode["Outputs"] as JObject, to_path, from_path, ref changed);
                    change_prop_in_array(Jnode["Configuration"] as JObject, to_path, from_path, ref changed);
                }
            }
            if ((changed) && (replace_in_programs))
            {
                jProgram.Write();
            }

            return(changed);
        }
Пример #13
0
        /// #NAME#: #DESCRIPTION#
        public void f_246c3776_b78e_4702_b593_78ce31b6fef7()
        {
            //INI CODE PRCGUID: 246c3776-b78e-4702-b593-78ce31b6fef7

            ARQODE_UI.GestorProcesos.CVentanaProcesos CVentanaProcesos = new ARQODE_UI.GestorProcesos.CVentanaProcesos(vm);

            JToken JProc = ((KeyValuePair <String, JToken>)CVentanaProcesos.LProcess.SelectedItem).Value;

            ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);
            CStructModifications csmod = new CStructModifications(sys, App_globals);
            String    prc_guid         = JProc["Guid"].ToString();
            ArrayList program_refs     = csmod.FindProcessInPrograms(prc_guid);

            if (program_refs.Count <= 0)
            {
                // Remove process
                String   prc_path = Path.Combine(App_globals.AppDataSection(dPATH.CODE).FullName, CVentanaProcesos.TV_Processes.SelectedNode.FullPath);
                JSonFile jProcess = new JSonFile(prc_path);
                JToken   jPrc     = jProcess.getNode(String.Format("$.processes[?(@.Guid == '{0}')]", prc_guid));
                if (jPrc != null)
                {
                    jPrc.Remove();
                    jProcess.Write();
                }
            }
            else
            {
                //String message = "";
                //DirectoryInfo pprog = App_globals.DataSection(dPATH.PROGRAM);
                //foreach (String program in program_refs) { message += program.Replace(pprog.FullName + "\\", "") + "\r\n"; }
                //MessageBox.Show("Antes de eliminar este proceso debe eliminar las siguientes referencias en programas: \r\n" + message);

                String call_buscar_referencias = Config_str("Call a buscar referencias");
                vm.CallProgram(event_desc, call_buscar_referencias);
            }

            //END CODE PRCGUID: 246c3776-b78e-4702-b593-78ce31b6fef7
        }
Пример #14
0
        /// #NAME#: #DESCRIPTION#
        public void f_7f1c5983_51c4_4d71_9647_041bf4366321()
        {
            //INI CODE PRCGUID: 7f1c5983-51c4-4d71-9647-041bf4366321

            ARQODE_UI.ARQODE_UI.CInputDialog CInputDialog = new ARQODE_UI.ARQODE_UI.CInputDialog(vm);
            CInputDialog.InputDialog.AcceptButton = CInputDialog.BAceptar;
            CInputDialog.InputDialog.CancelButton = CInputDialog.BCancelar;

            CInputDialog.InputDialog.Text = "Fichero de procesos";
            CInputDialog.Label1.Text      = "Nombre del fichero";

            vm.Cancel_events = false;
            DialogResult dr = CInputDialog.InputDialog.ShowDialog();

            if (dr == DialogResult.OK)
            {
                ARQODE_UI.GestorProcesos.CVentanaProcesos CVentanaProcesos = new ARQODE_UI.GestorProcesos.CVentanaProcesos(vm);
                if (CVentanaProcesos.TV_Processes.SelectedNode != null)
                {
                    String Ruta = CVentanaProcesos.TV_Processes.SelectedNode.FullPath;
                    ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);
                    DirectoryInfo pprocs      = Globals.AppDataSection(dPATH.PROCESSES);
                    FileInfo      f_plantilla = pprocs.GetFiles(dGLOBALS.PROCESS_TEMPLATE)[0];
                    DirectoryInfo di          = App_globals.AppDataSection(Path.Combine(dPATH.CODE, Ruta));

                    JSonFile JPrc_plantilla = new JSonFile(f_plantilla.FullName);
                    JPrc_plantilla.jActiveObj["description"] = CInputDialog.textBox1.Text;

                    String   n_prc        = CInputDialog.textBox1.Text.EndsWith(".json") ? CInputDialog.textBox1.Text : CInputDialog.textBox1.Text + ".json";
                    JSonFile JNew_process = new JSonFile(Path.Combine(di.FullName, n_prc));
                    JNew_process.writeJsonFile(JPrc_plantilla.jActiveObj);
                }
            }
            CInputDialog.InputDialog.Close();


            //END CODE PRCGUID: 7f1c5983-51c4-4d71-9647-041bf4366321
        }
Пример #15
0
 private bool loadBaseProcess(CSystem sys)
 {
     pBasePrc = new JSonFile(sys.Globals.AppPath(dPATH.PROCESSES), Namespace, false);
     if (pBasePrc.file_exists)
     {
         if (!pBasePrc.hasErrors())
         {
             pBasePrc.setActiveNode(String.Format("$.{0}[?(@.{1} == '{2}')]", dPROCESS.PROCESSES, dPROCESS.GUID.ToString(), Guid));
         }
         else
         {
             sys.ProgramErrors.invalidJSON =
                 String.Format("Error loading json file {0}.{1}. Details: {2}",
                               dPATH.PROCESSES,
                               Namespace,
                               pBasePrc.jErrors.ToString());
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #16
0
 public TTracer(CGlobals globals)
 {
     Globals    = globals;
     tracerInfo = new JSonFile(Globals.AppPath(dPATH.TRACER), Globals.ActiveApp, false);
     initializar_tracer();
 }
Пример #17
0
 public TTracer(CGlobals globals)
 {
     Globals    = globals;
     tracerInfo = new JSonFile(Globals.AppDataSection(dPATH.TRACER), Globals.ActiveAppName, false);
     initializar_tracer();
 }
Пример #18
0
        public bool forceExitProgram = false; // Force program exit

        #endregion

        #region Constructor

        public TErrors(CGlobals Globals, String Program)
        {
            errorInfo = new JSonFile(Globals.AppPath(dPATH.ERRORS), Program);

            errorInfo.set(dERROR.STATUS, generalStatus.READY.ToString());
        }
Пример #19
0
 public TDebug(CGlobals globals, String Program)
 {
     Globals   = globals;
     debugInfo = new JSonFile(Globals.AppPath(dPATH.DEBUG), Program);
     debugInfo.set(dDEBUG.PROCESSES, new JArray());
 }
Пример #20
0
        /// <summary>
        /// Export process to code folder in vs project
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="mapedFile"></param>
        private void Export_Process(FileInfo fi)
        {
            #region Mapped process template file

            FileInfo f_prc_template = new DirectoryInfo(SYS_MAPS_PATH).GetFiles(dGLOBALS.MAPS_PROCESS)[0];
            String   prc_template   = File.ReadAllText(f_prc_template.FullName);
            #endregion

            #region Loop into processes

            JSonFile jProcess = new JSonFile(fi.FullName);
            if ((jProcess.jActiveObj[dPROCESS.PROCESSES] != null) && (fi.Name != "base_process.json"))
            {
                String functions      = "";
                String base_processes = "";

                #region create path to code

                // export code to
                String code_path   = (system_app) ? System_code_path : dEXPORTCODE.VS_CODE_PATH;
                String codeMapPath = Path.Combine(APP_VSPROJECT_PATH, code_path);

                String processes_path = DAPP_PRC.FullName;
                String file_path      = fi.FullName.Replace(processes_path, "");
                String relative_path  = "";
                String filename       = "";
                foreach (String dir in file_path.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    if (!dir.Contains(".json"))
                    {
                        relative_path = Path.Combine(relative_path, dir);
                        if (!Directory.Exists(Path.Combine(codeMapPath, relative_path)))
                        {
                            Directory.CreateDirectory(Path.Combine(codeMapPath, relative_path));
                        }
                    }
                    else
                    {
                        filename = dir.Replace(".json", ".cs");
                    }
                }
                #endregion

                #region Get code from logic and insert into process file

                foreach (JToken Jnode in jProcess.jActiveObj[dPROCESS.PROCESSES] as JArray)
                {
                    // Get code from logic
                    String Guid       = Jnode[dPROCESS.GUID].ToString();
                    String Name       = (Jnode[dPROCESS.NAME] != null) ? Jnode[dPROCESS.NAME].ToString() : "";
                    String Desciption = (Jnode[dPROCESS.DESCRIPTION] != null) ? Jnode[dPROCESS.DESCRIPTION].ToString() : "";
                    String prc_code   = CLogicEditor.get_Code_from_logic(ARQODE_PATH, Guid);

                    if ((prc_code == "") && (Jnode[dPROCESS.CODE] != null) && (Jnode[dPROCESS.CODE].ToString() != ""))
                    {
                        prc_code = System.Text.UTF8Encoding.UTF8.GetString(Convert.FromBase64String(Jnode[dPROCESS.CODE].ToString()));
                    }
                    if (prc_code != "")
                    {
                        // Save into current process
                        Jnode[dPROCESS.CODE] = Convert.ToBase64String(System.Text.UTF8Encoding.UTF8.GetBytes(prc_code));

                        // write replaced template file to mapped folder. Renaming guid to valid function name
                        functions += dEXPORTCODE.F_TEMPLATE.
                                     Replace(dEXPORTCODE.F_NAME, Name).
                                     Replace(dEXPORTCODE.F_DESCRIPTION, Desciption).
                                     Replace(dEXPORTCODE.F_FUNCTION_NAME, Utils.escape_sc(Guid)).
                                     Replace(dEXPORTCODE.F_CODE, prc_code);
                    }

                    #region Save base process string

                    JToken base_prc = Jnode.DeepClone();
                    if (Jnode[dPROCESS.CODE] != null)
                    {
                        ((JObject)base_prc).Property(dPROCESS.CODE).Remove();
                    }
                    base_processes += "public static string BP_" + Utils.escape_sc(Guid) +
                                      " { get { return \"" +
                                      Convert.ToBase64String(System.Text.UTF8Encoding.UTF8.GetBytes(base_prc.ToString()))
                                      + "\"; } } \r\n";
                    #endregion
                }
                jProcess.Write();
                #endregion

                if (functions != "")
                {
                    #region Save process file

                    prc_template = prc_template
                                   .Replace(dEXPORTCODE.F_FUNCTIONS, functions)            // Replace functions
                                   .Replace(dEXPORTCODE.F_BASE_PROCESSES, base_processes); // Replace base processs strings

                    File.WriteAllText(Path.Combine(codeMapPath, Path.Combine(relative_path, filename)), prc_template);
                    #endregion

                    #region Insert into VS project file

                    // Add node if not founded else remove from pj_compile list
                    if (!pj_compile_items.ContainsKey(Path.Combine(code_path, Path.Combine(relative_path, filename))))
                    {
                        XmlNode      xnode = x_pj.CreateNode(XmlNodeType.Element, dEXPORTCODE.VS_PJ_ITEM_COMPILE, null);
                        XmlAttribute xatt  = x_pj.CreateAttribute(dEXPORTCODE.VS_PJ_ATT_INCLUDE);
                        xatt.Value = Path.Combine(code_path, Path.Combine(relative_path, filename));
                        xnode.Attributes.Append(xatt);
                        x_item_group.AppendChild(xnode);
                        changes_in_pj = true;
                    }
                    else
                    {
                        pj_compile_items.Remove(Path.Combine(code_path, Path.Combine(relative_path, filename)));
                    }
                    #endregion
                }
            }
            #endregion
        }
Пример #21
0
        /// #NAME#: #DESCRIPTION#
        public void f_17250dd1_6cd2_4b1b_a7cd_58ec52297bb8()
        {
            //INI CODE PRCGUID: 17250dd1-6cd2-4b1b-a7cd-58ec52297bb8

            String fichero_de_salida = Input_str("Fichero de salida");

            if (fichero_de_salida != "")
            {
                // current program
                ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);
                String ns_programa = CVentanaProgramas.Namespace_programa_activo.ToString();

                // program stack for recursive exploration
                Stack <KeyValuePair <int, CProgram> > s_prog = new Stack <KeyValuePair <int, CProgram> >();

                // Progs and procs dictionarys
                Dictionary <String, JToken> exp_programs  = new Dictionary <string, JToken>();
                Dictionary <String, JToken> exp_processes = new Dictionary <String, JToken>();

                CProgram cprog = new CProgram(sys, App_globals, ns_programa);
                while ((ns_programa != "") || (s_prog.Count > 0))
                {
                    int i = 0;

                    // Restore program from stack
                    if (cprog == null)
                    {
                        KeyValuePair <int, CProgram> k_prog = s_prog.Pop();
                        i     = k_prog.Key;
                        cprog = k_prog.Value;
                    }
                    int  n_prcs     = ((JArray)cprog.Logic).Count;
                    bool force_exit = false;

                    // Save program and inner processes
                    while ((!force_exit) && (i < n_prcs))
                    {
                        TProcess proc = new TProcess(sys, App_globals, (JObject)((JArray)cprog.Logic).ElementAt(i));
                        if (!exp_programs.ContainsKey(cprog.Program_namespace))
                        {
                            // add program only once
                            exp_programs.Add(cprog.Program_namespace, cprog.get_json.DeepClone());
                        }

                        i++;
                        if (proc.Guid == "Call")
                        {
                            // Add current program to stack and atach the new one for explore recursively
                            s_prog.Push(new KeyValuePair <int, CProgram>(i, cprog));
                            cprog       = new CProgram(sys, App_globals, proc.Configuration["program"].ToString());
                            ns_programa = cprog.Program_namespace;
                            force_exit  = true;
                        }
                        else if (!exp_processes.ContainsKey(proc.Guid))
                        {
                            // add process only once
                            exp_processes.Add(proc.Guid, proc.get_json.DeepClone());
                        }
                    }
                    if ((i == n_prcs) && (!force_exit))
                    {
                        // set null program only if previous bucle ends
                        cprog       = null;
                        ns_programa = "";
                    }
                }

                #region Create zip

                Ionic.Zip.ZipFile exp_file = null;
                if (File.Exists(fichero_de_salida))
                {
                    exp_file = Ionic.Zip.ZipFile.Read(fichero_de_salida);
                }
                else
                {
                    exp_file = new Ionic.Zip.ZipFile(fichero_de_salida);
                }

                #region add programs & ns conversions to zip file

                String entry_path     = "";
                String base_file_path = "";
                JArray jConversion    = new JArray();

                if (exp_file.ContainsEntry(dEXPORTCODE.STR_IMPORT_CONVS))
                {
                    Ionic.Zip.ZipEntry ze = exp_file.Entries.Where(entry => entry.FileName == dEXPORTCODE.STR_IMPORT_CONVS).FirstOrDefault();

                    MemoryStream ms = new MemoryStream();
                    ze.Extract(ms);
                    byte[] entry_data   = ms.ToArray();
                    String file_content = System.Text.Encoding.Default.GetString(entry_data);
                    ms.Close();
                    jConversion = JArray.Parse(file_content);
                }
                foreach (String sprog in exp_programs.Keys)
                {
                    base_file_path = escape_sc(sprog);

                    // Conversions
                    String  new_ns = dPROGRAM.FOLDER + "\\Imports\\" + base_file_path;
                    JObject jconv  = new JObject(new JProperty(sprog, new_ns));
                    jConversion.Add(jconv);

                    // Add program
                    entry_path = dPROGRAM.FOLDER + "\\Imports\\" + base_file_path + ".json";
                    if (!exp_file.ContainsEntry(entry_path))
                    {
                        exp_file.AddEntry(entry_path, System.Text.UTF8Encoding.UTF8.GetBytes(exp_programs[sprog].ToString()));
                    }
                }
                if (exp_file.ContainsEntry(dEXPORTCODE.STR_IMPORT_CONVS))
                {
                    exp_file.UpdateEntry(dEXPORTCODE.STR_IMPORT_CONVS, jConversion.ToString());
                }
                else
                {
                    exp_file.AddEntry(dEXPORTCODE.STR_IMPORT_CONVS, jConversion.ToString());
                }
                #endregion

                #region Create processes file

                JSonFile jfTemplate = new JSonFile(Globals.AppDataSection(dPATH.PROCESSES), dGLOBALS.PROCESS_TEMPLATE.Replace(".json", ""));
                foreach (JToken jproc in exp_processes.Values)
                {
                    ((JArray)jfTemplate.get(dPROCESS.PROCESSES)).Add(jproc);
                }
                #endregion

                #region add processes file

                base_file_path = escape_sc(CVentanaProgramas.Namespace_programa_activo.ToString());
                entry_path     = dPROCESS.FOLDER + "\\Imports\\" + base_file_path + ".json";
                if (!exp_file.ContainsEntry(entry_path))
                {
                    exp_file.AddEntry(entry_path, System.Text.UTF8Encoding.UTF8.GetBytes(jfTemplate.jActiveObj.ToString()));
                }
                #endregion

                exp_file.Save();

                #endregion

                MessageBox.Show(String.Format("Program exported {0}", CVentanaProgramas.Namespace_programa_activo.ToString()));
            }

            //END CODE PRCGUID: 17250dd1-6cd2-4b1b-a7cd-58ec52297bb8
        }
Пример #22
0
 public TDebug(CGlobals globals, String Program)
 {
     Globals               = globals;
     debugInfo             = new JSonFile(true, Globals.AppData_path(dPATH.DEBUG), Program);
     Show_debug_in_console = Globals.get(dGLOBALS.SHOW_DEBUG_IN_CONSOLE).ToObject <bool>();
 }
Пример #23
0
        /// #NAME#: #DESCRIPTION#
        public void f_Asignar_proceso()
        {
            //INI CODE PRCGUID: Asignar proceso
            ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);

            if ((CVentanaProgramas.ArbolProgramas.SelectedNode != null) && (CVentanaProgramas.ArbolProgramas.SelectedNode.Text.EndsWith(".json")))
            {
                // obtenemos el proceso a incluir
                ListBox LProcess = (ListBox)view.getCtrl("LProcess");
                JToken  JProc    = ((KeyValuePair <String, JToken>)LProcess.SelectedItem).Value;

                // obtenemos la ruta del proceso
                TreeView TV_Processes = (TreeView)view.getCtrl("TV_Processes");
                if (TV_Processes.SelectedNode != null)
                {
                    String prc_namespace = TV_Processes.SelectedNode.FullPath.Replace(dPROCESS.FOLDER + "\\", "").Replace("\\", ".").Replace(".json", "");

                    // montamos el proceso destino:
                    JObject JNewProc_2_program = new JObject();
                    JNewProc_2_program.Add("Namespace", prc_namespace);
                    JNewProc_2_program.Add("Guid", JProc["Guid"].ToString());
                    JNewProc_2_program.Add("Name", JProc["Name"].ToString());
                    JNewProc_2_program.Add("Description", JProc["Description"].ToString());

                    JObject JConf = new JObject();
                    if (JProc["Configuration"].Count() > 0)
                    {
                        foreach (JToken jitem in (JArray)JProc["Configuration"])
                        {
                            JConf.Add(jitem.ToString(), "");
                        }
                    }
                    JNewProc_2_program.Add("Configuration", JConf);
                    JObject JIn = new JObject();
                    if (JProc["Inputs"].Count() > 0)
                    {
                        foreach (JToken jitem in (JArray)JProc["Inputs"])
                        {
                            JIn.Add(jitem.ToString(), "");
                        }
                    }
                    JNewProc_2_program.Add("Inputs", JIn);
                    JObject JOut = new JObject();
                    if (JProc["Outputs"].Count() > 0)
                    {
                        foreach (JToken jitem in (JArray)JProc["Outputs"])
                        {
                            JOut.Add(jitem.ToString(), "");
                        }
                    }
                    JNewProc_2_program.Add("Outputs", JOut);

                    // obtienes el programa
                    String rutaPrograma = Path.Combine(
                        App_globals.AppDataSection(dPATH.CODE).FullName,
                        CVentanaProgramas.ArbolProgramas.SelectedNode.FullPath);

                    JSonFile jprograma = new JSonFile(rutaPrograma);
                    (jprograma.jActiveObj["Logic"] as JArray).Add(JNewProc_2_program);
                    jprograma.Write();
                }
            }


            //END CODE PRCGUID: Asignar proceso
        }
Пример #24
0
        /// #NAME#: #DESCRIPTION#
        public void f_Cargar_proceso_activo()
        {
            //INI CODE PRCGUID: Cargar proceso activo

            ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas  = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);
            ARQODE_UI.GestorProcesos.CFormProcesoActivo CFormProcesoActivo = new ARQODE_UI.GestorProcesos.CFormProcesoActivo(vm);
            if ((CVentanaProgramas.Namespace_programa_activo != null) && (CVentanaProgramas.ListaProcesos.Rows.Count > 0))
            {
                ARQODE_UI.GestorProcesos.CVentanaProcesos CVentanaProcesos = new ARQODE_UI.GestorProcesos.CVentanaProcesos(vm);
                if (CVentanaProcesos.PProcessPanel.Controls.Count == 0)
                {
                    CVentanaProcesos.PProcessPanel.Controls.Add(CFormProcesoActivo.FormProcesoActivo);
                }
                CFormProcesoActivo.FormProcesoActivo.Dock = DockStyle.Fill;
                // Variables de vistas
                CFormProcesoActivo.TV_ViewsVars.Nodes.Clear();
                TreeNode        tn_views  = (TreeNode)CVentanaProgramas.Cargar_arbol_recursivo.Crear_arbol_desde_carpeta(App_globals.AppDataSection(dPATH.VIEWS).FullName, "base_control.json");
                List <TreeNode> NodosHoja = (List <TreeNode>)CVentanaProgramas.Cargar_arbol_recursivo.Crear_lista_de_nodos_hoja_del_arbol(tn_views);

                foreach (TreeNode node in tn_views.Nodes)
                {
                    CFormProcesoActivo.TV_ViewsVars.Nodes.Add(node);
                }

                foreach (TreeNode nodo in NodosHoja)
                {
                    JSonFile JView = new JSonFile(Path.Combine(
                                                      App_globals.AppDataSection(dPATH.VIEWS).FullName,
                                                      nodo.FullPath));
                    if (JView.jActiveObj["Variables"] != null)
                    {
                        foreach (JValue var in JView.jActiveObj["Variables"] as JArray)
                        {
                            nodo.Nodes.Add(var.Value.ToString());
                        }
                    }
                }

                // Variables de programa
                CFormProcesoActivo.LB_ProgramVars.Items.Clear();

                CProgram Curr_prog = new CProgram(sys, App_globals, CVentanaProgramas.Namespace_programa_activo.ToString());
                foreach (String var in Curr_prog.vars.Keys)
                {
                    CFormProcesoActivo.LB_ProgramVars.Items.Add(var);
                }

                // Variables globals
                CFormProcesoActivo.TV_GlobalsVars.Nodes.Clear();
                foreach (JToken JGlob in App_globals.Globals)
                {
                    TreeNode tn = new TreeNode(((JProperty)JGlob).Name);

                    if (((JProperty)JGlob).Value is JObject)
                    {
                        JObject JChildGlobs = (JObject)((JProperty)JGlob).Value;

                        foreach (JProperty JChildGlob in JChildGlobs.Properties())
                        {
                            TreeNode tn1 = new TreeNode(JChildGlob.Name);
                            tn.Nodes.Add(tn1);
                        }
                    }

                    CFormProcesoActivo.TV_GlobalsVars.Nodes.Add(tn);
                }

                // Datos del proceso
                JToken JProgram_logic = (JToken)CVentanaProgramas.Procesos_programa_activo;
                if (JProgram_logic != null)
                {
                    if ((CVentanaProgramas.ListaProcesos.SelectedCells.Count > 0) ||
                        (CVentanaProgramas.ListaProcesos.Rows.Count > 0))
                    {
                        int rowIndex = (CVentanaProgramas.ListaProcesos.SelectedCells.Count > 0) ?
                                       CVentanaProgramas.ListaProcesos.SelectedCells[0].RowIndex :
                                       0;

                        String PGuid = CVentanaProgramas.ListaProcesos[1, rowIndex].Value.ToString();
                        JToken JProc = (JProgram_logic as JArray)[rowIndex];
                        // Eliminar el proceso si está vacío
                        if (JProc.Count() == 0)
                        {
                            JProc.Remove();
                            JProc = (JProgram_logic as JArray)[rowIndex];
                        }

                        // Guardar proceso activo
                        Outputs("Proceso de programa activo", JProc);

                        CFormProcesoActivo.Fila_activa = rowIndex;

                        CFormProcesoActivo.Active_process            = JProc;
                        CFormProcesoActivo.Namespace_programa_activo = CVentanaProgramas.Namespace_programa_activo;

                        CFormProcesoActivo.LName.Text         = (JProc["Name"] != null) ? JProc["Name"].ToString() : JProc["Guid"].ToString();
                        CFormProcesoActivo.TBDescription.Text = (JProc["Description"] != null) ? JProc["Description"].ToString() : "";

                        // inputs
                        System.Data.DataTable dti = new System.Data.DataTable();

                        dti.Columns.Add("Input");
                        dti.Columns.Add("Value");
                        foreach (JProperty JInput in JProc["Inputs"])
                        {
                            dti.Rows.Add(new String[] { JInput.Name, JInput.Value.ToString() });
                        }
                        CFormProcesoActivo.LInputs.DataSource = dti;

                        // Outputs
                        System.Data.DataTable dto = new System.Data.DataTable();

                        dto.Columns.Add("Output");
                        dto.Columns.Add("Value");
                        foreach (JProperty JOutputs in JProc["Outputs"])
                        {
                            dto.Rows.Add(new String[] { JOutputs.Name, JOutputs.Value.ToString() });
                        }
                        CFormProcesoActivo.LOutputs.DataSource = dto;

                        // Configuration
                        if (JProc["Configuration"] != null)
                        {
                            System.Data.DataTable dtc = new System.Data.DataTable();

                            dtc.Columns.Add("Configuration");
                            dtc.Columns.Add("Value");
                            foreach (JProperty JConfig in JProc["Configuration"])
                            {
                                dtc.Rows.Add(new String[] { JConfig.Name, JConfig.Value.ToString() });
                            }
                            CFormProcesoActivo.LConfig.DataSource = dtc;
                        }
                    }
                    else
                    {
                        CFormProcesoActivo.Active_process      = null;
                        CFormProcesoActivo.LName.Text          = "";
                        CFormProcesoActivo.TBDescription.Text  = "";
                        CFormProcesoActivo.LInputs.DataSource  = null;
                        CFormProcesoActivo.LOutputs.DataSource = null;
                        CFormProcesoActivo.LConfig.DataSource  = null;
                        Outputs("Proceso de programa activo", null);
                    }
                }

                CVentanaProcesos.tabProcesos.SelectedIndex = 1;
            }
            else
            {
                CFormProcesoActivo.Active_process      = null;
                CFormProcesoActivo.LName.Text          = "";
                CFormProcesoActivo.TBDescription.Text  = "";
                CFormProcesoActivo.LInputs.DataSource  = null;
                CFormProcesoActivo.LOutputs.DataSource = null;
                CFormProcesoActivo.LConfig.DataSource  = null;
                Outputs("Proceso de programa activo", null);
            }
            //END CODE PRCGUID: Cargar proceso activo
        }
Пример #25
0
        /// #NAME#: #DESCRIPTION#
        public void f_df797af7_6e48_40b0_96c3_7278d4d71ab7()
        {
            //INI CODE PRCGUID: df797af7-6e48-40b0-96c3-7278d4d71ab7

            ARQODE_UI.GestorProcesos.CFormProceso CFormProceso = new ARQODE_UI.GestorProcesos.CFormProceso(vm);
            JToken JProc = (JToken)CFormProceso.Proceso;

            JProc["Description"] = CFormProceso.TBDescription.Text;

            // Load inputs
            JArray JInputs = new JArray();

            foreach (String input in CFormProceso.TBInputs.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                JInputs.Add(input.Trim());
            }
            JProc["Inputs"] = JInputs;

            // Load outputs
            JArray JOutputs = new JArray();

            foreach (String output in CFormProceso.TBOutputs.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                JOutputs.Add(output.Trim());
            }
            JProc["Outputs"] = JOutputs;

            // Load configuration
            JArray JConfiguration = new JArray();

            foreach (String config in CFormProceso.TBConfiguration.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                JConfiguration.Add(config.Trim());
            }
            JProc["Configuration"] = JConfiguration;

            // Load configuration
            JArray JDefault_Configuration = new JArray();

            foreach (String def_config in CFormProceso.TBDefault_Configuration.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (def_config.Contains(":"))
                {
                    String[] name_value = def_config.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                    JDefault_Configuration.Add(new JObject(new JProperty(name_value[0].Trim(), name_value[1].Trim())));
                }
                else
                {
                    MessageBox.Show("Error in Default config format. Correct samples: default operator: sum, allow null: false, max intents: 4");
                }
            }
            JProc["Default_Configuration"] = JDefault_Configuration;

            // Process info
            if ((JProc["Name"].ToString() != CFormProceso.TBName.Text) && (!CFormProceso.TBName.Text.Trim().Equals("")))
            {
                JProc["Name"] = CFormProceso.TBName.Text;
            }

            ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);
            CStructModifications csmod = new CStructModifications(sys, App_globals);

            csmod.SaveProcess(JProc as JObject);

            //Replace process
            JSonFile JProcesses = new JSonFile(CFormProceso.FicheroProceso.ToString());
            JToken   JOld_prce  = JProcesses.getNode(String.Format("$.processes[?(@.Guid == '{0}')]", JProc["Guid"].ToString()));

            JOld_prce.Replace(JProc);
            JProcesses.Write();


            //END CODE PRCGUID: df797af7-6e48-40b0-96c3-7278d4d71ab7
        }
Пример #26
0
        /// #NAME#: #DESCRIPTION#
        public void f_Cargar_subprocesos()
        {
            //INI CODE PRCGUID: Cargar subprocesos

            ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);
            ARQODE_UI.GestorProcesos.CVentanaProcesos   CVentanaProcesos  = new ARQODE_UI.GestorProcesos.CVentanaProcesos(vm);

            CVentanaProcesos.LProcess.Items.Clear();
            if (CVentanaProcesos.TV_Processes.SelectedNode != null)
            {
                String pathProcesses = CVentanaProcesos.TV_Processes.SelectedNode.FullPath;
                if (pathProcesses.EndsWith(".json"))
                {
                    JSonFile processes_file = new JSonFile(Path.Combine(App_globals.AppDataSection(dPATH.CODE).FullName, pathProcesses), true);

                    // Guardar fichero activo
                    ARQODE_UI.GestorProcesos.CFormProceso CFormProceso = new ARQODE_UI.GestorProcesos.CFormProceso(vm);
                    CFormProceso.FicheroProceso = processes_file.file_path;

                    if (!processes_file.hasErrors())
                    {
                        if (processes_file.jActiveObj["processes"].Count() > 0)
                        {
                            foreach (JToken jProc in (JArray)processes_file.jActiveObj["processes"])
                            {
                                String Name = (jProc["Name"] != null) ? jProc["Name"].ToString() : jProc["Guid"].ToString();
                                KeyValuePair <String, JToken> kprocess = new KeyValuePair <string, JToken>(Name, jProc);

                                CVentanaProcesos.LProcess.Items.Add(kprocess);
                                CVentanaProcesos.LProcess.ValueMember   = "Value";
                                CVentanaProcesos.LProcess.DisplayMember = "Key";
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Errors in json file: " + processes_file.jErrors.ToString());
                    }
                }
                else
                {
                    DirectoryInfo processes_path = new DirectoryInfo(Path.Combine(App_globals.AppDataSection(dPATH.CODE).FullName, pathProcesses));

                    foreach (TreeNode child_node in CVentanaProcesos.TV_Processes.SelectedNode.Nodes)
                    {
                        if ((child_node.Nodes.Count == 0) && (!child_node.Text.EndsWith(".json")))
                        {
                            foreach (DirectoryInfo subProcesses_folder in processes_path.GetDirectories(child_node.Text)[0].GetDirectories())
                            {
                                child_node.Nodes.Add(subProcesses_folder.FullName, subProcesses_folder.Name);
                                child_node.Nodes[child_node.Nodes.Count - 1].Name = subProcesses_folder.Name;
                            }

                            foreach (FileInfo subProcesses_files in processes_path.GetDirectories(child_node.Text)[0].GetFiles())
                            {
                                child_node.Nodes.Add(subProcesses_files.FullName, subProcesses_files.Name);
                                child_node.Nodes[child_node.Nodes.Count - 1].Name = subProcesses_files.Name;
                            }
                        }
                    }
                }
            }

            //END CODE PRCGUID: Cargar subprocesos
        }
Пример #27
0
        /// <summary>
        /// Find in processes process all words in find_str
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="find_str"></param>
        /// <param name="findedProcesses"></param>
        private void find_in_processes(FileInfo fi, ArrayList find_str, ref List <KeyValuePair <JToken, int> > findedProcesses)
        {
            JSonFile jProcess    = new JSonFile(fi.FullName);
            int      max_founded = 0;
            int      founded     = 0;

            // Search in calls
            if (jProcess.jActiveObj["processes"] != null)
            {
                foreach (JToken Jnode in jProcess.jActiveObj["processes"] as JArray)
                {
                    String Guid = Jnode["Guid"].ToString();
                    Jnode["Guid"] = "";
                    founded       = 0;
                    String cad_bus = "";
                    if (find_str.Count > 2)
                    {
                        foreach (string find in find_str)
                        {
                            cad_bus += find + " ";
                        }
                        if (Jnode.ToString().ToLower().Contains(cad_bus))
                        {
                            founded += 2;
                        }
                        cad_bus = "";
                    }
                    for (int i = 1; i < find_str.Count && find_str.Count > 1; i++)
                    {
                        cad_bus = find_str[i - 1] + " " + find_str[i];
                        if (Jnode.ToString().ToLower().Contains(cad_bus))
                        {
                            founded += 1;
                        }
                    }

                    foreach (string find in find_str)
                    {
                        if (Jnode.ToString().ToLower().Contains(find.ToLower()))
                        {
                            founded++;
                        }
                    }
                    if (founded >= find_str.Count)
                    {
                        if (max_founded < founded)
                        {
                            max_founded = founded;
                        }
                        JObject jfind = new JObject();
                        jfind["Process"]      = fi.FullName;
                        jfind["Process guid"] = Guid;
                        jfind["Process name"] = (Jnode["Name"] != null) ? Jnode["Name"] : Guid;
                        findedProcesses.Add(new KeyValuePair <JToken, int>(jfind, founded));
                    }
                }
            }
            #region find in path
            founded = 0;
            foreach (string find in find_str)
            {
                if (fi.FullName.ToLower().Contains(find.ToLower()))
                {
                    founded++;
                }
            }
            if (founded >= find_str.Count - 1)
            {
                JObject jfind = new JObject();
                jfind["Process"]      = fi.FullName;
                jfind["Process guid"] = "";
                jfind["Process name"] = "";
                if (max_founded < founded)
                {
                    max_founded = founded;
                }
                findedProcesses.Add(new KeyValuePair <JToken, int>(jfind, max_founded + (founded - find_str.Count)));
            }
            #endregion
        }
Пример #28
0
        /// <summary>
        /// Load Globals vars
        /// </summary>
        /// <param name="GLOBALS"></param>
        public CGlobals(String App_name)
        {
            active_app = App_name;
            // Get AppData location
            dApp_path = new DirectoryInfo(Assembly.GetExecutingAssembly().Location);
            String sApps_path = dGLOBALS.APPDATA_PATH;

            while ((dApp_path != null) && (!Directory.Exists(Path.Combine(dApp_path.FullName, sApps_path))))
            {
                dApp_path = dApp_path.Parent;
            }
            if (dApp_path != null)
            {
                // Apps path
                dApps = dApp_path.Parent;

                if (dApp_path != null)
                {
                    // appdata path
                    dAppData_path = dApp_path.GetDirectories(dGLOBALS.APPDATA_PATH)[0];
                    // data path
                    dData_path = dApp_path.GetDirectories(dGLOBALS.DATA_PATH)[0];
                    // resources path

                    dResources_path = (dApp_path.GetDirectories(dGLOBALS.RESOURCES_PATH).Length > 0) ?
                                      dApp_path.GetDirectories(dGLOBALS.RESOURCES_PATH)[0] :
                                      null;
                    // assembly path
                    dAssemblies_path = (dAppData_path.GetDirectories(dGLOBALS.ASSEMBLIES_PATH).Length > 0) ?
                                       dAppData_path.GetDirectories(dGLOBALS.ASSEMBLIES_PATH)[0] :
                                       null;
                }
                else
                {
                    errors = "Error loading AppData path";
                }

                if (errors == "")
                {
                    #region Get globals from settings

                    //String sglobals = VS_PROJECT.Properties.Settings.Default.Globals;
                    //JObject jGlobals = JObject.Parse(System.Text.UTF8Encoding.UTF8.GetString(Convert.FromBase64String(sglobals)));

                    //pInfo = new JSonFile(jGlobals);
                    //globals = pInfo.jActiveObj;
                    #endregion

                    #region Get globals from globals.json

                    pInfo = new JSonFile(dData_path, dGLOBALS.GLOBALS);
                    if (!pInfo.hasErrors())
                    {
                        globals = pInfo.get(dGLOBALS.GLOBALS);
                    }
                    else
                    {
                        errors = pInfo.jErrors.ToString();
                    }
                    #endregion
                }
            }
            else
            {
                errors = "AppData path not found";
            }
        }
Пример #29
0
 public TErrors(CGlobals Globals, String Program)
 {
     errorInfo      = new JSonFile(true, Globals.AppData_path(dPATH.ERRORS), Program);
     Console_output = Globals.get(dGLOBALS.SHOW_ERRORS_IN_CONSOLE).ToObject <bool>();
     ErrorStatus    = errorStatus.OK;
 }