示例#1
0
        private TwilioWorkState DeserializeStep(IReceivedData receivedData)
        {
            var state = new TwilioWorkState
            {
                ReceivedData = receivedData
            };

            try
            {
                state.TextMessage = state.ReceivedData.ContentType switch
                {
                    Constants.HeaderValueForLetter =>
                    _serializationProvider
                    .Deserialize <TextMessage>(state.ReceivedData.Letter.Body),

                    _ => _serializationProvider
                    .Deserialize <TextMessage>(state.ReceivedData.Data)
                };

                if (state.ReceivedData.Data.Length > 0 && (state.TextMessage != null || state.ReceivedData.Letter != null))
                {
                    state.DeserializeStepSuccess = true;
                }
            }
            catch
            { state.DeserializeStepSuccess = false; }

            return(state);
        }
示例#2
0
        public SendEmailState SendEmailDeserialize(IReceivedData receivedData)
        {
            var state = new SendEmailState
            {
                ReceivedData = receivedData
            };

            try
            {
                state.SendEmail = state.ReceivedData.ContentType switch
                {
                    Constants.HeaderValueForLetter =>
                    _serializationProvider
                    .Deserialize <SendEmail>(state.ReceivedData.Letter.Body),

                    _ => _serializationProvider
                    .Deserialize <SendEmail>(state.ReceivedData.Data)
                };

                state.StepSuccess[SendEmailDeserializeStepKey] = state.SendEmail != default || state.SendEmail != null;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, SendEmailDeserializeError);
                state.StepSuccess[SendEmailDeserializeStepKey] = false;
            }

            return(state);
        }
示例#3
0
        private async Task <WorkState> DeserializeStepAsync(IReceivedData receivedData)
        {
            var state = new WorkState
            {
                ReceivedData = receivedData
            };

            try
            {
                state.Message = state.ReceivedData.ContentType switch
                {
                    HouseofCat.RabbitMQ.Constants.HeaderValueForLetter => await receivedData
                    .GetTypeFromJsonAsync <Message>()
                    .ConfigureAwait(false),

                    _ => await receivedData
                    .GetTypeFromJsonAsync <Message>(decrypt : false, decompress : false)
                    .ConfigureAwait(false),
                };

                if (state.ReceivedData.Data.Length > 0 && (state.Message != null || state.ReceivedData.Letter != null))
                {
                    state.DeserializeStepSuccess = true;
                }
            }
            catch
            { }

            return(state);
        }
示例#4
0
        private WorkState DeserializeStep(IReceivedData receivedData)
        {
            var state = new WorkState
            {
                ReceivedData = receivedData
            };

            try
            {
                state.Message = state.ReceivedData.ContentType switch
                {
                    HouseofCat.RabbitMQ.Constants.HeaderValueForLetter =>
                    _serializationProvider
                    .Deserialize <Message>(state.ReceivedData.Letter.Body),

                    _ => _serializationProvider
                    .Deserialize <Message>(state.ReceivedData.Data),
                };

                if (state.ReceivedData.Data.Length > 0 && (state.Message != null || state.ReceivedData.Letter != null))
                {
                    state.DeserializeStepSuccess = true;
                }
            }
            catch
            { }

            return(state);
        }
示例#5
0
        public void Add(Guid guid, DateTime receiveTime, string senderName, IReceivedData receivedData, bool completed, bool replaceIfExisting = true)
        {
            System.Diagnostics.Debug.WriteLine($"Added {guid} from {senderName} to db");
            if (ContainsKey(guid))
            {
                if (replaceIfExisting)
                {
                    Remove(guid);
                }
                else
                {
                    return;
                }
            }

            HistoryRow r = new HistoryRow()
            {
                Id               = guid,
                ReceiveTime      = receiveTime,
                RemoteDeviceName = senderName,
                Data             = receivedData,
                Completed        = completed,
            };

            data.Insert(r);
        }