コード例 #1
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			var counter = 0;

			// check for id, guid or pointer
			int id;
			if (parameters.TryGetAndRemove(context, "id", out id))
			{
				query.Add(new IsPropertyEqualSpecification("id", id));
				counter++;
			}
			string guids;
			if (parameters.TryGetAndRemove(context, "guid", out guids) && !string.IsNullOrEmpty(guids))
			{
				// split the value
				var values = guids.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray();
				query.Add(new IsPropertyInSpecification("guid", values));
				counter++;
			}
			NodePointer pointer;
			if (parameters.TryGetAndRemove(context, "pointer", out pointer))
			{
				query.Add(new IsPropertyEqualSpecification("id", pointer.Id));
				counter++;
			}

			// check for ambigous parameters
			if (counter > 1)
				throw new InvalidOperationException("Detected an ambigious id parmeters. Remove either id, guid or pointer.");
		}
コード例 #2
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// parse the sorts and add them to the query
			string sortString;
			if (parameters.TryGetAndRemove(context, "sort", out sortString) && !string.IsNullOrEmpty(sortString))
				query.Add(Sort.Parse(sortString));
			else
				query.Add(Sort.DefaultSort);
		}
コード例 #3
0
        public void TestSimpleLikeQuery2()
        {
            Query query = new Query();
            query.Add(Criterion.Create<Products>(t => t.ProductId, 2, CriteriaOperator.Greater), QueryOperator.And);
            query.Add(Criterion.Create<Products>(t => t.ProductId, 4, CriteriaOperator.LesserThan));

            string result = QueryTranslator.TranslateIntoSqlQuery(query, PRODUCT_SCRIPT);
            Assert.IsTrue(result == "exec sp_executesql N'select * from [Production].[Product] where (ProductId > @0 and ProductId < @1)', N'@0 nvarchar(4000), @1 nvarchar(4000)', @0 = N'2', @1 = N'4'");
        }
コード例 #4
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// if the authorization is bypassed do not add the security check
			// TODO: add validator logic to make sure the type supports authorization
			bool bypassAuthorization;
			if (parameters.TryGetAndRemove(context, "bypassAuthorization", out bypassAuthorization) && bypassAuthorization)
				query.Add(AllowedRolesSpecification.Any());
			else
				query.Add(AllowedRolesSpecification.UserRoles(context));
		}
コード例 #5
0
        public override void BuildQuery(Query query)
        {
            base.BuildQuery(query);

            query.Add("raw");

            if (Index.HasValue)
            {
                query.Add("index", Index);
            }
        }
コード例 #6
0
        public IEnumerable<Order> FindAllCustomersOrdersWithInOrderDateBy(Guid customerId, DateTime orderDate)
        {
            IEnumerable<Order> customerOrders = new List<Order>();

            Query query = new Query();
            query.Add(new Criterion("CustomerId", customerId, CriteriaOperator.Equal));
            query.QueryOperator = QueryOperator.And;
            query.Add(new Criterion("OrderDate", orderDate, CriteriaOperator.LessThanOrEqual));
            query.OrderByProperty = new OrderByClause { PropertyName = "OrderDate", Desc = true };

            customerOrders = _orderRepository.FindBy(query);

            return customerOrders;
        }
コード例 #7
0
        public override void BuildQuery(Query query)
        {
            base.BuildQuery(query);

            if (Recurse)
            {
                query.Add("recurse");
            }

            if (CheckAndSet.HasValue)
            {
                query.Add("cas", CheckAndSet);
            }
        }
コード例 #8
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// get the type name is any
			string typeNames;
			if (!parameters.TryGetAndRemove(context, "type", out typeNames) && string.IsNullOrEmpty(typeNames))
				return;

			// parse the type names
			var types = typeNames.Split(',').Select(x => typeService.Load(context, x)).ToArray();
			if (types.Length == 0)
				return;

			// add the type hints to the query
			query.Add(types);
			query.Add(new IsPropertyInSpecification("type", types.Select(type => type.Name)));
		}
コード例 #9
0
 public virtual void BuildQuery(Query query)
 {
     if (!string.IsNullOrEmpty(DataCenter))
     {
         query.Add("dc", DataCenter);
     }
 }
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// check for search
			string where;
			if (parameters.TryGetAndRemove(context, "fts", out where) && !string.IsNullOrEmpty(where))
				query.Add(new FullTextSearchSpecification(where));
		}
コード例 #11
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// check for the cache flag
			object tmp;
			if (parameters.TryGetAndRemove(context, StorageOnlyQueryComponent.PropertyKey, out tmp))
				query.Add(new StorageOnlyQueryComponent());
		}
コード例 #12
0
        public override void BuildQuery(Query query)
        {
            base.BuildQuery(query);

            query.Add("keys");

            if (Index.HasValue)
            {
                query.Add("index", Index);
            }

            if (Separator.HasValue)
            {
                query.Add("separator", Separator);
            }
        }
