Beispiel #1
0
        public override IQueryable <Department> Apply(IQueryable <Department> qry)
        {
            if (Ids?.Length > 0)
            {
                qry = qry.Where(x => Ids.Contains(x.Id));
            }

            if (Id != null)
            {
                qry = qry.Where(x => x.Id == Id);
            }

            if (!string.IsNullOrEmpty(Name))
            {
                qry = qry.Where(a => a.Name == Name);
            }

            if (!string.IsNullOrEmpty(Term))
            {
                qry = qry.Where(a => a.Code.Contains(Term) || a.Name.Contains(Term));
            }

            if (Deleted != null)
            {
                qry = qry.Where(x => x.Deleted == Deleted);
            }

            return(qry);
        }
Beispiel #2
0
        /// <summary>
        /// 创建查询对象
        /// </summary>
        /// <returns>返回查询对象</returns>
        public override IQuery CreateQuery()
        {
            IQuery query = base.CreateQuery() ?? QueryManager.Create <PermissionGroupEntity>(this);

            if (LevelOne)
            {
                query.And <PermissionGroupEntity>(c => c.Parent <= 0);
            }
            if (!Ids.IsNullOrEmpty())
            {
                query.And <PermissionGroupEntity>(c => Ids.Contains(c.Id));
            }
            if (!ExcludeIds.IsNullOrEmpty())
            {
                query.And <PermissionGroupEntity>(c => !ExcludeIds.Contains(c.Id));
            }
            if (!string.IsNullOrWhiteSpace(Name))
            {
                query.And <PermissionGroupEntity>(c => c.Name == Name);
            }
            if (Sort.HasValue)
            {
                query.And <PermissionGroupEntity>(c => c.Sort == Sort.Value);
            }
            if (Parent.HasValue)
            {
                query.And <PermissionGroupEntity>(c => c.Parent == Parent.Value);
            }
            if (!string.IsNullOrWhiteSpace(Remark))
            {
                query.And <PermissionGroupEntity>(c => c.Remark == Remark);
            }
            return(query);
        }
Beispiel #3
0
        public IQueryable <Planet> Filter(IQueryable <Planet> planetQuery)
        {
            if (!string.IsNullOrEmpty(ToSearch))
            {
                if (!PerfectMatch)
                {
                    ToSearch = new string("%" + ToSearch + "%");
                }
                planetQuery = planetQuery.Where(planet =>
                                                EF.Functions.Like(planet.Name, ToSearch));
            }

            if (Ids != null && Ids.Count != 0)
            {
                planetQuery = planetQuery.Where(planet => Ids.Contains(planet.Id));
            }

            if (SystemId != Guid.Empty)
            {
                planetQuery = planetQuery.Where(t => t.SolarSystemId.Equals(SystemId));
            }

            if (ShuttleId != Guid.Empty)
            {
                planetQuery = planetQuery.Where(t => t.ShuttleId.Equals(ShuttleId));
            }

            return(planetQuery);
        }
Beispiel #4
0
        public void Add(Field field)
        {
            if (Ids.Contains(field.Id))
            {
                return;
            }

            _passwordFields = _usernameFields = null;

            Ids.Add(field.Id);
            Fields.Add(field);
            AutofillIds.Add(field.AutofillId);
            IdToFieldMap.Add(field.Id, field);

            if (field.Hints != null)
            {
                foreach (var hint in field.Hints)
                {
                    Hints.Add(hint);
                    if (field.Focused)
                    {
                        FocusedHints.Add(hint);
                    }

                    if (!HintToFieldsMap.ContainsKey(hint))
                    {
                        HintToFieldsMap.Add(hint, new List <Field>());
                    }

                    HintToFieldsMap[hint].Add(field);
                }
            }
        }
