コード例 #1
0
        public static Guid GetBrandId(string fileFullName, string keyword)
        {
#if DEBUG
            Write.Stopwatch.Restart();
#endif
            Guid guid = Guid.Empty;
            int  LEN  = keyword.Length;
            if (fileFullName == AppFileFullName)
            {
                Assembly assembly = Assembly.GetEntryAssembly();
                string   name     = $"NTMiner.Brand.{keyword}";
                using (var stream = assembly.GetManifestResourceStream(name)) {
                    if (stream == null)
                    {
                        return(guid);
                    }
                    byte[] data = new byte[stream.Length];
                    stream.Read(data, 0, data.Length);
                    string rawBrand   = Encoding.UTF8.GetString(data);
                    string guidString = rawBrand.Substring(LEN, rawBrand.Length - 2 * LEN);
                    Guid.TryParse(guidString, out guid);
                }
            }
            else
            {
                string rawBrand = $"{keyword}{Guid.Empty}{keyword}";
                byte[] rawData  = Encoding.UTF8.GetBytes(rawBrand);
                int    len      = rawData.Length;
                byte[] source   = File.ReadAllBytes(fileFullName);
                int    index    = 0;
                for (int i = 0; i < source.Length - len; i++)
                {
                    int j = 0;
                    for (; j < len; j++)
                    {
                        if ((j < LEN || j > len - LEN) && source[i + j] != rawData[j])
                        {
                            break;
                        }
                    }
                    if (j == rawData.Length)
                    {
                        index = i;
                        break;
                    }
                }
                string guidString = Encoding.UTF8.GetString(source, index + LEN, len - 2 * LEN);
                Guid.TryParse(guidString, out guid);
            }
#if DEBUG
            Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {typeof(VirtualRoot).Name}.GetBrandId");
#endif
            return(guid);
        }
コード例 #2
0
            private GroupViewModels()
            {
#if DEBUG
                Write.Stopwatch.Restart();
#endif
                this.Add = new DelegateCommand(() => {
                    new GroupViewModel(Guid.NewGuid())
                    {
                        SortNumber = Count + 1
                    }.Edit.Execute(FormType.Add);
                });
                VirtualRoot.BuildEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                        action: message => {
                    _dicById.Clear();
                    Init();
                });
                VirtualRoot.BuildEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                           action: message => {
                    OnPropertyChangeds();
                });
                AppContextEventPath <GroupAddedEvent>("添加了组后调整VM内存", LogEnum.DevConsole,
                                                      action: (message) => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        GroupViewModel groupVm = new GroupViewModel(message.Source);
                        _dicById.Add(message.Source.GetId(), groupVm);
                        OnPropertyChangeds();
                    }
                });
                AppContextEventPath <GroupUpdatedEvent>("更新了组后调整VM内存", LogEnum.DevConsole,
                                                        action: (message) => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        GroupViewModel entity = _dicById[message.Source.GetId()];
                        int sortNumber        = entity.SortNumber;
                        entity.Update(message.Source);
                        if (sortNumber != entity.SortNumber)
                        {
                            this.OnPropertyChanged(nameof(List));
                            OnPropertyChanged(nameof(SelectionOptions));
                        }
                    }
                });
                AppContextEventPath <GroupRemovedEvent>("删除了组后调整VM内存", LogEnum.DevConsole,
                                                        action: (message) => {
                    _dicById.Remove(message.Source.GetId());
                    OnPropertyChangeds();
                });
                Init();
#if DEBUG
                Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
            }
コード例 #3
0
            private KernelOutputFilterViewModels()
            {
#if DEBUG
                Write.Stopwatch.Restart();
#endif
                VirtualRoot.BuildEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                        action: message => {
                    _dicById.Clear();
                    _dicByKernelOutputId.Clear();
                    Init();
                });
                AppContextEventPath <KernelOutputFilterAddedEvent>("添加了内核输出过滤器后刷新VM内存", LogEnum.DevConsole,
                                                                   action: message => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        KernelOutputFilterViewModel vm = new KernelOutputFilterViewModel(message.Source);
                        _dicById.Add(vm.Id, vm);
                        if (AppContext.Instance.KernelOutputVms.TryGetKernelOutputVm(vm.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
                        {
                            if (!_dicByKernelOutputId.ContainsKey(vm.KernelOutputId))
                            {
                                _dicByKernelOutputId.Add(vm.KernelOutputId, new List <KernelOutputFilterViewModel>());
                            }
                            _dicByKernelOutputId[vm.KernelOutputId].Add(vm);
                            kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputFilters));
                        }
                    }
                });
                AppContextEventPath <KernelOutputFilterUpdatedEvent>("更新了内核输出过滤器后刷新VM内存", LogEnum.DevConsole,
                                                                     action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out KernelOutputFilterViewModel vm))
                    {
                        vm.Update(message.Source);
                    }
                });
                AppContextEventPath <KernelOutputFilterRemovedEvent>("删除了内核输出过滤器后刷新VM内存", LogEnum.DevConsole,
                                                                     action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out KernelOutputFilterViewModel vm))
                    {
                        _dicById.Remove(vm.Id);
                        _dicByKernelOutputId[vm.KernelOutputId].Remove(vm);
                        KernelOutputViewModel kernelOutputVm;
                        if (AppContext.Instance.KernelOutputVms.TryGetKernelOutputVm(vm.KernelOutputId, out kernelOutputVm))
                        {
                            kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputFilters));
                        }
                    }
                });
                Init();
