public static bool BundleMap() { System.DateTime lastTime = System.DateTime.Now; string sOutDir = AppPackage.AddStamp(ms_sDataOutDir); string[] files = AppPackage.GetFiles(new string[] { ms_sMapDir }, new string[] { "*.unity" }, true); AppPackage.BundleFiles(sOutDir, files, BuildAssetBundleOptions.DeterministicAssetBundle, false); /*// 生成MD5 * Dictionary<string, string> dicMD5 = new Dictionary<string, string>(); * Dictionary<string, int> dicSize = new Dictionary<string, int>(); * string[] fls = GetFiles(new string[] { sOutDir }, new string[] { "*" + GameConfigMgr.ms_sABType }, false); * System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); * for (int i = 0; i < fls.Length; i++) * { * byte[] bt = File.ReadAllBytes(fls[i]); * int nLen = bt.Length; * string sMD5 = System.BitConverter.ToString(md5.ComputeHash(bt)); * string path = fls[i].Substring(sOutDir.Length, fls[i].Length - sOutDir.Length - GameConfigMgr.ms_sABType.Length); * dicMD5.Add(path, sMD5); * dicSize.Add(path, nLen); * File.WriteAllBytes(fls[i] + GameConfigMgr.ms_sMD5Type, System.Text.Encoding.UTF8.GetBytes(sMD5)); * } * md5.Clear();*/ System.TimeSpan costTime = System.DateTime.Now - lastTime; Debug.Log("-->> BundleMap Cost: " + (costTime.Hours * 3600 + costTime.Minutes * 60 + costTime.Seconds).ToString() + "s"); return(true); }
//creates an activity with 2 inputs and variable number of outputs. All outsputs are places //in a folder 'outputs' static Activity CreateActivity(AppPackage package) { Console.WriteLine("Creating/Updating Activity..."); var activity = new Activity() { Id = ActivityName, Instruction = new Instruction() { Script = "_tilemode\n1\n_filedia\n0\nCreateCloset\n6\n3\n8\n2\n40\n3\n1\n_.VSCURRENT\nsketchy\n_.Zoom\nExtents\n_.SaveAs\n\nResult.dwg\n" }, Parameters = new Parameters() { InputParameters = { new Parameter() { Name = "HostDwg", LocalFileName = "$(HostDwg)" }, }, OutputParameters = { new Parameter() { Name = "Result", LocalFileName = "Result.dwg" } } }, RequiredEngineVersion = "21.0" }; activity.AppPackages.Add(PackageName); // reference the custom AppPackage container.AddToActivities(activity); container.SaveChanges(); return(activity); }
public async Task ExportTest() { Store.SqlStore.SetDefaultSqlStore(new Store.PgSqlStore(StoreSettings)); var appId = 3250279307u; //env, sys=2660935927 var appName = "env"; var pkg = new AppPackage(); await Store.ModelStore.LoadToAppPackage(appId, appName, pkg); //序列化 using var wfs = File.OpenWrite($"{appName}.apk"); var wbs = new BinSerializer(wfs); wbs.Serialize(pkg); wfs.Close(); //反序列化 using var rfs = File.OpenRead($"{appName}.apk"); var rbs = new BinSerializer(rfs); var res = (AppPackage)rbs.Deserialize(); foreach (var model in res.Models) { output.WriteLine($"{model.Name} {model.ModelType}"); } }
protected override void Execute(CodeActivityContext context) { AndroidDriver <AndroidElement> driver; // Inherit driver from scope activity OR from input (if out of context) try { driver = context.DataContext.GetProperties()["Driver"].GetValue(context.DataContext) as AndroidDriver <AndroidElement>; } catch { driver = Driver.Get(context); } string appPackage = AppPackage.Get(context); string appActivity = AppActivity.Get(context); try { driver.StartActivity(appPackage, appActivity); } catch (Exception) { throw; } }
static AppPackage CreateOrUpdatePackage(string zip, AppPackage package) { Console.WriteLine("Creating/Updating AppPackage..."); // First step -- query for the url to upload the AppPackage file var url = container.AppPackages.GetUploadUrl().GetValue(); // Second step -- upload AppPackage file UploadObject(url, zip); if (package == null) { // third step -- after upload, create the AppPackage entity package = new AppPackage() { Id = PackageName, RequiredEngineVersion = "20.1", Resource = url }; container.AddToAppPackages(package); } else { //or update the existing one with the new url package.Resource = url; container.UpdateObject(package); } container.SaveChanges(); return package; }
static AppPackage CreateOrUpdatePackage(string zip, AppPackage package) { Console.WriteLine("Creating/Updating AppPackage..."); // First step -- query for the url to upload the AppPackage file var url = container.AppPackages.GetUploadUrl().GetValue(); // Second step -- upload AppPackage file UploadObject(url, zip); if (package == null) { // third step -- after upload, create the AppPackage entity package = new AppPackage() { Id = PackageName, RequiredEngineVersion = "21.0", Resource = url }; container.AddToAppPackages(package); } else { //or update the existing one with the new url package.Resource = url; container.UpdateObject(package); } container.SaveChanges(); return(package); }
//[MenuItem("WCTool/AlterAssets")] static void AlterAssets() { string[] uiFiles = AppPackage.GetFiles(new string[] { GameConfigMgr.ms_sDataDir + GameConfigMgr.ms_sDataFolderName + "/" + GameConfigMgr.ms_sUIFolderName + "/" }, new string[] { "*.prefab" }, true); for (int i = 0; i < uiFiles.Length; i++) { GameObject assObj = AssetDatabase.LoadAssetAtPath(uiFiles[i], typeof(GameObject)) as GameObject; Debug.LogWarningFormat("--------- Check GameObject CanvasRenderer: {0}", uiFiles[i]); Component[] coms = assObj.GetComponents(typeof(Component)); if (coms.Length == 2) { if ((coms[0].GetType() == typeof(RectTransform) && coms[1].GetType() == typeof(CanvasRenderer)) || ((coms[0].GetType() == typeof(CanvasRenderer) && coms[1].GetType() == typeof(RectTransform)))) { CanvasRenderer crcom = null; if (coms[0].GetType() == typeof(CanvasRenderer)) { crcom = coms[0] as CanvasRenderer; } else { crcom = coms[1] as CanvasRenderer; } GameObject.DestroyImmediate(crcom, true); Debug.LogWarningFormat("This Node Only Component(CanvasRenderer) {0}", assObj.name); } } RemoveComponent(assObj); } }
internal static async Task <UpdateFunctionCodeResponse> UpdateFunctionCodeAsync ( this AmazonLambdaClient client, AppPackage package, ASPNetServerLessPublishAWSLambdaConfigSection lambdaConfig, CancellationToken cancellationToken = default(CancellationToken) ) { var response = (UpdateFunctionCodeResponse)null; using (var packageStream = new MemoryStream(package.PackageBytes)) { var updateCodeRequest = new UpdateFunctionCodeRequest() { FunctionName = lambdaConfig.FunctionName, ZipFile = packageStream }; response = await client.UpdateFunctionCodeAsync(updateCodeRequest, cancellationToken).ConfigureAwait(false); updateCodeRequest = null; } return(response); }
public void TestGetMissingDependencies_Missing( ) { Solution appA = new Solution { Name = "appA" }; Solution appB = new Solution { Name = "appB" }; Solution appC = new Solution { Name = "appC" }; ApplicationDependency aDependsOnB = new ApplicationDependency { Name = "appA depends on appB", DependentApplication = appA, DependencyApplication = appB }; appA.DependentApplicationDetails.Add(aDependsOnB); appA.Save( ); ApplicationDependency bDependsOnC = new ApplicationDependency { Name = "appB depends on appC", DependentApplication = appB, DependencyApplication = appC }; appB.DependentApplicationDetails.Add(bDependsOnC); appB.Save( ); AppManager.PublishApp(RunAsDefaultTenant.DefaultTenantName, "appA"); AppManager.PublishApp(RunAsDefaultTenant.DefaultTenantName, "appB"); long tenantId = TenantHelper.CreateTenant("ABC"); AppManager.DeployApp("ABC", Applications.CoreApplicationId.ToString("B")); Guid appAUpgradeId = Entity.GetUpgradeId(appA.Id); using (new GlobalAdministratorContext( )) { AppPackage appPackage = SystemHelper.GetLatestPackageByGuid(appAUpgradeId); var applicationDependencies = SolutionHelper.GetMissingPackageDependencies(appPackage.Id, tenantId); Assert.AreEqual(1, applicationDependencies.Count); DependencyFailure dependency = applicationDependencies[0]; Assert.AreEqual(DependencyFailureReason.Missing, dependency.Reason); } }
public static bool BundleData() { bool bSuccess = true; System.DateTime lastTime = System.DateTime.Now; string sOutDir = AppPackage.AddStamp(ms_sDataOutDir); BuildAssetBundleOptions theAssetOptions = BuildAssetBundleOptions.ForceRebuildAssetBundle; //theAssetOptions = theAssetOptions | BuildAssetBundleOptions.CompleteAssets; //theAssetOptions = theAssetOptions | BuildAssetBundleOptions.CollectDependencies; theAssetOptions = theAssetOptions | BuildAssetBundleOptions.UncompressedAssetBundle; theAssetOptions = theAssetOptions | BuildAssetBundleOptions.DeterministicAssetBundle; List <string> lstFiles = new List <string>(); string[] mediaFiles = AppPackage.GetFiles(new string[] { ms_sMediaDir }, new string[] { "*.ogg", "*.mp3" }, true); lstFiles.AddRange(mediaFiles); string[] objFiles = AppPackage.GetFiles(new string[] { ms_sObjDir }, new string[] { "*.prefab" }, true); lstFiles.AddRange(objFiles); string[] effectFiles = AppPackage.GetFiles(new string[] { ms_sEffectDir }, new string[] { "*.prefab" }, true); lstFiles.AddRange(effectFiles); string[] charFiles = AppPackage.GetFiles(new string[] { ms_sCharDir }, new string[] { "*.prefab" }, true); lstFiles.AddRange(charFiles); string[] uiFiles = AppPackage.GetFiles(new string[] { ms_sUIDir }, new string[] { "*.prefab", "*.png", "*.jpg", "*.ttf" }, true); lstFiles.AddRange(uiFiles); /*string[] cfgFiles = GetFiles(new string[] { ms_sConfigDir }, new string[] { "*.prefab", "*.json", "*.bytes" }, true); * lstFiles.AddRange(cfgFiles);*/ string[] mapFiles = AppPackage.GetFiles(new string[] { ms_sMapDir }, new string[] { "*.prefab" }, true); lstFiles.AddRange(mapFiles); AppPackage.DeleteABManifest(sOutDir + ms_sMediaDir.ToLower()); AppPackage.DeleteABManifest(sOutDir + ms_sObjDir.ToLower()); AppPackage.DeleteABManifest(sOutDir + ms_sEffectDir.ToLower()); AppPackage.DeleteABManifest(sOutDir + ms_sCharDir.ToLower()); //AppPackage.DeleteABManifest(sOutDir + ms_sConfigDir.ToLower()); AppPackage.DeleteABManifest(sOutDir + ms_sMapDir.ToLower()); AppPackage.DeleteABManifest(null, sOutDir + GameConfigMgr.ms_sABMFileName); string[] depFiles = AssetDatabase.GetDependencies(lstFiles.ToArray()); string[] files = AppPackage.GetMatch(depFiles, new string[] { "^.+\\.ogg$|^.+\\.mp3$|^.+\\.prefab$|^.+\\.png$|^.+\\.jpg$|^.+\\.ttf$|^.+\\.json$|^.+\\.bytes$|^.+\\.renderTexture$" }); AppPackage.BundleFiles(sOutDir, files, theAssetOptions, false); bSuccess &= AppPackage.BackUpABManifest(sOutDir, sOutDir + GameConfigMgr.ms_sABMFileName + GameConfigMgr.ms_sABType); if (!bSuccess) { return(false); } System.TimeSpan costTime = System.DateTime.Now - lastTime; Debug.Log("-->> BundleData Cost: " + (costTime.Hours * 3600 + costTime.Minutes * 60 + costTime.Seconds).ToString() + "s"); return(true); }
public void AppPackage_MultiRead() { // Verify that a package can be opened for reading by multiple streams. string tempPath = GetTempFileName(); string tempDir = Helper.AddTrailingSlash(Path.GetTempPath()); AppRef appRef = AppRef.Parse("appref://myapps/mypackage.zip?version=1.2.3.4"); AppPackage pack1 = null; AppPackage pack2 = null; FileStream fs = null; MemoryStream ms; try { pack1 = AppPackage.Create(tempPath, appRef, @" LaunchType = Test.MyType:MyAssembly.dll; LaunchMethod = Foo; LaunchArgs = Bar; "); using (ms = new MemoryStream(4096)) { for (int i = 0; i < 4096; i++) { ms.WriteByte((byte)i); } ms.Position = 0; pack1.AddFile("Test.dat", ms); } pack1.Close(); pack1 = null; pack1 = AppPackage.Open(tempPath); pack2 = AppPackage.Open(tempPath); fs = new FileStream(tempPath, FileMode.Open, FileAccess.Read); } finally { if (pack1 != null) { pack1.Close(); } if (pack2 != null) { pack2.Close(); } if (fs != null) { fs.Close(); } Delete(tempPath); } }
public void TestGetMissingDependencies_InvalidTenant( ) { using (new GlobalAdministratorContext( )) { AppPackage appPackage = new AppPackage( ); SolutionHelper.GetMissingPackageDependencies(appPackage, -1); } }
static void Main(string[] args) { //instruct client side library to insert token as Authorization value into each request container = new Container(new Uri("https://developer.api.autodesk.com/autocad.io/us-east/v2/")); var token = GetToken(); container.SendingRequest2 += (sender, e) => e.RequestMessage.SetHeader("Authorization", token); //check if our app package exists AppPackage package = null; try { package = container.AppPackages.ByKey(PackageName).GetValue(); } catch {} string res = null; if (package != null) { res = Prompts.PromptForKeyword(string.Format("AppPackage '{0}' already exists. What do you want to do? [Recreate/Update/Leave]<Update>", PackageName)); } if (res == "Recreate") { container.DeleteObject(package); container.SaveChanges(); package = null; } if (res != "Leave") { package = CreateOrUpdatePackage(CreateZip(), package); } //check if our activity already exist Activity activity = null; try { activity = container.Activities.ByKey(ActivityName).GetValue(); } catch { } if (activity != null) { if (Prompts.PromptForKeyword(string.Format("Activity '{0}' already exists. Do you want to recreate it? [Yes/No]<No>", ActivityName)) == "Yes") { container.DeleteObject(activity); container.SaveChanges(); activity = null; } } if (activity == null) { activity = CreateActivity(package); } //save outstanding changes if any container.SaveChanges(); //finally submit workitem against our activity SubmitWorkItem(activity); // demo new features in V2 -- version control DemoVersionControl(); }
public void AppPackage_MD5() { string tempPath = GetTempFileName(); string tempDir = Helper.AddTrailingSlash(Path.GetTempPath()); AppPackage package = null; MemoryStream ms; byte[] md5; try { package = AppPackage.Create(tempPath, AppRef.Parse("appref://myapps/mypackage.zip?version=1.2.3.4"), @" LaunchType = Test.MyType:MyAssembly.dll; LaunchMethod = Foo; LaunchArgs = Bar; "); using (ms = new MemoryStream(4096)) { for (int i = 0; i < 4096; i++) { ms.WriteByte((byte)i); } ms.Position = 0; package.AddFile("Test.dat", ms); } package.Close(); package = null; // Verify that a MD5 hash computed manually on the package file jibes // with what AppPackage computes. using (var fs = new EnhancedFileStream(tempPath, FileMode.Open, FileAccess.Read)) { md5 = MD5Hasher.Compute(fs, fs.Length); } package = AppPackage.Open(tempPath); CollectionAssert.AreEqual(md5, package.MD5); package.Close(); package = null; } finally { if (package != null) { package.Close(); } Delete(tempPath); } }
public void SaveEmptySolution() { Solution solution = TestHelper.CreateSolution( ); solution.Save( ); long solutionId = solution.Id; AppManager.PublishApp(RunAsDefaultTenant.DefaultTenantName, TestHelper.DefaultSolutionName); solution = Entity.Get <Solution>(solutionId); Assert.IsNotNull(solution); Assert.IsNotNull(solution.PackageId); if (solution.PackageId != null) { Guid packageId = solution.PackageId.Value; using (new GlobalAdministratorContext( )) { AppPackage package = SystemHelper.GetPackageByVerId(packageId); Assert.IsNotNull(package); Assert.IsNotNull(package.AppVerId); Assert.AreEqual("1.0.0.0", package.AppVersionString); Assert.AreEqual(string.Format("{0} Application Package {1}", TestHelper.DefaultSolutionName, "1.0.0.0"), package.Name); Assert.AreEqual(string.Format("Application Package for version {1} of {0}.", TestHelper.DefaultSolutionName, "1.0.0.0"), package.Description); if (package.AppVerId != null) { var source = new LibraryAppSource { AppId = package.AppVerId.Value }; IEnumerable <EntityEntry> entities = source.GetEntities(null); Assert.IsFalse(entities.Any( )); IEnumerable <RelationshipEntry> relationships = source.GetRelationships(null); Assert.IsFalse(relationships.Any( )); foreach (string fieldDataTable in Helpers.FieldDataTables) { IEnumerable <DataEntry> fieldData = source.GetFieldData(fieldDataTable, null); Assert.IsFalse(fieldData.Any( )); } } } } }
private void DrawBuildDebug() { EditorGUILayout.Separator(); EditorGUILayout.LabelField("1.平时出版本用: (注:适合没有C++,CSharp变动时)"); // 小版本,只是拷贝Lua脚本和策划配置文件 if (GUILayout.Button("LittlePublic(小版本)")) { Debug.Log("LittlePublic - " + System.DateTime.Now); EditorGUIUtility.editingTextField = false; AppPackage.LittlePublic(m_bSvnUpdate); } }
internal static async Task <CreateFunctionResponse> CreateFunctionAsync ( this AmazonLambdaClient client, AppPackage package, ASPNetServerLessPublishAWSLambdaConfigSection lambdaConfig, Runtime lambdaRuntime, CancellationToken cancellationToken = default(CancellationToken) ) { var environmentVariables = new Dictionary <string, string>(lambdaConfig.EnvironmentVAriables); var functionTags = new Dictionary <string, string> { { "Name", lambdaConfig.FunctionName } }; var response = (CreateFunctionResponse)null; using (var packageStream = new MemoryStream(package.PackageBytes)) { var createFunctionRequest = new CreateFunctionRequest() { Code = new FunctionCode() { ZipFile = packageStream }, Environment = new Environment() { Variables = environmentVariables }, FunctionName = lambdaConfig.FunctionName, Handler = lambdaConfig.FunctionHandler, MemorySize = lambdaConfig.FunctionMemory.Value, Role = lambdaConfig.FunctionRole, Tags = functionTags, Timeout = lambdaConfig.FunctionTimeoutSeconds.Value, Runtime = lambdaRuntime }; response = await client.CreateFunctionAsync(createFunctionRequest, cancellationToken).ConfigureAwait(false); createFunctionRequest = null; } functionTags = null; environmentVariables = null; return(response); }
/// <summary> /// Gets the missing dependencies. /// </summary> /// <param name="package">The package.</param> /// <param name="tenantId">The tenant identifier.</param> /// <param name="immediateOnly">if set to <c>true</c> [immediate only].</param> /// <returns></returns> /// <exception cref="NullReferenceException"></exception> public static IList <DependencyFailure> GetMissingDependencies(this AppPackage package, long tenantId, bool immediateOnly = false) { if (package == null) { throw new NullReferenceException( ); } if (tenantId < 0) { throw new ArgumentException(@"Invalid tenant id specified.", nameof(tenantId)); } return(GetMissingPackageDependencies(package, tenantId, immediateOnly)); }
public void TestGetMissingDependencies( ) { Solution appA = new Solution { Name = "appA" }; Solution appB = new Solution { Name = "appB" }; Solution appC = new Solution { Name = "appC" }; ApplicationDependency aDependsOnB = new ApplicationDependency { Name = "appA depends on appB", DependentApplication = appA, DependencyApplication = appB }; appA.DependentApplicationDetails.Add(aDependsOnB); appA.Save( ); ApplicationDependency bDependsOnC = new ApplicationDependency { Name = "appB depends on appC", DependentApplication = appB, DependencyApplication = appC }; appB.DependentApplicationDetails.Add(bDependsOnC); appB.Save( ); AppManager.PublishApp(RunAsDefaultTenant.DefaultTenantName, "appA"); Guid appAUpgradeId = Entity.GetUpgradeId(appA.Id); long tenantId = RequestContext.TenantId; using (new GlobalAdministratorContext( )) { AppPackage appPackage = SystemHelper.GetLatestPackageByGuid(appAUpgradeId); SolutionHelper.GetMissingPackageDependencies(appPackage.Id, tenantId); } }
static int Main(string[] args) { var consumerKey = Environment.GetEnvironmentVariable("FORGE_CLIENT_ID"); var consumerSecret = Environment.GetEnvironmentVariable("FORGE_CLIENT_SECRET"); if (string.IsNullOrEmpty(consumerKey) || string.IsNullOrEmpty(consumerSecret)) { Console.WriteLine("Please enter valid Autodesk consumer key secret"); return(1); } var token = GetToken(consumerKey, consumerSecret); if (token == null) { Console.WriteLine("Error obtaining access token"); return(1); } string url = Credentials.baseUrl + "/autocad.io/us-east/v2/"; Container container = new Container(new Uri(url)); container.SendingRequest2 += (sender, e) => e.RequestMessage.SetHeader("Authorization", token); // Create the app package if it does not exist AppPackage package = CreatePackage(container); if (package == null) { Console.WriteLine("Error creating app package!"); return(1); } // Create the custom activity // Activity activity = CreateActivity(ActivityName, Script, container); if (activity == null) { Console.WriteLine("Error creating custom activity: " + ActivityName); return(1); } // Save changes if any container.SaveChanges(); return(0); }
static void Main(string[] args) { //instruct client side library to insert token as Authorization value into each request container = new Container(new Uri("https://developer.api.autodesk.com/autocad.io/us-east/v2/")); var token = GetToken(); container.SendingRequest2 += (sender, e) => e.RequestMessage.SetHeader("Authorization", token); //check if our app package exists AppPackage package = null; var packageQ = container.AppPackages.ByKey(PackageName); try { package = packageQ.GetValue(); } catch { } string res = "New"; if (package != null) { res = PromptVersions(package.Version, packageQ.GetVersions().RequestUri, packageQ.SetVersion(0).RequestUri, token); } if (res == "New") { package = CreateOrUpdatePackage(CreateZip(), package); } //check if our activity already exists Activity activity = null; var activityQ = container.Activities.ByKey(ActivityName); try { activity = activityQ.GetValue(); } catch { } res = "New"; if (activity != null) { res = PromptVersions(package.Version, activityQ.GetVersions().RequestUri, activityQ.SetVersion(0).RequestUri, token); } if (res == "New") { activity = CreateOrUpdateActivity(activity, PackageName); } //save outstanding changes if any container.SaveChanges(); //finally submit workitem against our activity SubmitWorkItem(activity); }
/// <summary> /// Determines whether a viable upgrade is available. /// </summary> /// <param name="dependency">The dependency.</param> /// <param name="upgradePackage">The upgrade package.</param> /// <returns> /// <c>true</c> if a viable upgrade is available; otherwise, <c>false</c>. /// </returns> private static bool TryGetUpgradePackage(DependencyFailure dependency, out AppPackage upgradePackage) { upgradePackage = null; if (dependency == null) { return(false); } long appId = GetApplicationId(dependency.ApplicationId); if (appId < 0) { return(false); } App app = Entity.Get <App>(appId); var applicationPackages = app.ApplicationPackages; if (applicationPackages != null && applicationPackages.Count > 0) { List <Tuple <Version, AppPackage> > list = new List <Tuple <Version, AppPackage> >( ); foreach (AppPackage applicationPackage in applicationPackages) { Version packageVersion; if (Version.TryParse(applicationPackage.AppVersionString, out packageVersion)) { list.Add(new Tuple <Version, AppPackage>(packageVersion, applicationPackage)); } } if (list.Count > 0) { var pair = list.OrderByDescending(p => p.Item1).FirstOrDefault(p => (dependency.MinVersion == null || p.Item1 >= dependency.MinVersion) && (dependency.MaxVersion == null || p.Item1 <= dependency.MaxVersion)); if (pair != null) { upgradePackage = pair.Item2; return(true); } } } return(false); }
// Creates an activity with 2 inputs and variable number of outputs. // All outputs are placed in a folder 'outputs' static Activity CreateActivity(AppPackage package) { Console.WriteLine("Creating/Updating Activity..."); var activity = new Activity() { Id = ActivityName, Version = 2, Instruction = new Instruction() { Script = "_jigio params.json pixels.json outputs\n" }, Parameters = new Parameters() { InputParameters = { new Parameter() { Name = "HostDwg", LocalFileName = "$(HostDwg)" }, new Parameter() { Name = "Params", LocalFileName = "params.json" }, new Parameter() { Name = "PixelsUrl", LocalFileName = "pixels.json" } }, OutputParameters = { new Parameter() { Name = "Results", LocalFileName = "outputs" } } }, RequiredEngineVersion = "20.0" }; // Establish link to package activity.AppPackages.Add(PackageName); // reference the custom AppPackage container.AddToActivities(activity); container.SaveChanges(); return(activity); }
public void AppPackage_ExtractTo() { string tempPath = GetTempFileName(); string tempDir = Helper.AddTrailingSlash(Path.GetTempPath()); AppPackage package = null; try { package = AppPackage.Create(tempPath, AppRef.Parse("appref://myapps/mypackage.zip?version=1.2.3.4"), @" LaunchType = Test.MyType:MyAssembly.dll; LaunchMethod = Foo; LaunchArgs = Bar; "); package.AddFile("File1.txt", Helper.ToUTF8("Hello World! #1\r\n")); package.AddFile("File2.txt", Helper.ToUTF8("Hello World! #2\r\n")); package.Close(); package = null; package = AppPackage.Open(tempPath); package.ExtractTo(tempDir); package.Close(); package = null; Assert.IsTrue(File.Exists(tempDir + "Package.ini")); Assert.IsTrue(File.Exists(tempDir + "File1.txt")); Assert.IsTrue(File.Exists(tempDir + "File2.txt")); using (var reader = new StreamReader(tempDir + "File1.txt")) { Assert.AreEqual("Hello World! #1", reader.ReadLine()); } using (var reader = new StreamReader(tempDir + "File2.txt")) { Assert.AreEqual("Hello World! #2", reader.ReadLine()); } } finally { if (package != null) { package.Close(); } Delete(tempPath); } }
public static bool GenVersion(string version) { if (!AppPackage.CheckVersion(version)) { return(false); } string sOutDir = AppPackage.AddStamp(ms_sDataOutDir); string path = sOutDir + GameConfigMgr.ms_sVersionFileName + GameConfigMgr.ms_sABType; string dir = path.Substring(0, path.LastIndexOf('/')); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } File.WriteAllBytes(path, Encoding.UTF8.GetBytes(version)); return(true); }
/// <summary> /// HAdds the a file to the package, handling any special processing necessary when /// adding the PACKAGE.INI file. /// </summary> /// <param name="package">The application package.</param> /// <param name="path">Path to he file.</param> /// <param name="basePath">Base path.</param> /// <returns><c>true</c> if the file processed was the PACKAGE.INI file.</returns> private static bool AddFile(AppPackage package, string path, string basePath) { string file; if (path.ToLowerInvariant().StartsWith(basePath.ToLowerInvariant() + Helper.PathSepString)) { file = path.Substring(basePath.Length + 1); } else { file = path; } if (String.Compare(file, "package.ini", true) != 0) { package.AddFile(path, basePath); return(false); } else { // Handle special processing of the PACKAGE.INI file. StreamReader reader = new StreamReader(path, Encoding.UTF8); string settings; MacroProcessor processor; try { processor = new MacroProcessor(); processor.Add("appref", package.AppRef.ToString()); settings = reader.ReadToEnd(); settings = processor.Expand(settings); package.AddFile("Package.ini", Helper.ToUTF8(settings)); } finally { reader.Close(); } return(true); } }
private void CreatePackage(string folder, AppRef appRef) { AppPackage package; package = AppPackage.Create(Helper.AddTrailingSlash(folder) + appRef.FileName, appRef, @" LaunchType = Test.MyType:MyAssembly.dll; LaunchMethod = Foo; LaunchArgs = Bar; "); package.AddFile("Test1.txt", Helper.ToUTF8("Hello World!\r\n")); byte[] buf = new byte[1000000]; for (int i = 0; i < buf.Length; i++) { buf[i] = (byte)Helper.Rand(); // Use Rand() to disable compression } package.AddFile("Test2.dat", buf); package.Close(); }
/// <summary> /// Gets the package dependencies recursive. /// </summary> /// <param name="packageId">The package identifier.</param> /// <param name="tenantId">The tenant identifier.</param> /// <param name="results">The results.</param> /// <param name="discoveredPackageIds">The discovered package ids.</param> /// <exception cref="ApplicationDependencyException"> /// </exception> private void GetPackageDependenciesRecursive(long packageId, long tenantId, List <MissingDependencyData> results, ISet <Guid> discoveredPackageIds) { IList <DependencyFailure> applicationDependencies = SolutionHelper.GetMissingPackageDependencies(packageId, tenantId); if (applicationDependencies != null && applicationDependencies.Count > 0) { foreach (DependencyFailure dependency in applicationDependencies) { if (dependency.Reason == DependencyFailureReason.BelowMinVersion) { SolutionHelper.EnsureUpgradePath(tenantId, dependency); } string dependencyPackageAppVersionString = null; var dependencyPackageId = SystemHelper.GetPackageIdByGuid(dependency.ApplicationId, dependency.MinVersion, dependency.MaxVersion); if (dependencyPackageId >= 0) { AppPackage dependencyPackage = ReadiNow.Model.Entity.Get <AppPackage>(dependencyPackageId); if (dependencyPackage != null) { dependencyPackageAppVersionString = dependencyPackage.AppVersionString; } } if (!discoveredPackageIds.Contains(dependency.ApplicationId)) { discoveredPackageIds.Add(dependency.ApplicationId); if (dependencyPackageId >= 0) { GetPackageDependenciesRecursive(dependencyPackageId, tenantId, results, discoveredPackageIds); } results.Add(new MissingDependencyData(dependency, dependencyPackageId, dependencyPackageAppVersionString)); } } } }
/// <summary> /// Gets the missing package dependencies. /// </summary> /// <param name="packageId">The package identifier.</param> /// <param name="tenantId">The tenant identifier.</param> /// <param name="immediateOnly">if set to <c>true</c> [immediate only].</param> /// <returns></returns> public static IList <DependencyFailure> GetMissingPackageDependencies(long packageId, long tenantId, bool immediateOnly = false) { if (packageId < 0) { throw new ArgumentException(@"Invalid package id specified.", nameof(packageId)); } if (tenantId < 0) { throw new ArgumentException(@"Invalid tenant id specified.", nameof(tenantId)); } AppPackage package = Entity.Get <AppPackage>(packageId); if (package == null) { throw new ArgumentException("Specified package Id does not represent a known package."); } return(GetMissingPackageDependencies(package, tenantId, immediateOnly)); }
/* * // 补丁包路径 * private string GenWcpPath() * { * string platform = AppPackage.ms_target.ToString(); * string dir = ""; * string oldName = ""; * string newName = ""; * if (!string.IsNullOrEmpty(m_sOldABDir)) * { * System.IO.DirectoryInfo oDir = new System.IO.DirectoryInfo(m_sOldABDir); * if(!oDir.Name.StartsWith(platform)) * { * Debug.LogError("platform: " + platform); * return ""; * } * oldName = oDir.Name.Substring(platform.Length + 1); * dir = oDir.Parent.FullName.Replace("\\", "/") + "/"; * } * if (!string.IsNullOrEmpty(m_sNewABDir)) * { * System.IO.DirectoryInfo oDir = new System.IO.DirectoryInfo(m_sNewABDir); * if (!oDir.Name.StartsWith(platform)) * { * Debug.LogError("platform: " + platform); * return ""; * } * newName = oDir.Name.Substring(platform.Length + 1); * dir = oDir.Parent.FullName.Replace("\\", "/") + "/"; * } * * return dir + platform + "_" + oldName + "-" + newName + GameConfigMgr.ms_sWcpType; * } * //*/ private void Build() { System.DateTime lastTime = System.DateTime.Now; Debug.Log("Build - " + lastTime); bool bOK = false; BuildOptions buildOptions = BuildOptions.None; //BuildOptions buildOptions = BuildOptions.UncompressedAssetBundle; if (m_bBuildRelease == false) { buildOptions = BuildOptions.Development | BuildOptions.AllowDebugging; //| BuildOptions.ConnectWithProfiler; // debug } if (m_bBuildProject && AppPackage.ms_target == BuildTarget.Android) { buildOptions = buildOptions | BuildOptions.AcceptExternalModificationsToPlayer; } else if (m_bBuildProject && AppPackage.ms_target == BuildTarget.iOS) { buildOptions = buildOptions | BuildOptions.AcceptExternalModificationsToPlayer | BuildOptions.Il2CPP; } bOK = AppPackage.Build(buildOptions, m_bSvnUpdate, m_sNewVersion, m_bBundleLua, m_bBundleData, m_bBundleMap, m_bCopyData, m_bBuildApp); System.TimeSpan costTime = System.DateTime.Now - lastTime; Debug.Log("-->> Build Cost: " + (costTime.Hours * 3600 + costTime.Minutes * 60 + costTime.Seconds).ToString() + "s"); if (bOK) { if (m_bBundleData && m_bBundleMap) { AppPackage.LittlePublic(false, "Build"); } else { EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog("Build", " Success!! ", "close"); } } m_sOldVersion = AppPackage.ms_sNewVersion; }
// only copy lua && csv public static void LittlePublic(bool bSvnUpdate, string sFinishMsg = null) { bool bOK = false; try { if (bSvnUpdate && !AppPackage.SvnUpdate(true)) { Debug.LogError("SvnUpdate Failed !!!!"); return; } string sSourcePath = GameConfigMgr.ms_sLuaScriptDir + "../../"; string sPublicPath = GameConfigMgr.ms_sPublicDir + "Trunk/"; string[] fileArr = ms_ArrLittleFiles; int nCount = fileArr.Length; for (int i = 0; i < nCount; i++) { AppPackage.CopyFiles(sSourcePath + fileArr[i], sPublicPath + fileArr[i], ms_ArrLittleCheck[i], false, true); } for (int i = 0; i < ms_ArrRemoveFiles.Length; i++) { string sDelPath = sPublicPath + ms_ArrRemoveFiles[i]; if (Directory.Exists(sDelPath)) { Directory.Delete(sDelPath, true); } } bOK = true; } catch (System.Exception ex) { bOK = false; Debug.LogError(ex.Message + "\n" + ex.StackTrace); } EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog(string.IsNullOrEmpty(sFinishMsg) ? "LittlePublic": sFinishMsg, bOK ? " Success!! ":" Failed!! ", "close"); }
public bool CheckSupport() { // We're going to open this file and read the comment in the ZIP to identify the package try { using (ZipFile zip = new ZipFile(this.filename)) { var comment = zip.Comment; Regex findAppID = new Regex(@"^APPID=\[(?<id>[0-9]*?)\]"); MatchCollection mc = findAppID.Matches(comment); if (mc.Count == 0) return false; appID = mc[0].Groups["id"].Value; package = AppCatalog.GetAppPackage(appID); return package != null; } } catch { appID = null; return false; } }
public static AppPackage CreateAppPackage(int version, global::System.DateTimeOffset timestamp, string userId, string ID) { AppPackage appPackage = new AppPackage(); appPackage.Version = version; appPackage.Timestamp = timestamp; appPackage.UserId = userId; appPackage.Id = ID; return appPackage; }
//creates an activity with 2 inputs and variable number of outputs. All outsputs are places //in a folder 'outputs' static Activity CreateActivity(AppPackage package) { Console.WriteLine("Creating/Updating Activity..."); var activity = new Activity() { Id = ActivityName, Instruction = new Instruction() { Script = "_test params.json outputs\n" }, Parameters = new Parameters() { InputParameters = { new Parameter() { Name = "HostDwg", LocalFileName = "$(HostDwg)" }, new Parameter() { Name = "Params", LocalFileName = "params.json" }, }, OutputParameters = { new Parameter() { Name = "Results", LocalFileName = "outputs" } } }, RequiredEngineVersion = "20.1" }; activity.AppPackages.Add(PackageName); // reference the custom AppPackage container.AddToActivities(activity); container.SaveChanges(); return activity; }
static void CreateAppPackage(Container container, string packId) { Console.WriteLine("Creating/Updating AppPackage..."); string zip = CreateZip(packId); // First step -- query for the url to upload the AppPackage file var url = container.AppPackages.GetUploadUrl().GetValue(); // Second step -- upload AppPackage file UploadObject(url, zip); // third step -- after upload, create the AppPackage entity AppPackage package = new AppPackage() { Id = packId, RequiredEngineVersion = "20.1", Resource = url }; container.AddToAppPackages(package); container.SaveChanges(); }
public void AddToAppPackages(AppPackage appPackage) { base.AddObject("AppPackages", appPackage); }