コード例 #1
0
        internal static SearchRequestDto BuildDTO()
        {
            var dto = new SearchRequestDto {
                SearchSort      = "computername",
                SearchAscending = true,
                QueryAlias      = "rI102"
            };

            dto.AppendWhereClause("upper(ASSET.STATUS) = '{0}'".Fmt(AssetConstants.Active.ToUpper()));
            dto.AppendSearchEntry("upper_computername", "P%");


            var configFilePath = MetadataProvider.GlobalProperty("RI102Path");

            if (!File.Exists(configFilePath))
            {
                return(dto);
            }
            var fileLines = File.ReadAllLines(configFilePath);

            var sb = ClassStructureConfigFileReader.DoBuildQuery(fileLines);

            dto.AppendWhereClause(sb);
            return(dto);
        }
コード例 #2
0
        public static SearchRequestDto BuildStdParentDTO()
        {
            var dto = new SearchRequestDto();

            dto.AppendProjectionField(ProjectionField.Default(ClassStructureIdColumn));
            dto.AppendWhereClause(StdClassificationPathParent);
            return(dto);
        }
コード例 #3
0
        public IEnumerable <IAssociationOption> ResolveOptions(ApplicationMetadata applicationMetadata,
                                                               AttributeHolder originalEntity, ApplicationAssociationDefinition association, SearchRequestDto associationFilter)
        {
            if (!FullSatisfied(association, originalEntity))
            {
                return(null);
            }

            // Set dependante lookup atributes
            var lookupAttributes = association.LookupAttributes();

            foreach (var lookupAttribute in lookupAttributes)
            {
                var searchValue = SearchUtils.GetSearchValue(lookupAttribute, originalEntity);
                if (!String.IsNullOrEmpty(searchValue))
                {
                    associationFilter.AppendSearchParam(lookupAttribute.To);
                    associationFilter.AppendSearchValue(searchValue);
                }
                else if (lookupAttribute.Query != null)
                {
                    associationFilter.AppendWhereClause(lookupAttribute.GetQueryReplacingMarkers(association.EntityAssociation.To));
                }
            }

            // Set projections and pre filter functions
            var numberOfLabels        = BuildProjections(associationFilter, association);
            var prefilterFunctionName = association.Schema.DataProvider.PreFilterFunctionName;

            if (prefilterFunctionName != null)
            {
                var preFilterParam = new AssociationPreFilterFunctionParameters(applicationMetadata, associationFilter, association, originalEntity);
                associationFilter = PrefilterInvoker.ApplyPreFilterFunction(DataSetProvider.GetInstance().LookupDataSet(applicationMetadata.Name), preFilterParam, prefilterFunctionName);
            }

            var entityMetadata = MetadataProvider.Entity(association.EntityAssociation.To);

            associationFilter.QueryAlias = association.AssociationKey;
            var queryResponse = EntityRepository.Get(entityMetadata, associationFilter);

            if (associationFilter is PaginatedSearchRequestDto)
            {
                var paginatedFilter = (PaginatedSearchRequestDto)associationFilter;
                if (paginatedFilter.NeedsCountUpdate)
                {
                    paginatedFilter.TotalCount = EntityRepository.Count(entityMetadata, associationFilter);
                }
            }

            var    options            = BuildOptions(queryResponse, association, numberOfLabels);
            string filterFunctionName = association.Schema.DataProvider.PostFilterFunctionName;

            return(filterFunctionName != null?ApplyFilters(applicationMetadata.Name, originalEntity, filterFunctionName, options, association) : options);
        }
コード例 #4
0
        internal static SearchRequestDto BuildDTO()
        {
            var dto = new SearchRequestDto {
                SearchSort      = "computername",
                SearchAscending = true,
                QueryAlias      = "rI104"
            };

            //h,c,n,t,a,b,k
            char[] chars = { 'h', 'c', 'n', 't', 'a', 'b', 'k' };
            dto.AppendWhereClause("upper(STATUS) in ('{0}') ".Fmt(AssetConstants.Active.ToUpper()));
            var sb = new StringBuilder(" ( ");

            for (var index = 0; index < chars.Length; index++)
            {
                var c = chars[index];
                sb.AppendFormat(" {0} like ('{1}%') ", ComputerNameQuery, c);
                if (index != chars.Length - 1)
                {
                    sb.AppendFormat(" or ");
                }
            }
            sb.Append(")");

            dto.AppendWhereClause(sb.ToString());



            //            var configFilePath = MetadataProvider.GlobalProperty("RI104Path");
            //            if (!File.Exists(configFilePath)) {
            //                return dto;
            //            }
            //            var fileLines = File.ReadAllLines(configFilePath);
            //
            //            var sb = ClassStructureConfigFileReader.DoBuildQuery(fileLines);
            //            dto.AppendWhereClause(sb);
            return(dto);
        }