#if DEBUG
                Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
            }
コード例 #4
0
            private KernelOutputViewModels()
            {
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
#if DEBUG
                NTStopwatch.Start();
#endif
                VirtualRoot.AddEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                      action: message => {
                    _dicById.Clear();
                    Init();
                }, location: this.GetType());
                VirtualRoot.AddEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                         action: message => {
                    AllPropertyChanged();
                }, location: this.GetType());
                AddEventPath <KernelOutputAddedEvent>("添加了内核输出组后刷新VM内存", LogEnum.DevConsole,
                                                      action: message => {
                    var vm = new KernelOutputViewModel(message.Source);
                    _dicById.Add(message.Source.GetId(), vm);
                    OnPropertyChanged(nameof(AllKernelOutputVms));
                    OnPropertyChanged(nameof(PleaseSelectVms));
                }, location: this.GetType());
                AddEventPath <KernelOutputUpdatedEvent>("更新了内核输出组后刷新VM内存", LogEnum.DevConsole,
                                                        action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out KernelOutputViewModel vm))
                    {
                        if (vm != null)
                        {
                            vm.Update(message.Source);
                        }
                    }
                }, location: this.GetType());
                AddEventPath <KernelOutputRemovedEvent>("移除了内核输出组后刷新VM内存", LogEnum.DevConsole,
                                                        action: message => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Remove(message.Source.GetId());
                        OnPropertyChanged(nameof(AllKernelOutputVms));
                        OnPropertyChanged(nameof(PleaseSelectVms));
                    }
                }, location: this.GetType());
                Init();
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #5
0
            private MineWorkViewModels()
            {
#if DEBUG
                Write.Stopwatch.Start();
#endif
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                foreach (var item in NTMinerRoot.Instance.MineWorkSet.AsEnumerable())
                {
                    _dicById.Add(item.GetId(), new MineWorkViewModel(item));
                }
                this.Add = new DelegateCommand(() => {
                    new MineWorkViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
                });
                BuildEventPath <MineWorkAddedEvent>("添加作业后刷新VM内存", LogEnum.DevConsole,
                                                    action: message => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Add(message.Source.GetId(), new MineWorkViewModel(message.Source));
                        OnPropertyChanged(nameof(List));
                        OnPropertyChanged(nameof(MineWorkVmItems));
                        if (message.Source.GetId() == AppContext.Instance.MinerClientsWindowVm.SelectedMineWork.GetId())
                        {
                            AppContext.Instance.MinerClientsWindowVm.SelectedMineWork = MineWorkViewModel.PleaseSelect;
                        }
                    }
                });
                BuildEventPath <MineWorkUpdatedEvent>("更新作业后刷新VM内存", LogEnum.DevConsole,
                                                      action: message => {
                    _dicById[message.Source.GetId()].Update(message.Source);
                });
                BuildEventPath <MineWorkRemovedEvent>("删除作业后刷新VM内存", LogEnum.DevConsole,
                                                      action: message => {
                    _dicById.Remove(message.Source.GetId());
                    OnPropertyChanged(nameof(List));
                    OnPropertyChanged(nameof(MineWorkVmItems));
                    if (message.Source.GetId() == AppContext.Instance.MinerClientsWindowVm.SelectedMineWork.GetId())
                    {
                        AppContext.Instance.MinerClientsWindowVm.SelectedMineWork = MineWorkViewModel.PleaseSelect;
                    }
                });
#if DEBUG
                var elapsedMilliseconds = Write.Stopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #6
0
            private PoolViewModels()
            {
#if DEBUG
                Write.Stopwatch.Start();
#endif
                VirtualRoot.BuildEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                        action: message => {
                    _dicById.Clear();
                    Init();
                });
                VirtualRoot.BuildEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                           action: message => {
                    OnPropertyChanged(nameof(AllPools));
                });
                BuildEventPath <PoolAddedEvent>("添加矿池后刷新VM内存", LogEnum.DevConsole,
                                                action: (message) => {
                    _dicById.Add(message.Source.GetId(), new PoolViewModel(message.Source));
                    OnPropertyChanged(nameof(AllPools));
                    if (AppContext.Instance.CoinVms.TryGetCoinVm((Guid)message.Source.CoinId, out CoinViewModel coinVm))
                    {
                        coinVm.CoinProfile.OnPropertyChanged(nameof(CoinProfileViewModel.MainCoinPool));
                        coinVm.CoinProfile.OnPropertyChanged(nameof(CoinProfileViewModel.DualCoinPool));
                        coinVm.OnPropertyChanged(nameof(CoinViewModel.Pools));
                        coinVm.OnPropertyChanged(nameof(NTMiner.Vms.CoinViewModel.OptionPools));
                    }
                });
                BuildEventPath <PoolRemovedEvent>("删除矿池后刷新VM内存", LogEnum.DevConsole,
                                                  action: (message) => {
                    _dicById.Remove(message.Source.GetId());
                    OnPropertyChanged(nameof(AllPools));
                    if (AppContext.Instance.CoinVms.TryGetCoinVm(message.Source.CoinId, out CoinViewModel coinVm))
                    {
                        coinVm.CoinProfile.OnPropertyChanged(nameof(CoinProfileViewModel.MainCoinPool));
                        coinVm.CoinProfile.OnPropertyChanged(nameof(CoinProfileViewModel.DualCoinPool));
                        coinVm.OnPropertyChanged(nameof(CoinViewModel.Pools));
                        coinVm.OnPropertyChanged(nameof(CoinViewModel.OptionPools));
                    }
                });
                BuildEventPath <PoolUpdatedEvent>("更新矿池后刷新VM内存", LogEnum.DevConsole,
                                                  action: (message) => {
                    _dicById[message.Source.GetId()].Update(message.Source);
                });
                Init();
