Example #1
0
		public EqOrNullExpression(string propertyName, object value, bool ignoreCase)
		{
			if(value==null)
				realCriterion = new NullExpression(propertyName);
			else
				realCriterion= new SimpleExpression(propertyName, value, " = ", ignoreCase);
		}
		private static SqlString[] GetColumnNamesUsingPropertyName(
			ICriteriaQuery criteriaQuery, 
			ICriteria criteria, 
			string propertyName, 
			object value, 
			ICriterion critertion)
		{
			string[] columnNames = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName);
			IType propertyType = criteriaQuery.GetTypeUsingProjection(criteria, propertyName);

			if (value != null && !(value is System.Type) && !propertyType.ReturnedClass.IsInstanceOfType(value))
			{
				throw new QueryException(string.Format(
											"Type mismatch in {0}: {1} expected type {2}, actual type {3}",
											critertion.GetType(), propertyName, propertyType.ReturnedClass, value.GetType()));
			}

			if (propertyType.IsCollectionType)
			{
				throw new QueryException(string.Format(
											"cannot use collection property ({0}.{1}) directly in a criterion,"
											+ " use ICriteria.CreateCriteria instead",
											criteriaQuery.GetEntityName(criteria), propertyName));
			}
			return Array.ConvertAll<string, SqlString>(columnNames, delegate(string col)
			{
				return new SqlString(col);
			});
		}
 public PresortBestSplitter(ICriterion criterion,
                            uint max_features,
                            uint min_samples_leaf,
                            Random random_state)
     : base(criterion, max_features, min_samples_leaf, random_state)
 {
 }
 public CriteriaQuery(ICriterion  criteria)
 {
     if (criteria != null)
     {
         this.criterion = criteria;
         this.criterion.SetQuery(this);
     }
 }
 public InsensitiveLikeIncludeNullExpression(string propertyName, string value, MatchMode matchMode) {
     if(value != null)
         _criterion = Restrictions.Disjunction()
             .Add(Restrictions.InsensitiveLike(propertyName, value, matchMode))
             .Add(Restrictions.IsNull(propertyName));
     else
         _criterion = Restrictions.IsNull(propertyName);
 }
 /// <summary>
 /// 생성자
 /// </summary>
 /// <param name="propertyName"></param>
 /// <param name="value"></param>
 public EqIncludeNullExpression(string propertyName, object value) {
     if(value != null)
         _criterion = Restrictions.Disjunction()
             .Add(Restrictions.Eq(propertyName, value))
             .Add(Restrictions.IsNull(propertyName));
     else
         _criterion = Restrictions.IsNull(propertyName);
 }
Example #7
0
 private IEnumerable<FileSystemItem> FindChildren(FileSystemPath path, ICriterion criterion)
 {
     return Session.CreateCriteria<FileSystemItem>()
         .Add(Restrictions.Eq("Path.Parent", path.ToString()))
         .Add(criterion)
         .AddOrder(Order.Asc("Path.Name"))
         .SetCacheable(true)
         .List<FileSystemItem>();
 }
		public CriteriaQuery(string aFullClassName, ICriterion criteria)
		{
			this.fullClassName = aFullClassName;
			if (criteria != null)
			{
				this.criterion = criteria;
				this.criterion.SetQuery(this);
			}
		}
        public InsensitiveLikeIncludeNullExpression(IProjection projection, string value, MatchMode matchMode) {
            _projection = projection;

            if(value != null)
                _criterion = Restrictions.Disjunction()
                    .Add(Restrictions.InsensitiveLike(projection, value, matchMode))
                    .Add(Restrictions.IsNull(projection));
            else
                _criterion = Restrictions.IsNull(projection);
        }
        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="projection"></param>
        /// <param name="value"></param>
        public EqIncludeNullExpression(IProjection projection, object value) {
            _projection = projection;

            if(value != null)
                _criterion = Restrictions.Disjunction()
                    .Add(Restrictions.Eq(projection, value))
                    .Add(Restrictions.IsNull(projection));
            else
                _criterion = Restrictions.IsNull(projection);
        }
 public SplitterBase(ICriterion criterion,
                 uint max_features,
                 uint min_samples_leaf,
                 Random random_state)
 {
     this.criterion = criterion;
     this.max_features = max_features;
     this.min_samples_leaf = min_samples_leaf;
     this.random_state = random_state ?? new Random();
 }
