Beispiel #1
0
        /// <param name="targetTable"> target table or view</param>
        /// <returns></returns>
        private SearchJob BuildSearchJob(string targetTable)
        {
            const int IndexCacheCount = 3;

            SearchJob search = new SearchJob();

            BuildIndexRoot();

            string indexPath = _indexDir;

            if (string.IsNullOrEmpty(indexPath))
            {
                indexPath = BuildIndexPath(targetTable);
            }

            if (!IndexExists(indexPath))
            {
                throw new Exception("Invalid index path: " + indexPath);
            }

            search.IndexesToSearch.Add(indexPath);
            search.SearchFlags        = search.SearchFlags | SearchFlags.dtsSearchDelayDocInfo;
            search.MaxFilesToRetrieve = _maxHitCount;

            if (_enableDtIndexCache)
            {
                if (_cache == null)
                {
                    _cache = new IndexCache(IndexCacheCount);
                }
                search.SetIndexCache(_cache);
            }

            return(search);
        }
Beispiel #2
0
        private void Save()
        {
            var searchJob = new SearchJob()
            {
                SearchDate = DateTime.Now
            };
            var requiredComplexeKeywords = _jhDbContext.Keywords.ToList().Where(x => x.IsComplexe || x.IsRequired).ToList();

            Result = Result.Where(x => x.Value.GetRequiredMatches(requiredComplexeKeywords).Count > 0).ToDictionary(x => x.Key, x => x.Value);

            CurrentCachedUrls.ForEach(x => x.SearchJob = searchJob);
            _jhDbContext.SearchJobs.Add(searchJob);
            _jhDbContext.ResultEntities.AddRange(Result.Select(x => new ResultEntity()
            {
                Description = x.Value.Description,
                Path        = x.Key,
                Provider    = x.Value.Provider,
                PublishDate = x.Value.PublishDate,
                Publisher   = x.Value.Publisher,
                RefUrl      = x.Value.RefUrl,
                SearchJob   = searchJob,
                Title       = x.Value.Title,
            }));
            _jhDbContext.CachedUrls.AddRange(CurrentCachedUrls);
            _jhDbContext.SaveChanges();
        }
Beispiel #3
0
        private void Enqueue(SearchJob job)
        {
            var host = job.Link.Uri.Host;

            lock (_LockFoundHostNames)
            {
                if (_foundHostNames.Contains(host))
                {
                    return;
                }
            }

            var prio        = _priority.GetPrio(job);
            var absoluteUri = job.Link.Uri.AbsoluteUri;

            if (prio > _Threshold)
            {
                return;
            }

            lock (_LockVisited)
            {
                if (_visited.Contains(absoluteUri))
                {
                    return;
                }

                _visited.Add(absoluteUri);
                _queue.Enqueue(job, prio);
            }
        }
Beispiel #4
0
        public async Task Multiple_matches_are_found()
        {
            var searched = "Lorem";

            var text =
                @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Etiam egestas leo urna, vel mollis urna sollicitudin non. 
Nam in orci ante. Praesent dapibus id purus sit amet molestie.
Maecenas erat ex, tempus vitae consectetur et, ullamcorper eget nibh. Nulla facilisi. 
Phasellus nec bibendum lorem. ALoremliquam ac est vitae neque placerat sollicitudin vitae nec odio. 
Aliquam cursus arcu quis magna feugiat, eget consectetur lorem accumsan.
Nam nibh est, aliquam eget ante ac, lacinia sceleLoremrisque eros. Phasellus commodo massa lacus. 
Ut aliquet fermentum tortor at egestas. Aliquam erat leo, auctor ut luctus sed,
aliquam id ligula. Cras eleifend sapien et tellus maximus, in fermentum leo
consectetur.Sed volutpat augue porttitor odLoremio dictum, et semper nisi tempor.
Quisque at aliquam turpis. Duis molestie lacus vitae eros tempor vehicula. ";

            var offsets = new List <int>()
            {
                0, 302, 496, 748
            };
            var offsetsResult = new List <int>()
            {
            };
            var          document = new TextDocument(text);
            var          token    = new CancellationToken();
            Action <int> onFound  = (int offset) => offsetsResult.Add(offset);
            var          sut      = new SearchJob(document.CreateReader(), searched, onFound);

            await sut.RunAsync(token);

            CollectionAssert.AreEquivalent(offsets, offsetsResult);
        }
        protected override void OnUpdate(ref JobHandle jobHandle)
        {
            if (Query == null)
            {
                return;
            }

            if (CurrentUpdateType == ModuleUpdateType.Job)
            {
                jobHandle = new ClearJob
                {
                    HashMap        = m_OwnerToAbilityMap,
                    TargetCapacity = Query.CalculateEntityCount() + 32
                }.Schedule(jobHandle);
                jobHandle = new SearchJob
                {
                    OwnerToAbilityMap = m_OwnerToAbilityMap.AsParallelWriter()
                }.Schedule(Query, jobHandle);
            }
            else
            {
                new ClearJob
                {
                    HashMap        = m_OwnerToAbilityMap,
                    TargetCapacity = Query.CalculateEntityCount() + 32
                }.Run();
                new SearchJob
                {
                    OwnerToAbilityMap = m_OwnerToAbilityMap.AsParallelWriter()
                }.Run(Query);
            }
        }
