protected override void OnOpen()
 {
     base.OnOpen();
     if (AppRoot.TryGetUser(this.Context.User.Identity.Name, out WsUserName userName, out UserData userData, out string _))
     {
         AppRoot.AddMinerStudioSession(userName, userData, this.Context.UserEndPoint, this);
     }
Ejemplo n.º 2
0
 internal static ReportResponse DoReportSpeed(SpeedDto speedDto, string minerIp)
 {
     try {
         if (speedDto == null)
         {
             return(ResponseBase.InvalidInput <ReportResponse>());
         }
         AppRoot.ClientDataSet.ReportSpeed(speedDto, minerIp, isFromWsServerNode: false);
         if (Version.TryParse(speedDto.Version, out Version version))
         {
             string jsonVersionKey = HomePath.GetServerJsonVersion(version);
             var    response       = ReportResponse.Ok(AppRoot.GetServerStateResponse(jsonVersionKey));
             if (speedDto.LocalServerMessageTimestamp.AddSeconds(1) < AppRoot.ServerMessageTimestamp)
             {
                 var list = AppRoot.ServerMessageSet.GetServerMessages(speedDto.LocalServerMessageTimestamp);
                 // 如果服务器新消息少于10条直接在上报算力时的响应消息中携带上,如果较多就算了推迟到用户切换到消息界面查看时再获取
                 if (list.Count < 10)
                 {
                     response.NewServerMessages.AddRange(list);
                 }
             }
             return(response);
         }
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
     return(ResponseBase.InvalidInput <ReportResponse>());
 }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        GameObject appRootObject = GameObject.FindWithTag("AppRoot");

        if (appRootObject != null)
        {
            appRoot = appRootObject.GetComponent <AppRoot>();
        }
        if (appRootObject == null)
        {
            Debug.Log("Cannot find 'AppRoot' script"); Application.Quit();
        }

        GameObject playerControllerObject = GameObject.FindWithTag("Player");

        if (playerControllerObject != null)
        {
            playerController = playerControllerObject.GetComponent <PlayerController>();
        }
        if (playerControllerObject == null)
        {
            Debug.Log("Cannot find 'PlayerController' script"); Application.Quit();
        }

        maxRoomNumber = ((uint)appRoot.beacons.Length) - 1;
        currentRoom   = 0;
        Teleportation(currentRoom);
    }
Ejemplo n.º 4
0
 public SharpWsServerAdapter(IHostConfig config)
 {
     _wsServer = new WebSocketServer($"ws://0.0.0.0:{config.GetServerPort().ToString()}")
     {
         KeepClean             = true,
         AuthenticationSchemes = AuthenticationSchemes.Basic, // 用基本验证字段承载签名信息,因为传输的并非原始密码,所以虽然是基本验证但不存在安全问题
         UserCredentialsFinder = id => {
             string base64String = id.Name;
             if (!AppRoot.TryGetUser(base64String, out WsUserName wsUserName, out UserData userData, out string _))
             {
                 return(null);
             }
             var password = HashUtil.Sha1(base64String + AppRoot.GetUserPassword(wsUserName, userData));
             // 经验证username对于基本验证来说没有用
             return(new NetworkCredential(userData.LoginName, password, domain: null, roles: wsUserName.ClientType.GetName()));
         }
     };
     //_wsServer.Log.Level = WebSocketSharp.LogLevel.Debug;
     _wsServer.Log.File   = Path.Combine(HomePath.HomeLogsDirFullName, NTKeyword.WebSocketSharpMinerStudioLogFileName);
     _wsServer.Log.Output = (data, path) => {
         Console.WriteLine(data.Message);
         if (path != null && path.Length > 0)
         {
             using (var writer = new StreamWriter(path, true))
                 using (var syncWriter = TextWriter.Synchronized(writer)) {
                     syncWriter.WriteLine(data.ToString());
                 }
         }
     };
     _wsServer.AddWebSocketService <MinerClientSharpWsSessionAdapter>(AppRoot.MinerClientPath);
     _wsServer.AddWebSocketService <MinerStudioSharpWsSessionAdapter>(AppRoot.MinerStudioPath);
     MinerClientWsSessions = new SharpWsSessionsAdapter(_wsServer.WebSocketServices[AppRoot.MinerClientPath].Sessions);
     MinerStudioWsSessions = new SharpWsSessionsAdapter(_wsServer.WebSocketServices[AppRoot.MinerStudioPath].Sessions);
 }
Ejemplo n.º 5
0
 public void ShowMainWindow(bool isToggle, out Window mainWindow)
 {
     if (_mainWindow == null)
     {
         lock (_locker) {
             if (_mainWindow == null)
             {
                 _mainWindow = CreateMainWindow();
                 NTMinerContext.RefreshArgsAssembly.Invoke("主界面创建后");
                 _mainWindow.Show();
             }
         }
     }
     else
     {
         AppRoot.Enable();
         bool needActive = _mainWindow.WindowState != WindowState.Minimized;
         _mainWindow.ShowWindow(isToggle);
         if (needActive)
         {
             _mainWindow.Activate();
         }
     }
     mainWindow = _mainWindow;
 }
Ejemplo n.º 6
0
        private void trvDeparts_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            TreeViewItem trv        = (TreeViewItem)trvDeparts.SelectedItem;
            string       depPrjMark = trv.Header.ToString().Split(" ").Last();

            departSelected = Conn.Db.Depart.Where(d => d.PrjMark == depPrjMark).FirstOrDefault();


            if (departSelected.Scheme == null)
            {
                return;
            }
            string svgPath = $"{AppRoot.GetApplicationRoot()}SVG\\{departSelected.Scheme}.svg";

            if (File.Exists(svgPath))
            {
                lblDepartInfo.Content = $"{departSelected.Name} {departSelected.PrjMark}";
                svgViewBox.Source     = new Uri(svgPath);
                Conn.Db.Entry(departSelected).Collection(u => u.Point).Load();
                svgCanvas.Children.Clear();
                svgCanvas.Height = svgViewBox.ActualHeight;
                foreach (Models.Point point in departSelected.Point)
                {
                    drawPoint((double)point.PosX, (double)point.PosY, point.Id, svgCanvas);
                }
            }
        }