Example #12
0
		/// <summary>
		/// Adds a collection of ICriterion to an ICriteria.
		/// </summary>
		/// <param name="criteria">The ICriteria that will be modified.</param>
		/// <param name="criterions">The collection of Criterion.</param>
		internal static void AddCriterionToCriteria(ICriteria criteria, ICriterion[] criterions)
		{
			if (criterions != null)
			{
				foreach (ICriterion cond in criterions)
				{
					criteria.Add(cond);
				}
			}
		}
		public void CountQuery_ByTypeAndCriteria()
		{
			Prepare();
			ICriterion[] criterionArray = new ICriterion[] 
            { 
                Expression.Eq("Category", "c")
            };
			CountQuery cq = new CountQuery(typeof(Post), criterionArray);
			int recordCount = (int)ActiveRecordMediator.ExecuteQuery(cq);
			Assert.AreEqual(2, recordCount);
		}
 public SqlFunctionExpression(String functionName, System.Type returnType, Object[] paramValues,
     System.Type[] paramTypes, ICriterion innerCriterion, int propertyPosition,
     SqlFunctionExpression rightFunction)
 {
     FunctionName = functionName;
     ReturnType = returnType;
     ParameterValues = paramValues;
     ParameterTypes = paramTypes;
     InnerCriterion = innerCriterion;
     PropertyPosition = propertyPosition;
     RightFunction = rightFunction;
 }
Example #15
0
        public static SqlFunctionExpression GetFunctionCriteria(MethodCallExpression call, ICriterion criterion,
            SqlFunctionExpression rightFunction)
        {
            System.Type[] paramTypes = null;
            object[] paramValues = GetMethodParameterValues(call, out paramTypes);

            int propertyPosition = 0;
            string methodName = QueryUtil.GetMethodName(call, out propertyPosition);

            return new SqlFunctionExpression(methodName, call.Method.ReturnType, paramValues, paramTypes, criterion,
                                             propertyPosition, rightFunction);
        }
 public static IList Find(ICriterion crit, Type type, PagerInfo pi)
 {
     ISession s = Sessions.GetSession();
     try
     {
         ICriteria c = s.CreateCriteria(type);
         if (crit != null ) c.Add(crit);
         if (pi != null )
         {
             c.SetFirstResult(pi.FirstResult);
             c.SetMaxResults(pi.MaxResults);
         }
         return c.List();
     }
     finally
     {
         s.Close();
     }
 }
        public KPJqGridControl(string primaryKey, HiddenField hiddenKey, Type typeEntity, KPItemModelCollection KPitemsModel,
                              KPJqGridDoubleClickActionEnum DoubleClickAction, ICriterion filter, Order order)
        {
            #region Filter/Order
            this.InitialFilter = filter;
            this.InitialOrder = order;
            #endregion

            this.HiddenKey = hiddenKey == null ? new HiddenField() : hiddenKey;
            this.Caption = String.Empty;
            this.PrimaryKey = primaryKey;
            this.UrlService = System.Web.VirtualPathUtility.ToAbsolute("~/WCF/EntityService.svc/GetEntityFilter");
            this.TypeEntity = typeEntity;
            this.KPItemsModel = KPitemsModel;
            this.DoubleClickAction = DoubleClickAction;

            this.RowNum = KPJqGridRowNumEnum.RowsView_10;
            this.OrderRecords = KPJqGridTypeOrderEnum.ASC;
            this.ViewTotalRecordsLabel = true;
            this.Height = 100;
            this.Width = 300;
        }
 public KPGridJsonProperties(bool isSearch, int page, int rows,
                             string propertyOrder, string orderTypeJason,
                             string filterJson,  KPSessionJQGrid sessionJQGrid, string propertyCompany,
                             ICriterion initialFilter, Order initialOrder, object[] colModel)
 {
     IsSearch = isSearch;
     Page = page;
     Rows = rows;
     PropertyOrder = propertyOrder;
     OrderTypeJson = orderTypeJason;
     User = sessionJQGrid.SecuritySession.Login;
     Company = sessionJQGrid.SecuritySession.FrwCompany;
     PropertyCompanyEntity = propertyCompany;
     FilterJson = filterJson;
     ColModel = Array.ConvertAll<object, string>(colModel, Convert.ToString);
     List<JqGridColumnCustom> jqGridColumnCustomList = new List<JqGridColumnCustom>();
     foreach (string item in ColModel)
         jqGridColumnCustomList.Add(KPJsonJqGrid.GetColumnCustom(item));
     ColumnsCustom = jqGridColumnCustomList.ToArray();
     InitialFilter = initialFilter;
     InitialOrder = initialOrder;
 }
		public static SqlString[] GetColumnNamesForSimpleExpression(
			string propertyName,
			IProjection projection,
			ICriteriaQuery criteriaQuery,
			ICriteria criteria,
			IDictionary<string, IFilter> enabledFilters,
			ICriterion criterion,
			object value)
		{
			if (projection == null)
			{
				return GetColumnNamesUsingPropertyName(
					criteriaQuery, 
					criteria, 
					propertyName,
					value, 
					criterion);
			}
			else
			{
				return GetColumnNamesUsingProjection(projection, criteriaQuery, criteria, enabledFilters);
			}
		}