Beispiel #6
0
        public ActionResult GetList(SearchJob filter, int index, int count)
        {
            filter.IsOnlyRecruiting = true;
            var result = JobLogic.GetList(filter, index, count);

            return(Json(result));
        }
        public static SearchResults GetPortalSearchWikiResults(string searchTerm, LoginUser loginUser, int parentOrgID)
        {
            Options options = new Options();

            options.TextFlags = TextFlags.dtsoTfRecognizeDates;
            using (SearchJob job = new SearchJob())
            {
                StringBuilder conditions = new StringBuilder();
                conditions.Append(" ((PortalView::True) AND (IsDeleted::false))");

                job.Request           = searchTerm;
                job.FieldWeights      = "ArticleName: 1000";
                job.BooleanConditions = conditions.ToString();
                job.TimeoutSeconds    = 30;
                job.SearchFlags       = SearchFlags.dtsSearchDelayDocInfo;

                int num = 0;
                if (!int.TryParse(searchTerm, out num))
                {
                    job.SearchFlags = job.SearchFlags |
                                      SearchFlags.dtsSearchPositionalScoring |
                                      SearchFlags.dtsSearchAutoTermWeight;
                }

                if (searchTerm.ToLower().IndexOf(" and ") < 0 && searchTerm.ToLower().IndexOf(" or ") < 0)
                {
                    job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchTypeAllWords;
                }
                job.IndexesToSearch.Add(DataUtils.GetPortalWikiIndexPath(loginUser, parentOrgID));
                job.Execute();

                return(job.Results);
            }
        }
Beispiel #8
0
        public async Task Text_is_not_found_if_no_match_found(string text, string searched)
        {
            var          offsets  = new List <int>();
            var          document = new TextDocument(text);
            var          token    = new CancellationToken();
            Action <int> onFound  = (int offset) => offsets.Add(offset);
            var          sut      = new SearchJob(document.CreateReader(), searched, onFound);

            await sut.RunAsync(token);

            Assert.AreEqual(0, offsets.Count);
        }
Beispiel #9
0
        public List <ResultModel> Search(string txt, string option)
        {
            List <ResultModel> lst = new List <ResultModel>();

            SearchJob sj1 = new SearchJob();

            sj1.BooleanConditions = txt;
            string[] ddlist;
            ddlist = Directory.GetDirectories(@"C:\Users\meharr\AppData\Local\dtSearch");
            sj1.IndexesToSearch.AddRange(ddlist);
            sj1.MaxFilesToRetrieve = 100;
            if (option == "stemming")
            {
                sj1.SearchFlags = SearchFlags.dtsSearchStemming;
            }
            else if (option == "phonic")
            {
                sj1.SearchFlags = SearchFlags.dtsSearchPhonic;
            }
            else if (option == "fuzzy")
            {
                sj1.Fuzziness   = 5;
                sj1.SearchFlags = SearchFlags.dtsSearchFuzzy;
            }
            sj1.Execute();

            SearchResults result = sj1.Results;

            for (int i = 0; i < result.Count; i++)
            {
                var tile = HighlightResult(i, result);
                int len  = tile.Length;
                int ind  = tile.IndexOf("Filename");
                tile = tile.Remove(ind, Math.Abs(ind - len));
                result.GetNthDoc(i);
                SearchResultsItem item = result.CurrentItem;

                ResultModel mod = new ResultModel();
                mod.DisplayName = item.DisplayName;
                mod.FileName    = item.Filename;
                mod.Title       = tile;
                mod.HitCount    = item.HitCount;
                lst.Add(mod);
            }
            return(lst);
        }
