protected void PerformAutomaticRecovery()
        {
            ESLog.Info("Performing automatic recovery");
            lock (recoveryLockTarget)
            {
                if (RecoverConnectionDelegate())
                {
                    RecoverConnectionShutdownHandlers();
                    RecoverConnectionBlockedHandlers();
                    RecoverConnectionUnblockedHandlers();

                    RecoverModels();
                    if (m_factory.TopologyRecoveryEnabled)
                    {
                        RecoverEntities();
                        RecoverConsumers();
                    }

                    ESLog.Info("Connection recovery completed");
                    RunRecoveryEventHandlers();
                }
                else
                {
                    ESLog.Warn("Connection delegate was manually closed. Aborted recovery.");
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Handles commands when in the Recovering state.
        /// </summary>
        /// <param name="command"></param>
        private void RecoveryLoopRecoveringHandler(RecoveryCommand command)
        {
            switch (command)
            {
            case RecoveryCommand.BeginAutomaticRecovery:
                ESLog.Info("Received request to BeginAutomaticRecovery, but already in Recovering state.");
                break;

            case RecoveryCommand.PerformAutomaticRecovery:
                if (TryPerformAutomaticRecovery())
                {
                    m_recoveryLoopState = RecoveryConnectionState.Connected;
                }
                else
                {
                    Task.Delay(m_factory.NetworkRecoveryInterval).ContinueWith(t => { m_recoveryLoopCommandQueue.TryAdd(RecoveryCommand.PerformAutomaticRecovery); });
                }

                break;

            default:
                ESLog.Warn($"RecoveryLoop command {command} is out of range.");
                break;
            }
        }
Пример #3
0
        private bool TryRecoverConnectionDelegate()
        {
            try
            {
                var fh = endpoints.SelectOne(m_factory.CreateFrameHandler);
                m_delegate = new Connection(m_factory, false, fh, this.ClientProvidedName);
                return(true);
            }
            catch (Exception e)
            {
                ESLog.Error("Connection recovery exception.", e);
                // Trigger recovery error events
                var handler = m_connectionRecoveryError;
                if (handler != null)
                {
                    var args = new ConnectionRecoveryErrorEventArgs(e);
                    foreach (EventHandler <ConnectionRecoveryErrorEventArgs> h in handler.GetInvocationList())
                    {
                        try
                        {
                            h(this, args);
                        }
                        catch (Exception ex)
                        {
                            var a = new CallbackExceptionEventArgs(ex);
                            a.Detail["context"] = "OnConnectionRecoveryError";
                            m_delegate.OnCallbackException(a);
                        }
                    }
                }
            }

            return(false);
        }
        protected async Task PerformAutomaticRecovery()
        {
            ESLog.Info("Performing automatic recovery");

            await recoverySlimTarget.WaitAsync();

            try
            {
                if (await RecoverConnectionDelegate())
                {
                    RecoverConnectionShutdownHandlers();
                    RecoverConnectionBlockedHandlers();
                    RecoverConnectionUnblockedHandlers();

                    await RecoverModels();

                    if (m_factory.TopologyRecoveryEnabled)
                    {
                        await RecoverEntities();
                        await RecoverConsumers();
                    }

                    ESLog.Info("Connection recovery completed");
                    await RunRecoveryEventHandlers();
                }
                else
                {
                    ESLog.Warn("Connection delegate was manually closed. Aborted recovery.");
                }
            }
            finally
            {
                recoverySlimTarget.Release();
            }
        }
        private void Init(IFrameHandler fh)
        {
            m_delegate = new Connection(m_factory, false,
                                        fh, this.ClientProvidedName);

            AutorecoveringConnection         self             = this;
            EventHandler <ShutdownEventArgs> recoveryListener = (_, args) =>
            {
                lock (recoveryLockTarget)
                {
                    if (ShouldTriggerConnectionRecovery(args))
                    {
                        try
                        {
                            self.BeginAutomaticRecovery();
                        }
                        catch (Exception e)
                        {
                            ESLog.Error("BeginAutomaticRecovery() failed.", e);
                        }
                    }
                }
            };

            lock (m_eventLock)
            {
                ConnectionShutdown += recoveryListener;
                if (!m_recordedShutdownEventHandlers.Contains(recoveryListener))
                {
                    m_recordedShutdownEventHandlers.Add(recoveryListener);
                }
            }
        }
        /// <summary>
        /// Handles commands when in the Recovering state.
        /// </summary>
        /// <param name="command"></param>
        private async Task RecoveryLoopRecoveringHandler(RecoveryCommand command)
        {
            switch (command)
            {
            case RecoveryCommand.BeginAutomaticRecovery:
                ESLog.Info("Received request to BeginAutomaticRecovery, but already in Recovering state.");
                break;

            case RecoveryCommand.PerformAutomaticRecovery:
                if (TryPerformAutomaticRecovery())
                {
                    _recoveryLoopState = RecoveryConnectionState.Connected;
                }
                else
                {
                    await Task.Delay(_factory.NetworkRecoveryInterval);

                    _recoveryLoopCommandQueue.Enqueue(RecoveryCommand.PerformAutomaticRecovery);
                    _semaphore.Release();
                }

                break;

            default:
                ESLog.Warn($"RecoveryLoop command {command} is out of range.");
                break;
            }
        }
 private void Page_Load(object sender, System.EventArgs e)
 {
     // Put user code to initialize the page here
     if (!Page.IsPostBack)
     {
         ESUsuario Empleado = new ESUsuario();
         Empleado.ObtenerUsuario((int)Session["IDUsuario"]);
         intIDEmpleado  = Empleado.intCodStaff;
         strRolAsociado = "0";
         if (ESSeguridad.VerificarAcceso(intIDEmpleado, "ESWFP004A", 0))
         {
             CargarAyuda();
             CargarModulos();
             ibtnBuscarEmpleado.Attributes.Add("OnClick", "javascript: AbrirBusquedaEmpleadoCategoria(document.Form1.txtCodigoEmpleado, document.Form1.txtEmpleado,document.Form1.txtCategoriaOrigen,'', '1', '0','0'" + "); return false;");
             ibtnBuscarDestino.Attributes.Add("OnClick", "javascript: AbrirBusquedaEmpleadoCategoria(document.Form1.txtCodigoEmpleado, document.Form1.txtEmpleado,document.Form1.txtCategoriaD,'', '0', '0'" + "," + strRolAsociado + "); return false;");
             //					btnReversar.Attributes.Add("OnClick","javascript: VerificarSeleccion(document.Form1.dgdWorkflow); return false;");
             btnReversar.Attributes.Add("onclick", "return (VerificarSeleccion());");
             CargarInicial();
         }
         else
         {
             ESError Error = new ESError();
             Error.strTitulo      = "Error general";
             Error.strDescripcion = "Ha ocurrido un error en el sistema. Por favor comuníquese con el administrador del sistema.";
             Error.strDetalle     = "Acceso denegado";
             Session["Error"]     = Error;
             ESLog.Log(intIDEmpleado, Convert.ToString(Session["Host"]), ESLog.TipoLog.Error, ESLog.TipoTransaccion.Desconocida, "ESWFP004A", 10, "", "Acceso denegado");
             Response.Redirect("../Principal/Error.aspx");
         }
     }
 }
        private bool TryRecoverConnectionDelegate()
        {
            try
            {
                IFrameHandler fh = _endpoints.SelectOne(_factory.CreateFrameHandler);
                _delegate = new Connection(_factory, false, fh, ClientProvidedName);
                return(true);
            }
            catch (Exception e)
            {
                ESLog.Error("Connection recovery exception.", e);
                // Trigger recovery error events
                foreach (EventHandler <ConnectionRecoveryErrorEventArgs> h in ConnectionRecoveryError?.GetInvocationList() ?? Array.Empty <Delegate>())
                {
                    try
                    {
                        h(this, new ConnectionRecoveryErrorEventArgs(e));
                    }
                    catch (Exception ex)
                    {
                        var a = new CallbackExceptionEventArgs(ex);
                        a.Detail["context"] = "OnConnectionRecoveryError";
                        _delegate.OnCallbackException(a);
                    }
                }
            }

            return(false);
        }
Пример #9
0
        public void HeartbeatReadTimerCallback(object state)
        {
            lock (_heartBeatReadLock)
            {
                if (m_hasDisposedHeartBeatReadTimer)
                {
                    return;
                }
                bool shouldTerminate = false;
                try
                {
                    if (!m_closed)
                    {
                        if (!m_heartbeatRead.WaitOne(0))
                        {
                            m_missedHeartbeats++;
                        }
                        else
                        {
                            m_missedHeartbeats = 0;
                        }

                        // We check against 8 = 2 * 4 because we need to wait for at
                        // least two complete heartbeat setting intervals before
                        // complaining, and we've set the socket timeout to a quarter
                        // of the heartbeat setting in setHeartbeat above.
                        if (m_missedHeartbeats > 2 * 4)
                        {
                            String description = String.Format("Heartbeat missing with heartbeat == {0} seconds", m_heartbeat);
                            var    eose        = new EndOfStreamException(description);
                            ESLog.Error(description, eose);
                            m_shutdownReport.Add(new ShutdownReportEntry(description, eose));
                            HandleMainLoopException(
                                new ShutdownEventArgs(ShutdownInitiator.Library, 0, "End of stream", eose));
                            shouldTerminate = true;
                        }
                    }

                    if (shouldTerminate)
                    {
                        TerminateMainloop();
                        FinishClose();
                    }
                    else if (_heartbeatReadTimer != null)
                    {
                        _heartbeatReadTimer.Change(Heartbeat * 1000, Timeout.Infinite);
                    }
                }
                catch (ObjectDisposedException)
                {
                    // timer is already disposed,
                    // e.g. due to shutdown
                }
                catch (NullReferenceException)
                {
                    // timer has already been disposed from a different thread after null check
                    // this event should be rare
                }
            }
        }
Пример #10
0
        private void Init(IFrameHandler fh)
        {
            m_delegate = new Connection(m_factory, false,
                                        fh, this.ClientProvidedName);

            m_recoveryThread = new Thread(MainRecoveryLoop)
            {
                IsBackground = true
            };
            m_recoveryThread.Start();

            EventHandler <ShutdownEventArgs> recoveryListener = (_, args) =>
            {
                if (ShouldTriggerConnectionRecovery(args))
                {
                    if (!m_recoveryLoopCommandQueue.TryAdd(RecoveryCommand.BeginAutomaticRecovery))
                    {
                        ESLog.Warn("Failed to notify RecoveryLoop to BeginAutomaticRecovery.");
                    }
                }
            };

            lock (m_eventLock)
            {
                ConnectionShutdown += recoveryListener;
                m_recordedShutdownEventHandlers += recoveryListener;
            }
        }
Пример #11
0
        /// <summary>
        /// This is the main loop for the auto-recovery thread.
        /// </summary>
        private void MainRecoveryLoop()
        {
            try
            {
                while (m_recoveryLoopCommandQueue.TryTake(out var command, -1, m_recoveryCancellationToken.Token))
                {
                    switch (m_recoveryLoopState)
                    {
                    case RecoveryConnectionState.Connected:
                        RecoveryLoopConnectedHandler(command);
                        break;

                    case RecoveryConnectionState.Recovering:
                        RecoveryLoopRecoveringHandler(command);
                        break;

                    default:
                        ESLog.Warn("RecoveryLoop state is out of range.");
                        break;
                    }
                }
            }
            catch (OperationCanceledException)
            {
                // expected when recovery cancellation token is set.
            }
            catch (Exception e)
            {
                ESLog.Error("Main recovery loop threw unexpected exception.", e);
            }
            m_recoveryLoopComplete.SetResult(0);
        }
        /// <summary>
        /// This is the main loop for the auto-recovery thread.
        /// </summary>
        private async Task MainRecoveryLoop()
        {
            try
            {
                while (await _recoveryLoopCommandQueue.Reader.WaitToReadAsync().ConfigureAwait(false))
                {
                    while (_recoveryLoopCommandQueue.Reader.TryRead(out RecoveryCommand command))
                    {
                        switch (_recoveryLoopState)
                        {
                        case RecoveryConnectionState.Connected:
                            RecoveryLoopConnectedHandler(command);
                            break;

                        case RecoveryConnectionState.Recovering:
                            RecoveryLoopRecoveringHandler(command);
                            break;

                        default:
                            ESLog.Warn("RecoveryLoop state is out of range.");
                            break;
                        }
                    }
                }
            }
            catch (OperationCanceledException)
            {
                // expected when recovery cancellation token is set.
            }
            catch (Exception e)
            {
                ESLog.Error("Main recovery loop threw unexpected exception.", e);
            }
        }
Пример #13
0
        public bool DeleteBulk(IEnumerable <T> list)
        {
            try
            {
                string          cmd     = CreateBulkCommand();
                BulkBuilder     builder = new BulkBuilder(serializer);
                StringBuilder   str     = new StringBuilder();
                OperationResult result;
                foreach (var item in list)
                {
                    str.Append(builder.Delete(item.id, _indexInfo.IndexName, _indexInfo.IndexType));
                }
                //最后一组
                if (str.Length > 0)
                {
                    result = Client.Post(cmd, str.ToString());
                }

                return(true);
            }
            catch (Exception ex)
            {
                ESLog.WriteLogException(MethodBase.GetCurrentMethod(), ex);
                return(false);
            }
        }
        /// <summary>
        /// This is the main loop for the auto-recovery thread.
        /// </summary>
        private async Task MainRecoveryLoop()
        {
            try
            {
                while (!_recoveryCancellationToken.IsCancellationRequested)
                {
                    var command = await _recoveryLoopCommandQueue.DequeueAsync(_recoveryCancellationToken.Token).ConfigureAwait(false);

                    switch (_recoveryLoopState)
                    {
                    case RecoveryConnectionState.Connected:
                        RecoveryLoopConnectedHandler(command);
                        break;

                    case RecoveryConnectionState.Recovering:
                        RecoveryLoopRecoveringHandler(command);
                        break;

                    default:
                        ESLog.Warn("RecoveryLoop state is out of range.");
                        break;
                    }
                }
            }
            catch (OperationCanceledException)
            {
                // expected when recovery cancellation token is set.
            }
            catch (Exception e)
            {
                ESLog.Error("Main recovery loop threw unexpected exception.", e);
            }

            _recoveryLoopComplete.SetResult(0);
        }
        /// <summary>
        /// Handles commands when in the Recovering state.
        /// </summary>
        /// <param name="command"></param>
        private void RecoveryLoopRecoveringHandler(RecoveryCommand command)
        {
            switch (command)
            {
            case RecoveryCommand.BeginAutomaticRecovery:
                ESLog.Info("Received request to BeginAutomaticRecovery, but already in Recovering state.");
                break;

            case RecoveryCommand.PerformAutomaticRecovery:
                if (TryPerformAutomaticRecovery())
                {
                    _recoveryLoopState = RecoveryConnectionState.Connected;
                }
                else
                {
                    ScheduleRecoveryRetry();
                }

                break;

            default:
                ESLog.Warn($"RecoveryLoop command {command} is out of range.");
                break;
            }
        }
Пример #16
0
 /// <summary>
 /// Cancels the main recovery loop and will block until the loop finishes, or the timeout
 /// expires, to prevent Close operations overlapping with recovery operations.
 /// </summary>
 private void StopRecoveryLoop()
 {
     m_recoveryCancellationToken.Cancel();
     if (!m_recoveryLoopComplete.Task.Wait(m_factory.RequestedConnectionTimeout))
     {
         ESLog.Warn("Timeout while trying to stop background AutorecoveringConnection recovery loop.");
     }
 }
        /// <summary>
        /// Cancels the main recovery loop and will block until the loop finishes, or the timeout
        /// expires, to prevent Close operations overlapping with recovery operations.
        /// </summary>
        private void StopRecoveryLoop()
        {
            _recoveryLoopCommandQueue.Writer.Complete();
            Task timeout = Task.Delay(_factory.RequestedConnectionTimeout);

            if (Task.WhenAny(_recoveryTask, timeout).Result == timeout)
            {
                ESLog.Warn("Timeout while trying to stop background AutorecoveringConnection recovery loop.");
            }
        }
Пример #18
0
        protected void Application_Error(Object sender, EventArgs e)
        {
            ESError Error = new ESError();

            Error.strTitulo      = "Error";
            Error.strDescripcion = "Ha ocurrido un error en el sistema.";
            Error.strDetalle     = Server.GetLastError().ToString();

            Session["Error"] = Error;

            ESLog.Log(Convert.ToInt32(Session["IDUsuario"]), Convert.ToString(Session["Host"]), ESLog.TipoLog.Error, ESLog.TipoTransaccion.Desconocida, "", 8, "", Server.GetLastError().ToString());
        }
Пример #19
0
 public string DeleteIndex(string indexName)
 {
     try
     {
         var cmd    = "/" + indexName;
         var result = Client.Delete(cmd);
         return(result);
     }
     catch (Exception ex) {
         ESLog.WriteLogException(MethodBase.GetCurrentMethod(), ex);
         return(ex.Message);
     }
 }
Пример #20
0
        protected void btnAceptar_Click(object sender, System.EventArgs e)
        {
            ESUsuario Usuario = new ESUsuario();

            if (intEmpleadoUsuario == 0)
            {
                Usuario.VerificarUsuario(Convert.ToInt32(txtCodigo.Text), txtUsuario.Text);

                if (Convert.ToInt32(txtCodigo.Text) == Usuario.intCodStaff)
                {
                    lblError.Text = ESMensajes.ObtenerMensaje(416);
                    return;
                }

                if (txtUsuario.Text == Usuario.strUsuario)
                {
                    lblError.Text = ESMensajes.ObtenerMensaje(417);;
                    return;
                }
            }
            else
            {
                Usuario.intIDUsuario = 1;
            }

            Usuario.intCodStaff        = Convert.ToInt32(txtCodigo.Text);
            Usuario.strUsuario         = txtUsuario.Text;
            Usuario.strPassword        = ESSeguridad.Encriptar(txtPassword.Text);
            Usuario.blnActivo          = chkActivo.Checked;
            Usuario.blnCambiarPassword = chkCambiar.Checked;
            Usuario.strComentarios     = txtComentarios.Text;

            if (Usuario.Guardar() > 0)
            {
                if (intEmpleadoUsuario == 0)
                {
                    ESLog.Log(intEmpleado, Session["Host"].ToString(), ESLog.TipoLog.Informativo, ESLog.TipoTransaccion.Insertar, "ESSEP002A", 8, Usuario.intCodStaff.ToString(), "Usuario creado: " + Usuario.strUsuario);
                }
                else
                {
                    ESLog.Log(intEmpleado, Session["Host"].ToString(), ESLog.TipoLog.Informativo, ESLog.TipoTransaccion.Actualizar, "ESSEP002A", 8, intEmpleadoUsuario.ToString(), "Usuario actualizado: " + intEmpleadoUsuario.ToString());
                }

                Response.Redirect("ESSEP001A.aspx");
            }
            else
            {
                lblError.Text = ESMensajes.ObtenerMensaje(418);;
                return;
            }
        }
Пример #21
0
 public BaseQueryEntity <T> QueryBayConditions(string query)
 {
     try
     {
         string          cmd    = CreateSearchCommand();                        //构造查询命令
         OperationResult result = Client.Post(cmd, query);                      //Post query参数查询
         var             data   = serializer.ToSearchResult <T>(result.Result); //返回结果转换
         return(GetResults(data));
     }
     catch (Exception ex)
     {
         ESLog.WriteLogException(MethodBase.GetCurrentMethod(), "查询条件:" + query);
         ESLog.WriteLogException(MethodBase.GetCurrentMethod(), ex);
         return(new BaseQueryEntity <T>());
     }
 }
Пример #22
0
        /*
         * 功能:将表date字段设置为string类型,不被解析,防止其他类型parse出现异常,例如2015-02-01,'some name' 前者能转换为日期,后者不能(都为字符串)
         * 调用:只能在没有创建index的时候调用,否则会出现 index_already_exists_exception
         * 异常: {"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"already exists","index":"ms_mobile"}],
         *      "type":"index_already_exists_exception","reason":"already exists","index":"ms_mobile"},"status":400}
         *      无法连接到远程服务器
         * 正确返回结果:{"acknowledged":true}
         */
        public bool SetDateDetection(bool dateDetection = true)
        {
            var cmd   = "/" + _indexInfo.IndexName;
            var param = "{\"mappings\":{\"" + _indexInfo.IndexType + "\":{\"date_detection\":" + dateDetection.ToString().ToLowerInvariant() + "}}}";

            try
            {
                OperationResult result = Client.Put(cmd, param);
                return(true);
            }
            catch (Exception ex)
            {
                ESLog.WriteLogException(MethodBase.GetCurrentMethod(), ex);
                return(false);
            }
        }
        /// <summary>
        /// This is the main loop for the auto-recovery thread.
        /// </summary>
        private async Task MainRecoveryLoop()
        {
            try
            {
                while (!_recoveryCancellationToken.IsCancellationRequested)
                {
                    try
                    {
                        await _semaphore.WaitAsync(_recoveryCancellationToken.Token).ConfigureAwait(false);
                    }
                    catch (TaskCanceledException)
                    {
                        // Swallowing the task cancellation in case we are stopping work.
                    }

                    if (!_recoveryCancellationToken.IsCancellationRequested && _recoveryLoopCommandQueue.TryDequeue(out RecoveryCommand command))
                    {
                        switch (_recoveryLoopState)
                        {
                        case RecoveryConnectionState.Connected:
                            await RecoveryLoopConnectedHandler(command).ConfigureAwait(false);

                            break;

                        case RecoveryConnectionState.Recovering:
                            await RecoveryLoopRecoveringHandler(command).ConfigureAwait(false);

                            break;

                        default:
                            ESLog.Warn("RecoveryLoop state is out of range.");
                            break;
                        }
                    }
                }
            }
            catch (OperationCanceledException)
            {
                // expected when recovery cancellation token is set.
            }
            catch (Exception e)
            {
                ESLog.Error("Main recovery loop threw unexpected exception.", e);
            }

            _recoveryLoopComplete.SetResult(0);
        }
Пример #24
0
        /// <summary>
        /// Handles commands when in the Connected state.
        /// </summary>
        /// <param name="command"></param>
        private void RecoveryLoopConnectedHandler(RecoveryCommand command)
        {
            switch (command)
            {
            case RecoveryCommand.PerformAutomaticRecovery:
                ESLog.Warn("Not expecting PerformAutomaticRecovery commands while in the connected state.");
                break;

            case RecoveryCommand.BeginAutomaticRecovery:
                m_recoveryLoopState = RecoveryConnectionState.Recovering;
                Task.Delay(m_factory.NetworkRecoveryInterval).ContinueWith(t => { m_recoveryLoopCommandQueue.TryAdd(RecoveryCommand.PerformAutomaticRecovery); });
                break;

            default:
                ESLog.Warn($"RecoveryLoop command {command} is out of range.");
                break;
            }
        }
        /// <summary>
        /// Handles commands when in the Connected state.
        /// </summary>
        /// <param name="command"></param>
        private void RecoveryLoopConnectedHandler(RecoveryCommand command)
        {
            switch (command)
            {
            case RecoveryCommand.PerformAutomaticRecovery:
                ESLog.Warn("Not expecting PerformAutomaticRecovery commands while in the connected state.");
                break;

            case RecoveryCommand.BeginAutomaticRecovery:
                _recoveryLoopState = RecoveryConnectionState.Recovering;
                ScheduleRecoveryRetry();
                break;

            default:
                ESLog.Warn($"RecoveryLoop command {command} is out of range.");
                break;
            }
        }
Пример #26
0
 /// <summary>
 /// 根据单一条件查询删除
 /// </summary>
 /// <param name="query">例如(字符串) {"artid":1000000000}</param>
 /// <returns></returns>
 public bool DeleteByQuery(string query)
 {
     try
     {
         var cmd       = CreateDeleteByQueryCommand();
         var fullQuery = "{ \"query\": { \"term\": " + query + " }}";
         var result    = QueryBayConditions(fullQuery);
         if (result.hits > 0)
         {
             DeleteBulk(result.list);
         }
         return(true);
     }
     catch (Exception ex)
     {
         ESLog.WriteLogException(MethodBase.GetCurrentMethod(), ex);
         return(false);
     }
 }
        protected bool RecoverConnectionDelegate()
        {
            while (!ManuallyClosed)
            {
                try
                {
                    var fh = endpoints.SelectOne(m_factory.CreateFrameHandler);
                    m_delegate = new Connection(m_factory, false, fh, this.ClientProvidedName);
                    return(true);
                }
                catch (Exception e)
                {
                    ESLog.Error("Connection recovery exception.", e);
                    // Trigger recovery error events
                    var handler = m_connectionRecoveryError;
                    if (handler != null)
                    {
                        var args = new ConnectionRecoveryErrorEventArgs(e);
                        foreach (EventHandler <ConnectionRecoveryErrorEventArgs> h in handler.GetInvocationList())
                        {
                            try
                            {
                                h(this, args);
                            }
                            catch (Exception ex)
                            {
                                var a = new CallbackExceptionEventArgs(ex);
                                a.Detail["context"] = "OnConnectionRecoveryError";
                                m_delegate.OnCallbackException(a);
                            }
                        }
                    }

#if NETFX_CORE
                    System.Threading.Tasks.Task.Delay(m_factory.NetworkRecoveryInterval).Wait();
#else
                    Thread.Sleep(m_factory.NetworkRecoveryInterval);
#endif
                }
            }

            return(false);
        }
        protected async Task <bool> RecoverConnectionDelegate()
        {
            while (!ManuallyClosed)
            {
                try
                {
                    var fh = await endpoints.SelectOne(m_factory.CreateFrameHandler);

                    m_delegate = new Connection(m_factory, false, fh, this.ClientProvidedName);
                    await m_delegate.Open();

                    return(true);
                }
                catch (Exception e)
                {
                    ESLog.Error("Connection recovery exception.", e);
                    // Trigger recovery error events
                    var handler = m_connectionRecoveryError;
                    if (handler != null)
                    {
                        var args = new ConnectionRecoveryErrorEventArgs(e);
                        foreach (AsyncEventHandler <ConnectionRecoveryErrorEventArgs> h in handler.GetInvocationList())
                        {
                            try
                            {
                                await h(this, args);
                            }
                            catch (Exception ex)
                            {
                                var a = new CallbackExceptionEventArgs(ex);
                                a.Detail["context"] = "OnConnectionRecoveryError";
                                await m_delegate.OnCallbackException(a);
                            }
                        }
                    }

                    await Task.Delay(m_factory.NetworkRecoveryInterval);
                }
            }

            return(false);
        }
Пример #29
0
        /// <summary>
        /// Handles commands when in the Connected state.
        /// </summary>
        /// <param name="command"></param>
        private async Task RecoveryLoopConnectedHandler(RecoveryCommand command)
        {
            switch (command)
            {
            case RecoveryCommand.PerformAutomaticRecovery:
                ESLog.Warn("Not expecting PerformAutomaticRecovery commands while in the connected state.");
                break;

            case RecoveryCommand.BeginAutomaticRecovery:
                _recoveryLoopState = RecoveryConnectionState.Recovering;
                await Task.Delay(_factory.NetworkRecoveryInterval).ConfigureAwait(false);

                _recoveryLoopCommandQueue.TryAdd(RecoveryCommand.PerformAutomaticRecovery);
                break;

            default:
                ESLog.Warn($"RecoveryLoop command {command} is out of range.");
                break;
            }
        }
Пример #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ESUsuario Empleado = new ESUsuario();
                Empleado.ObtenerUsuario((int)Session["IDUsuario"]);
                intIDEmpleado = Empleado.intCodStaff;
                if (ESSeguridad.VerificarAcceso(intIDEmpleado, "ESWFP002A", 0))
                {
                    if (!(ESSeguridad.VerificarAcceso(intIDEmpleado, "ESWFP002A", 1)))
                    {
                        btnReversar.Visible = false;
                        dgdWorkflow.Columns[10].Visible = false;
                        lblTitulo.Text = "Workflow > Consulta de aprobaciones pendientes";
                    }
                    else
                    {
                        btnReversar.Visible = true;
                        dgdWorkflow.Columns[10].Visible = true;
                        lblTitulo.Text = "Workflow > Reverso de aprobación";
                    }
                    CargarAyuda();
                    CargarModulos();
                    CargarInicial();

                }
                else
                {
                    ESError Error = new ESError();
                    Error.strTitulo = "Error general";
                    Error.strDescripcion = "Ha ocurrido un error en el sistema. Por favor comuníquese con el administrador del sistema.";
                    Error.strDetalle = "Acceso denegado";
                    Session["Error"] = Error;
                    ESLog.Log(intIDEmpleado, Convert.ToString(Session["Host"]), ESLog.TipoLog.Error, ESLog.TipoTransaccion.Desconocida, "ESWFP002A", 10, "", "Acceso denegado");
                    Response.Redirect("../Principal/Error.aspx");
                }
            }
        }