Example #20
0
 private Task <IResponse <T> > GetAllProjectionsAsync <T>(ICriterion criterion) where T : class, new()
 {
     return(Task.Run <IResponse <T> >(() => GetAllProjections <T>(criterion)));
 }
Example #21
0
 IResponse <T> IModelRequestService.GetAllProjections <T>(ICriterion criterion)
 {
     return(GetAllProjections <T>(criterion));
 }
Example #22
0
 IResponse <T> IModelRequestService.ExecuteCommand <T>(System.Data.DataSet ds, ICriterion criterion)
 {
     return(ExecuteCommand <T>(ds, criterion));
 }
Example #23
0
 IResponse <T, U> IModelRequestService.ExecuteMany <T, U>(System.Collections.Generic.IEnumerable <T> list, ICriterion criterion)
 {
     throw new NotImplementedException();
 }
Example #24
0
 public IEnumerable <IInventoryPostingRuleState> Get(ICriterion filter, IList <string> orders = null, int firstResult = 0, int maxResults = int.MaxValue, IList <string> fields = null)
 {
     return(GetAsync(filter, orders, firstResult, maxResults, fields).GetAwaiter().GetResult());
 }
        /// <summary>
        /// Sends a multi-pages message
        /// </summary>
        /// <param name="context"></param>
        /// <param name="pager"></param>
        /// <param name="Reactions"></param>
        /// <param name="criterion"></param>
        /// <returns></returns>
        public async Task <IUserMessage> SendPaginatedMessageAsync(SocketCommandContext context, PaginatedMessage pager, ReactionList Reactions, ICriterion <SocketReaction> criterion = null)
        {
            var callback = new PaginatedMessageCallback(new InteractiveService(Discord.GetShardFor(context.Guild)), context, pager, criterion);
            await callback.DisplayAsync(Reactions).ConfigureAwait(false);

            return(callback.Message);
        }
 public static Object FindFirst(Type t, ICriterion[] criteria)
 {
     return FindOne(t, criteria);
 }
 public DetachedCriteria CreateAlias(string associationPath, string alias, JoinType joinType, ICriterion withClause)
 {
     criteria.CreateAlias(associationPath, alias, joinType, withClause);
     return(this);
 }
 public DetachedCriteria Add(ICriterion criterion)
 {
     criteria.Add(criterion);
     return(this);
 }
        /// <summary>
        /// 获取所有子孙裔节点
        /// </summary>
        /// <returns></returns>
        public virtual IList <T> GetDescendantNodes()
        {
            ICriterion crit = Expression.Like(Prop_Path, this.ID, MatchMode.Anywhere);

            return(EntityBase <T> .FindAll(crit));
        }
Example #30
0
 private Task <IResponse <T, U> > ExecuteRpcAsync <T, U>(T model, ICriterion criterion) where T : class, new()
 {
     return(Task.Run <IResponse <T, U> >(() => ExecuteRpc <T, U>(model, criterion)));
 }
Example #31
0
 IResponse <T, U> IRpcRequestService.ExecuteRpc <T, U>(T model, ICriterion criterion)
 {
     return(ExecuteRpc <T, U>(model, criterion));
 }
Example #32
0
        public IList <T> ObtenerTodosVigentes()
        {
            ICriterion expresion = Expression.Eq("Vigente", true);

            return(repositorio.ObtenerTodos(expresion).ToList <T>());
        }
Example #33
0
 public IEnumerable <IOrganizationState> Get(ICriterion filter, IList <string> orders = null, int firstResult = 0, int maxResults = int.MaxValue)
 {
     return(Get(filter, orders, firstResult, maxResults, null));
 }
 public static Array Where(Type t, ICriterion[] criteria, Order[] order)
 {
     return FindAll(t, order, criteria);
 }
