public static async Task <T> FindByIdAsyncGeneric <T>(this IEntityProvider provider, long id, Func <EntitySearch, Task <List <T> > > searcher)
        {
            var search = new EntitySearch();

            search.Ids.Add(id);
            return((await searcher(search)).OnlySingle());
        }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);

        if (!String.IsNullOrEmpty(txtCheckDetail_Search.Text))
        {
            es.AddSearchCodition("CheckDetail", txtCheckDetail_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtCheckMethod_Search.Text))
        {
            es.AddSearchCodition("CheckMethod", txtCheckMethod_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtSpecifiedSizeHeight_Search.Text))
        {
            es.AddSearchCodition("SpecifiedSizeHeight", txtSpecifiedSizeHeight_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtKnockPosition_Search.Text))
        {
            es.AddSearchCodition("KnockPosition", txtKnockPosition_Search.Text, "=");
        }


        Filter = es.Where;
        BindData();
    }
Пример #3
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);

        if (!String.IsNullOrEmpty(txtSection_Search.Text))
        {
            es.AddSearchCodition("Section", txtSection_Search.Text, "like");
        }

        if (!String.IsNullOrEmpty(txtSequence_Search.Text))
        {
            es.AddSearchCodition("Sequence", txtSequence_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtCheckPosition_Search.Text))
        {
            es.AddSearchCodition("CheckPosition", txtCheckPosition_Search.Text, "like");
        }

        if (!String.IsNullOrEmpty(txtCheckMethod_Search.Text))
        {
            es.AddSearchCodition("CheckMethod", txtCheckMethod_Search.Text, "like");
        }

        if (!String.IsNullOrEmpty(txtBarCode_Search.Text))
        {
            es.AddSearchCodition("BarCode", txtBarCode_Search.Text, "like");
        }


        Filter = es.Where;
        BindData();
    }
Пример #4
0
        private void SetBinding()
        {
            if (entity == null)
            {
                entity = new EntitySearch();
            }

            // マスタコントロールPropertyChanged
            entity.PropertyChanged += this.utlInvoice_F.MstID_Changed;
            entity.PropertyChanged += this.utlInvoice_T.MstID_Changed;

            #region Bind

            // バインド
            Binding BindingInvoiceId_F = new Binding("invoice_id_from");
            BindingInvoiceId_F.Mode   = BindingMode.TwoWay;
            BindingInvoiceId_F.Source = entity;
            this.utlInvoice_F.txtID.SetBinding(TextBox.TextProperty, BindingInvoiceId_F);

            // バインド
            Binding BindingInvoiceId_T = new Binding("invoice_id_to");
            BindingInvoiceId_T.Mode   = BindingMode.TwoWay;
            BindingInvoiceId_T.Source = entity;
            this.utlInvoice_T.txtID.SetBinding(TextBox.TextProperty, BindingInvoiceId_T);

            #endregion

            this.utlInvoice_F.txtID.OnFormatString();
            this.utlInvoice_T.txtID.OnFormatString();
        }
Пример #5
0
        public IQueryable <Entity> ApplyEntitySearch(IQueryable <Entity> query, EntitySearch search, bool finalize)
        {
            query = ApplyGeneric(query, search, false);

            if (!string.IsNullOrEmpty(search.NameLike))
            {
                query = query.Where(x => EF.Functions.Like(x.name, search.NameLike));
            }
            if (!string.IsNullOrEmpty(search.TypeLike))
            {
                query = query.Where(x => EF.Functions.Like(x.type, search.TypeLike));
            }

            if (search.Names.Count > 0)
            {
                query = query.Where(x => search.Names.Contains(x.name));
            }
            if (search.Types.Count > 0)
            {
                query = query.Where(x => search.Types.Contains(x.type));
            }

            if (finalize)
            {
                query = ApplyFinal(query, search);
            }

            return(query);
        }
        public override IList <BaseEntityResultDTO> GetEntities(EntitySearch search)
        {
            var type     = search == null ? Type : search.Type;
            var cacheKey = $"{type}:{search.CalculateHash()}";

            return(_cacheService.GetOrAdd($"entities:{cacheKey}", () => base.GetEntities(search)));
        }