Beispiel #5
0
        public IQueryable <Explorer> Filter(IQueryable <Explorer> explorerQuery)
        {
            if (!string.IsNullOrEmpty(ToSearch))
            {
                if (!PerfectMatch)
                {
                    ToSearch = new string("%" + ToSearch + "%");
                }
                explorerQuery = explorerQuery.Where(humanCaptain =>
                                                    EF.Functions.Like(humanCaptain.Name, ToSearch));
            }

            if (Ids != null && Ids.Count != 0)
            {
                explorerQuery = explorerQuery.Where(humanCaptain =>
                                                    Ids.Contains(humanCaptain.Id) || Ids.Contains(humanCaptain.TeamOfExplorersId));
            }

            if (TeamId != Guid.Empty)
            {
                explorerQuery = explorerQuery.Where(t => t.TeamOfExplorersId.Equals(TeamId));
            }

            return(explorerQuery);
        }
Beispiel #6
0
        private void AddInternal(TItem item)
        {
            if (item == null)
            {
                return;
            }

            if (ModelRegistry.IsManagedModel(item) && !ModelRegistry.IsManagedBy(Session, item))
            {
                var id = ModelRegistry.GetId(item);
                throw new UnmanagedModelException(item.GetType(), id);
            }

            var itemId = ModelRegistry.GetOrCreateId(item);

            Session.Cache.Update(itemId, item);

            if (Ids.Contains(itemId))
            {
                return;
            }

            Ids.Add(itemId);
            IsModified = true;
        }
Beispiel #7
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var jObject = JObject.Load(reader);

            var typeName = jObject["type"]?.Value <string>() ?? jObject["@type"]?.Value <string>();

            if (typeName == null)
            {
                // Get value of this objectType's "Type" JsonProperty(Required)
                var typeJsonPropertyRequiredValue = objectType.GetRuntimeProperty("Type")
                                                    .CustomAttributes.Where(a => a.AttributeType == typeof(JsonPropertyAttribute)).FirstOrDefault()?
                                                    .NamedArguments.Where(a => a.TypedValue.ArgumentType == typeof(Required)).FirstOrDefault()
                                                    .TypedValue.Value.ToString();

                // If this objectType does not require "Type" attribute, use the objectType's XML "TypeName" attribute
                if (typeJsonPropertyRequiredValue == "0")
                {
                    typeName = objectType
                               .GetRuntimeFields().Where(x => x.Name == "TypeName").FirstOrDefault()?
                               .GetValue("TypeName").ToString();
                }
                else
                {
                    throw new AdaptiveSerializationException("Required property 'type' not found on adaptive card element");
                }
            }

            if (TypedElementTypes.Value.TryGetValue(typeName, out var type))
            {
                if (jObject.Value <string>("id") == null)
                {
                    if (typeof(AdaptiveInput).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()))
                    {
                        throw new AdaptiveSerializationException($"Required property 'id' not found on '{typeName}'");
                    }
                }
                else
                {
                    string objectId = jObject.Value <string>("id");
                    if (Ids.Contains(objectId))
                    {
                        throw new AdaptiveSerializationException($"Duplicate 'id' found: '{objectId}'");
                    }
                    else
                    {
                        Ids.Add(objectId);
                    }
                }

                var result = (AdaptiveTypedElement)Activator.CreateInstance(type);
                serializer.Populate(jObject.CreateReader(), result);

                HandleAdditionalProperties(result);
                return(result);
            }

            Warnings.Add(new AdaptiveWarning(-1, $"Unknown element '{typeName}'"));
            return(null);
        }
Beispiel #8
0
        public override object ExecuteCommand(InCourseRequest inCourseRequest)
        {
            var request = (from d in context.PortfoliosUsuario where Ids.Contains(d.IdPortfolioUsuario) select d).ToList();

            this.context.RemoveRange(request);

            return(null);
        }
Beispiel #9
0
        /// <summary>
        /// 若不填Id則取全部, 填了取部分
        /// </summary>
        /// <param name="db"></param>
        /// <param name="Ids"></param>
        /// <returns></returns>
        private IQueryable <TodoItem> Get(TodoContext db, params Guid[] Ids)
        {
            var query = db.TodoItems.AsQueryable();

            if (Ids.Count() > 0)
            {
                query = query.Where(item => Ids.Contains(item.Id));
            }
            return(query);
        }
        public override Expression <Func <WorkflowDefinition, bool> > ToExpression()
        {
            Expression <Func <WorkflowDefinition, bool> > predicate = x => Ids.Contains(x.DefinitionId);

            if (VersionOptions != null)
            {
                predicate = predicate.WithVersion(VersionOptions);
            }

            return(predicate);
        }
