private void Init()
 {
     lock (_locker) {
         if (!_isInited)
         {
             var repository = NTMinerRoot.CreateServerRepository <KernelOutputFilterData>(_isUseJson);
             foreach (var item in repository.GetAll())
             {
                 if (!_dicById.ContainsKey(item.GetId()))
                 {
                     _dicById.Add(item.GetId(), item);
                 }
                 if (!_dicByKernelOutputId.ContainsKey(item.KernelOutputId))
                 {
                     _dicByKernelOutputId.Add(item.KernelOutputId, new List <KernelOutputFilterData>());
                 }
                 if (_dicByKernelOutputId[item.KernelOutputId].All(a => a.GetId() != item.GetId()))
                 {
                     _dicByKernelOutputId[item.KernelOutputId].Add(item);
                 }
             }
             _isInited = true;
         }
     }
 }
Exemple #2
0
 private void Init()
 {
     lock (_locker) {
         if (!_isInited)
         {
             var repository = NTMinerRoot.CreateServerRepository <KernelOutputTranslaterData>();
             foreach (var item in repository.GetAll())
             {
                 if (!_dicById.ContainsKey(item.GetId()))
                 {
                     _dicById.Add(item.GetId(), item);
                 }
                 if (!_dicByKernelOutputId.ContainsKey(item.KernelOutputId))
                 {
                     _dicByKernelOutputId.Add(item.KernelOutputId, new List <KernelOutputTranslaterData>());
                 }
                 if (_dicByKernelOutputId[item.KernelOutputId].All(a => a.GetId() != item.GetId()))
                 {
                     _dicByKernelOutputId[item.KernelOutputId].Add(item);
                 }
             }
             foreach (var item in _dicByKernelOutputId.Values)
             {
                 item.Sort(new SortNumberComparer());
             }
             _isInited = true;
         }
     }
 }
Exemple #3
0
 private void Init()
 {
     lock (_locker) {
         if (!_isInited)
         {
             var repository = NTMinerRoot.CreateServerRepository <SysDicItemData>(_isUseJson);
             foreach (var item in repository.GetAll())
             {
                 if (!_dicById.ContainsKey(item.GetId()))
                 {
                     _dicById.Add(item.GetId(), item);
                 }
                 if (!_dicByDicId.ContainsKey(item.DicId))
                 {
                     _dicByDicId.Add(item.DicId, new Dictionary <string, SysDicItemData>(StringComparer.OrdinalIgnoreCase));
                 }
                 if (!_dicByDicId[item.DicId].ContainsKey(item.Code))
                 {
                     _dicByDicId[item.DicId].Add(item.Code, item);
                 }
             }
             _isInited = true;
         }
     }
 }
Exemple #4
0
 private void Init()
 {
     lock (_locker) {
         if (!_isInited)
         {
             var repository             = NTMinerRoot.CreateServerRepository <PoolKernelData>();
             List <PoolKernelData> list = repository.GetAll().ToList();
             foreach (IPool pool in _root.PoolSet)
             {
                 foreach (ICoinKernel coinKernel in _root.CoinKernelSet.Where(a => a.CoinId == pool.CoinId))
                 {
                     PoolKernelData poolKernel = list.FirstOrDefault(a => a.PoolId == pool.GetId() && a.KernelId == coinKernel.KernelId);
                     if (poolKernel != null)
                     {
                         _dicById.Add(poolKernel.GetId(), poolKernel);
                     }
                     else
                     {
                         Guid poolKernelId = Guid.NewGuid();
                         _dicById.Add(poolKernelId, new PoolKernelData()
                         {
                             Id          = poolKernelId,
                             Args        = string.Empty,
                             Description = string.Empty,
                             KernelId    = coinKernel.KernelId,
                             PoolId      = pool.GetId()
                         });
                     }
                 }
             }
             _isInited = true;
         }
     }
 }
Exemple #5
0
        public PoolKernelSet(INTMinerRoot root, bool isUseJson)
        {
            _root      = root;
            _isUseJson = isUseJson;
            VirtualRoot.Window <AddPoolKernelCommand>("处理添加矿池级内核命令", LogEnum.DevConsole,
                                                      action: message => {
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    var entity = new PoolKernelData().Update(message.Input);
                    _dicById.Add(message.Input.GetId(), entity);
                    var repository = NTMinerRoot.CreateServerRepository <PoolKernelData>(isUseJson);
                    repository.Add(entity);
                    VirtualRoot.Happened(new PoolKernelAddedEvent(message.Input));
                }
            }).AddToCollection(root.ContextHandlers);
            VirtualRoot.Window <RemovePoolKernelCommand>("处理移除矿池级内核命令", LogEnum.DevConsole,
                                                         action: message => {
                if (_dicById.ContainsKey(message.EntityId))
                {
                    var entity = _dicById[message.EntityId];
                    _dicById.Remove(message.EntityId);
                    var repository = NTMinerRoot.CreateServerRepository <PoolKernelData>(isUseJson);
                    repository.Remove(message.EntityId);
                    VirtualRoot.Happened(new PoolKernelRemovedEvent(entity));
                }
            }).AddToCollection(root.ContextHandlers);
            VirtualRoot.Window <UpdatePoolKernelCommand>("更新矿池内核", LogEnum.DevConsole,
                                                         action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_root.PoolSet.Contains(message.Input.PoolId))
                {
                    throw new ValidationException("there is no pool with id" + message.Input.PoolId);
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                PoolKernelData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <PoolKernelData>(isUseJson);
                repository.Update(entity);

                VirtualRoot.Happened(new PoolKernelUpdatedEvent(entity));
            }).AddToCollection(root.ContextHandlers);
        }
Exemple #6
0
        public PoolKernelSet(IServerContext context)
        {
            _context = context;
            _context.AddCmdPath <AddPoolKernelCommand>("处理添加矿池级内核命令", LogEnum.DevConsole,
                                                       action: message => {
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    var entity = new PoolKernelData().Update(message.Input);
                    _dicById.Add(message.Input.GetId(), entity);
                    var repository = NTMinerRoot.CreateServerRepository <PoolKernelData>();
                    repository.Add(entity);
                    VirtualRoot.RaiseEvent(new PoolKernelAddedEvent(message.MessageId, message.Input));
                }
            }, location: this.GetType());
            _context.AddCmdPath <RemovePoolKernelCommand>("处理移除矿池级内核命令", LogEnum.DevConsole,
                                                          action: message => {
                if (_dicById.ContainsKey(message.EntityId))
                {
                    var entity = _dicById[message.EntityId];
                    _dicById.Remove(message.EntityId);
                    var repository = NTMinerRoot.CreateServerRepository <PoolKernelData>();
                    repository.Remove(message.EntityId);
                    VirtualRoot.RaiseEvent(new PoolKernelRemovedEvent(message.MessageId, entity));
                }
            }, location: this.GetType());
            _context.AddCmdPath <UpdatePoolKernelCommand>("更新矿池内核", LogEnum.DevConsole,
                                                          action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_context.PoolSet.Contains(message.Input.PoolId))
                {
                    throw new ValidationException("there is no pool with id" + message.Input.PoolId);
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                PoolKernelData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <PoolKernelData>();
                repository.Update(entity);

                VirtualRoot.RaiseEvent(new PoolKernelUpdatedEvent(message.MessageId, entity));
            }, location: this.GetType());
        }