Пример #7
0
        public PagedRecordsViewModel GetRecords(Entity entity, int page, int take, IList <IEntityFilter> filters, string searchQuery, string order, string orderDirection)
        {
            var skip = (page - 1) * take;

            var search = new EntitySearch {
                Query = searchQuery, Properties = entity.SearchProperties
            };

            order          = order.IsNullOrEmpty() ? entity.Key.ColumnName : order;
            orderDirection = orderDirection.IsNullOrEmpty() ? "ASC" : orderDirection.ToUpper();
            var orderBy = order + " " + orderDirection;
            var columns = GetColumns(entity);

            var where = ConvertFiltersToSQL(filters, search);

            var table = new DynamicModel(AdminInitialise.ConnectionString, tableName: entity.TableName, primaryKeyField: entity.Key.ColumnName);

            var result = table.Paged(columns: columns, where : where, orderBy: orderBy, currentPage: page, pageSize: take);

            var data = new List <DataRowViewModel>();

            foreach (var item in result.Items)
            {
                data.Add(ExpandoToDataRow(item, entity));
            }

            return(new PagedRecordsViewModel
            {
                TotalItems = result.TotalRecords,
                TotalPages = result.TotalPages,
                Records = data
            });
        }
        private void SetBinding()
        {
            if (entity == null)
            {
                entity = new EntitySearch();
            }

            // マスタコントロールPropertyChanged
            entity.PropertyChanged += this.utlPurchase.MstID_Changed;
            entity.PropertyChanged += this.utlSummingUp.MstID_Changed;

            #region Bind

            // バインド
            Binding BindingInvoiceId = new Binding("purchase_id");
            BindingInvoiceId.Mode   = BindingMode.TwoWay;
            BindingInvoiceId.Source = entity;
            this.utlPurchase.txtID.SetBinding(TextBox.TextProperty, BindingInvoiceId);

            Binding BindingSummingUpGroupId = new Binding("summing_up_group_id");
            BindingSummingUpGroupId.Mode   = BindingMode.TwoWay;
            BindingSummingUpGroupId.Source = entity;
            this.utlSummingUp.txtID.SetBinding(TextBox.TextProperty, BindingSummingUpGroupId);

            #endregion

            this.utlPurchase.txtID.OnFormatString();
            this.utlSummingUp.txtID.SetZeroToNullString();
        }
Пример #9
0
        public IList <DataRowViewModel> GetRecords(Entity entity, IList <IEntityFilter> filters = null, string searchQuery = null, string order = null, string orderDirection = null, bool determineDisplayValue = false)
        {
            var search = new EntitySearch {
                Query = searchQuery, Properties = entity.SearchProperties
            };

            order          = order.IsNullOrEmpty() ? entity.Key.ColumnName : order;
            orderDirection = orderDirection.IsNullOrEmpty() ? "ASC" : orderDirection.ToUpper();
            var orderBy = order + " " + orderDirection;
            var columns = string.Join(",", entity.Properties.Where(x => !x.IsForeignKey || (!x.IsCollection && x.IsForeignKey)).Select(x => x.ColumnName).Distinct());

            var where = ConvertFiltersToSQL(filters, search);

            var table = new DynamicModel(AdminInitialise.ConnectionString, tableName: entity.TableName, primaryKeyField: entity.Key.ColumnName);

            var result = table.All(columns: columns, where : where, orderBy: orderBy);

            var data = new List <DataRowViewModel>();

            foreach (var item in result)
            {
                data.Add(ExpandoToDataRow(item, entity));
            }

            if (determineDisplayValue)
            {
                foreach (var row in data)
                {
                    row.DisplayName = GetDisplayName(entity, row);
                }
            }

            return(data);
        }
Пример #10
0
        public virtual IList <T> GetEntities(EntitySearch entitySearch, IList <string> types, ISet <Uri> namedGraphs)
        {
            var query = entitySearch == null?GenerateGetAllQuery(types, namedGraphs) : GenerateGetAllQuery(types, namedGraphs, entitySearch);

            var results = _tripleStoreRepository.QueryTripleStoreResultSet(query);

            return(TransformQueryResults(results));
        }
Пример #11
0
 public Task <List <Entity> > GetEntitiesAsync(EntitySearch search)
 {
     logger.LogTrace("GetEntitiesAsync called");
     return(LockAsync(async() =>
     {
         var entities = await query.GetQueryableAsync <Entity>();
         return await query.GetListAsync(searcher.ApplyEntitySearch(entities, search));
     }));
 }
        private void SetBinding()
        {
            if (entity == null)
            {
                entity = new EntitySearch();
            }

            // マスタコントロールPropertyChanged
            entity.PropertyChanged += this.utlPerson_F.MstID_Changed;
            entity.PropertyChanged += this.utlPerson_T.MstID_Changed;
            entity.PropertyChanged += this.utlCompanyGroup.MstID_Changed;
            entity.PropertyChanged += this.utlCustomer.MstID_Changed;
            entity.PropertyChanged += this.utlPurchase.MstID_Changed;
            entity.PropertyChanged += this.utlCommodity.MstID_Changed;

            #region Bind

            // バインド
            Binding BindingPersonF = new Binding("person_id_from");
            BindingPersonF.Mode   = BindingMode.TwoWay;
            BindingPersonF.Source = entity;
            this.utlPerson_F.txtID.SetBinding(TextBox.TextProperty, BindingPersonF);

            Binding BindingPersonT = new Binding("person_id_to");
            BindingPersonT.Mode   = BindingMode.TwoWay;
            BindingPersonT.Source = entity;
            this.utlPerson_T.txtID.SetBinding(TextBox.TextProperty, BindingPersonT);

            Binding BindingGroup = new Binding("group_id");
            BindingGroup.Mode   = BindingMode.TwoWay;
            BindingGroup.Source = entity;
            this.utlCompanyGroup.txtID.SetBinding(TextBox.TextProperty, BindingGroup);

            Binding BindingCustomer = new Binding("customer_id");
            BindingCustomer.Mode   = BindingMode.TwoWay;
            BindingCustomer.Source = entity;
            this.utlCustomer.txtID.SetBinding(TextBox.TextProperty, BindingCustomer);

            Binding BindingPurchase = new Binding("purchase_id");
            BindingPurchase.Mode   = BindingMode.TwoWay;
            BindingPurchase.Source = entity;
            this.utlPurchase.txtID.SetBinding(TextBox.TextProperty, BindingPurchase);

            Binding BindingCommodity = new Binding("commodity_id");
            BindingCommodity.Mode   = BindingMode.TwoWay;
            BindingCommodity.Source = entity;
            this.utlCommodity.txtID.SetBinding(TextBox.TextProperty, BindingCommodity);

            #endregion

            this.utlPerson_F.txtID.OnFormatString();
            this.utlPerson_T.txtID.SetZeroToNullString();
            this.utlCompanyGroup.txtID.SetZeroToNullString();
            this.utlCustomer.txtID.SetZeroToNullString();
            this.utlPurchase.txtID.SetZeroToNullString();
            this.utlCommodity.txtID.SetZeroToNullString();
        }
        private bool DataIsAccessable(DR_Requester requester, EntitySearch entitySearch)
        {
            if (requester.SkipSecurity)
            {
                return(true);
            }

            return(bizTableDrivedEntity.DataIsAccessable(requester, entitySearch.TableDrivedEntity1));
        }
Пример #14
0
        public PagedRecords GetChangesRecords(
            Entity entityChangesFor,
            int page,
            int take,
            IList <IEntityFilter> filters,
            string searchQuery,
            string order,
            string orderDirection)
        {
            var changeEntity = AdminInitialise.ChangeEntity;

            var search = new EntitySearch
            {
                Query      = searchQuery,
                Properties = changeEntity.SearchProperties
            };

            order          = order.IsNullOrEmpty() ? changeEntity.Key.ColumnName : order;
            orderDirection = orderDirection.IsNullOrEmpty() ?
                             "ASC" :
                             orderDirection.ToUpper();
            var           orderBy = order + " " + orderDirection;
            var           columns = string.Join(",", changeEntity.GetColumns());
            List <object> args;

            var where = ConvertFiltersToSql(filters, search, out args);
            where    += where.IsNullOrEmpty() ? " WHERE " : " AND ";
            where    += "EntityName = @" + args.Count;
            args.Add(entityChangesFor.Name);
            var table = new DynamicModel(
                AdminInitialise.ConnectionStringName,
                changeEntity.TableName,
                changeEntity.Key.Name);

            var result = table.Paged(
                columns: columns,
                where : where,
                orderBy: orderBy,
                currentPage: page,
                pageSize: take,
                args: args.ToArray());

            var data = new List <DataRow>();

            foreach (var item in result.Items)
            {
                data.Add(new DataRow(item, changeEntity));
            }

            return(new PagedRecords
            {
                TotalItems = result.TotalRecords,
                TotalPages = result.TotalPages,
                Records = data
            });
        }
Пример #15
0
        public async Task <List <V> > GetRevisions(long id, Requester requester)
        {
            var search = new EntitySearch();

            search.Ids = await services.history.GetRevisionIdsAsync(id);

            var packages = await provider.GetEntityPackagesAsync(search);

            return(packages.Select(x => converter.ToView(services.history.ConvertHistoryToUpdate(x))).ToList());
        }
