private string GetExternalDownloads(List <AssetServerAsset> ListOfAssets, string AboveVersion, Boolean IsUpdate) { StringBuilder ret = new StringBuilder(); if (IsUpdate) { ret.Append("<b>Update:</b> "); } else { ret.Append("<b>Download:</b> "); } string Seperator = " | "; foreach (AssetServerAsset asset in ListOfAssets) { AssetVersion thisVersion = new AssetVersion(asset.Version); AssetVersion comparedVersion = new AssetVersion(AboveVersion); if (thisVersion.CompareTo(comparedVersion) > 0) { ret.AppendFormat("<a href=\"{0}\" target=\"_blank\">{1} {2}</a>{3}", asset.Link, asset.Title, asset.Version, Seperator); } } String retS = ret.ToString(); if (retS.Length > Seperator.Length && retS.EndsWith(Seperator)) { retS = retS.Substring(0, retS.Length - Seperator.Length); } return(retS); }
// install version locally protected async Task InstallVersion(string assetsVersion) { // check if folder versions already exist in local file system and ignore otherwise string clientAssetsVersionRoot = GetClientPath(assetsVersion); string serverAssetsVersionRoot = GetServerPath(assetsVersion); if (!Directory.Exists(clientAssetsVersionRoot) || !Directory.Exists(serverAssetsVersionRoot)) { // check if version exists in remote storage and error otherwise if (!(await storageService.Exists(assetsVersion))) { throw new Exception("Could not find asset version in remote storage"); } // TODO - make externals scripts file installable/invalidate cache and read from it (allows full frontend deployment) // copy versioned folder from remote storage to local storage await storageService.Copy($"{assetsVersion}/client", clientAssetsVersionRoot); await storageService.Copy($"{assetsVersion}/server", serverAssetsVersionRoot); } // change last updated version Models.Settings.AppClock appClock = await settingsService.GetClock(); AssetVersion updated = new AssetVersion(assetsVersion, appClock.CurrentTime); await SetLastUpdatedVersion(updated); // cleanup orphaned versions if they exist await CleanOrphanedVersions(); }
void SetVersionList(LoadingInfo info) { for (int i = 0; i < info.patch_list.Length; i++) { var p = info.patch_list[i]; AssetVersion.AddVersionList(p.version); } }
void initAssetManager() { string[] strs = System.Enum.GetNames(typeof(NEngine.Game.GameEnum)); for (int i = 0; i < strs.Length; i++) { AssetVersion ver1 = AssetVersion.FromString(FileUtil.ReadFromFile(appConfigPath_old + "/Conn/" + strs[i] + "/assetVersion.config")); AssetbundleConfig ver2 = AssetbundleConfig.FromString(FileUtil.ReadFromFile(appConfigPath_old + "/Conn/" + strs[i] + "/abConfig.config")); PreloadConfig ver3 = PreloadConfig.FromString(FileUtil.ReadFromFile(appConfigPath_old + "/Conn/" + strs[i] + "/preloadConfig.config")); App.GetMgr <AssetManager>().AddAssetConfig(strs[i], new AssetConfig(strs[i], ver1, ver2, ver3)); } }
private void OnDownLoadApkCompleted(bool ok, AssetVersion assetVersion) { if (ok) { this.step = Step.Completed; } else { this.step = Step.DownLoadFailed; } }
public async Task PublishVersion(string assetsVersion) { AssetVersion previouslyPublishedVersion = await GetPublishedVersion(); Models.Settings.AppClock appClock = await settingsService.GetClock(); await SetPublishedVersion(new AssetVersion(assetsVersion, appClock.CurrentTime)); if (previouslyPublishedVersion != null) { await SetPreviousPublishedVersion(previouslyPublishedVersion); } }
public override async Task <AssetInstance[]> GetInstances() { // in a non-distributed system we only have one instance (the current one) AssetVersion[] versions = await GetUsableVersions(); string host = this.httpContextAccessor.HttpContext.Request.Host.Host; AssetVersion downloadingVersion = await GetDownloadingVersion(); AssetInstance instance = new AssetInstance(host, versions, downloadingVersion); return(new AssetInstance[] { instance }); }
protected async Task <AssetVersion> GetDownloadingVersion() { AssetVersion[] installedVersions = await GetUsableVersions(); AssetVersion lastUpdatedVersion = await GetLastUpdatedVersion(); if (!installedVersions.Contains(lastUpdatedVersion)) { return(lastUpdatedVersion); } return(null); // not currently downloading a version since it already exists }
private static void RemoteVersionDownloadFinished(AssetUpdater updater, int assetIndex) { AssetVersion remote = updater.GetRemoteVersion(0); AssetVersion local = updater.GetLocalVersion(0); AssetUpdater.Instance.remoteVersionDownloadFinished -= RemoteVersionDownloadFinished; AssetUpdater.Instance.remoteVersionDownloadFailed -= RemoteVersionDownloadFailed; if (remote.Version.ToString() != local.Version.ToString()) { AssetUpdateWindow.Init(); } }
static Dictionary <string, AssetVersion> ParseAssetVersions(string assetVersionFile) { assetVersions.Clear(); var lines = assetVersionFile.Split(FileExtension.lineSplit, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < lines.Length; i++) { var assetVersion = new AssetVersion(lines[i]); assetVersions[assetVersion.relativePath] = assetVersion; } return(assetVersions); }
string[] getUpdatelist() { string[] uplist = null; string[] strs = System.Enum.GetNames(typeof(NEngine.Game.GameEnum)); for (int i = 0; i < strs.Length; i++) { AssetVersion ver1 = AssetVersion.FromString(FileUtil.ReadFromFile(appConfigPath_new + "/Conn/" + strs[i] + "/assetVersion.config")); AssetVersion ver2 = AssetVersion.FromString(FileUtil.ReadFromFile(appConfigPath_old + "/Conn/" + strs[i] + "/assetVersion.config")); if (ver1 == null || ver2 == null) { Debug.LogError(string.Format("{0} assetversion is null", strs[i])); continue; } uplist = AssetVersion.CompareAndGetUpdateList(ver2, ver1); } return(uplist); }
protected async Task SetPublishedVersion(AssetVersion version) { // don't allow the publishing of a version that hasn't been installed on all instances AssetInstance[] instances = await GetInstances(); bool isVersionInstalled = instances.All(i => { return(i.InstalledVersions.Contains(version)); }); if (!isVersionInstalled) { throw new Exception("Cannot publish version that hasn't been installed to all instances"); } await SetVersion(AppConstants.CacheKeys.publishedVersion, version); this.publishedVersion = GetLazyVersion(AppConstants.CacheKeys.publishedVersion); }
/// <summary> /// 生成资源配置信息: 资源包信息, 资源与包的关系信息 /// </summary> static void CreatAssetversionInfo(string game) { Dictionary <string, Hash128> abDic = new Dictionary <string, Hash128>(); string manifestFolder = game + "_ab"; string mainFolder = game + "_Res"; mainFolder = mainFolder.ToLower(); GetABInfo(game, pathRes_Editor + "/" + manifestFolder + "/" + mainFolder, ref abDic); AssetVersion rinfo = new AssetVersion(); rinfo.manifestName = mainFolder + "/" + manifestFolder; // 将manifest文件放入对应游戏资源子目录下 foreach (KeyValuePair <string, Hash128> kp in abDic) { rinfo.bundlesInfo.Add(kp.Key, kp.Value); } string path = pathConfig_Editor + "/" + game + "/assetVersion.config"; FileUtil.SaveFile(path, rinfo.ToStr()); CopyToStreamingAssets(game, path); }
void initAppConfig() { string[] gs = System.Enum.GetNames(typeof(GameEnum)); APPVersion app = new APPVersion(); //AssetConfig for (int i = 0; i < gs.Length; i++) { GameVersion ver = new GameVersion(gs[i], "name:" + gs[i]); app.Add(ver); AssetVersion aver = new AssetVersion(); aver.assetVersion = 0; AssetbundleConfig abcon = new AssetbundleConfig(); abcon.AddAssetBundle("test", "has001"); PreloadConfig pre = new PreloadConfig(); FileUtil.SaveFile(path + "/" + gs[i] + "/assetVersion.config", aver.ToStr()); FileUtil.SaveFile(path + "/" + gs[i] + "/abConfig.config", abcon.ToString()); FileUtil.SaveFile(path + "/" + gs[i] + "/preloadConfig.config", pre.ToString()); } FileUtil.SaveFile(path + "/appVersion.config", app.ToString()); //appversion }
protected AssetConfig LoadLocalConfig(string game) { Debug.Log("资源配置文件loading"); string path = Application.streamingAssetsPath + "/CONFIG/" + game; string[] files = System.IO.Directory.GetFiles(path); AssetbundleConfig bundle = null; AssetVersion assetversion = null; PreloadConfig preload = null; string str = ""; string name = ""; for (int i = 0; i < files.Length; i++) { str = ""; using (System.IO.StreamReader sr = new System.IO.StreamReader(files[i])) { name = Util.GetFileName(files[i]); str = sr.ReadToEnd(); //str = System.Text.Encoding.UTF8.GetString(System.Text.Encoding.UTF8.GetBytes(str)); if (name == "bundle.config") { bundle = AssetbundleConfig.FromString(str); } else if (name == "assetVersion.config") { assetversion = AssetVersion.FromString(str); } else if (name == "preload.config") { preload = PreloadConfig.FromString(str); } sr.Close(); } } return(new AssetConfig(game, assetversion, bundle, preload)); }
protected void PrepareVRCPathForS3(string abPath, string blueprintId, int version, AssetVersion assetVersion) { uploadVrcPath = Application.temporaryCachePath + "/" + blueprintId + "_" + version.ToString() + "_" + Application.unityVersion + "_" + assetVersion.ApiVersion + "_" + API.GetAssetPlatformString() + "_" + API.GetServerEnvironmentForApiUrl() + System.IO.Path.GetExtension(abPath); uploadVrcPath.Trim(); uploadVrcPath.Replace(' ', '_'); if (System.IO.File.Exists(uploadVrcPath)) { System.IO.File.Delete(uploadVrcPath); } System.IO.File.Copy(abPath, uploadVrcPath); }
public async Task <string> GetCurrentVersion() { AssetVersion publishedVersion = await GetPublishedVersion(); return(publishedVersion != null ? publishedVersion.Version : AppConstants.Assets.defaultAssetVersion); }
protected async Task SetPreviousPublishedVersion(AssetVersion version) { await SetVersion(AppConstants.CacheKeys.previouslyPublishedVersion, version); this.previouslyPublishedVersion = GetLazyVersion(AppConstants.CacheKeys.previouslyPublishedVersion); }
private async Task SetVersion(string cacheKey, AssetVersion version) { await this.distributedCache.SetAsync <AssetVersion>(cacheKey, version, new DistributedCacheEntryOptions()); }
public void BuildGatewayList() { String GW = AppLogic.ActivePaymentGatewayCleaned(); List <GatewayData> ds = new List <GatewayData>(); String downloadLink = "<br /><a href=\"{1}\" onclick=\"showGatewayDirections('{2}');\">{0}</a>"; if (repGateways.DataSource == null) { Dictionary <String, List <AssetServerAsset> > serverAssets = AssetServer.AssetServerAsset.GetAssetServerAssets(); IEnumerable <string> availibleGateways = GatewayLoader.GetAvailableGatewayNames(); foreach (String s in availibleGateways) { GatewayProcessor GWActual = GatewayLoader.GetProcessor(s); GatewayData gd = new GatewayData(); gd.DisplayName = GWActual.DisplayName(ThisCustomer.LocaleSetting); gd.AdministratorSetupPrompt = GWActual.AdministratorSetupPrompt; if (serverAssets.ContainsKey(GWActual.TypeName)) { if (serverAssets[GWActual.TypeName].Count == 0) { return; } AssetServer.AssetVersion dllVersion = new AssetVersion(GWActual.Version); AssetServer.AssetVersion availibleVersion = new AssetVersion(serverAssets[GWActual.TypeName][0].Version); if (availibleVersion.CompareTo(dllVersion) > 0) { gd.AdministratorSetupPrompt += "<b>Download Update</b>"; foreach (AssetServerAsset asa in serverAssets[GWActual.TypeName]) { gd.AdministratorSetupPrompt += String.Format(downloadLink, asa.Title + " (" + asa.Version + ")", asa.Link, CommonLogic.IIF(String.IsNullOrEmpty(asa.DownloadInstructions), String.Empty, HttpContext.Current.Server.HtmlEncode(asa.DownloadInstructions))); } } serverAssets.Remove(GWActual.TypeName); } gd.IsInstalled = true; gd.GatewayIdentifier = s; ds.Add(gd); } // foreach (KeyValuePair <String, List <AssetServerAsset> > sa in serverAssets) { if (sa.Value.Count == 0) { break; } GatewayData gd = new GatewayData(); gd.DisplayName = sa.Value[0].Title; gd.IsInstalled = false; StringBuilder setupPrompt = new StringBuilder(); setupPrompt.Append("<b>Download</b>"); foreach (AssetServerAsset asa in sa.Value) { setupPrompt.AppendFormat(downloadLink, asa.Title, asa.Link, CommonLogic.IIF(String.IsNullOrEmpty(asa.DownloadInstructions), String.Empty, HttpContext.Current.Server.HtmlEncode(asa.DownloadInstructions))); } gd.AdministratorSetupPrompt = setupPrompt.ToString(); ds.Add(gd); } ds.Add(CreateGatewayData("PayPal Payflow Link", "PayFlowPro", "(also enables PayPal Express Checkout) - See <a href=\"http://www.aspdotnetstorefront.com/linkmanager.aspx?topic=paypalpayflowlink&type=manual\" target=\"_blank\">Manual</a>.")); ds.Add(CreateGatewayData("PayPal Payments Advanced", "PayFlowPro", "(also enables PayPal Express Checkout) - See <a href=\"http://www.aspdotnetstorefront.com/linkmanager.aspx?topic=paypalpaymentsadvanced&type=manual\" target=\"_blank\">Manual</a>.")); ds = ds.Where(gd => IsPaymentOptionAvailable(gd.DisplayName, ddlCountries.SelectedValue)).ToList(); ds = SortGatewayList(ds); repGateways.DataSource = ds; repGateways.DataBind(); } }
IEnumerator LoadPatch() { string platfrom = GetPlatformName(); if (string.IsNullOrEmpty(platfrom)) { platfrom = Application.platform.ToString(); } step = Step.Check; string fullURL = gameURL + "patch/index2.php?" + HTTPQueryStr; // He platform=" + platfrom + "&v=" + Application.version + "&t=" + versionTag; Debug.LogFormat(fullURL); WWW www = new WWW(fullURL); yield return(www); if (!string.IsNullOrEmpty(www.error)) { Debug.Log(www.error); message.text = "加载补丁列表失败"; if (reloadButton != null && (versionTag == "test" || versionTag == "dev")) { reloadButton.SetActive(true); } yield break; } #if UNITY_EDITOR if (!AssetManager.SimulateMode) #endif { ResourceBundle.Clear(); AssetManager.Clear(); } LoadingInfo info = JsonUtility.FromJson <LoadingInfo>(www.text); Debug.Log(www.text); if (!string.IsNullOrEmpty(info.bundleURL)) { bundleURL = info.bundleURL; } server_list = info.server_list; serverTag = info.tag; if (string.IsNullOrEmpty(info.asset_version)) { info.asset_version = AssetVersion.Version; } versionString = string.Format("{0}:{1}:{2}", Application.version, AssetVersion.Version, info.asset_version); versionText.text = versionString; Debug.Log("version:" + versionString); Dictionary <string, string> localbundles = new Dictionary <string, string>(); do { #if UNITY_EDITOR if (AssetManager.SimulateMode) { break; } #endif if (AssetVersion.Version == info.asset_version) { break; } List <PatchInfo> lpds = GetLocalBundles(info, ref localbundles); total_count = lpds.Count; loaded_count = 0; int patchDownLoadTotalSize = 0; for (int i = 0; i < total_count; ++i) { patchDownLoadTotalSize += lpds[i].size; } OSTools.AlertDialog("提示", string.Format("您将下载 {0} MB 的资源", patchDownLoadTotalSize / 1024 / 1024), "确认", () => { patchDownLoadTotalSize = 0; }, "取消", () => { Application.Quit(); }); while (patchDownLoadTotalSize > 0) { yield return(null); } for (int i = 0; i < total_count; ++i) { var patch = lpds[i]; string url = patch.file; if (!url.StartsWith("http://")) { url = info.patchURL + "/" + url; } step = Step.Down; // current_file = patch.file; Debug.LogFormat("down patch {0}", url); loading_www = new WWW(url); yield return(loading_www); if (loading_www.error != null && !loading_www.error.Equals("")) { message.text = "下载补丁文件失败"; yield break; } if (loading_www.bytesDownloaded != patch.size) { Debug.LogError("down load patch error, patch file:" + patch.file); break; } step = Step.Unzip; message.text = "解压文件..."; process = 1; yield return(new WaitForSeconds(0.1f)); List <string> files = new List <string>(); unzipFile(loading_www.bytes, Application.persistentDataPath + "/" + patch.version, (string name) => { files.Add(name); }); step = Step.Install; message.text = "安装补丁..."; process = 0; yield return(new WaitForSeconds(0.1f)); bool flag = false; AssetVersion.StartAddBundle(patch.version); int c = 0; foreach (var p in files) { if (!MergePatch(p, patch, ref localbundles)) { flag = true; break; } AssetVersion.AddBundle(p.Replace(".patch", "")); message.text = string.Format("正在安装补丁:{0}/{1}", ++c, files.Count); process = c / (float)files.Count; yield return(null); } AssetVersion.EndAddBundle(); message.text = "安装补丁结束"; process = 1; yield return(null); if (flag) { AssetVersion.ClearBundle(patch.version); break; } AssetVersion.Version = patch.version; AssetVersion.Flush(); loaded_count += 1; } if (loaded_count != total_count) { break; } versionText.text = string.Format("{0}:{1}:{2}", Application.version, AssetVersion.Version, info.asset_version); loading_www = null; Caching.ClearCache(); } while (false); if (loaded_count != total_count || total_count == 0) { localbundles.Clear(); GetLocalBundles(info, ref localbundles); } foreach (var iter in localbundles) { var v = iter.Value; string bundlename = iter.Key; string abrepath = v + "/" + bundlename; string fullpath = Application.persistentDataPath + "/" + abrepath; if (Path.GetFileName(abrepath).StartsWith("hotfix")) { ResourceBundle.Replace(bundlename, fullpath); } else { if (PatchFiles.ContainsKey(bundlename)) { PatchFiles[bundlename] = v; } else { PatchFiles.Add(bundlename, v); } } } SetVersionList(info); Statistics.GetCache(this); AssetManager.Init(); message.text = total_count != 0 && loaded_count != total_count ? "补丁更新失败,正在使用本地版本进入游戏" : "加载游戏中..."; step = Step.Enter; process = 0; versionString = string.Format("{0}:{1}:{2}", Application.version, AssetVersion.Version, info.asset_version); yield return(new WaitForSeconds(0.22f)); patch_is_ready = true; StartCoroutine(BundleManager.DownAndLoadThread()); StartCoroutine(AssetManager.CheckMemoryThread()); }
protected void PrepareUnityPackageForS3(string packagePath, string blueprintId, int version, AssetVersion assetVersion) { uploadUnityPackagePath = Application.temporaryCachePath + "/" + blueprintId + "_" + version.ToString() + "_" + Application.unityVersion + "_" + assetVersion.ApiVersion + "_" + ApiModel.GetAssetPlatformString() + "_" + ApiModel.GetServerEnvironmentForApiUrl() + ".unitypackage"; uploadUnityPackagePath.Trim(); uploadUnityPackagePath.Replace(' ', '_'); if (System.IO.File.Exists(uploadUnityPackagePath)) { System.IO.File.Delete(uploadUnityPackagePath); } System.IO.File.Copy(packagePath, uploadUnityPackagePath); }
protected void PreparePluginPathForS3(string pluginPath, string blueprintId, int version, AssetVersion assetVersion) { uploadPluginPath = Application.temporaryCachePath + "/" + blueprintId + "_" + version.ToString() + "_" + Application.unityVersion + "_" + assetVersion.ApiVersion + "_" + VRC.Tools.Platform + "_" + API.GetServerEnvironmentForApiUrl() + ".dll"; uploadPluginPath.Trim(); uploadPluginPath.Replace(' ', '_'); if (System.IO.File.Exists(uploadPluginPath)) { System.IO.File.Delete(uploadPluginPath); } System.IO.File.Copy(pluginPath, uploadPluginPath); }
protected async Task SetLastUpdatedVersion(AssetVersion version) { await SetVersion(AppConstants.CacheKeys.lastUpdatedVersion, version); this.lastUpdatedVersion = GetLazyVersion(AppConstants.CacheKeys.lastUpdatedVersion); }
protected void PreparePluginPathForS3(string pluginPath, string blueprintId, int version, AssetVersion assetVersion) { uploadPluginPath = Application.temporaryCachePath + "/" + blueprintId + "_" + version.ToString() + "_" + Application.unityVersion + "_" + assetVersion.ApiVersion + "_" + ApiModel.GetAssetPlatformString() + (IsUsingDevAPI() ? "_dev" : "_release") + ".dll"; uploadPluginPath.Trim(); uploadPluginPath.Replace(' ', '_'); if (System.IO.File.Exists(uploadPluginPath)) { System.IO.File.Delete(uploadPluginPath); } System.IO.File.Copy(pluginPath, uploadPluginPath); }
public static bool IsNewAssets(AssetVersion _old, AssetVersion _new, out Dictionary <string, Hash128> newDic) { AssetVersion.CompareAndGetUpdateList(_old, _new, out newDic); return(newDic.Count != 0); }