Exemple #7
0
        public CoinGroupSet(INTMinerRoot root)
        {
            _root = root;
            Global.Access <AddCoinGroupCommand>(
                Guid.Parse("2dd8f7e9-c79d-4621-954f-9fc45b0207dd"),
                "添加币组",
                LogEnum.Log,
                action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                CoinGroupData entity = new CoinGroupData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <CoinGroupData>();
                repository.Add(entity);

                Global.Happened(new CoinGroupAddedEvent(entity));
            });
            Global.Access <RemoveCoinGroupCommand>(
                Guid.Parse("e52874f4-37d8-4d49-a637-5b95aa89367e"),
                "移除币组",
                LogEnum.Log,
                action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                CoinGroupData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.GetId());
                var repository = NTMinerRoot.CreateServerRepository <CoinGroupData>();
                repository.Remove(message.EntityId);

                Global.Happened(new CoinGroupRemovedEvent(entity));
            });
            Global.Logger.InfoDebugLine(this.GetType().FullName + "接入总线");
        }
Exemple #8
0
 private void Init()
 {
     lock (_locker) {
         if (!_isInited)
         {
             IRepository <PackageData> repository = NTMinerRoot.CreateServerRepository <PackageData>(_isUseJson);
             foreach (var item in repository.GetAll())
             {
                 if (!_dicById.ContainsKey(item.GetId()))
                 {
                     _dicById.Add(item.GetId(), item);
                 }
             }
             _isInited = true;
         }
     }
 }
Exemple #9
0
 private void Init()
 {
     lock (_locker) {
         if (!_isInited)
         {
             var repository = NTMinerRoot.CreateServerRepository <CoinKernelData>();
             foreach (var item in repository.GetAll())
             {
                 if (!_dicById.ContainsKey(item.GetId()))
                 {
                     _dicById.Add(item.GetId(), item);
                 }
             }
             _isInited = true;
         }
     }
 }
Exemple #10
0
        public CoinGroupSet(INTMinerRoot root, bool isUseJson)
        {
            _root      = root;
            _isUseJson = isUseJson;
            _root.ServerContextWindow <AddCoinGroupCommand>("添加币组", LogEnum.DevConsole,
                                                            action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                CoinGroupData entity = new CoinGroupData().Update(message.Input);
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <CoinGroupData>(isUseJson);
                repository.Add(entity);

                VirtualRoot.Happened(new CoinGroupAddedEvent(entity));
            });
            _root.ServerContextWindow <RemoveCoinGroupCommand>("移除币组", LogEnum.DevConsole,
                                                               action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                CoinGroupData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.GetId());
                var repository = NTMinerRoot.CreateServerRepository <CoinGroupData>(isUseJson);
                repository.Remove(message.EntityId);

                VirtualRoot.Happened(new CoinGroupRemovedEvent(entity));
            });
        }
Exemple #11
0
        public CoinGroupSet(IServerContext context)
        {
            context.BuildCmdPath <AddCoinGroupCommand>("添加币组", LogEnum.DevConsole,
                                                       action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                CoinGroupData entity = new CoinGroupData().Update(message.Input);
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <CoinGroupData>();
                repository.Add(entity);

                VirtualRoot.RaiseEvent(new CoinGroupAddedEvent(message.Id, entity));
            });
            context.BuildCmdPath <RemoveCoinGroupCommand>("移除币组", LogEnum.DevConsole,
                                                          action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                CoinGroupData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.GetId());
                var repository = NTMinerRoot.CreateServerRepository <CoinGroupData>();
                repository.Remove(message.EntityId);

                VirtualRoot.RaiseEvent(new CoinGroupRemovedEvent(message.Id, entity));
            });
        }
Exemple #12
0
        public KernelInputSet(IServerContext context)
        {
            context.AddCmdPath <AddKernelInputCommand>("添加内核输入组", LogEnum.DevConsole,
                                                       action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelInputData entity = new KernelInputData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <KernelInputData>();
                repository.Add(entity);

                VirtualRoot.RaiseEvent(new KernelInputAddedEvent(message.Id, entity));
            }, location: this.GetType());
            context.AddCmdPath <UpdateKernelInputCommand>("更新内核输入组", LogEnum.DevConsole,
                                                          action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Name))
                {
                    throw new ValidationException($"{nameof(message.Input.Name)} can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelInputData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <KernelInputData>();
                repository.Update(entity);

                VirtualRoot.RaiseEvent(new KernelInputUpdatedEvent(message.Id, entity));
            }, location: this.GetType());
            context.AddCmdPath <RemoveKernelInputCommand>("移除内核输入组", LogEnum.DevConsole,
                                                          action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                KernelInputData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.GetId());
                var repository = NTMinerRoot.CreateServerRepository <KernelInputData>();
                repository.Remove(message.EntityId);

                VirtualRoot.RaiseEvent(new KernelInputRemovedEvent(message.Id, entity));
            }, location: this.GetType());
        }