Ejemplo n.º 7
0
 public void SaveCalcConfigs(List <CalcConfigData> data)
 {
     InitOnece();
     if (data == null || data.Count == 0)
     {
         return;
     }
     lock (_dicByCode) {
         var dic = new Dictionary <string, CalcConfigData>(StringComparer.OrdinalIgnoreCase);
         foreach (var item in data)
         {
             if (dic.TryGetValue(item.CoinCode, out CalcConfigData entity))
             {
                 entity.Update(item);
             }
             else
             {
                 dic.Add(item.CoinCode, item);
             }
         }
         using (LiteDatabase db = AppRoot.CreateLocalDb()) {
             var col = db.GetCollection <CalcConfigData>();
             col.Delete(Query.All());
             col.Insert(dic.Values);
         }
         _dicByCode = dic;
     }
 }
Ejemplo n.º 8
0
        public void SetAppSetting(UserAppSettingData appSetting)
        {
            InitOnece();
            if (appSetting == null || string.IsNullOrEmpty(appSetting.LoginName))
            {
                return;
            }
            if (!_dicByLoginName.TryGetValue(appSetting.LoginName, out List <UserAppSettingData> list))
            {
                list = new List <UserAppSettingData>();
                _dicByLoginName.Add(appSetting.LoginName, list);
            }
            var exist = list.FirstOrDefault(a => a.Key == appSetting.Key);

            if (exist != null)
            {
                exist.Value = appSetting.Value;
            }
            else
            {
                list.Add(appSetting);
            }
            using (LiteDatabase db = AppRoot.CreateLocalDb()) {
                var col = db.GetCollection <UserAppSettingData>();
                col.Upsert(exist);
            }
        }
