Exemple #1
0
        public virtual async Task LoadDAFApplications(ApplicationManagerClient appMgr, string entLookup)
        {
            log.LogInformation($"Loading DAF Applications for {entLookup}");

            State.DAFApplications = new List <DataDAFAppDetails>();

            if (!AllApplications.IsNullOrEmpty() && !State.ActiveAppPathGroup.IsNullOrEmpty())
            {
                log.LogInformation($"Loading active DAF Applications for {entLookup}");

                var activeApp = AllApplications.FirstOrDefault(app => app.PathGroup == State.ActiveAppPathGroup);

                await activeApp.AppIDs.Each(async appId =>
                {
                    log.LogInformation($"Listing active DAF Applications for {entLookup} from {appId}");

                    var dafApps = await appMgr.ListDAFApplications(entLookup, appId.Key);

                    if (dafApps.Status)
                    {
                        log.LogInformation($"Preparing DAF Application details for {entLookup} from {appId}");

                        var dafAppDetails = await getDetailsFromDAFApp(appMgr, entLookup, appId.Key, dafApps.Model);

                        lock (activeApp)
                            State.DAFApplications.Add(dafAppDetails);
                    }
                });
            }

            await SetActiveDAFApp(State.DAFApplications.FirstOrDefault(da => da.ID == State.ActiveDAFAppID)?.ID);
        }
 public ActionResult UpdateTenantDetails(TenantDetailsModel details)
 {
     var client = new ApplicationManagerClient();
     client.UpdateTenantUrl(details.ApplicationName, details.Name, details.Url);
     
     return RedirectToAction("TenantDetails" , new { details.ApplicationName, details.Name});
 }
Exemple #3
0
        public virtual async Task SaveDataApp(ApplicationDeveloperClient appDev, ApplicationManagerClient appMgr, string entApiKey, string host,
                                              Application app)
        {
            var appResp = await appDev.SaveApp(app, host, "lcu-data-apps", entApiKey);

            await SetActiveApp(appMgr, entApiKey, appResp.Model);
        }
Exemple #4
0
        public virtual async Task SaveDAFApp(ApplicationDeveloperClient appDev, ApplicationManagerClient appMgr, string entLookup,
                                             string host, DataDAFAppDetails dafAppDetails)
        {
            log.LogInformation($"Saving DAF Application for {entLookup}");

            var saveRes = await appDev.SaveAppAndDAFApps(new SaveAppAndDAFAppsRequest()
            {
                Application = new Application()
                {
                    ID           = dafAppDetails.ID,
                    Name         = dafAppDetails.Name,
                    Description  = dafAppDetails.Description,
                    PathRegex    = $"{dafAppDetails.Path.TrimEnd('/')}*",
                    AccessRights = dafAppDetails.Security.AccessRights,
                    Licenses     = dafAppDetails.Security.Licenses,
                    IsPrivate    = dafAppDetails.Security.IsPrivate,
                    Priority     = dafAppDetails.Priority
                },
                DAFApps = dafAppDetails.Configs.Select(dafAppConfig =>
                {
                    return(new DAFApplication()
                    {
                        Lookup = dafAppConfig.Key,
                        Details = dafAppConfig.Value,
                        Priority = 500
                    });
                }).ToList()
            }, entLookup, host);

            State.ActiveDAFAppID = null;

            await LoadApplications(appMgr, entLookup);
        }
Exemple #5
0
        public virtual async Task RefreshZipOptions(ApplicationManagerClient appMgr, EnterpriseManagerClient entMgr, string entLookup)
        {
            log.LogInformation($"Refreshing Zip Options for {entLookup}");

            State.ZipAppOptions = new List <ZipAppOption>();

            var entRes = await entMgr.GetEnterprise(entLookup);

            if (entRes.Status)
            {
                // var listRes = await appMgr.Get<ListFilesResponse>($"dfs/list/{entRes.Model.ID}/app-uploads/application/zip");

                log.LogInformation($"Listing files for Zip Options");

                var listRes = await appMgr.ListFiles(entRes.Model.ID, $"app-uploads/application/zip");

                if (listRes.Status)
                {
                    State.ZipAppOptions = listRes.Files.Select(file =>
                    {
                        return(new ZipAppOption()
                        {
                            DisplayName = file,
                            File = file
                        });
                    }).ToList();
                }
            }

            State.ZipLoading = false;
        }
