Пример #1
0
 public ProductCategoryAPIController(IProductCategoryService _categoryService, IAscending _ascending, ICount _count, IPageNumber _number, ISize _size, IItemSearch _itemSearch)
 {
     this.categoryService = _categoryService;
     this.ascending       = _ascending;
     this.count           = _count;
     this.number          = _number;
     this.size            = _size;
     this.itemSearch      = _itemSearch;
 }
Пример #2
0
 public ProductCategoryRepository(IRepository <ProductCategoryEntity> repository, IAscending _ascending, ICount _count, IPageNumber _number, ISize _size, IItemSearch _itemSearch)
 {
     this.Repository = repository;
     this.ascending  = _ascending;
     this.count      = _count;
     this.number     = _number;
     this.size       = _size;
     this.itemSearch = _itemSearch;
 }
Пример #3
0
 public ProductController(IProductService _service, IRepository <ProductCategoryEntity> _categoryRepository, IAscending _ascending, ICount _count, IPageNumber _number, ISize _size, IItemSearch _itemSearch)
 {
     this.service            = _service;
     this.categoryRepository = _categoryRepository;
     this.ascending          = _ascending;
     this.count      = _count;
     this.number     = _number;
     this.size       = _size;
     this.itemSearch = _itemSearch;
 }
Пример #4
0
        private static ICount InitializeCounters(out ICount recievedWarningCount, out ICount targetErrorCount,
                                                 out ICount targetWarningCount)
        {
            ICount recievedErrorCount = new CountRecievedError();

            recievedWarningCount = new CountRecievedWarning();
            targetErrorCount     = new CountTargetError();
            targetWarningCount   = new CountTargetWarning();
            return(recievedErrorCount);
        }
