Пример #1
0
        private List <RosterDetailAttributes> CalculateRosterDetails(List <Models.RosterDetail> rosterdetails, RosterApp rosterApp)
        {
            //List<RosterDetailModel> rdm = new List<RosterDetailModel>();
            List <RosterDetailAttributes> rda = new List <RosterDetailAttributes>();
            Shift shift = new Shift();

            shift = db.Shifts.First(aa => aa.ShiftID == rosterApp.ShiftID);
            DateTime            currentDate     = rosterApp.DateStarted.Value;
            List <RosterDetail> tempRotaDetails = new List <RosterDetail>();

            while (currentDate <= rosterApp.DateEnded)
            {
                RosterDetailAttributes rdaS = new RosterDetailAttributes();
                tempRotaDetails = rosterdetails.Where(aa => aa.RosterDate == currentDate).ToList();
                if (tempRotaDetails.Count > 0)
                {
                    rdaS.Changed  = true;
                    rdaS.Day      = tempRotaDetails.FirstOrDefault().RosterDate.Value.ToString("dddd");
                    rdaS.DutyCode = tempRotaDetails.FirstOrDefault().DutyCode;
                    rdaS.DutyDate = tempRotaDetails.FirstOrDefault().RosterDate.Value;
                    rdaS.DutyTime = (TimeSpan)tempRotaDetails.FirstOrDefault().DutyTime;
                    rdaS.WorkMin  = (short)tempRotaDetails.FirstOrDefault().WorkMin;
                }
                else
                {
                    rdaS.Changed = false;
                    rdaS.Day     = currentDate.ToString("dddd");
                    int wrkMin = CalculateDutyCode(shift, currentDate);
                    if (wrkMin == 0)
                    {
                        rdaS.DutyCode = "R";
                    }
                    else
                    {
                        rdaS.DutyCode = "D";
                    }
                    rdaS.DutyDate = currentDate;
                    rdaS.DutyTime = shift.StartTime;
                    rdaS.WorkMin  = wrkMin;
                }
                rda.Add(rdaS);
                currentDate = currentDate.AddDays(1);
            }
            return(rda);
        }
Пример #2
0
 private List<RosterDetailAttributes> CalculateRosterDetails(List<Models.RosterDetail> rosterdetails, RosterApp rosterApp)
 {
     //List<RosterDetailModel> rdm = new List<RosterDetailModel>();
     List<RosterDetailAttributes> rda = new List<RosterDetailAttributes>();
     Shift shift = new Shift();
     shift = db.Shifts.First(aa => aa.ShiftID == rosterApp.ShiftID);
     DateTime currentDate = rosterApp.DateStarted.Value;
     List<RosterDetail> tempRotaDetails = new List<RosterDetail>();
     while (currentDate <= rosterApp.DateEnded)
     {
         RosterDetailAttributes rdaS = new RosterDetailAttributes();
         tempRotaDetails = rosterdetails.Where(aa => aa.RosterDate == currentDate).ToList();
         if (tempRotaDetails.Count > 0)
         {
             rdaS.Changed = true;
             rdaS.Day = tempRotaDetails.FirstOrDefault().RosterDate.Value.ToString("dddd");
             rdaS.DutyCode = tempRotaDetails.FirstOrDefault().DutyCode;
             rdaS.DutyDate = tempRotaDetails.FirstOrDefault().RosterDate.Value;
             rdaS.DutyTime = (TimeSpan)tempRotaDetails.FirstOrDefault().DutyTime;
             rdaS.WorkMin = (short)tempRotaDetails.FirstOrDefault().WorkMin;
         }
         else
         {
             rdaS.Changed = false;
             rdaS.Day = currentDate.ToString("dddd");
             int wrkMin = CalculateDutyCode(shift, currentDate);
             if (wrkMin == 0)
                 rdaS.DutyCode = "R";
             else
                 rdaS.DutyCode = "D";
             rdaS.DutyDate = currentDate;
             rdaS.DutyTime = shift.StartTime;
             rdaS.WorkMin = wrkMin;
         }
         rda.Add(rdaS);
         currentDate = currentDate.AddDays(1);
     }
     return rda;
 }
Пример #3
0
        private List <RosterDetailAttributes> CalculateRosterDetails(List <Models.RosterDetail> rosterdetails, RosterApp rosterApp)
        {
            //List<RosterDetailModel> rdm = new List<RosterDetailModel>();
            List <RosterDetailAttributes> rda = new List <RosterDetailAttributes>();
            Shift shift = new Shift();

            shift = db.Shifts.First(aa => aa.ShiftID == rosterApp.ShiftID);
            DateTime            currentDate     = rosterApp.DateStarted.Value;
            List <RosterDetail> tempRotaDetails = new List <RosterDetail>();
            string Criteria = "";

            switch (rosterApp.RosterCriteria)
            {
            case "S":
                Criteria = "Applied on Shift: " + rosterApp.Shift.ShiftName;
                break;

            case "T":
                Criteria = "Applied on Section :" + db.Sections.Where(aa => aa.SectionID == rosterApp.CriteriaData).First().SectionName;
                break;

            case "C":
                Criteria = "Applied on Crew :" + db.Crews.Where(aa => aa.CrewID == rosterApp.CriteriaData).First().CrewName;
                break;

            case "E":
                Criteria = "Applied on Employee :" + db.Emps.Where(aa => aa.EmpID == rosterApp.CriteriaData).First().EmpName;
                break;
            }
            string _Date = "Date: " + rosterApp.DateStarted.Value.ToString("dd-MMM-yyyy") + "   TO   " + rosterApp.DateEnded.Value.ToString("dd-MMM-yyyy");

            while (currentDate <= rosterApp.DateEnded)
            {
                RosterDetailAttributes rdaS = new RosterDetailAttributes();
                tempRotaDetails = rosterdetails.Where(aa => aa.RosterDate == currentDate).ToList();
                if (tempRotaDetails.Count > 0)
                {
                    rdaS.Date     = _Date;
                    rdaS.Shift    = rosterApp.Shift.ShiftName;
                    rdaS.Criteria = Criteria;
                    rdaS.Changed  = true;
                    rdaS.Day      = tempRotaDetails.FirstOrDefault().RosterDate.Value.ToString("dddd");
                    rdaS.DutyCode = tempRotaDetails.FirstOrDefault().DutyCode;
                    rdaS.DutyDate = tempRotaDetails.FirstOrDefault().RosterDate.Value;
                    rdaS.DutyTime = (TimeSpan)tempRotaDetails.FirstOrDefault().DutyTime;
                    rdaS.WorkMin  = (short)tempRotaDetails.FirstOrDefault().WorkMin;
                }
                else
                {
                    rdaS.Date     = _Date;
                    rdaS.Shift    = rosterApp.Shift.ShiftName;
                    rdaS.Criteria = Criteria;
                    rdaS.Changed  = false;
                    rdaS.Day      = currentDate.ToString("dddd");
                    int wrkMin = CalculateDutyCode(shift, currentDate);
                    if (wrkMin == 0)
                    {
                        rdaS.DutyCode = "R";
                    }
                    else
                    {
                        rdaS.DutyCode = "D";
                    }
                    rdaS.DutyDate = currentDate;
                    rdaS.DutyTime = shift.StartTime;
                    rdaS.WorkMin  = wrkMin;
                }
                rda.Add(rdaS);
                currentDate = currentDate.AddDays(1);
            }
            return(rda);
        }