Exemple #13
0
        public KernelOutputSet(IServerContext context)
        {
            #region 接线
            context.AddCmdPath <AddKernelOutputCommand>("添加内核输出组", LogEnum.DevConsole,
                                                        action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelOutputData entity = new KernelOutputData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputData>();
                repository.Add(entity);

                VirtualRoot.RaiseEvent(new KernelOutputAddedEvent(message.MessageId, entity));
            }, location: this.GetType());
            context.AddCmdPath <UpdateKernelOutputCommand>("更新内核输出组", LogEnum.DevConsole,
                                                           action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Name))
                {
                    throw new ValidationException($"{nameof(message.Input.Name)} can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelOutputData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputData>();
                repository.Update(entity);

                VirtualRoot.RaiseEvent(new KernelOutputUpdatedEvent(message.MessageId, entity));
            }, location: this.GetType());
            context.AddCmdPath <RemoveKernelOutputCommand>("移除内核输出组", LogEnum.DevConsole,
                                                           action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                IKernel[] outputUsers = context.KernelSet.AsEnumerable().Where(a => a.KernelOutputId == message.EntityId).ToArray();
                if (outputUsers.Length != 0)
                {
                    throw new ValidationException($"这些内核在使用该内核输出组,删除前请先解除使用:{string.Join(",", outputUsers.Select(a => a.GetFullName()))}");
                }
                KernelOutputData entity = _dicById[message.EntityId];
                List <Guid> kernelOutputTranslaterIds = context.KernelOutputTranslaterSet.AsEnumerable().Where(a => a.KernelOutputId == entity.Id).Select(a => a.GetId()).ToList();
                foreach (var kernelOutputTranslaterId in kernelOutputTranslaterIds)
                {
                    VirtualRoot.Execute(new RemoveKernelOutputTranslaterCommand(kernelOutputTranslaterId));
                }
                _dicById.Remove(entity.GetId());
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputData>();
                repository.Remove(message.EntityId);

                VirtualRoot.RaiseEvent(new KernelOutputRemovedEvent(message.MessageId, entity));
            }, location: this.GetType());
            #endregion
        }
        public KernelOutputFilterSet(INTMinerRoot root)
        {
            _root = root;
            Global.Access <AddKernelOutputFilterCommand>(
                Guid.Parse("43c09cc6-456c-4e55-95b1-63b5937c5b11"),
                "添加内核输出过滤器",
                LogEnum.Log,
                action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.RegexPattern))
                {
                    throw new ValidationException("KernelOutputFilter RegexPattern can't be null or empty");
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelOutputFilterData entity = new KernelOutputFilterData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                if (!_dicByKernelId.ContainsKey(entity.KernelId))
                {
                    _dicByKernelId.Add(entity.KernelId, new List <KernelOutputFilterData>());
                }
                _dicByKernelId[entity.KernelId].Add(entity);
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputFilterData>();
                repository.Add(entity);

                Global.Happened(new KernelOutputFilterAddedEvent(entity));
            });
            Global.Access <UpdateKernelOutputFilterCommand>(
                Guid.Parse("b449bd25-98d8-4a60-9c75-36a6983c6176"),
                "更新内核输出过滤器",
                LogEnum.Log,
                action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.RegexPattern))
                {
                    throw new ValidationException("KernelOutputFilter RegexPattern can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelOutputFilterData entity = _dicById[message.Input.GetId()];
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputFilterData>();
                repository.Update(entity);

                Global.Happened(new KernelOutputFilterUpdatedEvent(entity));
            });
            Global.Access <RemoveKernelOutputFilterCommand>(
                Guid.Parse("11a3a185-3d2e-463e-bd92-94a0db909d32"),
                "移除内核输出过滤器",
                LogEnum.Log,
                action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                KernelOutputFilterData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.Id);
                _dicByKernelId[entity.KernelId].Remove(entity);
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputFilterData>();
                repository.Remove(entity.Id);

                Global.Happened(new KernelOutputFilterRemovedEvent(entity));
            });
            BootLog.Log(this.GetType().FullName + "接入总线");
        }
        public KernelOutputTranslaterSet(INTMinerRoot root, bool isUseJson)
        {
            _root      = root;
            _isUseJson = isUseJson;
            _root.ServerContextWindow <AddKernelOutputTranslaterCommand>("添加内核输出翻译器", LogEnum.DevConsole,
                                                                         action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.RegexPattern))
                {
                    throw new ValidationException($"{nameof(message.Input.RegexPattern)} can't be null or empty");
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelOutputTranslaterData entity = new KernelOutputTranslaterData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                if (!_dicByKernelOutputId.ContainsKey(entity.KernelOutputId))
                {
                    _dicByKernelOutputId.Add(entity.KernelOutputId, new List <KernelOutputTranslaterData>());
                }
                _dicByKernelOutputId[entity.KernelOutputId].Add(entity);
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputTranslaterData>(isUseJson);
                repository.Add(entity);

                VirtualRoot.Happened(new KernelOutputTranslaterAddedEvent(entity));
            });
            _root.ServerContextWindow <UpdateKernelOutputTranslaterCommand>("更新内核输出翻译器", LogEnum.DevConsole,
                                                                            action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.RegexPattern))
                {
                    throw new ValidationException($"{nameof(message.Input.RegexPattern)} can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelOutputTranslaterData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                string regexPattern = entity.RegexPattern;
                string color        = entity.Color;
                entity.Update(message.Input);
                if (entity.RegexPattern != regexPattern)
                {
                    _regexDic.Remove(entity);
                }
                if (entity.Color != color)
                {
                    _colorDic.Remove(entity);
                }
                _dicByKernelOutputId[entity.KernelOutputId].Sort(new SortNumberComparer());
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputTranslaterData>(isUseJson);
                repository.Update(entity);

                VirtualRoot.Happened(new KernelOutputTranslaterUpdatedEvent(entity));
            });
            _root.ServerContextWindow <RemoveKernelOutputTranslaterCommand>("移除内核输出翻译器", LogEnum.DevConsole,
                                                                            action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                KernelOutputTranslaterData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.Id);
                _dicByKernelOutputId[entity.KernelOutputId].Remove(entity);
                _colorDic.Remove(entity);
                _regexDic.Remove(entity);
                _dicByKernelOutputId[entity.KernelOutputId].Sort(new SortNumberComparer());
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputTranslaterData>(isUseJson);
                repository.Remove(entity.Id);

                VirtualRoot.Happened(new KernelOutputTranslaterRemovedEvent(entity));
            });
            _root.ServerContextOn <SysDicItemUpdatedEvent>($"{Consts.LogColorDicKey}字典项更新后刷新翻译器内存", LogEnum.DevConsole,
                                                           action: message => {
                if (!_root.SysDicSet.TryGetSysDic(Consts.LogColorDicKey, out ISysDic dic))
                {
                    return;
                }
                if (message.Source.DicId != dic.GetId())
                {
                    return;
                }
                foreach (var entity in _dicById.Values)
                {
                    if (entity.Color == message.Source.Code)
                    {
                        _colorDic.Remove(entity);
                    }
                }
            });
        }
