public RequestOrchestration( IInfrastructure infrastructure, ARMTemplateHelper templateHelper) { this.infrastructure = infrastructure; this.templateHelper = templateHelper; }
/// <summary> /// get the dbcontext from a DbSet /// </summary> /// <typeparam name="T"></typeparam> /// <param name="dbSet"></param> /// <returns></returns> public static DbContext GetDbContext <TEntity>(this DbSet <TEntity> dbSet) where TEntity : class { IInfrastructure <IServiceProvider> infrastructure = dbSet as IInfrastructure <IServiceProvider>; ICurrentDbContext currentDbContext = infrastructure.Instance.GetService(typeof(ICurrentDbContext)) as ICurrentDbContext; return(currentDbContext.Context); }
public void DeleteInfrastructure(IInfrastructure infra) { var infraPath = Path.Combine(_providerPath, infra.Name); var directoryInfo = new DirectoryInfo(infraPath); foreach (var directory in directoryInfo.EnumerateDirectories()) { var jsonFile = directory.EnumerateFiles("*.json").FirstOrDefault(); if (jsonFile == null) { throw new FileNotFoundException("Config file is not available!!!!"); } var text = File.ReadAllText(jsonFile.FullName); var deserializeObject = JsonConvert.DeserializeObject(text, _jsonSerializerSettings); if (!(deserializeObject is IMaybeAggregated)) { jsonFile.Delete(); directory.Delete(); } } var directoryInfo2 = new DirectoryInfo(infraPath); foreach (var directory in directoryInfo2.EnumerateDirectories()) { directory.Delete(true); } }
private static List <Resource> ExpandCopyResource( JsonElement resource , JsonElement copyElement , Dictionary <string, object> context , ARMFunctions functions , IInfrastructure infrastructure , string parentName , string parentType) { Copy copy = Copy.Parse(copyElement, context, functions, infrastructure); DeploymentContext deploymentContext = context[ContextKeys.ARM_CONTEXT] as DeploymentContext; var CopyResource = new CopyResource() { Name = copy.Name, Type = Copy.ServiceType, FullName = $"{deploymentContext.DeploymentName}/{copy.Name}", FullType = $"{infrastructure.BuiltinServiceTypes.Deployments}/{Copy.ServiceType}", ResourceId = copy.Id, Mode = copy.Mode, BatchSize = copy.BatchSize, }; List <Resource> resources = new List <Resource> { CopyResource }; var copyindex = new Dictionary <string, int>() { { copy.Name, 0 } }; Dictionary <string, object> copyContext = new Dictionary <string, object> { { ContextKeys.ARM_CONTEXT, deploymentContext }, { ContextKeys.COPY_INDEX, copyindex }, { ContextKeys.CURRENT_LOOP_NAME, copy.Name }, { ContextKeys.IS_PREPARE, true } }; for (int i = 0; i < copy.Count; i++) { copyindex[copy.Name] = i; var rs = ParseInternal(resource, copyContext, functions, infrastructure, parentName, parentType); rs[0].CopyIndex = i; rs[0].CopyId = copy.Id; rs[0].CopyName = copy.Name; CopyResource.Resources.Add(rs[0].Name); resources.AddRange(rs); } CopyResource.SubscriptionId = resources[1].SubscriptionId; CopyResource.ManagementGroupId = resources[1].ManagementGroupId; CopyResource.SKU = resources[1].SKU; CopyResource.Plan = resources[1].Plan; CopyResource.Kind = resources[1].Kind; CopyResource.Zones = resources[1].Zones; CopyResource.Location = resources[1].Location; return(resources); }
public void CreateResource(IResource resource, IInfrastructure infra) { var infraPath = CreateDirectory(infra.Name, _providerPath); var resourcePath = CreateDirectory(resource.Name, infraPath); WriteJson(infra, resource); }
public AsyncRequestActivity(IOptions <CommunicationWorkerOptions> options, ARMTemplateHelper templateHelper, IInfrastructure infrastructure) { this.infrastructure = infrastructure; this.templateHelper = templateHelper; asyncRequestActivity = new maskx.OrchestrationService.Activity.AsyncRequestActivity(options); }
public SshClientMock(IInfrastructure infrastructure) { if (!(infrastructure is InfrastructureMock)) { throw new Exception("SshClientMock must be used with InfrastructureMock"); } this.infrastructure = (InfrastructureMock)infrastructure; }
public WaitDependsOnActivity(IOptions <ARMOrchestrationOptions> options, ARMTemplateHelper templateHelper, IInfrastructure infrastructure) { this.options = options?.Value; this.templateHelper = templateHelper; this.infrastructure = infrastructure; this.commandText = string.Format(commandTemplate, this.options.Database.WaitDependsOnTableName); }
public DeploymentOrchestration( ARMTemplateHelper helper, IInfrastructure infrastructure, ARMFunctions aRMFunctions) { this._ARMFunctions = aRMFunctions; this.helper = helper; this.infrastructure = infrastructure; }
private void WriteJson(IInfrastructure infra, IResource resource) { var filePath = GetFileNamePath(infra.Name, resource.Name); var serialized = JsonConvert.SerializeObject(resource, _jsonSerializerSettings); File.WriteAllText(filePath, serialized); }
public static TService TryGetService <TService>([NotNull] this IInfrastructure <IServiceProvider> accessor) { try { return(accessor.GetService <TService>()); } catch { return(default);
public ARMFunctions(IOptions <ARMOrchestrationOptions> options, IServiceProvider serviceProvider, IInfrastructure infrastructure) { this.options = options?.Value; this.serviceProvider = serviceProvider; this.infrastructure = infrastructure; this.InitBuiltInFunction(); }
private static TService GetService <TService>(IInfrastructure <IServiceProvider> databaseFacade) { Check.NotNull(databaseFacade, nameof(databaseFacade)); var service = databaseFacade.Instance.GetService <TService>(); if (service == null) { throw new InvalidOperationException("MongoDb is not in use."); } return(service); }
public InfraWebServerCreateVm( ListAsk listAsk, ListResources listResources, IInfrastructure infrastructure, ISshClient sshClient) { this.listAsk = listAsk; this.infrastructure = infrastructure; this.listResources = listResources; this.sshClient = sshClient; }
private static TService GetService <TService>(IInfrastructure <IServiceProvider> databaseFacade) { var service = databaseFacade.Instance.GetService <TService>(); if (service == null) { throw new InvalidOperationException(CosmosStrings.CosmosNotInUse); } return(service); }
public static SshConnection GetVmSshConnection(this IInfrastructure infrastructure, string key, string vmName, string user, string password) { var sshUri = infrastructure.GetVmSshUri(key, vmName); return(new SshConnection() { SshUri = sshUri, User = user, Password = password }); }
/// <summary> /// Gets the database service. /// </summary> /// <typeparam name="TService">The type of the service.</typeparam> /// <param name="databaseFacade">The database facade where looking for the service.</param> /// <returns></returns> /// <exception cref="InvalidOperationException">The service is not registered in the facade.</exception> private static TService GetDatabaseService <TService>(this IInfrastructure <IServiceProvider> databaseFacade) { var service = databaseFacade.Instance.GetService <TService>(); if (service == null) { throw new InvalidOperationException($"Service {typeof(TService).Name} not found"); } return(service); }
public static List <Resource> Parse( string rawString , Dictionary <string, object> context , ARMFunctions functions , IInfrastructure infrastructure , string parentName, string parentType) { using var doc = JsonDocument.Parse(rawString); return(Parse(doc.RootElement, context, functions, infrastructure, parentName, parentType)); }
private static TService GetRelationalService <TService>(this IInfrastructure <IServiceProvider> databaseFacade) { Check.NotNull(databaseFacade, nameof(databaseFacade)); var service = databaseFacade.Instance.GetService <TService>(); if (service == null) { throw new InvalidOperationException(RelationalStrings.RelationalNotInUse); } return(service); }
public Service( IEntityRepository entityRepository, IMapper mapper, ISubscriptionHandlerFactory subscriptionHandlerFactory, IInfrastructure infrastructure, IImportOpml importer) { this.entityRepository = entityRepository; this.mapper = mapper; this.subscriptionHandlerFactory = subscriptionHandlerFactory; this.infrastructure = infrastructure; this.importer = importer; }
/// <summary> /// <para> /// Resolves a service from the <see cref="IServiceProvider" /> exposed from a type that implements /// <see cref="IInfrastructure{IServiceProvider}" />. /// </para> /// <para> /// This method is typically used by database providers (and other extensions). It is generally /// not used in application code. /// </para> /// <para> /// <see cref="IInfrastructure{T}" /> is used to hide properties that are not intended to be used in /// application code but can be used in extension methods written by database providers etc. /// </para> /// </summary> /// <typeparam name="TService"> The type of service to be resolved. </typeparam> /// <param name="accessor"> The object exposing the service provider. </param> /// <returns> The requested service. </returns> public static TService GetService <TService>([NotNull] this IInfrastructure <IServiceProvider> accessor) { Check.NotNull(accessor, nameof(accessor)); var service = accessor.Instance.GetService <TService>(); if (service == null) { throw new InvalidOperationException(CoreStrings.NoProviderConfiguredFailedToResolveService(typeof(TService).FullName)); } return(service); }
public bool UpgradeCapacity(IInfrastructure infrastructureToUpgrade, Cell currentCell) { var previousTech = infrastructureToUpgrade.GetCurrentLevel(InfrastructureLevelType.Capacity); var upgrade = infrastructureToUpgrade?.Upgrade(InfrastructureLevelType.Capacity); if (upgrade == null) { return(false); } this.Money -= upgrade.BuildCost; this.MaintenanceCosts = this.MaintenanceCosts - previousTech.MaintenanceCost + upgrade.MaintenanceCost; return(true); }
public DeploymentOperation(DeploymentContext deploymentContext, IInfrastructure infrastructure, Resource resource = null) { this.GroupType = deploymentContext.GroupType; this.GroupId = deploymentContext.GroupId; this.HierarchyId = deploymentContext.HierarchyId; this.RootId = deploymentContext.RootId; this.DeploymentId = deploymentContext.DeploymentId; this.CorrelationId = deploymentContext.CorrelationId; this.CreateByUserId = deploymentContext.CreateByUserId; if (string.IsNullOrEmpty(deploymentContext.LastRunUserId)) { this.LastRunUserId = this.CreateByUserId; } else { this.LastRunUserId = deploymentContext.LastRunUserId; } if (resource == null) { if (!string.IsNullOrEmpty(deploymentContext.SubscriptionId)) { this.SubscriptionId = deploymentContext.SubscriptionId; this.ResourceId = $"/{infrastructure.BuiltinPathSegment.Subscription}/{deploymentContext.SubscriptionId}"; } if (!string.IsNullOrEmpty(deploymentContext.ManagementGroupId)) { this.ManagementGroupId = deploymentContext.ManagementGroupId; this.ResourceId = $"/{infrastructure.BuiltinPathSegment.ManagementGroup}/{deploymentContext.ManagementGroupId}"; } if (!string.IsNullOrEmpty(deploymentContext.ResourceGroup)) { this.ResourceId += $"/{infrastructure.BuiltinPathSegment.ResourceGroup}/{deploymentContext.ResourceGroup}"; } this.ResourceId += $"/{infrastructure.BuiltinPathSegment.Provider}/{infrastructure.BuiltinServiceTypes.Deployments}/{deploymentContext.DeploymentName}"; this.Type = infrastructure.BuiltinServiceTypes.Deployments; this.Name = deploymentContext.DeploymentName; this.ParentResourceId = deploymentContext.ParentId; this.SubscriptionId = deploymentContext.SubscriptionId; this.ManagementGroupId = deploymentContext.ManagementGroupId; } else { this.ResourceId = resource.ResourceId; this.Name = resource.FullName; this.Type = resource.FullType; this.ParentResourceId = string.IsNullOrEmpty(resource.CopyId) ? deploymentContext.GetResourceId(infrastructure) : resource.CopyId; this.SubscriptionId = resource.SubscriptionId; this.ManagementGroupId = resource.ManagementGroupId; } }
public static List <Resource> Parse( JsonElement resourceElement , Dictionary <string, object> context , ARMFunctions functions , IInfrastructure infrastructure , string parentName, string parentType) { if (resourceElement.TryGetProperty("copy", out JsonElement copy)) { return(ExpandCopyResource(resourceElement, copy, context, functions, infrastructure, parentName, parentType)); } return(ParseInternal(resourceElement, context, functions, infrastructure, parentName, parentType)); }
public ARMOrchestrationClient( OrchestrationWorkerClient orchestrationWorkerClient, IOptions <ARMOrchestrationOptions> options, IInfrastructure infrastructure) { this._OrchestrationWorkerClient = orchestrationWorkerClient; this._Options = options?.Value; this._Infrastructure = infrastructure; this._GetResourceListCommandString = string.Format("select * from {0} where deploymentId=@deploymentId", this._Options.Database.DeploymentOperationsTableName); this._GetAllResourceListCommandString = string.Format("select * from {0} where RootId=@RootId", this._Options.Database.DeploymentOperationsTableName); }
private static void GetBulkInfrstructure <TEntity>(DbContext context, out IInfrastructure <IServiceProvider> sp, out IEntityType entity, out IRelationalConnection relationalConnection) { sp = (IInfrastructure <IServiceProvider>)context; var options = sp.GetService <IDbContextOptions>(); entity = context.Model.FindEntityType(typeof(TEntity)); if (entity == null) { throw new NotSupportedException($"The type {typeof(TEntity)} is not part of the EntityFramework metadata model. Only mapped entities are supported."); } relationalConnection = sp.GetService <IRelationalConnection>(); }
public void ClickOnCell(Cell cell) { _buildMenu.SetActive(false); _disctrictMenu.SetActive(false); _infosMenu.SetActive(false); if (_currentCell == cell) { _currentCell.GetComponent <MeshRenderer>().material = _unSelectedMaterial; _currentCell = null; return; } if (_currentCell != null) { _currentCell.GetComponent <MeshRenderer>().material = _unSelectedMaterial; } _currentCell = cell; cell.GetComponent <MeshRenderer>().material = _selectedMaterial; if (!cell.IsConstructible) // Si la cellule a un quartier { District district = cell.Building.GetComponent <District>(); _infoLevelDistrictText.text = district.Level.ToString(CultureInfo.InvariantCulture); _infoPeopleDistrictText.text = district.Peoples.ToString(CultureInfo.InvariantCulture); _disctrictMenu.SetActive(true); } else if (!cell.HaveBuilding) // Si la cellule n'a rien dessus et qu'elle est constructible { _buildMenu.SetActive(true); } else if (cell.HaveBuilding) // Si la cellule a une infrastructure dessus { IInfrastructure infrastructure = cell.Building.GetComponent <IInfrastructure>(); _infoMaintenanceCostText.text = infrastructure.MaintenanceCost.ToString(CultureInfo.InvariantCulture) + " €"; _infoNameText.GetComponent <TranslateText>().SetText(infrastructure.Name); _infoTypeText.GetComponent <TranslateText>().SetText(infrastructure.InfrastructureType == InfrastructureType.CellularNetwork ? "Cellular" : "Wired"); _upgradeCapacityCostText.text = infrastructure.GetNextUpgrade(InfrastructureLevelType.Capacity).BuildCost.ToString(CultureInfo.InvariantCulture) + " €"; _upgradeCapacityNameText.GetComponent <TranslateText>().SetText(infrastructure.GetNextUpgrade(InfrastructureLevelType.Capacity).Name); _upgradeTechnologyCostText.text = infrastructure.GetNextUpgrade(InfrastructureLevelType.Technology).BuildCost.ToString(CultureInfo.InvariantCulture) + " €"; _upgradeTechnologyNameText.GetComponent <TranslateText>().SetText(infrastructure.GetNextUpgrade(InfrastructureLevelType.Technology).Name); _infosMenu.SetActive(true); } }
public static void ApplyAllAssemblyConfigurations <T>(this IInfrastructure <T> modelBuilder, Type[] tipos) { var methodInfo = modelBuilder.GetType().GetMethod( nameof(ModelBuilder.ApplyConfiguration), BindingFlags.Instance | BindingFlags.Public ); var mapeamentos = tipos.Where(ClasseImplementaEntityConfiguration); foreach (var mapeamento in mapeamentos) { var entidadeMapeada = mapeamento.GetInterfaces().Single().GenericTypeArguments.Single(); var metodo = methodInfo.MakeGenericMethod(entidadeMapeada); metodo.Invoke(modelBuilder, new[] { Activator.CreateInstance(mapeamento) }); } }
public bool CanBuild(IInfrastructure infrastructureToBuild) { if (infrastructureToBuild == null) { return(false); } var infrastructureCount = this._infrastructuresList.Count(e => e.Name == infrastructureToBuild.Name && e.InfrastructureType == infrastructureToBuild.InfrastructureType); if (infrastructureCount >= infrastructureToBuild.Limit) { return(false); } return(!(infrastructureToBuild.BuildCost > this.Money)); }
/// <summary> /// Gets a TService from database facade. /// </summary> /// <param name="databaseFacade">The database facade for context.</param> /// <typeparam name="TService">The requered service.</typeparam> /// <returns>The instance of TService.</returns> private static TService GetService <TService>(this IInfrastructure <IServiceProvider> databaseFacade) { if (databaseFacade is null) { throw new ArgumentNullException(nameof(databaseFacade)); } var service = (TService)databaseFacade.Instance.GetService(typeof(TService)); if (service == null) { throw new InvalidOperationException($"Service {typeof(TService).Name} not found."); } return(service); }
private void CreateInfrastructurePanel(ISolutionBuilderViewModel solutionBuilderModel, IInfrastructure infrastructure, int position) { var infrastructureVM = new InnerPanelViewModel(); infrastructureVM.Title = "Infrastructure"; infrastructureVM.Items.Add(new InnerPanelTitle { Product = infrastructure.As<IProductElement>(), Text = infrastructure.InstanceName }); if (infrastructure.Security != null) { infrastructureVM.Items.Add(new InnerPanelTitle { Product = infrastructure.Security.As<IProductElement>(), Text = infrastructure.Security.InstanceName }); if (infrastructure.Security.Authentication != null) { infrastructureVM.Items.Add(new InnerPanelItem { Product = infrastructure.Security.Authentication.As<IProductElement>(), Text = infrastructure.Security.Authentication.InstanceName }); } } this.SetPanel(position, new LogicalView(new LogicalViewModel(solutionBuilderModel, infrastructureVM))); }
/// <summary> /// If the infrastructure project doesn't exist, it creates the project /// and adds references to the project on each existing endpoint project. /// Also it adds the references when a new endpoint is created /// by listening the OnInstantiated event. /// </summary> /// <param name="infrastructure">Infrastructure</param> /// <param name="solution">Solution</param> /// <returns>The infrastructure project</returns> public static IProject GenerateInfrastructureProjectIfNeeded(IInfrastructure infrastructure, ISolution solution) { var projectName = infrastructure.Parent.Parent.InstanceName + ".Infrastructure"; if (!solution.Items.Any(i => i.Name == projectName)) { // Unfold the project infrastructure.As<IProductElement>().Execute("GenerateProjectCommand"); infrastructure.As<IProductElement>().Execute("UnfoldPackagesConfig"); // Add the references on existing projects AddInfrastructureReferences(infrastructure.Parent.Parent, solution); infrastructure.Parent.Parent.OnInstantiatedEndpoint += (s, e) => { // Add the references on each new endpoint project AddInfrastructureReferences(infrastructure.Parent.Parent, solution); }; } var item = solution.Items.First(i => i.Name == projectName); return item.As<IProject>(); }