Пример #5
0
        public BaseNpa(IDataAccess iDataAccess)
        {
            mType        = typeof(T);
            TAG          = this.GetType().ToString();
            mIDataAccess = iDataAccess;
            mIDataAccess.setLog(this.GetType());
            MemberInfo memberInfo = mType;

            try
            {
                Table entity = (Attribute.GetCustomAttribute(memberInfo, typeof(Table)) as Table);
                entity.setType(mType);
                mTable  = entity.Name;
                mScheme = entity.Scheme;
            }
            catch (Exception ex)
            {
                throw new Exception(TAG + "获取映射表名异常:" + memberInfo.Name + " " + ex.Message);
            }

            PropertyInfo[] propertyInfos = mType.GetProperties();
            columnsDic = new Dictionary <String, IColumn>(propertyInfos.Length);
            foreach (PropertyInfo pi in propertyInfos)
            {
                try
                {
                    Attribute attr = Attribute.GetCustomAttribute(pi, typeof(BaseColumn));
                    if (attr != null)
                    {
                        IColumn column = attr as IColumn;
                        column.setPropertyInfo(pi);
                        columnsDic[pi.Name] = column;
                        if (column.isIdColumn())
                        {
                            idList.Add(column);
                        }
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(String.Format("{0} 获取类 {1} 的属性 {2} 注解异常:{3}", TAG, mType.Name, pi.Name, e.Message));
                }
            }
            mISave     = new Insert <T>(mScheme, mTable, columnsDic, idList, TAG);
            mIUpdate   = new Update <T>(mScheme, mTable, columnsDic, idList, TAG);
            mIDelete   = new Delete <T>(mScheme, mTable, columnsDic, idList, TAG);
            mISelect   = new Select <T>(mScheme, mTable, columnsDic, TAG);
            mICount    = new Count <T>(mScheme, mTable, columnsDic, idList, TAG);
            mIGenerate = new Generate <T>(columnsDic, TAG);
            mICreate   = new Creator();
        }
Пример #6
0
 public ICountedConfig GetConfig(ICountedEntity <TEntityType> entity, TCountType measure)
 {
     ArgumentValidator.ThrowIfNull("entity", entity);
     CountTracker <TEntityType, TCountType> .EntityValue entityValue;
     if (this.entities.TryGetValue(entity.Name, out entityValue))
     {
         ICount <TEntityType, TCountType> usage = entityValue.GetUsage(measure);
         if (usage != null)
         {
             return(usage.Config);
         }
     }
     return(null);
 }
Пример #7
0
        public string GenerateAutoID(string PrefixString, string TableName, string TableFieldName)
        {
            double ICount;

            oDataSet = new DataSet();
            oDataSet = SQLResult("Select " + TableFieldName + " from " + TableName + " where " + TableFieldName + " like '%" + PrefixString + "%'  order by right(" + TableFieldName + ",5)");
            if (oDataSet.Tables[0].Rows.Count > 0)
            {
                ICount       = int.Parse(oDataSet.Tables[0].Rows[oDataSet.Tables[0].Rows.Count - 1][0].ToString().Substring(PrefixString.Length, 5)) + 1;
                PrefixString = PrefixString + ICount.ToString("00000");
            }
            else
            {
                PrefixString = PrefixString + "00001";
            }

            return(PrefixString);
        }
Пример #8
0
        public static bool FilterByCount(string searchTerm, ICount count)
        {
            var op = searchTerm[0];
            var n  = InvalidNumber;

            if (char.IsNumber(op))
            {
                if (!int.TryParse(searchTerm, out n))
                {
                    n = InvalidNumber;
                }
                op = '=';
            }
            else if (searchTerm.Length > 1)
            {
                var subValue = searchTerm.Substring(1).Trim();
                if (!int.TryParse(subValue, out n))
                {
                    n = InvalidNumber;
                }
            }

            if (n == InvalidNumber)
            {
                return(false);
            }

            switch (op)
            {
            case '=':
                return(count.Count == n);

            case '>':
                return(count.Count > n);

            case '<':
                return(count.Count < n);

            default:
                return(true);
            }
        }
Пример #9
0
 public IDictionary <TCountType, ICount <TEntityType, TCountType> > GetUsage(ICountedEntity <TEntityType> entity, TCountType[] measures)
 {
     ArgumentValidator.ThrowIfNull("entity", entity);
     ArgumentValidator.ThrowIfNull("measures", measures);
     CountTracker <TEntityType, TCountType> .EntityValue entityValue;
     if (this.entities.TryGetValue(entity.Name, out entityValue))
     {
         IDictionary <TCountType, ICount <TEntityType, TCountType> > dictionary = new Dictionary <TCountType, ICount <TEntityType, TCountType> >();
         foreach (TCountType tcountType in measures)
         {
             ICount <TEntityType, TCountType> usage = entityValue.GetUsage(tcountType);
             if (usage != null)
             {
                 dictionary.Add(tcountType, usage);
             }
         }
         return(dictionary);
     }
     return(measures.ToDictionary((TCountType countType) => countType, (TCountType countType) => new EmptyCount <TEntityType, TCountType>(entity, countType)));
 }
Пример #10
0
        public string GenerateAutoID(string PrefixString, string TableName, string TableFieldName, int StringLength, SqlConnection oSqlConnection, SqlTransaction oSqlTransaction)
        {
            double ICount;

            oDataSet = new DataSet();
            oCResult = SQLResult("Select " + TableFieldName + " from " + TableName + " where " + TableFieldName + " like '%" + PrefixString + "%'  order by right(" + TableFieldName + "," + StringLength + ")", oSqlConnection, oSqlTransaction);
            oDataSet = (DataSet)oCResult.Data;
            if (oDataSet.Tables[0].Rows.Count > 0)
            {
                ICount       = int.Parse(oDataSet.Tables[0].Rows[oDataSet.Tables[0].Rows.Count - 1][0].ToString().Substring(PrefixString.Length, StringLength)) + 1;
                PrefixString = PrefixString + ICount.ToString().PadLeft(StringLength, '0');
            }
            else
            {
                ICount       = 1;
                PrefixString = PrefixString + ICount.ToString().PadLeft(StringLength, '0');
            }

            return(PrefixString);
        }
Пример #11
0
        public string GenerateAutoID(string PrefixString, string TableName, string TableFieldName, int StringLength, string AdditionalWhere)
        {
            double ICount;

            oDataSet = new DataSet();
            oDataSet = SQLResult("Select " + TableFieldName + " from " + TableName + " where " + TableFieldName + " like '%" + PrefixString + "%' and " + AdditionalWhere + "order by right(" + TableFieldName + "," + StringLength + ")");

            if (oDataSet.Tables[0].Rows.Count > 0)
            {
                ICount       = int.Parse(oDataSet.Tables[0].Rows[oDataSet.Tables[0].Rows.Count - 1][0].ToString().Substring(PrefixString.Length, StringLength)) + 1;
                PrefixString = PrefixString + ICount.ToString().PadLeft(StringLength, '0');
            }
            else
            {
                ICount       = 1;
                PrefixString = PrefixString + ICount.ToString().PadLeft(StringLength, '0');
            }

            return(PrefixString);
        }
Пример #12
0
 /// <summary>Returns true if the collection contains any elements.</summary>
 public static bool Any(this ICount c)
 {
     return(c.Count > 0);
 }
Пример #13
0
        public async Task <IPagedList <IProduct> > GetProductsAsync(IAscending ascending, ICount count, IPageNumber number, ISize size, IItemSearch itemSearch)
        {
            var productTable = repository.GetProducts();

            productTable = ascending.IsAscending == false?productTable.OrderByDescending(x => x.Name) : productTable.OrderBy(x => x.Name);

            if (!string.IsNullOrEmpty(itemSearch.Search))
            {
                count.TotalCount = await productTable.Where(x => x.Name == itemSearch.Search).CountAsync();

                productTable = productTable.Where(x => x.Name == itemSearch.Search).Skip((number.pageNumber - 1) * size.PageSize).Take(size.PageSize);
            }
            else
            {
                count.TotalCount = await productTable.CountAsync();

                productTable = productTable.Skip((number.pageNumber - 1) * size.PageSize).Take(size.PageSize);
            }

            var enumerableProduct = productTable.AsQueryable();
            var mappedProduct     = Mapper.Map <IEnumerable <ProductEntity>, IEnumerable <IProduct> >(enumerableProduct);

            return(new StaticPagedList <IProduct>(mappedProduct, number.pageNumber, size.PageSize, count.TotalCount));
        }
 public Task<long> GetCount(ICount repo, DateTime start, DateTime end)
 {
     return repo.GetCountByDate(start, end);
 }
Пример #15
0
        public void GivenListOfThresholdsWhenCountRecievedWarningsInvokedThenAssertToSuccess()
        {
            _count = new CountRecievedWarning();

            Assert.AreEqual(2, _count.Get(_recievedThresholdList));
        }
Пример #16
0
 public async Task <IPagedList <IProduct> > GetProductsAsync(IAscending ascending, ICount count, IPageNumber number, ISize size, IItemSearch itemSearch)
 {
     return(await Repository.GetProductsAsync(ascending, count, number, size, itemSearch));
 }
Пример #17
0
 public ReadNumbersForRepetation(ICount <int> number)
 {
     _number = number;
 }
Пример #18
0
        public void GivenListOfThresholdsWhenCountTargetErrorsInvokedThenAssertToSuccess()
        {
            _count = new CountTargetError();

            Assert.AreEqual(3, _count.Get(_targetThresholdList));
        }
Пример #19
0
 public MainViewModel(ICount count)
 {
     this.count = count;
     CountWordsCommand = new DelegateCommand(CountWordsExecute, CountWordsCanExecute);
     CountedWords = new ObservableCollection<WordCountViewModel>();
 }
Пример #20
0
 public ReadTextForRepetation(ICount <char> letter)
 {
     _letter = letter;
 }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImpTestA"/> class.
 /// </summary>
 /// <param name="ICount">The i count.</param>
 public ImpTestA(ICount ICount)
 {
     _iCount = ICount;
 }
Пример #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestInterceptor"/> class.
 /// </summary>
 /// <param name="count">The count.</param>
 public TestInterceptor(ICount count)
 {
     this.count = count;
 }
Пример #23
0
 public LogsController(ICount count)
 {
     _count = count;
 }