Exemple #16
0
        public PoolKernelSet(INTMinerRoot root)
        {
            _root = root;
            Global.Access <CoinKernelAddedEvent>(
                Guid.Parse("F39019DF-21F7-40EF-9233-4F7E8291FF39"),
                "新添了币种内核后刷新矿池内核内存",
                LogEnum.Log,
                action: (message) => {
                ICoin coin;
                if (root.CoinSet.TryGetCoin(message.Source.CoinId, out coin))
                {
                    IPool[] pools = root.PoolSet.Where(a => a.CoinId == coin.GetId()).ToArray();
                    foreach (IPool pool in pools)
                    {
                        Guid poolKernelId = Guid.NewGuid();
                        var entity        = new PoolKernelData()
                        {
                            Id          = poolKernelId,
                            Args        = string.Empty,
                            Description = string.Empty,
                            KernelId    = message.Source.KernelId,
                            PoolId      = pool.GetId()
                        };
                        _dicById.Add(poolKernelId, entity);
                        Global.Happened(new PoolKernelAddedEvent(entity));
                    }
                }
            });
            Global.Access <CoinKernelRemovedEvent>(
                Guid.Parse("3FD6D2B4-4C8F-4C81-8E15-2FBA4E730AF7"),
                "移除了币种内核后刷新矿池内核内存",
                LogEnum.Log,
                action: (message) => {
                ICoin coin;
                if (root.CoinSet.TryGetCoin(message.Source.CoinId, out coin))
                {
                    var repository        = NTMinerRoot.CreateServerRepository <PoolKernelData>();
                    List <Guid> toRemoves = new List <Guid>();
                    IPool[] pools         = root.PoolSet.Where(a => a.CoinId == coin.GetId()).ToArray();
                    foreach (IPool pool in pools)
                    {
                        foreach (PoolKernelData poolKernelVm in _dicById.Values.Where(a => a.PoolId == pool.GetId() && a.KernelId == message.Source.KernelId))
                        {
                            toRemoves.Add(poolKernelVm.Id);
                        }
                    }
                    foreach (Guid poolKernelId in toRemoves)
                    {
                        var entity = _dicById[poolKernelId];
                        _dicById.Remove(poolKernelId);
                        repository.Remove(entity.Id);
                        Global.Happened(new PoolKernelRemovedEvent(entity));
                    }
                }
            });
            Global.Access <PoolAddedEvent>(
                Guid.Parse("CDDC4FD4-DC93-4CD3-B814-5A3A99228AB0"),
                "新添了矿池后刷新矿池内核内存",
                LogEnum.Log,
                action: (message) => {
                ICoin coin;
                if (root.CoinSet.TryGetCoin(message.Source.CoinId, out coin))
                {
                    ICoinKernel[] coinKernels = root.CoinKernelSet.Where(a => a.CoinId == coin.GetId()).ToArray();
                    foreach (ICoinKernel coinKernel in coinKernels)
                    {
                        Guid poolKernelId = Guid.NewGuid();
                        var entity        = new PoolKernelData()
                        {
                            Id          = poolKernelId,
                            Args        = string.Empty,
                            Description = string.Empty,
                            KernelId    = coinKernel.KernelId,
                            PoolId      = message.Source.GetId()
                        };
                        _dicById.Add(poolKernelId, entity);
                        Global.Happened(new PoolKernelAddedEvent(entity));
                    }
                }
            });
            Global.Access <PoolRemovedEvent>(
                Guid.Parse("F4B99EAE-2532-4DAC-8D49-2D6A51530722"),
                "移除了矿池后刷新矿池内核内存",
                LogEnum.Log,
                action: (message) => {
                var repository   = NTMinerRoot.CreateServerRepository <PoolKernelData>();
                Guid[] toRemoves = _dicById.Values.Where(a => a.PoolId == message.Source.GetId()).Select(a => a.Id).ToArray();
                foreach (Guid poolKernelId in toRemoves)
                {
                    var entity = _dicById[poolKernelId];
                    _dicById.Remove(poolKernelId);
                    repository.Remove(entity.Id);
                    Global.Happened(new PoolKernelRemovedEvent(entity));
                }
            });
            Global.Access <UpdatePoolKernelCommand>(
                Guid.Parse("08843B3B-3F82-45D2-8B45-6B24F397A326"),
                "更新矿池内核",
                LogEnum.Log,
                action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_root.PoolSet.Contains(message.Input.PoolId))
                {
                    throw new ValidationException("there is no pool with id" + message.Input.PoolId);
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                PoolKernelData entity = _dicById[message.Input.GetId()];
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <PoolKernelData>();
                repository.Update(entity);

                Global.Happened(new PoolKernelUpdatedEvent(entity));
            });
            Global.Logger.InfoDebugLine(this.GetType().FullName + "接入总线");
        }
Exemple #17
0
        public GroupSet(INTMinerRoot root, bool isUseJson)
        {
            _isUseJson = isUseJson;
            _root      = root;
            _root.ServerContextWindow <AddGroupCommand>("添加组", LogEnum.DevConsole,
                                                        action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                if (string.IsNullOrEmpty(message.Input.Name))
                {
                    throw new ValidationException("Group name can't be null or empty");
                }
                GroupData entity = new GroupData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <GroupData>(isUseJson);
                repository.Add(entity);

                VirtualRoot.Happened(new GroupAddedEvent(entity));
            });
            _root.ServerContextWindow <UpdateGroupCommand>("更新组", LogEnum.DevConsole,
                                                           action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Name))
                {
                    throw new ValidationException("Group name can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                GroupData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <GroupData>(isUseJson);
                repository.Update(entity);

                VirtualRoot.Happened(new GroupUpdatedEvent(entity));
            });
            _root.ServerContextWindow <RemoveGroupCommand>("移除组", LogEnum.DevConsole,
                                                           action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                GroupData entity = _dicById[message.EntityId];
                Guid[] toRemoves = root.CoinGroupSet.GetGroupCoinIds(entity.Id).ToArray();
                foreach (var id in toRemoves)
                {
                    VirtualRoot.Execute(new RemoveCoinGroupCommand(id));
                }
                _dicById.Remove(entity.GetId());
                var repository = NTMinerRoot.CreateServerRepository <GroupData>(isUseJson);
                repository.Remove(message.EntityId);

                VirtualRoot.Happened(new GroupRemovedEvent(entity));
            });
        }
Exemple #18
0
        public FileWriterSet(INTMinerRoot root, bool isUseJson)
        {
            _isUseJson = isUseJson;
            _root      = root;
            _root.ServerContextWindow <AddFileWriterCommand>("添加文件书写器", LogEnum.DevConsole,
                                                             action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                if (string.IsNullOrEmpty(message.Input.FileUrl) || string.IsNullOrEmpty(message.Input.Body))
                {
                    throw new ValidationException("FileWriter name and body can't be null or empty");
                }
                FileWriterData entity = new FileWriterData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <FileWriterData>(isUseJson);
                repository.Add(entity);

                VirtualRoot.Happened(new FileWriterAddedEvent(entity));
            });
            _root.ServerContextWindow <UpdateFileWriterCommand>("更新文件书写器", LogEnum.DevConsole,
                                                                action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.FileUrl) || string.IsNullOrEmpty(message.Input.Body))
                {
                    throw new ValidationException("FileWriter name and body can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                FileWriterData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <FileWriterData>(isUseJson);
                repository.Update(entity);

                VirtualRoot.Happened(new FileWriterUpdatedEvent(entity));
            });
            _root.ServerContextWindow <RemoveFileWriterCommand>("移除组", LogEnum.DevConsole,
                                                                action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                FileWriterData entity = _dicById[message.EntityId];
                // TODO:移除内核对文件书写器的引用关系
                _dicById.Remove(entity.GetId());
                var repository = NTMinerRoot.CreateServerRepository <FileWriterData>(isUseJson);
                repository.Remove(message.EntityId);

                VirtualRoot.Happened(new FileWriterRemovedEvent(entity));
            });
        }
