Ejemplo n.º 1
0
        private void Compare(JSONJobs a, JSONJobs b, string statustext)
        {
            if (a != null && b != null)
            {
                foreach (JSONJob j1 in a.jobs)
                {
                    string slug = j1.slug;

                    bool foundit = false;
                    foreach (JSONJob j2 in b.jobs)
                    {
                        if (j2.slug.Trim() == j1.slug.Trim())
                        {
                            foundit = true;
                            break;
                        }
                    }

                    if (!foundit)
                    {
                        j1.RECORD_STATUS = statustext;
                    }
                    else
                    {
                        j1.RECORD_STATUS = JOBSTATUS_SAME;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void LoadGrid2(string filename, DataGridView dataGridView1)
        {
            string data = File.ReadAllText(filename);
            JsonSerializer ser = new JsonSerializer();
            File2Jobs = JsonConvert.DeserializeObject<JSONJobs>(data);

            configureGridColumns(dataGridView1);

            foreach (JSONJob j in File1Jobs.jobs)
            {
                string[] row = new string[] { j.RECORD_STATUS, j.slug, j.title, j.city, j.state, j.country, j.location, j.description };
                dataGridView1.Rows.Add(row);
            }

            if (File1Jobs != null && File2Jobs != null)
            {
                CompareFiles(dataGridView1);
            }
        }
Ejemplo n.º 3
0
        public void startupLoadFiles(DataGridView dataGridView1)
        {
            // get all JSON job files
            string[] files = Directory.GetFiles(@".\", "*.json");

            if (files.Length >= 2)
            {
                File1FileName = files[files.Length - 2];
                string data = File.ReadAllText(File1FileName);
                File1Jobs = JsonConvert.DeserializeObject<JSONJobs>(data);

                File2FileName = files[files.Length - 1];
                string data2 = File.ReadAllText(File2FileName);
                File2Jobs = JsonConvert.DeserializeObject<JSONJobs>(data2);
            }
            else if (files.Length == 1)
            {
                File2FileName = files[files.Length - 1];
                string data2 = File.ReadAllText(File2FileName);
                File2Jobs = JsonConvert.DeserializeObject<JSONJobs>(data2);

                File1Jobs = File2Jobs;
                File1FileName = File2FileName;
            }
            else
            {
                //test change
                return;
            }

            CompareFiles(dataGridView1);
            HideNotInterested = true;
            ToggleNotInterestedRows(dataGridView1);
        }
Ejemplo n.º 4
0
        public void CreateNewFile(DataGridView dataGridView1, ToolStripStatusLabel toolstripstatuslabel)
        {
            DateTime dt = DateTime.Now;

            // delete all json files for same day
            string[] deletefiles = Directory.GetFiles(@".\", string.Format("{0:MMddyy}*.json", dt));
            foreach (string deletefile in deletefiles)
            {
                File.Delete(deletefile);
            }

            // download 1,000 jobs from avanade careers right now
            string localFilename = @".\" + string.Format("{0:MMddyy HHmmss}.json", dt);

            List<JSONJob> totalJobs = null;

            int joboffset = 0;
            while (true)
            {
                string url = @"https://careers.avanade.com/api/jobs?brand=experienced,both&limit=100&offset={0}&page=1";
                url = string.Format(url, joboffset);

                toolstripstatuslabel.Text = string.Format("Requesting JSON file offset {0}... Please Wait ...", joboffset);
                Application.DoEvents();

                WebClient client = new WebClient();
                client.DownloadFile(url, localFilename);
                File2FileName = localFilename;

                // load the downloaded jobs into File2Jobs
                string data = File.ReadAllText(File2FileName);
                File2Jobs = JsonConvert.DeserializeObject<JSONJobs>(data);

                if (File2Jobs.jobs.Count<JSONJob>() == 0)
                {
                    break;
                }

                if (totalJobs == null)
                {
                    totalJobs = File2Jobs.jobs.ToList<JSONJob>();
                }
                else
                {
                    foreach (var job in File2Jobs.jobs)
                    {
                        totalJobs.Add(job);
                    }
                }

                joboffset += 100;

            }

            toolstripstatuslabel.Text = string.Format("Downloaded {0} Jobs Please Wait ...", totalJobs.Count);
            Application.DoEvents();

            File2Jobs = new JSONJobs();
            File2Jobs.jobs = totalJobs.ToArray<JSONJob>();
            File.WriteAllText(localFilename,JsonConvert.SerializeObject(File2Jobs));

            // get all JSON job files
            string[] files = Directory.GetFiles(@".\", "*.json");

            if (files.Length >= 2)
            {
                File1FileName = files[files.Length-2];
                string data2 = File.ReadAllText(File1FileName);
                File1Jobs = JsonConvert.DeserializeObject<JSONJobs>(data2);
            }
            else
            {
                File1Jobs = File2Jobs;
                File1FileName = File2FileName;
            }

            CompareFiles(dataGridView1);
        }