Example #1
0
 private void Init()
 {
     lock (_locker) {
         if (!_isInited)
         {
             if (RpcRoot.IsOuterNet)
             {
                 RpcRoot.OfficialServer.UserMinerGroupService.GetMinerGroupsAsync((response, e) => {
                     if (response.IsSuccess())
                     {
                         foreach (var item in response.Data)
                         {
                             _dicById.Add(item.Id, item);
                         }
                     }
                     _isInited = true;
                     VirtualRoot.RaiseEvent(new MinerGroupSetInitedEvent());
                 });
             }
             else
             {
                 var repository = VirtualRoot.CreateLocalRepository <MinerGroupData>();
                 foreach (var item in repository.GetAll())
                 {
                     _dicById.Add(item.Id, item);
                 }
                 _isInited = true;
                 VirtualRoot.RaiseEvent(new MinerGroupSetInitedEvent());
             }
         }
     }
 }
Example #2
0
 protected override void Init()
 {
     if (RpcRoot.IsOuterNet)
     {
         RpcRoot.OfficialServer.UserMineWorkService.GetMineWorksAsync((response, e) => {
             if (response.IsSuccess())
             {
                 foreach (var item in response.Data)
                 {
                     _dicById.Add(item.Id, item);
                 }
             }
             VirtualRoot.RaiseEvent(new MineWorkSetInitedEvent());
         });
     }
     else
     {
         var repository = VirtualRoot.CreateLocalRepository <MineWorkData>();
         foreach (var item in repository.GetAll())
         {
             _dicById.Add(item.Id, item);
         }
         VirtualRoot.RaiseEvent(new MineWorkSetInitedEvent());
     }
 }
Example #3
0
        protected override void Init()
        {
            var repository  = VirtualRoot.CreateLocalRepository <ColumnsShowData>();
            var columnsList = repository.GetAll();

            foreach (var item in columnsList)
            {
                _dicById.Add(item.Id, item);
            }
            if (!_dicById.ContainsKey(ColumnsShowData.PleaseSelect.Id))
            {
                _dicById.Add(ColumnsShowData.PleaseSelect.Id, ColumnsShowData.PleaseSelect);
                repository.Add(ColumnsShowData.PleaseSelect);
            }
        }
Example #4
0
        public void Remove(Guid id)
        {
            InitOnece();
            ColumnsShowData entity;

            lock (_locker) {
                if (_dicById.TryGetValue(id, out entity))
                {
                    _dicById.Remove(id);
                    var repository = VirtualRoot.CreateLocalRepository <ColumnsShowData>();
                    repository.Remove(id);
                }
            }
            if (entity != null)
            {
                VirtualRoot.RaiseEvent(new ColumnsRemovedEvent(Guid.Empty, entity));
            }
        }
Example #5
0
 public void AddOrUpdate(ColumnsShowData data)
 {
     InitOnece();
     lock (_locker) {
         var repository = VirtualRoot.CreateLocalRepository <ColumnsShowData>();
         if (_dicById.TryGetValue(data.Id, out ColumnsShowData entity))
         {
             entity.Update(data);
             repository.Update(entity);
         }
         else
         {
             _dicById.Add(data.Id, data);
             repository.Add(data);
         }
     }
     VirtualRoot.RaiseEvent(new ColumnsShowAddedOrUpdatedEvent(Guid.Empty, data));
 }
Example #6
0
 public MineWorkSet()
 {
     VirtualRoot.BuildEventPath <MinerStudioServiceSwitchedEvent>("切换了群口后台服务类型后刷新内存", LogEnum.DevConsole, path: message => {
         _dicById.Clear();
         base.Refresh();
         // 初始化以触发MineWorkSetInitedEvent事件
         InitOnece();
     }, this.GetType());
     VirtualRoot.BuildCmdPath <AddMineWorkCommand>(path: message => {
         InitOnece();
         if (!_dicById.ContainsKey(message.Input.Id))
         {
             var repository = VirtualRoot.CreateLocalRepository <MineWorkData>();
             var data       = new MineWorkData().Update(message.Input);
             data.CreatedOn = DateTime.Now;
             _dicById.Add(data.Id, data);
             repository.Add(data);
             VirtualRoot.RaiseEvent(new MineWorkAddedEvent(message.MessageId, data));
         }
     }, this.GetType());
     VirtualRoot.BuildCmdPath <UpdateMineWorkCommand>(path: message => {
         InitOnece();
         if (_dicById.TryGetValue(message.Input.Id, out MineWorkData data))
         {
             var repository = VirtualRoot.CreateLocalRepository <MineWorkData>();
             data.Update(message.Input);
             data.ModifiedOn = DateTime.Now;
             repository.Update(data);
             VirtualRoot.RaiseEvent(new MineWorkUpdatedEvent(message.MessageId, data));
         }
     }, this.GetType());
     VirtualRoot.BuildCmdPath <RemoveMineWorkCommand>(path: message => {
         InitOnece();
         if (_dicById.TryGetValue(message.EntityId, out MineWorkData entity))
         {
             _dicById.Remove(message.EntityId);
             var repository = VirtualRoot.CreateLocalRepository <MineWorkData>();
             repository.Remove(message.EntityId);
             MinerStudioPath.DeleteMineWorkFiles(message.EntityId);
             VirtualRoot.RaiseEvent(new MineWorkRemovedEvent(message.MessageId, entity));
         }
     }, this.GetType());
 }
Example #7
0
 public MinerGroupSet()
 {
     VirtualRoot.AddEventPath <MinerStudioServiceSwitchedEvent>("切换了群口后台服务类型后刷新内存", LogEnum.DevConsole, action: message => {
         _dicById.Clear();
         _isInited = false;
         // 初始化以触发MinerGroupSetInitedEvent事件
         InitOnece();
     }, this.GetType());
     VirtualRoot.AddCmdPath <AddMinerGroupCommand>(action: message => {
         InitOnece();
         if (!_dicById.ContainsKey(message.Input.Id))
         {
             var repository = VirtualRoot.CreateLocalRepository <MinerGroupData>();
             var data       = new MinerGroupData().Update(message.Input);
             data.CreatedOn = DateTime.Now;
             _dicById.Add(data.Id, data);
             repository.Add(data);
             VirtualRoot.RaiseEvent(new MinerGroupAddedEvent(message.MessageId, data));
         }
     }, this.GetType());
     VirtualRoot.AddCmdPath <UpdateMinerGroupCommand>(action: message => {
         InitOnece();
         if (_dicById.TryGetValue(message.Input.Id, out MinerGroupData data))
         {
             var repository = VirtualRoot.CreateLocalRepository <MinerGroupData>();
             data.Update(message.Input);
             data.ModifiedOn = DateTime.Now;
             repository.Update(data);
             VirtualRoot.RaiseEvent(new MinerGroupUpdatedEvent(message.MessageId, data));
         }
     }, this.GetType());
     VirtualRoot.AddCmdPath <RemoveMinerGroupCommand>(action: message => {
         InitOnece();
         if (_dicById.TryGetValue(message.EntityId, out MinerGroupData entity))
         {
             _dicById.Remove(message.EntityId);
             var repository = VirtualRoot.CreateLocalRepository <MinerGroupData>();
             repository.Remove(message.EntityId);
             VirtualRoot.RaiseEvent(new MinerGroupRemovedEvent(message.MessageId, entity));
         }
     }, this.GetType());
 }
Example #8
0
 private void Init()
 {
     lock (_locker) {
         if (!_isInited)
         {
             var repository  = VirtualRoot.CreateLocalRepository <ColumnsShowData>();
             var columnsList = repository.GetAll();
             foreach (var item in columnsList)
             {
                 _dicById.Add(item.Id, item);
             }
             if (!_dicById.ContainsKey(ColumnsShowData.PleaseSelect.Id))
             {
                 _dicById.Add(ColumnsShowData.PleaseSelect.Id, ColumnsShowData.PleaseSelect);
                 repository.Add(ColumnsShowData.PleaseSelect);
             }
             _isInited = true;
         }
     }
 }
Example #9
0
 public MineWorkSet()
 {
     VirtualRoot.AddCmdPath <AddMineWorkCommand>(action: message => {
         InitOnece();
         if (!_dicById.ContainsKey(message.Input.Id))
         {
             var repository = VirtualRoot.CreateLocalRepository <MineWorkData>();
             var data       = new MineWorkData().Update(message.Input);
             data.CreatedOn = DateTime.Now;
             _dicById.Add(data.Id, data);
             repository.Add(data);
             VirtualRoot.RaiseEvent(new MineWorkAddedEvent(message.MessageId, data));
         }
     }, this.GetType());
     VirtualRoot.AddCmdPath <UpdateMineWorkCommand>(action: message => {
         InitOnece();
         if (_dicById.TryGetValue(message.Input.Id, out MineWorkData data))
         {
             var repository = VirtualRoot.CreateLocalRepository <MineWorkData>();
             data.Update(message.Input);
             data.ModifiedOn = DateTime.Now;
             repository.Update(data);
             VirtualRoot.RaiseEvent(new MineWorkUpdatedEvent(message.MessageId, data));
         }
     }, this.GetType());
     VirtualRoot.AddCmdPath <RemoveMineWorkCommand>(action: message => {
         InitOnece();
         if (_dicById.TryGetValue(message.EntityId, out MineWorkData entity))
         {
             _dicById.Remove(message.EntityId);
             var repository = VirtualRoot.CreateLocalRepository <MineWorkData>();
             repository.Remove(message.EntityId);
             MinerStudioPath.DeleteMineWorkFiles(message.EntityId);
             VirtualRoot.RaiseEvent(new MineWorkRemovedEvent(message.MessageId, entity));
         }
     }, this.GetType());
 }