コード例 #1
0
        internal async void HandleMoreResultsQueryCommand(SearchQueryViewModel parameter)
        {
            //this.debugQuery = (parameter);
            if (parameter != null)
            {
                //DisplayJobsCollection = this.ResultJobsCollection;
                //for (int i = 0; i < 5; i++)
                //{
                parameter.SkipPages = 20;
                try
                {
                    var newResults = await RemoteDataManager.SearchForJobs(parameter);

                    foreach (var item in newResults)
                    {
                        resultJobsCollection.Add(item);
                    }
                }
                catch (Exception e)
                {
                    //dont break the app :)
                    errorLog.AppendLine(e.ToString());
                }

                //}
                DisplayJobsCollection =
                    SearchManager.SearchForJobsInCollection(CurrentQuery, this.ResultJobsCollection);
                this.OnPropertyChanged("ResultCount");
                //foreach (var item in this.ResultJobsCollection)
                //{
                //item.CurrJobMatch = item.ChechMatchings(parameter.LookupSkills, parameter.NotMandatoryLookupSkills);
                //}
            }
        }
コード例 #2
0
        //Command Handlers
        internal async void HandleSearchQuerryCommand(SearchQueryViewModel parameter)
        {
            //this.debugQuery = (parameter);
            this.CurrentQuery = new SearchQueryViewModel(
                parameter.Keyword,
                parameter.PublishDate,
                parameter.LookupSkills,
                parameter.NotMandatoryLookupSkills
                );

            parameter.SkipPages = -50000;

            try
            {
                var results = await RemoteDataManager.SearchForJobs(parameter);

                this.ResultJobsCollection = results;
            }
            catch (Exception e)
            {
                errorLog.AppendLine(e.ToString());
            }

            DisplayJobsCollection = SearchManager.SearchForJobsInCollection(NewQuery, this.ResultJobsCollection);
            parameter.SkipPages   = 0;

            //foreach (var item in this.ResultJobsCollection)
            //{
            //item.CurrJobMatch = item.ChechMatchings(parameter.LookupSkills, parameter.NotMandatoryLookupSkills);
            //}
            this.OnPropertyChanged("ResultCount");
        }
コード例 #3
0
        //Constructor
        public HomePageViewModel()
        {
            this.FavoriteJobsCollection = new ObservableCollection <JobViewModel>();
            //this.ResultJobsCollection = new ObservableCollection<JobViewModel>();
            //DisplayJobsCollection = new ObservableCollection<JobViewModel>();
            PersonalSkillset        = new ObservableCollection <SkillViewModel>();
            this.PublishDateOptions = new ObservableCollection <PublishDateViewModel>();

            this.LoadFavoriteJobs(favoriteJobsFilename);
            this.LoadPersonalSkillset(personalSkillestFilename);
            this.LoadPublishDateOption(); //"PublishDateSearchOptions.xml"

            //if (newQuery == null)
            //{
            NewQuery = new SearchQueryViewModel(
                string.Empty,
                this.PublishDateOptions.First(),
                new ObservableCollection <SkillViewModel>(),
                personalSkillset
                );
            //}


            this.NewSkill    = new SkillViewModel();
            this.SelectedJob = null;
        }
コード例 #4
0
ファイル: SearchManager.cs プロジェクト: kirotab/JobsMatch
 public static IEnumerable<JobViewModel> SearchForJobsInCollection(
     SearchQueryViewModel searchQuery, IEnumerable<JobViewModel> Jobs)
 {
     var result = new LinkedList<JobViewModel>();
     if (Jobs != null)//&& Jobs.Count > 0
     {
         foreach (var item in Jobs)
         {
             item.CurrJobMatch = JobViewModel.ChechMatchings(item, searchQuery.LookupSkills, searchQuery.NotMandatoryLookupSkills);
             if (item.CurrJobMatch.Count() >= searchQuery.LookupSkills.Count)
             {
                 result.AddLast(item);
             }
         }
     }
     return result;
 }
コード例 #5
0
ファイル: SearchManager.cs プロジェクト: kirotab/JobsMatch
        public static IEnumerable <JobViewModel> SearchForJobsInCollection(
            SearchQueryViewModel searchQuery, IEnumerable <JobViewModel> Jobs)
        {
            var result = new LinkedList <JobViewModel>();

            if (Jobs != null)//&& Jobs.Count > 0
            {
                foreach (var item in Jobs)
                {
                    item.CurrJobMatch = JobViewModel.ChechMatchings(item, searchQuery.LookupSkills, searchQuery.NotMandatoryLookupSkills);
                    if (item.CurrJobMatch.Count() >= searchQuery.LookupSkills.Count)
                    {
                        result.AddLast(item);
                    }
                }
            }
            return(result);
        }