Ejemplo n.º 9
0
 private MineWorkViewModels()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     foreach (var item in NTMinerContext.MinerStudioContext.MineWorkSet.AsEnumerable())
     {
         if (!_dicById.ContainsKey(item.Id))
         {
             _dicById.Add(item.Id, new MineWorkViewModel(item));
         }
     }
     AppRoot.BuildEventPath <MineWorkSetInitedEvent>("作业集初始化后初始化Vm内存", LogEnum.DevConsole, path: message => {
         _dicById.Clear();
         foreach (var item in NTMinerContext.MinerStudioContext.MineWorkSet.AsEnumerable())
         {
             if (!_dicById.ContainsKey(item.Id))
             {
                 _dicById.Add(item.Id, new MineWorkViewModel(item));
             }
         }
         OnPropertyChangeds();
         MinerClientsWindowViewModel.Instance.RefreshMinerClientsSelectedMineWork(MinerClientsWindowViewModel.Instance.MinerClients.ToArray());
     }, this.GetType());
     this.Add = new DelegateCommand(() => {
         new MineWorkViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
     });
     AppRoot.BuildEventPath <MineWorkAddedEvent>("添加作业后刷新VM内存", LogEnum.DevConsole,
                                                 path: message => {
         if (!_dicById.TryGetValue(message.Source.GetId(), out MineWorkViewModel vm))
         {
             vm = new MineWorkViewModel(message.Source);
             _dicById.Add(message.Source.GetId(), vm);
             OnPropertyChangeds();
             if (message.Source.GetId() == MinerClientsWindowVm.SelectedMineWork.GetId())
             {
                 MinerClientsWindowVm.SelectedMineWork = MineWorkViewModel.PleaseSelect;
             }
         }
     }, location: this.GetType());
     AppRoot.BuildEventPath <MineWorkUpdatedEvent>("添加作业后刷新VM内存", LogEnum.DevConsole,
                                                   path: message => {
         if (_dicById.TryGetValue(message.Source.GetId(), out MineWorkViewModel vm))
         {
             vm.Update(message.Source);
         }
     }, location: this.GetType());
     AppRoot.BuildEventPath <MineWorkRemovedEvent>("移除了作业后刷新Vm内存", LogEnum.DevConsole, path: message => {
         if (_dicById.TryGetValue(message.Source.Id, out MineWorkViewModel vm))
         {
             _dicById.Remove(vm.Id);
             OnPropertyChangeds();
             if (vm.Id == MinerClientsWindowVm.SelectedMineWork.GetId())
             {
                 MinerClientsWindowVm.SelectedMineWork = MineWorkViewModel.PleaseSelect;
             }
         }
     }, this.GetType());
 }
Ejemplo n.º 10
0
        private void SetServerMessageTimestamp()
        {
            DateTime timestamp = DateTime.MinValue;

            if (_linkedList.Count != 0)
            {
                timestamp = _linkedList.First.Value.Timestamp;
            }
            AppRoot.SetServerMessageTimestamp(timestamp);
        }
Ejemplo n.º 11
0
 protected override void Init()
 {
     using (LiteDatabase db = AppRoot.CreateLocalDb()) {
         var col = db.GetCollection <CalcConfigData>();
         foreach (var item in col.FindAll())
         {
             _dicByCode.Add(item.CoinCode, item);
         }
     }
 }
Ejemplo n.º 12
0
 protected override void Init()
 {
     using (LiteDatabase db = AppRoot.CreateLocalDb()) {
         var col = db.GetCollection <UserMineWorkData>();
         foreach (var item in col.FindAll())
         {
             _dicById.Add(item.Id, item);
         }
     }
 }
Ejemplo n.º 13
0
        public static string AppCoverUrl(string url)
        {
            if (String.IsNullOrEmpty(url))
            {
                return(String.Empty);
            }

            url = string.Format("{0}/{1}", AppRoot.TrimEnd('/'), url.TrimStart('~').TrimStart('/'));
            return(url);
        }
Ejemplo n.º 14
0
 private void btnChoosePoint_Click(object sender, RoutedEventArgs e)
 {
     //SaveToPng(svgViewBox.DrawingCanvas);
     svgCanvas.Children.Clear();
     drawPoint((double)pointSelected.PosX, (double)pointSelected.PosY, pointSelected.Id, svgCanvas);
     (svgCanvas.Children[0] as Ellipse).Stroke = Brushes.Red;
     (svgCanvas.Children[0] as Ellipse).Fill   = Brushes.Red;
     CreateSaveBitmap(svgViewBox.DrawingCanvas, svgCanvas, $"{AppRoot.GetApplicationRoot()}PNG\\{pointSelected.Id}.png");
     cameFrom.updatePoint(pointSelected);
     NavigationService.GoBack();
 }
Ejemplo n.º 15
0
        public QueryActionCountsResponse QueryActionCounts([FromBody] QueryActionCountsRequest request)
        {
            if (request == null)
            {
                return(ResponseBase.InvalidInput <QueryActionCountsResponse>("参数错误"));
            }
            request.PagingTrim();
            var data = AppRoot.QueryActionCounts(request, out int total);

            return(QueryActionCountsResponse.Ok(data, total));
        }
