Пример #1
0
        public MMonitor(bool Local, string hosts)
        {
            this.Local = Local;
            try
            {
                if (this.Local == false)
                {
                    var httpBinding = new BasicHttpBinding()
                    {
                        SendTimeout            = TimeSpan.Parse("0:59:00"),
                        MaxBufferSize          = Int32.MaxValue,
                        MaxReceivedMessageSize = Int32.MaxValue
                    };


                    EndPointHost   = new EndpointAddress(hosts);
                    channelFactory = new ChannelFactory <Interfaces.IModelos>(httpBinding, EndPointHost);
                    Server         = channelFactory.CreateChannel();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #2
0
        /// <summary>
        /// Ejecuta los procesos de la cola en modo remoto
        /// </summary>
        /// <param name="db">Instancia de la Base de Datos</param>
        /// <param name="mod_pozo">Modelo del Pozo</param>
        /// <param name="server">Interface del servidor</param>
        /// <param name="MError">Tipo de mensaje al desplegar los errores</param>
        /// <returns></returns>
        private static bool ExecRemote(Entities_ModeloCI db, VW_MOD_POZO mod_pozo, Interfaces.IModelos server, Modo MError)
        {
            try
            {
                bool result = false;
                switch (mod_pozo.FUNCION)
                {
                case 1:
                    result = server.Sensibilidad_BN(mod_pozo.IDMODPOZO);



                    break;

                case 2:
                    result = server.Condicion(mod_pozo.IDMODPOZO, null);
                    break;

                default:
                    result = server.Execute(mod_pozo.IDMODPOZO, null);


                    break;
                }

                if (MError == Modo.console)
                {
                    WriteLineText(mod_pozo.POZO + ": Modelo ejecutado correctamente", "success");
                }
                return(true);
            }
            catch (Exception ex)
            {
                WriteEventLogEntry(System.Diagnostics.EventLogEntryType.Error, 22, mod_pozo.POZO + ": " + ex.Message, MError);

                return(false);
            }
        }
Пример #3
0
        protected override void OnStart(string[] args)
        {
            // TODO: agregar código aquí para iniciar el servicio.



            try
            {
                MTimer = new System.Timers.Timer(60000)
                {
                    AutoReset = true, Enabled = true
                };
                CTimer = new System.Timers.Timer(500000)
                {
                    AutoReset = true, Enabled = true
                };
                //MonitorCore.Libraries.LibConfiguration LibConfiguration = new MonitorCore.Libraries.LibConfiguration();
                if (args != null)
                {
                    if (args.Count() == 1)
                    {
                        ConfigXml.Refresh(false, args[0]);
                    }
                    //    if (args.Count() == 4)
                    //    {
                    //        LibConfiguration.Refresh(true, args[0], args[1], args[2], args[3]);


                    //    }
                    ConfigXml.Save();
                }

                var httpBinding = new BasicHttpBinding()
                {
                    SendTimeout            = TimeSpan.Parse("0:59:00"),
                    MaxBufferSize          = Int32.MaxValue,
                    MaxReceivedMessageSize = Int32.MaxValue
                };


                EndPointHost   = new EndpointAddress(ConfigXml.Host);
                channelFactory = new ChannelFactory <Interfaces.IModelos>(httpBinding, EndPointHost);
                Server         = channelFactory.CreateChannel();
                //MMonitor LibMonitor = new MMonitor();// new MMonitor(LibConfiguration.Local, LibConfiguration.Host);
                //MMonitor = new MMonitor();
                //MMonitor.ModeMessage = MMonitor.Modo.service;

                //var processes = Process.GetProcesses();
                //LProcess = Process.GetProcessesByName(NameProcess);

                //if (LProcess.Count() == 0)
                //{
                //    Process.Start(Path + NameProcess);
                //}

                MTimer.Elapsed += Monitor;
                // CTimer.Elapsed += LibMonitor.RequestConds;

                MTimer.Start();
                // CTimer.Start();

                // MMonitor.WriteEventLogEntry(System.Diagnostics.EventLogEntryType.Warning, 0, $"Iniciando monitor con configuracion local: {LibConfiguration.Local.ToString()} y host: {LibConfiguration.Host}", MMonitor.Modo.service);
            }
            catch
            {
                throw;
                //MMonitor.WriteEventLogEntry(System.Diagnostics.EventLogEntryType.Error, 0, ex.Message, MMonitor.Modo.service);
            }
        }