コード例 #13
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			var clauseCounter = 0;

			// get the depth
			var depthValue = new Lazy<int?>(() =>
			                                {
			                                	int? depth = 1;
			                                	string depthString;
			                                	if (parameters.TryGetAndRemove(context, "depth", out depthString))
			                                	{
			                                		// check for any
			                                		if ("any".Equals(depthString, StringComparison.OrdinalIgnoreCase))
			                                			depth = null;
			                                		else
			                                		{
			                                			// parse the depth
			                                			depth = conversionService.Convert(context, depthString, 1);
			                                		}
			                                	}
			                                	return depth;
			                                });

			// check for parentPointer
			NodePointer parentPointer;
			if (parameters.TryGetAndRemove(context, "childPointer", out parentPointer))
			{
				query.Add(ParentOfSpecification.Child(parentPointer, depthValue.Value));
				clauseCounter++;
			}

			// check for pointer
			Node parentNode;
			if (parameters.TryGetAndRemove(context, "childSource", out parentNode))
			{
				query.Add(ParentOfSpecification.Child(parentNode.Pointer, depthValue.Value));
				clauseCounter++;
			}

			// sort on depth if no explicit sort has been set
			if (clauseCounter > 0 && !parameters.Contains("sort"))
				query.Add(new SortQueryComponent(DefaultSort));

			// check for ambigous parameters
			if (clauseCounter > 1)
				throw new InvalidOperationException("Detected an ambigious parent of clause. Remove either childPointer or childSource.");
		}
コード例 #14
0
        public void TestSimpleContainQuery()
        {
            Query query = new Query();
            query.Add(Criterion.Create<Products>(t => t.ProductNumber, "CA-5965", CriteriaOperator.Equal));

            string result = QueryTranslator.TranslateIntoSqlQuery(query, PRODUCT_SCRIPT);
            Assert.IsTrue(result == "exec sp_executesql N'select * from [Production].[Product] where (ProductNumber = @0)', N'@0 nvarchar(4000)', @0 = N'CA-5965'");
        }
コード例 #15
0
        public void test_starts_with()
        {
            Query query = new Query();
            query.Add(Criterion.Create<Products>(t => t.Name, "Chainring", CriteriaOperator.StartWith));

            string result = QueryTranslator.TranslateIntoSqlQuery(query, PRODUCT_SCRIPT);
            Assert.IsTrue(result == "exec sp_executesql N'select * from [Production].[Product] where (Name like @0 + ''%'')', N'@0 nvarchar(4000)', @0 = N'Chainring'");
        }
コード例 #16
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			Specification where;
			if (!parameters.TryGetAndRemove(context, "where", out where))
				return;

			// parse the sorts and add them to the query
			query.Add(where);
		}
コード例 #17
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			int limit;
			if (!parameters.TryGetAndRemove(context, "limit", out limit))
				return;

			// parse the sorts and add them to the query
			query.Add(new LimitQueryComponent(limit));
		}
コード例 #18
0
        public override void BuildQuery(Query query)
        {
            base.BuildQuery(query);

            if (Flags.HasValue)
            {
                query.Add("flags", Flags);
            }

            if (CheckAndSet.HasValue)
            {
                query.Add("cas", CheckAndSet);
            }

            if (LockOperation != null)
            {
                LockOperation.BuildQuery(query);
            }
        }
コード例 #19
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// check for the cache flag
			bool isCachable;
			if (!parameters.TryGetAndRemove(context, "cache", out isCachable))
				isCachable = true;

			// add the query component
			query.Add(new CacheQueryComponent(isCachable));
		}
コード例 #20
0
 public void BuildQuery(Query query)
 {
     if (_jo != null)
     {
         IEnumerable<JProperty> properties = _jo.Properties();
         foreach (JProperty property in properties)
         {
             query.Add(property.Name, property.Value);
         }
     }
 }
コード例 #21
0
        public IEnumerable<Order> FindAllCustomersOrdersBy(Guid customerId)
        {
            IEnumerable<Order> customerOrders = new List<Order>();

            Query query = new Query();
            query.Add(new Criterion("CustomerId", customerId, CriteriaOperator.Equal));
            query.OrderByProperty = new OrderByClause { PropertyName = "CustomerId", Desc = true };

            customerOrders = _orderRepository.FindBy(query);

            return customerOrders;
        }
コード例 #22
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// check the input
			int pageNumber;
			var hasPageNumber = parameters.TryGetAndRemove(context, "pageNumber", out pageNumber);
			int pageSize;
			var hasPageSize = parameters.TryGetAndRemove(context, "pageSize", out pageSize);

			// add the paging query component
			if ((hasPageNumber && hasPageSize))
				query.Add(new PagingQueryComponent(pageNumber, pageSize));
		}
コード例 #23
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// loop over all the facet properties
			var facetPropertyNames = parameters.Names.Where(candidate => candidate.StartsWith("facet")).ToList();
			foreach (var facetPropertyName in facetPropertyNames)
			{
				// retrieve the facet from the property
				FacetDefinition facet;
				if (!parameters.TryGetAndRemove(context, facetPropertyName, out facet))
					throw new InvalidOperationException(string.Format("Property {0} did not contain a valid facet", facetPropertyName));

				// add the query component
				query.Add(new FacetQueryComponent(facet));
			}
		}
コード例 #24
0
        public void The_Translator_Should_Produce_Valid_SQL_From_A_Query_Object()
        {
            int customerId = 9;
            string expectedSQL = "SELECT * FROM Orders WHERE CustomerId = @CustomerId ORDER BY CustomerId DESC";

            Query query = new Query();
            query.Add(new Criterion("CustomerId", customerId, CriteriaOperator.Equal));
            query.OrderByProperty = new OrderByClause { PropertyName = "CustomerId", Desc = true };

            SqlCommand command = new SqlCommand();
            query.TranslateInto(command);

            Assert.AreEqual(expectedSQL, command.CommandText);

        }
コード例 #25
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// get the type name is any
			string baseTypeNames;
			if (!parameters.TryGetAndRemove(context, "baseType", out baseTypeNames) && string.IsNullOrEmpty(baseTypeNames))
				return;

			// parse the base type names
			var baseTypes = baseTypeNames.Split(',').Select(x => typeService.Load(context, x)).ToArray();
			if (baseTypes.Length == 0)
				return;

			// get all the types
			var types = baseTypes.SelectMany(baseType =>
			                                 {
			                                 	var list = new List<ITypeDefinition>(new[] {baseType});
			                                 	list.AddRange(baseType.GetInheritingTypes(context));
			                                 	return list;
			                                 }).ToArray();

			// add the type hints to the query
			query.Add(types);
			query.Add(new IsPropertyInSpecification("type", types.Select(type => type.Name)));
		}
コード例 #26
0
        public List <LabourChargeTypeDto> GetLabourChargesType()
        {
            LCTClient = new LabourChargeTypeServiceClient();
            UserDto   currentUserDto = (UserDto)Session[Constants.SKCURRENTUSER];
            Query     query          = new Query();
            Criterion criteriaCAId   = new Criterion(Constants.CAID, Helper.GetCAIdOfUser(currentUserDto), CriteriaOperator.Equal);

            query.Add(criteriaCAId);
            query.QueryOperator = QueryOperator.And;


            var labourchargetype = LCTClient.FindByQuery(query);

            LCTClient.Close();
            return(labourchargetype.Entities.ToList());
        }
コード例 #27
0
        public IEnumerable <Order> FindAllCustomersOrderBy(Guid customerId)
        {
            IEnumerable <Order> cusomterOrders = new List <Order>();

            Query query = new Query();

            query.Add(new Criterion(fieldName_CustomerId, customerId, CriteriaOperator.Equal));
            query.OrderByProperty = new OrderByClause()
            {
                PropertyName = fieldName_CustomerId, Desc = true
            };

            cusomterOrders = _orderRepository.FindBy(query);

            return(cusomterOrders);
        }
コード例 #28
0
        private CountryDto GetByCountrynameCommand(IRepositoryLocator locator, string CountryName)
        {
            CountryDto result       = null;
            Query      query        = new Query();
            Criterion  criteriaName = new Criterion("CountryName", CountryName, CriteriaOperator.Equal);

            query.Add(criteriaName);
            var country = locator.GetRepository <Country>().FindBy(query);

            if (country.Count() != 0)
            {
                result = EntityToEntityDto(country.FirstOrDefault());
            }

            return(result);
        }
コード例 #29
0
        public GetAlbumsByGenreResponse GetAlbumsByGenre(GetAlbumsByGenreRequest request)
        {
            var response = new GetAlbumsByGenreResponse();

            var albumQuery = new Query();

            albumQuery.AddAlias(QueryAlias.CreateAlias <Album>(g => g.Genre));

            albumQuery.Add(Criterion.Create <Album, Genre>(a => a.Genre, g => g.Name, request.Genre, CriteriaOperator.Equal));

            var albums = _albumRepository.FindAll(albumQuery);

            response.Albums = albums.ConvertToAlbumViews();

            return(response);
        }
コード例 #30
0
        public List <UserGroupDto> GetUserGroupList(int?CAId)
        {
            UserGroupServiceClient client = new UserGroupServiceClient();
            List <UserGroupDto>    ugList = null;

            try
            {
                UserDto CurrentUser = (UserDto)Session[Constants.SKCURRENTUSER];
                string  usertype    = "";
                if (!string.IsNullOrEmpty(Request.Params["userType"]))
                {
                    usertype = Request.Params["userType"];
                }
                Query     query = new Query();
                Criterion criteriaCAId;

                if (usertype == "AckUser" && !Helper.IsCAIdNotNull(CurrentUser))
                {
                    criteriaCAId = new Criterion(Constants.CAID, null, CriteriaOperator.IsNullOrZero);
                }
                else if (usertype == "CAUser" && (CAId != null || CAId != 0))
                {
                    criteriaCAId = new Criterion(Constants.CAID, CAId, CriteriaOperator.Equal);
                }
                else
                {
                    criteriaCAId = new Criterion(Constants.CAID, Helper.GetCAIdOfUser(CurrentUser), CriteriaOperator.Equal);
                }

                query.Add(criteriaCAId);
                query.QueryOperator = QueryOperator.And;
                var usergroupdtos = client.FindByQuery(query);
                ugList = usergroupdtos.Entities.ToList();
                ugList.Insert(0, new UserGroupDto
                {
                    UserGroupId   = 0,
                    UserGroupName = "[Select All]"
                });
            }
            catch (Exception ex)
            { }
            finally
            {
                client.Close();
            }
            return(ugList);
        }
