Exemplo n.º 1
0
        private void FireOffSearch(IGrouping <string, parseResult> newSeries, DataGridViewRow row, string customString)
        {
            string toSearch = string.IsNullOrEmpty(customString) ? newSeries.Key : customString;

            if (lastSearch.ContainsKey(row.Index))
            {
                lastSearch[row.Index] = toSearch;
            }
            else
            {
                lastSearch.Add(row.Index, toSearch);
            }

            System.Threading.Interlocked.Increment(ref queuedSearches);
            setSearchStatus();

            int iThreadCount = Environment.ProcessorCount;

            if (iThreadCount < 8)
            {
                iThreadCount = 8;
            }
            System.Threading.ThreadPool.SetMaxThreads(iThreadCount, iThreadCount);

            System.Threading.ThreadPool.QueueUserWorkItem((o) =>
            {
                // tell user we are now searching
                SearchProgress(cSearching, null, row);
                GetSeries gs = new GetSeries(toSearch);
                // and give the results
                SearchProgress(toSearch, gs, row);
            });
        }
Exemplo n.º 2
0
        private void SearchProgress(string searchString, GetSeries searchResult, DataGridViewRow row)
        {
            // we need to invoke
            if (this.dataGridViewIdentifySeries.InvokeRequired)
            {
                this.dataGridViewIdentifySeries.Invoke(new SearchProgressDelegate(SearchProgress), searchString, searchResult, row);
                return;
            }

            // lets update the combobox
            var comboCell = new DataGridViewComboBoxCell();

            row.Cells[ColIndexOf(colOSeries)] = comboCell;

            // ok, if we only get a string and the row, display that string
            if (searchResult == null)
            {
                displayValsInCBCell(comboCell, searchString);

                // this also means that a queued search went into active status
                System.Threading.Interlocked.Decrement(ref queuedSearches);
                System.Threading.Interlocked.Increment(ref activeSearches);
                setSearchStatus();
                return;
            }

            // else we got the results
            comboCell.Tag = searchResult.Results;

            // which also means an active search has finished
            System.Threading.Interlocked.Decrement(ref activeSearches);
            setSearchStatus();

            displayValsInCBCell(comboCell, searchResult.Results.Select(r => getDisplayStringForSeries(r)).ToArray());

            if (comboCell.Items.Count < 1)
            {
                displayValsInCBCell(comboCell, "No Results found");
            }

            var actionCell = row.Cells[ColIndexOf(colAction)] as DataGridViewComboBoxCell;

            // overwrite from the cellchanged event which set it to approved
            if (searchResult.PerfectMatch == null)
            {
                actionCell.Value = displayedActions[UserInputResults.SeriesAction.Skip];
            }
        }
Exemplo n.º 3
0
        private void SearchProgress(string searchString, GetSeries searchResult, DataGridViewRow row)
        {            
            // we need to invoke
            if (this.dataGridViewIdentifySeries.InvokeRequired)
            {                
                this.dataGridViewIdentifySeries.Invoke(new SearchProgressDelegate(SearchProgress), searchString, searchResult, row);
                return;
            }
            
            // lets update the combobox
            var comboCell = new DataGridViewComboBoxCell();
            row.Cells[ColIndexOf(colOSeries)] = comboCell;

            // ok, if we only get a string and the row, display that string
            if (searchResult == null)
            {
                displayValsInCBCell(comboCell, searchString);

                // this also means that a queued search went into active status
                System.Threading.Interlocked.Decrement(ref queuedSearches);
                System.Threading.Interlocked.Increment(ref activeSearches);
                setSearchStatus();
                return;
            }

            // else we got the results                        
            comboCell.Tag = searchResult.Results;

            // which also means an active search has finished
            System.Threading.Interlocked.Decrement(ref activeSearches);
            setSearchStatus();

            displayValsInCBCell(comboCell, searchResult.Results.Select(r => getDisplayStringForSeries(r)).ToArray());

            if (comboCell.Items.Count < 1)
                displayValsInCBCell(comboCell, "No Results found");

            var actionCell = row.Cells[ColIndexOf(colAction)] as DataGridViewComboBoxCell;

            // overwrite from the cellchanged event which set it to approved
            if (searchResult.PerfectMatch == null)
                actionCell.Value = displayedActions[UserInputResults.SeriesAction.Skip];

        }
Exemplo n.º 4
0
 public ISeriesModel Any(GetSeries request)
 {
     return(workflow.Get(request.ID));
 }
Exemplo n.º 5
0
        private void FireOffSearch(IGrouping<string, parseResult> newSeries, DataGridViewRow row, string customString)
        {
            string toSearch = string.IsNullOrEmpty(customString) ? newSeries.Key : customString;
            if(lastSearch.ContainsKey(row.Index))
                lastSearch[row.Index] = toSearch;
            else lastSearch.Add(row.Index, toSearch);
                        
            System.Threading.Interlocked.Increment(ref queuedSearches);
            setSearchStatus();

            int iThreadCount = Environment.ProcessorCount;
            if (iThreadCount < 8) iThreadCount = 8;
            System.Threading.ThreadPool.SetMaxThreads(iThreadCount, iThreadCount);            

            System.Threading.ThreadPool.QueueUserWorkItem((o) =>
                {
                    // tell user we are now searching
                    SearchProgress(cSearching, null, row);
                    GetSeries gs = new GetSeries(toSearch);
                    // and give the results
                    SearchProgress(toSearch, gs, row);
                });
            
        }