#if DEBUG
                var elapsedMilliseconds = Write.Stopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #7
0
            private CoinGroupViewModels()
            {
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
#if DEBUG
                NTStopwatch.Start();
#endif
                VirtualRoot.AddEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                      action: message => {
                    _dicById.Clear();
                    _listByGroupId.Clear();
                    Init();
                }, location: this.GetType());
                AddEventPath <CoinGroupAddedEvent>("添加了币组后调整VM内存", LogEnum.DevConsole,
                                                   action: (message) => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        CoinGroupViewModel coinGroupVm = new CoinGroupViewModel(message.Source);
                        _dicById.Add(message.Source.GetId(), coinGroupVm);
                        if (!_listByGroupId.ContainsKey(coinGroupVm.GroupId))
                        {
                            _listByGroupId.Add(coinGroupVm.GroupId, new List <CoinGroupViewModel>());
                        }
                        _listByGroupId[coinGroupVm.GroupId].Add(coinGroupVm);
                        OnGroupPropertyChanged(coinGroupVm.GroupId);
                    }
                }, location: this.GetType());
                AddEventPath <CoinGroupRemovedEvent>("删除了币组后调整VM内存", LogEnum.DevConsole,
                                                     action: (message) => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        var entity = _dicById[message.Source.GetId()];
                        _dicById.Remove(message.Source.GetId());
                        if (_listByGroupId.ContainsKey(entity.GroupId))
                        {
                            _listByGroupId[entity.GroupId].Remove(entity);
                        }
                        OnGroupPropertyChanged(entity.GroupId);
                    }
                }, location: this.GetType());
                Init();
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #8
0
            private FileWriterViewModels()
            {
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
#if DEBUG
                NTStopwatch.Start();
#endif
                this.Add = new DelegateCommand(() => {
                    new FileWriterViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
                });
                VirtualRoot.AddEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                      action: message => {
                    _dicById.Clear();
                    Init();
                }, location: this.GetType());
                VirtualRoot.AddEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                         action: message => {
                    OnPropertyChangeds();
                }, location: this.GetType());
                AddEventPath <FileWriterAddedEvent>("添加了文件书写器后调整VM内存", LogEnum.DevConsole,
                                                    action: (message) => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        FileWriterViewModel groupVm = new FileWriterViewModel(message.Source);
                        _dicById.Add(message.Source.GetId(), groupVm);
                        OnPropertyChangeds();
                    }
                }, location: this.GetType());
                AddEventPath <FileWriterUpdatedEvent>("更新了文件书写器后调整VM内存", LogEnum.DevConsole,
                                                      action: (message) => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out FileWriterViewModel vm))
                    {
                        vm.Update(message.Source);
                    }
                }, location: this.GetType());
                AddEventPath <FileWriterRemovedEvent>("删除了文件书写器后调整VM内存", LogEnum.DevConsole,
                                                      action: (message) => {
                    _dicById.Remove(message.Source.GetId());
                    OnPropertyChangeds();
                }, location: this.GetType());
                Init();
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #9
0
            private PackageViewModels()
            {
#if DEBUG
                Write.Stopwatch.Start();
#endif
                VirtualRoot.BuildEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                        action: message => {
                    _dicById.Clear();
                    Init();
                });
                VirtualRoot.BuildEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                           action: message => {
                    OnPropertyChanged(nameof(AllPackages));
                });
                BuildEventPath <PackageAddedEvent>("添加了包后调整VM内存", LogEnum.DevConsole,
                                                   action: (message) => {
                    _dicById.Add(message.Source.GetId(), new PackageViewModel(message.Source));
                    OnPropertyChanged(nameof(AllPackages));
                    foreach (var item in AppContext.Instance.KernelVms.AllKernels)
                    {
                        item.OnPropertyChanged(nameof(item.IsPackageValid));
                    }
                });
                BuildEventPath <PackageRemovedEvent>("删除了包后调整VM内存", LogEnum.DevConsole,
                                                     action: message => {
                    _dicById.Remove(message.Source.GetId());
                    OnPropertyChanged(nameof(AllPackages));
                    foreach (var item in AppContext.Instance.KernelVms.AllKernels)
                    {
                        item.OnPropertyChanged(nameof(item.IsPackageValid));
                    }
                });
                BuildEventPath <PackageUpdatedEvent>("更新了包后调整VM内存", LogEnum.DevConsole,
                                                     action: message => {
                    var entity = _dicById[message.Source.GetId()];
                    entity.Update(message.Source);
                    foreach (var item in AppContext.Instance.KernelVms.AllKernels)
                    {
                        item.OnPropertyChanged(nameof(item.IsPackageValid));
                    }
                });
                Init();
#if DEBUG
                var elapsedMilliseconds = Write.Stopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #10
