Esempio n. 1
0
        public async Task Start(SearchRequest sr, SearchCallback <SearchStatus> statusCallback)
        {
            this.Callback = statusCallback;
            this.Request  = sr;
            this.Request.FilterListChanged += OnFilterListChanged;
            this.Request.SortingChanged    += OnSortOrderChanged;

            FakeHits = null;


            Pici.Log.debug(typeof(SearchSession), "searching:" + sr.SearchString);
            ID = await PP2_Init();

            if (ID > 0)
            {
                //run query if successfully initiated session
                try
                {
                    Callback.ThrowIfCancellationRequested();
                    //start session ping loop
                    Task pingTask = StartPingLoop();
                    //run request
                    await RunQuery(String.Format("searching {0}", sr.SearchString), true, true);
                }
                catch (OperationCanceledException)
                {
                    throw;
                }
                finally
                {
                    Pici.Log.info(typeof(SearchSession), "running initial search finished");
                }
            }
        }
Esempio n. 2
0
        private async Task <int> PP2_Init()
        {
            try
            {
                // create session
                Stream stream = await UrlHelper.GetInitUrl().GetStreamAsync();

                PazPar2Init pInit =
                    await
                    Async.DeserializeXml <PazPar2Init>(serializerPazPar2Init, stream,
                                                       Pazpar2Settings.LOG_HTTP_RESPONSES);

                Callback.ThrowIfCancellationRequested();
                return(pInit.Session);
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Pici.Log.error(typeof(SearchSession), "pazpar2 init error", ex);
                throw;
            }
        }