Пример #16
0
        public IList <DataRow> GetRecords(
            Entity entity,
            IList <IEntityFilter> filters = null,
            string searchQuery            = null,
            string order               = null,
            string orderDirection      = null,
            bool determineDisplayValue = false)
        {
            var search = new EntitySearch
            {
                Query      = searchQuery,
                Properties = entity.SearchProperties
            };

            order          = order.IsNullOrEmpty() ? entity.Key.ColumnName : order;
            orderDirection = orderDirection.IsNullOrEmpty() ?
                             "ASC" :
                             orderDirection.ToUpper();
            var orderBy = order + " " + orderDirection;
            var columns = string.Join(",",
                                      entity.Properties
                                      .Where(x =>
                                             !x.IsForeignKey ||
                                             (!x.TypeInfo.IsCollection && x.IsForeignKey))
                                      .Select(x => x.ColumnName)
                                      .Distinct());
            List <object> args;

            var where = ConvertFiltersToSql(filters, search, out args);

            var table = new DynamicModel(
                AdminInitialise.ConnectionStringName,
                entity.TableName,
                entity.Key.ColumnName);

            var result = table.All(
                columns: columns,
                where : where,
                orderBy: orderBy,
                args: args.ToArray());

            var data = result
                       .Select(item => new DataRow(item, entity))
                       .ToList();

            if (determineDisplayValue)
            {
                foreach (var row in data)
                {
                    row.DisplayName = entity.ToString(row);
                }
            }

            return(data);
        }
Пример #17
0
        public virtual IList <TEntityResult> GetEntities(EntitySearch search)
        {
            var type     = string.IsNullOrWhiteSpace(search?.Type) ? Type : search.Type;
            var types    = _metadataService.GetLeafEntityTypes(type);
            var entities = _repository.GetEntities(search, types);

            return(entities
                   .Where(c => c.Id.IsValidBaseUri())
                   .Select(c => _mapper.Map <TEntityResult>(c))
                   .OrderBy(c => c.Name).ToList());
        }
Пример #18
0
        public IList <PidUriTemplateFlattened> GetFlatPidUriTemplates(EntitySearch entitySearch)
        {
            var cacheKey            = entitySearch == null ? Type : entitySearch.CalculateHash();
            var flatPidUriTemplates = _cacheService.GetOrAdd($"list:flattened:{cacheKey}", () =>
            {
                var templates = GetEntities(entitySearch);
                return(templates.Select(template => GetFlatPidUriTemplateByPidUriTemplate(template)).ToList());
            });

            return(flatPidUriTemplates);
        }
Пример #19
0
        public async Task <IActionResult> GetEntities([FromRoute] string schema, [FromQuery(Name = "")] EntitySearch query)
        {
            var result = await StandardValidationStuff(schema);

            if (result != null)
            {
                return(result);
            }

            var matchingEntities = Db.GetEntityDefinitions(schema, query);

            return(Ok(matchingEntities));
        }
Пример #20
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);


        if (!String.IsNullOrEmpty(txtName_Search.Text))
        {
            es.AddSearchCodition("Name", txtName_Search.Text, "like");
        }

        if (ddlArea_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Area", ddlArea_Search.SelectedItem.Text, "like");
        }

        if (ddlFactory_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Factory", ddlFactory_Search.SelectedItem.Text, "like");
        }

        if (ddlSection_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Section", ddlSection_Search.SelectedItem.Text, "like");
        }

        if (!String.IsNullOrEmpty(txtJobDate_begin.Text))
        {
            String endDate = DateTime.Today.ToString();
            if (!String.IsNullOrEmpty(txtJobDate_end.Text))
            {
                endDate = txtJobDate_end.Text;
            }
            String dateFilter = String.Format(@"jobDate between '{0}' and '{1}'", txtJobDate_begin.Text, endDate);
            String filter     = es.Where;
            if (filter != "")
            {
                filter = filter + " and " + dateFilter;
            }
            else
            {
                filter = dateFilter;
            }
            Filter = filter;
        }
        else
        {
            Filter = es.Where;
        }

        BindData();
    }
        public override IList <ExtendedUriTemplateResultDTO> GetEntities(EntitySearch search)
        {
            var cacheKey = search == null ? Type : search.CalculateHash();
            var extendedUriTemplateList =
                _cacheService.GetOrAdd($"entities:{cacheKey}", () =>
            {
                var extendedUriTemplate = base.GetEntities(search);
                return(extendedUriTemplate
                       .OrderBy(x => x.Properties.GetValueOrNull(COLID.Graph.Metadata.Constants.ExtendedUriTemplate.HasOrder, true))
                       .ToList());
            });

            return(extendedUriTemplateList);
        }
