/// <summary> /// 当需要持久化数据Provider中没有的信息时,用此类来合并Provider的数据 /// 和本地json数据文件。 /// </summary> /// <returns>合并后的数据列表</returns> public IEnumerable <AppRole> GetData() { var dbData = mProvider.GetData(); lock (mCachedData) { foreach (AppRole dbItem in dbData) { AppRole chItem = mCachedData.FirstOrDefault(ch => ch.Id == dbItem.Id); if (chItem != null) { dbItem.FunctionIds = chItem.FunctionIds; mCachedData[mCachedData.IndexOf(chItem)] = dbItem; } else { mCachedData.Add(dbItem); } } //移除Provider中没有的值 for (int i = mCachedData.Count - 1; i >= 0; i--) { if (!dbData.Any(d => d.Id == mCachedData[i].Id)) { mCachedData.RemoveAt(i); } } return(mCachedData); } }
/// <summary> /// 根据指定的类型名称和属性名称获取对应的属性配置项 /// </summary> /// <param name="className">类型名称</param> /// <param name="propName">属性名称</param> /// <param name="attr">标签属性</param> /// <returns>属性配置项</returns> public static AdvDataConfigItem GetPropertyConfig(CatalogExtAttribute attr, string className, string propName) { AdvDataConfigItem foundItem = null; var classConfig = _configCache.FirstOrDefault(cfg => cfg.ClassName.Equals(className)); if (classConfig == null) { classConfig = new AdvDataConfig() { ClassName = className }; _configCache.Add(classConfig); _modified = true; } foundItem = classConfig.Items.FirstOrDefault(c => c.PropertyName == propName); if (foundItem == null) { foundItem = new AdvDataConfigItem { OverWrite = true, FormOrder = 1, PropertyName = propName, GridOrder = 1, AllowNull = attr.AllowNull, DataSource = attr.DataSource.ToStr(), DataSourceType = CommOp.ToStr(attr.DataSourceType), DataType = attr.DataType.ToString(), MaxLength = attr.MaxLength, MinLength = attr.MinLength, MaxValue = CommOp.ToStr(attr.MaxValue), MinValue = CommOp.ToStr(attr.MinValue), RegExpr = attr.RegExpr, DefaultValue = attr.DefaultValue, InputFormat = attr.InputFormat, DisplayFormat = attr.DisplayFormat, Browsable = attr.Browsable, }; classConfig.Items.Add(foundItem); _modified = true; } else if (foundItem.OverWrite) { attr.DefaultValue = foundItem.DefaultValue; attr.DataType = CommOp.ToEnum <ExtDataType>(foundItem.DataType); attr.AllowNull = foundItem.AllowNull; attr.DataSource = foundItem.DataSource; attr.DataSourceType = CommOp.ToEnum <ExtDataSourceType>(foundItem.DataSourceType); attr.MaxLength = foundItem.MaxLength; attr.MinLength = foundItem.MinLength; attr.MaxValue = foundItem.MaxValue; attr.MinValue = foundItem.MinValue; attr.RegExpr = foundItem.RegExpr; attr.InputFormat = foundItem.InputFormat; attr.DisplayFormat = foundItem.DisplayFormat; attr.Browsable = foundItem.Browsable; } return(foundItem); }
/// <summary> /// /// </summary> /// <param name="handle"></param> /// <param name="priority">越大越先执行</param> public void Add(Action handle, int priority) { if (handles == null) { handles = new CachedList <Item>(); } handles.Add(new Item(handle, priority)); dirty = true; }
private void ExecuteStoreParticipanteAsync(ParticipanteLista participante) { if (CachedList.Count > 0) {//está pesquisando Members.Add(editListaCompraDetalheViewModel.AdicionarParticipante(participante)); CachedList.Add(participante); SearchText = string.Empty; AtualizarStatus(); return; } this.participanteListaCompra = participante; RemoverParticipanteSelecionadoCommand.ChangeCanExecute(); }
public UserConfigStorage() { AppManager.Instance.UserManager.AfterGetData = AfterGetData; AppManager.Instance.UserManager.AfterSaved = user => { var oldUser = usersList.FirstOrDefault(u => u.Id == user.Id); if (oldUser != null) { usersList.Remove(oldUser); } usersList.Add((T)user); usersList.Save(); }; usersList.OnMerge += usersList_OnMerge; }
private void ExecuteProdutoListaTapped(ProdutoListaCompraViewModel produtoListaCompra) { if (!IsNotSearching) { if (TransformGroupedCollectionToModel(CachedList).FirstOrDefault(x => x.Produto?.Nome == produtoListaCompra.ProdutoListaCompra.Produto?.Nome && x.Produto?.IdTipo == produtoListaCompra.ProdutoListaCompra.Produto?.IdTipo) == null) { //está pesquisando produtoListaCompra.IsNotSearching = true; var cached = CachedList.FirstOrDefault(x => x.Key == produtoListaCompra.Produto[0]); if (cached != null) { cached.Add(produtoListaCompra); } else { CachedList.Add(new GroupCollection <char, ProdutoListaCompraViewModel>(produtoListaCompra.Produto[0], new[] { produtoListaCompra })); } } SearchText = string.Empty; AtualizarStatus(); } }