예제 #1
0
        /// <summary>
        /// Implementa el Método de la Interfaz.
        /// </summary>
        public virtual DialogResult mostrarMensaje(string mensaje, ENivelMensaje nivel, string extra)
        {
            MessageBoxButtons mb = MessageBoxButtons.OK;
            MessageBoxIcon mi = MessageBoxIcon.Information;

            try {
                if (nivel == ENivelMensaje.ERROR || nivel == ENivelMensaje.FATAL)
                    mi = MessageBoxIcon.Error;

                if (nivel == ENivelMensaje.PREGUNTA) {
                    mb = MessageBoxButtons.YesNo;
                    mi = MessageBoxIcon.Question;
                }

                string miextra = string.Empty;
                if (extra != null) {
                    int pos = extra.LastIndexOf("***");
                    miextra = ((pos > 0) ? extra.Substring(0, pos).Replace("***", string.Empty) : extra);
                }

                string msj = string.Format(
                    "{0}\r\n{1}",
                    Mensaje.TextoMensaje(mensaje).Replace("***", string.Empty) +
                    ((nivel == ENivelMensaje.FATAL)
                         ? "\r\nDebería terminar la operación y salir del Sistema."
                         : string.Empty),
                    miextra);
                DialogResult res =
                    MessageBox.Show(msj, string.Format("{0}", Mensaje.TextoMensaje("TITULO-SHOW")), mb, mi);

                return res;
            } catch (Exception e) {
                throw new VistaErrorException("MENSAJE-NOK", e.ToString());
            }
        }
예제 #2
0
        /// <summary>
        /// Implementa el Método de la Interfaz.
        /// </summary>
        protected virtual void iniciarSistemaConUI(
            ENivelMensaje nivelEjecucion,
            IVistaCuadroInicio wininicio,
            IVistaVentanaPpal winppal,
            IControladorLogging log,
            IControladorSeguridad security)
        {
            try {
                // Inicializa los componentes internos necesarios
                _nivelEjecucion = nivelEjecucion;
                AppPath = Application.StartupPath;

                // Inicializa los parametros del mismo.
                iniciarParametros();

                // Establece componentes usados en la ejecución del sistema
                _log = log ?? new LogSistema(nivelEjecucion);
                _seguridad = security ?? new SecureService();

                // Inicia las interfaces gráficas
                _wininicio = wininicio ?? new WinInicio(this);
                _vista = winppal ?? new WinPrincipal(this);

                // Arranca la ventana de inicio que se encarga de
                // realizar el inicio efectivo de este sistema.
                _wininicio.abrir();
                _wininicio.iniciarSistema();

                // Inicia la vista (ventana) principal del sistema.
                iniciarUi();
            } catch (Exception e) {
                MessageBox.Show(string.Format("ERROR FATAL DEL SISTEMA!\r\n{0}\r\n{1}",
                        Mensaje.TextoMensaje("APP-NOINIT-ERROR"),
                        e),
                    Mensaje.TextoMensaje("TITULO-SHOW"),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Stop);
                cerrarSistema();
            }
        }
예제 #3
0
        /// <summary>
        /// Inicia el sistema sin interfaz gráfica.
        /// </summary>
        protected virtual void iniciarSistemaSinUI(
            ENivelMensaje nivelEjecucion,
            IControladorLogging log,
            IControladorSeguridad security)
        {
            // Inicializa los componentes internos necesarios
                _nivelEjecucion = nivelEjecucion;
                AppPath = Application.StartupPath;

                // Inicializa los parametros del mismo.
                iniciarParametros();

                // Establece componentes usados en la ejecución del sistema
                _log = log ?? new LogSistema(nivelEjecucion);
                _seguridad = security ?? new SecureService();

                // Luego inicializa los servicios del sistema
                iniciarLog();
                iniciarPersistencia();
        }
예제 #4
0
        /// <summary>
        /// Implementa el Método de la Interfaz.
        /// </summary>
        public virtual DialogResult mostrar(string mensaje, ENivelMensaje nivel, string extra, bool logging)
        {
            try {
                DialogResult res = _vista.mostrarMensaje(mensaje, nivel, extra);

                if (logging)
                    logear(mensaje, nivel, ". " + (extra ?? "") + " [Dialogo.Show=" + res + "]");

                return res;
            } catch (Exception e) {
                throw new FatalErrorException("MENSAJE-NOK", e.ToString());
            }
        }
예제 #5
0
 /// <summary>
 /// Implementa el Método de la Interfaz.
 /// </summary>
 public void logear(string mensaje, ENivelMensaje nivel, string extra)
 {
     if (_log != null)
         _log.logear(mensaje, nivel, extra);
 }
예제 #6
0
 /// <summary>
 /// Implementa el Método de la Interfaz.
 /// Inicia el sistema de acuerdo al tipo de llamada entrante, en donde
 /// en principio puede ejecutarse el sistema en modo 'BATCH': sin UI y
 /// finalizando al terminar la ejecucion de los procesos batch; ó, en 
 /// cualquier otro modo, con UI y dejando 'fluir' la aplicación.
 /// </summary>
 public virtual void iniciarSistema(
     ENivelMensaje nivelEjecucion,
     IVistaCuadroInicio wininicio,
     IVistaVentanaPpal winppal,
     IControladorLogging log,
     IControladorSeguridad security)
 {
     if (nivelEjecucion == ENivelMensaje.BATCH)
         try {
             iniciarSistemaSinUI(nivelEjecucion, log, security);
             ejecutarProcesosBatch();
         } catch (Exception e) {
             logear("APP-NOINIT-ERROR", ENivelMensaje.FATAL, e.ToString());
         } finally {
             cerrarSistema();
         }
     else
         try {
             iniciarSistemaConUI(nivelEjecucion, null, null, null, null);
         } catch (Exception e) {
             mostrar("APP-NOINIT-ERROR", ENivelMensaje.FATAL, e.ToString(), true);
             cerrarSistema();
         }
 }
예제 #7
0
 /// <summary>
 /// Constructor de la clase que acepta el nivel de ejecución de 
 /// la aplicación para utilizarlo como un corte y restringir los 
 /// mensajes a logear. El nivel de ejecución debe ser una cadena 
 /// que coincida con un valor de la enum ENivelMensaje. También 
 /// se setea aquí el flag de activo a falso.
 /// </summary>
 /// <param name="nivel">
 /// El nivel de ejecución deseado para el sistema (que se utiliza 
 /// al iniciar el subsistema de logging y permite filtrar mensajes 
 /// a logear).
 /// </param> 
 public LogSistema(ENivelMensaje nivel)
 {
     Activo = false;
     NivelMensaje = nivel;
 }
예제 #8
0
        /// <summary>
        /// Implementa el Método de la Interfaz.
        /// </summary>
        public void logear(string mensaje, ENivelMensaje nivel, string extra)
        {
            // Solo logea si esta activo y nivel supera el corte
            if (Activo & (nivel >= NivelMensaje))
                try {
                    string msj = "["
                        + DateTime.Now + "] => "
                        + nivel.ToString().ToUpper()
                        + ": " + Mensaje.TextoMensaje(mensaje).Replace(Mensaje.TERMINADOR, string.Empty);

                    msj = (extra == null)
                            ? msj
                            : msj + ": " + extra.Replace(Mensaje.TERMINADOR, string.Empty);

                    _archivo.WriteLine(msj);
                    _archivo.Flush();
                } catch (Exception ioe) {
                    throw new LogErrorException("NOLOG", ioe.ToString());
                }
        }