Exemple #6
0
        public virtual async Task DeleteDAFApp(ApplicationDeveloperClient appDev, ApplicationManagerClient appMgr, string entLookup,
                                               Guid appId, List <string> lookups)
        {
            log.LogInformation($"Deleting DAF Applications for {entLookup} from {appId} with lookups {lookups.ToJSON()}");

            var dafApps = await appMgr.ListDAFApplications(entLookup, appId);

            await lookups.Each(async lookup =>
            {
                lookup = lookup.Trim();

                var dafApp = dafApps.Model.FirstOrDefault(da => da.Lookup == lookup);

                if (dafApp != null)
                {
                    log.LogInformation($"Removing DAF Application {lookup} for {appId}");

                    await appDev.RemoveDAFApp(appId, dafApp.ID, entLookup);
                }
            });

            dafApps = await appMgr.ListDAFApplications(entLookup, appId);

            if (dafApps.Status && dafApps.Model.IsNullOrEmpty())
            {
                log.LogInformation($"Removing entire Application {appId}");

                await appDev.RemoveApp(appId, entLookup);
            }

            await LoadApplications(appMgr, entLookup);
        }
Exemple #7
0
        public ConfigManagerStateHarness(HttpRequest req, ILogger log, ConfigManagerState state)
            : base(req, log, state)
        {
            this.container = "Default";

            this.appMgr = req.ResolveClient <ApplicationManagerClient>(log);
        }
Exemple #8
0
        public virtual async Task LoadSideBar(ApplicationManagerClient appMgr, string entApiKey)
        {
            if (State.SideBar == null)
            {
                State.SideBar = new IDESideBar();
            }

            if (State.CurrentActivity != null)
            {
                var sectionsResp = await appMgr.LoadIDESideBarSections(entApiKey, State.CurrentActivity.Lookup);

                State.SideBar.Actions = sectionsResp.Model.SelectMany(section =>
                {
                    var actionsResp = appMgr.LoadIDESideBarActions(entApiKey, State.CurrentActivity.Lookup, section).Result;

                    return(actionsResp.Model);
                }).ToList();
            }
            else
            {
                State.SideBar = new IDESideBar();
            }

            if (!State.HasLoaded)
            {
                var firstAction = State.SideBar?.Actions?.FirstOrDefault();

                if (firstAction != null)
                {
                    await SelectSideBarAction(appMgr, entApiKey, firstAction.Group, firstAction.Action, firstAction.Section);
                }

                State.HasLoaded = true;
            }
        }
        public ActionResult DeactivateTenant(string applicationName, string name)
        {
            var client = new ApplicationManagerClient();

            client.DeactivateTenant(applicationName, name);
            return(RedirectToAction("Tenants", new { applicationName }));
        }
Exemple #10
0
        public virtual async Task SaveDataFlow(ApplicationManagerClient appMgr, ApplicationDeveloperClient appDev, string entLookup, DataFlow dataFlow)
        {
            // Create a new data flow
            if (String.IsNullOrEmpty(dataFlow.Lookup) && (dataFlow.ID == Guid.Empty))
            {
                var resp = await appMgr.SaveDataFlow(dataFlow, entLookup, State.EnvironmentLookup);

                State.IsCreating = true;
            }
            else
            {
                // If lookup property exists, look for existing data flow
                var existing = await appMgr.GetDataFlow(entLookup, State.EnvironmentLookup, dataFlow.Lookup);

                if (existing == null)
                {
                    // If it doesn't exist, clear the lookup
                    dataFlow.Lookup  = String.Empty;
                    State.IsCreating = true;
                }

                var resp = await appMgr.SaveDataFlow(dataFlow, entLookup, State.EnvironmentLookup);

                State.IsCreating = !resp.Status;
            }

            await LoadDataFlows(appMgr, appDev, entLookup);
        }
