/// <summary> /// Prepares result as an interval (<seealso cref="CaseTermInterval"/>). /// </summary> /// <param name="entity">Entity.</param> /// <param name="state">Case term state.</param> /// <param name="timeColumns">Time columns.</param> /// <param name="calendarId">Calendar identifier.</param> /// <returns>Case term interval.</returns> protected CaseTermInterval PrepareResult(Entity entity, CaseTermStates state, TimeColumnData timeColumns, Guid calendarId) { var result = new CaseTermInterval(); if (!state.HasFlag(CaseTermStates.ContainsResponse)) { var reactionTimeUnitName = entity.GetTypedColumnValue <string>(timeColumns.ReactionColumn.UnitCode); CalendarsTimeUnit timeUnit; Enum.TryParse(reactionTimeUnitName, out timeUnit); var term = new TimeTerm { Type = timeUnit, Value = entity.GetTypedColumnValue <int>(timeColumns.ReactionColumn.Value), CalendarId = calendarId }; result.ResponseTerm = term.ConvertToMinutes(); } if (!state.HasFlag(CaseTermStates.ContainsResolve)) { var solutionTimeUnitName = entity.GetTypedColumnValue <string>(timeColumns.SolutionColumn.UnitCode); CalendarsTimeUnit timeUnit; Enum.TryParse(solutionTimeUnitName, out timeUnit); var term = new TimeTerm { Type = timeUnit, Value = entity.GetTypedColumnValue <int>(timeColumns.SolutionColumn.Value), CalendarId = calendarId }; result.ResolveTerm = term.ConvertToMinutes(); } return(result); }
private TimeTerm GetTerm(Entity entity, string timeUnitColumnName, string timeValueColumnName, Guid calendarId) { var term = new TimeTerm(); var timeUnitName = entity.GetTypedColumnValue <string>(timeUnitColumnName); CalendarsTimeUnit timeUnit; if (Enum.TryParse(timeUnitName, out timeUnit)) { term.Type = timeUnit; } term.Value = entity.GetTypedColumnValue <int>(timeValueColumnName); term.CalendarId = calendarId; return(term.ConvertToMinutes()); }
/// <summary> /// Method that returns case term interval for calculation. /// </summary> /// <param name="mask">Mask for case term interval.</param> /// <returns>Case term interval.</returns> public override CaseTermInterval GetTermInterval(CaseTermStates mask) { CaseTermInterval result = new CaseTermInterval(); EntitySchemaQuery esqTimeToPrioritize = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "TimeToPrioritize"); IntervalColumnsNames names = PrepareEntitySchemaQuery(esqTimeToPrioritize, mask); var entityCollection = esqTimeToPrioritize.GetEntityCollection(UserConnection); if (entityCollection.IsEmpty()) { return(result); } Entity entity = entityCollection[0]; var entityCalendar = entity.GetTypedColumnValue <Guid>(names.Calendar); var calendarId = entityCalendar != Guid.Empty ? entityCalendar : GetCalendar(); if (calendarId == Guid.Empty) { return(result); } if (!mask.HasFlag(CaseTermStates.ContainsResponse)) { var reactionTimeUnitName = entity.GetTypedColumnValue <string>(names.ReactionType); var timeUnit = default(CalendarsTimeUnit); var term = new TimeTerm(); if (Enum.TryParse <CalendarsTimeUnit>(reactionTimeUnitName, out timeUnit)) { term.Type = timeUnit; } term.Value = entity.GetTypedColumnValue <int>(names.ReactionValue); term.CalendarId = calendarId; result.ResponseTerm = term.ConvertToMinutes(); } if (!mask.HasFlag(CaseTermStates.ContainsResolve)) { var solutionTimeUnitName = entity.GetTypedColumnValue <string>(names.SolutionType); var timeUnit = default(CalendarsTimeUnit); var term = new TimeTerm(); if (Enum.TryParse <CalendarsTimeUnit>(solutionTimeUnitName, out timeUnit)) { term.Type = timeUnit; } term.Value = entity.GetTypedColumnValue <int>(names.SolutionValue); term.CalendarId = calendarId; result.ResolveTerm = term.ConvertToMinutes(); } return(result); }
/// <summary> /// Gets case term interval for this strategy. /// </summary> /// <param name="state">Case term state.</param> /// <returns>Case term interval.</returns> public override CaseTermInterval GetTermInterval(CaseTermStates state) { var result = new CaseTermInterval(); var esq = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "ServiceItem"); TimeUnitColumnsNames names = PrepareEntitySchemaQuery(esq, state); var serviceItem = esq.GetEntity(UserConnection, _serviceDataModel.ServiceItemId); if (serviceItem == null) { return(result); } var serviceItemCalendar = serviceItem.GetTypedColumnValue <Guid>("CalendarId"); var calendarId = serviceItemCalendar != default(Guid) ? serviceItemCalendar : GetCalendarBySysSetting(); if (calendarId == default(Guid)) { return(result); } if (!state.HasFlag(CaseTermStates.ContainsResponse)) { var term = new TimeTerm(); var reactionTimeUnitName = serviceItem.GetTypedColumnValue <string>(names.ReactionType); CalendarsTimeUnit timeUnit; if (Enum.TryParse(reactionTimeUnitName, out timeUnit)) { term.Type = timeUnit; } term.Value = serviceItem.GetTypedColumnValue <int>("ReactionTimeValue"); term.CalendarId = calendarId; result.ResponseTerm = term.ConvertToMinutes(); } if (!state.HasFlag(CaseTermStates.ContainsResolve)) { var term = new TimeTerm(); var solutionTimeUnitName = serviceItem.GetTypedColumnValue <string>(names.SolutionType); CalendarsTimeUnit timeUnit; if (Enum.TryParse(solutionTimeUnitName, out timeUnit)) { term.Type = timeUnit; } term.Value = serviceItem.GetTypedColumnValue <int>("SolutionTimeValue"); term.CalendarId = calendarId; result.ResolveTerm = term.ConvertToMinutes(); } return(result); }