private static object ExecInternal(string comando, string estacion) { Console.WriteLine("Exec:" + comando); if (estacion == null || estacion.Length == 0) { estacion = Lfx.Environment.SystemInformation.MachineName; } string SubComando = Lfx.Types.Strings.GetNextToken(ref comando, " ").Trim().ToUpperInvariant(); switch (SubComando) { case "CREAR": case "CREATE": return(ExecCrearEditar(true, comando)); case "EDITAR": case "EDIT": return(ExecCrearEditar(false, comando)); case "LISTAR": case "LIST": return(ExecListar(comando)); case "IMPRIMIR": return(ExecImprimir(comando)); case "INSTANCIAR": return(ExecInstanciar(comando)); /* case "REPO": * qGen.Select Sel = new qGen.Select("comprob_detalle"); * Sel.Fields = "personas.id_persona,personas.nombre_visible,comprob.fecha,comprob.total"; * Sel.Joins.Add(new qGen.Join("comprob", "comprob_detalle.id_comprob=comprob.id_comprob")); * Sel.Joins.Add(new qGen.Join("personas", "comprob.id_cliente=personas.id_persona")); * Sel.WhereClause = new qGen.Where(); * Sel.WhereClause.AddWithValue("comprob.fecha", "'2009-09-01'", "'2009-09-30'"); * Sel.WhereClause.AddWithValue("comprob.compra", 0); * Sel.WhereClause.AddWithValue("comprob.numero", qGen.ComparisonOperators.GreaterThan, 0); * Sel.WhereClause.AddWithValue("comprob.tipo_fac", qGen.ComparisonOperators.In, new string[] { "FA", "FB", "FC", "FM", "FE" }); * * Lbl.Reportes.Reporte Rep = new Lbl.Reportes.Reporte(Lfx.Workspace.Master.GetNewConnection("REPO"), Sel); * Rep.Grouping = new Lfx.Data.Grouping("personas.nombre_visible"); * Rep.Aggregates.Add(new Lfx.Data.Aggregate(Lfx.Data.AggregationFunctions.Count, "comprob.fecha")); * Rep.Aggregates.Add(new Lfx.Data.Aggregate(Lfx.Data.AggregationFunctions.Sum, "comprob.total")); * Rep.Fields.Add(new Lazaro.Pres.Field("personas.nombre_visible", "Cliente", Lfx.Data.InputFieldTypes.Text, 320)); * Rep.Fields.Add(new Lazaro.Pres.Field("comprob.fecha", "Fecha", Lfx.Data.InputFieldTypes.Date, 100)); * Rep.Fields.Add(new Lazaro.Pres.Field("comprob.total", "Total", Lfx.Data.InputFieldTypes.Currency, 120)); * Rep.ExpandGroups = false; * * Lfc.Reportes.Reporte RepForm = new Lfc.Reportes.Reporte(); * RepForm.MdiParent = Aplicacion.FormularioPrincipal; * RepForm.ReporteAMostrar = Rep; * RepForm.Show(); * break; */ case "LIC": Lfx.Lic.Licenciar(@"..\..\"); Lfx.Lic.Licenciar(@"..\..\..\Componentes\RunComponent"); Lfx.Lic.Licenciar(@"..\..\..\Componentes\ServidorFiscal"); Lfx.Lic.Licenciar(@"..\..\..\Lfx"); Lfx.Lic.Licenciar(@"..\..\..\Lbl"); Lfx.Lic.Licenciar(@"..\..\..\Lui"); Lfx.Lic.Licenciar(@"..\..\..\Lcc"); Lfx.Lic.Licenciar(@"..\..\..\Lfc"); Lfx.Lic.Licenciar(@"..\..\..\Impresion"); Lfx.Lic.Licenciar(@"..\..\..\Pres"); break; case "HISTORIAL": string Tabla = Lfx.Types.Strings.GetNextToken(ref comando, " ").Trim(); int Id = Lfx.Types.Parsing.ParseInt(Lfx.Types.Strings.GetNextToken(ref comando, " ")); Lfc.Log.Editar His = new Lfc.Log.Editar(); His.MdiParent = Aplicacion.FormularioPrincipal; His.Mostrar(Tabla, Id); His.Show(); break; case "NAL": case "SONPESOS": Lui.Forms.MessageBox.Show(Lfx.Types.Formatting.SpellNumber(Lfx.Types.Parsing.ParseCurrency(comando)), "Números a letras"); break; case "VENTRE": Lfx.Data.Connection ConexionFiltro = Lfx.Workspace.Master.GetNewConnection("Importar datos"); string Opciones = Lfx.Types.Strings.GetNextToken(ref comando, " ").Trim().ToUpperInvariant(); Lbl.Servicios.Importar.Opciones OpcionesFiltro = new Lbl.Servicios.Importar.Opciones(); OpcionesFiltro.ImportarClientes = Opciones.IndexOf('C') >= 0; OpcionesFiltro.ImportarArticulos = Opciones.IndexOf('A') >= 0; OpcionesFiltro.ImportarFacturas = Opciones.IndexOf('F') >= 0; OpcionesFiltro.ImportarCtasCtes = Opciones.IndexOf('E') >= 0; OpcionesFiltro.ActualizarRegistros = SubComando.IndexOf('+') >= 0; Lbl.Servicios.Importar.FiltroEscorpion Fil = new Lbl.Servicios.Importar.FiltroEscorpion(ConexionFiltro, OpcionesFiltro); Fil.Dsn = "ventre"; System.Threading.ThreadStart ThreadFiltro = delegate { Fil.Importar(); }; System.Threading.Thread Thr = new System.Threading.Thread(ThreadFiltro); Thr.IsBackground = true; Thr.Start(); break; case "CHECK": string SubComandoDbCheck = Lfx.Types.Strings.GetNextToken(ref comando, " ").Trim().ToUpperInvariant(); switch (SubComandoDbCheck) { case "ALL": case "": Exec("CHECK STRUCT", estacion); Exec("CHECK DATA", estacion); break; case "DATA": Lbl.Servicios.Verificador Ver = new Lbl.Servicios.Verificador(Lfx.Workspace.Master.MasterConnection); Ver.CheckDataBase(); break; case "STRUCT": System.Threading.ThreadStart ThreadVerif = delegate { Lfx.Workspace.Master.CheckAndUpdateDataBaseVersion(true, false); }; System.Threading.Thread ThrVerif = new System.Threading.Thread(ThreadVerif); ThrVerif.IsBackground = true; ThrVerif.Start(); break; } break; case "VER": Lazaro.WinMain.Misc.AcercaDe OAcercaDe = new Lazaro.WinMain.Misc.AcercaDe(); OAcercaDe.ShowDialog(); break; case "REBOOT": try { int EstacionFiscal = Lfx.Workspace.Master.MasterConnection.FieldInt("SELECT id_pv FROM pvs WHERE estacion='" + Lfx.Environment.SystemInformation.MachineName + "' AND tipo=2 AND id_sucursal=" + Lfx.Workspace.Master.CurrentConfig.Empresa.SucursalActual.ToString()); if (EstacionFiscal > 0) { Lfx.Workspace.Master.DefaultScheduler.AddTask("REBOOT", "fiscal" + EstacionFiscal); System.Threading.Thread.Sleep(100); } } catch { // Nada } Lfx.Environment.Shell.Reboot(); break; case "CALC": Lazaro.WinMain.Misc.Calculadora OCalc = new Lazaro.WinMain.Misc.Calculadora(); OCalc.Show(); break; case "BACKUP": if (Lui.LogOn.LogOnData.ValidateAccess("Global.Backup", Lbl.Sys.Permisos.Operaciones.Administrar)) { string SubComandoBackup = Lfx.Types.Strings.GetNextToken(ref comando, " ").Trim().ToUpper(); switch (SubComandoBackup) { case "MANAGER": WinMain.Backup.Manager FormBackup = (WinMain.Backup.Manager)BuscarVentana("WinMain.Misc.Backup.Manager"); if (FormBackup == null) { FormBackup = new WinMain.Backup.Manager(); } FormBackup.MdiParent = Aplicacion.FormularioPrincipal; FormBackup.Show(); break; case "NOW": Lfx.Backups.BackupInfo Bkp = new Lfx.Backups.BackupInfo(); Bkp.Name = System.DateTime.Now.ToString(Lfx.Types.Formatting.DateTime.LongDatePattern + @" ""a las"" HH.mm.ss"); Bkp.CompanyName = Lbl.Sys.Config.Empresa.Nombre; Bkp.UserName = Lbl.Sys.Config.Actual.UsuarioConectado.Persona.Nombre; Bkp.ProgramVersion = Aplicacion.Version() + " del " + Aplicacion.BuildDate(); Lfx.Backups.Manager BackupManager = new Lfx.Backups.Manager(); BackupManager.BackupPath = System.IO.Path.Combine(Lbl.Sys.Config.CarpetaEmpresa, "Copias de seguridad" + System.IO.Path.DirectorySeparatorChar); BackupManager.StartBackup(Bkp); break; } } break; case "CONFIG": if (Lbl.Sys.Config.Actual.UsuarioConectado.TieneAccesoGlobal()) { Config.Preferencias FormConfig = new Config.Preferencias(); FormConfig.ShowDialog(Aplicacion.FormularioPrincipal); } else { Lfx.Workspace.Master.RunTime.Toast("No tiene permiso para cambiar las preferencias del programa.", "Error"); } break; case "CHANGEPWD": Misc.CambioContrasena FormCambio = new Misc.CambioContrasena(); FormCambio.ShowDialog(); break; case "FISCAL": string SubComandoFiscal = Lfx.Types.Strings.GetNextToken(ref comando, " ").Trim().ToUpper(); switch (SubComandoFiscal) { case "INICIAR": Lfx.Environment.Shell.Execute(Lfx.Environment.Folders.ApplicationFolder + "ServidorFiscal.exe", null, System.Diagnostics.ProcessWindowStyle.Normal, false); break; case "PANEL": Lazaro.WinMain.Misc.Fiscal OFormFiscal = (Lazaro.WinMain.Misc.Fiscal)BuscarVentana("Lazaro.Misc.Fiscal"); if (OFormFiscal == null) { OFormFiscal = new Lazaro.WinMain.Misc.Fiscal(); } OFormFiscal.ShowDialog(); break; } break; case "MENSAJE": case "MESSAGE": Lfx.Workspace.Master.RunTime.Toast(comando, "Mensaje remoto de " + estacion); return(null); case "RUN": string NombreComponente = Lfx.Types.Strings.GetNextToken(ref comando, ".").Trim(); string NombreFuncion = Lfx.Types.Strings.GetNextToken(ref comando, " ").Trim(); if (Lfx.Components.Manager.ComponentesCargados.ContainsKey(NombreComponente) == false) { NombreComponente += "." + Lfx.Types.Strings.GetNextToken(ref NombreFuncion, ".").Trim(); } if (Lfx.Components.Manager.ComponentesCargados.ContainsKey(NombreComponente) == false) { return(new Lfx.Types.FailureOperationResult("No se encuentra el componente " + NombreComponente)); } else { Lfx.Components.IComponent Componente = Lfx.Components.Manager.ComponentesCargados[NombreComponente]; if (Componente.Funciones.ContainsKey(NombreFuncion) == false) { return(new Lfx.Types.FailureOperationResult("No se encuentra el la función " + NombreComponente + "." + NombreFuncion)); } else { Lfx.Components.FunctionInfo Funcion = Componente.Funciones[NombreFuncion]; object RunResult = Funcion.Run(); if (RunResult is System.Windows.Forms.Form) { if (Funcion.Instancia.FunctionType == Lfx.Components.FunctionTypes.MdiChildren) { ((System.Windows.Forms.Form)(RunResult)).MdiParent = Aplicacion.Flotante ? null : Aplicacion.FormularioPrincipal; } ((System.Windows.Forms.Form)(RunResult)).Show(); } else if (RunResult is Lfx.Types.OperationResult) { Lfx.Types.OperationResult OpeResult = RunResult as Lfx.Types.OperationResult; if (OpeResult.Message != null && OpeResult.Message.Length > 0) { Lfx.Workspace.Master.RunTime.Toast(OpeResult.Message, OpeResult.Success ? "Aviso" : "Error"); } } } } break; case "QUIT": if (Aplicacion.FormularioPrincipal != null) { Aplicacion.FormularioPrincipal.Close(); } System.Threading.Thread.Sleep(200); Lfx.Workspace.Master.Dispose(); System.Environment.Exit(0); break; case "ERROR": throw new Exception("Error de prueba."); default: if (Lfx.Workspace.Master.DebugMode) { throw new NotImplementedException(comando); } else { return(new Lfx.Types.OperationResult(false)); } } return(null); }
public Lfx.Types.OperationResult Load() { if (this.Assembly == null) { string[] WhereToLook; if (Lfx.Workspace.Master.DebugMode) { WhereToLook = new string[] { System.IO.Path.Combine(Lfx.Environment.Folders.ApplicationFolder, @"../../../Componentes/bin/dev/" + this.EspacioNombres + ".dll"), System.IO.Path.Combine(Lfx.Environment.Folders.ComponentsFolder, this.EspacioNombres + System.IO.Path.DirectorySeparatorChar + this.EspacioNombres + ".dll"), Lfx.Environment.Folders.ComponentsFolder + this.EspacioNombres + ".dll", Lfx.Environment.Folders.ApplicationFolder + this.EspacioNombres + ".dll" }; } else { WhereToLook = new string[] { Lfx.Environment.Folders.ComponentsFolder + this.EspacioNombres + System.IO.Path.DirectorySeparatorChar + this.EspacioNombres + ".dll", Lfx.Environment.Folders.ComponentsFolder + this.EspacioNombres + ".dll", Lfx.Environment.Folders.ApplicationFolder + this.EspacioNombres + ".dll" }; } foreach (string Archivo in WhereToLook) { if (System.IO.File.Exists(Archivo)) { try { this.Assembly = System.Reflection.Assembly.LoadFrom(Archivo); break; } catch { // Nada } } } } if (this.Assembly == null) { return new Lfx.Types.FailureOperationResult("No se puede cargar el componente " + this.Nombre); } else { // Cargo las estructuras de datos adicionales que el componente necesita using (System.IO.Stream DbStructXml = this.Assembly.GetManifestResourceStream(this.EspacioNombres + ".dbstruct.xml")) { if (DbStructXml != null) { // FIXME: puedo cargarlo con un lector de texto using (System.IO.StreamReader Lector = new System.IO.StreamReader(DbStructXml)) { this.Estructura = Lector.ReadToEnd(); Lector.Close(); } } } this.TiposRegistrados = new Lfx.Components.RegisteredTypeCollection(); this.Funciones = new Lfx.Components.FunctionInfoCollection(); // Creo la función Try, que la tienen que definir todos los componentes Lfx.Components.FunctionInfo TryFunc = new Lfx.Components.FunctionInfo(this); TryFunc.Nombre = "Try"; this.Funciones.Add(TryFunc); // Creo la función Register, que la tienen que definir todos los componentes Lfx.Components.FunctionInfo RegisterFunc = new Lfx.Components.FunctionInfo(this); RegisterFunc.Nombre = "Register"; this.Funciones.Add(RegisterFunc); // Creo la función GetTypes, que la tienen que definir todos los componentes Lfx.Components.FunctionInfo GetTypesFunc = new Lfx.Components.FunctionInfo(this); GetTypesFunc.Nombre = "GetTypes"; this.Funciones.Add(GetTypesFunc); this.LoadCif(); // Agrego los tipos registrados this.Funciones["Register"].Run(); Lfx.Components.RegisteredTypeCollection Col = this.Funciones["GetTypes"].Run() as Lfx.Components.RegisteredTypeCollection; if (Col != null) this.TiposRegistrados.AddRange(Col); return new Lfx.Types.SuccessOperationResult(); } }
public Lfx.Types.OperationResult Load() { if (this.Assembly == null) { string[] WhereToLook; if (Lfx.Workspace.Master.DebugMode) { WhereToLook = new string[] { System.IO.Path.Combine(Lfx.Environment.Folders.ApplicationFolder, @"../../../Componentes/bin/dev/" + this.EspacioNombres + ".dll"), System.IO.Path.Combine(Lfx.Environment.Folders.ComponentsFolder, this.EspacioNombres + System.IO.Path.DirectorySeparatorChar + this.EspacioNombres + ".dll"), Lfx.Environment.Folders.ComponentsFolder + this.EspacioNombres + ".dll", Lfx.Environment.Folders.ApplicationFolder + this.EspacioNombres + ".dll" }; } else { WhereToLook = new string[] { Lfx.Environment.Folders.ComponentsFolder + this.EspacioNombres + System.IO.Path.DirectorySeparatorChar + this.EspacioNombres + ".dll", Lfx.Environment.Folders.ComponentsFolder + this.EspacioNombres + ".dll", Lfx.Environment.Folders.ApplicationFolder + this.EspacioNombres + ".dll" }; } foreach (string Archivo in WhereToLook) { if (System.IO.File.Exists(Archivo)) { try { this.Assembly = System.Reflection.Assembly.LoadFrom(Archivo); break; } catch { // Nada } } } } if (this.Assembly == null) { return(new Lfx.Types.FailureOperationResult("No se puede cargar el componente " + this.Nombre)); } else { // Cargo las estructuras de datos adicionales que el componente necesita using (System.IO.Stream DbStructXml = this.Assembly.GetManifestResourceStream(this.EspacioNombres + ".dbstruct.xml")) { if (DbStructXml != null) { // FIXME: puedo cargarlo con un lector de texto using (System.IO.StreamReader Lector = new System.IO.StreamReader(DbStructXml)) { this.Estructura = Lector.ReadToEnd(); Lector.Close(); } } } this.TiposRegistrados = new Lfx.Components.RegisteredTypeCollection(); this.Funciones = new Lfx.Components.FunctionInfoCollection(); // Creo la función Try, que la tienen que definir todos los componentes Lfx.Components.FunctionInfo TryFunc = new Lfx.Components.FunctionInfo(this); TryFunc.Nombre = "Try"; this.Funciones.Add(TryFunc); // Creo la función Register, que la tienen que definir todos los componentes Lfx.Components.FunctionInfo RegisterFunc = new Lfx.Components.FunctionInfo(this); RegisterFunc.Nombre = "Register"; this.Funciones.Add(RegisterFunc); // Creo la función GetTypes, que la tienen que definir todos los componentes Lfx.Components.FunctionInfo GetTypesFunc = new Lfx.Components.FunctionInfo(this); GetTypesFunc.Nombre = "GetTypes"; this.Funciones.Add(GetTypesFunc); this.LoadCif(); // Agrego los tipos registrados this.Funciones["Register"].Run(); Lfx.Components.RegisteredTypeCollection Col = this.Funciones["GetTypes"].Run() as Lfx.Components.RegisteredTypeCollection; if (Col != null) { this.TiposRegistrados.AddRange(Col); } return(new Lfx.Types.SuccessOperationResult()); } }
public void LoadCif() { // Cargo el archivo CIF using (System.IO.Stream CifXml = this.Assembly.GetManifestResourceStream(this.EspacioNombres + ".cif.xml")) { if (CifXml != null) { // FIXME: puedo cargarlo con un lector de texto using (System.IO.StreamReader Lector = new System.IO.StreamReader(CifXml)) { this.Cif = Lector.ReadToEnd(); Lector.Close(); } } } if (this.Cif == null) return; System.Xml.XmlDocument DocumentoCif = new System.Xml.XmlDocument(); DocumentoCif.LoadXml(this.Cif); System.Xml.XmlNodeList ListaComponentes = DocumentoCif.GetElementsByTagName("Component"); //Abro el/los nodo(s) de componentes foreach (System.Xml.XmlNode Componente in ListaComponentes) { System.Xml.XmlNodeList NodosMenu = DocumentoCif.GetElementsByTagName("MenuItem"); foreach (System.Xml.XmlNode NodoMenu in NodosMenu) { if (this.MenuEntries == null) this.MenuEntries = new List<Lfx.Components.MenuEntry>(); Lfx.Components.MenuEntry Menu = new Lfx.Components.MenuEntry(); Menu.Name = NodoMenu.Attributes["name"].Value; if (NodoMenu.Attributes["position"] == null) Menu.Parent = "Componentes"; else Menu.Parent = NodoMenu.Attributes["position"].Value; if (NodoMenu.Attributes["function"] != null) Menu.Function = NodoMenu.Attributes["function"].Value; this.MenuEntries.Add(Menu); } // Cargo las funciones personalizadas System.Xml.XmlNodeList NodosFunciones = DocumentoCif.GetElementsByTagName("Function"); foreach (System.Xml.XmlNode NodoFuncion in NodosFunciones) { Lfx.Components.FunctionInfo Func = new Lfx.Components.FunctionInfo(this); Func.Nombre = NodoFuncion.Attributes["name"].Value; if (Func.Nombre != null && Func.Nombre.Length > 0 && Func.Nombre != "-") { if (NodoFuncion.Attributes["autorun"] != null && NodoFuncion.Attributes["autorun"].Value == "1") Func.AutoRun = true; this.Funciones.Add(Func); } } } }
public void LoadCif() { // Cargo el archivo CIF using (System.IO.Stream CifXml = this.Assembly.GetManifestResourceStream(this.EspacioNombres + ".cif.xml")) { if (CifXml != null) { // FIXME: puedo cargarlo con un lector de texto using (System.IO.StreamReader Lector = new System.IO.StreamReader(CifXml)) { this.Cif = Lector.ReadToEnd(); Lector.Close(); } } } if (this.Cif == null) { return; } System.Xml.XmlDocument DocumentoCif = new System.Xml.XmlDocument(); DocumentoCif.LoadXml(this.Cif); System.Xml.XmlNodeList ListaComponentes = DocumentoCif.GetElementsByTagName("Component"); //Abro el/los nodo(s) de componentes foreach (System.Xml.XmlNode Componente in ListaComponentes) { System.Xml.XmlNodeList NodosMenu = DocumentoCif.GetElementsByTagName("MenuItem"); foreach (System.Xml.XmlNode NodoMenu in NodosMenu) { if (this.MenuEntries == null) { this.MenuEntries = new List <Lfx.Components.MenuEntry>(); } Lfx.Components.MenuEntry Menu = new Lfx.Components.MenuEntry(); Menu.Name = NodoMenu.Attributes["name"].Value; if (NodoMenu.Attributes["position"] == null) { Menu.Parent = "Componentes"; } else { Menu.Parent = NodoMenu.Attributes["position"].Value; } if (NodoMenu.Attributes["function"] != null) { Menu.Function = NodoMenu.Attributes["function"].Value; } this.MenuEntries.Add(Menu); } // Cargo las funciones personalizadas System.Xml.XmlNodeList NodosFunciones = DocumentoCif.GetElementsByTagName("Function"); foreach (System.Xml.XmlNode NodoFuncion in NodosFunciones) { Lfx.Components.FunctionInfo Func = new Lfx.Components.FunctionInfo(this); Func.Nombre = NodoFuncion.Attributes["name"].Value; if (Func.Nombre != null && Func.Nombre.Length > 0 && Func.Nombre != "-") { if (NodoFuncion.Attributes["autorun"] != null && NodoFuncion.Attributes["autorun"].Value == "1") { Func.AutoRun = true; } this.Funciones.Add(Func); } } } }