Beispiel #1
0
                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;
                }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }