public void CRITERIA01_SimpleExpressionSerializeTest()
        {
            // Arrange
            Guid baseId = new Guid("{b3e98851-27ab-4d70-bb10-3cf71c80d838}");
            string knownGood = "{\"Id\":\"" + TypeProjectionConstants.User.Id.ToString("D") + "\",\"Criteria\":{\"Base\":{\"Expression\":{\"SimpleExpression\":{\"ValueExpressionLeft\":{\"GenericProperty\":\"Id\"},\"Operator\":\"Equal\",\"ValueExpressionRight\":{\"Value\":\"" + baseId.ToString("D") + "\"}}}}}}";

            QueryCriteriaExpression expr = new QueryCriteriaExpression
            {
                PropertyName = "Id",
                PropertyType = QueryCriteriaPropertyType.GenericProperty,
                Operator = QueryCriteriaExpressionOperator.Equal,
                Value = baseId.ToString("D")
            };

            QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.User.Id)
            {
                GroupingOperator = QueryCriteriaGroupingOperator.SimpleExpression
            };

            criteria.Expressions.Add(expr);

            // Act
            string testSerialize = criteria.ToString();

            // Assert
            Assert.AreEqual(knownGood, testSerialize);
        }
예제 #2
0
        DataSet IProductionService.LoadCategories2and4()
        {
            IDataManager dataManager = EntityManager.FromDataBaseService(ServiceName.ADWDB);

            var one = new QueryCriteria(Category.Fields.CategoryID, ComparisonOperator.Equal, 2);
            var two = new QueryCriteria(Category.Fields.CategoryID, ComparisonOperator.Equal, 4);
            dataManager.LoadEntities<Category>( one.OR(two));

            return dataManager.Data;
        }
예제 #3
0
        private static string searchTable(QueryCriteria cirteria)
        {
            string search = @"select [Table].Id, Location, [Table].Name, SeatAmount, Status , TableType.Name as Type
                                       from [Table], TableType
                                       where   and [Table].TableTypeId = TableType.Id";

            if (cirteria != null)
            {
                search = search + " and " + cirteria.Name + " " + cirteria.Value;
            }
            return(search);
        }
예제 #4
0
        public void TestPostgreSqlMax()
        {
            QueryCriteria qc = new QueryCriteria(first.TableName, first.TableFields[0]);

            qc.Add(CriteriaOperator.Max, first.TableFields[0]);
            IQueryCriteriaGenerator iq = DataFactory.InitializeQueryCriteriaGenerator(DatabaseServer.PostgreSql);
            ExecutionQuery          s  = iq.GenerateSelect(qc);

            Console.WriteLine(s.Query);

            Assert.IsTrue(s.Query != null);
        }
예제 #5
0
        public ActionResult GetDataList(QueryCriteria query)
        {
            var dataList = new List <CurrencyViewModel>()
            {
            };

            dataList.Add(new CurrencyViewModel()
            {
                CurrencyNumber      = "001",
                CurrencyName        = "人民币",
                CurrencySymbo       = "¥",
                CurrencyCode        = "CNY",
                CurrencyExchangRate = 6.5M,
                IsDefault           = "是",
                CreateTime          = new DateTime(2014, 6, 8)
            });

            dataList.Add(new CurrencyViewModel()
            {
                CurrencyNumber      = "002",
                CurrencyName        = "港币",
                CurrencySymbo       = "$",
                CurrencyCode        = "HKD",
                CurrencyExchangRate = 6.5M,
                IsDefault           = "否",
                CreateTime          = new DateTime(2014, 6, 8)
            });

            dataList.Add(new CurrencyViewModel()
            {
                CurrencyNumber      = "003",
                CurrencyName        = "美元",
                CurrencySymbo       = "$",
                CurrencyCode        = "USD",
                CurrencyExchangRate = 6.5M,
                IsDefault           = "否",
                CreateTime          = new DateTime(2014, 6, 8)
            });

            dataList.Add(new CurrencyViewModel()
            {
                CurrencyNumber      = "004",
                CurrencyName        = "欧元",
                CurrencySymbo       = "EUR",
                CurrencyCode        = "EUR",
                CurrencyExchangRate = 6.5M,
                IsDefault           = "否",
                CreateTime          = new DateTime(2014, 6, 8)
            });

            return(new JsonNetResult(new { Rows = dataList, Total = 8 }));
        }
        /// <summary>
        /// This should never have to deal with a null query or null data reference
        /// </summary>
        protected override void DataSetRecorder(QueryCriteria query, byte[] data)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            _serialisedQueryAndResultsCache.TryAdd(query, data);
        }
예제 #7
0
        public PagingModel <LogHeader> GetLogList(QueryCriteria criteria)
        {
            PagingModel <LogHeader> pagingModel = null;

            using (var sqlConn = SqlConnectionProvider.GetConnection(AppConst.RantaMaster))
            {
                var entity = logHeaderDal.GetLogList(criteria, sqlConn);

                pagingModel = LogHeaderConvertor.ToModel(entity);
            }

            return(pagingModel);
        }
        public void TestDelete()
        {
            this.TestCreateSimple();

            QueryCriteria qc = new QueryCriteria(ctm.TableName, ctm.TableFields[0]);

            qc.Add(CriteriaOperator.Max, ctm.TableFields[0]);
            object val = cpo.GetValue(qc);

            CategoryTableMetadata c = (CategoryTableMetadata)this.cpo.GetTableMetadata(val);

            this.cpo.Delete(c);
        }
예제 #9
0
        public override IEnumerable <KeyValuePair <AttributeValue, long> > Enumerate(QueryCriteria value)
        {
            var andPredicate = new ANDPredicate();

            foreach (var attributeValue in _allValues)
            {
                andPredicate.AddChildPredicate(new RangePredicate(Source,
                                                                  new SingleAttributeValue(new ArrayElement(attributeValue, 0)), IsInverse,
                                                                  new SingleAttributeValue(new ArrayElement(attributeValue, int.MaxValue))
                                                                  , IsInverse, IsInverse));
            }
            return(andPredicate.Enumerate(value));
        }
예제 #10
0
        public void TestAccessEquality()
        {
            CustomerTableMetadata c  = new CustomerTableMetadata();
            QueryCriteria         qc = new QueryCriteria(c);

            qc.Add(CriteriaOperator.Equality, c.TableFields[0], 1);
            //IQueryCriteriaGenerator ss = DataFactory.InitializeQueryCriteriaGenerator(DatabaseServer.Access);
            //string s = ss.GenerateSelect(qc);
            //Console.WriteLine(s);
            DataSet ds = pAccess.GetDataSet(qc);

            Assert.IsTrue(ds != null);
        }
예제 #11
0
        public void TestPostgreSqlEquality()
        {
            CustomerTableMetadata c  = new CustomerTableMetadata();
            QueryCriteria         qc = new QueryCriteria(c);

            qc.Add(CriteriaOperator.Equality, c.TableFields[0], 1);
            IQueryCriteriaGenerator ss = DataFactory.InitializeQueryCriteriaGenerator(DatabaseServer.PostgreSql);
            ExecutionQuery          s  = ss.GenerateSelect(qc);

            Console.WriteLine(s.Query);

            Assert.IsTrue(s.Query != string.Empty);
        }
예제 #12
0
        /// <summary>
        /// This should never have to deal with a null query or null data reference
        /// </summary>
        protected override void DataSetRecorder(QueryCriteria query, byte[] data)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            WriteResultsIgnoringError(PREFIX_DATASET, query, SetInCachedResults(PREFIX_DATASET, query, data));
        }
예제 #13
0
        private static string searchSaleItem(QueryCriteria cirteria)
        {
            string search = @"select Id, Measurement, Item.Name, PricePerUnit, Description, Status, Amount
                                                , ItemType.Name as Type, SalePricePerUnit, IsRecommend 
                                        from Item,SaleItem,ItemType
                                        where Item.Id = SaleItem.ItemId and Item.ItemTypeId = ItemType.ID";

            if (cirteria != null)
            {
                search = search + " and " + cirteria.Name + " " + cirteria.Value;
            }
            return(search);
        }
예제 #14
0
        public void TestMySQLSmallerOrEqual()
        {
            CustomerTableMetadata c  = new CustomerTableMetadata();
            QueryCriteria         qc = new QueryCriteria(c);

            qc.Add(CriteriaOperator.SmallerOrEqual, c.TableFields[0], 47);
            IQueryCriteriaGenerator ss = DataFactory.InitializeQueryCriteriaGenerator(DatabaseServer.MySQL);
            ExecutionQuery          s  = ss.GenerateSelect(qc);

            Console.WriteLine(s.Query);

            Assert.IsTrue(s.Query != string.Empty);
        }
        public void TestDeleteWithQueryCriteria()
        {
            this.TestCreateSimple();


            QueryCriteria qc = new QueryCriteria(firstTable.TableName, firstTable.TableFields[0]);

            qc.Add(CriteriaOperator.Max, firstTable.TableFields[0]);
            object value = firstPersistent.GetValue(qc);

            First f = (First)firstPersistent.GetTableMetadata(value);

            firstPersistent.Delete(f);
        }
예제 #16
0
        protected virtual IQueryCriteria CreateCriteriaFromQuery(IDynamicQuery query)
        {
            var criteria = new QueryCriteria
            {
                Page       = query?.GetPage(),
                PageSize   = query?.GetPageSize(),
                Filters    = query?.GetFilters() ?? new List <IFilter>(),
                Sorts      = query?.GetSorts() ?? new List <ISort>(),
                Groups     = query.GetGroups() ?? new List <IGroup>(),
                Aggregates = query.GetAggregates() ?? new List <IAggregate>()
            };

            return(criteria);
        }
        private void AddCriteriaImpl()
        {
            var field = lvwFields.SelectedItem as FieldDescriptor;

            if (field != null)
            {
                var c = new QueryCriteria {
                    Field = field, Output = true
                };
                new SupportService(User).SetDefaultFormatOptions(c);

                _model.Add(c);
            }
        }
예제 #18
0
        public static bool CollectCommands <T>(Func <T, bool> predicate) where T : ICommand
        {
            var timeout  = DateTime.Now.Add(Constants.UI.WaitTimeout);
            var criteria = new QueryCriteria {
                FullNames = { typeof(T).FullName }
            };
            bool found;

            while (!(found = commandLog.Query(criteria).OfType <T>().Any(predicate)) && DateTime.Now < timeout)
            {
                Thread.Sleep(100);
            }
            return(found);
        }
        public void valid()
        {
            const string element = @"
                <QueryCriteria conditions=""primaryposref = ?"">
                    <Condition name=""primaryposref"" value=""123"" />
                </QueryCriteria>";

            var criteria = new QueryCriteria(XE.Parse(element));

            Assert.Equal("primaryposref = ?", criteria.Conditions_.Value);
            Assert.Single(criteria.ConditionDetails);
            Assert.Equal("primaryposref", criteria.ConditionDetails[0].Name.Value);
            Assert.Equal("123", criteria.ConditionDetails[0].Value_.Value_);
        }
예제 #20
0
        public override IEnumerable <KeyValuePair <AttributeValue, long> > Enumerate(QueryCriteria value)
        {
            IQueryStore   tempCollection = value.SubstituteStore;
            IJSONDocument doc            = JSONType.CreateNew();

            doc.Add("$count(*)", _count);
            doc.Key = Guid.NewGuid().ToString();
            tempCollection.InsertDocument(doc, null);
            var rowid = tempCollection.GetRowId(new DocumentKey(doc.Key));

            value.Store        = tempCollection;
            value.GroupByField = new AllField(Field.FieldType.Grouped);
            yield return(new KeyValuePair <AttributeValue, long>(NullValue.Null, rowid));
        }
        public void doFindRetailOrderByConditionTest()
        {
            NameValueCollection nvc = new NameValueCollection();

            nvc.Add("dealerCode", "2250010");
            nvc.Add("regionCode", "2256666");
            nvc.Add("startIndex", "0");
            nvc.Add("pageSize", "3");
            nvc.Add("startDateCreate", "2017-09-01");
            nvc.Add("endDateCreate", "2017-09-21");
            nvc.Add("remark", "Y");
            QueryCriteria queryCriteria = new QueryCriteria(nvc);
            PageResult <RetailOrderQueryListVo> result = retailQueryService.QueryRetailOrderList(queryCriteria);
        }
예제 #22
0
        public void TestSqlServerCount()
        {
            QueryCriteria qc = new QueryCriteria(first.TableName, first.TableFields[0]);

            qc.Add(CriteriaOperator.Count, first.TableFields[0]);
            //IQueryCriteriaGenerator iq = DataFactory.InitializeQueryCriteriaGenerator(DatabaseServer.SqlServer);
            //string s = iq.GenerateSelect(qc);

            //Console.WriteLine(s);

            DataSet ds = psqlserver.GetDataSet(qc);

            Assert.IsTrue(ds != null);
        }
예제 #23
0
        public IHttpActionResult Find(Element element)
        {
            List <TrackJob> trackList       = new List <TrackJob>();
            AxdSTMTrackJob  trackJob        = new AxdSTMTrackJob();
            CriteriaElement criteriaElement = new CriteriaElement();

            criteriaElement.DataSourceName = element.DataSourceName; // "STMTrackJobTable";
            criteriaElement.FieldName      = element.FieldName;      // "StmTrackId";
            criteriaElement.Operator       = Operator.Equal;
            criteriaElement.Value1         = element.Value;          // "TK000001";

            QueryCriteria criteria = new QueryCriteria();

            criteria.CriteriaElement = new CriteriaElement[] { criteriaElement };

            using (var client = new STMTrackJobServiceClient())
            {
                client.ClientCredentials.Windows.ClientCredential.Domain   = UserAccount.Domain;
                client.ClientCredentials.Windows.ClientCredential.UserName = UserAccount.Username;
                client.ClientCredentials.Windows.ClientCredential.Password = UserAccount.Password;
                trackJob = client.find(CallContexts.get(), criteria);
            }

            for (int i = 0; i < trackJob.STMTrackJobTable.Length; i++)
            {
                string bu       = Enum.GetName(typeof(AxdEnum_STMMBU), trackJob.STMTrackJobTable[i].STMMBU);
                string typeroom = Enum.GetName(typeof(AxdEnum_STMTypeRoomJIS), trackJob.STMTrackJobTable[i].STMTypeRoom);
                string status   = Enum.GetName(typeof(AxdEnum_STMTrackStatus), trackJob.STMTrackJobTable[i].STMTrackStatus);

                trackList.Add(new TrackJob
                {
                    RecId       = trackJob.STMTrackJobTable[i].RecId.ToString(),
                    TrackId     = trackJob.STMTrackJobTable[i].StmTrackId == null ? "" : trackJob.STMTrackJobTable[i].StmTrackId.ToString(),
                    BU          = bu,
                    CreateDate  = Convert.ToDateTime(trackJob.STMTrackJobTable[i].CreatedDate),
                    FinishDate  = Convert.ToDateTime(trackJob.STMTrackJobTable[i].FinishDate),
                    Name        = trackJob.STMTrackJobTable[i].Name == null ? "" : trackJob.STMTrackJobTable[i].Name.ToString(),
                    ProjId      = trackJob.STMTrackJobTable[i].ProjId == null ? "" : trackJob.STMTrackJobTable[i].ProjId.ToString(),
                    RefTrackId  = trackJob.STMTrackJobTable[i].RefTrackId == null ? "" : trackJob.STMTrackJobTable[i].RefTrackId.ToString(),
                    Stage       = trackJob.STMTrackJobTable[i].ProjStage == null ? "" : trackJob.STMTrackJobTable[i].ProjStage.ToString(),
                    StartDate   = Convert.ToDateTime(trackJob.STMTrackJobTable[i].StartDate),
                    TypeRoom    = typeroom,
                    Unit        = Convert.ToInt32(trackJob.STMTrackJobTable[i].Unit),
                    ProjAmount  = Convert.ToDouble(trackJob.STMTrackJobTable[i].ProjAmount),
                    TrackStatus = status
                });
            }

            return(Json(trackList));
        }
예제 #24
0
        public void TestAccessMax()
        {
            QueryCriteria qc = new QueryCriteria(first.TableName, first.TableFields[1]);

            qc.Add(CriteriaOperator.Max, first.TableFields[1]);
            //IQueryCriteriaGenerator iq = DataFactory.InitializeQueryCriteriaGenerator(DatabaseServer.Access);
            //string s = iq.GenerateSelect(qc);

            //Console.WriteLine(s);

            DataSet ds = pAccess.GetDataSet(qc);

            Assert.IsTrue(ds != null);
        }
예제 #25
0
        public void TestJoinSqlServerSingleJoin()
        {
            QueryCriteria qcFirst  = new QueryCriteria(first);
            QueryCriteria qcSecond = new QueryCriteria(second);
            QueryCriteria qcThird  = new QueryCriteria(third);

            qcFirst.AddJoin(JoinType.Inner, first.TableName, first.TableFields[0], second.TableName, second.TableFields[1], qcSecond);

            qcFirst.Add(CriteriaOperator.OrderBy, first.TableFields[0], "Asc");

            DataSet ds = psqlserver.GetDataSet(qcFirst);

            Assert.IsTrue(ds != null);
        }
예제 #26
0
        public int Execute(QueryCriteria criteria, bool isCountQuery)
        {
            var cmd = _cmdFac.CreateCommand(criteria, isCountQuery);

            using (var conn = cmd.Connection)
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                return(isCountQuery ? Convert.ToInt32(cmd.ExecuteScalar()) : cmd.ExecuteNonQuery());
            }
        }
예제 #27
0
        public void TestEmptyCriteria()
        {
            MockContextFactory.SeedAndTestContextFor("CriteriaTests_TestEmptyCriteria", TestSeeders.SimpleSeedScenario, ctx =>
            {
                var resultShouldMatch = ctx.Items.ToList();
                var queryable         = ctx.Items.AsQueryable();

                // query handler that is empty should be the same as running to list.
                var criteria     = new QueryCriteria();
                var queryHandler = new QueryHandler();
                var result       = queryHandler.Execute(queryable, criteria);
                Assert.Equal(resultShouldMatch, result.Data);
            });
        }
예제 #28
0
        public void GetValue()
        {
            object x = auth.GetMin(this.a[Author.AuthorFields.AuthorId]);

            if (x == null)
            {
                return;
            }

            QueryCriteria qc = new QueryCriteria(a.TableName, a[Author.AuthorFields.AuthorId]);

            qc.Add(CriteriaOperator.Different, a[Author.AuthorFields.Age], x);

            Assert.IsTrue(this.auth.GetValue(qc) != null);
        }
예제 #29
0
        public void TestEmptyCriteria()
        {
            MockContextFactory.SeedAndTestContextFor("AsyncTests_TestEmptyCriteria", TestSeeders.SimpleSeedScenario, async ctx =>
            {
                var resultShouldMatch = ctx.Items.ToList();
                var queryable         = ctx.Items.AsQueryable();

                // query handler that is empty should be the same as running to list.
                var aqf          = new AsyncQueryableService(new[] { new AsyncQueryableHandlerService() });
                var criteria     = new QueryCriteria();
                var queryHandler = new QueryHandlerAsync(aqf);
                var result       = await queryHandler.ExecuteAsync(queryable, criteria);
                Assert.Equal(resultShouldMatch, result.Data);
            });
        }
예제 #30
0
        public void TestSqlServerBetween()
        {
            CustomerTableMetadata c  = new CustomerTableMetadata();
            QueryCriteria         qc = new QueryCriteria(c);

            qc.Add(CriteriaOperator.Between, c.TableFields[0], 1, 10);
            //IQueryCriteriaGenerator ss = DataFactory.InitializeQueryCriteriaGenerator(DatabaseServer.SqlServer);
            //string s =  ss.GenerateSelect(qc);

            //Console.WriteLine(s);

            DataSet ds = psqlserver.GetDataSet(qc);

            Assert.IsTrue(ds != null);
        }
예제 #31
0
        public void TestAccessSmaller()
        {
            CustomerTableMetadata c  = new CustomerTableMetadata();
            QueryCriteria         qc = new QueryCriteria(c);

            qc.Add(CriteriaOperator.Smaller, c.TableFields[0], 47);
            IQueryCriteriaGenerator ss = DataFactory.InitializeQueryCriteriaGenerator(DatabaseServer.Access);
            ExecutionQuery          s  = ss.GenerateSelect(qc);

            Console.WriteLine(s.Query);

            DataSet ds = pAccess.GetDataSet(qc);

            Assert.IsTrue(ds != null);
        }
예제 #32
0
        public void TestUpdate()
        {
            QueryCriteria qc = new QueryCriteria(ctm.TableName, ctm.TableFields[0]);

            qc.Add(CriteriaOperator.Max, ctm.TableFields[0]);
            object val = cpo.GetValue(qc);

            CategoryTableMetadata c = (CategoryTableMetadata)this.cpo.GetTableMetadata(val);

            c.CategoryName = "spanac";
            c.Description  = "muhahhahahahah";
            c.Picture      = null;

            this.cpo.Update(c);
        }