コード例 #31
0
        /// <summary>
        /// Gets the specified code.
        /// </summary>
        /// <typeparam name="T">The type of the product repository item.</typeparam>
        /// <param name="location">The location.</param>
        /// <returns>The needed item.</returns>
        protected virtual Item GetItem <T>(string location) where T : IProductRepositoryItem
        {
            Assert.ArgumentNotNullOrEmpty(location, "code");

            /*
             * This functionality has tree possible scenario:
             * if code is Item Id it tries to find the product item by id (fastest way), by path.
             * else it tries to find the product item by code and unit of measures.
             */
            Item item;

            if (ID.IsID(location))
            {
                item = this.Database.GetItem(location);
                if (item != null)
                {
                    return(item);
                }
            }

            Item root = this.Database.GetItem(this.GetRepositoryRootPath());

            Assert.IsNotNull(root, "Repository root item is null");

            string path = IO.FileUtil.MakePath(root.Paths.FullPath, location);

            item = this.Database.GetItem(path);
            if (item != null)
            {
                return(item);
            }

            string key = this.EntityHelper.GetField <T>(i => i.Code);

            if (string.IsNullOrEmpty(key))
            {
                Log.Warn(string.Concat("Field name is undefined. Type: ", typeof(T).ToString(), ". Property: 'Code'."), this);
                key = "Code";
            }

            Query query = new Query();

            query.Add(new FieldQuery(key, location, MatchVariant.Exactly));

            return(this.Get(query, typeof(T)).FirstOrDefault(o => o != null));
        }
コード例 #32
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (var query = new Query())
     {
         try
         {
             query.Add("email", "e", NpgsqlDbType.Text);
             var a = query.ExecuteNonQuery();
             var v = query.FillData();
             MessageBox.Show("success");
         }
         catch (Exception exception)
         {
             MessageBox.Show(exception.Message);
         }
     }
 }
コード例 #33
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// find autocomplete properties
			foreach (var propertyName in parameters.Names.Where(x => x.EndsWith(Postfix, StringComparison.OrdinalIgnoreCase)).ToArray())
			{
				// remove the parameter
				string value;
				if (!parameters.TryGetAndRemove(context, propertyName, out value))
					continue;

				// cut of the autocomplete postfix
				var propertyNameWithoutPostix = propertyName.Substring(0, propertyName.Length - Postfix.Length);

				// create the specification
				query.Add(new AutocompleteSpecification(propertyNameWithoutPostix, value));
			}
		}
コード例 #34
0
        private void BindingList()
        {
            Query qm = Query.Build(new { SortFields = "MemberID" });

            qm.Add("MemberType", MemberType.普通学生.ToString());
            string Name = PubCom.CheckString(txtName.Text.Trim());

            if (Name != "")
            {
                qm.Add("MemberName", Name);
            }
            string Phone = PubCom.CheckString(txtPhone.Text.Trim());

            if (Phone != "")
            {
                qm.Add("Phone", Phone);
            }
            string Email = PubCom.CheckString(txtEmail.Text.Trim());

            if (Email != "")
            {
                qm.Add("Email", Email);
            }
            string Qualification = PubCom.CheckString(txtQualification.Text.Trim());

            if (Qualification != "")
            {
                qm.Add("Qualification", Qualification);
            }
            string Organization = PubCom.CheckString(txtOrganization.Text.Trim());

            if (Organization != "")
            {
                qm.Add("Organization", Organization);
            }

            int ret = 0;

            rplist.DataSource = bm.GetMembersList(qm, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out ret);
            rplist.DataBind();
            AspNetPager1.RecordCount = ret;

            // 插入日志  query
            SysOperateLog log = new SysOperateLog();

            log.LogID          = StringHelper.getKey();
            log.LogType        = LogType.普通学生信息.ToString();
            log.OperateUser    = GetLogUserName();
            log.OperateDate    = DateTime.Now;
            log.LogOperateType = "普通学生信息查询";
            log.LogAfterObject = JsonHelper.Obj2Json <string>(qm.GetCondition(true));
            bsol.Insert(log);
        }
コード例 #35
0
        //add record click btn
        private void AddRecord_Click(object sender, RoutedEventArgs e)
        {
            //CHECK EVERYTHING
            PopUp  p;
            Filter f             = new Filter();
            string item_name     = f.Trim(i_name.Text);
            string item_quantity = f.Trim(i_quantity.Text);
            string item_cost     = f.Trim(i_cost.Text);

            if (!(item_name == "" || item_quantity == "" || item_cost == ""))
            {
                //GOOD TO GO
                Query q = new Query();


                string[] val = { item_name, item_cost, item_quantity, user_id, "Now()" };
                q.successMessage = "Item " + item_name + " has been added successfully!";
                q.Add("items", val, "item_name,item_cost,quantity_left,_added_by,date_time");

                this.Frame.Opacity = 1;

                this.Frame.Navigate(typeof(Items), null);
            }

            else
            {
                if (item_name == "")
                {
                    p = new PopUp("Please enter the name of the item");
                }
                else if (item_cost == "")
                {
                    p = new PopUp("Please enter the price of the item");
                }
                else if (item_quantity == "")
                {
                    p = new PopUp("Please enter the quantity of the item.");
                }

                else
                {
                    p = new PopUp("Sorry, an error occured. The item couldn't be added. Please try again later");
                }
            }
        }
