Ejemplo n.º 1
0
        public override FindRecordingResultList GetRecordingSearchResults(string SearchToken,
                                                                          int MinResults,
                                                                          bool MinResultsSpecified, int MaxResults, bool MaxResultsSpecified, string WaitTime)
        {
            RecordingSearchSession session =
                SearchSessionManager.Instance.GetSession(SearchToken) as RecordingSearchSession;

            if (session != null)
            {
                IList <RecordingInformation> data = (IList <RecordingInformation>)session.Data;

                // all data received
                if (data.Count == 0)
                {
                    CommonUtils.ReturnFault(new string[] { "Sender", "InvalidArgVal", "InvalidToken" });
                    return(null);
                }

                FindRecordingResultList list = new FindRecordingResultList();

                Random rnd = new Random();
                int    cnt = Math.Min(rnd.Next(1, 4), data.Count);

                rnd = new Random();
                int sleep = rnd.Next(1, 3);
                System.Threading.Thread.Sleep(400 * sleep + 450);

                list.RecordingInformation = new RecordingInformation[cnt];
                for (int i = 0; i < cnt; i++)
                {
                    list.RecordingInformation[i] = data[0];
                    data.RemoveAt(0);
                }
                session.ResultsSent = session.ResultsSent + cnt;
                list.SearchState    = data.Count > 0 ? SearchState.Searching : SearchState.Completed;

                if (data.Count == 0)
                {
                    SearchSessionManager.Instance.Sessions.Remove(session);
                }
                return(list);
            }
            else
            {
                CommonUtils.ReturnFault(new string[] { "Sender", "InvalidArgVal", "InvalidToken" });
                return(null);
            }
        }
Ejemplo n.º 2
0
        public override string FindRecordings(SearchScope Scope, int MaxMatches, bool MaxMatchesSpecified, string KeepAliveTime)
        {
            string token = SearchSessionManager.Instance.GetNextToken();

            int    keepAliveTime = 0;
            string strKeepAlive  = KeepAliveTime.Substring(2, KeepAliveTime.Length - 3);

            keepAliveTime = int.Parse(strKeepAlive);
            if (KeepAliveTime.EndsWith("M"))
            {
                keepAliveTime = keepAliveTime * 60;
            }

            RecordingSearchSession session = new RecordingSearchSession()
            {
                KeepAlive   = keepAliveTime,
                Token       = token,
                Started     = System.DateTime.Now,
                LastRequest = System.DateTime.Now
            };

            //SearchStorage.Instance.ClearRecordings();
            //SearchStorage.Instance.ChangeRecordingsGeneration();

            List <RecordingInformation> filtered;

            if (Scope != null)
            {
                string filter = Scope.RecordingInformationFilter;

                if (filter.Contains("Video"))
                {
                    filtered =
                        SearchStorage.Instance.Recordings.Where(
                            R => R.Track.Where(T => T.TrackType == Search.TrackType.Video).Count() > 0).ToList();
                }
                else if (filter.Contains("Audio"))
                {
                    filtered =
                        SearchStorage.Instance.Recordings.Where(
                            R => R.Track.Where(T => T.TrackType == Search.TrackType.Audio).Count() > 0).ToList();
                }
                else if (filter.Contains("Metadata"))
                {
                    filtered =
                        SearchStorage.Instance.Recordings.Where(
                            R => R.Track.Where(T => T.TrackType == Search.TrackType.Metadata).Count() > 0).ToList();
                }
                else
                {
                    filtered = SearchStorage.Instance.Recordings;
                }
            }
            else
            {
                filtered = SearchStorage.Instance.Recordings;
            }


            List <RecordingInformation> list;

            if (MaxMatchesSpecified)
            {
                list = new List <RecordingInformation>();
                for (int i = 0; i < Math.Min(MaxMatches, filtered.Count); i++)
                {
                    list.Add(SearchStorage.Instance.Recordings[i]);
                }
            }
            else
            {
                list = new List <RecordingInformation>(filtered);
            }
            session.Data = list;

            SearchSessionManager.Instance.Sessions.Add(session);
            return(token);
        }