コード例 #6
0
        //private static SearchQueryViewModel lastSearchQuery = null;
        //public static List<JobViewModel> lastResult = null;
        
        //last=0&str_regions=&str_locations=&tab=jobs&old_country=&country=-1&region=0&l_category%5B%5D=0&keyword=
        public static async Task<ICollection<JobViewModel>> SearchForJobs(SearchQueryViewModel searchQuery)//ICollection<JobViewModel> prevResults = null 
        {
            //if (lastSearchQuery == null || !(lastSearchQuery.Equals(searchQuery)))//|| (lastResult == null || lastResult.Count() == 0)
            //{
            //if (lastSearchQuery != null)
            //{
            //    var debug = (lastSearchQuery== searchQuery);
            //}
            List<JobViewModel> testResult = new List<JobViewModel>();


            var skipResults = searchQuery.SkipPages;
            var keyword = searchQuery.Keyword;
            var dateFilter = searchQuery.PublishDate;
            var lookupSkills = searchQuery.LookupSkills;
            var notMandatoryLookupSkills = searchQuery.NotMandatoryLookupSkills;
            var baseAddress = "http://www.jobs.bg/front_job_search.php?";


            //lastSearchQuery = searchQuery;
            //if (lastSearchQuery == null)
            //{
            //    lastSearchQuery = new SearchQueryViewModel(
            //        keyword,
            //        dateFilter,
            //        lookupSkills,
            //        notMandatoryLookupSkills,
            //        skipResults
            //        );
            //}
            //else
            //{
            //    lastSearchQuery.Keyword = keyword;
            //    lastSearchQuery.PublishDate = dateFilter;
            //    lastSearchQuery.LookupSkills = lookupSkills;
            //    lastSearchQuery.NotMandatoryLookupSkills = notMandatoryLookupSkills;
            //    lastSearchQuery.SkipPages = skipResults;
            //}

            lastSkipResults += skipResults;
            if (lastSkipResults < 0)
            {
                lastSkipResults = 0;
            }


            var fullUri = String.Format("{0}frompage={3}&last={1}&keyword={2}", baseAddress, dateFilter.PublishDateValue, keyword, lastSkipResults);

            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri(fullUri);
            var response = await client.GetAsync("");

            //var responseTextAsStream = await response.Content.ReadAsStreamAsync();
            var responseText = await response.Content.ReadAsStringAsync();


            HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

            // There are various options, set as needed
            htmlDoc.OptionFixNestedTags = false;

            // filePath is a path to a file containing the html
            //htmlDoc.Load(responseTextAsStream);
            htmlDoc.LoadHtml(responseText);

            // Use:  htmlDoc.LoadHtml(xmlString);  to load from a string (was htmlDoc.LoadXML(xmlString)

            // ParseErrors is an ArrayList containing any errors from the Load statement
            //if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0)
            //{
            //    // Handle any parse errors as required

            //}
            //else
            if (htmlDoc.DocumentNode != null)
            {
                //List<HtmlAgilityPack.HtmlNode> bodyNode = htmlDoc.DocumentNode.Descendants("table").Where(x=>((x.Descendants("table").Count()) > 2)).ToList();// ("//body");


                if (htmlDoc.DocumentNode.Descendants("td") != null)
                {
                    var tableNode = (htmlDoc.DocumentNode.Descendants("td").Where(
                        d => (d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("listTitle"))
                        ).FirstOrDefault());
                    if (tableNode != null && tableNode.ParentNode != null && tableNode.ParentNode.ParentNode != null)
                    {
                        tableNode = tableNode.ParentNode.ParentNode;
                    }
                    if (tableNode != null)
                    {
                        var jobOfferRows = tableNode.Descendants("tr");

                        foreach (var row in jobOfferRows)
                        {

                            var cells = row.Elements("td").Where(d => (d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("offerslistRow"))).ToList();
                            if (cells.Count() == 5)
                            {
                                JobViewModel newOffer = null;
                                try
                                {
                                    newOffer = await CreateJobOfferFromRow(cells);
                                }
                                catch (Exception e)
                                {
                                    throw new InvalidOperationException("Parsing Job Offer Failed", e);
                                }

                                //item.CurrJobMatch = item.ChechMatchings(parameter.LookupSkills, parameter.NotMandatoryLookupSkills);
                                //if (newOffer != null)
                                //{
                                //    newOffer.CurrJobMatch = JobViewModel.ChechMatchings(newOffer, lookupSkills, notMandatoryLookupSkills);
                                //    if (newOffer.CurrJobMatch.Count() >= lookupSkills.Count)
                                //    {
                                //        testResult.Add(newOffer);
                                //    }
                                //}
                                if (newOffer != null)
                                {
                                    testResult.Add(newOffer);

                                }
                            }
                        }
                    }
                }
            }

            //lastResult = testResult;
            return testResult;
            //}
            //else
            //{
            //    return lastResult;
            //}
        }