Exemple #19
0
        public CoinSet(INTMinerRoot root, bool isUseJson)
        {
            _root      = root;
            _isUseJson = isUseJson;
            _root.ServerContextWindow <AddCoinCommand>("添加币种", LogEnum.DevConsole,
                                                       action: message => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Code))
                {
                    throw new ValidationException("coin code can't be null or empty");
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                if (_dicByCode.ContainsKey(message.Input.Code))
                {
                    throw new ValidationException("编码重复");
                }
                CoinData entity = new CoinData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                _dicByCode.Add(entity.Code, entity);
                var repository = NTMinerRoot.CreateServerRepository <CoinData>(isUseJson);
                repository.Add(entity);

                VirtualRoot.Happened(new CoinAddedEvent(entity));
            });
            _root.ServerContextWindow <UpdateCoinCommand>("更新币种", LogEnum.DevConsole,
                                                          action: message => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Code))
                {
                    throw new ValidationException("coin code can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                CoinData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <CoinData>(isUseJson);
                repository.Update(entity);

                VirtualRoot.Happened(new CoinUpdatedEvent(message.Input));
            });
            _root.ServerContextWindow <RemoveCoinCommand>("移除币种", LogEnum.DevConsole,
                                                          action: message => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                CoinData entity  = _dicById[message.EntityId];
                Guid[] toRemoves = root.PoolSet.Where(a => a.CoinId == entity.Id).Select(a => a.GetId()).ToArray();
                foreach (var id in toRemoves)
                {
                    VirtualRoot.Execute(new RemovePoolCommand(id));
                }
                toRemoves = root.CoinKernelSet.Where(a => a.CoinId == entity.Id).Select(a => a.GetId()).ToArray();
                foreach (var id in toRemoves)
                {
                    VirtualRoot.Execute(new RemoveCoinKernelCommand(id));
                }
                toRemoves = root.MinerProfile.GetWallets().Where(a => a.CoinId == entity.Id).Select(a => a.GetId()).ToArray();
                foreach (var id in toRemoves)
                {
                    VirtualRoot.Execute(new RemoveWalletCommand(id));
                }
                toRemoves = root.CoinGroupSet.Where(a => a.CoinId == entity.Id).Select(a => a.GetId()).ToArray();
                foreach (var id in toRemoves)
                {
                    VirtualRoot.Execute(new RemoveCoinGroupCommand(id));
                }
                _dicById.Remove(entity.Id);
                if (_dicByCode.ContainsKey(entity.Code))
                {
                    _dicByCode.Remove(entity.Code);
                }
                var repository = NTMinerRoot.CreateServerRepository <CoinData>(isUseJson);
                repository.Remove(entity.Id);

                VirtualRoot.Happened(new CoinRemovedEvent(entity));
            });
        }
Exemple #20
0
        public SysDicSet(INTMinerRoot root)
        {
            _root = root;
            Global.Access <AddSysDicCommand>(
                Guid.Parse("9353be1f-707f-455f-ade5-07e081141d47"),
                "添加系统字典",
                LogEnum.Log,
                action: message => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Code))
                {
                    throw new ValidationException("dic code can't be null or empty");
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                if (_dicByCode.ContainsKey(message.Input.Code))
                {
                    throw new DuplicateCodeException();
                }
                SysDicData entity = new SysDicData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                _dicByCode.Add(entity.Code, entity);
                var repository = NTMinerRoot.CreateServerRepository <SysDicData>();
                repository.Add(entity);

                Global.Happened(new SysDicAddedEvent(entity));
            });
            Global.Access <UpdateSysDicCommand>(
                Guid.Parse("b37df2da-ab45-416e-ba58-d703667f300b"),
                "更新系统字典",
                LogEnum.Log,
                action: message => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Code))
                {
                    throw new ValidationException("sysDic code can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                SysDicData entity = _dicById[message.Input.GetId()];
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <SysDicData>();
                repository.Update(entity);

                Global.Happened(new SysDicUpdatedEvent(entity));
            });
            Global.Access <RemoveSysDicCommand>(
                Guid.Parse("ac6af880-89a1-47a4-9596-55e33714db45"),
                "移除系统字典",
                LogEnum.Log,
                action: message => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                SysDicData entity     = _dicById[message.EntityId];
                List <Guid> toRemoves = root.SysDicItemSet.GetSysDicItems(entity.Code).Select(a => a.GetId()).ToList();
                foreach (var id in toRemoves)
                {
                    Global.Execute(new RemoveSysDicItemCommand(id));
                }
                _dicById.Remove(entity.Id);
                if (_dicByCode.ContainsKey(entity.Code))
                {
                    _dicByCode.Remove(entity.Code);
                }
                var repository = NTMinerRoot.CreateServerRepository <SysDicData>();
                repository.Remove(entity.Id);

                Global.Happened(new SysDicRemovedEvent(entity));
            });
            Global.Logger.InfoDebugLine(this.GetType().FullName + "接入总线");
        }
Exemple #21
0
        public SysDicSet(IServerContext context)
        {
            context.AddCmdPath <AddSysDicCommand>("添加系统字典", LogEnum.DevConsole,
                                                  action: message => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Code))
                {
                    throw new ValidationException("dic code can't be null or empty");
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                if (_dicByCode.ContainsKey(message.Input.Code))
                {
                    throw new ValidationException("编码重复");
                }
                SysDicData entity = new SysDicData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                _dicByCode.Add(entity.Code, entity);
                var repository = NTMinerRoot.CreateServerRepository <SysDicData>();
                repository.Add(entity);

                VirtualRoot.RaiseEvent(new SysDicAddedEvent(message.Id, entity));
            }, location: this.GetType());
            context.AddCmdPath <UpdateSysDicCommand>("更新系统字典", LogEnum.DevConsole,
                                                     action: message => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Code))
                {
                    throw new ValidationException("sysDic code can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                SysDicData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <SysDicData>();
                repository.Update(entity);

                VirtualRoot.RaiseEvent(new SysDicUpdatedEvent(message.Id, entity));
            }, location: this.GetType());
            context.AddCmdPath <RemoveSysDicCommand>("移除系统字典", LogEnum.DevConsole,
                                                     action: message => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                SysDicData entity     = _dicById[message.EntityId];
                List <Guid> toRemoves = context.SysDicItemSet.GetSysDicItems(entity.Code).Select(a => a.GetId()).ToList();
                foreach (var id in toRemoves)
                {
                    VirtualRoot.Execute(new RemoveSysDicItemCommand(id));
                }
                _dicById.Remove(entity.Id);
                if (_dicByCode.ContainsKey(entity.Code))
                {
                    _dicByCode.Remove(entity.Code);
                }
                var repository = NTMinerRoot.CreateServerRepository <SysDicData>();
                repository.Remove(entity.Id);

                VirtualRoot.RaiseEvent(new SysDicRemovedEvent(message.Id, entity));
            }, location: this.GetType());
        }