Beispiel #10
0
        private void DoSearch(string searchRequest, QueryResult result)
        {
            Debug.Assert(result.HitCount == 0);

            SearchJob search = BuildSearchJob(result.SourceTable);

            search.Request = searchRequest;

            _logger.DTSearchStarted(result.SourceTable, search.Request);
            {
                search.Execute();
                result.HitCount = search.Results.Count;

                ProcessResults(result, search.Results);
            }
            _logger.DTSearchStopped(result.SourceTable, result.ResultTable, result.HitCount);
        }
        public static SearchResults GetSearchNotesResults(string searchTerm, LoginUser loginUser)
        {
            Options options = new Options();

            options.TextFlags = TextFlags.dtsoTfRecognizeDates;
            using (SearchJob job = new SearchJob())
            {
                searchTerm       = searchTerm.Trim();
                job.Request      = searchTerm;
                job.FieldWeights = "Title: 1000";

                //StringBuilder conditions = new StringBuilder();
                //job.BooleanConditions = conditions.ToString();


                //job.MaxFilesToRetrieve = 1000;
                //job.AutoStopLimit = 1000000;
                job.TimeoutSeconds = 30;
                job.SearchFlags    =
                    //SearchFlags.dtsSearchSelectMostRecent |
                    SearchFlags.dtsSearchDelayDocInfo;

                int num = 0;
                if (!int.TryParse(searchTerm, out num))
                {
                    //job.Fuzziness = 1;
                    job.SearchFlags = job.SearchFlags |
                                      //SearchFlags.dtsSearchFuzzy |
                                      //SearchFlags.dtsSearchStemming |
                                      SearchFlags.dtsSearchPositionalScoring |
                                      SearchFlags.dtsSearchAutoTermWeight;
                }

                if (searchTerm.ToLower().IndexOf(" and ") < 0 && searchTerm.ToLower().IndexOf(" or ") < 0)
                {
                    job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchTypeAllWords;
                }
                job.IndexesToSearch.Add(DataUtils.GetNotesIndexPath(loginUser));
                job.Execute();

                return(job.Results);
            }
        }
Beispiel #12
0
        protected override void ProcessRecord()
        {
            try
            {
                WriteVerbose(pass);
                WriteVerbose("Query: " + query);

                SplunkConnection con = new SplunkConnection(serverUrl);
                if (login.StartsWith("\\"))
                {
                    login = login.Substring(1);
                }
                string sessionKey = con.Authenticate(login, pass);

                WriteVerbose("SessionKey: " + sessionKey);

                SearchManager searchManager = new SearchManager(con);
//                searchManager.ControlAllJobs(JobAction.CANCEL);

                SearchJob job = searchManager.SyncSearch(query, null);

                WriteVerbose("Job ID: " + job.Id);

                EventParameters ep = new EventParameters();

                if (fields != null && fields.Length > 0)
                {
                    ep.FieldList = fields;
                }

                DataTable dt = job.GetEventsTable(ep);

                WriteObject(dt);

                job.Cancel();
            }
            catch (Exception e)
            {
                WriteObject(e.Message);
            }
        }
Beispiel #13
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            SearchJob mySJob = null;
            string cnnstr = connectionString;
            string JobDescription = null;
            string customer = null;
            string customerTerms = null;
            string PONumber = "";

            try
            {

                dgvShipments.Columns.Clear();
                dgvItm.Columns.Clear();

                mySJob = new SearchJob(cnnstr);
                mySJob.getJobData(this.txtJobNum.Text.Trim(),
                                   ref JobDescription,
                                   ref customer,
                                   ref customerTerms, ref PONumber, dgvShipments
                                   );

                this.txtJobDes.Text = JobDescription;
                this.txtCustomer.Text = customer;
                this.txtCustomerTems.Text = customerTerms;
                this.txtCustomerPONum.Text  = PONumber;

                mySJob.getitem(txtJobNum.Text, myRowIndex, dgvItm);
                dgvShipments.Rows[0].Selected = true;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                mySJob = null;
            }
        }