0
            private UserViewModels()
            {
#if DEBUG
                Write.Stopwatch.Start();
#endif
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                this.Add = new DelegateCommand(() => {
                    if (!VirtualRoot.IsMinerStudio)
                    {
                        return;
                    }
                    new UserViewModel().Edit.Execute(FormType.Add);
                });
                BuildEventPath <UserAddedEvent>("添加了用户后", LogEnum.DevConsole,
                                                action: message => {
                    if (!_dicByLoginName.ContainsKey(message.Source.LoginName))
                    {
                        _dicByLoginName.Add(message.Source.LoginName, new UserViewModel(message.Source));
                        OnPropertyChanged(nameof(List));
                    }
                });
                BuildEventPath <UserUpdatedEvent>("更新了用户后", LogEnum.DevConsole,
                                                  action: message => {
                    UserViewModel vm;
                    if (_dicByLoginName.TryGetValue(message.Source.LoginName, out vm))
                    {
                        vm.Update(message.Source);
                    }
                });
                BuildEventPath <UserRemovedEvent>("移除了用户后", LogEnum.DevConsole,
                                                  action: message => {
                    _dicByLoginName.Remove(message.Source.LoginName);
                    OnPropertyChanged(nameof(List));
                });
                foreach (var item in NTMinerRoot.Instance.UserSet.AsEnumerable())
                {
                    _dicByLoginName.Add(item.LoginName, new UserViewModel(item));
                }
#if DEBUG
                var elapsedMilliseconds = Write.Stopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #11
0
            private PoolKernelViewModels()
            {
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
#if DEBUG
                NTStopwatch.Start();
#endif
                AddEventPath <PoolKernelAddedEvent>("新添了矿池内核后刷新矿池内核VM内存", LogEnum.DevConsole,
                                                    action: (message) => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        if (PoolVms.TryGetPoolVm(message.Source.PoolId, out PoolViewModel poolVm))
                        {
                            _dicById.Add(message.Source.GetId(), new PoolKernelViewModel(message.Source));
                            poolVm.OnPropertyChanged(nameof(poolVm.PoolKernels));
                        }
                    }
                }, location: this.GetType());
                AddEventPath <PoolKernelRemovedEvent>("移除了币种内核后刷新矿池内核VM内存", LogEnum.DevConsole,
                                                      action: (message) => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        var vm = _dicById[message.Source.GetId()];
                        _dicById.Remove(message.Source.GetId());
                        if (PoolVms.TryGetPoolVm(vm.PoolId, out PoolViewModel poolVm))
                        {
                            poolVm.OnPropertyChanged(nameof(poolVm.PoolKernels));
                        }
                    }
                }, location: this.GetType());
                AddEventPath <PoolKernelUpdatedEvent>("更新了矿池内核后刷新VM内存", LogEnum.DevConsole,
                                                      action: (message) => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out PoolKernelViewModel vm))
                    {
                        vm.Update(message.Source);
                    }
                }, location: this.GetType());
                Init();
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #12
0
            private WalletViewModels()
            {
#if DEBUG
                Write.Stopwatch.Start();
#endif
                VirtualRoot.BuildEventPath <LocalContextReInitedEvent>("LocalContext刷新后刷新钱包Vm内存", LogEnum.None,
                                                                       action: message => {
                    _dicById.Clear();
                    Init();
                });
                BuildEventPath <WalletAddedEvent>("添加了钱包后调整VM内存", LogEnum.DevConsole,
                                                  action: (message) => {
                    _dicById.Add(message.Source.GetId(), new WalletViewModel(message.Source));
                    OnPropertyChanged(nameof(WalletList));
                    CoinViewModel coin;
                    if (AppContext.Instance.CoinVms.TryGetCoinVm((Guid)message.Source.CoinId, out coin))
                    {
                        coin.OnPropertyChanged(nameof(CoinViewModel.Wallets));
                        coin.OnPropertyChanged(nameof(CoinViewModel.WalletItems));
                        coin.CoinKernel?.CoinKernelProfile?.SelectedDualCoin?.OnPropertyChanged(nameof(CoinViewModel.Wallets));
                    }
                });
                BuildEventPath <WalletRemovedEvent>("删除了钱包后调整VM内存", LogEnum.DevConsole,
                                                    action: (message) => {
                    _dicById.Remove(message.Source.GetId());
                    OnPropertyChanged(nameof(WalletList));
                    CoinViewModel coin;
                    if (AppContext.Instance.CoinVms.TryGetCoinVm((Guid)message.Source.CoinId, out coin))
                    {
                        coin.OnPropertyChanged(nameof(CoinViewModel.Wallets));
                        coin.OnPropertyChanged(nameof(CoinViewModel.WalletItems));
                        coin.CoinProfile?.OnPropertyChanged(nameof(CoinProfileViewModel.SelectedWallet));
                        coin.CoinKernel?.CoinKernelProfile?.SelectedDualCoin?.OnPropertyChanged(nameof(CoinViewModel.Wallets));
                    }
                });
                BuildEventPath <WalletUpdatedEvent>("更新了钱包后调整VM内存", LogEnum.DevConsole,
                                                    action: (message) => {
                    _dicById[message.Source.GetId()].Update(message.Source);
                });
                Init();
#if DEBUG
                var elapsedMilliseconds = Write.Stopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #13
0
            private FragmentWriterViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                this.Add = new DelegateCommand(() => {
                    new FragmentWriterViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
                });
                VirtualRoot.AddEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                      action: message => {
                    _dicById.Clear();
                    Init();
                }, location: this.GetType());
                VirtualRoot.AddEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                         action: message => {
                    OnPropertyChangeds();
                }, location: this.GetType());
                AddEventPath <FragmentWriterAddedEvent>("添加了命令行片段书写器后调整VM内存", LogEnum.DevConsole,
                                                        action: (message) => {
                    if (!_dicById.ContainsKey(message.Target.GetId()))
                    {
                        FragmentWriterViewModel groupVm = new FragmentWriterViewModel(message.Target);
                        _dicById.Add(message.Target.GetId(), groupVm);
                        OnPropertyChangeds();
                    }
                }, location: this.GetType());
                AddEventPath <FragmentWriterUpdatedEvent>("更新了命令行片段书写器后调整VM内存", LogEnum.DevConsole,
                                                          action: (message) => {
                    if (_dicById.ContainsKey(message.Target.GetId()))
                    {
                        FragmentWriterViewModel entity = _dicById[message.Target.GetId()];
                        entity.Update(message.Target);
                    }
                }, location: this.GetType());
                AddEventPath <FragmentWriterRemovedEvent>("删除了命令行片段书写器后调整VM内存", LogEnum.DevConsole,
                                                          action: (message) => {
                    _dicById.Remove(message.Target.GetId());
                    OnPropertyChangeds();
                }, location: this.GetType());
                Init();
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #14
0
            private NTMinerWalletViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                Init(refresh: false);
                AddEventPath <NTMinerWalletSetInitedEvent>("NTMiner钱包集初始化后", LogEnum.DevConsole,
                                                           action: message => {
                    Init(refresh: true);
                }, location: this.GetType());
                this.Add = new DelegateCommand(() => {
                    new NTMinerWalletViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
                });
                AddEventPath <NTMinerWalletAddedEvent>("添加NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                       action: message => {
                    if (!_dicById.ContainsKey(message.Target.GetId()))
                    {
                        _dicById.Add(message.Target.GetId(), new NTMinerWalletViewModel(message.Target));
                        if (AppContext.Instance.CoinVms.TryGetCoinVm(message.Target.CoinId, out CoinViewModel coinVm))
                        {
                            coinVm.OnPropertyChanged(nameof(coinVm.NTMinerWallets));
                        }
                    }
                }, location: this.GetType());
                AddEventPath <NTMinerWalletUpdatedEvent>("更新NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                         action: message => {
                    _dicById[message.Target.GetId()].Update(message.Target);
                }, location: this.GetType());
                AddEventPath <NTMinerWalletRemovedEvent>("删除NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                         action: message => {
                    _dicById.Remove(message.Target.GetId());
                    if (AppContext.Instance.CoinVms.TryGetCoinVm(message.Target.CoinId, out CoinViewModel coinVm))
                    {
                        coinVm.OnPropertyChanged(nameof(coinVm.NTMinerWallets));
                    }
                }, location: this.GetType());
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #15
0
            private DriveSetViewModel()
            {
#if DEBUG
                Write.Stopwatch.Restart();
#endif
                foreach (var item in DriveInfo.GetDrives().Where(a => a.DriveType == DriveType.Fixed))
                {
                    _drives.Add(new DriveViewModel(item));
                }
                this.Apply = new DelegateCommand(() => {
                    AppContext.Instance.VirtualMemorySetVm.SetVirtualMemoryOfDrive();
                });
#if DEBUG
                Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
            }
コード例 #16
0
            public static void CreateProcessAsync(IMineContext mineContext)
            {
                Task.Factory.StartNew(() => {
                    lock (_locker) {
                        try {
#if DEBUG
                            Write.Stopwatch.Restart();
#endif
                            // 清理除当前外的Temp/Kernel
                            Cleaner.Instance.Clear();
#if DEBUG
                            Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {nameof(MinerProcess)}.{nameof(CreateProcessAsync)}[{nameof(Cleaner)}.{nameof(Cleaner.Clear)}]");
#endif
                            Write.UserOk("场地打扫完毕");
                            // 应用超频
                            if (Instance.GpuProfileSet.IsOverClockEnabled(mineContext.MainCoin.GetId()))
                            {
                                Write.UserWarn("应用超频,如果CPU性能较差耗时可能超过1分钟,请耐心等待");
                                var cmd = new CoinOverClockCommand(mineContext.MainCoin.GetId());
                                // N卡超频当cpu性能非常差时较耗时,所以这里弄个回调
                                IMessagePathId callback = null;
                                callback = VirtualRoot.BuildEventPath <CoinOverClockDoneEvent>("超频完成后继续流程", LogEnum.DevConsole,
                                                                                               message => {
                                    if (mineContext != Instance.CurrentMineContext)
                                    {
                                        VirtualRoot.DeletePath(callback);
                                    }
                                    else if (message.CmdId == cmd.Id)
                                    {
                                        VirtualRoot.DeletePath(callback);
                                        ContinueCreateProcess(mineContext);
                                    }
                                });
                                VirtualRoot.Execute(cmd);
                            }
                            else
                            {
                                ContinueCreateProcess(mineContext);
                            }
                        }
                        catch (Exception e) {
                            Logger.ErrorDebugLine(e);
                            Write.UserFail("挖矿内核启动失败,请联系开发人员解决");
                        }
                    }
                });
            }
