public void GivenLaunchTwoFAApplicationAndVerifyHomescreen() { CleanUp.KillingChromeDriver(); string UI_URL = ConfigurationManager.AppSettings["AppURL"]; AUT.BrowserLaunch_sel(UI_URL); }
public ColumnEntity Create(ISession session, CleanUp cleanUp, TableEntity table = null, string name = null, string datatype = null, string description = null) { table = table ?? (new TableEntityCreator()).Create(session, cleanUp); name = name ?? RandomTool.RandomString(20); datatype = datatype ?? RandomTool.RandomString(20); description = description ?? RandomTool.RandomString(20); var entityToSave = new ColumnEntity { DataType = datatype, Description = description, Name = name, ParentTable = table }; using (var transaction = session.BeginTransaction()) { session.Save(entityToSave); transaction.Commit(); cleanUp.AddForDeletion(entityToSave); } return entityToSave; }
public void Cleanup(params IDisposable[] disposables) { foreach (var disposable in disposables) { CleanUp.Add(disposable); } }
public override void Execute() { var client = new AzureResourceManagerClient(); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group Console.WriteLine($"--------Start create group {Context.RgName}--------"); var resourceGroup = subscription.GetResourceGroupContainer().Construct(Context.Loc).CreateOrUpdate(Context.RgName).Value; CleanUp.Add(resourceGroup.Id); // Create AvailabilitySet Console.WriteLine("--------Start create AvailabilitySet--------"); var aset = resourceGroup.GetAvailabilitySetContainer().Construct("Aligned").CreateOrUpdate(Context.VmName + "_aSet").Value; // Create VNet Console.WriteLine("--------Start create VNet--------"); string vnetName = Context.VmName + "_vnet"; var vnet = resourceGroup.GetVirtualNetworkContainer().Construct("10.0.0.0/16").CreateOrUpdate(vnetName).Value; //create subnet Console.WriteLine("--------Start create Subnet--------"); var subnet = vnet.GetSubnetContainer().Construct("10.0.0.0/24").CreateOrUpdate(Context.SubnetName).Value; //create network security group Console.WriteLine("--------Start create NetworkSecurityGroup--------"); _ = resourceGroup.GetNetworkSecurityGroupContainer().Construct(80).CreateOrUpdate(Context.NsgName).Value; CreateVms(resourceGroup, aset, subnet); }
public ActionResult Contact() { ViewBag.Message = "Your contact page."; CleanUp.AutoClean(); return(View()); }
public static int DoSomething(CleanUp method = null) { if (method != null) { method(); } return(1); }
public override void Execute() { var client = new AzureResourceManagerClient(); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group Console.WriteLine($"--------Start create group {Context.RgName}--------"); var resourceGroup = subscription.GetResourceGroupContainer().Construct(Context.Loc).CreateOrUpdate(Context.RgName).Value; CleanUp.Add(resourceGroup.Id); Console.WriteLine("--------Start create Assignment--------"); var input = new RoleAssignmentCreateParameters($"/subscriptions/{Context.SubscriptionId}/resourceGroups/{Context.RgName}/providers/Microsoft.Authorization/roleDefinitions/{Context.RoleId}", Context.PrincipalId); var assign = resourceGroup.GetRoleAssignmentContainer().Create(Guid.NewGuid().ToString(), input).Value; Console.WriteLine("--------Done create Assignment--------"); assign = assign.Get().Value; // Create AvailabilitySet Console.WriteLine("--------Start create AvailabilitySet--------"); var aset = resourceGroup.GetAvailabilitySetContainer().Construct("Aligned").CreateOrUpdate(Context.VmName + "_aSet").Value; // Create VNet Console.WriteLine("--------Start create VNet--------"); string vnetName = Context.VmName + "_vnet"; var vnet = resourceGroup.GetVirtualNetworkContainer().Construct("10.0.0.0/16").CreateOrUpdate(vnetName).Value; //create subnet Console.WriteLine("--------Start create Subnet--------"); var subnet = vnet.GetSubnetContainer().Construct("10.0.0.0/24").CreateOrUpdate(Context.SubnetName).Value; //create network security group Console.WriteLine("--------Start create NetworkSecurityGroup--------"); _ = resourceGroup.GetNetworkSecurityGroupContainer().Construct(80).CreateOrUpdate(Context.NsgName).Value; // Create Network Interface Console.WriteLine("--------Start create Network Interface--------"); var nic = resourceGroup.GetNetworkInterfaceContainer().Construct(subnet.Id).CreateOrUpdate($"{Context.VmName}_nic").Value; // Create VM Console.WriteLine("--------Start create VM--------"); var vm = resourceGroup.GetVirtualMachineContainer().Construct(Context.Hostname, "admin-user", "!@#$%asdfA", nic.Id, aset.Id).CreateOrUpdate(Context.VmName).Value; Console.WriteLine("VM ID: " + vm.Id); Console.WriteLine("--------Done create VM--------"); Console.WriteLine("--------Start create Assignment--------"); var input2 = new RoleAssignmentCreateParameters($"{vm.Id}/providers/Microsoft.Authorization/roleDefinitions/{Context.RoleId}", Context.PrincipalId); var assign2 = vm.GetRoleAssignmentContainer().Create(Guid.NewGuid().ToString(), input2).Value; Console.WriteLine("--------Done create Assignment--------"); assign2 = assign2.Get().Value; Console.WriteLine($"Created assignment: '{assign.Data.Id}'"); }
public void CssBgUrl() { const string url = "http://.jpg"; var c1 = CleanUp.CssBgUrl("url(http://.jpg)"); Assert.AreEqual(url, c1); var c2 = CleanUp.CssBgUrl("url(\"http://.jpg\")"); Assert.AreEqual(url, c2); var c3 = CleanUp.CssBgUrl("url('http://.jpg')"); Assert.AreEqual(url, c3); //var c4 = CleanUp.CssBgUrl("url(http://.jpg)"); }
public void TestMethodTranslate() { System.Collections.Generic.List <GlobalStructureInfo> AllStructures = new System.Collections.Generic.List <GlobalStructureInfo>(); var UnusedObjects = CleanUp.GetUnusedObjects( Path.Combine(@"C:\steamcmd\empyrion\Saves\Games\Server\Shared"), AllStructures).ToArray(); var PossibleCleanUpObjects = UnusedObjects.Where(O => (DateTime.Now - O.LastAccess).TotalDays > 14).ToArray(); var usedTypes = AllStructures.Distinct(new StructureTypeEqualityComparer()); var Result = usedTypes.Aggregate("", (L, T) => L + T.type + ": " + AllStructures.Count(S => S.type == T.type)) + "\n" + $"Unused:{UnusedObjects.Length} ({UnusedObjects.Aggregate(0L, (S, O) => S + O.GetSize()) / (1024 * 1024):N2}MB) possible CleanUp:{PossibleCleanUpObjects.Length} ({PossibleCleanUpObjects.Aggregate(0L, (S, O) => S + O.GetSize()) / (1024 * 1024):N2}MB)" ; }
void CreateTerrain() { TerrainData terrain = Terrain.activeTerrain.terrainData; Undo.RegisterUndo(terrain, "Object to Terrain"); MeshCollider collider = Selection.activeGameObject.GetComponent <MeshCollider>(); CleanUp cleanUp = null; if (!collider) { collider = Selection.activeGameObject.AddComponent <MeshCollider>(); cleanUp = () => DestroyImmediate(collider); } Bounds bounds = collider.bounds; bounds.Expand(new Vector3(-sizeAdjustment * bounds.size.x, 0, -sizeAdjustment * bounds.size.z)); // Do raycasting samples over the object to see what terrain heights should be float[,] heights = new float[terrain.heightmapWidth, terrain.heightmapHeight]; Ray ray = new Ray(new Vector3(bounds.min.x, bounds.max.y * 2, bounds.min.z), -Vector3.up); RaycastHit hit = new RaycastHit(); float meshHeightInverse = 1 / bounds.size.y; Vector3 rayOrigin = ray.origin; Vector2 stepXZ = new Vector2(bounds.size.x / heights.GetLength(1), bounds.size.z / heights.GetLength(0)); for (int zCount = 0; zCount < heights.GetLength(0); zCount++) { for (int xCount = 0; xCount < heights.GetLength(1); xCount++) { heights[zCount, xCount] = collider.Raycast(ray, out hit, bounds.size.y * 2) ? 1 - (bounds.max.y - hit.point.y) * meshHeightInverse : 0; rayOrigin.x += stepXZ[0]; ray.origin = rayOrigin; } rayOrigin.z += stepXZ[1]; rayOrigin.x = bounds.min.x; ray.origin = rayOrigin; } terrain.SetHeights(0, 0, heights); if (cleanUp != null) { cleanUp(); } }
public async Task CleanUp(CleanUp cleanup) { try { await _context.AddAsync(cleanup); await _context.SaveChangesAsync(); } catch (Exception ex) { using (EventLog eventLog = new EventLog("Application")) { eventLog.Source = "Application"; eventLog.WriteEntry(ex.Message, EventLogEntryType.Information, 101, 1); } } }
void CreateTerrain() { TerrainData terrain = terrainToEdit.terrainData; Undo.RecordObject(terrain, "Mesh to Terrain"); MeshCollider collider = meshToUse.gameObject.GetComponent <MeshCollider>(); CleanUp cleanUp = null; if (!collider) { collider = meshToUse.gameObject.AddComponent <MeshCollider>(); cleanUp = () => DestroyImmediate(collider); } Bounds bounds = collider.bounds; bounds.Expand(new Vector3(-sizeAdjustment * bounds.size.x, 0, -sizeAdjustment * bounds.size.z)); float[,] heights = new float[terrain.heightmapWidth, terrain.heightmapHeight]; Ray ray = new Ray(new Vector3(bounds.min.x, bounds.max.y * 2, bounds.min.z), Vector3.down); RaycastHit hit = new RaycastHit(); float meshHeightInverse = 1 / bounds.size.y; Vector3 rayOrigin = ray.origin; Vector2 stepXZ = new Vector2(bounds.size.x / heights.GetLength(1), bounds.size.z / heights.GetLength(0)); for (int zCount = 0; zCount < heights.GetLength(0); zCount++) { for (int xCount = 0; xCount < heights.GetLength(1); xCount++) { heights[zCount, xCount] = collider.Raycast(ray, out hit, bounds.size.y * 2) ? 1 - (bounds.max.y - hit.point.y) * meshHeightInverse : 0; rayOrigin.x += stepXZ[0]; ray.origin = rayOrigin; } rayOrigin.z += stepXZ[1]; rayOrigin.x = bounds.min.x; ray.origin = rayOrigin; } terrain.SetHeights(0, 0, heights); if (cleanUp != null) { cleanUp(); } }
public override void Execute() { var client = new AzureResourceManagerClient(); var subscription = client.Subscription(Context.SubscriptionId); // Create Resource Group Console.WriteLine($"--------Start create group {Context.RgName}--------"); var resourceGroup = subscription.ResourceGroups().Create(Context.RgName, Context.Loc).Value; CleanUp.Add(resourceGroup.Id); // Create AvailabilitySet Console.WriteLine("--------Start create AvailabilitySet--------"); var aset = resourceGroup.AvailabilitySets().Construct("Aligned").Create(Context.VmName + "_aSet").Value; // Create VNet Console.WriteLine("--------Start create VNet--------"); string vnetName = Context.VmName + "_vnet"; var vnet = resourceGroup.VirtualNetworks().Construct("10.0.0.0/16").Create(vnetName).Value; //create subnet Console.WriteLine("--------Start create Subnet--------"); var subnet = vnet.Subnets().Construct(Context.SubnetName, "10.0.0.0/24").Create(Context.SubnetName).Value; //create network security group Console.WriteLine("--------Start create NetworkSecurityGroup--------"); _ = resourceGroup.NetworkSecurityGroups().Construct(Context.NsgName, 80).Create(Context.NsgName).Value; // Create IP Address Console.WriteLine("--------Start create IP Address--------"); var ipAddress = resourceGroup.PublicIpAddresses().Construct().Create($"{Context.VmName}_ip").Value; // Create Network Interface Console.WriteLine("--------Start create Network Interface--------"); var nic = resourceGroup.NetworkInterfaces().Construct(ipAddress.Data, subnet.Id).Create($"{Context.VmName}_nic").Value; // Create VM Console.WriteLine("--------Start create VM--------"); var vm = resourceGroup.VirtualMachines().Construct(Context.VmName, "admin-user", "!@#$%asdfA", nic.Id, aset.Data).Create(Context.VmName).Value; Console.WriteLine("VM ID: " + vm.Id); Console.WriteLine("--------Done create VM--------"); }
public override void Execute() { var client = new AzureResourceManagerClient(); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group Console.WriteLine($"--------Start create group {Context.RgName}--------"); var resourceGroup = subscription.GetResourceGroupContainer().Construct(Context.Loc).CreateOrUpdate(Context.RgName).Value; CleanUp.Add(resourceGroup.Id); // Create AvailabilitySet Console.WriteLine("--------Start create AvailabilitySet--------"); var aset = resourceGroup.GetAvailabilitySetContainer().Construct("Aligned").CreateOrUpdate(Context.VmName + "_aSet").Value; // Create VNet Console.WriteLine("--------Start create VNet--------"); string vnetName = Context.VmName + "_vnet"; var vnet = resourceGroup.GetVirtualNetworkContainer().Construct("10.0.0.0/16").CreateOrUpdate(vnetName).Value; //create subnet Console.WriteLine("--------Start create Subnet async--------"); var subnet = vnet.GetSubnetContainer().Construct("10.0.0.0/24").CreateOrUpdateAsync(Context.SubnetName).ConfigureAwait(false).GetAwaiter().GetResult().Value; //create network security group Console.WriteLine("--------Start create NetworkSecurityGroup--------"); _ = resourceGroup.GetNetworkSecurityGroupContainer().Construct(80).CreateOrUpdate(Context.NsgName).Value; // Create Network Interface Console.WriteLine("--------Start create Network Interface--------"); var nic = resourceGroup.GetNetworkInterfaceContainer().Construct(subnet.Id).CreateOrUpdate($"{Context.VmName}_nic").Value; // Create VM Console.WriteLine("--------Start create VM--------"); var vm = resourceGroup.GetVirtualMachineContainer().Construct(Context.Hostname, "admin-user", "!@#$%asdfA", nic.Id, aset.Id).CreateOrUpdate(Context.VmName).Value; Console.WriteLine("VM ID: " + vm.Id); Console.WriteLine("--------Done create VM--------"); }
private async System.Threading.Tasks.Task ExcuteAsync() { var client = new AzureResourceManagerClient(); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group Console.WriteLine($"--------Start StartCreate group {Context.RgName}--------"); var resourceGroup = (await(subscription.GetResourceGroupContainer().Construct(Context.Loc).StartCreateOrUpdate(Context.RgName)).WaitForCompletionAsync()).Value; CleanUp.Add(resourceGroup.Id); // Create AvailabilitySet Console.WriteLine("--------Start StartCreate AvailabilitySet async--------"); var aset = (await(resourceGroup.GetAvailabilitySetContainer().Construct("Aligned").StartCreateOrUpdate(Context.VmName + "_aSet")).WaitForCompletionAsync()).Value; // Create VNet Console.WriteLine("--------Start StartCreate VNet--------"); string vnetName = Context.VmName + "_vnet"; var vnet = (await(resourceGroup.GetVirtualNetworkContainer().Construct("10.0.0.0/16").StartCreateOrUpdate(vnetName)).WaitForCompletionAsync()).Value; //create subnet Console.WriteLine("--------Start StartCreate Subnet--------"); var subnet = (await(vnet.GetSubnetContainer().Construct("10.0.0.0/24").StartCreateOrUpdate(Context.SubnetName)).WaitForCompletionAsync()).Value; //create network security group Console.WriteLine("--------Start StartCreate NetworkSecurityGroup--------"); _ = (await(resourceGroup.GetNetworkSecurityGroupContainer().Construct(80).StartCreateOrUpdate(Context.NsgName)).WaitForCompletionAsync()).Value; // Create Network Interface Console.WriteLine("--------Start StartCreate Network Interface--------"); var nic = (await(resourceGroup.GetNetworkInterfaceContainer().Construct(subnet.Id).StartCreateOrUpdate($"{Context.VmName}_nic")).WaitForCompletionAsync()).Value; // Create VM Console.WriteLine("--------Start StartCreate VM --------"); var vm = (await(resourceGroup.GetVirtualMachineContainer().Construct(Context.Hostname, "admin-user", "!@#$%asdfA", nic.Id, aset.Id).StartCreateOrUpdate(Context.VmName)).WaitForCompletionAsync()).Value; Console.WriteLine("VM ID: " + vm.Id); Console.WriteLine("--------Done StartCreate VM--------"); }
/// <summary> /// Starting SignUp of MSN Client installation /// </summary> /// <param name="option">Installation option.</param> /// <param name="objHelper">Helper object.</param> internal void StartNewUserSignUp(string option, ref Helper objHelper) { Logger.AddComment(BuildSanityUIMessages.LanguageMarket + option, Logger.CommentType.Message); Logger.AddComment(Constants.CleanUpStarted, Logger.CommentType.Message); if (!CleanUp.Clean()) { throw new Exception(Constants.CleanUpError); } DriveInfo driveInstallation = new DriveInfo(Environment.SystemDirectory.Substring(0, Environment.SystemDirectory.IndexOf("\\"))); ////Check drive size is greater than 35mB if (driveInstallation.TotalFreeSpace > Constants.RequiredDiskSpace) { Logger.AddComment(Constants.LoggingCleanUp, Logger.CommentType.Pass); string choice = option; this.Connection = "premium"; switch (choice) { case "ENUS : DialUp": this.Connection = "dialup"; objHelper.VersionLanguage = objHelper.GetAccountDetails("ENUS", this.Connection, ref objHelper); objHelper.LanguageSelected = "ENUS"; break; case "ENUS : Premium": objHelper.VersionLanguage = objHelper.GetAccountDetails("ENUS", this.Connection, ref objHelper); objHelper.LanguageSelected = "ENUS"; break; } } else { throw new Exception(BuildSanityUIMessages.MsgSpaceNotAvailable); } }
public TableEntity Create(ISession session, CleanUp cleanUp, string name = null, string database = null, string description = null, string schema = null) { name = name ?? RandomTool.RandomString(20); database = database ?? RandomTool.RandomString(20); description = description ?? RandomTool.RandomString(20); schema = schema ?? RandomTool.RandomString(20); var tableToSave = new TableEntity { DatabaseName = database, Description = description, Name = name, SchemaName = schema }; using (var transaction = session.BeginTransaction()) { session.Save(tableToSave); transaction.Commit(); cleanUp.AddForDeletion(tableToSave); } return tableToSave; }
void CreateTerrain(){ //fire up the progress bar ShowProgressBar(1, 100); TerrainData terrain = new TerrainData(); terrain.heightmapResolution = resolution; GameObject terrainObject = Terrain.CreateTerrainGameObject(terrain); Undo.RegisterCreatedObjectUndo(terrainObject, "Object to Terrain"); MeshCollider collider = Selection.activeGameObject.GetComponent<MeshCollider>(); CleanUp cleanUp = null; //Add a collider to our source object if it does not exist. //Otherwise raycasting doesn't work. if(!collider){ collider = Selection.activeGameObject.AddComponent<MeshCollider>(); cleanUp = () => DestroyImmediate(collider); } Bounds bounds = collider.bounds; float sizeFactor = collider.bounds.size.y / (collider.bounds.size.y + addTerrain.y); terrain.size = collider.bounds.size + addTerrain; bounds.size = new Vector3(terrain.size.x, collider.bounds.size.y, terrain.size.z); // Do raycasting samples over the object to see what terrain heights should be float[,] heights = new float[terrain.heightmapWidth, terrain.heightmapHeight]; Ray ray = new Ray(new Vector3(bounds.min.x, bounds.max.y + bounds.size.y, bounds.min.z), -Vector3.up); RaycastHit hit = new RaycastHit(); float meshHeightInverse = 1 / bounds.size.y; Vector3 rayOrigin = ray.origin; int maxHeight = heights.GetLength(0); int maxLength = heights.GetLength(1); Vector2 stepXZ = new Vector2(bounds.size.x / maxLength, bounds.size.z / maxHeight); for(int zCount = 0; zCount < maxHeight; zCount++){ ShowProgressBar(zCount, maxHeight); for(int xCount = 0; xCount < maxLength; xCount++){ float height = 0.0f; if(collider.Raycast(ray, out hit, bounds.size.y * 3)){ height = (hit.point.y - bounds.min.y) * meshHeightInverse; height += shiftHeight; //bottom up if(bottomTopRadioSelected == 0){ height *= sizeFactor; } //clamp if(height < 0){ height = 0; } } heights[zCount, xCount] = height; rayOrigin.x += stepXZ[0]; ray.origin = rayOrigin; } rayOrigin.z += stepXZ[1]; rayOrigin.x = bounds.min.x; ray.origin = rayOrigin; } terrain.SetHeights(0, 0, heights); EditorUtility.ClearProgressBar(); if(cleanUp != null){ cleanUp(); } }
public static void Start() { CleanUp.AutoClean(); }
private async System.Threading.Tasks.Task ExecuteAsync() { var client = new AzureResourceManagerClient(); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group Console.WriteLine($"--------Start create group {Context.RgName}--------"); var resourceGroup = subscription.GetResourceGroupContainer().Construct(Context.Loc).CreateOrUpdate(Context.RgName).Value; CleanUp.Add(resourceGroup.Id); var rgOps = subscription.GetResourceGroupOperations(Context.RgName); ShouldThrow <ArgumentException>( () => rgOps.AddTag("", ""), "AddTag with empty string didn't throw", "AddTag"); await ShouldThrowAsync <ArgumentException>( async() => await rgOps.AddTagAsync(null, null), "AddTagAsync with null string didn't throw", "AddTagAsync"); ShouldThrow <ArgumentException>( () => rgOps.StartAddTag("", null), "StartAddTag with empty string didn't throw", "StartAddTag"); await ShouldThrowAsync <ArgumentException>( async() => await rgOps.StartAddTagAsync(" ", "test"), "StartAddTagAsync with whitespaces only string didn't throw", "StartAddTagAsync"); // Create AvailabilitySet Console.WriteLine("--------Create AvailabilitySet async--------"); var aset = (await(await resourceGroup.GetAvailabilitySetContainer().Construct("Aligned").StartCreateOrUpdateAsync(Context.VmName + "_aSet")).WaitForCompletionAsync()).Value; var data = aset.Get().Value.Data; ShouldThrow <ArgumentException>( () => rgOps.CreateResource <AvailabilitySetContainer, AvailabilitySet, AvailabilitySetData>("", data), "CreateResource with empty string didn't throw", "CreateResource"); await ShouldThrowAsync <ArgumentException>( async() => await rgOps.CreateResourceAsync <AvailabilitySetContainer, AvailabilitySet, AvailabilitySetData>(" ", data), "CreateResourceAsync with whitespaces string didn't throw", "CreateResourceAsync"); ShouldThrow <ArgumentNullException>( () => rgOps.SetTags(null), "SetTags with null didn't throw", "SetTags"); await ShouldThrowAsync <ArgumentNullException>( async() => await rgOps.SetTagsAsync(null), "SetTagsAsync with null didn't throw", "SetTagsAsync"); ShouldThrow <ArgumentNullException>( () => rgOps.StartSetTags(null), "StartSetTags with null didn't throw", "StartSetTags"); await ShouldThrowAsync <ArgumentNullException>( async() => await rgOps.StartSetTagsAsync(null), "StartSetTagsAsync with null didn't throw", "StartSetTagsAsync"); ShouldThrow <ArgumentException>( () => rgOps.RemoveTag(""), "RemoveTag with empty string didn't throw", "RemoveTag"); await ShouldThrowAsync <ArgumentException>( async() => await rgOps.RemoveTagAsync(null), "RemoveTagAsync with null didn't throw", "RemoveTagAsync"); ShouldThrow <ArgumentException>( () => rgOps.StartRemoveTag(" "), "StartRemoveTag with whitespace string didn't throw", "StartRemoveTag"); await ShouldThrowAsync <ArgumentException>( async() => await rgOps.StartRemoveTagAsync(null), "StartRemoveTagAsync with null didn't throw", "StartRemoveTagAsync"); ShouldThrow <ArgumentNullException>( () => rgOps.CreateResource <AvailabilitySetContainer, AvailabilitySet, AvailabilitySetData>("tester", null), "CreateResource model exception not thrown", "CreateResource"); await ShouldThrowAsync <ArgumentNullException>( async() => await rgOps.CreateResourceAsync <AvailabilitySetContainer, AvailabilitySet, AvailabilitySetData>("tester", null), "CreateResourceAsync model exception not thrown", "CreateResourceAsync"); Console.WriteLine("--------Done--------"); }
static void Main(string[] args) { CleanUp.Test(); Files.PrintStars("Done"); }
public override void Execute() { // Note that we need to create 3 clients from this scenario; customer must know which client contains which resource var rmClient = new ResourcesManagementClient(Context.SubscriptionId, Context.Credential); var computeClient = new ComputeManagementClient(Context.SubscriptionId, Context.Credential); var networkClient = new NetworkManagementClient(Context.SubscriptionId, Context.Credential); // Create Resource Group Console.WriteLine($"--------Start create group {Context.RgName}--------"); // note that some resources use the StartCreate and some use Create - this can make it a bit difficult to handle resource creation generically var resourceGroup = rmClient.ResourceGroups.CreateOrUpdate(Context.RgName, new ResourceGroup(Context.Loc)).Value; CleanUp.Add(resourceGroup.Id); // Create AvailabilitySet Console.WriteLine("--------Start create AvailabilitySet--------"); var aset = new AvailabilitySet(Context.Loc) { PlatformUpdateDomainCount = 5, PlatformFaultDomainCount = 2, Sku = new Azure.ResourceManager.Compute.Models.Sku() { Name = "Aligned" } }; aset = computeClient.AvailabilitySets.CreateOrUpdate(Context.RgName, Context.VmName + "_aSet", aset).Value; // Create VNet Console.WriteLine("--------Start create VNet--------"); string vnetName = Context.VmName + "_vnet"; var vnet = new VirtualNetwork() { Location = Context.Loc, AddressSpace = new AddressSpace() { AddressPrefixes = new List <string>() { "10.0.0.0/16" } } }; vnet = networkClient.VirtualNetworks.StartCreateOrUpdate(Context.RgName, vnetName, vnet).WaitForCompletionAsync().ConfigureAwait(false).GetAwaiter().GetResult().Value; //create subnet Console.WriteLine("--------Start create Subnet--------"); var nsg = new NetworkSecurityGroup { Location = Context.Loc }; nsg.SecurityRules = new List <SecurityRule> { new SecurityRule { Name = "Port80", Priority = 1001, Protocol = SecurityRuleProtocol.Tcp, Access = SecurityRuleAccess.Allow, Direction = SecurityRuleDirection.Inbound, SourcePortRange = "*", SourceAddressPrefix = "*", DestinationPortRange = "80", DestinationAddressPrefix = "*", Description = $"Port_80" } }; nsg = networkClient.NetworkSecurityGroups.StartCreateOrUpdate(Context.RgName, Context.NsgName, nsg).WaitForCompletionAsync().ConfigureAwait(false).GetAwaiter().GetResult().Value; var subnet = new Subnet() { Name = Context.SubnetName, AddressPrefix = "10.0.0.0/24", NetworkSecurityGroup = nsg }; subnet = networkClient.Subnets.StartCreateOrUpdate(Context.RgName, vnetName, Context.SubnetName, subnet).WaitForCompletionAsync().ConfigureAwait(false).GetAwaiter().GetResult().Value; // Create IP Address Console.WriteLine("--------Start create IP Address--------"); var ipAddress = new PublicIPAddress() { PublicIPAddressVersion = Azure.ResourceManager.Network.Models.IPVersion.IPv4.ToString(), PublicIPAllocationMethod = IPAllocationMethod.Dynamic, Location = Context.Loc, }; ipAddress = networkClient.PublicIPAddresses.StartCreateOrUpdate(Context.RgName, $"{Context.VmName}_ip", ipAddress).WaitForCompletionAsync().ConfigureAwait(false).GetAwaiter().GetResult().Value; // Create Network Interface Console.WriteLine("--------Start create Network Interface--------"); var nic = new NetworkInterface() { Location = Context.Loc, IpConfigurations = new List <NetworkInterfaceIPConfiguration>() { new NetworkInterfaceIPConfiguration() { Name = "Primary", Primary = true, Subnet = new Subnet() { Id = subnet.Id }, PrivateIPAllocationMethod = IPAllocationMethod.Dynamic, PublicIPAddress = new PublicIPAddress() { Id = ipAddress.Id } } } }; nic = networkClient.NetworkInterfaces.StartCreateOrUpdate(Context.RgName, $"{Context.VmName}_nic", nic).WaitForCompletionAsync().ConfigureAwait(false).GetAwaiter().GetResult().Value; // Create VM Console.WriteLine("--------Start create VM--------"); var vm = new VirtualMachine(Context.Loc) { NetworkProfile = new Azure.ResourceManager.Compute.Models.NetworkProfile { NetworkInterfaces = new[] { new NetworkInterfaceReference() { Id = nic.Id } } }, OsProfile = new OSProfile { ComputerName = Context.VmName, AdminUsername = "******", AdminPassword = "******", LinuxConfiguration = new LinuxConfiguration { DisablePasswordAuthentication = false, ProvisionVMAgent = true } }, StorageProfile = new StorageProfile() { ImageReference = new ImageReference() { Offer = "UbuntuServer", Publisher = "Canonical", Sku = "18.04-LTS", Version = "latest" }, DataDisks = new List <DataDisk>() }, HardwareProfile = new HardwareProfile() { VmSize = VirtualMachineSizeTypes.StandardB1Ms }, // The namespace-qualified type for SubResource is needed because all 3 libraries define an identical SubResource type. In the proposed model, the common type would be part of the core library AvailabilitySet = new Azure.ResourceManager.Compute.Models.SubResource() { Id = aset.Id } }; vm = computeClient.VirtualMachines.StartCreateOrUpdate(Context.RgName, Context.VmName, vm).WaitForCompletionAsync().ConfigureAwait(false).GetAwaiter().GetResult().Value; Console.WriteLine("VM ID: " + vm.Id); Console.WriteLine("--------Done create VM--------"); }
public void OnCleanUp() { CleanUp?.Invoke(_quik, EventArgs.Empty); }
public override void Execute() { var rmClient = new ResourcesManagementClient(Context.SubscriptionId, Context.Credential); var computeClient = new ComputeManagementClient(Context.SubscriptionId, Context.Credential); var networkClient = new NetworkManagementClient(Context.SubscriptionId, Context.Credential); // Create Resource Group Console.WriteLine($"--------Start create group {Context.RgName}--------"); var resourceGroup = rmClient.ResourceGroups.CreateOrUpdate(Context.RgName, new ResourceGroup(Context.Loc)).Value; CleanUp.Add(resourceGroup.Id); // Create AvailabilitySet Console.WriteLine("--------Start create AvailabilitySet--------"); var aset = new AvailabilitySet(Context.Loc) { PlatformUpdateDomainCount = 5, PlatformFaultDomainCount = 2, Sku = new Azure.ResourceManager.Compute.Models.Sku() { Name = "Aligned" } }; aset = computeClient.AvailabilitySets.CreateOrUpdate(Context.RgName, Context.VmName + "_aSet", aset).Value; // Create VNet Console.WriteLine("--------Start create VNet--------"); string vnetName = Context.VmName + "_vnet"; var vnet = new VirtualNetwork() { Location = Context.Loc, AddressSpace = new AddressSpace() { AddressPrefixes = new List <string>() { "10.0.0.0/16" } } }; vnet = networkClient.VirtualNetworks.StartCreateOrUpdate(Context.RgName, vnetName, vnet).WaitForCompletionAsync().ConfigureAwait(false).GetAwaiter().GetResult().Value; //create subnet Console.WriteLine("--------Start create Subnet--------"); var nsg = new NetworkSecurityGroup { Location = Context.Loc }; nsg.SecurityRules = new List <SecurityRule> { new SecurityRule { Name = "Port80", Priority = 1001, Protocol = SecurityRuleProtocol.Tcp, Access = SecurityRuleAccess.Allow, Direction = SecurityRuleDirection.Inbound, SourcePortRange = "*", SourceAddressPrefix = "*", DestinationPortRange = "80", DestinationAddressPrefix = "*", Description = $"Port_80" } }; nsg = networkClient.NetworkSecurityGroups.StartCreateOrUpdate(Context.RgName, Context.NsgName, nsg).WaitForCompletionAsync().ConfigureAwait(false).GetAwaiter().GetResult().Value; var subnet = new Subnet() { Name = Context.SubnetName, AddressPrefix = "10.0.0.0/24", NetworkSecurityGroup = nsg }; subnet = networkClient.Subnets.StartCreateOrUpdate(Context.RgName, vnetName, Context.SubnetName, subnet).WaitForCompletionAsync().ConfigureAwait(false).GetAwaiter().GetResult().Value; CreateVmsAsync(resourceGroup, aset, subnet).ConfigureAwait(false).GetAwaiter().GetResult(); }
/// <summary> /// Convert a mesh to a Terrain Data. Store the Terrain Data in the Asset database. /// </summary> /// <param name="name">The name of the terrain data.</param> /// <param name="resolution">The resolution of the terrain.</param> /// <param name="addTerrain">Additional terrain to add around the mesh terrain.</param> /// <param name="shiftHeight">Shift the height of the terrain up/down by this amount.</param> /// <param name="bottomToTop"></param> /// <returns></returns> public static TerrainData CreateTerrainData(string name, int resolution, Vector3 addTerrain, float shiftHeight, bool bottomToTop = true) { Debug.Log("Bottom to top " + bottomToTop); TerrainData terrainData = new TerrainData(); terrainData.heightmapResolution = resolution; GameObject preview = GameObject.Find("Preview Mesh"); MeshCollider collider = preview.GetComponent <MeshCollider>(); CleanUp cleanUp = null; //Add a collider to our source object if it does not exist. //Otherwise raycasting doesn't work. if (!collider) { collider = preview.AddComponent <MeshCollider>(); cleanUp = () => GameObject.DestroyImmediate(collider); } Bounds bounds = collider.bounds; float sizeFactor = collider.bounds.size.y / (collider.bounds.size.y + addTerrain.y); terrainData.size = collider.bounds.size + addTerrain; bounds.size = new Vector3(terrainData.size.x, collider.bounds.size.y, terrainData.size.z); // Do raycasting samples over the object to see what terrain heights should be float[,] heights = new float[terrainData.heightmapWidth, terrainData.heightmapHeight]; Ray ray = new Ray(new Vector3(bounds.min.x, bounds.max.y + bounds.size.y, bounds.min.z), -Vector3.up); RaycastHit hit = new RaycastHit(); float meshHeightInverse = 1 / bounds.size.y; Vector3 rayOrigin = ray.origin; int maxHeight = heights.GetLength(0); int maxLength = heights.GetLength(1); Vector2 stepXZ = new Vector2(bounds.size.x / maxLength, bounds.size.z / maxHeight); for (int zCount = 0; zCount < maxHeight; zCount++) { for (int xCount = 0; xCount < maxLength; xCount++) { float height = 0.0f; if (collider.Raycast(ray, out hit, bounds.size.y * 3)) { height = (hit.point.y - bounds.min.y) * meshHeightInverse; height += shiftHeight; //bottom up if (bottomToTop) { height *= sizeFactor; } //clamp if (height < 0) { height = 0; } } heights[zCount, xCount] = height; rayOrigin.x += stepXZ[0]; ray.origin = rayOrigin; } rayOrigin.z += stepXZ[1]; rayOrigin.x = bounds.min.x; ray.origin = rayOrigin; } terrainData.SetHeights(0, 0, heights); if (cleanUp != null) { cleanUp(); } if (!AssetDatabase.IsValidFolder("Assets/Terrain")) { AssetDatabase.CreateFolder("Assets", "Terrain"); } AssetDatabase.CreateAsset(terrainData, "Assets/Terrain/" + name + ".asset"); return(terrainData); }
/// <summary> /// Starting SignUp of MSN Client /// </summary> /// <param name="option">Installation option</param> /// <param name="susiiPath">Location of SUSII</param> /// <returns>Copied Susii location</returns> internal void Start(string option, ref Helper objHelper) { if (!CleanUp.Clean()) { throw new Exception(Constants.CleanUpError); } DriveInfo driveInstallation = new DriveInfo(Environment.SystemDirectory.Substring(0, Environment.SystemDirectory.IndexOf("\\"))); ////Check drive size is greater than 35mB if (driveInstallation.TotalFreeSpace > Constants.RequiredDiskSpace) { Logger.AddComment(Constants.LoggingCleanUp, Logger.CommentType.Pass); string choice = option; connection = "premium"; switch (choice) { case "ENUS : DialUp": connection = "dialup"; objHelper.VersionLanguage = objHelper.GetMailId("ENUS", connection, ref objHelper); objHelper.LanguageSelected = "ENUS"; break; case "ENUS : Premium": objHelper.VersionLanguage = objHelper.GetMailId("ENUS", connection, ref objHelper); objHelper.LanguageSelected = "ENUS"; break; case "DE-DE": objHelper.VersionLanguage = objHelper.GetMailId("DEDE", connection, ref objHelper); Localization.LocalizationIndex = 1; break; case "FR-FR": objHelper.VersionLanguage = objHelper.GetMailId("FRFR", connection, ref objHelper); Localization.LocalizationIndex = 2; break; case "ES-ES": objHelper.VersionLanguage = objHelper.GetMailId("ESES", connection, ref objHelper); Localization.LocalizationIndex = 3; break; case "FR-CA": objHelper.VersionLanguage = objHelper.GetMailId("FRCA", connection, ref objHelper); Localization.LocalizationIndex = 2; break; case "ES-MX": objHelper.VersionLanguage = objHelper.GetMailId("ESMX", connection, ref objHelper); Localization.LocalizationIndex = 3; break; case "EN-GB": objHelper.VersionLanguage = objHelper.GetMailId("ENGB", connection, ref objHelper); break; case "EN-AU": objHelper.VersionLanguage = objHelper.GetMailId("ENAU", connection, ref objHelper); break; case "EN-CA": objHelper.VersionLanguage = objHelper.GetMailId("ENCA", connection, ref objHelper); break; case "BC01 EN-CA": isPartner = true; objHelper.PartnerSelected = "BC01"; objHelper.VersionLanguage = objHelper.GetMailId("BC01 EN-CA", connection, ref objHelper); break; case "BC01 FR-CA": isPartner = true; objHelper.PartnerSelected = "BC01"; Localization.LocalizationIndex = 2; objHelper.VersionLanguage = objHelper.GetMailId("BC01 FR-CA", connection, ref objHelper); break; case "Q001": isPartner = true; connection = "dialup"; objHelper.PartnerSelected = "Q001"; objHelper.VersionLanguage = objHelper.GetMailId("Q001", connection, ref objHelper); break; case "Q002": isPartner = true; objHelper.PartnerSelected = "Q002"; objHelper.VersionLanguage = objHelper.GetMailId("Q002", connection, ref objHelper); break; case "VZ01": isPartner = true; objHelper.VersionLanguage = objHelper.GetMailId("VZ01", connection, ref objHelper); objHelper.LanguageSelected = "VZ01"; break; case "VZ02": isPartner = true; objHelper.PartnerSelected = "VZ02"; objHelper.VersionLanguage = objHelper.GetMailId("VZ02", connection, ref objHelper); break; case "DELL": objHelper.VersionLanguage = objHelper.GetMailId("DELL", connection, ref objHelper); objHelper.LanguageSelected = "DELL"; break; } } else { throw new Exception("Size in Root drive is lesser than 35Mb Please uninstall few files before installation"); } }