Beispiel #14
0
        public int GetPrio(SearchJob job)
        {
            if (LinkChecker.ImpressumChecker.IsRelevant(job.Link))
            {
                return(1); // top prio
            }
            var url = job.Link.Uri;

            var host       = url.Host;
            var depth      = job.CurrentDepth;
            var maxDepth   = job.MaxDepth;
            var isDeDomain = host.EndsWith(".de");

            if (!isDeDomain)
            {
                return(500000);
            }


            double factor = (maxDepth + 1.0) / (depth + 1.0);

            return(_readerWriterLock.ExecuteInUpgradeableReaderLock(() =>
            {
                if (_visitedHosts.Contains(host))
                {
                    return (int)Math.Ceiling(100 * factor);
                }
                else
                {
                    return _readerWriterLock.ExecuteInWriterLock(() =>
                    {
                        _visitedHosts.Add(host);
                        return (int)Math.Ceiling(10 * factor);
                    });
                }
            }));
        }
Beispiel #15
0
        public async Task FindInDocument(TextReader source, string phrase, SearchModeEnum mode, CancellationToken token, Action <int> onOffsetFound)
        {
            var dispatcher = Dispatcher.CurrentDispatcher;

            Action <int> onOffsetFoundUI = (int offset) =>
            {
                dispatcher.Invoke(onOffsetFound, offset); // Invoked on UI thread
            };

            switch (mode)
            {
            case SearchModeEnum.Default:
                var job = new SearchJob(source, phrase, onOffsetFoundUI);
                await JobRunner.Run(job, token);

                break;

            case SearchModeEnum.Regex:
                break;

            default:
                break;
            }
        }
Beispiel #16
0
 private void dgvShipments_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     SearchJob mySJob = null;
     try
     {
         mySJob = new SearchJob(connectionString);
         myRowIndex = dgvShipments.Rows[e.RowIndex].Cells[0].Value.ToString();
         mySJob.getitem(txtJobNum.Text, dgvShipments.Rows[e.RowIndex].Cells[0].Value.ToString(), dgvItm);
         mySJob.Dispose();
     }
     catch
     {
         //MessageBox.Show(ex.ToString());
     }
     finally
     {
         mySJob = null;
     }
 }