Ejemplo n.º 16
0
 private MinerGroupViewModels()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     foreach (var item in NTMinerContext.MinerStudioContext.MinerGroupSet.AsEnumerable().ToArray())
     {
         if (!_dicById.ContainsKey(item.Id))
         {
             _dicById.Add(item.Id, new MinerGroupViewModel(item));
         }
     }
     AppRoot.BuildEventPath <MinerGroupSetInitedEvent>("矿工组集初始化后初始化Vm内存", LogEnum.DevConsole, this.GetType(), PathPriority.Normal, path: message => {
         _dicById.Clear();
         foreach (var item in NTMinerContext.MinerStudioContext.MinerGroupSet.AsEnumerable().ToArray())
         {
             if (!_dicById.ContainsKey(item.Id))
             {
                 _dicById.Add(item.Id, new MinerGroupViewModel(item));
             }
         }
         this.OnPropertyChangeds();
         MinerClientsWindowViewModel.Instance.RefreshMinerClientsSelectedMinerGroup(MinerClientsWindowViewModel.Instance.MinerClients.ToArray());
     });
     this.Add = new DelegateCommand(() => {
         new MinerGroupViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
     });
     AppRoot.BuildEventPath <MinerGroupAddedEvent>("添加矿机分组后刷新VM内存", LogEnum.DevConsole, location: this.GetType(), PathPriority.Normal,
                                                   path: message => {
         if (!_dicById.TryGetValue(message.Source.GetId(), out MinerGroupViewModel vm))
         {
             vm = new MinerGroupViewModel(message.Source);
             _dicById.Add(message.Source.GetId(), vm);
             OnPropertyChangeds();
             MinerClientsWindowVm.OnPropertyChanged(nameof(MinerClientsWindowViewModel.SelectedMinerGroup));
         }
     });
     AppRoot.BuildEventPath <MinerGroupUpdatedEvent>("添加矿机分组后刷新VM内存", LogEnum.DevConsole, location: this.GetType(), PathPriority.Normal,
                                                     path: message => {
         if (_dicById.TryGetValue(message.Source.GetId(), out MinerGroupViewModel vm))
         {
             vm.Update(message.Source);
         }
     });
     AppRoot.BuildEventPath <MinerGroupRemovedEvent>("移除了矿机组后刷新Vm内容", LogEnum.DevConsole, this.GetType(), PathPriority.Normal, path: message => {
         if (_dicById.TryGetValue(message.Source.Id, out MinerGroupViewModel vm))
         {
             _dicById.Remove(vm.Id);
             OnPropertyChangeds();
             MinerClientsWindowVm.OnPropertyChanged(nameof(MinerClientsWindowViewModel.SelectedMinerGroup));
         }
     });
 }
Ejemplo n.º 17
0
        public static string ReParseHtmlContent(string html)
        {
            if (!string.IsNullOrWhiteSpace(html))
            {
                html = html.Replace("{InnerPictureSpace}", AppRoot.TrimEnd('/'));

                return(html);
            }

            return(string.Empty);
        }
Ejemplo n.º 18
0
        public void updatePoint(Models.Point point)
        {
            //string svgPath = $"{AppRoot.GetApplicationRoot()}{point.Scheme}.svg";
            //svgViewBox.Source = new Uri(svgPath);
            lblPointInfo.Content = point.Name;
            var uri    = new Uri($"{AppRoot.GetApplicationRoot()}PNG\\{point.Id}.png");
            var bitmap = new BitmapImage(uri);

            imgPoint.Source = bitmap;
            task.Point      = point;
        }
