Esempio n. 1
0
 private bool IsResponseTimeTerm(CaseTermInterval termInterval)
 {
     return(termInterval.ResponseTerm != null &&
            termInterval.ResponseTerm.Type != default(CalendarsTimeUnit) &&
            termInterval.ResponseTerm.Value > 0 &&
            _logStore.CalculationTermKind == CaseTermStates.ContainsResponse);
 }
        /// <summary>
        /// Method that returns time interval for calculation
        /// </summary>
        /// <param name="arguments">Arguments for strategies.</param>
        /// <returns>Time interval.</returns>
        public virtual ITermInterval <CaseTermStates> Get(Dictionary <string, object> arguments)
        {
            CaseTermInterval result = new CaseTermInterval();
            var strategyQueue       = ClassFactory.Get <CaseTermStrategyQueue>(
                new ConstructorArgument("userConnection", UserConnection));
            var strategyManager = ClassFactory.Get <CaseTermStrategyManager>();
            var className       = strategyQueue.Dequeue();
            var preferableFlags = CaseTermStates.ContainsResolve | CaseTermStates.ContainsResponse;

            while (className != null && !result.GetMask().HasFlag(preferableFlags))
            {
                var strategy = strategyManager.GetItem(className, arguments, UserConnection);
                className = strategyQueue.Dequeue();
                CaseTermStates currentMask = result.GetMask();
                try {
                    CaseTermInterval term     = strategy.GetTermInterval(currentMask);
                    CaseTermStates   termMask = term.GetMask();
                    if (!currentMask.HasFlag(CaseTermStates.ContainsResolve) &&
                        termMask.HasFlag(CaseTermStates.ContainsResolve))
                    {
                        result.ResolveTerm = term.ResolveTerm;
                    }
                    if (!currentMask.HasFlag(CaseTermStates.ContainsResponse) &&
                        termMask.HasFlag(CaseTermStates.ContainsResponse))
                    {
                        result.ResponseTerm = term.ResponseTerm;
                    }
                } catch {
                    continue;
                }
            }
            return(result);
        }
Esempio n. 3
0
 /// <summary>
 /// Gets state of case term.
 /// </summary>
 /// <returns>State of case term.</returns>
 public CaseTermStates GetCaseTermState(CaseTermInterval termInterval)
 {
     if (IsResponseTimeTerm(termInterval))
     {
         return(CaseTermStates.ContainsResponse);
     }
     if (IsResolveTimeTerm(termInterval))
     {
         return(CaseTermStates.ContainsResolve);
     }
     return(CaseTermStates.None);
 }
        /// <summary>
        /// Method that returns time interval for calculation
        /// </summary>
        /// <param name="arguments">Arguments for strategies.</param>
        /// <returns>Time interval.</returns>
        public virtual ITermInterval <CaseTermStates> Get(Dictionary <string, object> arguments)
        {
            CaseTermInterval result = new CaseTermInterval();
            var strategyQueue       = ClassFactory.Get <CaseTermStrategyQueue>(
                new ConstructorArgument("userConnection", UserConnection));
            var strategyManager = ClassFactory.Get <CaseTermStrategyManager>();
            var className       = strategyQueue.Dequeue();
            var preferableFlags = CaseTermStates.ContainsResolve | CaseTermStates.ContainsResponse;

            while (className != null && !result.GetMask().HasFlag(preferableFlags))
            {
                var            strategy    = strategyManager.GetItem(className, arguments, UserConnection);
                CaseTermStates currentMask = result.GetMask();
                try {
                    CaseTermInterval term     = strategy.GetTermInterval(currentMask);
                    CaseTermStates   termMask = term.GetMask();
                    if (!currentMask.HasFlag(CaseTermStates.ContainsResolve) &&
                        termMask.HasFlag(CaseTermStates.ContainsResolve))
                    {
                        if (_calculationLogStore != null &&
                            _calculationLogStore.CalculationTermKind == CaseTermStates.ContainsResolve)
                        {
                            _calculationLogStore.SelectedStrategy =
                                _calculationLogStore.CalculationStrategyRules.Find(item => item.StrategyClassName == className);
                            _calculationLogStore.TimeTerm = term.ResolveTerm.NativeTimeTerm ?? term.ResolveTerm;
                        }
                        result.ResolveTerm = term.ResolveTerm;
                    }
                    if (!currentMask.HasFlag(CaseTermStates.ContainsResponse) &&
                        termMask.HasFlag(CaseTermStates.ContainsResponse))
                    {
                        if (_calculationLogStore != null &&
                            _calculationLogStore.CalculationTermKind == CaseTermStates.ContainsResponse)
                        {
                            _calculationLogStore.SelectedStrategy =
                                _calculationLogStore.CalculationStrategyRules.Find(item => item.StrategyClassName == className);
                            _calculationLogStore.TimeTerm = term.ResponseTerm.NativeTimeTerm ?? term.ResponseTerm;
                        }
                        result.ResponseTerm = term.ResponseTerm;
                    }
                } catch {
                    className = strategyQueue.Dequeue();
                    continue;
                }
                className = strategyQueue.Dequeue();
            }
            return(result);
        }
Esempio n. 5
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);
        }