Exemplo n.º 1
0
        //var messsageType = GetMessageType(sourceData);
        //_ = messsageType.MessageType switch
        //        {
        //            (0) => _dataStoreProcesor.SavePersonAsync(sourceData),
        //            (1) => _dataStoreProcesor.SavePersonImgAsync(sourceData),
        //            (2) => _dataStoreProcesor.SaveDevicesAsync(sourceData),
        //            (3) => _dataStoreProcesor.SaveAttendRecordAsync(sourceData)
        //};

        public Task ProcessDataAsync(string sourceData)
        {
            this._logger.LogInformation($"MessageController::ProcessDataAsync executes : {DateTime.Now}");

            try
            {
                var messsageType = MessageConverter.GetMessageType <ThermoBaseMessageType>(sourceData);

                switch (messsageType.MessageType)
                {
                case 0:
                    this._logger.LogInformation(PersonProcessingMessage);
                    _dataStoreProcesor.SavePersonAsync(sourceData);
                    break;

                case 1:
                    this._logger.LogInformation(ImageProcessingMessage);
                    _dataStoreProcesor.SavePersonImgAsync(sourceData);
                    break;

                case 2:
                    this._logger.LogInformation(DeviceProcessingMessage);
                    _dataStoreProcesor.SaveDevicesAsync(sourceData);
                    break;

                case 3:
                    this._logger.LogInformation(AttendanceMessageProcessingMessage);
                    _dataStoreProcesor.SaveAttendRecordAsync(sourceData);
                    _notificationProcesor.ProcessAsync(sourceData);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                this._logger.LogError($"Error in MessageConroller : {ex.Message}");
                this._logger.LogError($"StackTrace: {ex.StackTrace}");
                throw;
            }
            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        private void Handle(object sender, BaseEvent e)
        {
            INotificationProcessor notificationProcessor = _serviceProvider.GetService <INotificationProcessor>();

            notificationProcessor.ProcessAsync(e);
        }