Beispiel #1
0
        /// <summary>
        /// Carga en memoria los componentes registrados en la base de datos
        /// </summary>
        public static void CargarComponentes()
        {
            // Cargo el componente Core
            Lbl.Componentes.Componente ComLfc = new Lbl.Componentes.Componente(Lfx.Workspace.Master.MasterConnection);
            ComLfc.Crear();

            ComLfc.Nombre         = "Lfc";
            ComLfc.EspacioNombres = "Lfc";
            ComLfc.Assembly       = System.Reflection.Assembly.LoadFrom("Lfc.dll");
            Lfx.Components.Manager.RegisterComponent(ComLfc);

            if (Lfx.Workspace.Master.Tables.ContainsKey("sys_components"))
            {
                Lbl.ColeccionGenerica <Lbl.Componentes.Componente> Comps = Lbl.Componentes.Componente.ObtenerActivos();
                // Inicializar todos los componentes
                foreach (Lbl.Componentes.Componente Comp in Comps)
                {
                    // Registro el componente con el actualizador
                    if (Lfx.Updates.Updater.Master != null)
                    {
                        Lfx.Updates.Package Pkg = new Lfx.Updates.Package();
                        Pkg.Name         = Comp.EspacioNombres;
                        Pkg.RelativePath = "Components" + System.IO.Path.DirectorySeparatorChar + Comp.EspacioNombres + System.IO.Path.DirectorySeparatorChar;
                        Pkg.Url          = Comp.UrlActualizaciones;
                        Lfx.Updates.Updater.Master.Packages.Add(Pkg);
                    }

                    try
                    {
                        Lfx.Components.Manager.RegisterComponent(Comp);
                        if (Comp.Estructura != null)
                        {
                            var Doc = new System.Xml.XmlDocument();
                            Doc.LoadXml(Comp.Estructura);
                            Lfx.Workspace.Master.Structure.AddToBuiltIn(Doc);
                        }
                        if (Lfx.Environment.SystemInformation.DesignMode == false && Comp.ObtenerVersionActual() > Comp.Version)
                        {
                            // Actualizo el CIF y la estrucutra en la BD
                            Comp.Version = Comp.ObtenerVersionActual();
                            Comp.Guardar();
                        }
                    }
                    catch (Exception ex)
                    {
                        if (Lfx.Workspace.Master != null && Lfx.Workspace.Master.DebugMode == false)
                        {
                            Lfx.Workspace.Master.RunTime.Toast("No se puede registrar el componente " + Comp.Nombre + "." + ex.Message, "Error");
                            throw;
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }
        }
Beispiel #2
0
		//[STAThread]
                public static void Main(string[] args)
                {

                        //Console.WriteLine("RunComponent");
                        //Console.WriteLine("    Ejecuta un componente Lfx fuera del entorno de Lázaro.");
                        //Console.WriteLine("    Copyright 2004-2012 Ernesto N. Carrea");
                        //Console.WriteLine("");
                        System.Windows.Forms.Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(ThreadExceptionHandler);
                        AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(GlobalExceptionHandler);
                        System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

                        string ComponentName = null, FunctionName = null;
                        if (args.Length == 2) {
                                ComponentName = args[0];
                                FunctionName = args[1];
                        } else if (args.Length == 1) {
                                ComponentName = args[0];
                                FunctionName = args[0];
                        } else if (args.Length == 0) {
                                ComponentName = System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().Location);
                                FunctionName = ComponentName;
                        }

                        Lfx.Workspace.Master = new Lfx.Workspace("default");
                        Lbl.Sys.Config.Actual = new Lbl.Sys.Configuracion.Global();
                        Lbl.Sys.Config.Cargar();

                        if (ComponentName != null && FunctionName != null) {
                                //Console.WriteLine("Ejecutando " + ComponentName + "." + FunctionName);
                                Lbl.Componentes.Componente Comp = new Lbl.Componentes.Componente(Lfx.Workspace.Master.GetNewConnection(ComponentName));
                                Comp.Crear();
                                Comp.Nombre = ComponentName;
                                Comp.EspacioNombres = ComponentName;
                                Lfx.Components.Manager.RegisterComponent(Comp);

                                Lfx.Components.Function Funcion = null;
                                try {
                                        Funcion = Comp.Funciones[FunctionName].Instancia;
                                } catch (Exception ex) {
                                        System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error");
                                }
                                if (Funcion != null) {
                                        Funcion.Workspace = Lfx.Workspace.Master;
                                        Funcion.ExecutableName = System.Reflection.Assembly.GetExecutingAssembly().Location;
                                        Funcion.Arguments = Environment.GetCommandLineArgs();
                                        Funcion.Run(true);
                                } else {
                                        System.Windows.Forms.MessageBox.Show("No se puede ejecutar " + ComponentName + "." + FunctionName, "Error");
                                }
                        } else {
                                Console.WriteLine("Uso:");
                                Console.WriteLine("    RunComponent [NombreComponente] [NombreFuncion]");
                                Console.WriteLine("        Si no se especifica NombreFuncion, se asume igual que NombreComponente.");
                                Console.WriteLine("        Si no se especifica NombreComponente, se asume el nombre de este ejecutable.");
                        }
                }
Beispiel #3
0
        //[STAThread]
        public static void Main(string[] args)
        {
            //Console.WriteLine("RunComponent");
            //Console.WriteLine("    Ejecuta un componente Lfx fuera del entorno de Lázaro.");
            //Console.WriteLine("    Copyright 2004-2017 Ernesto Nicolás Carrea y colaboradores");
            //Console.WriteLine("");
            System.Windows.Forms.Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(ThreadExceptionHandler);
            AppDomain.CurrentDomain.UnhandledException       += new UnhandledExceptionEventHandler(GlobalExceptionHandler);
            System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            string ComponentName = null, FunctionName = null;

            if (args.Length == 2)
            {
                ComponentName = args[0];
                FunctionName  = args[1];
            }
            else if (args.Length == 1)
            {
                ComponentName = args[0];
                FunctionName  = args[0];
            }
            else if (args.Length == 0)
            {
                ComponentName = System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().Location);
                FunctionName  = ComponentName;
            }

            Lfx.Workspace.Master  = new Lfx.Workspace("default");
            Lbl.Sys.Config.Actual = new Lbl.Sys.Configuracion.Global();
            Lbl.Sys.Config.Cargar();

            if (ComponentName != null && FunctionName != null)
            {
                //Console.WriteLine("Ejecutando " + ComponentName + "." + FunctionName);
                Lbl.Componentes.Componente Comp = new Lbl.Componentes.Componente(Lfx.Workspace.Master.GetNewConnection(ComponentName) as Lfx.Data.Connection);
                Comp.Crear();
                Comp.Nombre         = ComponentName;
                Comp.EspacioNombres = ComponentName;
                Lfx.Components.Manager.RegisterComponent(Comp);

                Comp.ComponentInstance.Do(FunctionName, Environment.GetCommandLineArgs());
            }
            else
            {
                Console.WriteLine("Uso:");
                Console.WriteLine("    RunComponent [NombreComponente] [NombreFuncion]");
                Console.WriteLine("        Si no se especifica NombreFuncion, se asume igual que NombreComponente.");
                Console.WriteLine("        Si no se especifica NombreComponente, se asume el nombre de este ejecutable.");
            }
        }
Beispiel #4
0
                /// <summary>
                /// Carga en memoria los componentes registrados en la base de datos
                /// </summary>
                private static void CargarComponentes()
                {
                        // Cargo el componente Core
                        Lbl.Componentes.Componente ComLfc = new Lbl.Componentes.Componente(Lfx.Workspace.Master.MasterConnection);
                        ComLfc.Crear();

                        ComLfc.Nombre = "Lfc";
                        ComLfc.EspacioNombres = "Lfc";
                        ComLfc.Assembly = System.Reflection.Assembly.LoadFrom("Lfc.dll");
                        Lfx.Components.Manager.RegisterComponent(ComLfc);

                        if (Lfx.Workspace.Master.MasterConnection.Tables.ContainsKey("sys_components")) {
                                Lbl.ColeccionGenerica<Lbl.Componentes.Componente> Comps = Lbl.Componentes.Componente.Todos();
                                // Inicializar todos los componentes
                                foreach (Lbl.Componentes.Componente Comp in Comps) {
                                        // Registro el componente con el actualizador
                                        if (Lfx.Updates.Updater.Master != null) {
                                                Lfx.Updates.Package Pkg = new Lfx.Updates.Package();
                                                Pkg.Name = Comp.EspacioNombres;
                                                Pkg.RelativePath = "Components" + System.IO.Path.DirectorySeparatorChar + Comp.EspacioNombres + System.IO.Path.DirectorySeparatorChar;
                                                Pkg.Url = Comp.UrlActualizaciones;
                                                Lfx.Updates.Updater.Master.Packages.Add(Pkg);
                                        }

                                        try {
                                                Lfx.Components.Manager.RegisterComponent(Comp);
                                                if (Comp.Estructura != null) {
                                                        System.Xml.XmlDocument Doc = new System.Xml.XmlDocument();
                                                        Doc.LoadXml(Comp.Estructura);
                                                        Lfx.Workspace.Master.Structure.AddToBuiltIn(Doc);
                                                }
                                                if (Lfx.Environment.SystemInformation.DesignMode == false && Comp.ObtenerVersionActual() > Comp.Version) {
                                                        // Actualizo el CIF y la estrucutra en la BD
                                                        Comp.Version = Comp.ObtenerVersionActual();
                                                        Comp.Guardar();
                                                }
                                        } catch (Exception ex) {
                                                if (Lfx.Workspace.Master != null && Lfx.Workspace.Master.DebugMode == false) {
                                                        Lfx.Workspace.Master.RunTime.Toast("No se puede registrar el componente " + Comp.Nombre + "." + ex.Message, "Error");
                                                        UnknownExceptionHandler(ex);
                                                } else {
                                                        throw ex;
                                                }
                                        }
                                }
                        }
                }