コード例 #17
0
            private KernelOutputViewModels()
            {
#if DEBUG
                Write.Stopwatch.Restart();
#endif
                VirtualRoot.On <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                            action: message => {
                    _dicById.Clear();
                    Init();
                });
                VirtualRoot.On <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                               action: message => {
                    AllPropertyChanged();
                });
                On <KernelOutputAddedEvent>("添加了内核输出组后刷新VM内存", LogEnum.DevConsole,
                                            action: message => {
                    var vm = new KernelOutputViewModel(message.Source);
                    _dicById.Add(message.Source.GetId(), vm);
                    OnPropertyChanged(nameof(AllKernelOutputVms));
                    OnPropertyChanged(nameof(PleaseSelectVms));
                });
                On <KernelOutputUpdatedEvent>("更新了内核输出组后刷新VM内存", LogEnum.DevConsole,
                                              action: message => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        var item = _dicById[message.Source.GetId()];
                        if (item != null)
                        {
                            item.Update(message.Source);
                        }
                    }
                });
                On <KernelOutputRemovedEvent>("移除了内核输出组后刷新VM内存", LogEnum.DevConsole,
                                              action: message => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Remove(message.Source.GetId());
                        OnPropertyChanged(nameof(AllKernelOutputVms));
                        OnPropertyChanged(nameof(PleaseSelectVms));
                    }
                });
                Init();
#if DEBUG
                Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
            }
コード例 #18
0
            private ShareViewModels()
            {
#if DEBUG
                Write.Stopwatch.Restart();
#endif
                AppContextEventPath <ShareChangedEvent>("收益变更后调整VM内存", LogEnum.DevConsole,
                                                        action: message => {
                    ShareViewModel shareVm;
                    if (_dicByCoinId.TryGetValue(message.Source.CoinId, out shareVm))
                    {
                        shareVm.Update(message.Source);
                    }
                });
#if DEBUG
                Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
            }
コード例 #19
0
            private PoolKernelViewModels()
            {
#if DEBUG
                Write.Stopwatch.Start();
#endif
                BuildEventPath <PoolKernelAddedEvent>("新添了矿池内核后刷新矿池内核VM内存", LogEnum.DevConsole,
                                                      action: (message) => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        PoolViewModel poolVm;
                        if (AppContext.Instance.PoolVms.TryGetPoolVm(message.Source.PoolId, out poolVm))
                        {
                            _dicById.Add(message.Source.GetId(), new PoolKernelViewModel(message.Source));
                            poolVm.OnPropertyChanged(nameof(poolVm.PoolKernels));
                        }
                    }
                });
                BuildEventPath <PoolKernelRemovedEvent>("移除了币种内核后刷新矿池内核VM内存", LogEnum.DevConsole,
                                                        action: (message) => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        var vm = _dicById[message.Source.GetId()];
                        _dicById.Remove(message.Source.GetId());
                        PoolViewModel poolVm;
                        if (AppContext.Instance.PoolVms.TryGetPoolVm(vm.PoolId, out poolVm))
                        {
                            poolVm.OnPropertyChanged(nameof(poolVm.PoolKernels));
                        }
                    }
                });
                BuildEventPath <PoolKernelUpdatedEvent>("更新了矿池内核后刷新VM内存", LogEnum.DevConsole,
                                                        action: (message) => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById[message.Source.GetId()].Update(message.Source);
                    }
                });
                Init();
#if DEBUG
                var elapsedMilliseconds = Write.Stopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #20
0
            private OverClockDataViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                Init(refresh: false);
                AddEventPath <OverClockDataSetInitedEvent>("超频建议集初始化后", LogEnum.DevConsole,
                                                           action: message => {
                    Init(refresh: true);
                }, location: this.GetType());
                AddEventPath <OverClockDataAddedEvent>("添加超频建议后刷新VM内存", LogEnum.DevConsole,
                                                       action: message => {
                    if (!_dicById.ContainsKey(message.Target.GetId()))
                    {
                        _dicById.Add(message.Target.GetId(), new OverClockDataViewModel(message.Target));
                        if (AppContext.Instance.CoinVms.TryGetCoinVm(message.Target.CoinId, out CoinViewModel coinVm))
                        {
                            coinVm.OnPropertyChanged(nameof(coinVm.OverClockDatas));
                        }
                    }
                }, location: this.GetType());
                AddEventPath <OverClockDataUpdatedEvent>("更新超频建议后刷新VM内存", LogEnum.DevConsole,
                                                         action: message => {
                    _dicById[message.Target.GetId()].Update(message.Target);
                }, location: this.GetType());
                AddEventPath <OverClockDataRemovedEvent>("删除超频建议后刷新VM内存", LogEnum.DevConsole,
                                                         action: message => {
                    _dicById.Remove(message.Target.GetId());
                    if (AppContext.Instance.CoinVms.TryGetCoinVm(message.Target.CoinId, out CoinViewModel coinVm))
                    {
                        coinVm.OnPropertyChanged(nameof(coinVm.OverClockDatas));
                    }
                }, location: this.GetType());
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #21
0
            private OverClockDataViewModels()
            {
#if DEBUG
                Write.Stopwatch.Restart();
#endif
                if (Design.IsInDesignMode)
                {
                    return;
                }
                Init(refresh: false);
                On <OverClockDataSetInitedEvent>("超频建议集初始化后", LogEnum.DevConsole,
                                                 action: message => {
                    Init(refresh: true);
                });
                On <OverClockDataAddedEvent>("添加超频建议后刷新VM内存", LogEnum.DevConsole,
                                             action: message => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Add(message.Source.GetId(), new OverClockDataViewModel(message.Source));
                        OnPropertyChanged(nameof(List));
                        CoinViewModel coinVm;
                        if (AppContext.Instance.CoinVms.TryGetCoinVm(message.Source.CoinId, out coinVm))
                        {
                            coinVm.OnPropertyChanged(nameof(coinVm.OverClockDatas));
                        }
                    }
                });
                On <OverClockDataUpdatedEvent>("更新超频建议后刷新VM内存", LogEnum.DevConsole,
                                               action: message => {
                    _dicById[message.Source.GetId()].Update(message.Source);
                });
                On <OverClockDataRemovedEvent>("删除超频建议后刷新VM内存", LogEnum.DevConsole,
                                               action: message => {
                    _dicById.Remove(message.Source.GetId());
                    OnPropertyChanged(nameof(List));
                    CoinViewModel coinVm;
                    if (AppContext.Instance.CoinVms.TryGetCoinVm(message.Source.CoinId, out coinVm))
                    {
                        coinVm.OnPropertyChanged(nameof(coinVm.OverClockDatas));
                    }
                });