コード例 #36
0
ファイル: EmployeeService.cs プロジェクト: zafariNet/Saman
        public GetGeneralResponse <IEnumerable <EmployeeView> > GetEmployees(Guid?groupID, int pageSize, int pageNumber, List <FilterData> filter, List <Sort> sort)
        {
            GetGeneralResponse <IEnumerable <EmployeeView> > response = new GetGeneralResponse <IEnumerable <EmployeeView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                Response <Employee> employees = new Response <Employee>();

                if (groupID != null)
                {
                    Query     query    = new Query();
                    Criterion criteria = new Criterion("Group.ID", groupID, CriteriaOperator.Equal);
                    query.Add(criteria);

                    employees = _employeeRepository.FindBy(query, index, count);
                }
                else
                {
                    string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "Employee", sort);
                    if (count == -1)
                    {
                        employees = _employeeRepository.FindAll(query);
                    }
                    else
                    {
                        employees = _employeeRepository.FindAll(query, index, count);
                    }
                }
                foreach (var item in employees.data)
                {
                    item.Permissions = null;
                }
                response.data = employees.data.ConvertToEmployeeViews();

                response.totalCount = employees.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }
            return(response);
        }
コード例 #37
0
        public static IList <RoleDto> GetAllRoles(string userType)
        {
            RolesServiceReference.RoleServiceClient client = null;
            IList <RoleDto> Roles = new List <RoleDto>();
            Query           query = new Query();

            client = new RoleServiceClient();
            if (userType == "CAUser")
            {
                Criterion CriteriaIsApplicableForAckUsers = new Criterion("IsApplicableForAckUsers", false, CriteriaOperator.Equal);
                query.Add(CriteriaIsApplicableForAckUsers);
            }

            Roles = client.FindByQuery(query).Entities.ToList();
            client.Close();
            //Session["UsersRolesList"] = Roles;
            return(Roles);
        }
コード例 #38
0
        public void The_Translator_Should_Produce_Valid_SQL_From_A_Query_Object()
        {
            int    customerId  = 9;
            string expectedSQL = "SELECT * FROM Orders WHERE CustomerId = @CustomerId ORDER BY CustomerId DESC";

            Query query = new Query();

            query.Add(new Criterion("CustomerId", customerId, CriteriaOperator.Equal));
            query.OrderByProperty = new OrderByClause {
                PropertyName = "CustomerId", Desc = true
            };

            SqlCommand command = new SqlCommand();

            query.TranslateInto(command);

            Assert.AreEqual(expectedSQL, command.CommandText);
        }
コード例 #39
0
ファイル: Database.cs プロジェクト: eagsys/Samples
        public int NewQuery(bool withTransaction = false)
        {
            if (Connection != null)
            {
                if (withTransaction)
                {
                    BeginTransaction();
                }

                Query.Add(new DatabaseQuery(Connection, Transaction));

                return(Query.Count - 1);
            }
            else
            {
                return(-1);
            }
        }
コード例 #40
0
        public virtual void TestFindBy()
        {
            string userGroupIdList = "1;2";

            string[] ugIdList = userGroupIdList.Split(';');

            //Default Criteria
            //int startPage = 0;
            Query     query        = new Query();
            Criterion criteriaCAId = new Criterion(Constants.CAID, null, CriteriaOperator.IsNullOrZero);

            query.Add(criteriaCAId);

            Query subquery = null;;
            //Add Filter criteria on selected UserGroups
            Criterion criteriaUserGroup = null;

            foreach (string ugId in ugIdList)
            {
                int userGroupId = Convert.ToInt32(ugId);
                if (userGroupId == 0)
                {
                    break;
                }
                else
                {
                    criteriaUserGroup = new Criterion("ug.UserGroupId", userGroupId, CriteriaOperator.Equal);
                    if (subquery == null)
                    {
                        subquery = new Query();
                    }
                    subquery.Add(criteriaUserGroup);
                    subquery.QueryOperator = QueryOperator.Or;
                }
            }
            if (subquery != null)
            {
                query.AddSubQuery(subquery);
                query.QueryOperator = QueryOperator.And;
            }
            var result = this.UserService.FindBy(query, 0, 100, false);

            Assert.IsTrue(result.Entities.Count == 1, "One User was expected");
        }
コード例 #41
0
        void DoLikeSearch(string term)
        {
            var q = term.Trim();

            if (!string.IsNullOrEmpty(q))
            {
                q = q.Trim();
                var disjunction = Restrictions.Disjunction();
                Querystring["term"] = q;
                foreach (var prop in Metadata.PropertyNames)
                {
                    var proptype = Metadata.GetPropertyType(prop);
                    if (proptype is NHibernate.Type.StringClobType)
                    {
                        return;
                    }
                    else if (proptype is ComponentType)
                    {
                        // do component props
                    }
                    else if (proptype is EntityType)
                    {
                        var subtype  = AR.Holder.GetClassMetadata(proptype.ReturnedClass);
                        var subquery = DetachedCriteria.For(proptype.ReturnedClass)
                                       .SetProjection(Projections.Id());
                        var subdisjunction = Restrictions.Disjunction();
                        foreach (var subprop in subtype.PropertyNames)
                        {
                            var subproptype = subtype.GetPropertyType(subprop);
                            if (subproptype is StringType)
                            {
                                subdisjunction.Add(Restrictions.InsensitiveLike(subprop, q, MatchMode.Anywhere));
                            }
                        }
                        disjunction.Add(Subqueries.PropertyIn(prop, subquery.Add(subdisjunction)));
                    }
                    else if (proptype is StringType)
                    {
                        disjunction.Add(Restrictions.InsensitiveLike(prop, q, MatchMode.Anywhere));
                    }
                }
                Query.Add(disjunction);
            }
        }