コード例 #5
0
        protected SearchRequestDto AssetByLocationCondition(SearchRequestDto searchDTO, string fromLocation, ApplicationMetadata metadata)
        {
            if (String.IsNullOrWhiteSpace(fromLocation))
            {
                throw ExceptionUtil.InvalidOperation("from location parameter should not be null");
            }
            searchDTO.IgnoreWhereClause = true;
            var locations = LocationManager.FindAllLocationsOfCurrentUser(metadata);
            var location  = locations.FirstOrDefault(l => l.SubCustomer.Contains(fromLocation));

            if (location == null)
            {
                throw ExceptionUtil.InvalidOperation("current user can not access location {0}", fromLocation);
            }

            searchDTO.AppendSearchEntry(ISMConstants.PluspCustomerColumn, "%" + fromLocation);
            searchDTO.AppendWhereClause(location.CostCentersForQuery("asset.glaccount"));
            return(searchDTO);
        }
コード例 #6
0
        public IEnumerable <IAssociationOption> FindCostCentersOfITC(string subCustomer, string personId = null)
        {
            string       costCentersToUse = "";
            InMemoryUser inMemoryUser     = null;

            if (personId == null)
            {
                personId     = SecurityFacade.CurrentUser().MaximoPersonId;
                inMemoryUser = SecurityFacade.CurrentUser();
            }

            costCentersToUse = BuildCostCentersFromMaximo(subCustomer, personId);

            if (costCentersToUse.Equals("1!=1"))
            {
                if (inMemoryUser == null)
                {
                    var user = _dao.FindSingleByQuery <User>(User.UserByMaximoPersonId, personId);
                    inMemoryUser = new InMemoryUser(user, new List <UserProfile>(), null);
                }
                //we´re interested in the current user, so we can assume its groups are synced fine.
                //pick the groups from SWDB
                var result  = FillUserLocations(inMemoryUser);
                var context = _contextLookuper.LookupContext();
                //if the user is not on XITC context, then we should pick just the costcenters directly bound to him (HAP-799)
                var locationsToUse = context.IsInModule(FunctionalRole.XItc)
                    ? result.GroupedLocations
                    : result.DirectGroupedLocations;
                var groupedLocation = locationsToUse.FirstOrDefault(f => f.SubCustomerSuffix == subCustomer);
                if (groupedLocation == null)
                {
                    return(null);
                }
                costCentersToUse = groupedLocation.CostCentersForQuery("glaccount");
            }

            var dto = new SearchRequestDto();

            dto.AppendProjectionField(new ProjectionField("accountname", "accountname"));
            dto.AppendProjectionField(new ProjectionField("glaccount", "glaccount"));
            dto.AppendProjectionField(new ProjectionField("displaycostcenter", "displaycostcenter"));

            dto.AppendWhereClause(costCentersToUse);

            var queryResult = _repository.Get(MetadataProvider.Entity("chartofaccounts"), dto);
            var options     = new HashSet <GenericAssociationOption>();

            foreach (var attributeHolder in queryResult)
            {
                var value = (String)attributeHolder.GetAttribute("glaccount");
                var label = (String)attributeHolder.GetAttribute("displaycostcenter");
                options.Add(new GenericAssociationOption(value, label));
            }

            //            if (options.Count == 0 && ApplicationConfiguration.IsDebug()) {
            //                options.Add(new GenericAssociationOption("6700-238-350", "6700/238/350//RMA+Prod+Contract Labor"));
            //                options.Add(new GenericAssociationOption("6690-810-300", "6690/810/300Inv//Shrinkage+Transit+Labor"));
            //                options.Add(new GenericAssociationOption("6700-300-300", "6700/300/300//Maint+Prod+Labor"));
            //            }

            return(options);
        }