Пример #22
0
        public async Task <List <V> > GetRevisions(long id)
        {
            var search = new EntitySearch();

            search.Ids = await entityServices.history.GetRevisionIdsAsync(id);

            if (search.Ids.Count == 0)
            {
                return(new List <V>());
            }
            var packages = await entityServices.provider.GetEntityPackagesAsync(search);

            return(packages.OrderBy(x => x.Entity.id).Select(x => ToView(entityServices.history.ConvertHistoryToUpdate(x))).ToList());
        }
        public object GetEntityFromSearch(EntitySearch entitySearch)
        {
            var type   = GetEntityType((EntityRelated)entitySearch.EntityIndex.FirstOrDefault(), typeof(Barrack), "trifenix.agro.db.model");
            var entity = CreateEntityInstance(type);

            type.GetProperty("Id")?.SetValue(entity, entitySearch.Id);
            var             props = entity.GetType().GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(SearchAttribute), true)).ToList();
            SearchAttribute attr;
            dynamic         values;

            props.ForEach(prop => {
                attr   = prop.GetCustomAttribute <SearchAttribute>(true);
                values = FormatValues(prop, GetValues(entitySearch, (int)attr.Related, attr.Index));
                prop.SetValue(entity, values);
            });
            return(entity);
        }
Пример #24
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);

        if (!String.IsNullOrEmpty(txtJobDate_Search.Text))
        {
            es.AddSearchCodition("JobDate", txtJobDate_Search.Text, "like");
        }


        if (!String.IsNullOrEmpty(txtTrainCode_Search.Text))
        {
            es.AddSearchCodition("TrainCode", txtTrainCode_Search.Text, "like");
        }

        if (!String.IsNullOrEmpty(txtName_Search.Text))
        {
            es.AddSearchCodition("Name", txtName_Search.Text, "like");
        }
        if (ddlCheckType_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("CheckType", ddlCheckType_Search.SelectedValue, "like");
        }



        if (ddlArea_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Area", ddlArea_Search.SelectedValue, "like");
        }

        if (ddlFactory_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Factory", ddlFactory_Search.SelectedValue, "like");
        }

        if (ddlSection_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Section", ddlSection_Search.SelectedValue, "like");
        }


        Filter = es.Where;
        BindData();
    }
Пример #25
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);

        if (!String.IsNullOrEmpty(txtUserName_Search.Text))
        {
            es.AddSearchCodition("UserName", txtUserName_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtUserNo_Search.Text))
        {
            es.AddSearchCodition("UserNo", txtUserNo_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtName_Search.Text))
        {
            es.AddSearchCodition("Name", txtName_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtDepartment_Search.Text))
        {
            es.AddSearchCodition("Department", txtDepartment_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtPassword_Search.Text))
        {
            es.AddSearchCodition("Password", txtPassword_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtIsActive_Search.Text))
        {
            es.AddSearchCodition("IsActive", txtIsActive_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtExpirtationDate_Search.Text))
        {
            es.AddSearchCodition("ExpirtationDate", txtExpirtationDate_Search.Text, "=");
        }


        Filter = es.Where;
        BindData();
    }
Пример #26
0
        protected IActionResult ValidateEntity(string schema, string name, bool isAlias, DataModel model)
        {
            var query = new EntitySearch();

            if (isAlias)
            {
                query.AssociatedEntity = name;
            }
            else
            {
                query.Name = name;
            }
            var entities = Db.GetEntityDefinitions(schema, query);

            if (!entities.Any())
            {
                return(NotFound());
            }
            throw new NotImplementedException();
        }
Пример #27
0
        public async Task <IActionResult> GetAllEntity(EntitySearch entityType)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }
            var service = new EntityRepositoryService(connString);
            var result  = await service.GetAllEntity();

            var filteredRes = result.Where(e => entityType.EntityTypeId.Any(mg => mg == e.EntityTypeId));

            var ent         = filteredRes.Select(a => a.EntityTypeId).Distinct();
            var finalresult = new List <EntityTypeDTO>();

            foreach (var item in ent)
            {
                var list       = result.Where(a => a.EntityTypeId == item).ToList();
                var entTypeDTO = new EntityTypeDTO();
                entTypeDTO.EntityTypeId   = list[0].EntityTypeId;
                entTypeDTO.EntityTypeName = list[0].EntityTypeName;
                entTypeDTO.Entities       = new List <EntityDTO>();
                foreach (var elm in list)
                {
                    var entDTO = new EntityDTO();
                    entDTO.EntityId          = elm.EntityId;
                    entDTO.EntityName        = elm.EntityName;
                    entDTO.EntityDescription = elm.EntityDescription;
                    entTypeDTO.Entities.Add(entDTO);
                }
                finalresult.Add(entTypeDTO);
            }
            var response = new GenericResponse <List <EntityTypeDTO> >()
            {
                IsSuccess    = true,
                Message      = "Data fetched successfully.",
                ResponseCode = 200,
                Result       = finalresult
            };

            return(Ok(response));
        }