Beispiel #17
0
        private void DoSearch()
        {
            if (radioButton_selected.Checked && SelectedItems == null)
            {
                return;
            }

            button_seach.Enabled      = false;
            button_cancel.Enabled     = true;
            button_showresult.Enabled = false;

            var typeAll    = radioButton_typeAll.Checked;
            var typeFolder = radioButton_typeFolder.Checked;
            var typeFile   = radioButton_typeFile.Checked;

            var selectall  = radioButton_SearchAll.Checked;
            var selectitem = radioButton_selected.Checked;
            var selecttree = radioButton_SerachFolder.Checked;
            var treepath   = textBox_SearchFolder.Text;

            var searchStr = comboBox_name.Text;

            var strstarts  = radioButton_startswith.Checked;
            var strends    = radioButton_endswith.Checked;
            var strcontain = radioButton_contain.Checked;

            var strregex = checkBox_regex.Checked;
            var strcase  = checkBox_case.Checked;

            var SizeOver  = checkBox_Over.Checked;
            var SizeUnder = checkBox_Under.Checked;
            var Over      = numericUpDown_over.Value;
            var Under     = numericUpDown_under.Value;

            var modifiedFromEnable = dateTimePicker_modifiedFrom.Checked;
            var modifiedToEnable   = dateTimePicker_modifiedTo.Checked;
            var createdFromEnable  = dateTimePicker_createdFrom.Checked;
            var createdToEnable    = dateTimePicker_createdTo.Checked;
            var modifiedFrom       = dateTimePicker_modifiedFrom.Value;
            var modifiedTo         = dateTimePicker_modifiedTo.Value;
            var createdFrom        = dateTimePicker_createdFrom.Value;
            var createdTo          = dateTimePicker_createdTo.Value;

            progressBar1.Style = ProgressBarStyle.Marquee;
            label_result.Text  = "wait for system...";

            SearchJob?.Cancel();
            SearchJob             = JobControler.CreateNewJob();
            SearchJob.DisplayName = "Search";
            JobControler.Run(SearchJob, (j) =>
            {
                j.ProgressStr = "Create index...";
                j.Progress    = -1;

                TSviewCloudConfig.Config.Log.LogOut("[Search] start");
                var sw = new System.Diagnostics.Stopwatch();
                try
                {
                    List <IRemoteItem> initselection = new List <IRemoteItem>();
                    List <IRemoteItem> selection     = new List <IRemoteItem>();

                    if (selectall)
                    {
                        initselection.AddRange(RemoteServerFactory.ServerList.Values.Select(x => x[""]));
                    }
                    if (selectitem)
                    {
                        initselection.AddRange(SelectedItems);
                    }
                    if (selecttree)
                    {
                        initselection.Add(RemoteServerFactory.PathToItem(treepath).Result);
                    }

                    synchronizationContext.Post((o) =>
                    {
                        label_result.Text = o as string;
                    }, "Prepare items...");

                    TSviewCloudConfig.Config.Log.LogOut("[Search] Create index");
                    sw.Start();

                    Parallel.ForEach(
                        initselection,
                        new ParallelOptions {
                        MaxDegreeOfParallelism = Convert.ToInt32(Math.Ceiling((Environment.ProcessorCount * 0.75) * 1.0))
                    },
                        () => new List <IRemoteItem>(),
                        (x, state, local) =>
                    {
                        if (x == null)
                        {
                            return(local);
                        }
                        var item = RemoteServerFactory.PathToItem(x.FullPath).Result;
                        if (item == null)
                        {
                            return(local);
                        }

                        local.AddRange(GetItems(item));
                        return(local);
                    },
                        (result) =>
                    {
                        lock (selection)
                            selection.AddRange(result);
                    }
                        );

                    synchronizationContext.Post((o) =>
                    {
                        label_result.Text = o as string;
                    }, "Prepare items done.");
                    sw.Stop();
                    var itemsearch_time = sw.Elapsed;



                    var search = selection.AsParallel();

                    if (typeFile)
                    {
                        search = search.Where(x => x.ItemType == RemoteItemType.File);
                    }
                    if (typeFolder)
                    {
                        search = search.Where(x => x.ItemType == RemoteItemType.Folder);
                    }


                    if (strregex)
                    {
                        if (!strcase)
                        {
                            search = search.Where(x => Regex.IsMatch(x.Name ?? "", searchStr));
                        }
                        else
                        {
                            search = search.Where(x => Regex.IsMatch(x.Name ?? "", searchStr, RegexOptions.IgnoreCase));
                        }
                    }
                    else
                    {
                        if (!strcase)
                        {
                            if (strstarts)
                            {
                                search = search.Where(x => (x.Name?.StartsWith(searchStr) ?? searchStr == ""));
                            }
                            if (strends)
                            {
                                search = search.Where(x => (x.Name?.EndsWith(searchStr) ?? searchStr == ""));
                            }
                            if (strcontain)
                            {
                                search = search.Where(x => (x.Name?.IndexOf(searchStr) >= 0));
                            }
                        }
                        else
                        {
                            search = search.Where(x => (
                                                      System.Globalization.CultureInfo.CurrentCulture.CompareInfo.IndexOf(
                                                          x.Name ?? "",
                                                          searchStr,
                                                          System.Globalization.CompareOptions.IgnoreCase | System.Globalization.CompareOptions.IgnoreKanaType | System.Globalization.CompareOptions.IgnoreWidth
                                                          | System.Globalization.CompareOptions.IgnoreNonSpace | System.Globalization.CompareOptions.IgnoreSymbols
                                                          ) >= 0));
                        }
                    }

                    if (SizeOver)
                    {
                        search = search.Where(x => (x.Size ?? 0) > Over);
                    }
                    if (SizeUnder)
                    {
                        search = search.Where(x => (x.Size ?? 0) < Under);
                    }


                    if (modifiedFromEnable)
                    {
                        search = search.Where(x => x.ModifiedDate > modifiedFrom);
                    }
                    if (modifiedToEnable)
                    {
                        search = search.Where(x => x.ModifiedDate < modifiedTo);
                    }

                    if (createdFromEnable)
                    {
                        search = search.Where(x => x.CreatedDate > createdFrom);
                    }
                    if (createdToEnable)
                    {
                        search = search.Where(x => x.CreatedDate < createdTo);
                    }

                    synchronizationContext.Post((o) =>
                    {
                        label_result.Text = o as string;
                    }, "Search...");
                    j.ProgressStr = "Search...";

                    TSviewCloudConfig.Config.Log.LogOut("[Search] Search");
                    sw.Restart();

                    SearchResult = search.ToArray();

                    sw.Stop();
                    var filteritem_time = sw.Elapsed;

                    j.Progress    = 1;
                    j.ProgressStr = "Found : " + SearchResult.Count().ToString();

                    synchronizationContext.Post((o) =>
                    {
                        label_result.Text         = o as string;
                        button_seach.Enabled      = true;
                        button_cancel.Enabled     = false;
                        button_showresult.Enabled = true;
                        progressBar1.Style        = ProgressBarStyle.Continuous;
                        SearchJob = null;
                    }, string.Format("Found : {0}, Index {1} search {2}", SearchResult.Count(), itemsearch_time, filteritem_time));

                    TSviewCloudConfig.Config.Log.LogOut("[Search] found " + SearchResult.Count().ToString());
                }
                catch
                {
                    TSviewCloudConfig.Config.Log.LogOut("[Search] Abort");

                    synchronizationContext.Post((o) =>
                    {
                        label_result.Text     = "abort";
                        button_seach.Enabled  = true;
                        button_cancel.Enabled = false;
                        progressBar1.Style    = ProgressBarStyle.Continuous;
                        SearchJob             = null;
                    }, null);
                }
            });
        }
