/// <summary>
        /// Calculate completeness value from detail.
        /// </summary>
        /// <param name="param">Completeness parameter for detail completeness.</param>
        /// <param name="recordId">Record id.</param>
        /// <returns>Completeness value.</returns>
        protected int GetCompletenessFromDetail(CompletenessParameter param, Guid recordId)
        {
            int    detailCompleteness = 0;
            Select entitiesSelect     =
                new Select(AppConnection.SystemUserConnection)
                .Column(Func.Count(param.DetailColumn))
                .From(param.DetailEntityName)
                .Where(param.DetailColumn).IsEqual(new QueryParameter(recordId)) as Select;

            if (!string.IsNullOrEmpty(param.TypeColumn) && !param.TypeValue.IsEmpty())
            {
                var typeCondition = new QueryCondition {
                    LeftExpression = new QueryColumnExpression(param.TypeColumn)
                };
                typeCondition.In(new QueryParameter(param.TypeValue));
                entitiesSelect.AddCondition(typeCondition, LogicalOperation.And);
            }
            entitiesSelect.SpecifyNoLockHints();
            using (DBExecutor dbExecutor = EnsureSystemUserDbConnection()) {
                using (IDataReader dataReader = entitiesSelect.ExecuteReader(dbExecutor)) {
                    while (dataReader.Read())
                    {
                        if (Convert.ToInt32(dataReader.GetValue(0)) > 0)
                        {
                            detailCompleteness = param.Percentage;
                        }
                    }
                }
            }
            return(detailCompleteness);
        }
 public CompletenessParameter(CompletenessParameter source)
     : base(source)
 {
 }
Пример #3
0
 public CompletenessParameter(Terrasoft.Configuration.CompletenessParameter source)
     : base(source)
 {
     this.CopyEntityLookupProperties(source);
 }