public async Task <bool> Set <T>(T entity, string fileName) where T : class, new() { var s = _entitySerialiser.Serialise(entity); return(await _applicationDataHelper.SaveString(fileName, s)); }
protected string Serialise <T>(T entity) { if (OverrideSerialiser != null) { return(OverrideSerialiser.Serialise(entity)); } return(_entitySerialiser.Serialise(entity)); }
public async Task <bool> Set <T>(T entity, string fileName) where T : class, new() { var t = _getFileName(fileName); var data = _entitySerialiser.Serialise(entity); var result = await _blobRepo.UploadTextAsync(t, data); return(result); }
public async Task <XResult <bool> > Post(T entity) { var s = _serialiser.Serialise(entity); var m = new CloudQueueMessage(s); var result = await XResiliant.Default.Run(() => OperationWrap <bool>(async() => { await _q.AddMessageAsync(m); return(true); })); return(result); }
public async Task <bool> Set <T>(T entity, string fileName) where T : class, new() { var t = _getFileName(fileName); var data = _entitySerialiser.Serialise(entity); var dEntity = new EntityCacheTableEntity { Data = data, PartitionKey = t.Item1, RowKey = t.Item2, Timestamp = DateTime.Now }; var result = await _entityCacheTableRepo.AddOrUpdate(dEntity); return(result.IsSuccess); }
public XResult <T> TrackOperation <T>(XResult <T> operation, string operationName = null) { var op = _entitySerialiser.Serialise(operation); var dict = new Dictionary <string, string>(); if (operationName != null) { dict.Add("Name", operationName); } dict.Add("Id", operation.Id.ToString()); dict.Add("Message", operation.Message); dict.Add("CallerMemberName", operation.CallerInfo.MemberName); dict.Add("Result", operation.ResultCode.ToString()); dict.Add("StatusCode", operation.StatusCode.ToString()); dict.Add("XResult", op); if (_contextInfoService.Context != null) { foreach (var i in _contextInfoService.Context) { dict.Add(i.Key, i.Value); } } if (operation.ResultCode == OperationResults.Exception || operation.Exception != null) { dict.Add("ExceptionType", "XResult"); TrackException(operation.Exception, dict); return(operation); } TrackTrace("XResult", operation.IsSuccess ? XSeverityLevel.Information : XSeverityLevel.Error, dict); return(operation); }
protected string Serialise <T>(T entity) { return(_entitySerialiser.Serialise(entity)); }
Task _runStage(XFlowState state) { if (state.State != XFlowStates.WaitingForNetwork && state.State != XFlowStates.WaitingForRetry && state.State != XFlowStates.WaitingToStart) { return(null); } if (_inProgressStates.Contains(state)) { return(null); } var t = Task.Run(async() => { var stage = _getStage(state); if (stage.RequiresNetwork && !_networkStatus.QuickNetworkCheck()) { state.State = XFlowStates.WaitingForNetwork; await Task.Yield(); return; } state.Text = stage.ProcessingText; state.State = XFlowStates.InProgress; state.Timestamp = DateTime.UtcNow; if (stage.IsDisconnectedProcess) { state.State = XFlowStates.DisconnectedProcessing; await _save(); Debug.WriteLine("Stopping flow for disconnected state, will resume when asked. {0}", state); return; } await _save(); XStageResult failResult = null; try { if (_inProgressStates.Contains(state)) { return; } _inProgressStates.Add(state); var result = await stage.Function(state.ItemId); if (result.Id != Guid.Empty) { state.ItemId = result.Id; } state.PreviousStageResult = result; _inProgressStates.Remove(state); if (!result.IsSuccess) { await _failResult(state); } else { await _successResult(state); } } catch (Exception ex) { _inProgressStates.Remove(state); failResult = new XStageResult(false, state.ItemId, null, exception: ex.ToString()); } if (failResult != null) { state.PreviousStageResult = failResult; var stateString = _entitySerialiser.Serialise(state); Debug.WriteLine("Caught exception process: {0}", stateString); await _failResult(state); } _cancelProcessWait(); }); return(t); }