Ejemplo n.º 1
0
        public QueryResult <Product> ReadProductByIds(GetDataInfo getInfo, int[] productIDs)
        {
            int?totalCount = null;
            var res        = this.DB.Products.Where(ca => productIDs.Contains(ca.ProductID));

            return(new QueryResult <Product>(res, totalCount));
        }
Ejemplo n.º 2
0
        public QueryResult <SalesOrderDetail> ReadSalesOrderDetail(GetDataInfo getInfo)
        {
            int?totalCount = null;
            var res        = QueryHelper.PerformQuery(this.DB.SalesOrderDetails, getInfo, ref totalCount).AsEnumerable();

            return(new QueryResult <SalesOrderDetail>(res, totalCount));
        }
Ejemplo n.º 3
0
        public QueryResult <ProductModel> ReadProductModel(GetDataInfo getInfo)
        {
            int?totalCount = null;
            var res        = QueryHelper.PerformQuery(this.DB.ProductModels, getInfo, ref totalCount).AsEnumerable();

            return(new QueryResult <ProductModel>(res, totalCount));
        }
Ejemplo n.º 4
0
        public QueryResult <CustomerAddress> ReadCustomerAddress(GetDataInfo getInfo)
        {
            int?totalCount = null;
            var res        = QueryHelper.PerformQuery(this.DB.CustomerAddresses, getInfo, ref totalCount).AsEnumerable();

            return(new QueryResult <CustomerAddress>(res, totalCount));
        }
Ejemplo n.º 5
0
        public QueryResult <CustomerAddress> ReadAddressForCustomers(GetDataInfo getInfo, int[] custIDs)
        {
            int?totalCount = null;
            var res        = this.DB.CustomerAddresses.Where(ca => custIDs.Contains(ca.CustomerID));

            return(new QueryResult <CustomerAddress>(res, totalCount));
        }
Ejemplo n.º 6
0
        public QueryResult <Address> ReadAddressByIds(GetDataInfo getInfo, int[] addressIDs)
        {
            int?totalCount = null;
            var res        = this.DB.Addresses.Where(ca => addressIDs.Contains(ca.AddressID));

            return(new QueryResult <Address>(res, totalCount));
        }
Ejemplo n.º 7
0
        public QueryResult <AddressInfo> ReadAddressInfo(GetDataInfo getInfo)
        {
            int?totalCount = null;
            var res        = QueryHelper.PerformQuery(this.DB.Addresses, getInfo, ref totalCount).Select(a => new AddressInfo {
                AddressID = a.AddressID, AddressLine1 = a.AddressLine1, City = a.City, CountryRegion = a.CountryRegion
            }).AsEnumerable();

            return(new QueryResult <AddressInfo>(res, totalCount));
        }
Ejemplo n.º 8
0
        public QueryResult <SalesInfo> ReadSalesInfo(GetDataInfo getInfo)
        {
            var res = this.DB.Customers.Where(c => c.SalesPerson.StartsWith(getInfo.filterInfo.filterItems[0].values.First().TrimEnd('%'))).Select(s => s.SalesPerson).Distinct().Select(s => new SalesInfo {
                SalesPerson = s
            });
            var res2 = res.Skip(getInfo.pageIndex * getInfo.pageSize).Take(getInfo.pageSize);

            return(new QueryResult <SalesInfo>(res2, res.Count()));
        }
