Ejemplo n.º 1
0
        public static async Task <HubScriptItem> GetScriptFromHub(string Id, string Token)
        {
            SHSearchLoader SHLoader          = new SHSearchLoader("uuid: " + Id, new string[] { Token });
            IEnumerable <HubScriptItem> HSIs = await SHLoader.NextPage(1);

            return(HSIs.FirstOrDefault());
        }
Ejemplo n.º 2
0
        private async void GotoScriptDetail(object sender, ItemClickEventArgs e)
        {
            GrantProcess GProc = ( GrantProcess )e.ClickedItem;

            if (GProc.GrantDef.SourceRemoved || GProc.IsLoading)
            {
                return;
            }

            GProc.IsLoading = true;
            string AccessToken = ( string )TokMgr.GetAuthById(GProc.ScriptId)?.Value;

            SHSearchLoader SHLoader = new SHSearchLoader(
                "uuid: " + GProc.ScriptId
                , AccessToken == null ? null : new string[] { AccessToken }
                );

            IList <HubScriptItem> HSIs = await SHLoader.NextPage();

            HubScriptItem HSI = HSIs.FirstOrDefault();

            if (HSI != null)
            {
                ControlFrame.Instance.NavigateTo(PageId.SCRIPT_DETAILS, () => {
                    ScriptDetails SDetails = new ScriptDetails(HSI);
                    SDetails.OpenRequest(GProc.Target);
                    return(SDetails);
                });
            }
        }
Ejemplo n.º 3
0
        public async void Resolve(string uuid, Action <string> DisplayName)
        {
            if (!Guid.TryParse(uuid, out Guid NOP_0))
            {
                return;
            }

            ReadCache();

            // Find zone name from cache
            if (ZoneMap.ContainsKey(uuid))
            {
                DisplayName(ZoneMap[uuid]);
                return;
            }

            if (ResolvQs.TryGetValue(uuid, out ConcurrentQueue <Action <string> > RQ))
            {
                RQ.Enqueue(DisplayName);
                return;
            }
            else
            {
                ResolvQs.TryAdd(uuid, new ConcurrentQueue <Action <string> >());
            }

            // Find zone name from online directory
            IEnumerable <string> AccessTokens = new TokenManager().AuthList.Remap(x => ( string )x.Value);
            SHSearchLoader       SHSL         = new SHSearchLoader("uuid: " + uuid, AccessTokens);

            IList <HubScriptItem> HSIs = await SHSL.NextPage();

            if (HSIs.Any())
            {
                string ZName = HSIs.First().Name;
                DisplayName(ZName);
                ZoneMap[uuid] = ZName;

                Shared.ZCacheDb.Write(CacheId, ZoneMap.Data);

                if (ResolvQs.TryRemove(uuid, out ConcurrentQueue <Action <string> > ResolvQ))
                {
                    while (ResolvQ.TryDequeue(out Action <string> Resolved))
                    {
                        Resolved(ZName);
                    }
                }
            }
            else
            {
                // Drop the entire waiting queue as we cannot resolve the name
                ResolvQs.TryRemove(uuid, out ConcurrentQueue <Action <string> > NOP_1);
            }
        }
Ejemplo n.º 4
0
        private async Task<HubScriptItem> LoadFromSHHub( string Id, string Token )
        {
            SHSearchLoader SHLoader = new SHSearchLoader( "uuid: " + Id, new string[] { Token } );
            IEnumerable<HubScriptItem> HSIs = await SHLoader.NextPage( 1 );

            return HSIs.FirstOrDefault();
        }
Ejemplo n.º 5
0
        public async void Search( string Query, IEnumerable<string> AccessTokens = null )
        {
            if ( AccessTokens == null )
                AccessTokens = new TokenManager().AuthList.Remap( x => ( string ) x.Value );

            Searching = true;
            SHSearchLoader SHLoader = new SHSearchLoader( Query, AccessTokens );

            SearchSet.ConnectLoader( SHLoader );
            SearchSet.UpdateSource( await SHLoader.NextPage() );

            Searching = false;
        }