Пример #28
0
        public void RandomSort()
        {
            List <Entity> entities = new List <Entity>();

            for (var i = 0; i < 100; i++)
            {
                entities.Add(NewEntity());
            }

            provider.WriteAsync(entities.ToArray()).Wait();


            var search = new EntitySearch();

            search.Sort = "random";

            var result  = provider.GetEntitiesAsync(search).Result;
            var result2 = provider.GetEntitiesAsync(search).Result;

            Assert.False(result.Select(x => x.id).SequenceEqual(result2.Select(x => x.id)));
        }
Пример #29
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);

        if (!String.IsNullOrEmpty(txtArea_Search.Text))
        {
            es.AddSearchCodition("Area", txtArea_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtFactory_Search.Text))
        {
            es.AddSearchCodition("Factory", txtFactory_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtSection_Search.Text))
        {
            es.AddSearchCodition("Section", txtSection_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtCode_Search.Text))
        {
            es.AddSearchCodition("Code", txtCode_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtTrainCode_Search.Text))
        {
            es.AddSearchCodition("TrainCode", txtTrainCode_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtAlias_Search.Text))
        {
            es.AddSearchCodition("Alias", txtAlias_Search.Text, "=");
        }


        Filter = es.Where;
        BindData();
    }
Пример #30
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);

        if (!String.IsNullOrEmpty(txtcode_Search.Text))
        {
            es.AddSearchCodition("code", txtcode_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtdescription_Search.Text))
        {
            es.AddSearchCodition("description", txtdescription_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtno1_Search.Text))
        {
            es.AddSearchCodition("no1", txtno1_Search.Text, "=");
        }


        Filter = es.Where;
        BindData();
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);
                if (!String.IsNullOrEmpty(txtCheckDetail_Search.Text))
        {
          es.AddSearchCodition("CheckDetail",txtCheckDetail_Search.Text,"=");
        }

        if (!String.IsNullOrEmpty(txtCheckMethod_Search.Text))
        {
          es.AddSearchCodition("CheckMethod",txtCheckMethod_Search.Text,"=");
        }

        if (!String.IsNullOrEmpty(txtSpecifiedSizeHeight_Search.Text))
        {
          es.AddSearchCodition("SpecifiedSizeHeight",txtSpecifiedSizeHeight_Search.Text,"=");
        }

        if (!String.IsNullOrEmpty(txtKnockPosition_Search.Text))
        {
          es.AddSearchCodition("KnockPosition",txtKnockPosition_Search.Text,"=");
        }

        Filter = es.Where;
        BindData();
    }
Пример #32
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);
        if (!String.IsNullOrEmpty(txtJobDate_Search.Text))
        {
            es.AddSearchCodition("JobDate", txtJobDate_Search.Text, "like");
        }

        if (!String.IsNullOrEmpty(txtTrainCode_Search.Text))
        {
            es.AddSearchCodition("TrainCode", txtTrainCode_Search.Text, "like");
        }

        if (!String.IsNullOrEmpty(txtName_Search.Text))
        {
            es.AddSearchCodition("Name", txtName_Search.Text, "like");
        }
        if (ddlCheckType_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("CheckType", ddlCheckType_Search.SelectedValue, "like");
        }

        if (ddlArea_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Area", ddlArea_Search.SelectedValue, "like");
        }

        if (ddlFactory_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Factory", ddlFactory_Search.SelectedValue, "like");
        }

        if (ddlSection_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Section", ddlSection_Search.SelectedValue, "like");
        }

        Filter = es.Where;
        BindData();
    }
Пример #33
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);
        if (!String.IsNullOrEmpty(txtUserName_Search.Text))
        {
            es.AddSearchCodition("UserName", txtUserName_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtUserNo_Search.Text))
        {
            es.AddSearchCodition("UserNo", txtUserNo_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtName_Search.Text))
        {
            es.AddSearchCodition("Name", txtName_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtDepartment_Search.Text))
        {
            es.AddSearchCodition("Department", txtDepartment_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtPassword_Search.Text))
        {
            es.AddSearchCodition("Password", txtPassword_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtIsActive_Search.Text))
        {
            es.AddSearchCodition("IsActive", txtIsActive_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtExpirtationDate_Search.Text))
        {
            es.AddSearchCodition("ExpirtationDate", txtExpirtationDate_Search.Text, "=");
        }

        Filter = es.Where;
        BindData();
    }