Exemple #22
0
        public FileWriterSet(IServerContext context)
        {
            context.BuildCmdPath <AddFileWriterCommand>("添加文件书写器", LogEnum.DevConsole,
                                                        action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                if (string.IsNullOrEmpty(message.Input.FileUrl) || string.IsNullOrEmpty(message.Input.Body))
                {
                    throw new ValidationException("FileWriter name and body can't be null or empty");
                }
                FileWriterData entity = new FileWriterData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <FileWriterData>();
                repository.Add(entity);

                VirtualRoot.RaiseEvent(new FileWriterAddedEvent(message.Id, entity));
            });
            context.BuildCmdPath <UpdateFileWriterCommand>("更新文件书写器", LogEnum.DevConsole,
                                                           action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.FileUrl) || string.IsNullOrEmpty(message.Input.Body))
                {
                    throw new ValidationException("FileWriter name and body can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                FileWriterData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <FileWriterData>();
                repository.Update(entity);

                VirtualRoot.RaiseEvent(new FileWriterUpdatedEvent(message.Id, entity));
            });
            context.BuildCmdPath <RemoveFileWriterCommand>("移除文件书写器", LogEnum.DevConsole,
                                                           action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                FileWriterData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.GetId());
                var repository = NTMinerRoot.CreateServerRepository <FileWriterData>();
                repository.Remove(message.EntityId);

                VirtualRoot.RaiseEvent(new FileWriterRemovedEvent(message.Id, entity));
            });
        }
Exemple #23
0
        public SysDicItemSet(INTMinerRoot root, bool isUseJson)
        {
            _root      = root;
            _isUseJson = isUseJson;
            _root.ServerContextWindow <AddSysDicItemCommand>("添加系统字典项", LogEnum.DevConsole,
                                                             action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Code))
                {
                    throw new ValidationException("dicitem code can't be null or empty");
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                if (!_dicByDicId.ContainsKey(message.Input.DicId))
                {
                    _dicByDicId.Add(message.Input.DicId, new Dictionary <string, SysDicItemData>(StringComparer.OrdinalIgnoreCase));
                }
                if (_dicByDicId[message.Input.DicId].ContainsKey(message.Input.Code))
                {
                    throw new DuplicateCodeException();
                }
                SysDicItemData entity = new SysDicItemData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                _dicByDicId[message.Input.DicId].Add(entity.Code, entity);
                var repository = NTMinerRoot.CreateServerRepository <SysDicItemData>(isUseJson);
                repository.Add(entity);

                VirtualRoot.Happened(new SysDicItemAddedEvent(entity));
            });
            _root.ServerContextWindow <UpdateSysDicItemCommand>("更新系统字典项", LogEnum.DevConsole,
                                                                action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Code))
                {
                    throw new ValidationException("sysDicItem code can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                SysDicItemData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                string oldCode = entity.Code;
                entity.Update(message.Input);
                // 如果编码变更了
                if (oldCode != entity.Code)
                {
                    _dicByDicId[entity.DicId].Remove(oldCode);
                    _dicByDicId[entity.DicId].Add(entity.Code, entity);
                }
                var repository = NTMinerRoot.CreateServerRepository <SysDicItemData>(isUseJson);
                repository.Update(entity);

                VirtualRoot.Happened(new SysDicItemUpdatedEvent(entity));
            });
            _root.ServerContextWindow <RemoveSysDicItemCommand>("移除系统字典项", LogEnum.DevConsole,
                                                                action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                SysDicItemData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.Id);
                if (_dicByDicId.ContainsKey(entity.DicId))
                {
                    if (_dicByDicId[entity.DicId].ContainsKey(entity.Code))
                    {
                        _dicByDicId[entity.DicId].Remove(entity.Code);
                    }
                }
                var repository = NTMinerRoot.CreateServerRepository <SysDicItemData>(isUseJson);
                repository.Remove(entity.Id);

                VirtualRoot.Happened(new SysDicItemRemovedEvent(entity));
            });
        }
Exemple #24
0
        public CoinKernelSet(INTMinerRoot root)
        {
            _root = root;
            _root.ServerContextWindow <AddCoinKernelCommand>("添加币种内核", LogEnum.DevConsole,
                                                             action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_root.CoinSet.Contains(message.Input.CoinId))
                {
                    throw new ValidationException("there is no coin with id" + message.Input.CoinId);
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                if (_dicById.Values.Any(a => a.CoinId == message.Input.CoinId && a.KernelId == message.Input.KernelId))
                {
                    return;
                }
                CoinKernelData entity = new CoinKernelData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <CoinKernelData>();
                repository.Add(entity);

                VirtualRoot.Happened(new CoinKernelAddedEvent(entity));

                ICoin coin;
                if (root.CoinSet.TryGetCoin(message.Input.CoinId, out coin))
                {
                    IPool[] pools = root.PoolSet.Where(a => a.CoinId == coin.GetId()).ToArray();
                    foreach (IPool pool in pools)
                    {
                        Guid poolKernelId = Guid.NewGuid();
                        var poolKernel    = new PoolKernelData()
                        {
                            Id       = poolKernelId,
                            Args     = string.Empty,
                            KernelId = message.Input.KernelId,
                            PoolId   = pool.GetId()
                        };
                        VirtualRoot.Execute(new AddPoolKernelCommand(poolKernel));
                    }
                }
            });
            _root.ServerContextWindow <UpdateCoinKernelCommand>("更新币种内核", LogEnum.DevConsole,
                                                                action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_root.CoinSet.Contains(message.Input.CoinId))
                {
                    throw new ValidationException("there is no coin with id" + message.Input.CoinId);
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                CoinKernelData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <CoinKernelData>();
                repository.Update(entity);

                VirtualRoot.Happened(new CoinKernelUpdatedEvent(entity));
            });
            _root.ServerContextWindow <RemoveCoinKernelCommand>("移除币种内核", LogEnum.DevConsole,
                                                                action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                CoinKernelData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.Id);
                var repository = NTMinerRoot.CreateServerRepository <CoinKernelData>();
                repository.Remove(entity.Id);

                VirtualRoot.Happened(new CoinKernelRemovedEvent(entity));
                ICoin coin;
                if (root.CoinSet.TryGetCoin(entity.CoinId, out coin))
                {
                    List <Guid> toRemoves = new List <Guid>();
                    IPool[] pools         = root.PoolSet.Where(a => a.CoinId == coin.GetId()).ToArray();
                    foreach (IPool pool in pools)
                    {
                        foreach (PoolKernelData poolKernel in root.PoolKernelSet.Where(a => a.PoolId == pool.GetId() && a.KernelId == entity.KernelId))
                        {
                            toRemoves.Add(poolKernel.Id);
                        }
                    }
                    foreach (Guid poolKernelId in toRemoves)
                    {
                        VirtualRoot.Execute(new RemovePoolKernelCommand(poolKernelId));
                    }
                }
            });
            _root.ServerContextOn <FileWriterRemovedEvent>("移除文件书写器后移除引用关系", LogEnum.DevConsole,
                                                           action: message => {
                var repository = NTMinerRoot.CreateServerRepository <CoinKernelData>();
                var entities   = _dicById.Values.Where(a => a.FileWriterIds.Contains(message.Source.GetId())).ToArray();
                foreach (var entity in entities)
                {
                    entity.FileWriterIds = new List <Guid>(entity.FileWriterIds.Where(a => a != message.Source.GetId()));
                    repository.Update(entity);
                    VirtualRoot.Happened(new CoinKernelUpdatedEvent(entity));
                }
            });
            _root.ServerContextOn <FragmentWriterRemovedEvent>("移除命令行片段书写器后移除引用关系", LogEnum.DevConsole,
                                                               action: message => {
                var repository = NTMinerRoot.CreateServerRepository <CoinKernelData>();
                var entities   = _dicById.Values.Where(a => a.FragmentWriterIds.Contains(message.Source.GetId())).ToArray();
                foreach (var entity in entities)
                {
                    entity.FragmentWriterIds = new List <Guid>(entity.FragmentWriterIds.Where(a => a != message.Source.GetId()));
                    repository.Update(entity);
                    VirtualRoot.Happened(new CoinKernelUpdatedEvent(entity));
                }
            });
        }