コード例 #7
0
        //private static SearchQueryViewModel lastSearchQuery = null;
        //public static List<JobViewModel> lastResult = null;

        //last=0&str_regions=&str_locations=&tab=jobs&old_country=&country=-1&region=0&l_category%5B%5D=0&keyword=
        public static async Task <ICollection <JobViewModel> > SearchForJobs(SearchQueryViewModel searchQuery)//ICollection<JobViewModel> prevResults = null
        {
            //if (lastSearchQuery == null || !(lastSearchQuery.Equals(searchQuery)))//|| (lastResult == null || lastResult.Count() == 0)
            //{
            //if (lastSearchQuery != null)
            //{
            //    var debug = (lastSearchQuery== searchQuery);
            //}
            List <JobViewModel> testResult = new List <JobViewModel>();


            var skipResults              = searchQuery.SkipPages;
            var keyword                  = searchQuery.Keyword;
            var dateFilter               = searchQuery.PublishDate;
            var lookupSkills             = searchQuery.LookupSkills;
            var notMandatoryLookupSkills = searchQuery.NotMandatoryLookupSkills;
            var baseAddress              = "http://www.jobs.bg/front_job_search.php?";


            //lastSearchQuery = searchQuery;
            //if (lastSearchQuery == null)
            //{
            //    lastSearchQuery = new SearchQueryViewModel(
            //        keyword,
            //        dateFilter,
            //        lookupSkills,
            //        notMandatoryLookupSkills,
            //        skipResults
            //        );
            //}
            //else
            //{
            //    lastSearchQuery.Keyword = keyword;
            //    lastSearchQuery.PublishDate = dateFilter;
            //    lastSearchQuery.LookupSkills = lookupSkills;
            //    lastSearchQuery.NotMandatoryLookupSkills = notMandatoryLookupSkills;
            //    lastSearchQuery.SkipPages = skipResults;
            //}

            lastSkipResults += skipResults;
            if (lastSkipResults < 0)
            {
                lastSkipResults = 0;
            }


            var fullUri = String.Format("{0}frompage={3}&last={1}&keyword={2}", baseAddress, dateFilter.PublishDateValue, keyword, lastSkipResults);

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(fullUri);
            var response = await client.GetAsync("");

            //var responseTextAsStream = await response.Content.ReadAsStreamAsync();
            var responseText = await response.Content.ReadAsStringAsync();


            HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

            // There are various options, set as needed
            htmlDoc.OptionFixNestedTags = false;

            // filePath is a path to a file containing the html
            //htmlDoc.Load(responseTextAsStream);
            htmlDoc.LoadHtml(responseText);

            // Use:  htmlDoc.LoadHtml(xmlString);  to load from a string (was htmlDoc.LoadXML(xmlString)

            // ParseErrors is an ArrayList containing any errors from the Load statement
            //if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0)
            //{
            //    // Handle any parse errors as required

            //}
            //else
            if (htmlDoc.DocumentNode != null)
            {
                //List<HtmlAgilityPack.HtmlNode> bodyNode = htmlDoc.DocumentNode.Descendants("table").Where(x=>((x.Descendants("table").Count()) > 2)).ToList();// ("//body");


                if (htmlDoc.DocumentNode.Descendants("td") != null)
                {
                    var tableNode = (htmlDoc.DocumentNode.Descendants("td").Where(
                                         d => (d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("listTitle"))
                                         ).FirstOrDefault());
                    if (tableNode != null && tableNode.ParentNode != null && tableNode.ParentNode.ParentNode != null)
                    {
                        tableNode = tableNode.ParentNode.ParentNode;
                    }
                    if (tableNode != null)
                    {
                        var jobOfferRows = tableNode.Descendants("tr");

                        foreach (var row in jobOfferRows)
                        {
                            var cells = row.Elements("td").Where(d => (d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("offerslistRow"))).ToList();
                            if (cells.Count() == 5)
                            {
                                JobViewModel newOffer = null;
                                try
                                {
                                    newOffer = await CreateJobOfferFromRow(cells);
                                }
                                catch (Exception e)
                                {
                                    throw new InvalidOperationException("Parsing Job Offer Failed", e);
                                }

                                //item.CurrJobMatch = item.ChechMatchings(parameter.LookupSkills, parameter.NotMandatoryLookupSkills);
                                //if (newOffer != null)
                                //{
                                //    newOffer.CurrJobMatch = JobViewModel.ChechMatchings(newOffer, lookupSkills, notMandatoryLookupSkills);
                                //    if (newOffer.CurrJobMatch.Count() >= lookupSkills.Count)
                                //    {
                                //        testResult.Add(newOffer);
                                //    }
                                //}
                                if (newOffer != null)
                                {
                                    testResult.Add(newOffer);
                                }
                            }
                        }
                    }
                }
            }

            //lastResult = testResult;
            return(testResult);
            //}
            //else
            //{
            //    return lastResult;
            //}
        }