Example #35
0
 public virtual long GetCount(ICriterion filter)
 {
     return(GetCountAsync(filter).GetAwaiter().GetResult());
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="AndExpression"/> class
		/// that combines two <see cref="ICriterion"/>.
		/// </summary>
		/// <param name="lhs">The <see cref="ICriterion"/> to use as the left hand side.</param>
		/// <param name="rhs">The <see cref="ICriterion"/> to use as the right hand side.</param>
		public AndExpression(ICriterion lhs, ICriterion rhs) : base(lhs, rhs)
		{
		}
Example #37
0
 public IEnumerable <IInventoryPostingRuleState> Get(ICriterion filter, IList <string> orders = null, int firstResult = 0, int maxResults = int.MaxValue)
 {
     return(Get(filter, orders, firstResult, maxResults, null));
 }
Example #38
0
		/// <summary>
		/// Returns all instances found for the specified type
		/// using criteria and IStatelessSession.
		/// </summary>
		/// <param name="type">The target type.</param>
		/// <param name="criterias">The criteria expression</param>
		/// <returns>The <see cref="Array"/> of results.</returns>
		public virtual Array FindAllStateless(Type type, ICriterion[] criterias)
		{
			return FindAllStateless(type, criterias, null, int.MinValue, int.MinValue);
		}
Example #39
0
		/// <summary>
		/// Returns all instances found for the specified type
		/// using criteria and IStatelessSession.
		/// </summary>
		/// <param name="type">The target type.</param>
		/// <param name="criterias">The criteria expression</param>
		/// <param name="sortItems">An <see cref="Array"/> of <see cref="Order"/> objects.</param>
		/// <returns>The <see cref="Array"/> of results.</returns>
		public virtual Array FindAllStateless(Type type, ICriterion[] criterias, Order[] sortItems)
		{
			return FindAllStateless(type, criterias, sortItems, int.MinValue, int.MinValue);
		}
Example #40
0
        public T Obtener(string nombreCampo, object valorBuscado)
        {
            ICriterion expresion = Expression.Eq(nombreCampo, valorBuscado);

            return(repositorio.Obtener(expresion));
        }
Example #41
0
 IResponse <T, U> IModelRequestService.ExecuteAction <T, U>(T model, ICriterion criterion)
 {
     return(ExecuteAction <T, U>(model, criterion));
 }
        /// <summary>
        /// Waits for the next message to be sent
        /// </summary>
        /// <param name="context"></param>
        /// <param name="criterion"></param>
        /// <param name="timeout"></param>
        /// <returns></returns>
        public async Task <SocketMessage> NextMessageAsync(SocketCommandContext context, ICriterion <SocketMessage> criterion, TimeSpan?timeout = null)
        {
            timeout = timeout ?? _defaultTimeout;

            var eventTrigger = new TaskCompletionSource <SocketMessage>();

            async Task Handler(SocketMessage message)
            {
                var result = await criterion.JudgeAsync(context, message).ConfigureAwait(false);

                if (result)
                {
                    eventTrigger.SetResult(message);
                }
            }

            context.Client.MessageReceived += Handler;

            var trigger = eventTrigger.Task;
            var delay   = Task.Delay(timeout.Value);
            var task    = await Task.WhenAny(trigger, delay).ConfigureAwait(false);

            context.Client.MessageReceived -= Handler;

            if (task == trigger)
            {
                return(await trigger.ConfigureAwait(false));
            }
            return(null);
        }
Example #43
0
 private Task <IResponse <T, U> > ExecuteManyAsync <T, U>(IEnumerable <T> list, ICriterion criterion) where T : class, new()
 {
     return(Task.Run <IResponse <T, U> >(() => ExecuteMany <T, U>(list, criterion)));
 }
Example #44
0
        /// <summary>
        /// 选择数据
        /// </summary>
        private void DoSelect()
        {
            // 构建查询表达式
            SearchCriterion sc = new HqlSearchCriterion();

            sc.SetOrder("SortIndex");

            ICriterion crit = null;

            if (RequestActionString == "querychildren")
            {
                if (ids != null && ids.Count > 0 || pids != null && pids.Count > 0)
                {
                    if (ids != null && ids.Count > 0)
                    {
                        IEnumerable <string> distids = ids.Distinct().Where(tent => !String.IsNullOrEmpty(tent));
                        crit = Expression.In(A_TaskWBS.Prop_Id, distids.ToArray());
                    }

                    if (pids != null && pids.Count > 0)
                    {
                        IEnumerable <string> dispids = pids.Distinct().Where(tent => !String.IsNullOrEmpty(tent));

                        if (crit != null)
                        {
                            crit = SearchHelper.UnionCriterions(crit, Expression.In(A_TaskWBS.Prop_ParentID, dispids.ToArray()));
                        }
                        else
                        {
                            crit = Expression.In(A_TaskWBS.Prop_ParentID, dispids.ToArray());
                            string pid = dispids.ToArray()[0];
                            if (pid == "1437f360-6937-409b-9548-964661e6c27c")
                            {
                                string test = pid;
                            }
                            //不是自己责任人的只能看到属于自己的(暂时屏蔽掉,有权限看到自己的子节点)

                            /*if (A_TaskWBS.Find(pid).DutyId.IndexOf(this.UserInfo.UserID) < 0)
                             * {
                             *  //判断是否父节点有权限,有全部输出
                             *  //A_TaskWBS tp = A_TaskWBS.Find(pid);
                             *  string sqlall = " select Id,Path from " + db + "..A_TaskWBS where DutyId like '%" + this.UserInfo.UserID + "%'";
                             *  DataTable dtall = DataHelper.QueryDataTable(sqlall);
                             *  string checksql = "select Id from " + db + "..A_TaskWBS where ParentId='" + pid + "' and ";
                             *  string rules = "";
                             *  foreach (DataRow row in dtall.Rows)
                             *  {
                             *      if (row["Path"] != null && row["Path"].ToString() != "")
                             *          rules += "  Path like '%" + row["Path"] + "%' or";
                             *  }
                             *  if (rules != "") rules = rules.Substring(0, rules.Length - 2);
                             *  if (DataHelper.QueryDataTable(checksql + "(" + rules + ")").Rows.Count == 0)
                             *  {
                             *      //判断有权限的子节点梯队
                             *      string sqlIds = " select Id,Path from " + db + "..A_TaskWBS where DutyId like '%" + this.UserInfo.UserID + "%' and Path like '%" + pid + "%'";
                             *      DataTable dt = DataHelper.QueryDataTable(sqlIds);
                             *      string cids = "";
                             *      string cpids = "";
                             *      foreach (DataRow row in dt.Rows)
                             *      {
                             *          cids += row["Path"].ToString() + '.';
                             *          cpids += " or Path like '%" + row["Path"].ToString() + "%'";
                             *      }
                             *      cids = cids.TrimEnd('.').Replace(".", "','");
                             *      crit = Expression.Sql(" ParentID = '" + pid + "' and  ( Id in ('" + cids + "') " + cpids + " )");//SearchHelper.IntersectCriterions(crit);
                             *
                             *  }
                             * }*/
                        }
                    }
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(year))
                {
                    crit = Expression.Eq(A_TaskWBS.Prop_Year, year);

                    /*EasyDictionary es = SysEnumeration.GetEnumDict("AimType");
                     * foreach (var at in es)
                     * {
                     *  if (!this.RequestData.Get<bool>(at.Value.ToString()))
                     *  {
                     *      crit = SearchHelper.IntersectCriterions(crit, Expression.Not(Expression.Eq(A_TaskWBS.Prop_TaskType, at.Value)));
                     *  }
                     * }*/
                }
                if (this.Request.QueryString["Type"] != null && this.Request.QueryString["Type"].ToString() != "")
                {
                    crit = SearchHelper.UnionCriterions(Expression.IsNull(A_TaskWBS.Prop_ParentID),
                                                        Expression.Eq(A_TaskWBS.Prop_ParentID, String.Empty));
                    //crit = SearchHelper.IntersectCriterions(crit,Expression.Eq(A_TaskWBS.Prop_Type, this.Request.QueryString["Type"].ToString()));
                }
                else
                {
                    /*crit = SearchHelper.UnionCriterions(Expression.IsNull(A_TaskWBS.Prop_ParentID),
                     *  Expression.Eq(A_TaskWBS.Prop_ParentID, String.Empty));
                     * //crit = Expression.Like(A_TaskWBS.Prop_DutyId, this.UserInfo.UserID);*/
                    //先屏蔽掉一进来自己只能看到自己的限制,根据权限过滤查询.
                    //crit = SearchHelper.IntersectCriterions(crit, Expression.Sql(" Id in (select distinct SUBSTRING(isnull(Path,Id),0,37) from A_TaskWBS where DutyId like '%" + this.UserInfo.UserID + "%')"));
                }
                crit = CheckProperty(crit);
            }

            if (crit != null)
            {
                ents = A_TaskWBS.FindAll(sc, crit);
            }
            else
            {
                ents = A_TaskWBS.FindAll(sc);
            }

            if (ents != null && ents.Length != 0)
            {
                this.PageState.Add("DtList", ents.OrderBy(en => en.Code));
            }
        }
Example #45
0
 private Task <IResponse <T> > ExecuteCommandAsync <T>(DataSet ds, ICriterion criterion) where T : class, new()
 {
     return(Task.Run <IResponse <T> >(() => ExecuteCommand <T>(ds, criterion)));
 }
Example #46
0
        //权限判定专用
        private ICriterion CheckProperty(ICriterion ic)
        {
            string         sql      = "";
            EasyDictionary dic      = new EasyDictionary();
            DataTable      dt       = new DataTable();
            string         DeptName = this.RequestData.Get <string>("DeptName");

            //能看到全部的角色
            if (this.UserContext.Roles.Where(ent => ent.Name == "全部目标查看").Count() > 0)
            {
                sql = @"select v.Name,isnull(s.sort,v.Type) Type from (select Name,10000 Type from SysGroup as ent WHERE PathLevel=2 and (Type = 2) and Name not in ('院领导','内部退休','副总工程师','临时工')
union
select UserName Name,Type from dbo.View_SysUserGroup  where ChildDeptName='主管院长') v left join {0}..A_SortSetting s on v.Name=s.PName
order by isnull(s.sort,v.Type) asc
";
                dt  = DataHelper.QueryDataTable(string.Format(sql, db));
                this.PageState.Add("CurrentDept", dt.Rows[0][0]);
                ICriterion ich = null;
                if (string.IsNullOrEmpty(DeptName))
                {
                    ich = Expression.Sql(" DutyName ='" + dt.Rows[0][0].ToString() + "'");
                }
                else
                {
                    ich = Expression.Sql(" (DutyName ='" + DeptName + "' or DeptName like '%" + DeptName + "%')");
                }
                ic = SearchHelper.IntersectCriterions(ic, ich);
            }
            //只是主管院长
            else if (this.UserContext.Groups.Where(ent => ent.Name == "主管院长").Count() > 0)
            {
                sql = @"select distinct ParentDeptName from View_SysUserGroup where ChildDeptName='主管院长' and UserId ='{0}'  
                union select '{1}'";
                sql = string.Format(sql, this.UserInfo.UserID, this.UserInfo.Name);
                dt  = DataHelper.QueryDataTable(sql);
                this.PageState.Add("CurrentDept", this.UserInfo.Name);
                ICriterion ich = null;
                if (string.IsNullOrEmpty(DeptName))
                {
                    ich = Expression.Sql(" DutyName ='" + this.UserInfo.Name + "'");
                }
                else
                {
                    ich = Expression.Sql(" (DutyName ='" + DeptName + "' or DeptName like '%" + DeptName + "%')");
                }
                ic = SearchHelper.IntersectCriterions(ic, ich);
            }
            //只是部门长
            else if (this.UserContext.Groups.Where(ent => ent.Name == "所(处、部)长").Count() > 0)
            {
                sql = @"select distinct case when ChildDeptName='所(处、部)长' then ParentDeptName else ChildDeptName end from dbo.View_SysUserGroup where UserId like '%" + this.UserInfo.UserID + "%'";
                dt  = DataHelper.QueryDataTable(sql);
                this.PageState.Add("CurrentDept", dt.Rows[0][0]);
                ICriterion ich = Expression.Sql("( DutyName ='" + dt.Rows[0][0].ToString() + "' or DeptName like '%" + dt.Rows[0][0].ToString() + "%')");
                ic = SearchHelper.IntersectCriterions(ic, ich);
            }
            //普通责任人,能看到自己的责任任务
            else
            {
                sql = @"select distinct case when ChildDeptName='所(处、部)长' then ParentDeptName else ChildDeptName end from dbo.View_SysUserGroup where UserId like '%" + this.UserInfo.UserID + "%' and Type=2";
                dt  = DataHelper.QueryDataTable(sql);
                this.PageState.Add("CurrentDept", dt.Rows[0][0]);
                ICriterion ich = Expression.Sql(" ( DutyName ='" + dt.Rows[0][0].ToString() + "' or DeptName like '%" + dt.Rows[0][0].ToString() + "%')");
                ic = SearchHelper.IntersectCriterions(ic, ich);
            }
            foreach (DataRow row in dt.Rows)
            {
                dic.Add(row[0].ToString(), row[0]);
            }
            this.PageState.Add("Depts", dic);
            return(ic);
        }
 public DetachedCriteria CreateCriteria(string associationPath, string alias, JoinType joinType, ICriterion withClause)
 {
     return(new DetachedCriteria(impl, criteria.CreateCriteria(associationPath, alias, joinType, withClause)));
 }
