public Result Update(AppDto dto) { try { var entity = dto.MapTo <AppEntity>(); var rlt = UnitOfWorkService.Execute(() => _repo.Update(entity)); if (!rlt) { return new Result { Status = false, Message = "数据库操作失败" } } ; var json = Serializer.Serialize(dto); var url = _configuration.GetValue("WebApi:url", "http://localhost:15002/sync"); var http = _hxHttpClientFactory.CreateHttpClient(); http.SendAsync(url, Serializer.Serialize(new CusNotification { Method = 12, Body = json })); Logger.Info($"app同步结果update:{json}"); return(new Result { Status = true }); } catch (Exception ex) { Logger.Error("update app error", ex); return(new Result { Status = false, Message = "内部服务器错误" }); } }
public Result Add(AppDto dto, UserType roleId)//TODO:缓存同步 { try { var id = ""; var entity = dto.MapTo <AppEntity>(); var rlt = UnitOfWorkService.Execute(() => { id = _repo.InsertAndGetId(entity); var orgId = _staffRepository.GetOrgId(dto.SalesMan).OrgId; var dataInOrg = new DataInOrgEntity { DataId = id, DataType = (int)DataType.App, OrgId = orgId, RoleId = ((int)roleId).ToString() }; var dataRlt = _dataInOrgRepository.Inserts(dataInOrg); return(id.IsNotNullOrEmpty() && dataRlt); }); if (!rlt) { return new Result { Status = false, Message = "数据库操作失败" } } ; dto.Id = id; var json = Serializer.Serialize(dto); var url = _configuration.GetValue("WebApi:url", "http://localhost:15002/sync"); var http = _hxHttpClientFactory.CreateHttpClient(); http.SendAsync(url, Serializer.Serialize(new CusNotification { Method = 11, Body = json })); Logger.Info($"app同步结果add:{json}"); //_mediator.Publish(syncModel); return(new Result { Status = true }); } catch (Exception ex) { Logger.Error("add app error", ex); return(new Result { Status = false, Message = "内部服务器错误" }); } }