Exemple #25
0
        public PackageSet(INTMinerRoot root)
        {
            _root = root;
            _root.ServerContextWindow <AddPackageCommand>("添加包", LogEnum.DevConsole,
                                                          action: message => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Name))
                {
                    throw new ValidationException($"{nameof(message.Input.Name)} can't be null or empty");
                }
                if (_dicById.Values.Any(a => string.Equals(message.Input.Name, a.Name, StringComparison.OrdinalIgnoreCase)))
                {
                    throw new ValidationException("包名重复");
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                PackageData entity = new PackageData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                IRepository <PackageData> repository = NTMinerRoot.CreateServerRepository <PackageData>();
                repository.Add(entity);

                VirtualRoot.Happened(new PackageAddedEvent(entity));
            });
            _root.ServerContextWindow <UpdatePackageCommand>("更新包", LogEnum.DevConsole,
                                                             action: message => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Name))
                {
                    throw new ValidationException($"{nameof(message.Input.Name)} can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                if (_dicById.Values.Any(a => a.Id != message.Input.Id && string.Equals(message.Input.Name, a.Name, StringComparison.OrdinalIgnoreCase)))
                {
                    throw new ValidationException("包名重复");
                }
                PackageData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                IRepository <PackageData> repository = NTMinerRoot.CreateServerRepository <PackageData>();
                repository.Update(entity);

                VirtualRoot.Happened(new PackageUpdatedEvent(entity));
            });
            _root.ServerContextWindow <RemovePackageCommand>("移除包", LogEnum.DevConsole,
                                                             action: message => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                PackageData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.Id);
                IRepository <PackageData> repository = NTMinerRoot.CreateServerRepository <PackageData>();
                repository.Remove(entity.Id);

                VirtualRoot.Happened(new PackageRemovedEvent(entity));
            });
        }
Exemple #26
0
        public KernelSet(IServerContext context)
        {
            context.AddCmdPath <AddKernelCommand>("添加内核", LogEnum.DevConsole,
                                                  action: message => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Code))
                {
                    throw new ValidationException($"{nameof(message.Input.Code)} can't be null or empty");
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelData entity = new KernelData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <KernelData>();
                repository.Add(entity);

                VirtualRoot.RaiseEvent(new KernelAddedEvent(message.Id, entity));
            }, location: this.GetType());
            context.AddCmdPath <UpdateKernelCommand>("更新内核", LogEnum.DevConsole,
                                                     action: message => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Code))
                {
                    throw new ValidationException($"{nameof(message.Input.Code)} can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <KernelData>();
                repository.Update(entity);

                VirtualRoot.RaiseEvent(new KernelUpdatedEvent(message.Id, entity));
            }, location: this.GetType());
            context.AddCmdPath <RemoveKernelCommand>("移除内核", LogEnum.DevConsole,
                                                     action: message => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                KernelData entity         = _dicById[message.EntityId];
                List <Guid> coinKernelIds = context.CoinKernelSet.AsEnumerable().Where(a => a.KernelId == entity.Id).Select(a => a.GetId()).ToList();
                foreach (var coinKernelId in coinKernelIds)
                {
                    VirtualRoot.Execute(new RemoveCoinKernelCommand(coinKernelId));
                }
                _dicById.Remove(entity.Id);
                var repository = NTMinerRoot.CreateServerRepository <KernelData>();
                repository.Remove(entity.Id);

                VirtualRoot.RaiseEvent(new KernelRemovedEvent(message.Id, entity));
            }, location: this.GetType());
        }
        public KernelOutputFilterSet(INTMinerRoot root, bool isUseJson)
        {
            _root      = root;
            _isUseJson = isUseJson;
            _root.ServerContextWindow <AddKernelOutputFilterCommand>("添加内核输出过滤器", LogEnum.DevConsole,
                                                                     action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.RegexPattern))
                {
                    throw new ValidationException($"{nameof(message.Input.RegexPattern)} can't be null or empty");
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelOutputFilterData entity = new KernelOutputFilterData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                if (!_dicByKernelOutputId.ContainsKey(entity.KernelOutputId))
                {
                    _dicByKernelOutputId.Add(entity.KernelOutputId, new List <KernelOutputFilterData>());
                }
                _dicByKernelOutputId[entity.KernelOutputId].Add(entity);
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputFilterData>(isUseJson);
                repository.Add(entity);

                VirtualRoot.Happened(new KernelOutputFilterAddedEvent(entity));
            });
            _root.ServerContextWindow <UpdateKernelOutputFilterCommand>("更新内核输出过滤器", LogEnum.DevConsole,
                                                                        action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.RegexPattern))
                {
                    throw new ValidationException($"{nameof(message.Input.RegexPattern)} can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelOutputFilterData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputFilterData>(isUseJson);
                repository.Update(entity);

                VirtualRoot.Happened(new KernelOutputFilterUpdatedEvent(entity));
            });
            _root.ServerContextWindow <RemoveKernelOutputFilterCommand>("移除内核输出过滤器", LogEnum.DevConsole,
                                                                        action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                KernelOutputFilterData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.Id);
                _dicByKernelOutputId[entity.KernelOutputId].Remove(entity);
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputFilterData>(isUseJson);
                repository.Remove(entity.Id);

                VirtualRoot.Happened(new KernelOutputFilterRemovedEvent(entity));
            });
        }