Ejemplo n.º 9
0
        public QueryResult <Product> ReadProduct(GetDataInfo getInfo, int[] param1, string param2)
        {
            int?totalCount  = null;
            var res         = QueryHelper.PerformQuery(this.DB.Products, getInfo, ref totalCount).AsEnumerable();
            var queryResult = new QueryResult <Product>(res, totalCount);

            //example of returning out of band information and use it on the client (of it can be more useful than it)
            queryResult.extraInfo = new { test = "ReadProduct Extra Info: " + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") };
            return(queryResult);
        }
Ejemplo n.º 10
0
        public QueryResult <LookUpProduct> ReadProductLookUp(GetDataInfo getInfo)
        {
            int?totalCount = null;
            var res        = QueryHelper.PerformQuery(this.DB.Products, getInfo, ref totalCount).Select(p => new LookUpProduct {
                ProductID = p.ProductID, Name = p.Name
            }).AsEnumerable();
            var queryResult = new QueryResult <LookUpProduct>(res, totalCount);

            return(queryResult);
        }
Ejemplo n.º 11
0
 public IQueryable <T> PerformQuery <T>(IQueryable <T> entities, GetDataInfo getInfo, ref int?totalCount)
     where T : class
 {
     if (getInfo.isIncludeTotalCount && !totalCount.HasValue)
     {
         totalCount = this.GetTotalCount(entities, getInfo.filterInfo, getInfo.dbSetInfo);
     }
     entities = this.PerformFilter(entities, getInfo.filterInfo, getInfo.dbSetInfo);
     entities = this.PerformSort(entities, getInfo.sortInfo);
     entities = this.GetPage(entities, getInfo.pageIndex, getInfo.pageSize, getInfo.pageCount, getInfo.dbSetInfo);
     return(entities);
 }
Ejemplo n.º 12
0
        public QueryResult <Customer> ReadCustomer(GetDataInfo getInfo, bool?includeNav)
        {
            string[] includeHierarchy = new string[0];
            if (includeNav == true)
            {
                DataLoadOptions opt = new DataLoadOptions();
                opt.LoadWith <Customer>(m => m.CustomerAddresses);
                opt.LoadWith <CustomerAddress>(m => m.Address);
                this.DB.LoadOptions = opt;

                //we can conditionally include entity hierarchy into results
                //making the path navigations decisions on the server enhances security
                //we can not trust clients to define navigation's expansions because it can influence the server performance
                //and is not good from security's standpoint
                includeHierarchy = new string[] { "CustomerAddresses.Address" };
            }

            int?totalCount = null;
            var res        = QueryHelper.PerformQuery(this.DB.Customers, getInfo, ref totalCount).AsEnumerable();

            return(new QueryResult <Customer>(res, totalCount, includeHierarchy));
        }
Ejemplo n.º 13
0
        public QueryResult <FolderModel> ReadChildren(GetDataInfo getInfo, string parentKey, int level, string path, bool includeFiles)
        {
            string        fullpath = Path.GetFullPath(Path.Combine(ROOT, path));
            DirectoryInfo dinfo    = new DirectoryInfo(fullpath);

            if (!includeFiles)
            {
                var dirs = dinfo.EnumerateDirectories();
                var res  = dirs.Select(d => new FolderModel {
                    Key = Guid.NewGuid().ToString(), ParentKey = parentKey, HasSubDirs = d.EnumerateDirectories().Any(), Level = level, Name = d.Name, IsFolder = true
                }).OrderBy(d => d.Name);
                return(new QueryResult <FolderModel>(res));
            }
            else
            {
                var fileSyst = dinfo.EnumerateFileSystemInfos();
                var res2     = fileSyst.Select(d => new FolderModel {
                    Key = Guid.NewGuid().ToString(), ParentKey = parentKey, HasSubDirs = (d is DirectoryInfo) ? ((DirectoryInfo)d).EnumerateFileSystemInfos().Any() : false, Level = level, Name = d.Name, IsFolder = (d is DirectoryInfo)
                }).OrderByDescending(d => d.IsFolder).ThenBy(d => d.Name);
                return(new QueryResult <FolderModel>(res2));
            }
        }
Ejemplo n.º 14
0
        public GetDataInfo GetData(EAlgoInput v, bool getPrimary, bool getIntensity, bool getGroup, bool getTime, bool getRep)
        {
            // Get the peak
            // Get the constraint
            // We always use "constraint A" for anything other than "SamePeak" since different constraints on the second peak/time can only be out of error presently
            Peak      peak;
            ObsFilter con;

            if (v == EAlgoInput.A)
            {
                peak = this.PeakA;
                con  = this.Args.VectorAConstraint;
            }
            else
            {
                switch (this.Args.VectorBSource)
                {
                case EAlgoInputBSource.AltPeak:
                    peak = this.Args.VectorBPeak;
                    con  = this.Args.VectorAConstraint;    // to avoid error - we never expect conditions for A and B to be different
                    break;

                case EAlgoInputBSource.SamePeak:
                    peak = this.PeakA;
                    con  = this.Args.VectorBConstraint;
                    break;

                case EAlgoInputBSource.Time:
                    peak = this.PeakA;
                    con  = this.Args.VectorAConstraint;    // to avoid error
                    break;

                case EAlgoInputBSource.DmPeak:
                    peak = this.PeakB;
                    con  = this.Args.VectorAConstraint;    // to avoid error
                    break;

                case EAlgoInputBSource.None:
                default:
                    throw new SwitchException(this.Args.VectorBSource);
                }
            }

            GetDataInfo r = new GetDataInfo();

            bool primaryIsTime = (v == EAlgoInput.B && this.Args.VectorBSource == EAlgoInputBSource.Time);

            if (getPrimary)
            {
                getIntensity |= !primaryIsTime;
                getTime      |= primaryIsTime;
            }

            // TODO: This whole section is awful legacy stuff, why do we keep looking this stuff up!
            Vector srcV = this.Args.SourceMatrix.Find(peak);
            // null condition just means "everything"
            IEnumerable <int> indices = con == null?srcV.Observations.Indices() : srcV.Observations.Which(λ => con.Test((ObservationInfo)λ));

            IEnumerable <ObservationInfo> srcC = srcV.Observations.At(indices);

            if (getIntensity)
            {
                r.Intensity = srcV.Values.At(indices).ToArray();
            }

            if (getTime)
            {
                r.Time = srcC.Select(z => z.Time).ToArray();
            }

            if (getGroup)
            {
                r.Group = srcC.Select(z => z.Group).ToArray();
            }

            if (getTime)
            {
                r.Rep = srcC.Select(z => z.Rep).ToArray();
            }

            if (getPrimary)
            {
                r.Primary = primaryIsTime ? r.Time.Select(z => (double)z).ToArray() : r.Intensity;
            }

            return(r);
        }
Ejemplo n.º 15
0
 public ActionResult GetItems(GetDataInfo getInfo)
 {
     return(new IncrementalResult(this.DomainService.ServiceGetData(getInfo)));
 }
Ejemplo n.º 16
0
 public QueryResult <FolderModel> ReadRoot(GetDataInfo getInfo, bool includeFiles)
 {
     return(ReadChildren(getInfo, null, 0, "", includeFiles));
 }