Beispiel #1
0
 public void TestRecentJobsExecuteMethodReturnsAListOfJobsForTrainer()
 {
     string stream = "All";
     RecentJobs recJobs = new RecentJobs();
     recJobs.SetStringStream(stream);
     List<DbJob> jobs = recJobs.Execute();
     Assert.AreEqual(5, jobs.Count());
 }
Beispiel #2
0
 public void TestRecentJobsExecuteMethodReturnsAListOfJobsForConsultant()
 {
     int user_id = 1;
     RecentJobs recJobs = new RecentJobs();
     recJobs.GetUserStream(user_id);
     List<DbJob> jobs =  recJobs.Execute();
     Assert.AreEqual(1, jobs.Count());
 }
Beispiel #3
0
        public void TestRecentJobsExecuteMethodReturnsAListOfJobsForConsultant()
        {
            int        user_id = 1;
            RecentJobs recJobs = new RecentJobs();

            recJobs.GetUserStream(user_id);
            List <DbJob> jobs = recJobs.Execute();

            Assert.AreEqual(1, jobs.Count());
        }
Beispiel #4
0
        public void TestRecentJobsExecuteMethodReturnsAListOfJobsForTrainer()
        {
            string     stream  = "All";
            RecentJobs recJobs = new RecentJobs();

            recJobs.SetStringStream(stream);
            List <DbJob> jobs = recJobs.Execute();

            Assert.AreEqual(5, jobs.Count());
        }
Beispiel #5
0
    public static string Html()
    {
        StringBuilder sbHtml = new StringBuilder();

        RecentJobs RecentJobs = new RecentJobs();

        int cJobs = 0;

        if (RecentJobs.Jobs != null && RecentJobs.Jobs.Count > 0)
        {
            ArrayList Reverse = (ArrayList)RecentJobs.Jobs.Clone();
            Reverse.Reverse();

            DB db = new DB();

            sbHtml.Append(
                "<i class=\"fa fa-bookmark-o bookmark\" title=\"Recent Jobs\"></i>\n" +
                "<div id=\"JobToolbar\" class=\"ui-widget-header ui-corner-all\">\n");

            foreach (Int32 JobRno in Reverse)
            {
                string Sql = string.Format(
                    "Select Coalesce(cu.Name, c.Name) as Customer, JobDate " +
                    "From mcJobs j " +
                    "Inner Join Contacts c on j.ContactRno = c.ContactRno " +
                    "Left Join Customers cu on c.CustomerRno = cu.CustomerRno " +
                    "Where JobRno = {0}", JobRno);
                DataRow dr = db.DataRow(Sql);
                if (dr != null)
                {
                    cJobs++;
                    sbHtml.AppendFormat(
                        "<div><button class=\"JobOnBar\" data-job=\"{0}\">#{0} - {1} {2}</button></div>\n",
                        JobRno,
                        DB.DtTm(dr["JobDate"]).ToString("M/d/yyyy"),
                        DB.Str(dr["Customer"]));
                }
            }
            sbHtml.Append("</div>\n");
            db.Close();
        }

        if (cJobs == 0)
        {
            sbHtml = new StringBuilder();
        }

        return(sbHtml.ToString());
    }
Beispiel #6
0
 public void Test_RecentJobsClass_ExecuteMethod_Returns_A_List_of_DbJob()
 {
     RecentJobs rJobs = new RecentJobs();
     Assert.IsInstanceOf(typeof(List<DbJob>), rJobs.Execute());
 }
Beispiel #7
0
        public void Test_RecentJobsClass_ExecuteMethod_Returns_A_List_of_DbJob()
        {
            RecentJobs rJobs = new RecentJobs();

            Assert.IsInstanceOf(typeof(List <DbJob>), rJobs.Execute());
        }
Beispiel #8
0
 public DbJob FindJob(int jobId)
 {
     RecentJobs jobs = new RecentJobs();
     return jobs.GetJob(jobId);
 }
Beispiel #9
0
 public string DetermineUserStream(int user_id)
 {
     RecentJobs recJobs = new RecentJobs();
     return recJobs.GetUserStream(user_id);
 }
Beispiel #10
0
 public List<DbJob> RecentJobs(string stream)
 {
     RecentJobs recJobs = new RecentJobs();
     recJobs.SetStringStream(stream);
     return recJobs.Execute();
 }
Beispiel #11
0
        public List<DbJob> Search(string stream, string status, string location, string company, List<string> skills)
        {
            List<DbJob> finalJobs = new List<DbJob>();
            List<string> sortedJobs = new List<string>();
            List<string> sortedJobs2 = new List<string>();
            List<string> sortedJobs3 = new List<string>();
            List<string> sortedJobs4 = new List<string>();
            List<Tuple<string, int>> unsortedJobs = new List<Tuple<string, int>>();

            // search based on stream, status, skills, company and location

            string qry1 = GetQryStreamStatus(stream, status);
            string qry2 = GetQryLocComp(location, company);

            IReadCommand read = new ReadCommand();
            DataTable dt1 = read.Execute(qry1);
            List<string> jobs1 = (from row in dt1.AsEnumerable() select Convert.ToString(row["JOB_ID"])).ToList();

            for (int i = 0; i < jobs1.Count(); i++)
            {
                sortedJobs.Add(jobs1[i]);
            }

            DataTable dt2 = read.Execute(qry2);
            List<string> jobs2 = (from row in dt2.AsEnumerable() select Convert.ToString(row["JOB_ID"])).ToList();

            for (int i = 0; i < jobs2.Count(); i++)
            {
                sortedJobs2.Add(jobs2[i]);
            }

            //selects matching jobs from both lists
            List<string> relevantJobs = sortedJobs.Intersect(sortedJobs2).ToList();

            for (int k = 0; k < relevantJobs.Count(); k++)
            {
                sortedJobs3.Add(relevantJobs[k]);
            }

            // match skills
            List<string> jobs3 = new List<string>();
            // check if skills are empty
            if (skills.Count > 0)
            {
                // if not: for each required skill
                for (int i = 0; i < skills.Count(); i++)
                {
                    Console.WriteLine(skills[i]);
                    // select all jobs that have skill
                    string qry3 = "SELECT JOBPOST.job_id FROM JOBPOST JOIN JOBSKILL ON JOBPOST.job_id=JOBSKILL.job_id JOIN SKILL ON SKILL.skill_id = JOBSKILL.skill_id WHERE skilltext = '" + skills[i] + "'";
                    IReadCommand read2 = new ReadCommand();
                    DataTable dt3 = read2.Execute(qry3);
                    List<string> jobs4 = (from row in dt3.AsEnumerable() select Convert.ToString(row["JOB_ID"])).ToList();
                    for (int j = 0; j < jobs4.Count(); j++)
                    {
                        jobs3.Add(jobs4[j]);
                        //Console.WriteLine(jobs4[j]);
                    }
                    Console.WriteLine("count " + jobs3.Count().ToString());
                    // return list of jobs
                }

                //count how often job appears in skills - how many of the relevant skills it has
                var groups = jobs3.GroupBy(v => v);
                foreach (var group in groups)
                {
                    Tuple<string, int> job = new Tuple<string, int>(group.Key, group.Count());
                    unsortedJobs.Add(job);
                }

                // sort unique jobs by skill count
                unsortedJobs.Sort((a, b) => a.Item2.CompareTo(b.Item2));
                Console.WriteLine("count unsorted" + unsortedJobs.Count().ToString());

                for (int k = 0; k < unsortedJobs.Count(); k++)
                {
                    sortedJobs4.Add(unsortedJobs[k].Item1.ToString());
                }
                Console.WriteLine("count sorted" + sortedJobs4.Count().ToString());

                IEnumerable<string> relevantJobs2 = sortedJobs4.Intersect(relevantJobs);
                //IEnumerable<string> relevantJobs2 = relevantJobs.Intersect(sortedJobs3);

                foreach (var job in relevantJobs2.ToList())
                {
                    RecentJobs recJobs = new RecentJobs();
                    DbJob jobDesc = recJobs.GetJob(int.Parse(job));
                    finalJobs.Add(jobDesc);
                }
            }
            else
            {
                for (int i = 0; i < sortedJobs4.Count(); i++)
                {
                    RecentJobs recJobs = new RecentJobs();
                    DbJob jobDesc = recJobs.GetJob(int.Parse(sortedJobs4.ToList()[i]));
                    finalJobs.Add(jobDesc);
                }
            }

            return finalJobs;
        }