Exemple #28
0
        public KernelInputSet(INTMinerRoot root, bool isUseJson)
        {
            _root      = root;
            _isUseJson = isUseJson;
            VirtualRoot.Window <AddKernelInputCommand>("添加内核输入组", LogEnum.DevConsole,
                                                       action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelInputData entity = new KernelInputData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <KernelInputData>(isUseJson);
                repository.Add(entity);

                VirtualRoot.Happened(new KernelInputAddedEvent(entity));
            }).AddToCollection(root.ContextHandlers);
            VirtualRoot.Window <UpdateKernelInputCommand>("更新内核输入组", LogEnum.DevConsole,
                                                          action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Name))
                {
                    throw new ValidationException("KernelInput name can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelInputData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <KernelInputData>(isUseJson);
                repository.Update(entity);

                VirtualRoot.Happened(new KernelInputUpdatedEvent(entity));
            }).AddToCollection(root.ContextHandlers);
            VirtualRoot.Window <RemoveKernelInputCommand>("移除内核输入组", LogEnum.DevConsole,
                                                          action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                KernelInputData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.GetId());
                var repository = NTMinerRoot.CreateServerRepository <KernelInputData>(isUseJson);
                repository.Remove(message.EntityId);

                VirtualRoot.Happened(new KernelInputRemovedEvent(entity));
            }).AddToCollection(root.ContextHandlers);
        }
Exemple #29
0
        public CoinKernelSet(INTMinerRoot root)
        {
            _root = root;
            Global.Access <AddCoinKernelCommand>(
                Guid.Parse("6345c411-4860-433b-ad5e-3a743bcebfa8"),
                "添加币种内核",
                LogEnum.Log,
                action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_root.CoinSet.Contains(message.Input.CoinId))
                {
                    throw new ValidationException("there is no coin with id" + message.Input.CoinId);
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                if (_dicById.Values.Any(a => a.CoinId == message.Input.CoinId && a.KernelId == message.Input.KernelId))
                {
                    return;
                }
                CoinKernelData entity = new CoinKernelData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <CoinKernelData>();
                repository.Add(entity);

                Global.Happened(new CoinKernelAddedEvent(entity));
            });
            Global.Access <UpdateCoinKernelCommand>(
                Guid.Parse("b3dfdf09-f732-4b3b-aeeb-25de7b83d30c"),
                "更新币种内核",
                LogEnum.Log,
                action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_root.CoinSet.Contains(message.Input.CoinId))
                {
                    throw new ValidationException("there is no coin with id" + message.Input.CoinId);
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                CoinKernelData entity = _dicById[message.Input.GetId()];
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <CoinKernelData>();
                repository.Update(entity);

                Global.Happened(new CoinKernelUpdatedEvent(entity));
            });
            Global.Access <RemoveCoinKernelCommand>(
                Guid.Parse("ee34113f-e616-421d-adcc-c2e810723035"),
                "移除币种内核",
                LogEnum.Log,
                action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                CoinKernelData entity = _dicById[message.EntityId];
                _dicById.Remove(entity.Id);
                var repository = NTMinerRoot.CreateServerRepository <CoinKernelData>();
                repository.Remove(entity.Id);

                Global.Happened(new CoinKernelRemovedEvent(entity));
            });
            Global.Logger.InfoDebugLine(this.GetType().FullName + "接入总线");
        }
Exemple #30
0
        public KernelOutputSet(INTMinerRoot root, bool isUseJson)
        {
            _root      = root;
            _isUseJson = isUseJson;
            _root.ServerContextWindow <AddKernelOutputCommand>("添加内核输出组", LogEnum.DevConsole,
                                                               action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelOutputData entity = new KernelOutputData().Update(message.Input);
                _dicById.Add(entity.Id, entity);
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputData>(isUseJson);
                repository.Add(entity);

                VirtualRoot.Happened(new KernelOutputAddedEvent(entity));
            });
            _root.ServerContextWindow <UpdateKernelOutputCommand>("更新内核输出组", LogEnum.DevConsole,
                                                                  action: (message) => {
                InitOnece();
                if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (string.IsNullOrEmpty(message.Input.Name))
                {
                    throw new ValidationException("KernelOutput name can't be null or empty");
                }
                if (!_dicById.ContainsKey(message.Input.GetId()))
                {
                    return;
                }
                KernelOutputData entity = _dicById[message.Input.GetId()];
                if (ReferenceEquals(entity, message.Input))
                {
                    return;
                }
                entity.Update(message.Input);
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputData>(isUseJson);
                repository.Update(entity);

                VirtualRoot.Happened(new KernelOutputUpdatedEvent(entity));
            });
            _root.ServerContextWindow <RemoveKernelOutputCommand>("移除内核输出组", LogEnum.DevConsole,
                                                                  action: (message) => {
                InitOnece();
                if (message == null || message.EntityId == Guid.Empty)
                {
                    throw new ArgumentNullException();
                }
                if (!_dicById.ContainsKey(message.EntityId))
                {
                    return;
                }
                IKernel[] outputUsers = root.KernelSet.Where(a => a.KernelOutputId == message.EntityId).ToArray();
                if (outputUsers.Length != 0)
                {
                    throw new ValidationException($"这些内核在使用该内核输出组,删除前请先解除使用:{string.Join(",", outputUsers.Select(a => a.GetFullName()))}");
                }
                KernelOutputData entity               = _dicById[message.EntityId];
                List <Guid> kernelOutputFilterIds     = root.KernelOutputFilterSet.Where(a => a.KernelOutputId == entity.Id).Select(a => a.GetId()).ToList();
                List <Guid> kernelOutputTranslaterIds = root.KernelOutputTranslaterSet.Where(a => a.KernelOutputId == entity.Id).Select(a => a.GetId()).ToList();
                foreach (var kernelOutputFilterId in kernelOutputFilterIds)
                {
                    VirtualRoot.Execute(new RemoveKernelOutputFilterCommand(kernelOutputFilterId));
                }
                foreach (var kernelOutputTranslaterId in kernelOutputTranslaterIds)
                {
                    VirtualRoot.Execute(new RemoveKernelOutputTranslaterCommand(kernelOutputTranslaterId));
                }
                _dicById.Remove(entity.GetId());
                var repository = NTMinerRoot.CreateServerRepository <KernelOutputData>(isUseJson);
                repository.Remove(message.EntityId);

                VirtualRoot.Happened(new KernelOutputRemovedEvent(entity));
            });
        }