Пример #34
0
        private string ConvertFiltersToSql(
            IList<BaseFilter> filters,
            EntitySearch search,
            out List<object> args,
            string alias = "")
        {
            args = new List<object>();
            filters = filters ?? new List<BaseFilter>();

            var activeFilters = filters
                .Where(x => !x.Value.IsNullOrEmpty())
                .ToList();
            if (!activeFilters.Any() && !search.IsActive)
            {
                return null;
            }

            if (!alias.IsNullOrEmpty())
            {
                alias += ".";
            }

            var sbConditions = new StringBuilder();
            foreach (var filter in activeFilters)
            {
                var condition = filter.GetSqlCondition(alias, ref args);

                if (!condition.IsNullOrEmpty())
                {
                    sbConditions.AppendFormat(" {0} AND", condition);
                }
            }

            if (search.IsActive)
            {
                var searchCondition = String.Empty;
                foreach (var property in search.Properties)
                {
                    var query = search.Query.TrimStart('>', '<');
                    decimal temp;
                    if (property.TypeInfo.IsString)
                    {
                        searchCondition += " {0}{1} LIKE @{2} OR"
                            .Fill(alias, property.Column, args.Count);
                        args.Add("%" + search.Query + "%");
                    }
                    else if (decimal.TryParse(query.Replace(",", "."), NumberStyles.Any, CultureInfo.CurrentCulture, out temp))
                    {
                        var sign = "=";
                        if (search.Query.StartsWith(">"))
                        {
                            sign = ">=";
                        }
                        else if (search.Query.StartsWith("<"))
                        {
                            sign = "<=";
                        }

                        searchCondition += " {0}{1} {2} @{3} OR"
                            .Fill(alias, property.Column, sign, args.Count);
                        args.Add(temp);
                    }
                }

                if (!searchCondition.IsNullOrEmpty())
                {
                    searchCondition = searchCondition
                        .TrimStart(' ')
                        .TrimEnd("OR".ToCharArray());
                    sbConditions.AppendFormat(" ({0})", searchCondition);
                }
            }

            var conditions = sbConditions.ToString();
            if (conditions.IsNullOrEmpty())
            {
                return null;
            }

            return " WHERE" + conditions.TrimEnd("AND".ToCharArray());
        }
Пример #35
0
        public PagedRecords GetRecords(
            Entity entity,
            IList<BaseFilter> filters = null,
            string searchQuery = null,
            string order = null,
            string orderDirection = null,
            bool determineDisplayValue = false,
            int? page = null,
            int? take = null,
            bool loadForeignKeys = false)
        {
            var search = new EntitySearch
            {
                Query = searchQuery,
                Properties = entity.SearchProperties
            };
            order = order.IsNullOrEmpty() ? entity.Keys.FirstOrDefault().Column : order;
            orderDirection = orderDirection.IsNullOrEmpty() ?
                "ASC" :
                orderDirection.ToUpper();
            var orderBy = order + " " + orderDirection;
            var columns = string.Join(",",
                entity.DisplayProperties
                    .Union(entity.Keys)
                    .Where(x =>
                        !x.IsForeignKey ||
                        (!x.TypeInfo.IsCollection && x.IsForeignKey))
                    .Select(x => $"{entity.Table}.{x.Column} as {x.Column}")
                    .Distinct());
            List<object> args;
            var where = ConvertFiltersToSql(filters, search, out args);

            var table = new DynamicModel(
                _admin.ConnectionStringName,
                entity.Table,
                entity.JoinedKeys);

            if (page.HasValue && take.HasValue)
            {
                var result = table.Paged(
                    columns: columns,
                    where: where,
                    orderBy: orderBy,
                    currentPage: page.Value,
                    pageSize: take.Value,
                    args: args.ToArray());

                var records = new List<EntityRecord>();
                foreach (var item in result.Items)
                {
                    records.Add(entity.CreateRecord((Dictionary<string, object>)item));
                }

                return new PagedRecords
                {
                    TotalItems = result.TotalRecords,
                    TotalPages = result.TotalPages,
                    Records = records
                };
            }
            else
            {
                var joins = "";
                if (loadForeignKeys)
                {
                    foreach (var foreignKey in entity.ForeignKeys.WhereOneToMany())
                    {
                        var joinTable = foreignKey.ForeignEntity.Table;
                        var joinProperty = foreignKey.ForeignEntity.Keys.FirstOrDefault(x => x.ForeignEntity == entity);

                        var keyProperty = foreignKey.TypeInfo.IsCollection ?
                            entity.Keys.FirstOrDefault() :
                            foreignKey;

                        joins += Environment.NewLine +
                            $"left join {joinTable} on {joinTable}.{joinProperty.Column} = {entity.Table}.{keyProperty.Column}";

                        var propertyToGet = foreignKey.ForeignEntity.Keys.FirstOrDefault(x => x.ForeignEntity != entity) ??
                                            joinProperty;

                        columns += $",{joinTable}.{propertyToGet.Column} as {foreignKey.Column}";
                    }
                }
                var result = table.All(
                    columns: columns,
                    joins: joins,
                    where: where,
                    orderBy: orderBy,
                    args: args.ToArray());

                var records = result
                    .Select(item => entity.CreateRecord(item))
                    .ToList();

                return new PagedRecords
                {
                    Records = records
                };
            }
        }
