コード例 #1
0
    public Setup(XmlNode setupNode)
    {
        if (setupNode != null)
        {
            XmlNodeList personNodes = setupNode.SelectNodes("people/person");
            foreach (XmlNode personNode in personNodes)
            {
                PersonSetup person = createPerson(personNode);
                if (person.refOnly)
                {
                    referencePeople.Add(person);
                }
                else
                {
                    people.Add(person);
                }
            }

            XmlNodeList vehicleNodes = setupNode.SelectNodes("vehicles/vehicle");
            foreach (XmlNode vehicleNode in vehicleNodes)
            {
                vehicles.Add(createVehicle(vehicleNode));
            }

            referencePeople.Sort((a, b) => a.id.CompareTo(b.id));
            people.Sort((a, b) => a.time.CompareTo(b.time));
            vehicles.Sort((a, b) => a.time.CompareTo(b.time));
        }
    }
コード例 #2
0
        public JobPercentChartVM GetJobsPercentage(int DeptId, int Week, int CompanyId, string Culture)
        {
            JobPercentChartVM result = new JobPercentChartVM();

            //Check Jobs
            var jobs = context.Assignments.Where(a => a.AssignDate <= DateTime.Today && a.EndDate >= DateTime.Today && a.CompanyId == CompanyId && a.DepartmentId == DeptId)
                       .Select(a => new { id = a.JobId, name = HrContext.TrlsName(a.Job.Name, Culture) }).Distinct().ToList();

            if (jobs.Count == 0)
            {
                result.message = MsgUtils.Instance.Trls(Culture, "DeptIsEmpty");
                return(result);
            }

            #region ---Get Week Range
            DateTime day = DateTime.Today, firstDW, lastDW;

            day = day.AddDays(Week * 7); //for next/prev button

            PersonSetup personnel = GetPersonSetup(CompanyId);
            byte        fWorkDay  = (personnel?.Weekend2 ?? personnel?.Weekend1) ?? 0;
            fWorkDay = (byte)(fWorkDay == 6 ? 0 : fWorkDay + 1);
            byte endWeek = 6; //working days only
            if (personnel?.Weekend2 != null)
            {
                endWeek--;
            }
            if (personnel?.Weekend1 != null)
            {
                endWeek--;
            }

            int diff = ((int)day.DayOfWeek - fWorkDay);
            if (diff < 0)
            {
                diff += 7;
            }
            firstDW = day.AddDays(-1 * diff).Date;
            lastDW  = day.AddDays(endWeek - (diff)).Date;

            #endregion

            List <int> jobsIds = jobs.Select(a => a.id).ToList();
            ///---Get Data
            var query = context.DeptJobLeavePlans.Where(d => d.CompanyId == CompanyId && d.DeptId == DeptId && jobsIds.Contains(d.JobId))
                        .Select(d => new { Job = HrContext.TrlsName(d.Job.Name, Culture), d.FromDate, d.ToDate, d.MinAllowPercent });

            List <ChartViewModel> chartData = new List <ChartViewModel>();

            while (firstDW <= lastDW)
            {
                var jobsInDate = query.Where(d => d.FromDate <= firstDW && d.ToDate >= firstDW).ToList();

                if (jobsInDate.Count > 0)
                {
                    chartData.AddRange(jobsInDate.Select(d =>
                                                         new ChartViewModel {
                        myGroup = d.Job, dateCategory = firstDW, floatValue = d.MinAllowPercent
                    }));
                }
                else
                {
                    foreach (var job in jobs)
                    {
                        chartData.Add(new ChartViewModel {
                            myGroup = job.name, dateCategory = firstDW, floatValue = 0
                        });
                    }
                }
                firstDW = firstDW.AddDays(1);
            }

            result.chartData = chartData.ToList();
            return(result);
        }
コード例 #3
0
 public void Attach(PersonSetup setup)
 {
     context.PersonSetup.Attach(setup);
 }
コード例 #4
0
 public DbEntityEntry <PersonSetup> Entry(PersonSetup setup)
 {
     return(Context.Entry(setup));
 }
コード例 #5
0
 public void Add(PersonSetup setup)
 {
     context.PersonSetup.Add(setup);
 }