#if DEBUG
                Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
            }
コード例 #22
0
            public static void CreateProcessAsync(IMineContext mineContext)
            {
                Task.Factory.StartNew(() => {
                    lock (_locker) {
                        try {
#if DEBUG
                            NTStopwatch.Start();
#endif
                            // 清理除当前外的Temp/Kernel
                            Cleaner.Instance.Clear();
#if DEBUG
                            var elapsedMilliseconds = NTStopwatch.Stop();
                            if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                            {
                                Write.DevTimeSpan($"耗时{elapsedMilliseconds} {nameof(MinerProcess)}.{nameof(CreateProcessAsync)}[{nameof(Cleaner)}.{nameof(Cleaner.Clear)}]");
                            }
#endif
                            Write.UserOk("场地打扫完毕");
                            // 应用超频
                            if (Instance.GpuProfileSet.IsOverClockEnabled(mineContext.MainCoin.GetId()))
                            {
                                Write.UserWarn("应用超频,如果CPU性能较差耗时可能超过1分钟,请耐心等待");
                                var cmd = new CoinOverClockCommand(mineContext.MainCoin.GetId());
                                VirtualRoot.AddOnecePath <CoinOverClockDoneEvent>("超频完成后继续流程", LogEnum.DevConsole,
                                                                                  message => {
                                    if (mineContext == Instance.LockedMineContext)
                                    {
                                        ContinueCreateProcess(mineContext);
                                    }
                                }, location: typeof(MinerProcess), pathId: cmd.Id);
                                // 超频是在另一个线程执行的,因为N卡超频当cpu性能非常差时较耗时
                                VirtualRoot.Execute(cmd);
                            }
                            else
                            {
                                ContinueCreateProcess(mineContext);
                            }
                        }
                        catch (Exception e) {
                            Logger.ErrorDebugLine(e);
                            Write.UserFail("挖矿内核启动失败,请联系开发人员解决");
                        }
                    }
                });
            }
コード例 #23
0
            private MinerGroupViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                foreach (var item in NTMinerRoot.Instance.MinerGroupSet.AsEnumerable())
                {
                    _dicById.Add(item.GetId(), new MinerGroupViewModel(item));
                }
                this.Add = new DelegateCommand(() => {
                    new MinerGroupViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
                });
                AddEventPath <MinerGroupAddedEvent>("添加矿机分组后刷新VM内存", LogEnum.DevConsole,
                                                    action: message => {
                    if (!_dicById.ContainsKey(message.Target.GetId()))
                    {
                        _dicById.Add(message.Target.GetId(), new MinerGroupViewModel(message.Target));
                        OnPropertyChanged(nameof(List));
                        OnPropertyChanged(nameof(MinerGroupItems));
                        AppContext.Instance.MinerClientsWindowVm.OnPropertyChanged(nameof(MinerClientsWindowViewModel.SelectedMinerGroup));
                    }
                }, location: this.GetType());
                AddEventPath <MinerGroupUpdatedEvent>("更新矿机分组后刷新VM内存", LogEnum.DevConsole,
                                                      action: message => {
                    _dicById[message.Target.GetId()].Update(message.Target);
                }, location: this.GetType());
                AddEventPath <MinerGroupRemovedEvent>("删除矿机分组后刷新VM内存", LogEnum.DevConsole,
                                                      action: message => {
                    _dicById.Remove(message.Target.GetId());
                    OnPropertyChanged(nameof(List));
                    OnPropertyChanged(nameof(MinerGroupItems));
                    AppContext.Instance.MinerClientsWindowVm.OnPropertyChanged(nameof(MinerClientsWindowViewModel.SelectedMinerGroup));
                }, location: this.GetType());
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #24
0
            private FileWriterViewModels()
            {
#if DEBUG
                Write.Stopwatch.Restart();
#endif
                this.Add = new DelegateCommand(() => {
                    new FileWriterViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
                });
                VirtualRoot.On <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                            action: message => {
                    _dicById.Clear();
                    Init();
                });
                VirtualRoot.On <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                               action: message => {
                    OnPropertyChangeds();
                });
                On <FileWriterAddedEvent>("添加了文件书写器后调整VM内存", LogEnum.DevConsole,
                                          action: (message) => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        FileWriterViewModel groupVm = new FileWriterViewModel(message.Source);
                        _dicById.Add(message.Source.GetId(), groupVm);
                        OnPropertyChangeds();
                    }
                });
                On <FileWriterUpdatedEvent>("更新了文件书写器后调整VM内存", LogEnum.DevConsole,
                                            action: (message) => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        FileWriterViewModel entity = _dicById[message.Source.GetId()];
                        entity.Update(message.Source);
                    }
                });
                On <FileWriterRemovedEvent>("删除了文件书写器后调整VM内存", LogEnum.DevConsole,
                                            action: (message) => {
                    _dicById.Remove(message.Source.GetId());
                    OnPropertyChangeds();
                });
                Init();