Beispiel #18
0
        public RadComboBoxItemData[] GetKBTicketByDescription(RadComboBoxContext context)
        {
            Options options = new Options();

            options.TextFlags = TextFlags.dtsoTfRecognizeDates;

            using (SearchJob job = new SearchJob())
            {
                string searchTerm = context["FilterString"].ToString().Trim();
                job.Request            = searchTerm;
                job.FieldWeights       = "TicketNumber: 5000, Name: 1000";
                job.BooleanConditions  = "(OrganizationID::" + TSAuthentication.OrganizationID.ToString() + ") AND (IsKnowledgeBase::True)";
                job.MaxFilesToRetrieve = 25;
                job.AutoStopLimit      = 100000;
                job.TimeoutSeconds     = 10;
                job.SearchFlags        =
                    SearchFlags.dtsSearchSelectMostRecent |
                    SearchFlags.dtsSearchStemming |
                    SearchFlags.dtsSearchDelayDocInfo;

                int num = 0;
                if (!int.TryParse(searchTerm, out num))
                {
                    job.Fuzziness   = 1;
                    job.Request     = job.Request + "*";
                    job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchFuzzy;
                }

                if (searchTerm.ToLower().IndexOf(" and ") < 0 && searchTerm.ToLower().IndexOf(" or ") < 0)
                {
                    job.SearchFlags = job.SearchFlags | SearchFlags.dtsSearchTypeAllWords;
                }
                job.IndexesToSearch.Add(DataUtils.GetTicketIndexPath(TSAuthentication.GetLoginUser()));
                job.Execute();
                SearchResults results = job.Results;


                IDictionary <string, object> contextDictionary = (IDictionary <string, object>)context;
                List <RadComboBoxItemData>   list = new List <RadComboBoxItemData>();
                try
                {
                    for (int i = 0; i < results.Count; i++)
                    {
                        results.GetNthDoc(i);
                        RadComboBoxItemData itemData = new RadComboBoxItemData();
                        itemData.Text  = results.CurrentItem.DisplayName;
                        itemData.Value = results.CurrentItem.Filename + "," + results.CurrentItem.UserFields["TicketNumber"].ToString();
                        list.Add(itemData);
                    }
                }
                catch (Exception)
                {
                }
                if (list.Count < 1)
                {
                    RadComboBoxItemData noData = new RadComboBoxItemData();
                    noData.Text  = "[No tickets to display.]";
                    noData.Value = "-1";
                    list.Add(noData);
                }

                return(list.ToArray());
            }
        }
        public ActionResult Findjob()
        {
            string    skill    = Request["skills"];
            string    loc      = Request["location"];
            string    category = Request["category"];
            SearchJob s        = new SearchJob();

            List <String> titles     = new List <string>();
            List <String> locations  = new List <string>();
            List <int>    salaries   = new List <int>();
            List <String> starttimes = new List <string>();
            List <String> endtimes   = new List <string>();
            List <String> categories = new List <string>();
            List <String> skills     = new List <string>();
            List <String> jobtypes   = new List <string>();

            List <JobPost> jj = new List <JobPost>();
            //IQueryable result= s.searchRelevantJob(skill, loc, category);

            List <JobPost> a = s.searchRelevantJob(skill, loc, category);
            int            i = 0;

            foreach (var x in a)
            {
                //titles.Clear();
                //skills.Clear();

                JobPost j = new JobPost();

                j.Locationn      = x.Locationn;
                j.RequiredSkills = x.RequiredSkills;
                j.Designation    = x.Designation;
                j.jobTyoe        = x.jobTyoe;
                j.Salary         = x.Salary;
                j.StartTime      = x.StartTime;
                j.EndTime        = x.EndTime;
                j.Title          = x.Title;
                jj.Add(j);

                //titles.Add(x.Title);
                //locations.Add(x.Locationn);
                //skills.Add(x.RequiredSkills);
                //jobtypes.Add(x.jobTyoe);
                //starttimes.Add(x.StartTime);
                //endtimes.Add(x.EndTime);
                //categories.Add(x.Department);

                //ViewBag[i].location = x.Locationn;
                //ViewBag[i].skills = x.RequiredSkills;
                //ViewBag[i].category = x.Department;
                //ViewBag[i].starttime = x.StartTime;
                //ViewBag[i].endtime = x.EndTime;
                //ViewBag[i].titleee= x.Title;
                //ViewBag[i].salary= x.Salary;
                //ViewBag[i].jobtype= x.jobTyoe;
                ViewBag.jobs = jj;
            }
            //ViewBag.nameee = s.showjob();
            //ViewBag.nameee = result;
            //var x = result;
            //int id = 00;
            // foreach (dynamic a in x)
            //{
            //   id = a.id;
            // }
            // ViewBag.nam = id;

            return(View("Indexx3"));
        }
