/// <summary> /// 批量更新 /// </summary> /// <param name="PositionRequest"></param> /// <returns></returns> public BasicResponse UpdatePositions(PositionsRequest PositionRequest) { BasicResponse Result = new BasicResponse(); List <Jc_WzInfo> items = PositionRequest.PositionsInfo; List <Jc_WzInfo> PositionCaches = new List <Jc_WzInfo>(); Jc_WzInfo olditem = null; PositionCacheGetAllRequest positionCacheRequest = new PositionCacheGetAllRequest(); var result = _PositionCacheService.GetAllPositongCache(positionCacheRequest); PositionCaches = result.Data; foreach (Jc_WzInfo item in items) { olditem = PositionCaches.Find(a => a.WzID == item.WzID); //增加重复判断 if (result.Data == null) { //缓存中存在此测点 Result.Code = 1; Result.Message = "当前更新的安装位置不存在!"; return(Result); } } TransactionsManager.BeginTransaction(() => { foreach (Jc_WzInfo item in items) { //保存数据库 var _jc_Wz = ObjectConverter.Copy <Jc_WzInfo, Jc_WzModel>(item); _Repository.UpdatePosition(_jc_Wz); } //保存缓存 PositionCacheBatchUpdateRequest BatchUpdatePositionCacheRequest = new PositionCacheBatchUpdateRequest(); BatchUpdatePositionCacheRequest.PositionInfos = items; _PositionCacheService.BatchUpdatePositionCache(BatchUpdatePositionCacheRequest); }); return(Result); }
public BasicResponse BatchUpdatePositionCache(PositionCacheBatchUpdateRequest positionCacheRequest) { PositionCache.PositionCahceInstance.UpdateItems(positionCacheRequest.PositionInfos); return(new BasicResponse()); }