Beispiel #11
0
        public bool Contains(TItem item)
        {
            if (item == null)
            {
                return(false);
            }

            Initialize();

            return(Ids.Contains(ModelRegistry.GetId(item)));
        }
Beispiel #12
0
 internal Func <Product, bool> GetFuncPredicate()
 {
     return((Product p) =>
            (Ids != null && Ids.Any() ? Ids.Contains(p.Id) : true) &&
            (MaxCount != null ? p.CountInStock < MaxCount : true) &&
            (MinCount != null ? p.CountInStock > MinCount : true) &&
            (UnitId != null ? p.UnitId == UnitId : true) &&
            (MinWeight != null ? p.Weight > MinWeight : true) &&
            (MaxWeight != null ? p.Weight < MaxWeight : true) &&
            (ManufactureCountryId != null ? p.ManufactureCountryId == ManufactureCountryId : true) &&
            (Name != null ? p.Name.Contains(Name, StringComparison.OrdinalIgnoreCase) : true));
 }
Beispiel #13
0
 protected override void AddFilters()
 {
     FilterIfHasValue(Ids, session => Ids.Contains(session.Id));
     FilterIfHasValue(VariantIds, session => VariantIds.Contains(session.TestSessionId));
     FilterIfHasValue(VariantId, session => session.TestVariantId == VariantId.Value);
     FilterIfHasValue(Id, session => session.Id == Id.Value);
     FilterIfHasValue(State, session => session.State == State);
     FilterIfHasValue(StudentId, session => session.StudentId == StudentId.Value);
     FilterIfHasValue(ExceptTestSessionState, session => session.TestSession.State != ExceptTestSessionState);
     FilterIfHasValue(ExcludedStates, session => !ExcludedStates.Contains(session.State));
     FilterIfHasValue(TestSessionId, session => session.TestSessionId == TestSessionId.Value);
     FilterIfHasValue(MoreOrGreaterThanShouldEndAt, session => session.ShouldEndAt <= MoreOrGreaterThanShouldEndAt);
 }
Beispiel #14
0
 /// <summary>
 /// 搜索后运行的函数,继承的类如果需要在搜索结束后进行其他操作,可重载这个函数
 /// </summary>
 public virtual void AfterDoSearcher()
 {
     if (SearcherMode == ListVMSearchModeEnum.Selector && Ids != null && Ids.Count > 0 && EntityList != null && EntityList.Count > 0)
     {
         foreach (var item in EntityList)
         {
             if (Ids.Contains(item.ID))
             {
                 item.Checked = true;
             }
         }
     }
 }
Beispiel #15
0
 public Chief(string firstName, string secondName, string departamentName, long id, byte age)
 {
     FirstName       = firstName;
     SecondName      = secondName;
     DepartamentName = departamentName;
     if (Ids.Contains(id))
     {
         id = defIndexId;
     }
     Id  = id;
     Age = age;
     defIndexId++;
 }
Beispiel #16
0
 public Intern(string firstName, string secondName, string departamentName, long id, byte age, uint salary)
 {
     FirstName       = firstName;
     SecondName      = secondName;
     DepartamentName = departamentName;
     if (Ids.Contains(id))
     {
         id = defIndexId;
     }
     Id  = id;
     Age = age;
     CalculateSalary(salary);
     defIndexId++;
 }
Beispiel #17
0
 public Staffer(string firstName, string secondName, string departamentName, long id, byte age, int workHours)
 {
     FirstName       = firstName;
     SecondName      = secondName;
     DepartamentName = departamentName;
     if (Ids.Contains(id))
     {
         id = defIndexId;
     }
     Id  = id;
     Age = age;
     CalculateSalary(workHours);
     defIndexId++;
 }
        public IQueryable <RoomJob> Filter(IQueryable <RoomJob> filterQuery)
        {
            if (!string.IsNullOrEmpty(SearchTerm))
            {
                return(Guid.TryParse(SearchTerm, out var roomId)
                    ? filterQuery.Where(t => t.Id == roomId)
                    : filterQuery.Where(t => CheckContains(t)));
            }
            if (Ids.Count > 0)
            {
                filterQuery = filterQuery.Where(t => Ids.Contains(t.Id));
            }

            return(filterQuery);
        }