Exemple #11
0
        public override async Task RunTaskAsync(string taskName, string taskSessionId)
        {
            if (taskName == null)
            {
                throw new ArgumentNullException(nameof(taskName));
            }
            if (taskSessionId == null)
            {
                throw new ArgumentNullException(nameof(taskSessionId));
            }

            var domainOutput = new DomainOutput();

            domainOutput.OnWrite     += (text, color) => Output.Write(text, color);
            domainOutput.OnWriteLine += (text, color) => Output.WriteLine(text, color);
            domainOutput.OnWriteRaw  += text => Output.WriteRaw(text);

            var packageClient     = new DomainPackageClient(Packages.Boundary);
            var applicationClient = new ApplicationManagerClient(Applications.Boundary)
            {
                CurrentProjectId        = Project.Id,
                CurrentDeploymentNumber = DeploymentNumber,
            };

            var context = new AgentDeployContext {
                DeploymentNumber      = DeploymentNumber,
                Project               = Project,
                ProjectPackageId      = ProjectPackageId,
                ProjectPackageVersion = ProjectPackageVersion,
                AssemblyFilename      = AssemblyFilename,
                TaskName              = taskName,
                WorkDirectory         = WorkDirectory,
                ContentDirectory      = ContentDirectory,
                BinDirectory          = BinDirectory,
                ApplicationsDirectory = ApplicationsDirectory,
                Output          = domainOutput,
                Packages        = packageClient,
                AgentVariables  = AgentVariables,
                ServerVariables = ServerVariables,
                Applications    = applicationClient,
                EnvironmentName = EnvironmentName,
                Agent           = Agent,
            };

            try {
                var task = Task.Run(async() => {
                    await Domain.RunDeployTask(context, TokenSource.Token);
                });
                await taskList.AddOrUpdate(taskSessionId, id => task, (id, _) => task);

                await task.ContinueWith(t => {
                    taskList.TryRemove(taskSessionId, out _);
                });
            }
            catch (Exception error) {
                Exception = error;
                throw;
            }
        }
        public virtual async Task SetEditSection(ApplicationManagerClient appMgr, string entApiKey, string section)
        {
            await ToggleAddNew(AddNewTypes.None);

            State.EditSection = State.SideBarSections?.FirstOrDefault(sec => sec == section);

            await LoadSecionActions(appMgr, entApiKey);
        }
        public Refresh(EnterpriseManagerClient entMgr, ApplicationManagerClient appMgr, ApplicationDeveloperClient appDev)
        {
            this.appDev = appDev;

            this.appMgr = appMgr;

            this.entMgr = entMgr;
        }
Exemple #14
0
        public SetActiveDataFlow(EnterpriseManagerClient entMgr, ApplicationManagerClient appMgr, ApplicationDeveloperClient appDev)
        {
            this.appDev = appDev;

            this.entMgr = entMgr;

            this.appMgr = appMgr;
        }
Exemple #15
0
        public virtual async Task LoadApplications(ApplicationManagerClient appMgr, string entApiKey)
        {
            var apps = await appMgr.ListApplications(entApiKey);

            State.Applications = apps.Model.Where(app => app.Container == "lcu-data-apps").ToList();

            State.ActiveApp = State.Applications.FirstOrDefault(app => app.ID == State.ActiveApp?.ID);
        }
        public RequestUserAccess(ApplicationManagerClient appMgr, ISecurityDataTokenService secMgr, IIdentityAccessService idMgr)
        {
            this.idMgr = idMgr;

            this.secMgr = secMgr;

            this.appMgr = appMgr;
        }
Exemple #17
0
        public virtual async Task Refresh(EnterpriseManagerClient entMgr, ApplicationManagerClient appMgr, ApplicationDeveloperClient appDev, string entApiKey, string host)
        {
            await LoadEnvironment(entMgr, entApiKey);

            await LoadDataFlows(appMgr, appDev, entApiKey);

            await LoadModulePackSetup(entMgr, appMgr, entApiKey, host);
        }
