private async Task <ClusterOperationError> ClusterTask(Func <Task> task, ClusterOperation operation, bool treatErrorsAsTransient = false)
        {
            try
            {
                await task();
            }
            catch (Exception ex)
            {
                return(new ClusterOperationError
                {
                    Operation = operation,
                    Transient = treatErrorsAsTransient || IsTransientException(ex),
                    ErrorDetails = JObject.FromObject(ex)
                });
            }

            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Detect expressions that are being clustered (grouped by month, etc) and convert them to clustering expressions.
        /// </summary>
        /// <param name="scalarExpression"></param>
        /// <param name="reportExpression"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        private static void ApplyExpressionClustering(ScalarExpression scalarExpression, ReportExpression reportExpression, FromEntityContext context)
        {
            if (reportExpression == null || scalarExpression == null)
            {
                return;
            }

            var reportColumn = reportExpression.ExpressionForColumn;

            var displayFormat = reportColumn?.ColumnDisplayFormat;

            if (displayFormat == null)
            {
                return;
            }

            ClusterOperation oper = ClusterOperation.None;

            if (displayFormat.DateColumnFormat_Enum != null)
            {
                switch (displayFormat.DateColumnFormat_Enum)
                {
                case DateColFmtEnum_Enumeration.DateDayMonth: oper = ClusterOperation.Day | ClusterOperation.Month; break;

                case DateColFmtEnum_Enumeration.DateMonth: oper = ClusterOperation.Month; break;

                case DateColFmtEnum_Enumeration.DateMonthYear: oper = ClusterOperation.Month | ClusterOperation.Year; break;

                case DateColFmtEnum_Enumeration.DateQuarter: oper = ClusterOperation.Quarter; break;

                case DateColFmtEnum_Enumeration.DateQuarterYear: oper = ClusterOperation.Quarter | ClusterOperation.Year; break;

                case DateColFmtEnum_Enumeration.DateYear: oper = ClusterOperation.Year; break;

                case DateColFmtEnum_Enumeration.DateWeekday: oper = ClusterOperation.Weekday; break;

                case DateColFmtEnum_Enumeration.DateLong:
                case DateColFmtEnum_Enumeration.DateShort:
                default:
                    oper = ClusterOperation.None; break;
                }
            }
            if (displayFormat.TimeColumnFormat_Enum != null)
            {
                switch (displayFormat.TimeColumnFormat_Enum)
                {
                case TimeColFmtEnum_Enumeration.TimeHour: oper = ClusterOperation.Hour; break;

                default:
                    oper = ClusterOperation.None; break;
                }
            }
            if (displayFormat.DateTimeColumnFormat_Enum != null)
            {
                switch (displayFormat.DateTimeColumnFormat_Enum)
                {
                case DateTimeColFmtEnum_Enumeration.DateTimeDayMonth: oper = ClusterOperation.Day | ClusterOperation.Month; break;

                case DateTimeColFmtEnum_Enumeration.DateTimeMonth: oper = ClusterOperation.Month; break;

                case DateTimeColFmtEnum_Enumeration.DateTimeMonthYear: oper = ClusterOperation.Month | ClusterOperation.Year; break;

                case DateTimeColFmtEnum_Enumeration.DateTimeQuarter: oper = ClusterOperation.Quarter; break;

                case DateTimeColFmtEnum_Enumeration.DateTimeQuarterYear: oper = ClusterOperation.Quarter | ClusterOperation.Year; break;

                case DateTimeColFmtEnum_Enumeration.DateTimeYear: oper = ClusterOperation.Year; break;

                case DateTimeColFmtEnum_Enumeration.DateTimeWeekday: oper = ClusterOperation.Weekday; break;

                case DateTimeColFmtEnum_Enumeration.DateTimeDate: oper = ClusterOperation.Year | ClusterOperation.Month | ClusterOperation.Day; break;

                case DateTimeColFmtEnum_Enumeration.DateTimeTime: oper = ClusterOperation.Hour | ClusterOperation.Minute | ClusterOperation.Second; break;

                case DateTimeColFmtEnum_Enumeration.DateTimeHour: oper = ClusterOperation.Hour; break;

                case DateTimeColFmtEnum_Enumeration.DateTime24Hour:
                case DateTimeColFmtEnum_Enumeration.DateTimeDayMonthTime:
                case DateTimeColFmtEnum_Enumeration.DateTimeLong:
                case DateTimeColFmtEnum_Enumeration.DateTimeShort:
                case DateTimeColFmtEnum_Enumeration.DateTimeSortable:
                default:
                    oper = ClusterOperation.None; break;
                }
            }

            scalarExpression.ClusterOperation = oper;
        }
Ejemplo n.º 3
0
 public void set(String name, ClusterOperation operation,
     byte[] key, byte[] value)
 {
     this.name = name;
     this.operation = (byte)operation;
     this.key = key;
     this.value = value;
     this.threadId = Thread.CurrentThread.ManagedThreadId;
 }