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); }
/// <summary> /// Inicia la interfaz gráfica del programa. /// </summary> private static Lfx.Types.OperationResult IniciarGui() { int Configurado = Lfx.Workspace.Master.CurrentConfig.ReadGlobalSetting<int>("Sistema.Configurado", 0); if ((Configurado == 0 && Lbl.Sys.Config.Empresa.ClaveTributaria == null) || string.IsNullOrEmpty(Lbl.Sys.Config.Empresa.Nombre)) { Config.Preferencias FormConfig = new Config.Preferencias(); FormConfig.PrimeraVez = true; if (FormConfig.ShowDialog() != DialogResult.OK) Ejecutor.Exec("QUIT"); } System.DateTime FechaServidor = System.Convert.ToDateTime(Lfx.Workspace.Master.MasterConnection.FirstRowFromSelect("SELECT NOW()")[0]); System.TimeSpan Diferencia = FechaServidor - System.DateTime.Now; if (Math.Abs(Diferencia.TotalMinutes) > 10) { string DiferenciaExplicada = ""; if (Math.Abs(Diferencia.TotalDays) >= 2) DiferenciaExplicada = Math.Ceiling(Math.Abs(Diferencia.TotalDays)).ToString() + " días"; else if (Math.Abs(Diferencia.TotalHours) >= 2) DiferenciaExplicada = Math.Ceiling(Math.Abs(Diferencia.TotalHours)).ToString() + " horas"; else DiferenciaExplicada = Math.Ceiling(Math.Abs(Diferencia.TotalMinutes)).ToString() + " minutos"; Lfx.Workspace.Master.RunTime.Toast("Existe una diferencia de " + DiferenciaExplicada + " entre el reloj del servidor SQL y el reloj de este equipo. Es necesario que revise y ajuste el reloj de ambos equipos a la brevedad.", "Error de fecha y hora"); } // Si el administrador tiene la contraseña predeterminada y aquí entro siempre como administrador // o todavía no entré nunca, ingreso directamente sin pedir contraseña. int UltimoUsuario = Lfx.Workspace.Master.CurrentConfig.ReadGlobalSetting<int>("Sistema.Ingreso.UltimoUsuario", 1); if(UltimoUsuario == 1) { Lbl.Personas.Usuario Usu = new Lbl.Personas.Usuario(Lfx.Workspace.Master.MasterConnection, 1); if (Usu.ContrasenaValida("admin")) Lbl.Sys.Config.Actual.UsuarioConectado = new Lbl.Sys.Configuracion.UsuarioConectado(Usu); } if (Lbl.Sys.Config.Actual.UsuarioConectado.Id == 0) { using (Lazaro.WinMain.Misc.Ingreso FormIngreso = new Lazaro.WinMain.Misc.Ingreso()) { FormIngreso.Connection = Lfx.Workspace.Master.MasterConnection; FormIngreso.ShowDialog(); } } if (Lbl.Sys.Config.Actual.UsuarioConectado.Id > 0) { if (Lfx.Workspace.Master.SlowLink == false && Lfx.Workspace.Master.CurrentConfig.ReadGlobalSetting<string>("Sistema.Backup.Tipo", "0") == "2") { string FechaActual = System.DateTime.Now.ToString("yyyy-MM-dd"); string FechaBackup = Lfx.Workspace.Master.CurrentConfig.ReadGlobalSetting<string>("Sistema.Backup.Ultimo", ""); if (FechaActual != FechaBackup) { int Articulos = Lfx.Workspace.Master.MasterConnection.FieldInt("SELECT COUNT(id_articulo) FROM articulos"); if (Articulos > 0) { //Hago un backup automático, una vez por día, siempre que haya al menos 1 artículo en la BD //Esto es para evitar hacer backup de una BD vacía Ejecutor.Exec("BACKUP NOW"); Lfx.Workspace.Master.CurrentConfig.WriteGlobalSetting("Sistema.Backup.Ultimo", FechaActual); } } } // Mostrar qué hay de nuevo string FechaWhatsnew = Lfx.Workspace.Master.CurrentConfig.ReadGlobalSetting<string>("Usuario." + Lbl.Sys.Config.Actual.UsuarioConectado.Id.ToString() + ".Whatsnew.Ultimo", "firsttime"); if (FechaWhatsnew == "firsttime") { // Primera vez que entra. No muestro qué hay de nuevo (TODO: pero podría darle una bienvenida) Lfx.Workspace.Master.CurrentConfig.WriteGlobalSetting("Usuario." + Lbl.Sys.Config.Actual.UsuarioConectado.Id.ToString() + ".Whatsnew.Ultimo", System.DateTime.Now.ToString("yyyy-MM-dd")); } else { // Veo si hay novedades para mostrar // string FechaWhatsnewOriginal = FechaWhatsnew; System.IO.StreamReader Whatsnew = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Lazaro.whatsnew.txt")); System.Text.StringBuilder Mostrar = null; bool Mostrando = false; while (Whatsnew.EndOfStream == false) { string Linea = Whatsnew.ReadLine(); if (Linea.Length > 4 && Linea.Substring(0, 4) == "*** ") { string FechaLinea = Linea.Substring(4, Linea.Length - 4); if (string.Compare(FechaLinea, FechaWhatsnew) > 0) { FechaWhatsnew = FechaLinea; Linea = Lfx.Types.Parsing.ParseDate(FechaLinea).Value.ToString(Lfx.Types.Formatting.DateTime.LongDatePattern) + ":"; Mostrando = true; } } if (Mostrando) { if (Mostrar == null) { Mostrar = new System.Text.StringBuilder(); Mostrar.AppendLine("Por favor tómese un momento para leer sobre las novedades incorporadas recientemente en Lázaro:"); Mostrar.AppendLine(""); } Mostrar.AppendLine(Linea.Replace("* ", "• ")); } } Whatsnew.BaseStream.Close(); Whatsnew.Close(); if (Mostrar != null && Mostrar.Length > 0) { Lfx.Workspace.Master.RunTime.Toast(Mostrar.ToString(), "Novedades"); Lfx.Workspace.Master.CurrentConfig.WriteGlobalSetting("Usuario." + Lbl.Sys.Config.Actual.UsuarioConectado.Id.ToString(), "Whatsnew.Ultimo", FechaWhatsnew); } } // Mostrar el formulario Lfx.Workspace.Master.MainForm = new Principal.Inicio(); Aplicacion.FormularioPrincipal.Show(); if (FechaWhatsnew == "firsttime") { Lui.Forms.YesNoDialog Pregunta = new Lui.Forms.YesNoDialog("¡Hola! ¿Le gustaría ver una página sencilla con un poco de información sobre cómo utilizar Lázaro?", "Primeros pasos"); Pregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo; if (Pregunta.ShowDialog() == DialogResult.OK) Help.ShowHelp(Aplicacion.FormularioPrincipal, "http://www.lazarogestion.com/?q=node/44"); } else { string RunTimeName = Lfx.Environment.SystemInformation.RuntimeName; // Verifico la presencia de .NET Framework 3.5 if (Lfx.Environment.SystemInformation.RunTime == Lfx.Environment.SystemInformation.RunTimes.DotNet && RunTimeName.IndexOf("3.5") < 0) { Lui.Forms.YesNoDialog Pregunta = new Lui.Forms.YesNoDialog("Es necesario instalar un componente para el correcto funcionamiento de Lázaro. El componente es Microsoft .NET Framework versión 3.5. ¿Desea ir a la página de descarga para instalarlo ahora?", "Advertencia"); Pregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo; if (Pregunta.ShowDialog() == DialogResult.OK) Help.ShowHelp(Aplicacion.FormularioPrincipal, "http://download.microsoft.com/download/5/3/4/5347CEDC-6A83-49F5-9347-BCD58A9AAE25/DotNetFx35ClientSetup.exe"); } } Application.Run(Aplicacion.FormularioPrincipal); } return new Lfx.Types.SuccessOperationResult(); }
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; }
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 "LISTAR_2": case "LIST_2": return(ExecListar2(comando)); case "IMPRIMIR": return(ExecImprimir(comando)); case "INSTANCIAR": return(ExecInstanciar(comando)); 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": var ConexionFiltro = Lfx.Workspace.Master.GetNewConnection("Importar datos") as Lfx.Data.Connection; 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; } 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": try { if (Lfx.Environment.SystemInformation.DesignMode == true) { System.Diagnostics.Process[] tempProc = System.Diagnostics.Process.GetProcessesByName("ServidorFiscal.exe"); if (tempProc.Length == 0) { tempProc = System.Diagnostics.Process.GetProcessesByName("ServidorFiscal"); if (tempProc.Length == 0) { Lfx.Environment.Shell.Execute(@"C:\Users\Leona\Source\Workspaces\Excelencia\Excelencia-Gestion\Sistema\bin\Debug\Components\" + "Fiscal.exe", null, System.Diagnostics.ProcessWindowStyle.Normal, false); } } } else { System.Diagnostics.Process[] tempProc = System.Diagnostics.Process.GetProcessesByName("ServidorFiscal.exe"); foreach (System.Diagnostics.Process pro in tempProc) { pro.CloseMainWindow(); pro.WaitForExit(); } foreach (System.Diagnostics.Process pro in tempProc) { try { pro.Kill(); pro.WaitForExit(); } catch { //Nada. } } tempProc = System.Diagnostics.Process.GetProcessesByName("ServidorFiscal"); if (tempProc.Length == 0) { Lfx.Environment.Shell.Execute(Lfx.Environment.Folders.ApplicationFolder + @"\Components\ServidorFiscal.exe", null, System.Diagnostics.ProcessWindowStyle.Normal, false); } } } catch { MessageBox.Show("No se inicio el servidor fiscal.", "¡Atención!"); } 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 "CHAT": //Mensajeria.Chat.Inicio chat = new Mensajeria.Chat.Inicio(); //Mensajeria.Chat.ChatControl cControl = chat.IniciarChat(Lbl.Sys.Config.Actual.UsuarioConectado.Persona, estacion); //chat.Show(); 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 { IComponentInfo Componente = Lfx.Components.Manager.ComponentesCargados[NombreComponente]; object DoResult = Componente.ComponentInstance.Do(NombreFuncion, null); if (DoResult is System.Windows.Forms.Form) { var FormResult = DoResult as System.Windows.Forms.Form; //if (Funcion.Instancia.FunctionType == Lfx.Components.FunctionTypes.MdiChildren) FormResult.MdiParent = Aplicacion.Flotante ? null : Aplicacion.FormularioPrincipal; FormResult.Show(); } else if (DoResult is Lfx.Types.OperationResult) { Lfx.Types.OperationResult OpeResult = DoResult 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.FailureOperationResult("No existe el comando " + comando)); } } return(null); }