Exemple #18
0
        public virtual async Task LoadDataFlows(ApplicationManagerClient appMgr, ApplicationDeveloperClient appDev, string entApiKey)
        {
            var resp = await appMgr.ListDataFlows(entApiKey, State.EnvironmentLookup);

            State.DataFlows = resp.Model;

            await SetActiveDataFlow(appDev, entApiKey, State?.ActiveDataFlow?.Lookup);
        }
Exemple #19
0
        public AddPhoto(AmblOnGraph amblGraph, EnterpriseManagerClient entMgr, ApplicationManagerClient appMgr)
        {
            this.amblGraph = amblGraph;

            this.appMgr = appMgr;

            this.entMgr = entMgr;
        }
Exemple #20
0
        public Refresh(ApplicationDeveloperClient appDev, ApplicationManagerClient appMgr, IdentityManagerClient idMgr)
        {
            this.appDev = appDev;

            this.appMgr = appMgr;

            this.idMgr = idMgr;
        }
        public virtual async Task DeleteLCU(ApplicationDeveloperClient appDev, ApplicationManagerClient appMgr, string entApiKey, string lcuLookup)
        {
            await appDev.DeleteLCU(lcuLookup, entApiKey);

            //  TODO:  Need to delete other assets related to the LCU...  created apps, delete from filesystem, cleanup state??  Or what do we want to do with that stuff?

            await LoadLCUs(appMgr, entApiKey);
        }
        public ActionResult UpdateTenantDetails(TenantDetailsModel details)
        {
            var client = new ApplicationManagerClient();

            client.UpdateTenantUrl(details.ApplicationName, details.Name, details.Url);

            return(RedirectToAction("TenantDetails", new { details.ApplicationName, details.Name }));
        }
Exemple #23
0
        public virtual async Task SetActivity(ApplicationManagerClient appMgr, string entApiKey, string activityLookup)
        {
            State.CurrentActivity = State.Activities.FirstOrDefault(a => a.Lookup == activityLookup);

            await LoadSideBar(appMgr, entApiKey);

            State.SideBar.CurrentAction = State.SideBar.Actions.FirstOrDefault(a => $"{a.Group}|{a.Action}" == State.CurrentEditor?.Lookup);
        }
        public RequestUserAccess(ApplicationManagerClient appMgr, SecurityManagerClient secMgr, IdentityManagerClient idMgr)
        {
            this.idMgr = idMgr;

            this.secMgr = secMgr;

            this.appMgr = appMgr;
        }
Exemple #25
0
        public virtual async Task SetActiveApp(ApplicationManagerClient appMgr, string entApiKey, Application app)
        {
            await ToggleAddNew(AddNewTypes.None);

            State.ActiveApp = app;

            await LoadAppView(appMgr, entApiKey);
        }
Exemple #26
0
        public override async Task RunTaskAsync(string taskName, string taskSessionId)
        {
            using (var contextOutput = new DomainOutput()) {
                contextOutput.OnWrite     += (text, color) => Output.Write(text, color);
                contextOutput.OnWriteLine += (text, color) => Output.WriteLine(text, color);
                contextOutput.OnWriteRaw  += text => Output.WriteRaw(text);

                var packageClient     = new DomainPackageClient(Packages.Boundary);
                var applicationClient = new ApplicationManagerClient(Applications.Boundary)
                {
                    CurrentProjectId        = Project.Id,
                    CurrentDeploymentNumber = BuildNumber, // TODO: BuildTask should not have access
                };

                var context = new AgentBuildContext {
                    Project          = Project,
                    Agent            = Agent,
                    AssemblyFilename = AssemblyFilename,
                    GitRefspec       = GitRefspec,
                    TaskName         = taskName,
                    WorkDirectory    = WorkDirectory,
                    ContentDirectory = ContentDirectory,
                    BinDirectory     = BinDirectory,
                    BuildNumber      = BuildNumber,
                    Output           = contextOutput,
                    Packages         = packageClient,
                    ServerVariables  = ServerVariables,
                    AgentVariables   = AgentVariables,
                    Applications     = applicationClient,
                    CommitHash       = CommitHash,
                    CommitAuthor     = CommitAuthor,
                    CommitMessage    = CommitMessage,
                };

                var githubSource = Project?.Source as ProjectGithubSource;
                var notifyGithub = githubSource != null && githubSource.NotifyOrigin == NotifyOrigin.Agent;

                if (notifyGithub && SourceCommit != null)
                {
                    await NotifyGithubStarted(githubSource);
                }

                try {
                    var task = Task.Run(async() => {
                        await Domain.RunBuildTask(context, TokenSource.Token);
                    });
                    await taskList.AddOrUpdate(taskSessionId, id => task, (id, _) => task);

                    await task.ContinueWith(t => {
                        taskList.TryRemove(taskSessionId, out _);
                    });
                }
                catch (Exception error) {
                    Exception = error;
                    throw;
                }
            }
        }
        public ActionResult Add(string name)
        {
            Requires.ArgumentNotNullOrEmptyString(name, "name");

            var client = new ApplicationManagerClient();

            client.CreateApplication(name);
            return(RedirectToAction("Index", "Home"));
        }
        public virtual async Task LoadAppView(ApplicationManagerClient appMgr, string entLookup)
        {
            if (State.ActiveApp != null)
            {
                var dafApps = await appMgr.ListDAFApplications(entLookup, State.ActiveApp.ID);

                if (dafApps.Status)
                {
                    if (dafApps.Model.Count < 2)
                    {
                        State.ActiveDAFApp = dafApps?.Model?.FirstOrDefault()?.JSONConvert <DAFApplication>();

                        State.ActiveDAFAPIs = null;
                    }
                    else
                    {
                        State.ActiveDAFAPIs = dafApps?.Model?.ToList();

                        State.ActiveDAFApp = null;
                    }
                }
                else
                {
                    State.ActiveDAFApp = null;

                    State.ActiveDAFAPIs = null;
                }

                if (State.ActiveDAFApp != null)
                {
                    if (State.ActiveDAFApp.Details.Metadata.ContainsKey("APIRoot"))
                    {
                        await SetViewType(DAFAppTypes.API);
                    }
                    else if (State.ActiveDAFApp.Details.Metadata.ContainsKey("Redirect"))
                    {
                        await SetViewType(DAFAppTypes.Redirect);
                    }
                    else if (State.ActiveDAFApp.Details.Metadata.ContainsKey("BaseHref"))
                    {
                        await SetViewType(DAFAppTypes.View);
                    }
                    else if (State.ActiveDAFApp.Details.Metadata.ContainsKey("DAFApplicationID"))
                    {
                        await SetViewType(DAFAppTypes.DAFApp);
                    }
                }
                else if (!State.ActiveDAFAPIs.IsNullOrEmpty())
                {
                    await SetViewType(DAFAppTypes.API);
                }
            }
            else
            {
                State.ActiveDAFApp = null;
            }
        }
Exemple #29
0
        public virtual async Task SetupActivities(ApplicationManagerClient appMgr, string entApiKey)
        {
            var activitiesResp = await appMgr.LoadIDEActivities(entApiKey);

            if (activitiesResp.Status)
            {
                await SetupActivities(activitiesResp.Model, entApiKey);
            }
        }
