private BootstrapData SaveBootstrapData(BootstrapData vm) { var isUpdate = vm.Id > 0; var bootstrapData = new BootstrapData(); var processedOrderChanged = false; if (isUpdate) { bootstrapData = dataFlowDbContext.BootstrapData.FirstOrDefault(x => x.Id == vm.Id); bootstrapData.Id = vm.Id; processedOrderChanged = bootstrapData.ProcessingOrder != vm.ProcessingOrder; } bootstrapData.EntityId = vm.EntityId; bootstrapData.Data = vm.Data; bootstrapData.ProcessingOrder = vm.ProcessingOrder; bootstrapData.ProcessedDate = isUpdate ? vm.ProcessedDate : null; bootstrapData.CreateDate = isUpdate ? vm.CreateDate : DateTime.Now; bootstrapData.UpdateDate = DateTime.Now; dataFlowDbContext.BootstrapData.AddOrUpdate(bootstrapData); dataFlowDbContext.SaveChanges(); LogService.Info(LogTemplates.InfoCrud("BootstrapData", bootstrapData.EntityId.ToString(), bootstrapData.Id, LogTemplates.EntityAction.Added)); ReorderBootstrapData(bootstrapData.ProcessingOrder, bootstrapData.Id, false, isUpdate && processedOrderChanged); return(bootstrapData); }
public ActionResult Add() { var bootstrapData = new BootstrapData(); ViewBag.Entities = GetEntityList; return(View(bootstrapData)); }
protected void AddBootstrapJsonBinary(IList <Binary> binaries, Component relatedComponent, StructureGroup sg, string variantName) { BootstrapData bootstrapData = new BootstrapData { Files = binaries.Where(b => b != null).Select(b => b.Url).ToArray() }; binaries.Add(AddJsonBinary(bootstrapData, relatedComponent, sg, BootstrapFilename, variantName + "-bootstrap")); }
public IContainer GetContainer() { if (BootstrapData == null) { BootstrapData = BootstrapApplication(); } var builder = new ContainerBuilder(); builder.RegisterWebPortal(); // You'll need to have an AWS profile configured in one of two ways: // 1) Ambient environment http://docs.aws.amazon.com/AWSSdkDocsNET/latest/DeveloperGuide/net-dg-config-creds.html // 2) EC2 IAM role // // The profile will need: // * EC2 access to describe the tags of the instance StackIt is running on // * S3 access to the bucket where the bootstrap config lives // * KMS access to the master key that's used for encrypting other AWS profiles builder.Register(context => AmbientCredentials.GetCredentials()).As <AWSCredentials>(); builder.Register(context => { var kmsClient = new AmazonKeyManagementServiceClient(context.Resolve <AWSCredentials>()); var masterKeyAlias = context.Resolve <IStackItConfiguration>().CloudOptions.MasterKeyAlias; return(new EnvelopeCryptoProvider(kmsClient, string.Format("alias/{0}", masterKeyAlias))); }).As <ICryptoProvider>(); // At this point, the application is configured to use values supplied by app.config // However, if we're running on EC2 and bootstrap data was provided, // we need to overwrite some infrastructure-level registrations if (BootstrapData != null) { builder.RegisterType <BootstrapDatabaseConfiguration>().As <IDatabaseConfiguration>() .WithParameter("connectionString", BootstrapData.ApplicationDatabaseConnectionString); builder.RegisterType <BootstrapCrowdConfiguration>().As <ICrowdConfiguration>() .WithParameter("url", BootstrapData.CrowdUrl) .WithParameter("applicationName", BootstrapData.CrowdUsername) .WithParameter("apiPassword", BootstrapData.CrowdPassword); builder.RegisterType <BootstrapHangfireConfiguration>().As <IHangfireConfiguration>() .WithParameter("connectionString", BootstrapData.HangfireDatabaseConnectionString); } builder.Register(_ => EventBus.Instance).SingleInstance(); builder.RegisterHubWithLifetimeScope <EventBusHub>(); return(builder.Build()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //the terrible hack var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance; //Add admin details to database BootstrapData.SeedAdminData(); }
public ActionResult Edit(BootstrapData vm) { if (!JsonHelper.IsValidJson(vm.Data)) { ModelState.AddModelError("Data", "Please enter valid JSON."); } if (!ModelState.IsValid) { ViewBag.Entities = GetEntityList; return(View(vm)); } SaveBootstrapData(vm); return(RedirectToAction("Index")); }
private void LoadResources() { using (new Tracer(this)) { BootstrapData resourcesData = null; LoadStaticContentItem("resources/_all.json", ref resourcesData); _resources = new Hashtable(); foreach (string staticContentItemUrl in resourcesData.Files) { string type = staticContentItemUrl.Substring(staticContentItemUrl.LastIndexOf("/", StringComparison.Ordinal) + 1); type = type.Substring(0, type.LastIndexOf(".", StringComparison.Ordinal)).ToLower(); string resourcesJson = SiteConfiguration.ContentProvider.GetStaticContentItem(staticContentItemUrl, this).GetText(); IDictionary <string, object> resources = JsonConvert.DeserializeObject <Dictionary <string, object> >(resourcesJson); foreach (KeyValuePair <string, object> resource in resources) { //we ensure resource key uniqueness by adding the type (which comes from the filename) _resources.Add($"{type}.{resource.Key}", resource.Value); } } } }
protected IDictionary LoadResources() { using (new Tracer(this)) { try { BootstrapData resourcesData = null; _localization.LoadStaticContentItem("resources/_all.json", ref resourcesData); var allResources = new Hashtable(); foreach (string staticContentItemUrl in resourcesData.Files) { string type = staticContentItemUrl.Substring( staticContentItemUrl.LastIndexOf("/", StringComparison.Ordinal) + 1); type = type.Substring(0, type.LastIndexOf(".", StringComparison.Ordinal)).ToLower(); string resourcesJson = SiteConfiguration.ContentProvider.GetStaticContentItem(staticContentItemUrl, _localization) .GetText(); IDictionary <string, object> resources = JsonConvert.DeserializeObject <Dictionary <string, object> >(resourcesJson); foreach (KeyValuePair <string, object> resource in resources) { //we ensure resource key uniqueness by adding the type (which comes from the filename) allResources.Add($"{type}.{resource.Key}", resource.Value); } } return(allResources); } catch (Exception) { Log.Warn("Failed to open 'resources/_all.json'"); return(new ConcurrentDictionary <string, object>()); } } }
protected void AddBootstrapJsonBinary(IList<Binary> binaries, Component relatedComponent, StructureGroup sg, string variantName) { BootstrapData bootstrapData = new BootstrapData { Files = binaries.Where(b => b != null).Select(b => b.Url).ToArray() }; binaries.Add(AddJsonBinary(bootstrapData, relatedComponent, sg, BootstrapFilename, variantName + "-bootstrap")); }