Exemple #1
0
        private List <PackageRequest> GetNuGetPackageDependencies(IPackageMetadata package)
        {
            var dependencies = package.GetCompatiblePackageDependencies(SystemUtility.GetTargetFramework())
                               .Select(dependency => new PackageRequest
            {
                Id            = dependency.Id,
                VersionsRange = dependency.VersionSpec != null ? dependency.VersionSpec.ToString() : null,
                RequestedBy   = "package " + package.Id
            }).ToList();

            if (!dependencies.Any(p => string.Equals(p.Id, "Rhetos", StringComparison.OrdinalIgnoreCase)))
            {
                // FrameworkAssembly is an obsolete way of marking package dependency on a specific Rhetos version:
                var rhetosFrameworkAssemblyRegex = new Regex(@"^Rhetos\s*,\s*Version\s*=\s*(\S+)$");
                var parseFrameworkAssembly       = package.FrameworkAssemblies
                                                   .Select(fa => rhetosFrameworkAssemblyRegex.Match(fa.AssemblyName.Trim()))
                                                   .SingleOrDefault(m => m.Success == true);
                if (parseFrameworkAssembly != null)
                {
                    dependencies.Add(new PackageRequest
                    {
                        Id            = "Rhetos",
                        VersionsRange = parseFrameworkAssembly.Groups[1].Value,
                        RequestedBy   = "package " + package.Id
                    });
                }
            }

            return(dependencies);
        }
Exemple #2
0
 private IConceptInfo CreateInitializationConcept()
 {
     return(new InitializationConcept
     {
         RhetosVersion = SystemUtility.GetRhetosVersion()
     });
 }
Exemple #3
0
 public CategoryViewModel()
 {
     Model = new CategoryModel {
         Id = SystemUtility.GetGuid()
     };
     IsNew = true;
 }
Exemple #4
0
        public async Task <string> Authenticate(string userName, string password)
        {
            var clientIp  = this._contextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
            var isBlocked = await this._repository.IsBlacklisted(clientIp);

            if (isBlocked)
            {
                throw new Exception("You've been blocked. Please contact our tech support.");
            }
            if (userName == SystemUtility.GetEnvironmentVariableAsString(this._appConfig.Value.LoginUserNameKey) &&
                password == SystemUtility.GetEnvironmentVariableAsString(this._appConfig.Value.LoginPasswordKey))
            {
                await this._repository.RemoveWrongPassword(clientIp);

                var tokenHandler    = new JwtSecurityTokenHandler();
                var tokenDescriptor = new SecurityTokenDescriptor
                {
                    Subject = new ClaimsIdentity(new Claim[]
                    {
                        new Claim(ClaimTypes.Name, userName)
                    }),
                    Expires            = DateTime.UtcNow.AddDays(7),
                    SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(this._appConfig.Value.SecretKey), SecurityAlgorithms.HmacSha256Signature)
                };
                var    securityToken = tokenHandler.CreateToken(tokenDescriptor);
                string token         = tokenHandler.WriteToken(securityToken);

                return(token);
            }
            await this._repository.LogWrongPassword(clientIp);

            throw new Exception("User name or password is wrong!");
        }
    /// <summary>
    /// Raises the click select callback event.
    /// </summary>
    /// <param name='obj'>
    /// Object.
    /// </param>
    public void OnClickSelectCallback(GameObject obj)
    {
        string objName = obj.name;

        ViNoDebugger.Log("SELECTION", "click callback obj : " + objName);
        if (m_SelectionDict == null)
        {
            return;
        }
        if (m_SelectionDict.ContainsKey(objName))
        {
            string destNodeName = m_SelectionDict[objName].m_Target;
            if (!destNodeName.Equals(string.Empty))
            {
                if (ScenarioNode.Instance.flagTable != null)
                {
                    ScenarioNode.Instance.flagTable.SetFlagBy("SELECTED/" + destNodeName, true);
                }
                VM.Instance.GoToLabel(m_SelectionDict[objName].m_Target);                       // Run with Tag.
            }
            else
            {
                Debug.LogError("SelectionUnit Target must not be empty .");
            }
        }
        else
        {
            Debug.LogError("SelectionUnit  NOT FOUND in SelectionDictionary .");
        }
        SystemUtility.EnableColliderCurrentTextBox(true);

        DeactivateSelections();

        ChangeActive(false);
    }
Exemple #6
0
    private void ClearMessage()
    {
        AddToBacklog();

        ClearTextBuilder();

        SystemUtility.ClearAllTextBoxMessage();
    }
Exemple #7
0
 public CostViewModel()
 {
     Model = new CostModel {
         Id = SystemUtility.GetGuid()
     };
     IsNew        = true;
     HavePrevCost = false;
 }
Exemple #8
0
    /// <summary>
    /// Load the specified info.
    /// </summary>
    /// <returns>
    /// If Load Succeed return true , Load Failed return false.
    /// </returns>
    static public bool Load(ViNoSaveInfo info)
    {
        bool levelNameNotMatchThisScene = !info.data.m_LoadedLevelName.Equals(Application.loadedLevelName);

        if (levelNameNotMatchThisScene)
        {
            ViNoDebugger.LogError("SaveData Level Name is : \""
                                  + info.data.m_LoadedLevelName + "\" but this level is \"" + Application.loadedLevelName + "\"");
            return(false);
        }

        // Load Scene from XML.
        if (ViNoSceneManager.Instance != null)
        {
            ViNoSceneManager.Instance.Load(info);
        }

        bool haveLevelName = !string.IsNullOrEmpty(info.data.m_LoadedLevelName);
        bool haveNodeName  = !string.IsNullOrEmpty(info.data.m_NodeName);
        bool isLoad        = (haveLevelName && haveNodeName);

        if (isLoad)
        {
            // Deserialize VM.
            VM vm = VM.Instance;
            if (vm != null)
            {
                vm.ClearTextBuilder();

                SystemUtility.ClearAllTextBoxMessage();

                vm.Deserialize(info.data.m_NodeName);

                GameObject scenarioObj = GetScenarioObject(info);

                // Play from File ?.
                ScenarioNode scenario = scenarioObj.GetComponent <ScenarioNode>();
                scenario.startFromSave = true;
                scenario.PlayFrom(info.data.m_NodeName);
            }

            // Load Sound.
            if (ISoundPlayer.Instance != null)
            {
                ISoundPlayer pl = ISoundPlayer.Instance;
                pl.OnLoad(info.data);
            }

            // Deactivate Selections.
            if (ISelectionsCtrl.Instance != null)
            {
                ISelectionsCtrl.Instance.ChangeActive(false);
            }
        }
        return(isLoad);
    }
Exemple #9
0
 /// <summary>
 /// 提交按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         SetButtonDisabled(button1, false);
         //程序崩溃生成转储文件
         if (args == null || args.Length == 0)
         {
             MessageBox.Show(this, $"args=null不允许操作!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return;
         }
         var mainPath = args[0];
         if (!File.Exists(mainPath))
         {
             MessageBox.Show(this, $"{mainPath} 文件不存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return;
         }
         var programeName = Path.GetFileNameWithoutExtension(mainPath);
         var path         = Application.StartupPath + $"\\CrashDumps\\";
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         path += $"{DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss")}{programeName}.dmp";
         using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.Write))
         {
             MiniDump.Write(fs.SafeFileHandle, MiniDump.Option.WithFullMemory, programeName);
         }
         Logger.WriteProfilerLog(new Tuple <string, string>("CrashLog", _eventId), $"创建Crash文件成功!{path}");
         //发送报告,并上传dmp文件到服务器
         if (checkBox1.Checked)
         {
             Logger.WriteProfilerLog(new Tuple <string, string>("CrashLog", _eventId), $"上传Crash文件到服务器...");
         }
         //重启宿主
         if (checkBox2.Checked)
         {
             Logger.WriteProfilerLog(new Tuple <string, string>("CrashLog", _eventId), $"杀进程:{programeName},重启宿主:{mainPath}");
             //杀掉进程
             var     rtKill = SystemUtility.KillProcess(programeName);
             Process pr     = new Process();
             pr.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
             pr.StartInfo.FileName         = mainPath;//重启宿主
             pr.Start();
             Environment.Exit(0);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, $"提交异常:{ex.Message}", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     finally
     {
         SetButtonDisabled(button1, true);
     }
 }
        public BalanceViewModel()
        {
            Model = new BalanceModel
            {
                Id       = SystemUtility.GetGuid(),
                Currency = NumberFormatInfo.CurrentInfo.CurrencySymbol
            };

            IsNew = true;
        }
 public DslSyntax CreateDslSyntax()
 {
     return(new DslSyntax
     {
         ConceptTypes = CreateConceptTypesAndMembers(_conceptInfoPlugins.Select(ci => ci.GetType())),
         Version = SystemUtility.GetRhetosVersion(),
         ExcessDotInKey = _buildOptions.DslSyntaxExcessDotInKey,
         DatabaseLanguage = _databaseSettings.DatabaseLanguage,
     });
 }
Exemple #12
0
        public void TestFinalIK(string typeName)
        {
            if (!TestUtils.HasFinalIK)
            {
                Assert.Ignore("FinalIK is not imported.");
            }
            var type = SystemUtility.GetTypeByName(typeName);

            Assert.NotNull(type);
            Assert.False(remover.IsUnsupportedComponent(type));
        }
Exemple #13
0
        public void TestDynamicBone(string typeName)
        {
            if (!TestUtils.HasDynamicBone)
            {
                Assert.Ignore("DynamicBone is not imported.");
            }
            var type = SystemUtility.GetTypeByName(typeName);

            Assert.NotNull(type);
            Assert.True(remover.IsUnsupportedComponent(type));
        }
Exemple #14
0
    private void AdjustModePanel()
    {
        Vector4 clipRegion   = modePanel.baseClipRegion;
        int     heightExtend = (int)((Constant.SCREEN_WIDTH / SystemUtility.GetDeviceWHAspect() - Constant.SCREEN_HEIGHT) / 2);

        heightExtend = heightExtend > 0 ? heightExtend : 0;
        int newPanelHeight = (int)clipRegion.w + heightExtend;

        clipRegion.w             = newPanelHeight;
        clipRegion.y             = -newPanelHeight / 2;
        modePanel.baseClipRegion = clipRegion;
    }
Exemple #15
0
 private static void OpenBrowser(string browserPath, string webBrowserUrl)
 {
     // Chrome has known issues with being launched as admin.
     if (!string.IsNullOrEmpty(browserPath) && browserPath.EndsWith(NodejsConstants.ChromeApplicationName))
     {
         SystemUtility.ExecuteProcessUnElevated(browserPath, webBrowserUrl);
     }
     else
     {
         VsShellUtilities.OpenBrowser(webBrowserUrl, (uint)__VSOSPFLAGS.OSP_LaunchNewBrowser);
     }
 }
Exemple #16
0
        /// <summary>
        /// Downloads the packages from the provided sources, if not already downloaded.
        /// Unpacks the packages, if not already unpacked.
        /// </summary>
        public InstalledPackages GetPackages()
        {
            var sw = Stopwatch.StartNew();
            var installedPackages = new List <InstalledPackage>();

            // These Rhetos framework packages are already integrated in Rhetos application when using DeployPackages build process.
            installedPackages.Add(new InstalledPackage("Rhetos", SystemUtility.GetRhetosVersion(), new List <PackageRequest>(), Paths.RhetosServerRootPath,
                                                       new PackageRequest {
                Id = "Rhetos", VersionsRange = null, Source = null, RequestedBy = "Rhetos framework"
            }, ".", new List <ContentFile> {
            }));
            installedPackages.Add(new InstalledPackage("Rhetos.MSBuild", SystemUtility.GetRhetosVersion(), new List <PackageRequest>(), Paths.RhetosServerRootPath,
                                                       new PackageRequest {
                Id = "Rhetos.MSBuild", VersionsRange = null, Source = null, RequestedBy = "Rhetos framework"
            }, ".", new List <ContentFile> {
            }));

            var binFileSyncer = new FileSyncer(_logProvider);

            binFileSyncer.AddDestinations(Paths.PluginsFolder); // Even if there are no packages, this folder must be emptied.

            _filesUtility.SafeCreateDirectory(_packagesCacheFolder);
            var packageRequests = _deploymentConfiguration.PackageRequests;

            while (packageRequests.Any())
            {
                var newDependencies = new List <PackageRequest>();
                foreach (var request in packageRequests)
                {
                    _logger.Trace(() => $"Getting package {request.ReportIdVersionRequestSource()}.");
                    if (!CheckAlreadyDownloaded(request, installedPackages))
                    {
                        var installedPackage = GetPackage(request, binFileSyncer);
                        ValidatePackage(installedPackage, request);
                        installedPackages.Add(installedPackage);
                        newDependencies.AddRange(installedPackage.Dependencies);
                    }
                }
                packageRequests = newDependencies;
            }

            DeleteObsoletePackages(installedPackages);
            SortByDependencies(installedPackages);

            binFileSyncer.UpdateDestination();

            _performanceLogger.Write(sw, "GetPackages.");

            return(new InstalledPackages {
                Packages = installedPackages
            });
        }
Exemple #17
0
    private async Task <BGMData> GetBGMData(int bgmIndex)
    {
        if (_gameConfig == null)
        {
            _gameConfig = await SystemUtility.GetGameConfig();
        }

        if (_gameConfig == null || _gameConfig.BackGroundMusics.Length <= bgmIndex)
        {
            return(null);
        }

        return(_gameConfig.BackGroundMusics[bgmIndex]);
    }
Exemple #18
0
        private IEnumerable <IPackageFile> FilterCompatibleLibFiles(IEnumerable <IPackageFile> files)
        {
            IEnumerable <IPackageFile> compatibleLibFiles;
            var allLibFiles = files.Where(file => file.Path.StartsWith(@"lib\"));

            if (VersionUtility.TryGetCompatibleItems(SystemUtility.GetTargetFramework(), allLibFiles, out compatibleLibFiles))
            {
                return(compatibleLibFiles);
            }
            else
            {
                return(Enumerable.Empty <IPackageFile>());
            }
        }
Exemple #19
0
    static public bool DoQuickLoad()
    {
        SystemUtility.ClearAllTextBoxMessage();
        ViNoSaveInfo info = ScenarioCtrl.Instance.quickSaveSlot;

        if (info != null)
        {
            return(ViNo.LoadData("QSaveData", ref info));
        }
        else
        {
            Debug.LogError("ScenarioCtrl not attached QuickSaveSlot. couldn't Load.");
            return(false);
        }
    }
        private IEnumerable <IPackageFile> FilterCompatibleLibFiles(IEnumerable <IPackageFile> files)
        {
            IEnumerable <IPackageFile> compatibleLibFiles;
            var allLibFiles = files.Where(file => file.Path.StartsWith(@"lib\") &&
                                          Path.GetFileName(file.Path) != "_._"); // Microsoft's convention for empty folders in NuGet packages.

            if (VersionUtility.TryGetCompatibleItems(SystemUtility.GetTargetFramework(), allLibFiles, out compatibleLibFiles))
            {
                return(compatibleLibFiles);
            }
            else
            {
                return(Enumerable.Empty <IPackageFile>());
            }
        }
Exemple #21
0
        /// <summary>
        /// Downloads the packages from the provided sources, if not already downloaded.
        /// Unpacks the packages, if not already unpacked.
        /// </summary>
        public List <InstalledPackage> GetPackages()
        {
            var sw = Stopwatch.StartNew();
            var installedPackages = new List <InstalledPackage>();

            installedPackages.Add(new InstalledPackage("Rhetos", SystemUtility.GetRhetosVersion(), new List <PackageRequest>(), Paths.RhetosServerRootPath,
                                                       new PackageRequest {
                Id = "Rhetos", VersionsRange = "", Source = "", RequestedBy = "Rhetos framework"
            }, ".", new List <ContentFile> {
            }));

            var binFileSyncer = new FileSyncer(_logProvider);

            binFileSyncer.AddDestinations(Paths.PluginsFolder, Paths.ResourcesFolder); // Even if there are no packages, those folders must be created and emptied.

            _filesUtility.SafeCreateDirectory(Paths.PackagesCacheFolder);
            var packageRequests = _deploymentConfiguration.PackageRequests;

            while (packageRequests.Any())
            {
                var newDependencies = new List <PackageRequest>();
                foreach (var request in packageRequests)
                {
                    if (!CheckAlreadyDownloaded(request, installedPackages))
                    {
                        var installedPackage = GetPackage(request, binFileSyncer);
                        ValidatePackage(installedPackage, request, installedPackages);
                        installedPackages.Add(installedPackage);
                        newDependencies.AddRange(installedPackage.Dependencies);
                    }
                }
                packageRequests = newDependencies;
            }

            DeleteObsoletePackages(installedPackages);
            SortByDependencies(installedPackages);

            binFileSyncer.UpdateDestination();

            foreach (var package in installedPackages)
            {
                _packagesLogger.Trace(() => package.Report());
            }

            _performanceLogger.Write(sw, "PackageDownloader.GetPackages.");

            return(installedPackages);
        }
Exemple #22
0
    public static int LogBatteryStatus_s(IntPtr l)
    {
        int result;

        try
        {
            SystemUtility.LogBatteryStatus();
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemple #23
0
 public void downloadDone(bool launch)
 {
     mRunning = false;
     if (launch)
     {
         mUpdateDone = true;
         if (mAutoStartGame)
         {
             // 显示提示
             mBusyInfo.Show();
             mBusyInfo.setInfo("正在启动游戏...");
             // 启动游戏
             SystemUtility.launchExecutable(CommonDefine.GAME_NAME);
         }
     }
 }
Exemple #24
0
    public static int GetBatteryLevel_s(IntPtr l)
    {
        int result;

        try
        {
            float batteryLevel = SystemUtility.GetBatteryLevel();
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, batteryLevel);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemple #25
0
    public static int GetBatteryStatus_s(IntPtr l)
    {
        int result;

        try
        {
            BatteryStatus batteryStatus = SystemUtility.GetBatteryStatus();
            LuaObject.pushValue(l, true);
            LuaObject.pushEnum(l, (int)batteryStatus);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemple #26
0
    public static int GetConfigDataDeviceSetting_s(IntPtr l)
    {
        int result;

        try
        {
            ConfigDataDeviceSetting configDataDeviceSetting = SystemUtility.GetConfigDataDeviceSetting();
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, configDataDeviceSetting);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemple #27
0
    public static int IsiPhoneX_s(IntPtr l)
    {
        int result;

        try
        {
            bool b = SystemUtility.IsiPhoneX();
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, b);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
        private void ValidatePackage(InstalledPackage installedPackage, PackageRequest request, List <InstalledPackage> installedPackages)
        {
            if (request.Id != null)
            {
                if (installedPackage.Id != request.Id)
                {
                    throw new UserException(string.Format(
                                                "Package ID '{0}' at location '{1}' does not match package ID '{2}' requested from {3}.",
                                                installedPackage.Id, installedPackage.Source, request.Id, request.RequestedBy));
                }
            }

            var currentRhetosVersion = SystemUtility.GetRhetosVersion();

            if (installedPackage.RequiredRhetosVersion != null)
            {
                if (!VersionUtility.ParseVersionSpec(installedPackage.RequiredRhetosVersion).Satisfies(SemanticVersion.Parse(currentRhetosVersion)))
                {
                    DependencyError(string.Format(
                                        "Package '{0}, version {1}' requires Rhetos version {2}. It is incompatible with current Rhetos version {3}.",
                                        installedPackage.Id, installedPackage.Version, installedPackage.RequiredRhetosVersion, currentRhetosVersion));
                }
            }

            if (request.VersionsRange != null)
            {
                if (!VersionUtility.ParseVersionSpec(request.VersionsRange).Satisfies(SemanticVersion.Parse(installedPackage.Version)))
                {
                    DependencyError(string.Format(
                                        "Incompatible package version '{0}, version {1}'. Version {2} is requested from {3}'.",
                                        installedPackage.Id, installedPackage.Version,
                                        request.VersionsRange, request.RequestedBy));
                }
            }

            var similarOldPackage = installedPackages.FirstOrDefault(oldPackage => oldPackage.Id != installedPackage.Id &&
                                                                     SimplifyPackageName(oldPackage.Id) == SimplifyPackageName(installedPackage.Id));

            if (similarOldPackage != null)
            {
                throw new UserException(string.Format(
                                            "Incompatible package names '{0}' (requested from {1}) and '{2}' (requested from {3}).",
                                            installedPackage.Id, installedPackage.Request.RequestedBy,
                                            similarOldPackage.Id, similarOldPackage.Request.RequestedBy));
            }
        }
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            switch (SettingsWorker.Current.GetRequestedTheme())
            {
            case ApplicationTheme.Light:
                LightTheme.IsChecked = true;
                break;

            case ApplicationTheme.Dark:
                DarkTheme.IsChecked = true;
                break;
            }

            VersionTextBlock.Text = SystemUtility.GetVersionApp();

            _isLoaded = true;
        }
Exemple #30
0
    public static int constructor(IntPtr l)
    {
        int result;

        try
        {
            SystemUtility o = new SystemUtility();
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, o);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }