private void metroButton1_Click(object sender, EventArgs e)
        {
            //DateTime temp = DateTime.Parse(metroDateTime1.Text);
            //string prefYear = temp.ToString("yyyy-MM-dd");
            try
            {
                DateTime date         = jobPerformanceDateTime.Value;
                int      staffId      = employeeNo;
                int      knowledge    = Int32.Parse(knowledgeTxtbox.Text);
                int      saftey       = Int32.Parse(safetyTexbox.Text);
                int      quality      = Int32.Parse(qualityTxtbox.Text);
                int      adaptability = Int32.Parse(adaptabilityTxtbox.Text);
                int      productivity = Int32.Parse(productivityTxtbox.Text);
                int      initiative   = Int32.Parse(initiativeTxtbox.Text);


                int jobPerformanceNo = 0;


                JobPerformance JPObj = new JobPerformance(staffId, date, knowledge, saftey, quality, adaptability, productivity, initiative);

                Database.addJobPerformance(JPObj);
                Notification.showNotification();
            }
            catch (Exception ex) {
                MessageBox.Show("Something went wrong! + " + ex + "", "Update client", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void metroButton2_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime date         = jobPerformanceDateTime.Value;
                int      staffId      = employeeNo;
                int      knowledge    = Int32.Parse(knowledgeTxtbox.Text);
                int      saftey       = Int32.Parse(safetyTexbox.Text);
                int      quality      = Int32.Parse(qualityTxtbox.Text);
                int      adaptability = Int32.Parse(adaptabilityTxtbox.Text);
                int      productivity = Int32.Parse(productivityTxtbox.Text);
                int      initiative   = Int32.Parse(initiativeTxtbox.Text);


                int jobPerformanceNo = 0;


                JobPerformance JPObj = new JobPerformance(staffId, date, knowledge, saftey, quality, adaptability, productivity, initiative);
                Database.updateJobPerformance(JPObj);
                Notification.showNotification();
                JPaddBtn.Enabled               = true;
                JPUpdateBtn.Enabled            = false;
                jobPerformanceDateTime.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went wrong! + " + ex + "", "Update client", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
 public static void addJobPerformance(JobPerformance jobPerformanceObj)
 {
     try
     {
         DBConnection.updateDB("insert into job_performance(staff_id, perf_year, knowledge, saftey, quality, adaptability, productivity, Initiative)values" +
                               "('" + jobPerformanceObj.StaffId + "','" + jobPerformanceObj.PerfYear.ToString("yyyy/M/d") + "', '" + jobPerformanceObj.Knowledge + "', '" + jobPerformanceObj.Safety + "'," +
                               "'" + jobPerformanceObj.Quality + "','" + jobPerformanceObj.Adaptability + "','" + jobPerformanceObj.Productivity + "','" + jobPerformanceObj.Initiative + "')");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Something went wrong!'" + ex + "'", "Update client", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 4
0
 public static bool AddJobPerformance(JobPerformance jobPerformance)
 {
     try
     {
         using (var dataContext = new IDPJobManagerDataContext())
         {
             dataContext.T_JobPerformance.Add(jobPerformance);
             dataContext.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Logger.Instance.Error(ex.Message);
         return(false);
     }
 }
Ejemplo n.º 5
0
 public static void updateJobPerformance(JobPerformance jobPerformanceObj)//This update does not work
 {
     try
     {
         DBConnection.updateDB("update job_performance set knowledge = '" + jobPerformanceObj.Knowledge + "'," +
                               "saftey = '" + jobPerformanceObj.Safety + "'," +
                               "quality =  '" + jobPerformanceObj.Quality + "'," +
                               "adaptability = '" + jobPerformanceObj.Adaptability + "'," +
                               "productivity = '" + jobPerformanceObj.Productivity + "'," +
                               "Initiative = '" + jobPerformanceObj.Initiative + "'" +
                               "where perf_year = '" + jobPerformanceObj.PerfYear.ToString("yyyy/M/d") + "'");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Something went wrong!'" + ex + "'", "Update client", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void metroButton2_Click(object sender, EventArgs e)
        {
            //int staffId = employeeNo;
            //int influence = Int32.Parse(influenceTxtbox.Text);
            //int presentation = Int32.Parse(presentationTxtbox.Text);
            //int relationships = Int32.Parse(relationshipTxtbox.Text);
            //int listening = Int32.Parse(listeningTxtbox.Text);
            //int negotiation = Int32.Parse(negotiationTxtbox.Text);



            //CommunicationSkills cS = new CommunicationSkills(staffId, getDate(), influence, presentation, relationships, listening, negotiation);
            //Database.updateCommunicationSkills(cS);
            ////Notification.showNotification();
            //notifyIcon1.Icon = SystemIcons.Application;
            //notifyIcon1.BalloonTipText = "Record Updated!";
            //notifyIcon1.ShowBalloonTip(1000);
            //CSAddBtn.Enabled = true;
            //CSUpdateBtn.Enabled = false;

            try
            {
                int staffId      = employeeNo;
                int knowledge    = Int32.Parse(knowledgeTxtbox.Text);
                int saftey       = Int32.Parse(safetyTexbox.Text);
                int quality      = Int32.Parse(qualityTxtbox.Text);
                int adaptability = Int32.Parse(adaptabilityTxtbox.Text);
                int productivity = Int32.Parse(productivityTxtbox.Text);
                int initiative   = Int32.Parse(initiativeTxtbox.Text);


                JobPerformance JPObj = new JobPerformance(staffId, getDate(), knowledge, saftey, quality, adaptability, productivity, initiative);
                Database.updateJobPerformance(JPObj);
                notifyIcon1.Icon           = SystemIcons.Application;
                notifyIcon1.BalloonTipText = "Record Updated!";
                notifyIcon1.ShowBalloonTip(1000);
                JPaddBtn.Enabled    = true;
                JPUpdateBtn.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went wrong! + " + ex + "", "Update client", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 7
0
        public List <JobPerformance> Get(JobPerformanceCriteria criteria)
        {
            var listJob = jobs;

            if (criteria.ThisWeek)
            {
                DateTime fromDate = DateTime.Now.StartOfWeek(DayOfWeek.Monday);
                DateTime toDate   = DateTime.Now.StartOfWeek(DayOfWeek.Sunday);
                listJob = listJob.Where(x => (x.AssignTime >= fromDate && x.AssignTime <= toDate)).ToList();
            }
            if (criteria.ThisMonth)
            {
                listJob = listJob.Where(x => (x.AssignTime.Month == DateTime.Now.Month)).ToList();
            }
            if (criteria.ThisQuater)
            {
            }
            if (criteria.ThisYear)
            {
                listJob = listJob.Where(x => (x.AssignTime.Year == DateTime.Now.Year)).ToList();
            }
            if (!string.IsNullOrEmpty(criteria.UserId))
            {
                listJob = listJob.Where(x => x.UserId == criteria.UserId).ToList();
            }
            var results = new List <JobPerformance>();
            var list    = listJob.GroupBy(x => x.CurrentStageStatus).Select(x => new { JobStatus = x.Key, NumberJob = x.Count() });

            if (!list.Any(x => x.JobStatus == JobStatus.Canceled))
            {
                results.Add(new JobPerformance {
                    JobStatus = JobStatus.Canceled, NumberJob = 0, StatusName = GetStatusName(JobStatus.Canceled)
                });
            }
            if (!list.Any(x => x.JobStatus == JobStatus.Finish))
            {
                results.Add(new JobPerformance {
                    JobStatus = JobStatus.Finish, NumberJob = 0, StatusName = GetStatusName(JobStatus.Finish)
                });
            }
            if (!list.Any(x => x.JobStatus == JobStatus.InSchedule))
            {
                results.Add(new JobPerformance {
                    JobStatus = JobStatus.InSchedule, NumberJob = 0, StatusName = GetStatusName(JobStatus.InSchedule)
                });
            }
            if (!list.Any(x => x.JobStatus == JobStatus.Overdued))
            {
                results.Add(new JobPerformance {
                    JobStatus = JobStatus.Overdued, NumberJob = 0, StatusName = GetStatusName(JobStatus.Overdued)
                });
            }
            if (!list.Any(x => x.JobStatus == JobStatus.Pending))
            {
                results.Add(new JobPerformance {
                    JobStatus = JobStatus.Pending, NumberJob = 0, StatusName = GetStatusName(JobStatus.Pending)
                });
            }
            if (!list.Any(x => x.JobStatus == JobStatus.Processing))
            {
                results.Add(new JobPerformance {
                    JobStatus = JobStatus.Processing, NumberJob = 0, StatusName = GetStatusName(JobStatus.Processing)
                });
            }
            //if (!list.Any(x => x.JobStatus == JobStatus.WillOverDue))
            //{
            //    results.Add(new JobPerformance { JobStatus = JobStatus.WillOverDue, NumberJob = 0, StatusName = GetStatusName(JobStatus.WillOverDue) });
            //}
            foreach (var item in list)
            {
                var performance = new JobPerformance();
                performance.JobStatus  = item.JobStatus;
                performance.NumberJob  = item.NumberJob;
                performance.StatusName = GetStatusName(item.JobStatus);
                results.Add(performance);
            }
            return(results);
        }
Ejemplo n.º 8
0
 public WorkerCallbackContext(JobPerformance jobPerformance, IWorker <Project> worker)
 {
     JobPerformance = jobPerformance;
     Worker         = worker;
 }
Ejemplo n.º 9
0
        public void Execute()
        {
            if (!Monitor.TryEnter(_executionLock))
            {
                throw new Exception("Cannot call execute twice");
            }

            var buildIterationIndex = 0;

            if (_workerList.Count == 0)
            {
                throw new Exception("Worker list is empty ...");
            }

            try
            {
                var perf = JobPerformance.CreateJobStatistics(Name);
                perf.SetTotalJobs(_workerList.Count);

                if (ResolveDependencies)
                {
                    foreach (var worker in _workerList)
                    {
                        worker.ResolveDependencies();
                    }
                }

                var unsatisfiedDeps = new StringBuilder();

                do
                {
                    var workerCount    = 0;
                    var bWorkersActive = false;

                    // determine projects that will execute in this iteration
                    log.DebugFormat("Beginning build iteration #{0}", ++buildIterationIndex);

                    var localWorkerList = _workerList.ToArray();
                    log.DebugFormat("Remaining items {0}", localWorkerList.Length);

                    foreach (var worker in localWorkerList)
                    {
                        if (!worker.CanExecute())
                        {
                            unsatisfiedDeps.Length = 0;
                            foreach (var dep in worker.UnsatisfiedDependencies())
                            {
                                if (unsatisfiedDeps.Length > 0)
                                {
                                    unsatisfiedDeps.AppendFormat(",{0}", dep.Name);
                                }
                                else
                                {
                                    unsatisfiedDeps.AppendFormat("{0}", dep.Name);
                                }
                            }

                            log.DebugFormat("Skipping {0} [{1}]",
                                            worker.Name,
                                            unsatisfiedDeps.ToString());


                            continue;
                        }

                        bWorkersActive = true;

                        log.InfoFormat("Building {0}", worker.Name);

                        _workerList.Remove(worker);

                        _sem.WaitOne(-1, false);

                        if (_prematureExit)
                        {
                            break;
                        }

                        lock (_executionList)
                        {
                            _executionList.Add(worker);
                        }

                        _workerExecuteFunc.BeginInvoke(
                            worker,
                            WorkerExecuteInvokationCallback,
                            new WorkerCallbackContext(perf, worker));

                        workerCount++;
                        perf.NewJobExecuted();
                    }

                    // check if some project failed
                    if (_prematureExit)
                    {
                        break;
                    }

                    if (!bWorkersActive)
                    {
                        log.Debug("No Workers where started, waiting for a project to finish");
                        _projectFinishedEvent.WaitOne(-1, false);
                        log.Debug("Waiting ... returned");
                    }

                    log.DebugFormat("Executing {0} workers", workerCount);
                    log.DebugFormat("Pending {0} workers", _workerList.Count);

                    log.DebugFormat("{0},===========================================", buildIterationIndex);
                } while ((_workerList.Count > 0 || _executionList.Count > 0) && !_prematureExit);

                log.InfoFormat("Building complete ...");
            }
            finally
            {
                Monitor.Exit(_executionLock);
            }
        }