private SynchronizationConfig GetSynchronizationConfig() { try { SynchronizationConfig configDoc = null; storage.Batch( accessor => { if (accessor.ConfigExists(SynchronizationConstants.RavenSynchronizationConfig) == false) { return; } configDoc = accessor.GetConfig(SynchronizationConstants.RavenSynchronizationConfig).JsonDeserialization <SynchronizationConfig>(); }); return(configDoc); } catch (Exception e) { Log.Warn("Could not deserialize a synchronization config", e); return(null); } }
public ResponseResult <bool> Save(SynchronizationConfig cfg) { var service = GetService <SynchronizationConfigService>(); if (cfg.Id <= 0) { return(ResponseResult <bool> .GenSuccessResponse(service.Add(cfg) > 0)); } else { return(ResponseResult <bool> .GenSuccessResponse(service.Update(cfg))); } }
/// <summary> /// 保存功能操作信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonResult SaveConfig(SynchronizationConfig model) { var result = new BaseResult() { Code = (int)ResultCode.Faild }; if (model != null) { model.EditDate = DateTime.Now; result = ServiceHelper.CallService(ServiceConst.BizApi.SyncConfigSave, JsonConvert.SerializeObject(model), this.CurrentUser.Token); } return(Json(result, JsonRequestBehavior.AllowGet)); }
private UserSyncContext GetSyncContext(SynchronizationConfig config, IEnumerable <IGrouping <int, ShipInfo> > grouping) { var sync = new UserSyncContext(); var user = _sysUserService.GetModelById(config.UserId); sync.TaskId = user.PlaneNumber; sync.UserId = config.UserId; sync.SyncPeriodHours = config.SyncUnit.Equals("1") ? config.SyncPeriod : config.SyncPeriod * 24; sync.Shops = new List <ShipInfo>(); var myShops = grouping.FirstOrDefault(x => x.Key == config.UserId).ToList(); var shopIds = config.StoreIds.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); var syncShops = myShops.FindAll(x => shopIds.Contains(x.Id.ToString())); sync.Shops.AddRange(syncShops); return(sync); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SynchronizationConfig model, IDbTransaction transaction = null) { return(_SynchronizationConfigRepository.Update(model, transaction)); }
/// <summary> /// 新增 /// </summary> public int Add(SynchronizationConfig model, IDbTransaction transaction = null) { return(_SynchronizationConfigRepository.Insert(model, transaction)); }