public WalletSet(INTMinerRoot root) { _root = root; Global.Access <AddWalletCommand>( Guid.Parse("d050de9d-7356-471b-b9c7-19d685aa770a"), "添加钱包", 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 not coin with id " + message.Input.CoinId); } if (string.IsNullOrEmpty(message.Input.Address)) { throw new ValidationException("wallet code and Address can't be null or empty"); } if (_dicById.ContainsKey(message.Input.GetId())) { return; } WalletData entity = new WalletData().Update(message.Input); _dicById.Add(entity.Id, entity); AddWallet(entity); Global.Happened(new WalletAddedEvent(entity)); }); Global.Access <UpdateWalletCommand>( Guid.Parse("658f0e61-8c86-493f-a147-d66da2ed194d"), "更新钱包", 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 not coin with id " + message.Input.CoinId); } if (string.IsNullOrEmpty(message.Input.Address)) { throw new ValidationException("wallet Address can't be null or empty"); } if (string.IsNullOrEmpty(message.Input.Name)) { throw new ValidationException("wallet name can't be null or empty"); } if (!_dicById.ContainsKey(message.Input.GetId())) { return; } WalletData entity = _dicById[message.Input.GetId()]; entity.Update(message.Input); UpdateWallet(entity); Global.Happened(new WalletUpdatedEvent(entity)); }); Global.Access <RemoveWalletCommand>( Guid.Parse("bd70fe34-7575-43d0-a8e5-d8e9566d8d56"), "移除钱包", LogEnum.Log, action: (message) => { InitOnece(); if (message == null || message.EntityId == Guid.Empty) { throw new ArgumentNullException(); } if (!_dicById.ContainsKey(message.EntityId)) { return; } WalletData entity = _dicById[message.EntityId]; _dicById.Remove(entity.GetId()); RemoveWallet(entity.Id); Global.Happened(new WalletRemovedEvent(entity)); }); BootLog.Log(this.GetType().FullName + "接入总线"); }
public WalletSet(INTMinerRoot root) { _root = root; VirtualRoot.AddCmdPath <AddWalletCommand>(action: message => { InitOnece(); if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty) { throw new ArgumentNullException(); } if (!_root.ServerContext.CoinSet.Contains(message.Input.CoinId)) { throw new ValidationException("there is not coin with id " + message.Input.CoinId); } if (string.IsNullOrEmpty(message.Input.Address)) { throw new ValidationException("wallet code and Address can't be null or empty"); } if (_dicById.ContainsKey(message.Input.GetId())) { return; } WalletData entity = new WalletData().Update(message.Input); _dicById.Add(entity.Id, entity); AddWallet(entity); VirtualRoot.RaiseEvent(new WalletAddedEvent(message.Id, entity)); }, location: this.GetType()); VirtualRoot.AddCmdPath <UpdateWalletCommand>(action: message => { InitOnece(); if (message == null || message.Input == null || message.Input.GetId() == Guid.Empty) { throw new ArgumentNullException(); } if (!_root.ServerContext.CoinSet.Contains(message.Input.CoinId)) { throw new ValidationException("there is not coin with id " + message.Input.CoinId); } if (string.IsNullOrEmpty(message.Input.Address)) { throw new ValidationException("wallet Address can't be null or empty"); } if (string.IsNullOrEmpty(message.Input.Name)) { throw new ValidationException("wallet name can't be null or empty"); } if (!_dicById.ContainsKey(message.Input.GetId())) { return; } WalletData entity = _dicById[message.Input.GetId()]; entity.Update(message.Input); UpdateWallet(entity); VirtualRoot.RaiseEvent(new WalletUpdatedEvent(message.Id, entity)); }, location: this.GetType()); VirtualRoot.AddCmdPath <RemoveWalletCommand>(action: (message) => { InitOnece(); if (message == null || message.EntityId == Guid.Empty) { throw new ArgumentNullException(); } if (!_dicById.ContainsKey(message.EntityId)) { return; } WalletData entity = _dicById[message.EntityId]; _dicById.Remove(entity.GetId()); RemoveWallet(entity.Id); VirtualRoot.RaiseEvent(new WalletRemovedEvent(message.Id, entity)); }, location: this.GetType()); }
public WalletSet(INTMinerRoot root) { _root = root; VirtualRoot.Window <AddWalletCommand>("添加钱包", 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 not coin with id " + message.Input.CoinId); } if (string.IsNullOrEmpty(message.Input.Address)) { throw new ValidationException("wallet code and Address can't be null or empty"); } if (_dicById.ContainsKey(message.Input.GetId())) { return; } WalletData entity = new WalletData().Update(message.Input); _dicById.Add(entity.Id, entity); AddWallet(entity); VirtualRoot.Happened(new WalletAddedEvent(entity)); }); VirtualRoot.Window <UpdateWalletCommand>("更新钱包", 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 not coin with id " + message.Input.CoinId); } if (string.IsNullOrEmpty(message.Input.Address)) { throw new ValidationException("wallet Address can't be null or empty"); } if (string.IsNullOrEmpty(message.Input.Name)) { throw new ValidationException("wallet name can't be null or empty"); } if (!_dicById.ContainsKey(message.Input.GetId())) { return; } WalletData entity = _dicById[message.Input.GetId()]; entity.Update(message.Input); UpdateWallet(entity); VirtualRoot.Happened(new WalletUpdatedEvent(entity)); }); VirtualRoot.Window <RemoveWalletCommand>("移除钱包", LogEnum.DevConsole, action: (message) => { InitOnece(); if (message == null || message.EntityId == Guid.Empty) { throw new ArgumentNullException(); } if (!_dicById.ContainsKey(message.EntityId)) { return; } WalletData entity = _dicById[message.EntityId]; _dicById.Remove(entity.GetId()); RemoveWallet(entity.Id); VirtualRoot.Happened(new WalletRemovedEvent(entity)); }); }