예제 #33
0
 private void WriteContent(QueryCriteria criteria, object model, StringBuilder sb)
 {
     if (this.ControllerContext == null)
         throw new CriteriaRenderException(this, typeof(RazorWebContentRender).Name + " must have Controller context");
     try
     {
         RazorView view = new RazorView(ControllerContext.ControllerContext, GetTemplateVirtualPath(criteria), layoutPath, true, new string[] { "cshtml", "vbhtml" });
         StringWriter sw = new StringWriter(sb);
         //设置视图数据对象
         ControllerContext.ViewBag.Criteria = criteria;
         ControllerContext.ViewBag.Data = model;
         ViewContext viewContext = new ViewContext(ControllerContext.ControllerContext, view, ControllerContext.ViewData, ControllerContext.TempData, sw);
         view.Render(viewContext, viewContext.Writer);
     }
     catch (Exception e)
     {
         throw new CriteriaRenderException(this, "render criteria view has error!", e);
     }
 }
        /// <summary>
        /// Convenience method that returns an Incident by its ID
        /// </summary>
        /// <param name="authToken">AuthorizationToken to use</param>
        /// <param name="incidentID">ID of the Incident to retrieve</param>
        /// <returns>Incident</returns>
        public static async Task<Incident> GetIncidentByID(AuthorizationToken authToken, string incidentID)
        {
            QueryCriteriaExpression expression = new QueryCriteriaExpression();
            expression.PropertyName = (new PropertyPathHelper(ClassConstants.Incident, "ID")).ToString();
            expression.PropertyType = QueryCriteriaPropertyType.Property;
            expression.Operator = QueryCriteriaExpressionOperator.Equal;
            expression.Value = incidentID;

            QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.Incident);
            criteria.GroupingOperator = QueryCriteriaGroupingOperator.SimpleExpression;
            criteria.Expressions.Add(expression);

            List<Incident> incidentList = await IncidentController.GetIncidentsByCriteria(authToken, criteria);

            if (incidentList.Count == 0)
                return null;

            return incidentList[0];
        }
        /// <summary>
        /// Convenience method that returns a list of Purchase Orders with the specified order type
        /// </summary>
        /// <param name="authToken">AuthorizationToken to use</param>
        /// <param name="poTypeGuid">Purchase Order Type ID to search for</param>
        /// <returns></returns>
        public static async Task<List<PurchaseOrder>> GetPurchaseOrdersByType(AuthorizationToken authToken, Guid poTypeGuid)
        {
            QueryCriteriaExpression expression = new QueryCriteriaExpression
            {
                PropertyName = (new PropertyPathHelper(ClassConstants.PurchaseOrder, "PurchaseOrderType")).ToString(),
                PropertyType = QueryCriteriaPropertyType.Property,
                Operator = QueryCriteriaExpressionOperator.Equal,
                Value = poTypeGuid.ToString("B")
            };

            QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.PurchaseOrder);
            criteria.GroupingOperator = QueryCriteriaGroupingOperator.And;
            criteria.Expressions.Add(expression);

            List<PurchaseOrder> purchaseOrderList = await PurchaseOrderController.GetPurchaseOrdersByCriteria(authToken, criteria);

            if (purchaseOrderList.Count == 0)
                return null;

            return purchaseOrderList;
        }
        /// <summary>
        /// Convenience method that gets a list of all Locations that are active
        /// </summary>
        /// <param name="authToken">AuthorizationToken to use</param>
        /// <returns></returns>
        public static async Task<List<Location>> GetAll(AuthorizationToken authToken)
        {
            PropertyPathHelper pathHelper = new PropertyPathHelper();
            pathHelper.PropertyName = "ObjectStatus";
            pathHelper.ObjectClass = ClassConstants.GetClassIdByType<Location>();

            QueryCriteriaExpression expr = new QueryCriteriaExpression
            {
                PropertyName = pathHelper.ToString(),
                PropertyType = QueryCriteriaPropertyType.Property,
                Operator = QueryCriteriaExpressionOperator.Equal,
                Value = EnumerationConstants.ConfigItem.BuiltinValues.ObjectStatus.Active.ToString("D")
            };

            QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.Location.Id)
            {
                GroupingOperator = QueryCriteriaGroupingOperator.SimpleExpression
            };

            criteria.Expressions.Add(expr);

            return await GetByCriteria(authToken, criteria);
        }
        public void CRITERIA02_CompoundExpressionSerializeTest()
        {
            // Arrange
            Guid typeGuid = new Guid("{2bc63f3a-a7a1-4ded-a727-b14f7b2cef69}");
            string poNumber = "Testing123";
            string knownGood = "{\"Id\":\"f27daae2-280c-dd8b-24e7-9bdb5120d6d2\",\"Criteria\":{\"Base\":{\"Expression\":{\"And\":{\"Expression\":[{\"SimpleExpression\":{\"ValueExpressionLeft\":{\"Property\":\"$Context/Property[Type='2afe355c-24a7-b20f-36e3-253b7249818d']/PurchaseOrderType$\"},\"Operator\":\"Equal\",\"ValueExpressionRight\":{\"Value\":\"" + typeGuid.ToString("B") + "\"}}},{\"SimpleExpression\":{\"ValueExpressionLeft\":{\"Property\":\"$Context/Property[Type='2afe355c-24a7-b20f-36e3-253b7249818d']/PurchaseOrderNumber$\"},\"Operator\":\"Equal\",\"ValueExpressionRight\":{\"Value\":\"" + poNumber + "\"}}}]}}}}}";

            QueryCriteriaExpression expr1 = new QueryCriteriaExpression
            {
                PropertyName = (new PropertyPathHelper(ClassConstants.PurchaseOrder.Id, "PurchaseOrderType")).ToString(),
                PropertyType = QueryCriteriaPropertyType.Property,
                Operator = QueryCriteriaExpressionOperator.Equal,
                Value = typeGuid.ToString("B")
            };

            QueryCriteriaExpression expr2 = new QueryCriteriaExpression
            {
                PropertyName = (new PropertyPathHelper(ClassConstants.PurchaseOrder.Id, "PurchaseOrderNumber")).ToString(),
                PropertyType = QueryCriteriaPropertyType.Property,
                Operator = QueryCriteriaExpressionOperator.Equal,
                Value = poNumber
            };

            QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.PurchaseOrder.Id);
            criteria.GroupingOperator = QueryCriteriaGroupingOperator.And;
            criteria.Expressions.Add(expr1);
            criteria.Expressions.Add(expr2);

            // Act
            string testSerialize = criteria.ToString();

            // Assert
            Assert.AreEqual(knownGood, testSerialize);
        }
예제 #38
0
 private string GetTemplateVirtualPath(QueryCriteria criteria)
 {
     return TEMPLATE_ROOT_PATH + criteria.GetContextName() + "_" + criteria.Name;
 }
 /// <summary>
 /// Gets a list of Purchase Orders based on the supplied criteria
 /// </summary>
 /// <param name="authToken">AuthorizationToken to use</param>
 /// <param name="criteria">QueryCriteria to search for</param>
 /// <returns></returns>
 public static async Task<List<PurchaseOrder>> GetPurchaseOrdersByCriteria(AuthorizationToken authToken, QueryCriteria criteria)
 {
     criteria.ProjectionID = TypeProjectionConstants.PurchaseOrder;
     return await ConfigurationItemController.GetConfigurationItemsByCriteria<PurchaseOrder>(authToken, criteria);
 }
예제 #40
0
 public object RenderValue(QueryCriteria criteria, params CriteriaValue[] selectedValue)
 {
     StringBuilder sb = new StringBuilder();
     WriteContent(criteria, selectedValue, sb);
     return sb.ToString();
 }
 /// <summary>
 /// Gets a list of Locations based on the supplied criteria
 /// </summary>
 /// <param name="authToken">AuthorizationToken to use</param>
 /// <param name="criteria">QueryCriteria to search for</param>
 /// <returns></returns>
 public static async Task<List<Location>> GetByCriteria(AuthorizationToken authToken, QueryCriteria criteria)
 {
     criteria.ProjectionID = TypeProjectionConstants.Location.Id;
     return await ConfigurationItemController.GetByCriteria<Location>(authToken, criteria);
 }
예제 #42
0
			private List<DicomAttributeCollection> ImageQuery(QueryCriteria queryCriteria)
			{
				string studyUid = queryCriteria[DicomTags.StudyInstanceUid];
				string seriesUid = queryCriteria[DicomTags.SeriesInstanceUid];

				if (String.IsNullOrEmpty(studyUid) || String.IsNullOrEmpty(seriesUid))
					throw new ArgumentException("The study and series uids must be specified for an image level query.");

				IStudy study = GetStudy(studyUid);
				if (study == null)
					throw new ArgumentException(String.Format("No study exists with the given study uid ({0}).", studyUid));
					
				ISeries series = CollectionUtils.SelectFirst(study.GetSeries(),
									delegate(ISeries test) { return test.SeriesInstanceUid == seriesUid; });

				if (series == null)
				{
					string message = String.Format("No series exists with the given study and series uids ({0}, {1})", studyUid, seriesUid);
					throw new ArgumentException(message);
				}

				try
				{
					QueryResultFilter<SopInstance> filter =
						new QueryResultFilter<SopInstance>(queryCriteria, Convert.Cast<SopInstance>(series.GetSopInstances()), GetSpecificCharacterSet);
					return filter.GetResults();
				}
				catch (DataStoreException)
				{
					throw;
				}
				catch (Exception e)
				{
					throw new DataStoreException("An error occurred while performing the image query.", e);
				}
			}
예제 #43
0
 public object RenderContent(QueryCriteria criteria, object model)
 {
     StringBuilder sb = new StringBuilder();
     WriteContent(criteria, model, sb);
     return sb.ToString();
 }
예제 #44
0
			private List<DicomAttributeCollection> StudyQuery(QueryCriteria queryCriteria)
			{
				try
				{
					string hqlQuery = QueryBuilder.BuildHqlQuery<Study>(queryCriteria);
					SessionManager.BeginReadTransaction();
					IList studiesFound = Session.CreateQuery(hqlQuery).List();

					QueryResultFilter<Study> filter =
						new QueryResultFilter<Study>(queryCriteria, Convert.Cast<Study>(studiesFound), GetSpecificCharacterSet);
					return filter.GetResults();
				}
				catch(DataStoreException)
				{
					throw;
				}
				catch (Exception e)
				{
					throw new DataStoreException("An error occurred while performing the study root query.", e);
				}
			}
