Esempio n. 1
0
        public override string CreateSaga(MessageContext context, SagaEntity sagaentity)
        {
            try
            {
                var partition = $"{context.DateTimeUtc.ToString("yyyyMMdd")}_{context.Saga.Name}";

                var id = $"{partition}@{sagaentity.Key}@{_currenttablenamesufix}";

                var table = GetCloudTable(_connectionstring, $"{_sagastoragename}{_currenttablenamesufix}");

                var record = new SagaRecord(partition, sagaentity.Key)
                {
                    Data     = sagaentity.Data,
                    Created  = sagaentity.Created,
                    Updated  = sagaentity.Updated,
                    Name     = sagaentity.Name,
                    DataType = sagaentity.DataType,
                    Timeout  = sagaentity.Timeout,
                    Status   = sagaentity.Status
                };

                table.Execute(TableOperation.Insert(record));

                return(id);
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"Error during the saga record creation saga {context.Saga.Name}", ex);
            }
        }
Esempio n. 2
0
        public override string CreateSaga(MessageContext context, SagaEntity sagaentity)
        {
            try
            {
                var partition = $"{context.DateTimeUtc.ToString("yyyyMMdd")}_{context.Saga.Name}";

                var id = $"{partition}@{sagaentity.Key}@{_currenttablenamesufix}";

                var table = GetCloudTable(_connectionstring, $"{_sagastoragename}{_currenttablenamesufix}");

                var record = new SagaRecord(partition, sagaentity.Key)
                {
                    Data     = sagaentity.Data,
                    Created  = sagaentity.Created,
                    Updated  = sagaentity.Updated,
                    Name     = sagaentity.Name,
                    DataType = sagaentity.DataType,
                    Timeout  = sagaentity.Timeout,
                    Status   = sagaentity.Status
                };

                var result = table.ExecuteAsync(TableOperation.Insert(record)).GetAwaiter().GetResult();

                return(id);
            }
            catch (StorageException s)
            {
                throw new ApplicationException($"Error during the saga record creation for saga {context.Saga.Name} and route {context.Route.Name}, status code: {s.RequestInformation?.HttpStatusCode} error code: {s.RequestInformation?.ExtendedErrorInformation?.ErrorCode} error message: {s.RequestInformation?.ExtendedErrorInformation?.ErrorMessage}", s);
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"Error during the saga record creation for saga {context.Saga.Name} and route {context.Route.Name}", ex);
            }
        }