#if DEBUG
                Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
            }
コード例 #25
0
            private ColumnsShowViewModels()
            {
#if DEBUG
                Write.Stopwatch.Start();
#endif
                this.Add = new DelegateCommand(() => {
                    new ColumnsShowViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
                });
                BuildEventPath <ColumnsShowAddedEvent>("添加了列显后刷新VM内存", LogEnum.DevConsole,
                                                       action: message => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        ColumnsShowViewModel vm = new ColumnsShowViewModel(message.Source);
                        _dicById.Add(message.Source.GetId(), vm);
                        OnPropertyChanged(nameof(List));
                        AppContext.Instance.MinerClientsWindowVm.ColumnsShow = vm;
                    }
                });
                BuildEventPath <ColumnsShowUpdatedEvent>("更新了列显后刷新VM内存", LogEnum.DevConsole,
                                                         action: message => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        ColumnsShowViewModel entity = _dicById[message.Source.GetId()];
                        entity.Update(message.Source);
                    }
                });
                BuildEventPath <ColumnsShowRemovedEvent>("移除了列显后刷新VM内存", LogEnum.DevConsole,
                                                         action: message => {
                    AppContext.Instance.MinerClientsWindowVm.ColumnsShow = _dicById.Values.FirstOrDefault();
                    _dicById.Remove(message.Source.GetId());
                    OnPropertyChanged(nameof(List));
                });
                foreach (var item in NTMinerRoot.Instance.ColumnsShowSet.AsEnumerable())
                {
                    _dicById.Add(item.GetId(), new ColumnsShowViewModel(item));
                }
#if DEBUG
                var elapsedMilliseconds = Write.Stopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #26
0
            private ShareViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                AddEventPath <ShareChangedEvent>("收益变更后调整VM内存", LogEnum.DevConsole,
                                                 action: message => {
                    if (_dicByCoinId.TryGetValue(message.Target.CoinId, out ShareViewModel shareVm))
                    {
                        shareVm.Update(message.Target);
                    }
                }, location: this.GetType());
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
コード例 #27
0
            private PoolProfileViewModels()
            {
#if DEBUG
                Write.Stopwatch.Restart();
#endif
                AppContextEventPath <PoolProfilePropertyChangedEvent>("矿池设置变更后刷新VM内存", LogEnum.DevConsole,
                                                                      action: message => {
                    if (_dicById.TryGetValue(message.PoolId, out PoolProfileViewModel vm))
                    {
                        vm.OnPropertyChanged(message.PropertyName);
                    }
                });
                VirtualRoot.BuildEventPath <LocalContextReInitedEvent>("LocalContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                       action: message => {
                    _dicById.Clear();
                });
#if DEBUG
                Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
            }
コード例 #28
0
            private void Init()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                lock (_locker) {
                    if (!_isInited)
                    {
                        _isInited = true;
                        _localIps = GetLocalIps();
                        RaiseEvent(new LocalIpSetInitedEvent());
                    }
                }
#if DEBUG
                // 将近300毫秒
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.{nameof(Init)}");
                }
#endif
            }
コード例 #29
0
            private CoinSnapshotDataViewModels()
            {
#if DEBUG
                Write.Stopwatch.Restart();
#endif
                foreach (var coinVm in AppContext.Instance.CoinVms.AllCoins)
                {
                    _dicByCoinCode.Add(coinVm.Code, new CoinSnapshotDataViewModel(new MinerServer.CoinSnapshotData {
                        CoinCode            = coinVm.Code,
                        MainCoinMiningCount = 0,
                        MainCoinOnlineCount = 0,
                        DualCoinMiningCount = 0,
                        DualCoinOnlineCount = 0,
                        ShareDelta          = 0,
                        RejectShareDelta    = 0,
                        Speed     = 0,
                        Timestamp = DateTime.MinValue
                    }));
                }
#if DEBUG
                Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
            }
コード例 #30
0
            private PoolProfileViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                AddEventPath <PoolProfilePropertyChangedEvent>("矿池设置变更后刷新VM内存", LogEnum.DevConsole,
                                                               action: message => {
                    if (_dicById.TryGetValue(message.PoolId, out PoolProfileViewModel vm))
                    {
                        vm.OnPropertyChanged(message.PropertyName);
                    }
                }, location: this.GetType());
                VirtualRoot.AddEventPath <LocalContextReInitedEvent>("LocalContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                     action: message => {
                    _dicById.Clear();
                }, location: this.GetType());
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }