/// <summary> /// Compares the current instance with another object of the same type and returns an integer that indicates /// whether the current instance precedes, follows, or occurs in the same position in the sort order as the /// <paramref name="comparison" /> object. /// </summary> /// <remarks> /// <para> /// Semantic Versions have a very specific and somewhat counterintuitive order of precedence. Comparison /// begins with the major version and proceeds to the minor version, patch, prerelease tag and build /// metadata tag. The order of precedence is always returned as soon as it can be determined. /// </para> /// <para> /// If order cannot be determined from the major, minor and patch versions, then comparison proceeds to /// the prerelease tag and then the build metadata tag. These fields can contain multiple segments /// separated by the '.' character. each dot-separated segment is considered separately and where /// possible is converted to an integer, so that <c>beta.9</c> sorts before <c>beta.10</c>. /// </para> /// <para> /// Note that any version with a prerelease tag sorts lower than the same version without a prerelease /// tag. Put another way: a release version is greater than a prerelease version. /// </para> /// <para> /// The specification states that build metadata should be ignored when determining precedence. That /// doesn't seem like a very sensible approach to us, since builds have to appear in some sort of order /// and 'random' didn't strike us as an amazingly useful outcome. Therefore we have chosen to deviate /// from the specification and include it as the last item in the list of comparisons when determining /// the collation sequence. We treat the build metadata in a similar way to the prerelease tag, giving /// it the lowest precedence but nonetheless yielding a more deterministic result when comparing and /// sorting semantic versions. /// </para> /// </remarks> /// <param name="comparison">An object to compare with this instance.</param> /// <returns> /// A value that indicates the relative order of the objects being compared. /// </returns> public int CompareTo(SemanticVersion comparison) { if (comparison == null) { throw new ArgumentNullException(nameof(comparison)); } if (ReferenceEquals(this, comparison)) { return(0); } int result = MajorVersion.CompareTo(comparison.MajorVersion); if (result != 0) { return(result); } result = MinorVersion.CompareTo(comparison.MinorVersion); if (result != 0) { return(result); } result = PatchVersion.CompareTo(comparison.PatchVersion); if (result != 0) { return(result); } result = ComparePrereleaseVersions(PrereleaseVersion, comparison.PrereleaseVersion); if (result != 0) { return(result); } return(CompareBuildVersions(BuildVersion, comparison.BuildVersion)); }
private static void UpdatePatches(string dcsRoot, string patchSet, string outputPath) { // determine DCS version string autoUpdatePath = Path.Combine(dcsRoot, "autoupdate.cfg"); string versionString = JsonConvert.DeserializeObject <AutoUpdateConfig>(File.ReadAllText(autoUpdatePath)) .Version; string dcsVersion = PatchVersion.SortableString(versionString); // now build patches based on files changed in repo string patchesPath = outputPath ?? FileSystem.FindNearestDirectory("Patching\\Patches"); Console.WriteLine($"writing patches for {dcsVersion} to {patchesPath}"); int nCount = 0; using (Repository repo = new Repository(dcsRoot)) { foreach (StatusEntry item in repo.RetrieveStatus(new StatusOptions())) { if (item.State == FileStatus.ModifiedInWorkdir) { string source; string target; Debug.WriteLine(item.FilePath); Blob blob = repo.Head.Tip[item.FilePath].Target as Blob; using (var content = new StreamReader(blob.GetContentStream(), Encoding.UTF8)) { source = content.ReadToEnd(); } string workingPath = Path.Combine(repo.Info.WorkingDirectory, item.FilePath); using (var content = new StreamReader(workingPath, Encoding.UTF8)) { target = content.ReadToEnd(); } string patchPath = Path.Combine(patchesPath, "DCS", dcsVersion, patchSet, $"{item.FilePath}.gpatch"); string reversePath = Path.Combine(patchesPath, "DCS", dcsVersion, patchSet, $"{item.FilePath}.grevert"); string outputDirectoryPath = Path.GetDirectoryName(patchPath); if (outputDirectoryPath != null && !Directory.Exists(outputDirectoryPath)) { Directory.CreateDirectory(outputDirectoryPath); } Console.WriteLine($"writing patch {patchPath}"); WritePatch(source, target, patchPath); WritePatch(target, source, reversePath); nCount++; } } } if (nCount == 0) { Console.WriteLine($"no patch files written, does {dcsRoot} not have any current changes in the working directory?"); } }
public IEnumerator startPatch() { // loading local patch info PatchMessage = "Checking new version..."; process = 0; string localpath = Application.persistentDataPath + "/" + CommonPatcherData.patchVersionFN; XmlDocument localVerDoc = XmlTool.loadXml(localpath); if (localVerDoc != null) { PatchVersion.setVersion(localVerDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes ["LastVersion"].Value); } // loading latest patch info string infofile = PatchURL + "/" + CommonPatcherData.patchVersionFN; WWW patchInfo = new WWW(infofile); yield return(patchInfo); if (patchInfo.error == null) { XmlDocument xmlDoc = XmlTool.loadXml(patchInfo.bytes); string newVersion_Folder = xmlDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes ["LastVersion"].Value; if (!PatchVersion.isEqualToLocalVersion(newVersion_Folder)) { // proc update PatchMessage = "Start updating..."; // get list to update yield return(instance.StartCoroutine(instance.getPatchInfo(xmlDoc))); // startcoroutine for all list } if (patchErrorCount > 0) { PatchProgress = 100; } else { PatchMessage = "Finish !"; PatchProgress = 100; File.WriteAllBytes(localpath, patchInfo.bytes); } } else { Debug.LogError("Patch Error : " + patchInfo.error); PatchMessage = "Error..." + infofile; PatchProgress = 100; PatchErrorCount = 1; } }
public IEnumerator GetPatchVersionFromLocalStorage() { _localVersion = null; string patchVersionPath = _GetPatchVersionPath(PATCH_VERSION_PATH.LOCAL); LPetUtil.DebugLogf("Local patchversion path<{0}>", patchVersionPath); using (WWW www = new WWW(patchVersionPath)) { yield return www; if (www.error != null) { LPetUtil.DebugLogf("WWW errro, local version has an error:" + www.error); if (_IsAbleUpdateAssetBundles()) { StartCoroutine(_newVersion.DownloadSaveAssetBundles(_OnCompletedAssetBundlesDownloadSave, _OnFailedAssetBundlesDownloadSave)); } else { StartCoroutine(_GetPatchVersionFromPackage()); } yield break; } LPetUtil.DebugLogf("Local version find!"); _localVersion = new PatchVersion(); _localVersion.PatchVersionJsonParser(www.text); // Is need major update? if (_IsNeedMajorUpdate()) { // update alarm!!! and EXIT app LPetUtil.DebugLogf("App Quit"); Application.Quit(); yield break; } if (_IsAbleUpdateAssetBundles()) { StartCoroutine(_newVersion.DownloadSaveAssetBundles(_OnCompletedAssetBundlesDownloadSave, _OnFailedAssetBundlesDownloadSave)); } else { StartCoroutine(_localVersion.LoadAssetBundles(_OnCompletedAssetBundlesLoad, _OnFailedAssetBundlesLoadFromLocalStorage)); } } }
public static void PatchVersion(this CloudShellContext context, PatchVersionSettings settings) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } var resolver = BuildResolver(context); var runner = new PatchVersion(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, resolver); runner.Execute(settings); }
private void btnScan_Click(object sender, EventArgs e) { txtList.Text = ""; progressBar.Maximum = getFileCount(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory)); progressBar.Maximum += getFileCount(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\Resources")); progressBar.Maximum += getFileCount(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\sounds")); progressBar.Maximum += getFileCount(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\SpellEffects")); progressBar.Maximum += getFileCount(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\storyline")); // progressBar.Maximum += getFileCount(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\uifiles")); // progressBar.Maximum += getFileCount(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\atlas")); txtList.Text = "Max:" + progressBar.Maximum; PatchVersion pv = new PatchVersion(); pv.ClientVersion = clientVersions[currentVersion].ShortName; //Root var fileMap = WalkDirectoryTree(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory)); pv.RootFiles = fileMap; //Resources fileMap = WalkDirectoryTree(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\Resources")); pv.ResourceFiles = fileMap; //Sounds fileMap = WalkDirectoryTree(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\sounds")); pv.SoundFiles = fileMap; //SpellEffects fileMap = WalkDirectoryTree(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\SpellEffects")); pv.SpellEffectFiles = fileMap; //Storyline fileMap = WalkDirectoryTree(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\storyline")); pv.StorylineFiles = fileMap; /* //UIFiles fileMap = WalkDirectoryTree(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\uifiles")); pv.UIFiles = fileMap; //Atlas fileMap = WalkDirectoryTree(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\atlas")); pv.AtlasFiles = fileMap; */ txtList.Text = JsonConvert.SerializeObject(pv); }
private void btnScan_Click(object sender, EventArgs e) { txtList.Text = ""; var fileMap = WalkDirectoryTree(new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory)); PatchVersion pv = new PatchVersion(); pv.ClientVersion = clientVersion; pv.RootFiles = fileMap; txtList.Text = JsonConvert.SerializeObject(pv); }
void _OnCompletedAssetBundlesDownloadSave() { LPetUtil.DebugLogf("Success. Downloaded and Save server asset"); _oldVersion.DeleteAssetBundles(); _newVersion.SavePatchVersionFromJsonData(_GetPatchVersionPath(PATCH_VERSION_PATH.LOCAL)); _serverVersion = null; _newVersion = null; _oldVersion = null; StartCoroutine(GetPatchVersionFromLocalStorage()); }
IEnumerator InitPatchData() { //获取本地的path res信息 string persistentPatchResPath = PathManager.RES_PERSISTENT_ROOT_PATH + "/" + PathManager.GetRuntimePlatform() + "/PatchRes.text"; if (File.Exists(persistentPatchResPath)) { using (FileStream fs = File.Open(persistentPatchResPath, FileMode.Open, FileAccess.ReadWrite)) using (StreamReader sr = new StreamReader(fs)) { string content = sr.ReadToEnd(); mPatchResLocal = JsonUtility.FromJson <PatchRes>(content); } } else { string streamPatchResPath = PathManager.RES_STREAM_ROOT_PATH + "/" + PathManager.GetRuntimePlatform() + "/PatchRes.text"; using (UnityWebRequest request = new UnityWebRequest(streamPatchResPath)) { yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { Debuger.LogError("common", request.error); } else { using (FileStream fs = File.Open(persistentPatchResPath, FileMode.CreateNew, FileAccess.ReadWrite)) using (StreamWriter sw = new StreamWriter(fs)) { string content = request.downloadHandler.text; sw.Write(content); sw.Flush(); mPatchResLocal = JsonUtility.FromJson <PatchRes>(content); } } } } //获取本地的path version信息 string persistentPatchVersionPath = PathManager.RES_PERSISTENT_ROOT_PATH + "/" + PathManager.GetRuntimePlatform() + "/PatchVersion.text"; if (File.Exists(persistentPatchVersionPath)) { using (FileStream fs = File.Open(persistentPatchVersionPath, FileMode.Open, FileAccess.ReadWrite)) using (StreamReader sr = new StreamReader(fs)) { string content = sr.ReadToEnd(); mPatchVersionLocal = JsonUtility.FromJson <PatchVersion>(content); } } else { //从stream路径拷贝到persistent路径 string streamPatchVersionPath = PathManager.RES_STREAM_ROOT_PATH + "/" + PathManager.GetRuntimePlatform() + "/PatchVersion.text"; using (UnityWebRequest request = new UnityWebRequest(streamPatchVersionPath)) { yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { Debuger.LogError("common", request.error); } else { using (FileStream fs = File.Open(persistentPatchVersionPath, FileMode.CreateNew, FileAccess.ReadWrite)) using (StreamWriter sw = new StreamWriter(fs)) { string content = request.downloadHandler.text; sw.Write(content); sw.Flush(); mPatchVersionLocal = JsonUtility.FromJson <PatchVersion>(content); } } } } //获取服务器的patch version信息 string serverPatchVersionPath = PathManager.GetServerURL("PatchVersion.text"); using (UnityWebRequest request = new UnityWebRequest(serverPatchVersionPath)) { yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { Debuger.LogError("common", request.error); } else { string content = request.downloadHandler.text; mPatchVersionServer = JsonUtility.FromJson <PatchVersion>(content); } } //更新APK if (mPatchVersionLocal.EngineVersion < mPatchVersionServer.EngineVersion) { Application.Quit(); yield break; } //更新资源 if (mPatchVersionLocal.ResVersion < mPatchVersionServer.ResVersion) { string serverPatchResPath = PathManager.GetServerURL(mPatchVersionServer.PatchResPath + "/PatchRes.text"); using (UnityWebRequest request = new UnityWebRequest(serverPatchResPath)) { yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { Debuger.LogError("common", request.error); } else { string content = request.downloadHandler.text; mPatchResServer = JsonUtility.FromJson <PatchRes>(content); } } yield return(StartCoroutine(StartUpdateRes())); //更新批次数据 UpdatePatchData(); } else if (mPatchVersionLocal.ResVersion > mPatchVersionServer.ResVersion) { Debuger.LogError("common", "mPatchVersionLocal.ResVersion > mPatchVersionServer.ResVersion"); } }
void OnGUI() { GUIStyle styleCmdArea = new GUIStyle(); styleCmdArea.normal.background = MakeTex(600, 80, Color.white); // info area GUILayout.BeginArea(new Rect(10, 10, 600, 80), styleCmdArea); GUILayout.BeginHorizontal(); GUILayout.Label("Platform:", GUILayout.Width(200)); selectedPlatform = EditorGUILayout.Popup(selectedPlatform, listPlatform.ToArray()); switch (selectedPlatform) { case 0: if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android); LoadConfigXML(CommonPatcherData.cnfFN); LoadVersionXML(); } else { GUILayout.EndHorizontal(); } break; case 1: if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.StandaloneWindows) { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows); LoadConfigXML(CommonPatcherData.cnfFN); LoadVersionXML(); } else { GUILayout.EndHorizontal(); } break; } GUILayout.BeginHorizontal(); GUILayout.Label("Last Version : " + lastMajorVersion + "." + lastMinorVersion); GUILayout.Label(">>>"); GUILayout.Label("New Version :"); chkLastMajorVersion = GUILayout.TextField("" + chkLastMajorVersion); chkLastMinorVersion = GUILayout.TextField("" + chkLastMinorVersion); if (GUILayout.Button("Apply", GUILayout.Width(70))) { // apply last version info and make folders and modify xml files. if (EditorUtility.DisplayDialog("You know that ?!", "This work just makes a folder for new version and change the text of last version. Later, you can make new resources for next patch when you press the button [Upload to repository].", "I see!!") == true) { SaveVersionXML(); } } if (GUILayout.Button("Rollback", GUILayout.Width(70))) { string prevVersion = PatchVersion.getPreviousVersion(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN); int prevMajor = Convert.ToInt32(prevVersion.Split('_')[1]); int prevMinor = Convert.ToInt32(prevVersion.Split('_')[2]); string curVersion = verDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes["LastVersion"].Value; int curMajor = Convert.ToInt32(curVersion.Split('_')[1]); int curMinor = Convert.ToInt32(curVersion.Split('_')[2]); if (EditorUtility.DisplayDialog("Caution!!", "Your last version(VER " + curMajor.ToString("D2") + "." + curMinor.ToString("D3") + ") data will remove complete. Are you sure?", "YES", "NO") == true) { // check last version Debug.Log("Rollback to previous Version >> " + prevVersion); // modify patch.xml file verDoc.SelectSingleNode("/VERSIONS/PATCH").Attributes["LastVersion"].Value = prevVersion; PatchVersion.removeVersionNode(verDoc, curMajor, curMinor); XmlTool.writeXml(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.patchVersionFN, verDoc); // remove assets.xml and files, and backup folder string _dn = CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/VER_" + curMajor.ToString("D2") + "/" + curMinor.ToString("D3"); Directory.Delete(_dn, true); // latest folder change Directory.Delete(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo, true); Directory.Move(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo + "_VER_" + curMajor.ToString("D2") + "_" + curMinor.ToString("D3"), CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget + "/" + CommonPatcherData.lastVersionRepo); lastMajorVersion = prevMajor; chkLastMajorVersion = curMajor.ToString("D2"); lastMinorVersion = prevMinor; chkLastMinorVersion = curMinor.ToString("D3"); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Path :"); CommonPatcherData.repoPath = GUILayout.TextField(CommonPatcherData.repoPath); // read config file if (GUILayout.Button("Read", GUILayout.Width(100))) { LoadConfigXML(CommonPatcherData.cnfFN); } if (GUILayout.Button("Save", GUILayout.Width(100))) { cnfDoc.SelectSingleNode("/ToolConfig/Repository").Attributes ["path"].Value = CommonPatcherData.repoPath; SaveConfigXML(CommonPatcherData.cnfFN, cnfDoc); MakeLocalRepo(); } GUILayout.EndHorizontal(); GUILayout.EndArea(); // command area GUILayout.BeginArea(new Rect(10, 100, 600, 140)); GUILayout.BeginHorizontal(); if (GUILayout.Button("Build AssetBundles", GUILayout.Width(150))) { ActiveABMWType = ABMWType.Build; BuildScript.BuildAssetBundles(); return; } if (GUILayout.Button("unregisted assets", GUILayout.Width(150))) { ActiveABMWType = ABMWType.Unregisted; checkUnregistedAssets(); } if (GUILayout.Button("All AssetBundles List", GUILayout.Width(150))) { ActiveABMWType = ABMWType.PatchInfo; checkRegistedAssets(); } if (GUILayout.Button("Upload to repository", GUILayout.Width(150))) { if (EditorUtility.DisplayDialog("Upload !!", "Did you make a folder for new version?! If not, press the button [apply]. This will make a folder and change the version number for new version.", "I DID!!", "Ooops!") == true) { ActiveABMWType = ABMWType.Upload; BuildScript.BuildAssetBundles(); // compare all AssetBundles with "repoPath + lastVersionRepo"'s all files List <FileInfo> listNew = new List <FileInfo>(); List <FileInfo> listModify = new List <FileInfo>(); List <FileInfo> listRemoved = new List <FileInfo>(); { DirectoryInfo latestDir = new DirectoryInfo(CommonPatcherData.repoPath + "/" + EditorUserBuildSettings.activeBuildTarget); FileInfo [] latestABFiles = latestDir.GetFiles("*.*", SearchOption.AllDirectories); DirectoryInfo buildDir = new DirectoryInfo(BuildScript.GetAssetBundleBuildPath() + "/" + EditorUserBuildSettings.activeBuildTarget); FileInfo [] newABFiles = buildDir.GetFiles("*.*", SearchOption.AllDirectories); int newIndex = 0; foreach (FileInfo fi in newABFiles) { int latestIndex = 0; foreach (FileInfo latefi in latestABFiles) { int ret = compareFile(fi, latefi); if (ret == 0) // completely different { } else if (ret == 1) // same exactly { break; } else if (ret == 2) // modified { listModify.Add(fi); break; } latestIndex++; } if (latestIndex == latestABFiles.Length) { listNew.Add(fi); } newIndex++; } foreach (FileInfo latefiR in latestABFiles) { int chkIndex = 0; foreach (FileInfo fiR in newABFiles) { if (fiR.Name == latefiR.Name) { break; } chkIndex++; } if (chkIndex == latestABFiles.Length) { listRemoved.Add(latefiR); } } } // upload updated AssetBundles to the new repository. SaveAssetsXML(listNew, listModify, listRemoved); } } GUILayout.EndHorizontal(); GUILayout.EndArea(); // console area GUILayout.BeginArea(new Rect(10, 150, 600, 600)); switch (ActiveABMWType) { case ABMWType.Build: break; case ABMWType.Unregisted: ListUnregistedAssets(); break; case ABMWType.PatchInfo: ListRegistedAssets(); break; case ABMWType.Upload: break; } GUILayout.EndArea(); }
public RavenVersionAttribute() { MajorVersion = _assemblyVersion.Major; MajorVersionAsChar = char.Parse(MajorVersion.ToInvariantString()); MinorVersion = _assemblyVersion.Minor; PatchVersion = _assemblyVersion.Build; AssemblyVersion = $"{MajorVersion.ToInvariantString()}.{MinorVersion.ToInvariantString()}.{PatchVersion.ToInvariantString()}.{BuildVersion.ToInvariantString()}"; }
/// <summary> /// Get a <see cref="PatchVersionException"/> from a <see cref="PatchVersion"/> value found in a patch file. /// </summary> /// <param name="found">Value</param> /// <returns>PatchVersionException</returns> public static PatchVersionException From(PatchVersion found) { return(new PatchVersionException(PatchUtils.PATCH_VERSION, PatchUtils.PATCH_PREVIOUS, found)); }
public PatchVersionException(PatchVersion current, PatchVersion found) { this.Current = current; this.Found = found; }
IEnumerator getPatchInfo(XmlDocument _verDoc) { // get all list for patching List <string> versions = PatchVersion.getPatchList(_verDoc, PatchVersion.major, PatchVersion.minor); // get all assetbundle's version when you got them last time. Dictionary <string, int> verList = PatchVersion.getAssetBundleVerList(); List <string> patchList = new List <string> (); Dictionary <string, string> patchListPath = new Dictionary <string, string> (); // file name, fullpath // sort patch files list foreach (string verStr in versions) { string [] ver = verStr.Split('_'); string listPath = url + ver[0] + "_" + ver[1] + "/" + ver[2] + "/" + CommonPatcherData.assetbundleFN; WWW patchListWWW = new WWW(listPath); yield return(patchListWWW); XmlDocument xmlDoc = XmlTool.loadXml(patchListWWW.bytes); if (xmlDoc != null) { { // create files XmlNode _nodeCreate = xmlDoc.SelectSingleNode("/AssetBundles/CREATE"); XmlNode _nodeC_Files = _nodeCreate.FirstChild; while (_nodeC_Files != null) { string name = _nodeC_Files.Attributes["name"].Value; if (patchList.FindIndex(delegate(string r){ return(r == name); }) == -1) { patchList.Add(name); } patchListPath[name] = url + ver[0] + "_" + ver[1] + "/" + ver[2] + "/" + name; _nodeC_Files = _nodeC_Files.NextSibling; } } { // modify files XmlNode _nodeModify = xmlDoc.SelectSingleNode("/AssetBundles/MODIFY"); XmlNode _nodeM_Files = _nodeModify.FirstChild; while (_nodeM_Files != null) { string name = _nodeM_Files.Attributes["name"].Value; if (patchList.FindIndex(delegate(string r){ return(r == name); }) == -1) { patchList.Add(name); } patchListPath[name] = url + ver[0] + "_" + ver[1] + "/" + ver[2] + "/" + name; _nodeM_Files = _nodeM_Files.NextSibling; } } } } // start downloading dictionary int count = 0; foreach (string name in patchList) { PatchMessage = "Downloading.. " + name + "(" + count + "/" + patchList.Count + ")"; int newversion = 0; if (verList.ContainsKey(name)) { newversion = verList[name] + 1; } else { verList.Add(name, 0); } yield return(StartCoroutine(Downloading(patchListPath[name], newversion))); verList[name] += 1; count++; PatchProgress = (count * 100) / patchList.Count; } PatchVersion.setAssetBundleVerList(verList); }
bool _IsAbleUpdateAssetBundles() { if (_serverVersion == null) { return false; } if (_localVersion == null) { _newVersion = _serverVersion; return true; } _newVersion = new PatchVersion(); _oldVersion = new PatchVersion(); for (int serverIndex = 0; serverIndex < _serverVersion.AssetCount; ++serverIndex) { AssetBundleInfo serverAsset = _serverVersion[serverIndex]; AssetBundleInfo localAsset = _localVersion[serverAsset.guid]; // compared update version if (localAsset == null || serverAsset.asset_version > localAsset.asset_version) { _newVersion[serverAsset.guid] = serverAsset; if (localAsset != null) { _oldVersion[localAsset.guid] = localAsset; } } } if (_newVersion.AssetCount > 0) { return true; } return false; }
void _OnFailedAssetBundlesDownloadSave() { LPetUtil.DebugLogf("Failed. Download server asset"); _newVersion.DeleteAssetBundles(); _serverVersion = null; _newVersion = null; _oldVersion = null; StartCoroutine(GetPatchVersionFromLocalStorage()); }
public IPatchBuilder WithVersion(PatchVersion patchVersion) { _patchContext.Version = patchVersion; return(this); }
private static void EditInstallation(string dcsRootPath, string jsonDirPath) { if (jsonDirPath == null) { if (!FileSystem.TryFindNearestDirectory("Tools\\ToolsCommon\\Data\\Viewports", out jsonDirPath)) { jsonDirPath = FileSystem.FindNearestDirectory("Data\\Viewports"); } } // open DCS installation location if (!InstallationLocation.TryLoadLocation(dcsRootPath, true, out InstallationLocation dcs)) { throw new Exception($"failed to open DCS installation at {dcsRootPath}"); } // pick JSON file from the given ones based on version number string exactName = $"ViewportTemplates_{PatchVersion.SortableString(dcs.Version)}.json"; string versionedJsonPath = ""; foreach (string candidate in Directory.EnumerateFiles(jsonDirPath, "ViewportTemplates_*.json", SearchOption.AllDirectories)) { string candidateName = Path.GetFileName(candidate); if (string.Compare(candidateName, exactName, StringComparison.InvariantCulture) > 0) { continue; } // applies if (string.Compare(candidateName, versionedJsonPath, StringComparison.InvariantCulture) > 0) { // new best match versionedJsonPath = candidate; } } string json = File.ReadAllText(Path.Combine(jsonDirPath, "ViewportTemplates.json")); List <ViewportTemplate> templates = JsonConvert.DeserializeObject <ViewportTemplate[]>(json).ToList(); if (versionedJsonPath == "") { ConfigManager.LogManager.LogInfo($"no ViewportTemplates_*.json file found that is applicable to selected DCS version {dcs.Version}"); } else { // read version specific changes and replace any entries by ModuleId string changesText = File.ReadAllText(versionedJsonPath); List <ViewportTemplate> changes = JsonConvert.DeserializeObject <ViewportTemplate[]>(changesText).ToList(); templates = templates.GroupJoin(changes, t => t.TemplateName, c => c.TemplateName, (original, applicableChanges) => applicableChanges.FirstOrDefault() ?? original).ToList(); } // get DCS location from the Helios utility that manages DCS install locations (have to use Profile Editor to configure it, either running dev build or start with --documents HeliosDev) string documentPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "HeliosDev"); if (!Directory.Exists(documentPath)) { documentPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Helios"); } HeliosInit.Initialize(documentPath, "EditViewports.log", LogLevel.Debug); ConfigManager.LogManager.LogInfo($"Editing viewport in DCS distribution {dcs.Path} of Version {dcs.Version}"); ConfigManager.LogManager.LogInfo($"Selected ViewportTemplates file {versionedJsonPath}"); PatchDestination destination = new PatchDestination(dcs); EditFilesInDestination(templates, destination); HeliosInit.OnShutdown(); }
private async Task OnExecuteAsync() { var toolsOption = GetToolsOptions(ConfigFilePath); LoadPlugins(toolsOption.RequiredPlugins); LoadPatchs(toolsOption.RequiredPatchs); toolPlugins = GetInstalledPlugins(toolsOption.RequiredPlugins); portalPatches = GetInstalledPortalPatchs(toolsOption.RequiredPatchs); identityPatches = GetInstalledIdentityPatchs(toolsOption.RequiredPatchs); bool isRunningPlugin = !IsPortal() && !IsIdentity(); // Check if run with mode patch bool isPatchRunning = false; if (!isRunningPlugin && !string.IsNullOrEmpty(PatchName) && Command != "install") { throw new NotSupportedException("Sorry, we only support -pn with install command."); } else if (!isRunningPlugin && !string.IsNullOrEmpty(PatchName) && Command == "install") { isPatchRunning = true; } IToolPlugin toolPlugin = isRunningPlugin ? toolPlugins.First(a => a.AppName == App) : null; var services = new ServiceCollection(); ConventionPackDefault.Register(); MongoDbRegistry.RegisterEntities(); var dbType = DatabseType.ToEnum <ConnectionType>(true); var databaseOption = new DatabaseOptions { ConnectionString = !string.IsNullOrEmpty(Connection) ? Connection : (isRunningPlugin ? toolPlugin.LoadDefaultDatabase().ConnectionString : GetDefaultConnectionString(dbType, App, toolsOption)), ConnectionType = dbType }; var runningCommand = GetAvailableCommands().FirstOrDefault(a => a.CommandName.ToLower() == Command.ToLower()); if (runningCommand != null) { ToolsContext toolsContext = null; var storingConnections = toolsOption.GetByDatabaseType(dbType); switch (dbType) { case ConnectionType.MongoDB: var mongoConnection = new MongoConnection(databaseOption); var mongoVersionContext = new MongoVersionContext(databaseOption); var versionMongoRepository = new VersionMongoRepository(mongoConnection); var patchMongoRepository = new PatchVersionMongoRepository(mongoConnection); mongoVersionContext.ConnectionType = ConnectionType.MongoDB; mongoVersionContext.DatabaseOptions = databaseOption; mongoVersionContext.PortalDatabaseOptions = toolsOption.MongoStoringConnections.PortalConnection; mongoVersionContext.ServiceManagementOptions = storingConnections.ServiceManagementConnection; mongoVersionContext.IdentityDbOptions = storingConnections.IdentityConnection; var latestVersion = await versionMongoRepository.GetLastestVersion(App); var allVersions = Enumerable.Empty <IVersion>(); IServiceProvider serviceProvider = null; PatchVersion latestPatchVersion = null; IPortalPatchFeatureTool portalPatchFeatureTool = null; IIdentityPatchFeatureTool identityPatchFeatureTool = null; if (IsPortal()) { RegisterServicesForPortal(services, databaseOption); if (isPatchRunning) { latestPatchVersion = await patchMongoRepository.GetLatestAsync(App, PatchName); portalPatchFeatureTool = portalPatches.First(a => a.PatchName == PatchName); portalPatchFeatureTool.RegisterServices(services, configuration); } serviceProvider = services.BuildServiceProvider(); allVersions = Scanner.GetAllPortalVersions(serviceProvider); } else if (IsIdentity()) { RegisterServicesForIdentity(services, databaseOption); if (isPatchRunning) { latestPatchVersion = await patchMongoRepository.GetLatestAsync(App, PatchName); identityPatchFeatureTool = identityPatches.First(a => a.PatchName == PatchName); identityPatchFeatureTool.RegisterServices(services, configuration); } serviceProvider = services.BuildServiceProvider(); allVersions = Scanner.GetAllIdentityVersions(serviceProvider); } else { var foundPlugin = toolPlugins.First(a => a.AppName.Equals(App, StringComparison.OrdinalIgnoreCase)); foundPlugin.RegisterServices(services, configuration); serviceProvider = services.BuildServiceProvider(); allVersions = foundPlugin.GetAllVersions(serviceProvider); } toolsContext = new ToolsContext { LatestVersion = latestVersion, LatestPatchVersion = latestPatchVersion, VersionContext = mongoVersionContext, VersionNumber = VersionNumber, Versions = allVersions, VersionRepository = versionMongoRepository, PatchesFolder = PatchesFolder, AllowPatch = !string.IsNullOrEmpty(PatchesFolder), Services = serviceProvider, PatchVersionRepository = patchMongoRepository, CurrentPatchPortal = portalPatchFeatureTool, CurrentIdentityPortal = identityPatchFeatureTool, Arguments = CombineArguments() }; break; case ConnectionType.PostgreSQL: case ConnectionType.MySQL: case ConnectionType.SQLServer: #pragma warning disable CA2000 // Dispose objects before losing scope var letportalContext = new SaturnFullContext(databaseOption); #pragma warning restore CA2000 // Dispose objects before losing scope letportalContext.Database.EnsureCreated(); #pragma warning disable CA2000 // Dispose objects before losing scope var letportalContextForRepo = new SaturnFullContext(databaseOption); #pragma warning restore CA2000 // Dispose objects before losing scope var sqlEFVersionContext = new EFVersionContext(letportalContext) { ConnectionType = dbType, DatabaseOptions = databaseOption }; var patchEFRepository = new PatchVersionEFRepository(letportalContextForRepo); var portalVersionRepository = new VersionEFRepository(letportalContextForRepo); var latestVersionEF = await portalVersionRepository.GetLastestVersion(App); sqlEFVersionContext.ServiceManagementOptions = storingConnections.ServiceManagementConnection; sqlEFVersionContext.IdentityDbOptions = storingConnections.IdentityConnection; sqlEFVersionContext.PortalDatabaseOptions = storingConnections.PortalConnection; var sqlAllVersions = Enumerable.Empty <IVersion>(); IServiceProvider sqlServiceProvider = null; PatchVersion latestEFPatchVersion = null; IPortalPatchFeatureTool portalEFPatchFeatureTool = null; IIdentityPatchFeatureTool identityEFPatchFeatureTool = null; if (IsPortal()) { RegisterServicesForPortal(services, databaseOption); if (isPatchRunning) { latestEFPatchVersion = await patchEFRepository.GetLatestAsync(App, PatchName); portalEFPatchFeatureTool = portalPatches.First(a => a.PatchName == PatchName); portalEFPatchFeatureTool.RegisterServices(services, configuration); } sqlServiceProvider = services.BuildServiceProvider(); sqlAllVersions = Scanner.GetAllPortalVersions(sqlServiceProvider); } else if (IsIdentity()) { RegisterServicesForIdentity(services, databaseOption); if (isPatchRunning) { latestEFPatchVersion = await patchEFRepository.GetLatestAsync(App, PatchName); identityEFPatchFeatureTool = identityPatches.First(a => a.PatchName == PatchName); identityEFPatchFeatureTool.RegisterServices(services, configuration); } sqlServiceProvider = services.BuildServiceProvider(); sqlAllVersions = Scanner.GetAllIdentityVersions(sqlServiceProvider); } else { var foundPlugin = toolPlugins.First(a => a.AppName.Equals(App, StringComparison.OrdinalIgnoreCase)); foundPlugin.RegisterServices(services, configuration); sqlServiceProvider = services.BuildServiceProvider(); sqlAllVersions = foundPlugin.GetAllVersions(sqlServiceProvider); } toolsContext = new ToolsContext { LatestVersion = latestVersionEF, VersionContext = sqlEFVersionContext, VersionNumber = VersionNumber, Versions = sqlAllVersions, VersionRepository = portalVersionRepository, AllowPatch = !string.IsNullOrEmpty(PatchesFolder), Services = sqlServiceProvider, Arguments = CombineArguments(), PatchesFolder = PatchesFolder, PatchVersionRepository = patchEFRepository, CurrentPatchPortal = portalEFPatchFeatureTool, CurrentIdentityPortal = identityEFPatchFeatureTool }; break; } if (toolsContext != null) { Console.WriteLine(""); await runningCommand.RunAsync(toolsContext); toolsContext.Dispose(); } Console.WriteLine("-----------------------++++++DONE++++++-------------------------"); } else { Console.WriteLine("Oops! We don't find any matching command to execute. If you don't know how to run, please type '--help'"); } Console.ReadLine(); }
public IEnumerator GetPatchVersionFromServer() { string patchVersionPath = _GetPatchVersionPath(PATCH_VERSION_PATH.SERVER); LPetUtil.DebugLogf("Server patchversion path<{0}>", patchVersionPath); using (WWW www = new WWW(patchVersionPath)) { yield return www; if (www.error != null) { LPetUtil.DebugLogf("WWW errro, server version has an error:" + www.error); StartCoroutine(GetPatchVersionFromLocalStorage()); yield break; } LPetUtil.DebugLogf("Server version find!"); _serverVersion = new PatchVersion(); _serverVersion.PatchVersionJsonParser(www.text); StartCoroutine(GetPatchVersionFromLocalStorage()); } }
public PatchVersionException(PatchVersion current, PatchVersion previous, PatchVersion found) { this.Current = current; this.Found = found; this.Previous = previous; }
IEnumerator _GetPatchVersionFromPackage() { string patchVersionPath = _GetPatchVersionPath(PATCH_VERSION_PATH.PACKAGE); LPetUtil.DebugLogf("Package patchversion path<{0}>", patchVersionPath); using (WWW www = new WWW(patchVersionPath)) { yield return www; if (www.error != null) { LPetUtil.DebugLogf("WWW error version has an error:" + www.error); _OnFailedAssetBundlesLoad(); } _localVersion = new PatchVersion(); _localVersion.PatchVersionJsonParser(www.text); StartCoroutine(_localVersion.LoadAssetBundles(_OnCompletedAssetBundlesLoad, _OnFailedAssetBundlesLoad)); } }