Exemple #30
0
        public virtual async Task LoadDefaultApps(ApplicationManagerClient appMgr, string entApiKey)
        {
            var apps = await appMgr.ListDefaultApplications(entApiKey);

            State.DefaultApps = apps.Model;

            var defApps = await appMgr.HasDefaultApplications(entApiKey);

            State.DefaultAppsEnabled = defApps.Status;
        }
        public ActionResult DeleteTenant(string applicationName, string name)
        {
            Requires.ArgumentNotNullOrEmptyString(applicationName, "applicationName");
            Requires.ArgumentNotNullOrEmptyString(name, "name");

            var client = new ApplicationManagerClient();

            client.DeleteApplicationTenant(applicationName, name);
            return(RedirectToAction("Tenants", new { applicationName }));
        }
 public ActionResult Index()
 {
     ViewBag.Message = "Manage";
     var client = new ApplicationManagerClient();
     //client.CreateApplication("App1");
     //client.CreateApplication("App2");
     //client.CreateApplication("App3");
     //Thread.Sleep(1000);
     var applications = client.GetApplications();
     return View(applications);
 }
        public ActionResult Tenants(string applicationName, int startIndex = 0, int pageSize = 50)
        {
            var applicationTenantsModel = new ApplicationTenantsModel
            {
                ApplicationName = applicationName
            };

            var client = new ApplicationManagerClient();
            var query = new ApplicationTenantsQuery() { ApplicationName = applicationName, PageSize = pageSize, StartIndex = startIndex };
            var results = client.GetApplicationTenants(query);

            applicationTenantsModel.TotalCount = results.TotalCount;
            applicationTenantsModel.Tenants = results.Items ?? new ApplicationTenantHeaderInfo[]{};
            
            return View(applicationTenantsModel);
        }
 private TenantDetailsModel GetTenantDetailsModel(string applicationName, string name)
 {
     var tenantDetailsModel = default(TenantDetailsModel);
     var client = new ApplicationManagerClient();
     var headerInfo = client.GetTenantDetails(applicationName, name);
     if (headerInfo == null)
     {
         ModelState.AddModelError("TenantNotFound",
                                  string.Format("Tenant {0} in application {1} could not be found.", name,
                                                applicationName));
     }
     else
     {
         tenantDetailsModel = new TenantDetailsModel();
         tenantDetailsModel.ApplicationName = applicationName;
         tenantDetailsModel.Name = name;
         tenantDetailsModel.Url = headerInfo.Url;
         tenantDetailsModel.ContractStartTime = headerInfo.ContractStartedAt;
         tenantDetailsModel.IsActive = headerInfo.IsActive;
         tenantDetailsModel.Connections = client.GetDatabaseConfiguration(applicationName, name);
     }
     return tenantDetailsModel;
 }
        public ActionResult UpdateTenantDatabaseConfiguration(string applicationName, string name, DatabaseConfigurationInfo configurationInfo)
        {
            Requires.ArgumentNotNullOrEmptyString(applicationName, "applicationName");
            Requires.ArgumentNotNullOrEmptyString(name, "name");
            Requires.ArgumentNotNull(configurationInfo, "configurationInfo");
            Requires.ArgumentNotNull(configurationInfo.Name, "configurationInfo.Name");
            Requires.ArgumentNotNull(configurationInfo.ConnectionString, "configurationInfo.ConnectionString");

            var client = new ApplicationManagerClient();
            client.UpdateDatabaseConfiguration(applicationName, name, configurationInfo);
            return RedirectToAction("TenantDatabaseConfiguration", new { applicationName, name });
        }
        public ActionResult DeleteTenantDatabaseConfiguration(string applicationName, string name, string configurationname)
        {
            Requires.ArgumentNotNullOrEmptyString(applicationName, "applicationName");
            Requires.ArgumentNotNullOrEmptyString(name, "name");
            Requires.ArgumentNotNullOrEmptyString(configurationname, "configurationname");

            var client = new ApplicationManagerClient();
            client.RemoveDatabaseConfiguration(applicationName, name, configurationname);

            return RedirectToAction("TenantDatabaseConfiguration", new { applicationName, name });
        }
        public ActionResult Add(string name)
        {
            Requires.ArgumentNotNullOrEmptyString(name, "name");

            var client = new ApplicationManagerClient();
            client.CreateApplication(name);
            return RedirectToAction("Index", "Home");
        }
        public ActionResult AddTenant(string applicationName, string name, string url)
        {
            Requires.ArgumentNotNullOrEmptyString(applicationName, "applicationName");
            Requires.ArgumentNotNullOrEmptyString(name, "name");
            Requires.ArgumentNotNullOrEmptyString(url, "url");

            var client = new ApplicationManagerClient();
            client.AddApplicationTenant(applicationName, name, url);
            return RedirectToAction("Tenants", new { applicationName });
        }
 public ActionResult DeactivateTenant(string applicationName, string name)
 {
     var client = new ApplicationManagerClient();
     client.DeactivateTenant(applicationName, name);
     return RedirectToAction("Tenants", new { applicationName });
 }