public ServerMessagesViewModel() { if (WpfUtil.IsInDesignMode) { return; } foreach (var messageType in EnumItem <ServerMessageType> .GetEnumItems()) { _count.Add(messageType.Value, new MessageTypeItem <ServerMessageType>(messageType, ServerMessageViewModel.GetIcon, ServerMessageViewModel.GetIconFill, RefreshQueryResults)); } Init(); this.Add = new DelegateCommand(() => { new ServerMessageViewModel(new ServerMessageData { Id = Guid.NewGuid(), MessageType = ServerMessageType.Info.GetName(), Provider = "admin", Content = string.Empty, Timestamp = DateTime.MinValue }).Edit.Execute(FormType.Add); }); this.ClearKeyword = new DelegateCommand(() => { this.Keyword = string.Empty; }); this.Clear = new DelegateCommand(() => { this.ShowDialog(new DialogWindowViewModel(message: "确定清空吗?", title: "确认", onYes: () => { VirtualRoot.Execute(new ClearServerMessages()); })); }); VirtualRoot.BuildEventPath <ServerMessagesClearedEvent>("清空了本地存储的服务器消息后刷新Vm内存", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { Init(); }); }); VirtualRoot.BuildEventPath <NewServerMessageLoadedEvent>("从服务器加载了新消息后刷新Vm内存", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { foreach (var item in message.Data) { var vm = new ServerMessageViewModel(item); _serverMessageVms.Insert(0, vm); if (IsSatisfyQuery(vm)) { _queyResults.Insert(0, vm); } } OnPropertyChanged(nameof(IsNoRecord)); }); }); _serverMessageVms = new ObservableCollection <ServerMessageViewModel>(NTMinerRoot.Instance.ServerMessageSet.Select(a => new ServerMessageViewModel(a))); }
public void Apply(OpenApiSchema schema, SchemaFilterContext context) { if (!TypeHelper.IsSerializeAttribute(context.Type) && !TypeHelper.IsEnumerable(context.Type) && context.Type != typeof(object)) { //if (context.Type.Name == "UserReg") //{ } schema.Type = "object"; schema.Properties.Clear(); schema.AdditionalPropertiesAllowed = true; OpenApiSchema baseSchema = GetBaseSchema(context); if (baseSchema != null) { schema.AllOf = new List <OpenApiSchema> { baseSchema }; } if (TypeHelper.IsBaseType(context.Type, typeof(DBItem))) { var table = DBTable.GetTableAttributeInherit(context.Type); if (table != null) { ApplyTable(schema, context, table); return; } } ApplyObject(schema, context); } else if (context.Type.IsEnum) { var items = EnumItem.GetEnumItems(context.Type); var namesArray = new OpenApiArray(); namesArray.AddRange(items.Select(p => new OpenApiString(p.Name))); schema.Extensions.Add("x-enumNames", namesArray); var textArray = new OpenApiArray(); textArray.AddRange(items.Select(p => new OpenApiString(p.Text))); schema.Extensions.Add("x-enumMembers", textArray); if (context.Type.GetCustomAttribute <FlagsAttribute>() != null) { schema.Extensions.Add("x-flags", new OpenApiInteger(Enum.GetValues(context.Type).Cast <int>().First())); } } }
public LocalMessagesViewModel() { if (WpfUtil.IsInDesignMode) { return; } foreach (var messageChannel in LocalMessageChannelEnumItems) { var values = new Dictionary <LocalMessageType, MessageTypeItem <LocalMessageType> >(); foreach (var messageType in EnumItem <LocalMessageType> .GetEnumItems()) { values.Add(messageType.Value, new MessageTypeItem <LocalMessageType>(messageType, LocalMessageViewModel.GetIcon, LocalMessageViewModel.GetIconFill, RefreshQueryResults)); } _count.Add(messageChannel, values); } _selectedChannel = LocalMessageChannelEnumItems.FirstOrDefault(); Init(); this.ClearKeyword = new DelegateCommand(() => { this.Keyword = string.Empty; }); this.Clear = new DelegateCommand(() => { this.ShowDialog(new DialogWindowViewModel(message: "确定清空吗?", title: "确认", onYes: () => { VirtualRoot.LocalMessages.Clear(); })); }); VirtualRoot.BuildEventPath <LocalMessageClearedEvent>("清空挖矿消息集后刷新VM内存", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { Init(); }); }); VirtualRoot.BuildEventPath <LocalMessageAddedEvent>("发生了挖矿事件后刷新Vm内存", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { var vm = new LocalMessageViewModel(message.Source); _localMessageVms.Insert(0, vm); if (IsSatisfyQuery(vm)) { _queyResults.Insert(0, vm); } foreach (var item in message.Removes) { var toRemove = _localMessageVms.FirstOrDefault(a => a.Id == item.Id); if (toRemove != null) { _localMessageVms.Remove(toRemove); if (IsSatisfyQuery(toRemove)) { _queyResults.Remove(toRemove); } } } int removedCount = message.Removes.Count(a => a.MessageType == vm.MessageTypeEnum.GetName()); if (removedCount != 1) { _count[vm.ChannelEnum.GetEnumItem()][vm.MessageTypeEnum].Count += 1 - removedCount; UpdateChannelAll(); } OnPropertyChanged(nameof(IsNoRecord)); }); }); }