Example #1
0
 public ImapIdleEmailClient(
     IImapEmailMapper mapper,
     IEmailParser parser,
     IPublisherContract publisher,
     IDispatcher dispatcher)
     : base(mapper, parser, publisher, dispatcher)
 {
 }
        public ImapIdleEmailClient(
            IImapEmailMapper mapper,
            IEmailParser parser,
            IPublisherContract publisher)
            : base(mapper, parser, publisher)
        {
            this.baseLogString = $"{this.GetType()} [{this.GetHashCode()}] =>{Environment.NewLine}";
            string verboseMessage = $"{baseLogString} entering Ctor.";

            Logger.LogVerbose(verboseMessage);
        }
        public IHttpActionResult Update([FromUri] int id, [FromBody] PublisherUpdateModel game)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _publisherService = new PublisherServices();

            _publisherService.UpdatePublisher(id, game);

            return(Ok());
        }
        public IHttpActionResult Create([FromBody] PublisherCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _publisherService = new PublisherServices();

            _publisherService.CreatePublisher(model);

            return(Ok());
        }
        public ImapEmailClient(IImapEmailMapper mapper, IEmailParser parser, IPublisherContract publisher, IDispatcher dispatcher)
        {
            address  = ConfigurationManager.AppSettings["emailAddress"];
            password = ConfigurationManager.AppSettings["emailPassword"];
            server   = ConfigurationManager.AppSettings["emailServer"];
            port     = Int32.Parse(ConfigurationManager.AppSettings["emailPort"]);

            this.mapper     = mapper;
            this.parser     = parser;
            this.publisher  = publisher;
            this.dispatcher = dispatcher;

            client = new ImapClient(server, port, true);
        }
Example #6
0
        private async Task PublishScadaData(Topic topic, ScadaMessage scadaMessage)
        {
            string verboseMessage = $"{baseLogString} entering PublishScadaData method.";

            Logger.LogVerbose(verboseMessage);

            try
            {
                ScadaPublication   scadaPublication = new ScadaPublication(topic, scadaMessage);
                IPublisherContract publisherClient  = PublisherClient.CreateClient();
                await publisherClient.Publish(scadaPublication, MicroserviceNames.ScadaModelProviderService);

                Logger.LogInformation($"{baseLogString} PublishScadaData => SCADA service published data of topic: {scadaPublication.Topic}, publisher name: {MicroserviceNames.ScadaModelProviderService}");
            }
            catch (Exception e)
            {
                string errorMessage = $"{baseLogString} PublishScadaData => exception {e.Message}";
                Logger.LogError(errorMessage, e);
                throw e;
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"{baseLogString} PublishScadaData => MeasurementCache content: ");

            var enumerableMeasurementCache = await MeasurementsCache.GetEnumerableDictionaryAsync();

            foreach (long gid in enumerableMeasurementCache.Keys)
            {
                ModbusData data = enumerableMeasurementCache[gid];

                if (data is AnalogModbusData analogModbusData)
                {
                    sb.AppendLine($"Analog data line: [gid] 0x{gid:X16}, [value] {analogModbusData.Value}, [alarm] {analogModbusData.Alarm}");
                }
                else if (data is DiscreteModbusData discreteModbusData)
                {
                    sb.AppendLine($"Discrete data line: [gid] 0x{gid:X16}, [value] {discreteModbusData.Value}, [alarm] {discreteModbusData.Alarm}");
                }
                else
                {
                    sb.AppendLine($"UNKNOWN data type: {data.GetType()}");
                }
            }

            Logger.LogDebug(sb.ToString());
        }
        public ImapEmailClient(IImapEmailMapper mapper, IEmailParser parser, IPublisherContract publisher)
        {
            this.baseLogString = $"{this.GetType()} [{this.GetHashCode()}] =>{Environment.NewLine}";
            string verboseMessage = $"{baseLogString} entering Ctor.";

            Logger.LogVerbose(verboseMessage);

            address  = ConfigurationManager.AppSettings["emailAddress"];
            password = ConfigurationManager.AppSettings["emailPassword"];
            server   = ConfigurationManager.AppSettings["emailServer"];
            port     = Int32.Parse(ConfigurationManager.AppSettings["emailPort"]);

            this.mapper    = mapper;
            this.parser    = parser;
            this.publisher = publisher;

            client = new ImapClient(server, port, true);
        }
 public IHttpActionResult Delete([FromUri] int id)
 {
     _publisherService = new PublisherServices();
     _publisherService.DeletePublisher(id);
     return(Ok());
 }
 public IHttpActionResult Get([FromUri] int id)
 {
     _publisherService = new PublisherServices();
     return(Ok(_publisherService.GetPublisher(id)));
 }
 public IHttpActionResult List()
 {
     _publisherService = new PublisherServices();
     return(Ok(_publisherService.GetPublisher()));
 }