Beispiel #19
0
        public IQueryable <RoomWallObject> Filter(IQueryable <RoomWallObject> filterQuery)
        {
            if (!string.IsNullOrEmpty(SearchTerm))
            {
                return(Guid.TryParse(SearchTerm, out var roomId)
                    ? filterQuery.Where(t => t.Id == roomId)
                    : filterQuery.Where(t => t.Type.ToString() == SearchTerm));
            }
            if (Ids.Count > 0)
            {
                filterQuery = filterQuery.Where(t => Ids.Contains(t.Id));
            }

            return(filterQuery);
        }
        public override Expression <Func <TSelector, bool> > ToExpresion()
        {
            var expresion = base.ToExpresion();

            if (Ids != null)
            {
                expresion = expresion.And(e => Ids.Contains(e.Id));
            }

            if (Text != null)
            {
                expresion = expresion.And(x => EF.Functions.Like(x.Text, $"%{Text}%"));
            }

            return(expresion);
        }
Beispiel #21
0
        /// <summary>
        /// 设定批量模式下的搜索语句,继承的类应重载这个函数来指定自己批量模式的搜索语句,如果不指定则默认使用Ids.Contains(x.Id)来代替搜索语句中的Where条件
        /// </summary>
        /// <returns>搜索语句</returns>
        public virtual IOrderedQueryable <TModel> GetBatchQuery()
        {
            var baseQuery = GetSearchQuery();

            if (ReplaceWhere == null)
            {
                WhereReplaceModifier mod = new WhereReplaceModifier(x => Ids.Contains(x.ID));
                var newExp   = mod.Modify(baseQuery.Expression);
                var newQuery = baseQuery.Provider.CreateQuery <TModel>(newExp) as IOrderedQueryable <TModel>;
                return(newQuery);
            }
            else
            {
                return(baseQuery);
            }
        }
Beispiel #22
0
        public IQueryable <SolarSystem> Filter(IQueryable <SolarSystem> solarSystemQuery)
        {
            if (!string.IsNullOrEmpty(ToSearch))
            {
                if (!PerfectMatch)
                {
                    ToSearch = new string("%" + ToSearch + "%");
                }
                solarSystemQuery = solarSystemQuery.Where(system =>
                                                          EF.Functions.Like(system.Name, ToSearch));
            }

            if (Ids != null && Ids.Count != 0)
            {
                solarSystemQuery = solarSystemQuery.Where(system => Ids.Contains(system.Id));
            }
            return(solarSystemQuery);
        }
Beispiel #23
0
        public IQueryable <Shuttle> Filter(IQueryable <Shuttle> shuttleQuery)
        {
            if (!string.IsNullOrEmpty(ToSearch))
            {
                if (!PerfectMatch)
                {
                    ToSearch = new string("%" + ToSearch + "%");
                }
                shuttleQuery = shuttleQuery.Where(shuttle =>
                                                  EF.Functions.Like(shuttle.Name, ToSearch));
            }

            if (Ids != null && Ids.Count != 0)
            {
                shuttleQuery = shuttleQuery.Where(shuttle => Ids.Contains(shuttle.Id));
            }
            return(shuttleQuery);
        }
Beispiel #24
0
 public Func <WorkItem, bool> GetPredicate()
 {
     return(x =>
     {
         bool result = true;
         if (Ids != null)
         {
             result = Ids.Contains(x.Id);
         }
         if (Statuses != null)
         {
             result = result && Statuses.Contains(x.Status);
         }
         if (ExecutionTypes != null)
         {
             result = result && ExecutionTypes.Contains(x.ExecutionType);
         }
         return result;
     });
 }
        public int AllocateId()
        {
            while (true)
            {
                if (_lastAssignedId < int.MaxValue)
                {
                    _lastAssignedId++;
                }
                else
                {
                    _lastAssignedId = 0;
                }

                if (!Ids.Contains(_lastAssignedId))
                {
                    Ids.Add(_lastAssignedId);
                    return(_lastAssignedId);
                }
            }
        }