Example #48
0
        public IList <T> ObtenerTodos(string nombreCampo, object valorBuscado)
        {
            ICriterion expresion = Expression.Eq(nombreCampo, valorBuscado);

            return(repositorio.ObtenerTodos(expresion).ToList <T>());
        }
 public static Array Where(Type t, ICriterion[] criteria, Order order)
 {
     return Where(t, criteria, new Order[] { order } );
 }
        public void CreateWorkSheet(ExcelFile ex, DateTime dateFrom, DateTime dateTo)
        {
            var daySpan = dateTo.Subtract(dateFrom).Days;

            for (var i = 0; i <= daySpan; i++)
            {
                var day       = dateFrom.Add(new TimeSpan(i, 0, 0, 0));
                var worksheet = ex.Worksheets.AddCopy(day.ToString("dd-MMM-yyyy"), ex.Worksheets[0]);

                ICriterion finalCriterion = Expression.Ge("Id", 0);
                finalCriterion = Expression.And(finalCriterion, Expression.Eq("Status", StatusType.Approved));
                finalCriterion = Expression.And(finalCriterion, Expression.Not(Expression.Eq("IsTransferred", true)));
                finalCriterion = Expression.And(finalCriterion, Expression.Eq("Deleted", false));

                var timeSpan = new TimeSpan(0, 23, 59, 59);
                var dateFrom2DayBookingCriterion = Expression.Ge("StartDate", day);
                var dateTo2DayBookingCriterion   = Expression.Le("StartDate", day.Date.Add(timeSpan));
                var dateFrom3DayBookingCriterion = Expression.Le("StartDate", day);
                var dateTo3DayBookingCriterion   = Expression.Ge("EndDate", day.Date.Add(timeSpan));

                var dateFromTo2DayBookingCriterion = Expression.And(dateFrom2DayBookingCriterion, dateTo2DayBookingCriterion);
                var dateFromTo3DayBookingCriterion = Expression.And(dateFrom3DayBookingCriterion, dateTo3DayBookingCriterion);

                var dateFromToCriterion = Expression.Or(dateFromTo2DayBookingCriterion, dateFromTo3DayBookingCriterion);

                finalCriterion = Expression.And(finalCriterion, dateFromToCriterion);


                var bookingList     = Module.GetObject <Booking>(finalCriterion, 0, 0);
                var currentRowSheet = 1;
                if (bookingList.Count > 0)
                {
                    for (int l = 0; l < bookingList.Count; l++)
                    {
                        var customerListVn   = new List <Customer>();
                        var customerList     = new List <Customer>();
                        var booking          = bookingList[l];
                        var bookingRoomslist = Module.GetObject <BookingRoom>(Expression.Eq("Book", booking), 0, 0);
                        for (int k = 0; k < bookingRoomslist.Count; k++)
                        {
                            var bookingRooms      = bookingRoomslist[k];
                            var realCustomersList = bookingRooms.RealCustomers;
                            for (int j = 0; j < realCustomersList.Count; j++)
                            {
                                var customer = realCustomersList[j] as Customer;
                                if (customer != null)
                                {
                                    customerList.Add(customer);
                                }
                                else
                                {
                                    throw new Exception("customer = null");
                                }
                            }
                        }
                        FillDataToSheet(worksheet, customerList, 1, booking, ref currentRowSheet);
                    }
                }
            }
            ex.Worksheets[0].Delete();
        }
