public static SlaPausedTim GetSlaPausedTim(LoginUser loginUser, int id) { SlaPausedTimes slaPausedTimes = new SlaPausedTimes(loginUser); slaPausedTimes.LoadById(id); if (slaPausedTimes.IsEmpty) { return(null); } else { return(slaPausedTimes[0]); } }
public static TimeSpan CalculatePausedTime(int ticketId, Organization organization, BusinessHours businessHours, SlaTrigger slaTrigger, List <DateTime> daysToPause, CalendarEvents holidays, LoginUser loginUser, Dictionary <int, double> businessPausedTimes, Logs logs = null, bool overwritePrevious = false, DateTime?startOn = null) { TimeSpan totalPausedTime = new TimeSpan(); SlaPausedTimes slaPausedTimes = new SlaPausedTimes(loginUser); slaPausedTimes.LoadByTicketId(ticketId, startOn); foreach (SlaPausedTime slaPausedTime in slaPausedTimes) { bool hasBeenCalculated = slaPausedTime.BusinessPausedTime != null; if (!hasBeenCalculated || (hasBeenCalculated && overwritePrevious)) { TimeSpan rangePausedTime = SlaPausedTimes.CalculatePausedTime(loginUser, organization, slaTrigger, slaPausedTime.PausedOnUtc, (DateTime)slaPausedTime.ResumedOnUtc, businessHours, daysToPause, holidays, logs); totalPausedTime = totalPausedTime.Add(rangePausedTime); //return the results to stored them in the db. businessPausedTimes.Add(slaPausedTime.Id, rangePausedTime.TotalSeconds); } else if (hasBeenCalculated && !overwritePrevious) { TimeSpan previouslyCalculatedPausedTime = TimeSpan.FromSeconds((int)slaPausedTime.BusinessPausedTime); totalPausedTime = totalPausedTime.Add(previouslyCalculatedPausedTime); } } return(totalPausedTime); }
public SlaPausedTim(DataRow row, SlaPausedTimes slaPausedTimes) : base(row, slaPausedTimes) { _slaPausedTimes = slaPausedTimes; }