예제 #45
0
			private List<DicomAttributeCollection> SeriesQuery(QueryCriteria queryCriteria)
			{
				string studyUid = queryCriteria[DicomTags.StudyInstanceUid];
				if (String.IsNullOrEmpty(studyUid))
					throw new ArgumentException("The study uid must be specified for a series level query.");

				IStudy study = GetStudy(studyUid);
				if (study == null)
					throw new ArgumentException(String.Format("No study exists with the given study uid ({0}).", studyUid));

				try
				{
					QueryResultFilter<Series> filter =
						new QueryResultFilter<Series>(queryCriteria, Convert.Cast<Series>(study.GetSeries()), GetSpecificCharacterSet);
					return filter.GetResults();
				}
				catch(DataStoreException)
				{
					throw;
				}
				catch(Exception e)
				{
					throw new DataStoreException("An error occurred while performing the series query.", e);
				}
			}
예제 #46
0
			public IEnumerable<DicomAttributeCollection> Query(DicomAttributeCollection queryCriteria)
			{
				Platform.CheckForNullReference(queryCriteria, "queryCriteria");

				QueryCriteria convertedCriteria = new QueryCriteria(queryCriteria);

				string level = queryCriteria[DicomTags.QueryRetrieveLevel].ToString();
				switch(level)
				{
					case "STUDY":
						return StudyQuery(convertedCriteria);
					case "SERIES":
						return SeriesQuery(convertedCriteria);
					case "IMAGE":
						return ImageQuery(convertedCriteria);
					default:
						throw new ArgumentException(String.Format("Invalid query level: {0}", level));
				}
			}
        /// <summary>
        /// Gets a list of all Locations that are active
        /// </summary>
        /// <param name="authToken">AuthorizationToken to use</param>
        /// <returns></returns>
        public static async Task<List<Location>> GetAllLocations(AuthorizationToken authToken)
        {
            QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.Location);

            return await TypeProjectionController.GetProjectionByCriteria<Location>(authToken, ConfigurationItemController.ExcludeInactiveItems<Location>(criteria));
        }
 /// <summary>
 /// Retrieves a list of HardwareAssets that match the given criteria
 /// </summary>
 /// <param name="authToken">AuthorizationToken to use</param>
 /// <param name="criteria">QueryCriteria to search for</param>
 /// <param name="includeInactiveItems">If true, override the criteria to exclude inactive items (this will set the grouping operator to AND!)</param>
 /// <returns></returns>
 public static async Task<List<HardwareAsset>> GetByCriteria(AuthorizationToken authToken, QueryCriteria criteria, bool includeInactiveItems = false)
 {
     criteria.ProjectionID = TypeProjectionConstants.HardwareAsset.Id;
     return await ConfigurationItemController.GetByCriteria<HardwareAsset>(authToken, criteria);
 }
        /// <summary>
        /// Helper method that returns a QueryCriteria used by the GetHardwareAssetBy.. methods
        /// </summary>
        /// <param name="property">Property to query</param>
        /// <param name="value">Property value to look for</param>
        /// <returns></returns>
        private static QueryCriteria BuildCriteria(PropertyPathHelper property, string value)
        {
            QueryCriteriaExpression expression = new QueryCriteriaExpression
            {
                PropertyName = property.ToString(),
                PropertyType = QueryCriteriaPropertyType.Property,
                Operator = QueryCriteriaExpressionOperator.Equal,
                Value = value
            };

            QueryCriteria criteria = new QueryCriteria(TypeProjectionConstants.HardwareAsset.Id)
            {
                GroupingOperator = QueryCriteriaGroupingOperator.SimpleExpression
            };

            criteria.Expressions.Add(expression);

            return criteria;
        }
 /// <summary>
 /// Gets a list of Incidents based on the supplied criteria
 /// </summary>
 /// <param name="authToken">AuthorizationToken to use</param>
 /// <param name="criteria">QueryCriteria to search for</param>
 /// <returns></returns>
 public static async Task<List<Incident>> GetIncidentsByCriteria(AuthorizationToken authToken, QueryCriteria criteria)
 {
     criteria.ProjectionID = TypeProjectionConstants.Incident;
     return await TypeProjectionController.GetProjectionByCriteria<Incident>(authToken, criteria);
 }