Ejemplo n.º 19
0
 public DataResponse <WebApiServerState> GetServerState([FromBody] object request)
 {
     if (request == null)
     {
         return(ResponseBase.InvalidInput <DataResponse <WebApiServerState> >("参数错误"));
     }
     return(new DataResponse <WebApiServerState> {
         StateCode = 200,
         ReasonPhrase = "Ok",
         Description = "成功",
         Data = AppRoot.GetServerState()
     });
 }
            private NTMinerWalletViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                Init(refresh: false);
                AppRoot.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);
                });
                AppRoot.AddEventPath <NTMinerWalletAddedEvent>("添加NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                               action: message => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Add(message.Source.GetId(), new NTMinerWalletViewModel(message.Source));
                        if (AppRoot.CoinVms.TryGetCoinVm(message.Source.CoinCode, out CoinViewModel coinVm))
                        {
                            coinVm.OnPropertyChanged(nameof(coinVm.NTMinerWallets));
                        }
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <NTMinerWalletUpdatedEvent>("更新NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                                 action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out NTMinerWalletViewModel vm))
                    {
                        vm.Update(message.Source);
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <NTMinerWalletRemovedEvent>("删除NTMiner钱包后刷新VM内存", LogEnum.DevConsole,
                                                                 action: message => {
                    _dicById.Remove(message.Source.GetId());
                    if (AppRoot.CoinVms.TryGetCoinVm(message.Source.CoinCode, 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
            }
Ejemplo n.º 21
0
        protected internal LayoutModel GetLayoutModelForPath(string path)
        {
            if (path.Equals("/"))
            {
                path = "/{0}"._Format(AppConf.DefaultPage.Or(AppConf.DefaultLayoutConst));
            }

            string absolutePath;
            string lowered = path.ToLowerInvariant();

            string[] layoutSegments = string.Format("~/pages/{0}{1}", path, LayoutFileExtension).DelimitSplit("/", "\\");
            string[] htmlSegments   = string.Format("~/pages/{0}.html", path).DelimitSplit("/", "\\");

            LayoutModel result = null;

            if (LayoutModelsByPath.ContainsKey(lowered))
            {
                result = LayoutModelsByPath[lowered];
            }
            else if (AppRoot.FileExists(out absolutePath, layoutSegments))
            {
                LayoutConf layoutConf     = new LayoutConf(AppConf);
                LayoutConf fromLayoutFile = FileCachesByExtension[LayoutFileExtension].GetText(new FileInfo(absolutePath)).FromJson <LayoutConf>();
                layoutConf.CopyProperties(fromLayoutFile);
                result = layoutConf.CreateLayoutModel(htmlSegments);
                LayoutModelsByPath[lowered] = result;
            }
            else
            {
                LayoutConf defaultLayoutConf = new LayoutConf(AppConf);
                result = defaultLayoutConf.CreateLayoutModel(htmlSegments);
                FileInfo file = new FileInfo(AppRoot.GetAbsolutePath(layoutSegments));
                if (!file.Directory.Exists)
                {
                    file.Directory.Create();
                }
                // write the file to disk
                defaultLayoutConf.ToJsonFile(file);
                LayoutModelsByPath[lowered] = result;
            }

            if (string.IsNullOrEmpty(Path.GetExtension(path)))
            {
                string page = path.TruncateFront(1);
                if (!string.IsNullOrEmpty(page))
                {
                    result.StartPage = page;
                }
            }
            return(result);
        }
Ejemplo n.º 22
0
 public void RemoveById(Guid id)
 {
     InitOnece();
     lock (_dicById) {
         if (_dicById.ContainsKey(id))
         {
             _dicById.Remove(id);
             using (LiteDatabase db = AppRoot.CreateLocalDb()) {
                 var col = db.GetCollection <NTMinerWalletData>();
                 col.Delete(id);
             }
         }
     }
 }
Ejemplo n.º 23
0
        private AppRoot AddAppRoot()
        {
            using (var documentSession = CreateSession())
            {
                // Create the AppRoot without user
                var appRoot = new AppRoot(DateTime.UtcNow);
                documentSession.Store(appRoot);

                // Save the approot to be available for all subsequent setup
                documentSession.SaveChanges();

                return(appRoot);
            }
        }
Ejemplo n.º 24
0
 public void RemoveById(Guid id)
 {
     InitOnece();
     lock (_dicById) {
         if (_dicById.ContainsKey(id))
         {
             _dicById.Remove(id);
             using (LiteDatabase db = AppRoot.CreateLocalDb()) {
                 var col = db.GetCollection <UserMineWorkData>();
                 col.Delete(id);
             }
             SpecialPath.DeleteMineWorkFiles(id);
         }
     }
 }
Ejemplo n.º 25
0
 protected override void Init()
 {
     using (LiteDatabase db = AppRoot.CreateLocalDb()) {
         var col = db.GetCollection <UserAppSettingData>();
         foreach (var item in col.FindAll())
         {
             if (!_dicByLoginName.TryGetValue(item.LoginName, out List <UserAppSettingData> list))
             {
                 list = new List <UserAppSettingData>();
                 _dicByLoginName.Add(item.LoginName, list);
             }
             list.Add(item);
         }
     }
 }
Ejemplo n.º 26
0
            private OverClockDataViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                Init(refresh: false);
                AppRoot.AddEventPath <OverClockDataSetInitedEvent>("超频菜谱集初始化后", LogEnum.DevConsole,
                                                                   action: message => {
                    Init(refresh: true);
                }, location: this.GetType());
                AppRoot.AddEventPath <OverClockDataAddedEvent>("添加超频菜谱后刷新VM内存", LogEnum.DevConsole,
                                                               action: message => {
                    if (!_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Add(message.Source.GetId(), new OverClockDataViewModel(message.Source));
                        if (AppRoot.CoinVms.TryGetCoinVm(message.Source.CoinId, out CoinViewModel coinVm))
                        {
                            coinVm.OnPropertyChanged(nameof(coinVm.OverClockDatas));
                        }
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <OverClockDataUpdatedEvent>("更新超频菜谱后刷新VM内存", LogEnum.DevConsole,
                                                                 action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out OverClockDataViewModel vm))
                    {
                        vm.Update(message.Source);
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <OverClockDataRemovedEvent>("删除超频菜谱后刷新VM内存", LogEnum.DevConsole,
                                                                 action: message => {
                    _dicById.Remove(message.Source.GetId());
                    if (AppRoot.CoinVms.TryGetCoinVm(message.Source.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
            }
Ejemplo n.º 27
0
 public static T ToWsMessage <T>(this MessageEventArgs e) where T : WsMessage
 {
     // IsPing、IsBinary、IsText三者是互斥的,经查源码实际上是判断一个Opcode枚举类型的值
     if (e.IsPing)
     {
         throw new InvalidProgramException("Ping消息不应走到这一步");
     }
     if (e.IsBinary)
     {
         return(VirtualRoot.BinarySerializer.Deserialize <T>(e.RawData));
     }
     else
     {
         return(AppRoot.ParseWsMessage <T>(e.Data));
     }
 }
 public ResponseBase ClearByExceptedOutputIds(DataRequest <Guid[]> request)
 {
     if (request == null || request.Data == null || request.Data.Length == 0)
     {
         return(ResponseBase.InvalidInput("参数错误"));
     }
     try {
         VirtualRoot.Execute(new ClearKernelOutputKeywordsCommand(request.Data));
         AppRoot.UpdateKernelOutputKeywordTimestamp(DateTime.Now);
         return(ResponseBase.Ok());
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(ResponseBase.ServerError(e.Message));
     }
 }
Ejemplo n.º 29
0
 public ResponseBase RemoveKernelOutputKeyword([FromBody] DataRequest <Guid> request)
 {
     if (request == null || request.Data == Guid.Empty)
     {
         return(ResponseBase.InvalidInput("参数错误"));
     }
     try {
         VirtualRoot.Execute(new RemoveKernelOutputKeywordCommand(request.Data));
         AppRoot.UpdateKernelOutputKeywordTimestamp(DateTime.Now);
         return(ResponseBase.Ok());
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
         return(ResponseBase.ServerError(e.Message));
     }
 }
Ejemplo n.º 30
0
        private void AddAllSpecies(AppRoot appRoot)
        {
            using (var docSession = CreateSession())
            {
                appRoot.SetPerformSpeciesDataUpdate(false);
                docSession.Store(appRoot);
                docSession.SaveChanges();
            }

            var fileList = Directory.GetFiles(Path.Combine(_configSettings.GetEnvironmentRootPath(), _configSettings.GetSpeciesRelativePath()));

            foreach (var file in fileList.Where(x => !Path.GetFileName(x).StartsWith("UTF8-")))
            {
                AddSpeciesKingdom(file);
            }
        }
Ejemplo n.º 31
0
 private void SaveAppRoot(AppRoot appRoot)
 {
     _documentSession.Store(appRoot);
     _documentSession.SaveChanges();
 }
Ejemplo n.º 32
0
 public AppRoot()
 {
     _instance = this;
 }
Ejemplo n.º 33
0
 public AppRoot()
 {
     mInstance = this;
 }
Ejemplo n.º 34
0
    public AppRoot()
    {
        mInstance = this;

        //EditorUtility.OpenFilePanel()
    }