コード例 #42
0
        //protected override void OnActionExecuting(ActionExecutingContext filterContext)
        //{
        //    // If session exists
        //    if (isUserLoggedout)
        //    {
        //        if (filterContext.HttpContext.Session != null)
        //        {
        //            if (this.Session[Constants.SKUSERNAME] == null)
        //            {
        //                filterContext.Result = RedirectToAction("LogOn", "Account");
        //                return;
        //            }
        //        }
        //        //otherwise continue with action
        //        base.OnActionExecuting(filterContext);
        //    }
        //}

        #region Common methods
        public ClientDto GetClient(int CAId, bool PopulateChildObjects)
        {
            ClientServiceClient clientService = new ClientServiceClient();
            ClientDto           clientDto     = null;

            clientService = new ClientServiceClient();
            Query     query         = new Query();
            Criterion criterionCAId = new Criterion("CAId", CAId, CriteriaOperator.Equal);

            query.Add(criterionCAId);
            var clients = clientService.FindByQuery(query, PopulateChildObjects);

            if (clients.TotalRecords != 0)
            {
                clientDto = clients.Entities.FirstOrDefault <ClientDto>();
            }

            return(clientDto);
        }
        public static Query CreateQueryFor(GetProductsByCategoryRequest request)
        {
            Query productQuery = new Query();
            Query colourQuery  = new Query();
            Query brandQuery   = new Query();
            Query sizeQuery    = new Query();

            colourQuery.QueryOperator = QueryOperator.Or;
            foreach (int id in request.ColourIds)
            {
                colourQuery.Add(Criterion.Create <Product>(p => p.Colour.Id, id, CriteriaOperator.Equal));
            }

            if (colourQuery.Criteria.Count() > 0)
            {
                productQuery.AddSubQuery(colourQuery);
            }

            brandQuery.QueryOperator = QueryOperator.Or;
            foreach (int id in request.BrandIds)
            {
                brandQuery.Add(Criterion.Create <Product>(p => p.Brand.Id, id, CriteriaOperator.Equal));
            }

            if (brandQuery.Criteria.Count() > 0)
            {
                productQuery.AddSubQuery(brandQuery);
            }

            sizeQuery.QueryOperator = QueryOperator.Or;
            foreach (int id in request.SizeIds)
            {
                sizeQuery.Add(Criterion.Create <Product>(p => p.Size.Id, id, CriteriaOperator.Equal));
            }

            if (sizeQuery.Criteria.Count() > 0)
            {
                productQuery.AddSubQuery(sizeQuery);
            }

            productQuery.Add(Criterion.Create <Product>(p => p.Category.Id, request.CategoryId, CriteriaOperator.Equal));
            return(productQuery);
        }
コード例 #44
0
		/// <summary>
		/// Processes the <paramref name="parameters"/> and turn them into <paramref name="query"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="parameters">The parameters which to process.</param>
		/// <param name="query">The <see cref="Query"/> in which to set the parameters.</param>
		protected override void DoProcess(IMansionContext context, IPropertyBag parameters, Query query)
		{
			// loop through all the remaining properties
			foreach (var propertyName in parameters.Names.ToArray())
			{
				// guard against empty properties
				string valueString;
				if (!parameters.TryGetAndRemove(context, propertyName, out valueString) || string.IsNullOrWhiteSpace(valueString))
					continue;

				// parse the parameters, ignoring properties without values
				object[] values = (valueString).Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray();
				if (values.Length == 0)
					continue;

				// turn it into a specification
				query.Add(SpecificationFactory.IsIn(propertyName, values));
			}
		}
コード例 #45
0
        public static List <DistrictDto> GetDistricts(int state)
        {
            Query     query         = new Query();
            Criterion criteriaState = new Criterion("st.StateId", state, CriteriaOperator.Equal);

            query.Add(criteriaState);
            query.AddAlias(new Alias("st", "StateOfDistrict"));
            DistrictServiceReference.IDistrictService client = new DistrictServiceClient();
            var districts = client.FindByQuery(query);
            List <DistrictDto> districtList = new List <DistrictDto>();

            districtList = districts.Entities.ToList();
            districtList.Insert(0, new DistrictDto
            {
                DistrictId   = 0,
                DistrictName = "[Select]"
            });
            return(districtList);
        }
コード例 #46
0
        public IEnumerable <Order> FindAllCustomersOrdersBy(Guid customerId)
        {
            IEnumerable <Order> customerOrders = new List <Order>();

            Query query = new Query();

            //字符串
            //query.Add(new Criterion("CustomerId", customerId, CriteriaOperator.Equal));

            //Lambda
            query.Add(Criterion.Createe <Order>(o => o.CustomerId, customerId, CriteriaOperator.Equal));

            query.OrderByProperty = new OrderByClause("CustomerId", true);

            customerOrders = _orderRepository.FindBy(query);


            return(customerOrders);
        }