Example #51
0
		public ConditionalProjection(ICriterion criterion, IProjection whenTrue, IProjection whenFalse)
		{
			this.whenTrue = whenTrue;
			this.whenFalse = whenFalse;
			this.criterion = criterion;
		}
        protected override void rptBookingList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header)
            {
                Repeater rptCruisesRow = e.Item.FindControl("rptCruisesRow") as Repeater;
                if (rptCruisesRow != null)
                {
                    rptCruisesRow.DataSource = AllCruises;
                    rptCruisesRow.DataBind();
                }

                Repeater rptCruiseRoom = e.Item.FindControl("rptCruiseRoom") as Repeater;
                if (rptCruiseRoom != null)
                {
                    rptCruiseRoom.DataSource = AllCruises;
                    rptCruiseRoom.DataBind();
                }
            }

            #region -- Item --
            if (e.Item.DataItem is DateTime)
            {
                Literal litTr = e.Item.FindControl("litTr") as Literal;
                if (litTr != null)
                {
                    if (e.Item.ItemType == ListItemType.Item)
                    {
                        litTr.Text = "<tr>";
                    }
                    else
                    {
                        litTr.Text = @"<tr style=""background-color:#E9E9E9"">";
                    }
                }

                DateTime date      = (DateTime)e.Item.DataItem;
                Label    labelDate = (Label)e.Item.FindControl("labelDate");
                if (labelDate != null)
                {
                    labelDate.Text = date.ToString("dd/MM/yyyy");
                }

                HyperLink hplDate = (HyperLink)e.Item.FindControl("hplDate");
                if (hplDate != null)
                {
                    hplDate.Text        = date.ToString("dd/MM/yyyy");
                    hplDate.NavigateUrl = string.Format("BookingReport.aspx?NodeId={0}&SectionId={1}&Date={2}", Node.Id,
                                                        Section.Id, date.ToOADate());
                }

                #region -- Counting --
                int count;
                // Điều kiện bắt buộc
                ICriterion criterion = Expression.And(Expression.Eq("Deleted", false),
                                                      Expression.Eq("Status", StatusType.Approved));
                // Không bao gồm booking transfer
                criterion      = Expression.And(criterion, Expression.Not(Expression.Eq("IsTransferred", true)));
                criterion      = Module.AddDateExpression(criterion, date);
                _util.Bookings = Module.GetBookingListInPeriod(false, StatusType.Approved, false, date);

                Repeater rptCruiseRoom = e.Item.FindControl("rptCruiseRoom") as Repeater;
                if (rptCruiseRoom != null)
                {
                    rptCruiseRoom.DataSource = AllCruises;
                    rptCruiseRoom.DataBind();
                }
                #endregion
            }
            #endregion
        }
