Esempio n. 1
0
        /// <summary>
        /// Adds time columns to given entity schema query.
        /// </summary>
        /// <param name="esq">Reference to <seealso cref="EntitySchemaQuery"/> instance.</param>
        /// <returns>Added time column data.</returns>
        protected TimeColumnData AddTimeColumns(ref EntitySchemaQuery esq)
        {
            var timeColumns = new TimeColumnData {
                ReactionColumn = new TimeColumn {
                    UnitCode = esq.AddColumn("ReactionTimeUnit.Code").Name,
                    Value    = esq.AddColumn("ReactionTimeValue").Name
                },
                SolutionColumn = new TimeColumn {
                    UnitCode = esq.AddColumn("SolutionTimeUnit.Code").Name,
                    Value    = esq.AddColumn("SolutionTimeValue").Name
                }
            };

            return(timeColumns);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns 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();
            Guid calendarId = GetCalendarId();

            if (calendarId == default(Guid))
            {
                return(result);
            }
            var            esq         = new EntitySchemaQuery(UserConnection.EntitySchemaManager, EntitySchemaName);
            TimeColumnData timeColumns = AddTimeColumns(ref esq);

            ApplyFilters(ref esq);
            EntityCollection entityCollection = esq.GetEntityCollection(UserConnection);

            if (entityCollection.IsNotEmpty())
            {
                result = PrepareResult(entityCollection[0], state, timeColumns, calendarId);
            }
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns time interval for this strategy.
        /// </summary>
        /// <param name="mask">Flags which indicate which values are already filled.</param>
        /// <returns>Time interval.</returns>
        public override CaseTermInterval GetTermInterval(CaseTermStates mask)
        {
            var            result             = new CaseTermInterval();
            var            esq                = new EntitySchemaQuery(UserConnection.EntitySchemaManager, EntitySchemaName);
            TimeColumnData timeColumns        = AddTimeColumns(ref esq);
            string         calendarColumnName = esq.AddColumn("Calendar.Id").Name;

            ApplyFilters(ref esq);
            EntityCollection entityCollection = esq.GetEntityCollection(UserConnection);

            if (entityCollection.IsNotEmpty())
            {
                var  entity     = entityCollection[0];
                Guid calendarId = entity.GetTypedColumnValue <Guid>(calendarColumnName) == default(Guid) ?
                                  GetCalendarId() : entity.GetTypedColumnValue <Guid>(calendarColumnName);
                if (calendarId == default(Guid))
                {
                    return(result);
                }
                result = PrepareResult(entity, mask, timeColumns, calendarId);
            }
            return(result);
        }
Esempio n. 4
0
        /// <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);
        }