Beispiel #26
0
        public IQueryable <TeamOfExplorers> Filter(IQueryable <TeamOfExplorers> teamOfExplorersQuery)
        {
            if (!string.IsNullOrEmpty(ToSearch))
            {
                if (!PerfectMatch)
                {
                    ToSearch = new string("%" + ToSearch + "%");
                }
                teamOfExplorersQuery = teamOfExplorersQuery.Where(t =>
                                                                  EF.Functions.Like(t.Name, ToSearch));
            }
            if (Ids != null && Ids.Count != 0)
            {
                teamOfExplorersQuery = teamOfExplorersQuery.Where(t => Ids.Contains(t.Id));
            }
            if (ShuttleGuid != Guid.Empty)
            {
                teamOfExplorersQuery = teamOfExplorersQuery.Where(t => t.ShuttleId.Equals(ShuttleGuid));
            }

            return(teamOfExplorersQuery);
        }
Beispiel #27
0
        public virtual IQueryable <T> ApplyFilter(IQueryable <T> query)
        {
            query = query.Where(Query);
            if (Ids.Count > 0)
            {
                query = query.Where(d => Ids.Contains(d.Id));
            }
            if (_isOwnedByOrganization && OrganizationIds.Count > 0)
            {
                query = query.Where(d => OrganizationIds.Contains(((IOwnedByOrganization)d).OrganizationId));
            }
            if (_isOwnedByProject && ProjectIds.Count > 0)
            {
                query = query.Where(d => ProjectIds.Contains(((IOwnedByProject)d).ProjectId));
            }
            if (_isOwnedByStack && StackIds.Count > 0)
            {
                query = query.Where(d => StackIds.Contains(((IOwnedByStack)d).StackId));
            }

            return(query);
        }
        private static void ArchivedCustomerOrdersWithoutCustomerOrderParts()
        {
            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();


            Ids customerOrderIds = new Ids();

            foreach (var demand in dbTransactionData.CustomerOrderPartGetAll())
            {
                CustomerOrderPart customerOrderPart = (CustomerOrderPart)demand;
                customerOrderIds.Add(customerOrderPart.GetCustomerOrderId());
            }

            foreach (var customerOrder in dbTransactionData.CustomerOrderGetAll())
            {
                bool customerOrderHasNoCustomerOrderPart =
                    customerOrderIds.Contains(customerOrder.GetId()) == false;
                if (customerOrderHasNoCustomerOrderPart)
                {
                    ArchiveCustomerOrder(customerOrder.GetId());
                }
            }
        }
Beispiel #29
0
        public IQueryable <Robot> Filter(IQueryable <Robot> robotQuery)
        {
            if (!string.IsNullOrEmpty(ToSearch))
            {
                if (!PerfectMatch)
                {
                    ToSearch = new string("%" + ToSearch + "%");
                }
                robotQuery = robotQuery.Where(robot =>
                                              EF.Functions.Like(robot.Name, ToSearch));
            }

            if (Ids != null && Ids.Count != 0)
            {
                robotQuery = robotQuery.Where(robot => Ids.Contains(robot.Id));
            }

            if (TeamId != Guid.Empty)
            {
                robotQuery = robotQuery.Where(t => t.TeamOfExplorersId.Equals(TeamId));
            }

            return(robotQuery);
        }
        private static void ArchivedPurchaseOrdersWithoutPurchaseOrderParts()
        {
            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();


            Ids purchaseOrderIds = new Ids();

            foreach (var demand in dbTransactionData.PurchaseOrderPartGetAll())
            {
                PurchaseOrderPart purchaseOrderPart = (PurchaseOrderPart)demand;
                purchaseOrderIds.Add(purchaseOrderPart.GetPurchaseOrderId());
            }

            foreach (var purchaseOrder in dbTransactionData.PurchaseOrderGetAll())
            {
                bool purchaseOrderHasNoPurchaseOrderParts =
                    purchaseOrderIds.Contains(purchaseOrder.GetId()) == false;
                if (purchaseOrderHasNoPurchaseOrderParts)
                {
                    ArchivePurchaseOrder(purchaseOrder);
                }
            }
        }