コード例 #47
0
        protected internal new LuceneBooleanOperationBase GroupedOrInternal(string[] fields, IExamineValue[] fieldVals, Occur occurrence)
        {
            if (fields == null)
            {
                throw new ArgumentNullException(nameof(fields));
            }
            if (fieldVals == null)
            {
                throw new ArgumentNullException(nameof(fieldVals));
            }

            //if there's only 1 query text we want to build up a string like this:
            //(field1:query field2:query field3:query)
            //but Lucene will bork if you provide an array of length 1 (which is != to the field length)

            Query.Add(GetMultiFieldQuery(fields, fieldVals, Occur.SHOULD, true), occurrence);

            return(CreateOp());
        }
コード例 #48
0
 private void button2_Click(object sender, EventArgs e)
 {
     using (var query = new Query())
     {
         try
         {
             query.Add("email", "e", NpgsqlDbType.Text);
             var a             = query.ExecuteNonQuery();
             var v             = query.FillData();
             var dataTableJson = new DataTableJsonConverter();
             var json          = dataTableJson.ConvertToJson(v);
             var dataTable     = dataTableJson.ConvertToDataTable(json);
             MessageBox.Show("success");
         }
         catch (Exception exception)
         {
             MessageBox.Show(exception.Message);
         }
     }
 }
コード例 #49
0
        public void RemovePurchaseOrder(string[] ids)
        {
            Query query = new Query();

            query.Add(Criterion.Create <PurchaseOrder>(c => c.Id, ids, CriteriaOperator.InOfString));
            IEnumerable <PurchaseOrder> model = this.GetPurchaseOrderBy(query);

            string result = "删除成功";

            try {
                foreach (PurchaseOrder one in model)
                {
                    one.IsValid = false;
                    this._purchaseOrderRepository.Save(one);
                }
            } catch (Exception ex) {
                result = "修改失败:" + ex.Message;
            }
            this._uow.Commit();
        }
コード例 #50
0
        public int Delete(string userid)
        {
            SysUser su = du.GetUserByUserID(userid);

            if (su.IsMain == true && su.OrgID != null && su.OrgID.ToString() != "")
            {
                Query qm = new Query();
                qm.OrderBy("userid");
                qm.Add("OrgID", (int)su.OrgID);
                IList <SysUser> ls = du.GetUserList(qm);
                foreach (SysUser s in ls)
                {
                    du.Delete(s.UserID);
                }
            }

            du.Delete(userid);

            return(1);
        }
コード例 #51
0
ファイル: StoreService.cs プロジェクト: zafariNet/Saman
        public GeneralResponse DeleteStores(IEnumerable <DeleteRequest> requests)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                foreach (DeleteRequest request in requests)
                {
                    Infrastructure.Querying.Query query = new Query();
                    Criterion CriteriaStoreID           = new Criterion("Store.ID", request.ID, CriteriaOperator.Equal);
                    query.Add(CriteriaStoreID);

                    StoreProduct storeProduct = _storeProductRepository.FindBy(query).FirstOrDefault();
                    if (storeProduct == null)
                    {
                        Store store = new Store();

                        store = _storeRepository.FindBy(request.ID);

                        _storeRepository.Remove(store);
                    }
                    else
                    {
                        response.ErrorMessages.Add("در سیستم برای انبار " + storeProduct.Store.StoreName + " تراکنش وجود داد. لذا امکان حذف این انبار وجود ندارد");
                        return(response);
                    }
                }
                _uow.Commit();
            }

            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
