コード例 #1
0
    public static IEnumerable <ShiftWorkItem> EnumerateShifts(this ShiftConfig config, DateTime from, DateTime until)
    {
        DateTime  day        = from.Date.AddDays(-1);
        DateTime? shiftStart = null;
        ShiftInfo lastShift  = null;

        while (true)
        {
            foreach (var shift in config)
            {
                var shiftEnd = day.Add(shift.StartTime);
                if (shiftStart != null)
                {
                    if ((shiftStart.Value <= from && shiftEnd >= from) || (shiftStart.Value <= until && shiftEnd >= until) || (shiftStart.Value > from && shiftEnd <= until))
                    {
                        var workFrom  = shiftStart.Value < from ? from : shiftStart.Value;
                        var workUntil = shiftEnd > until ? until : shiftEnd;
                        yield return(new ShiftWorkItem(lastShift, shiftStart.Value, shiftEnd, workFrom, workUntil));
                    }
                }

                if (shiftEnd >= until)
                {
                    yield break;
                }

                shiftStart = shiftEnd;
                lastShift  = shift;
            }

            day = day.AddDays(1);
        }
    }
コード例 #2
0
 public JobController(IMemoryCache cache, IOptions <ShiftConfig> settings)
 {
     _settings = settings.Value;
     if (jobClient == null)
     {
         jobClient = cache.Get("Shift.JobClient") as JobClient;
     }
 }
コード例 #3
0
        public ShiftConfig PostShiftConfigData(saveShiftConfig data)
        {
            ShiftConfig SR = new ShiftConfig();

            try
            {
                string Details = JsonConvert.SerializeObject(data.details);
                db.HRP_Cnf_ShiftConfig_Save(data.head.year, data.head.workLocation, data.head.startdate, data.head.shiftdays, data.head.startshift, Details);
                SR.status = 1; SR.message = "Saved Successfully!!";

                return(SR);
            }
            catch (Exception ex)
            {
                SR.message = "Error Occured in Configuring Shift Details"; SR.status = 0;
                return(SR);
            }
        }
コード例 #4
0
        public ShiftConfig GetShiftConfigData(int year, int location)
        {
            ShiftConfig SR = new ShiftConfig();

            try
            {
                SR.status  = 1;
                SR.head    = db.HRP_Cnf_ShiftConfigHead_GetAll(year, location).ToList();
                SR.details = db.HRP_Cnf_ShiftConfigDetails_GetAll(year, location).ToList();

                return(SR);
            }
            catch
            {
                SR.message = "Error Occured in fetching Existing Data!"; SR.status = 0;
                return(SR);
            }
        }
コード例 #5
0
 public static IEnumerable <ShiftWorkItem> EnumerateShifts(this ShiftConfig config, DateTime from, TimeSpan duration)
 {
     return(EnumerateShifts(config, from, from.Add(duration)));
 }