Пример #36
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);
        if (!String.IsNullOrEmpty(txtArea_Search.Text))
        {
            es.AddSearchCodition("Area", txtArea_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtFactory_Search.Text))
        {
            es.AddSearchCodition("Factory", txtFactory_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtSection_Search.Text))
        {
            es.AddSearchCodition("Section", txtSection_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtCode_Search.Text))
        {
            es.AddSearchCodition("Code", txtCode_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtTrainCode_Search.Text))
        {
            es.AddSearchCodition("TrainCode", txtTrainCode_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtAlias_Search.Text))
        {
            es.AddSearchCodition("Alias", txtAlias_Search.Text, "=");
        }

        Filter = es.Where;
        BindData();
    }
Пример #37
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);
        if (!String.IsNullOrEmpty(txtcode_Search.Text))
        {
            es.AddSearchCodition("code", txtcode_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtdescription_Search.Text))
        {
            es.AddSearchCodition("description", txtdescription_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtno1_Search.Text))
        {
            es.AddSearchCodition("no1", txtno1_Search.Text, "=");
        }

        Filter = es.Where;
        BindData();
    }
Пример #38
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);

        if (!String.IsNullOrEmpty(txtName_Search.Text))
        {
            es.AddSearchCodition("Name", txtName_Search.Text, "like");
        }

        if (ddlArea_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Area", ddlArea_Search.SelectedItem.Text, "like");
        }

        if (ddlFactory_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Factory", ddlFactory_Search.SelectedItem.Text, "like");
        }

        if (ddlSection_Search.SelectedIndex > 0)
        {
            es.AddSearchCodition("Section", ddlSection_Search.SelectedItem.Text, "like");
        }

        if (!String.IsNullOrEmpty(txtJobDate_begin.Text))
        {
            String endDate = DateTime.Today.ToString();
            if (!String.IsNullOrEmpty(txtJobDate_end.Text))
            {
                endDate = txtJobDate_end.Text;
            }
            String dateFilter=String.Format(@"jobDate between '{0}' and '{1}'",txtJobDate_begin.Text,endDate);
            String filter = es.Where;
            if (filter != "")
            {
                filter = filter+" and " + dateFilter;
            }
            else {
                filter = dateFilter;
            }
            Filter = filter;

        }
        else
        {
            Filter = es.Where;
        }

        BindData();
    }
Пример #39
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        EntitySearch es = new EntitySearch(_Entity);
        if (!String.IsNullOrEmpty(txtSection_Search.Text))
        {
            es.AddSearchCodition("Section", txtSection_Search.Text, "like");
        }

        if (!String.IsNullOrEmpty(txtSequence_Search.Text))
        {
            es.AddSearchCodition("Sequence", txtSequence_Search.Text, "=");
        }

        if (!String.IsNullOrEmpty(txtCheckPosition_Search.Text))
        {
            es.AddSearchCodition("CheckPosition", txtCheckPosition_Search.Text, "like");
        }

        if (!String.IsNullOrEmpty(txtCheckMethod_Search.Text))
        {
            es.AddSearchCodition("CheckMethod", txtCheckMethod_Search.Text, "like");
        }

        if (!String.IsNullOrEmpty(txtBarCode_Search.Text))
        {
            es.AddSearchCodition("BarCode", txtBarCode_Search.Text, "like");
        }

        Filter = es.Where;
        BindData();
    }