コード例 #52
0
        internal ElasticSearchBooleanOperation RangeQueryInternal <T>(string[] fields, T?min, T?max,
                                                                      bool minInclusive = true, bool maxInclusive = true)
            where T : struct
        {
            Query.Add(new LateBoundQuery(() =>
            {
                //Strangely we need an inner and outer query. If we don't do this then the lucene syntax returned is incorrect
                //since it doesn't wrap in parenthesis properly. I'm unsure if this is a lucene issue (assume so) since that is what
                //is producing the resulting lucene string syntax. It might not be needed internally within Lucene since it's an object
                //so it might be the ToString() that is the issue.
                var outer = new BooleanQuery();
                var inner = new BooleanQuery();

                var fieldsMapping = _searcher.AllProperties;

                foreach (var valueType in fieldsMapping.Where(e => fields.Contains(e.Key.Name)))
                {
                    if (FromElasticType(valueType.Value) is IIndexRangeValueType <T> type)
                    {
                        var q = type.GetQuery(min, max, minInclusive, maxInclusive);
                        if (q != null)
                        {
                            //CriteriaContext.FieldQueries.Add(new KeyValuePair<IIndexFieldValueType, Query>(type, q));
                            inner.Add(q, Occur.SHOULD);
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException(
                            $"Could not perform a range query on the field {valueType.Key}, it's value type is {valueType.Value.Type}");
                    }
                }

                outer.Add(inner, Occur.SHOULD);

                return(outer);
            }), Occurrence);


            return(new ElasticSearchBooleanOperation(this));
        }
コード例 #53
0
        protected override void CheckForValidations(MeasuringUnit measuringunit)
        {
            measuringunit.GetBrokenRules();
            foreach (BusinessRule rule in measuringunit.GetBrokenRules())
            {
                Container.RequestContext.Notifier.AddWarning(BusinessWarningEnum.Validation, rule.Rule);
            }

            //check is Equivalent Unit with the same Unit exists
            Query query = new Query();

            query.Add(new Criterion(Constants.MEASUREMENTUNIT, measuringunit.MeasurementUnit, CriteriaOperator.Equal));
            var result = ExecuteCommand(loc => loc.GetRepository <MeasuringUnit>().FindBy(query));

            if (result.Count() != 0)
            {
                Container.RequestContext.Notifier.AddWarning(BusinessWarningEnum.Validation, ClientMasterBusinessRule.CheckMUMeasurementUnit.Rule);
                base.IsValid = false;
                base.IsValidForBasicMandatoryFields = false;
            }
        }
コード例 #54
0
ファイル: Router.cs プロジェクト: Xanede/BnsLauncher
        private Route GetCurrentRoute()
        {
            var currentLocation = new Uri(BaseUri, _location);

            foreach (var route in _routes)
            {
                var matches = route.Key.Match(BaseUri, currentLocation);
                if (matches != null)
                {
                    Query.Clear();
                    Query.Add(matches.QueryParameters);

                    Params.Clear();
                    Params.Add(matches.BoundVariables);

                    return(route.Value);
                }
            }

            return(null);
        }
コード例 #55
0
        public static List <CityVillageDto> GetPlaces(int district)
        {
            Query     query         = new Query();
            Criterion criteriaState = new Criterion("st.DistrictId", district, CriteriaOperator.Equal);

            query.Add(criteriaState);
            query.AddAlias(new Alias("st", "DistrictOfCityVillage"));

            CityVillageServiceReference.ICityVillageService client = new CityVillageServiceClient();
            var cityVillage = client.FindByQuery(query);
            List <CityVillageDto> cityVillageList = new List <CityVillageDto>();

            cityVillageList = cityVillage.Entities.ToList();
            cityVillageList.Insert(0, new CityVillageDto
            {
                CityVillageId = 0,
                CityOrVillage = CityVillageType.City,
                Name          = "[Select]"
            });
            return(cityVillageList);
        }
コード例 #56
0
 public void SetQuery(IQueryBuilder queryBuilder)
 {
     if (queryBuilder == null)
     {
         throw new ArgumentNullException("queryBuilder");
     }
     if (queryBuilder.QueryParameters.Count == 0)
     {
         throw new ArgumentException("QueryParameters are empty", "queryBuilder");
     }
     for (int i = 0; i < queryBuilder.QueryParameters.Count; i++)
     {
         var key = queryBuilder.QueryParameters.GetKey(i);
         if (key.Equals(CommonParams.WT, StringComparison.InvariantCultureIgnoreCase))
         {
             throw new InvalidOperationException("wt parameter is not allowed in the QueryParameters");
         }
         var value = queryBuilder.QueryParameters.Get(i);
         Query.Add(key, value);
     }
 }
コード例 #57
0
        public GetGeneralResponse <IEnumerable <SupportStatusView> > GetFirstSupportStatuses()
        {
            GetGeneralResponse <IEnumerable <SupportStatusView> > response = new GetGeneralResponse <IEnumerable <SupportStatusView> >();

            try
            {
                Query     query = new Query();
                Criterion firstStatusesCriteria = new Criterion("IsFirstSupportStatus", true, CriteriaOperator.Equal);
                query.Add(firstStatusesCriteria);

                Response <SupportStatus> supportStatusViews = _supportStatusRepository.FindByQuery(query);

                response.data       = supportStatusViews.data.ConvertToSupportStatusViews();
                response.totalCount = supportStatusViews.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }

            return(response);
        }
コード例 #58
0
ファイル: Main.cs プロジェクト: meebey/SmartDao
 private static void TestHighLevel(DatabaseManager dbMan, int count)
 {
     Query<DBTest> query = new Query<DBTest>(dbMan);
     for (int i = 0; i < count; i++) {
         DateTime now = DateTime.UtcNow;
         DBTest test = new DBTest();
         test.PKInt32 = i;
         test.StringColumn = "abc";
         test.DateTimeColumn = now;
         test.DateTimeColumnNotNullable = now;
         test.BooleanColumn = true;
         test.DoubleColumn = i;
         query.Add(test);
     }
 }
コード例 #59
0
        /// <summary>
        /// Adds the checkboxes.
        /// </summary>
        /// <param name="checklists">The checklists.</param>
        /// <param name="condition">The condition.</param>
        public virtual void AddCheckboxes(NameValueCollection checklists, QueryCondition condition)
        {
            for (var cl = 0; cl < checklists.Count; cl++)
              {
            var fieldName = checklists.Keys[cl];
            var checkBoxesValues = new ListString(checklists[cl]);
            var subquery = new Query();
            for (var cb = 0; cb < checkBoxesValues.Count; cb++)
            {
              subquery.Add(new FieldQuery(fieldName, checkBoxesValues[cb], MatchVariant.Exactly));
              if (cb < checkBoxesValues.Count - 1)
              {
            subquery.AppendCondition(QueryCondition.Or);
              }
            }

            this.CheckListsSubQuery.AppendSubquery(subquery);
            if (cl < checklists.Count - 1)
            {
              this.CheckListsSubQuery.AppendCondition(QueryCondition.And);
            }
              }

              this.AddSubquery(this.CheckListsSubQuery, condition);
        }
コード例 #60
0
ファイル: AcquireLock.cs プロジェクト: fallin/cerulean-consul
 public override void BuildQuery(Query query)
 {
     query.Add("acquire", Session);
 }