Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public virtual async Task <LCUAppsState> LoadDAFApps(List <DAFApplicationConfiguration> dafApps = null)
        {
            if (dafApps.IsNullOrEmpty())
            {
                var dafAppsResponse = await appMgr.ListDAFApplications(details.EnterpriseAPIKey, state.ActiveApp.ID);

                state.ActiveDAFApps = dafAppsResponse.Model;
            }
            else
            {
                state.ActiveDAFApps = dafApps;
            }

            if (state.ActiveDAFApps.IsNullOrEmpty())
            {
                state.ActiveDAFApps = new List <DAFApplicationConfiguration>()
                {
                    new DAFApplicationConfiguration()
                }
            }
            ;

            if (state.ActiveDAFApps.Any(da => !da.ID.IsEmpty()))
            {
                state.ActiveAppType = state.ActiveDAFApps.Any(da => da.Metadata.ContainsKey("APIRoot")) ? "API" : "View";
            }
            else
            {
                state.ActiveAppType = null;
            }

            return(state);
        }
Exemplo n.º 3
0
        public virtual async Task <ConfigManagerState> LoadAppView()
        {
            if (state.ActiveApp != null)
            {
                var apps = await appMgr.ListDAFApplications(details.EnterpriseAPIKey, state.ActiveApp.ID);

                state.ActiveDAFApp = apps?.Model?.FirstOrDefault()?.JSONConvert <DAFApplicationConfiguration>();

                if (state.ActiveDAFApp.Metadata.ContainsKey("APIRoot"))
                {
                    await SetViewType(DAFAppTypes.API);
                }
                else if (state.ActiveDAFApp.Metadata.ContainsKey("Redirect"))
                {
                    await SetViewType(DAFAppTypes.Redirect);
                }
                else if (state.ActiveDAFApp.Metadata.ContainsKey("BaseHref"))
                {
                    await SetViewType(DAFAppTypes.View);
                }
            }
            else
            {
                state.ActiveDAFApp = null;
            }

            return(state);
        }
        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;
            }
        }
        public virtual async Task LoadDAFAppOptions(ApplicationManagerClient appMgr, string entLookup)
        {
            State.DAFAppOptions = new Dictionary <string, string>();

            if (!State.Applications.IsNullOrEmpty())
            {
                await State.Applications.Each(async app =>
                {
                    var dafApps = await appMgr.ListDAFApplications(entLookup, app.ID);

                    dafApps.Model.Each(dafApp => State.DAFAppOptions[dafApp.ID.ToString()] = $"{app.Name} {dafApp.Lookup}");
                });
            }
        }