Example #53
0
 public void Add(ICriterion criteria) {
    _criteria.Add(criteria);
 }
Example #54
0
 public virtual bool ConflictsWith(ICriterion other)
 {
     return(false);
 }
Example #55
0
		/// <summary>
		/// Returns all instances found for the specified type
		/// using criteria and IStatelessSession.
		/// </summary>
		/// <param name="type">The target type.</param>
		/// <param name="criterias">The criteria expression</param>
		/// <param name="firstRow">The number of the first row to retrieve.</param>
		/// <param name="maxRows">The maximum number of results retrieved.</param>
		/// <returns>The <see cref="Array"/> of results.</returns>
		public virtual Array FindAllStateless(Type type, ICriterion[] criterias, int firstRow, int maxRows)
		{
			return FindAllStateless(type, criterias, null, firstRow, maxRows);
		}
Example #56
0
 /// <summary>
 /// Sends a paginated message
 /// </summary>
 /// <param name="pager">The paginated message</param>
 /// <param name="criterion">The criterion for the reply</param>
 /// <param name="reactions">Customized reaction list</param>
 /// <returns>The message sent.</returns>
 public Task <IUserMessage> PagedReplyAsync(PaginatedMessage pager, ICriterion <SocketReaction> criterion, ReactionList reactions)
 {
     return(Interactive.SendPaginatedMessageAsync(SocketContext(), pager, reactions, criterion));
 }
