Пример #1
0
        /// <summary>
        /// Прочита ако има отговори
        /// Затваря канала за връзка с ЕИСПП
        /// </summary>
        /// <returns></returns>
        protected override async Task CloseChanel()
        {
            try
            {
                var messages = await Receive();

                eisppReplies.AddRange(messages);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Error receiving messages!");
            };
            try
            {
                await eisppClient.CloseAsync();

                eisppClient = null;
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Error closing channel!");
            }

            await ProcessReplies();
        }
Пример #2
0
        /// <summary>
        /// Инициализира канала за връзка ЕИСПП
        /// </summary>
        /// <returns></returns>
        protected override async Task <bool> InitChanel()
        {
            bool result = false;

            try
            {
                eisppReplies = new List <string>();
                eisppClient  = await connector.Connect();

                if (eisppClient.State != System.ServiceModel.CommunicationState.Opened)
                {
                    logger.LogError(new Exception("EisppClient.State"), $"Error opening channel {eisppClient.State}!");
                }

                result = true;
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Error initiating channel!");
            }

            return(result);
        }