public async Task <TEntity> PostEntityAsync <TEntity>(TEntity entity, string actionType = "") where TEntity : DSWBaseEntity { return(await ExecuteHelper(async() => { _httpClient.SetEntityRest <TEntity>(); return await _httpClient.PostAsync(entity, actionType) .ResponseToModelAsync <TEntity>(); }, "WebAPIClient.PostEntityAsync -> POST entities error")); }
private void InsertProtocolLog(DocumentUnit entity, BiblosDocumentInfo documentInfo) { using (WindowsIdentity wi = (WindowsIdentity)HttpContext.Current.User.Identity) using (WindowsImpersonationContext wic = wi.Impersonate()) using (ExecutionContext.SuppressFlow()) { ProtocolLog protocolLog = new ProtocolLog() { LogDescription = string.Format("\"{0}\" [{1}]", documentInfo.Name, documentInfo.DocumentId.ToString("N")), Entity = new Protocol(entity.UniqueId) }; try { string actionType = EnumHelper.GetDescription(InsertActionType.ViewProtocolDocument); //string actionType = "ViewProtocolDocument"; protocolLog = _httpClient.PostAsync(protocolLog, actionType).ResponseToModel <ProtocolLog>(); } catch (Exception ex) { FileLogger.Error(LogName.FileLog, ex.Message, ex); throw ex; } finally { wic.Undo(); } } }