Example #57
0
		/// <summary>
		/// Returns all instances found for the specified type
		/// using criteria and IStatelessSession.
		/// </summary>
		/// <param name="type">The target type.</param>
		/// <param name="criterias">The criteria expression</param>
		/// <param name="sortItems">An <see cref="Array"/> of <see cref="Order"/> objects.</param>
		/// <param name="firstRow">The number of the first row to retrieve.</param>
		/// <param name="maxRows">The maximum number of results retrieved.</param>
		/// <returns>The <see cref="Array"/> of results.</returns>
		public virtual Array FindAllStateless(Type type, ICriterion[] criterias, Order[] sortItems, int firstRow, int maxRows)
		{
			using (IStatelessSession session = GetStatelessSession())
			{
				try
				{
					ICriteria criteria = session.CreateCriteria(type);

					if (criterias != null)
					{
						foreach (ICriterion cond in criterias)
						{
							criteria.Add(cond);
						}
					}

					if (sortItems != null)
					{
						foreach (Order order in sortItems)
						{
							criteria.AddOrder(order);
						}
					}

					if (firstRow != int.MinValue) criteria.SetFirstResult(firstRow);
					if (maxRows != int.MinValue) criteria.SetMaxResults(maxRows);
					IList result = criteria.List();

					Array array = Array.CreateInstance(type, result.Count);
					result.CopyTo(array, 0);

					return array;
				}
				catch (Exception ex)
				{
					throw new DataException("Could not perform FindAllStateless for " + type.Name, ex);
				}
			}
		}
Example #58
0
 /// <summary>
 ///     Waits for the next message. NOTE: Your run-mode must be async or this will lock up.
 /// </summary>
 /// <param name="criterion">The criterion for the message</param>
 /// <param name="timeout">Time to wait before exiting</param>
 /// <returns>The message received</returns>
 public Task <SocketMessage> NextMessageAsync(ICriterion <SocketMessage> criterion, TimeSpan?timeout = null)
 {
     return(Interactive.NextMessageAsync(SocketContext(), criterion, timeout));
 }
 public AddCriterionEvent(ICriterion criterion)
 {
     this.criterion = criterion;
 }
        string ToSqlOn(ICriterion criterion, Type type)
        {
            string column;

            var key = criterion.PropertyName;

            if (key.EndsWith("Id") && key.Length > 2)
            {
                var association = type.GetProperty(key.TrimEnd("Id"));

                if (association != null && !association.Defines <CalculatedAttribute>() &&
                    association.PropertyType.IsA <IEntity>())
                {
                    key = key.TrimEnd("Id");
                }
            }

            column = Query.Column(key);

            var value    = criterion.Value;
            var function = criterion.FilterFunction;

            if (value == null)
            {
                return("{0} IS {1} NULL".FormatWith(column, "NOT".OnlyWhen(function != FilterFunction.Is)));
            }

            var valueData = value;

            if (function == FilterFunction.Contains || function == FilterFunction.NotContains)
            {
                valueData = "%{0}%".FormatWith(value);
            }
            else if (function == FilterFunction.BeginsWith)
            {
                valueData = "{0}%".FormatWith(value);
            }
            else if (function == FilterFunction.EndsWith)
            {
                valueData = "%{0}".FormatWith(value);
            }
            else if (function == FilterFunction.In)
            {
                if ((value as string) == "()")
                {
                    return("1 = 0 /*" + column + " IN ([empty])*/");
                }
                else
                {
                    return(column + " " + function.GetDatabaseOperator() + " " + value);
                }
            }

            var parameterName = GetUniqueParameterName(column);

            Query.Parameters.Add(parameterName, valueData);

            var critera      = $"{column} {function.GetDatabaseOperator()} @{parameterName}";
            var includeNulls = function == FilterFunction.IsNot;

            return(includeNulls ? $"( {critera} OR {column} {FilterFunction.Null.GetDatabaseOperator()} )" : critera);
        }