Beispiel #20
0
        private static void SearchLoopIteration(int iteration)
        {
            // first check to see if a new location was set
            if (NextLocation != null)
            {
                HandleLocationUpdate();
            }

            foreach (Credentials credentials in args.Credentials)
            {
                // now check if each session needs refreshing
                if (credentials.Session != null)
                {
                    TimeSpan remainingTime = credentials.Session.AccessToken.Expiry - DateTime.Now;

                    // ticket almost expired, should login again
                    if (remainingTime.TotalSeconds > 60)
                    {
                        Log($"Skipping Pokemon Go login for {credentials.Username} since already logged in for another {remainingTime.TotalSeconds} seconds.");
                    }
                    else
                    {
                        LoginAtPosition(credentials, args.ScanLocation);
                    }
                }
                else
                {
                    LoginAtPosition(credentials, args.ScanLocation);
                }
            }

            int currentStepNumber = 1;

            IEnumerable <Location> locationSteps = LocationMath.GenerateLocationSteps(args.ScanLocation, args.StepLimit);

            object objLock = new object();

            foreach (Location locationStep in locationSteps)
            {
                //Log($"Queueing search iteration {iteration}, step {currentStepNumber}");
                SearchJob searchJob = new SearchJob()
                {
                    SearchIteration = iteration,
                    StepLocation    = locationStep,
                    StepNumber      = currentStepNumber,
                    LockObj         = objLock
                };

                searchJobQueue.Enqueue(searchJob);
                //WriteToFile($"{searchJob.StepLocation.Latitude}, {searchJob.StepLocation.Longitude}");
                currentStepNumber++;
            }

            List <Task> searchTasks = new List <Task>();

            for (int threadNumber = 0; threadNumber < args.Credentials.Count; threadNumber++)
            {
                Task searchTask = CreateSearchJobProcessingThread(args.Credentials[threadNumber]);
                searchTask.Start();
                searchTasks.Add(searchTask);
            }

            foreach (Task searchTask in searchTasks)
            {
                searchTask.Wait();
            }
        }