private ServiceTermResponse ExecuteCalculateTerms(DateTime startDate, CaseTermInterval termInterval, TimeZoneInfo userTimeZone, CaseTermStates mask) { var calendarutility = new CalendarUtility(UserConnection); var response = new ServiceTermResponse(); response.ReactionTime = mask.HasFlag(CaseTermStates.ContainsResponse) ? calendarutility.Add(startDate, termInterval.ResponseTerm, userTimeZone) as DateTime? : null; response.SolutionTime = mask.HasFlag(CaseTermStates.ContainsResolve) ? calendarutility.Add(startDate, termInterval.ResolveTerm, userTimeZone) as DateTime? : null; return(response); }
private ServiceTermResponse ExecuteRecalculateTerms(DateTime startDate, CaseTermInterval termInterval, IEnumerable <DateTimeInterval> intervals, TimeZoneInfo userTimeZone, CaseTermStates mask) { var calendarutility = new CalendarUtility(UserConnection); var response = new ServiceTermResponse(); var dateTime = ConvertFromUtc(DateTime.UtcNow, userTimeZone); response.ReactionTime = mask.HasFlag(CaseTermStates.ContainsResponse) ? calendarutility.Add(dateTime, termInterval.ResponseTerm, intervals, userTimeZone) as DateTime? : null; response.SolutionTime = mask.HasFlag(CaseTermStates.ContainsResolve) ? calendarutility.Add(dateTime, termInterval.ResolveTerm, intervals, userTimeZone) as DateTime? : null; return(response); }
public DateTime _CalculateTermsByGroup(string groupId, string ServiceId, int indx) { FindGroup(groupId); FindCalendar(ServiceId, indx); var calendarUtility = new CalendarUtility(UserConnection); var startDate = DateTime.Now; TimeTerm ReactionTimeTerm = new TimeTerm(); DateTime ReactionTime = new DateTime(); if (_reactionUnitValue == 0) { // TimeZoneInfo info = System.TimeZoneInfo.Local; // var dateToConvert = DateTime.Now; // DateTime ReactionTime = TimeZoneInfo.ConvertTimeToUtc(dateToConvert, info); ReactionTimeTerm.Type = CalendarTimeUnit.Minute; ReactionTimeTerm.Value = 20; ReactionTimeTerm.CalendarId = new Guid(CalendarId); ReactionTime = calendarUtility.Add(startDate, ReactionTimeTerm, System.TimeZoneInfo.Local); } else { // TimeZoneInfo info = System.TimeZoneInfo.Local; // var _dateToConvert = DateTime.Now; // DateTime nowTime = TimeZoneInfo.ConvertTimeToUtc(_dateToConvert, info); ReactionTimeTerm.Type = CalendarTimeUnit.WorkingMinute; ReactionTimeTerm.Value = _reactionUnitValue; ReactionTimeTerm.CalendarId = new Guid(CalendarId); ReactionTime = calendarUtility.Add(startDate, ReactionTimeTerm, System.TimeZoneInfo.Local); } //string json = JsonConvert.SerializeObject(calculatedDates); return(ReactionTime); }
public DateTime CalculateReactionTimeByDefaultSetting(int SysMinutes) { var calendarUtility = new CalendarUtility(UserConnection); var startDate = DateTime.Now; TimeTerm ReactionTimeTerm = new TimeTerm(); DateTime ReactionTime = new DateTime(); ReactionTimeTerm.Type = CalendarTimeUnit.WorkingMinute; ReactionTimeTerm.Value = SysMinutes; ReactionTimeTerm.CalendarId = new Guid(CalendarId); ReactionTime = calendarUtility.Add(startDate, ReactionTimeTerm, System.TimeZoneInfo.Local); return(ReactionTime); }
public DateTime AddMinutesInPauseToSolutionDate(DateTime SolDate, int value) { TimeTerm timeTerm = new TimeTerm(); timeTerm.Type = CalendarTimeUnit.WorkingMinute; timeTerm.Value = value; timeTerm.CalendarId = new Guid(CalendarId); var calendarUtility = new CalendarUtility(UserConnection); CalculatedDates calculatedDates = new CalculatedDates(); DateTime SolutionTime = calendarUtility.Add(SolDate, timeTerm, System.TimeZoneInfo.Local); //string json = JsonConvert.SerializeObject(calculatedDates); return(SolutionTime); }
public DateTime CalculateArchiveTime(int wHours, string ServiceId, int indx) { FindCalendar(ServiceId, indx); var calendarUtility = new CalendarUtility(UserConnection); var startDate = DateTime.Now; TimeTerm ReactionTimeTerm = new TimeTerm(); DateTime ReactionTime = new DateTime(); ReactionTimeTerm.Type = CalendarTimeUnit.WorkingHour; ReactionTimeTerm.Value = wHours; ReactionTimeTerm.CalendarId = new Guid(CalendarId); ReactionTime = calendarUtility.Add(startDate, ReactionTimeTerm, System.TimeZoneInfo.Local); return(ReactionTime); }
public DateTime _CalculateTerms(string ITServiceId, string categoryname) { FindITService(ITServiceId, categoryname); TimeTerm timeTerm = new TimeTerm(); if (_solutionUnitType == "bdcbb819-9b26-4627-946f-d00645a2d401") { //Для рабочего дня timeTerm.Type = CalendarTimeUnit.WorkingDay; } else if (_solutionUnitType == "2a608ed7-d118-402a-99c0-2f583291ed2e") { //Для рабочего часа timeTerm.Type = CalendarTimeUnit.WorkingHour; } else if (_solutionUnitType == "3ab432a6-ca84-4315-ba33-f343c758a8f0") { //Для рабочей минуты timeTerm.Type = CalendarTimeUnit.WorkingMinute; } else { return(DateTime.MinValue); } timeTerm.Value = _solutionUnitValue; timeTerm.CalendarId = new Guid(CalendarId); var calendarUtility = new CalendarUtility(UserConnection); var startDate = DateTime.Now; CalculatedDates calculatedDates = new CalculatedDates(); DateTime SolutionTime = calendarUtility.Add(startDate, timeTerm, System.TimeZoneInfo.Local); //string json = JsonConvert.SerializeObject(calculatedDates); return(SolutionTime); }
public DateTime Add(ICalendar <ICalendarDay> calendar, DateTime date, TimeUnit timeUnit, int value) { var utility = new CalendarUtility(calendar); return(utility.Add(date, timeUnit, value)); }
public DateTime Add(Guid calendarId, DateTime date, TimeUnit timeUnit, int value) { var utility = new CalendarUtility(calendarId, UserConnection); return(utility.Add(date, timeUnit, value)); }
public string PercentDiff(string ITServiceId, string GroupId, string dateInput, int timeinpause, string categoryname, int indx) { DateTime RegTime = DateTime.Parse(dateInput); FindCalendar(ITServiceId, indx); if (indx == 0) { FindITService(ITServiceId, categoryname); } else if (indx == 1) { FindTechService(ITServiceId, categoryname); } else { string errormes = "Не найдены сервисы по индексу: " + indx.ToString(); return(errormes); } TimeTerm timeTerm = new TimeTerm(); if (_solutionUnitType == "bdcbb819-9b26-4627-946f-d00645a2d401") { //Для рабочего дня timeTerm.Type = CalendarTimeUnit.WorkingMinute; _solutionUnitValue = _solutionUnitValue * 60 * 24; } else if (_solutionUnitType == "2a608ed7-d118-402a-99c0-2f583291ed2e") { //Для рабочего часа timeTerm.Type = CalendarTimeUnit.WorkingMinute; _solutionUnitValue = _solutionUnitValue * 60; } else if (_solutionUnitType == "3ab432a6-ca84-4315-ba33-f343c758a8f0") { //Для рабочей минуты timeTerm.Type = CalendarTimeUnit.WorkingMinute; } else { string errormes = "Единица времени по категории не найдена: " + categoryname; return(errormes); } var calendarUtility = new CalendarUtility(UserConnection); var startDate = DateTime.Now; int _solutionUnitValue50 = _solutionUnitValue / 2; timeTerm.Value = _solutionUnitValue50; timeTerm.CalendarId = new Guid(CalendarId); timeinpause = timeinpause; CalculatedDates calculatedDates = new CalculatedDates(); calculatedDates.SolutionTime = calendarUtility.Add(RegTime, timeTerm, System.TimeZoneInfo.Local); if (timeinpause != 0 && timeinpause != null) { calculatedDates.SolutionTime = AddMinutesInPauseToSolutionDate(calculatedDates.SolutionTime, timeinpause); } int _solutionUnitValue70 = Convert.ToInt16(_solutionUnitValue * 0.70); TimeTerm ReactionTimeTerm = new TimeTerm(); ReactionTimeTerm.Value = _solutionUnitValue70; ReactionTimeTerm.CalendarId = new Guid(CalendarId); ReactionTimeTerm.Type = CalendarTimeUnit.WorkingMinute; calculatedDates.ReactionTime = calendarUtility.Add(RegTime, ReactionTimeTerm, System.TimeZoneInfo.Local); if (timeinpause != 0 && timeinpause != null) { calculatedDates.ReactionTime = AddMinutesInPauseToSolutionDate(calculatedDates.ReactionTime, timeinpause); } string json = JsonConvert.SerializeObject(calculatedDates); return(json); }
public string CalculateTerms(string ITServiceId, string GroupId, string dateInput, int timeinpause, string categoryname, int indx) { DateTime RegTime = DateTime.Parse(dateInput); FindCalendar(ITServiceId, indx); if (indx == 0) { FindITService(ITServiceId, categoryname); } else if (indx == 1) { FindTechService(ITServiceId, categoryname); } else { string errormes = "Не найдены сервисы по индексу: " + indx.ToString(); return(errormes); } //GroupId = "b157e016-99d0-4eb1-8096-3fda7af06210"; //_solutionUnitType = "bdcbb819-9b26-4627-946f-d00645a2d401"; //_solutionUnitValue = 2; TimeTerm timeTerm = new TimeTerm(); if (_solutionUnitType == "bdcbb819-9b26-4627-946f-d00645a2d401") { //Для рабочего дня timeTerm.Type = CalendarTimeUnit.WorkingDay; } else if (_solutionUnitType == "2a608ed7-d118-402a-99c0-2f583291ed2e") { //Для рабочего часа timeTerm.Type = CalendarTimeUnit.WorkingHour; } else if (_solutionUnitType == "3ab432a6-ca84-4315-ba33-f343c758a8f0") { //Для рабочей минуты timeTerm.Type = CalendarTimeUnit.WorkingMinute; } else { string errormes = "Единица времени по категории не найдена: " + categoryname; return(errormes); } timeTerm.Value = _solutionUnitValue; timeTerm.CalendarId = new Guid(CalendarId); var calendarUtility = new CalendarUtility(UserConnection); var startDate = DateTime.Now; timeinpause = timeinpause; CalculatedDates calculatedDates = new CalculatedDates(); calculatedDates.SolutionTime = calendarUtility.Add(RegTime, timeTerm, System.TimeZoneInfo.Local); if (timeinpause != 0 && timeinpause != null) { calculatedDates.SolutionTime = AddMinutesInPauseToSolutionDate(calculatedDates.SolutionTime, timeinpause); } //FindGroup(GroupId); TimeTerm ReactionTimeTerm = new TimeTerm(); if (_reactionUnitValue == 0) { //Id указан группы "Диспетчеры" т.к. она по умолчанию, а так же если группа не указана в справочнике _reactionUnitValue == 0 // TimeZoneInfo info = System.TimeZoneInfo.Local; // var dateToConvert = DateTime.Now; // DateTime ReactionTime = TimeZoneInfo.ConvertTimeToUtc(dateToConvert, info); ReactionTimeTerm.Type = CalendarTimeUnit.Minute; ReactionTimeTerm.Value = 20; ReactionTimeTerm.CalendarId = new Guid(CalendarId); calculatedDates.ReactionTime = calendarUtility.Add(startDate, ReactionTimeTerm, System.TimeZoneInfo.Local); } else { // TimeZoneInfo info = System.TimeZoneInfo.Local; // var _dateToConvert = DateTime.Now; // DateTime nowTime = TimeZoneInfo.ConvertTimeToUtc(_dateToConvert, info); ReactionTimeTerm.Type = CalendarTimeUnit.WorkingMinute; ReactionTimeTerm.Value = _reactionUnitValue; ReactionTimeTerm.CalendarId = new Guid(CalendarId); calculatedDates.ReactionTime = calendarUtility.Add(startDate, ReactionTimeTerm, System.TimeZoneInfo.Local); } string json = JsonConvert.SerializeObject(calculatedDates); return(json); }