Exemple #1
0
        public async Task <T> SaveToQueue <T>(T obj, VerifiedUserContext user, string resourceId) where T : IHSObject
        {
            try
            {
                var orch = new OrchestrationObject <T>
                {
                    Token    = user.AccessToken,
                    ClientId = user.ClientID,
                    ID       = obj.ID,
                    Model    = obj
                };
                await _blobQueue.Save(orch.BuildPath(resourceId, user.ClientID), JsonConvert.SerializeObject(orch));

                return(await Task.FromResult(obj));
            }
            catch (OrderCloudIntegrationException ex)
            {
                throw new OrderCloudIntegrationException(ex.ApiError);
            }
            catch (Exception ex)
            {
                await _log.Save(new OrchestrationLog()
                {
                    Level   = LogLevel.Error,
                    Message = $"Failed to save blob to queue from API: {user.SupplierID} - {typeof(T)}:  {ex.Message}",
                    Current = JObject.FromObject(obj)
                });

                throw new OrderCloudIntegrationException(Headstart.Models.ErrorCodes.All["WriteFailure"], obj);
            }
        }
 public async Task LogEvent([ActivityTrigger] OrchestrationLog log) => await _log.Save(log);