public IEnumerable <IAssociationOption> FindDefaultITCsOfLocation(string subcustomer)
        {
            var dto = new SearchRequestDto();

            dto.AppendProjectionField(ProjectionField.Default("personid"));
            dto.AppendProjectionField(ProjectionField.Default("hlagdisplayname"));
            var groupNameToQuery = HapagPersonGroupConstants.BaseHapagLocationPrefix + subcustomer + "%";

            dto.AppendWhereClauseFormat("personid in (select personid from persongroupview where persongroup like '{0}' and groupdefault=1)", groupNameToQuery);

            var persons = _repository.Get(_personEntity, dto);


            var result = new HashSet <ItcUser>();

            foreach (var user in persons)
            {
                var personId    = user.GetAttribute("personid") as string;
                var displayname = user.GetAttribute("hlagdisplayname") as string;
                result.Add(new ItcUser {
                    Label = displayname,
                    Value = personId
                });
            }
            return(result);
        }
Example #2
0
        public static SearchRequestDto BuildStdParentDTO()
        {
            var dto = new SearchRequestDto();

            dto.AppendProjectionField(ProjectionField.Default(ClassStructureIdColumn));
            dto.AppendWhereClause(StdClassificationPathParent);
            return(dto);
        }
        public void TestReplaceInner()
        {
            var dto = new SearchRequestDto();

            dto.AppendProjectionField(ProjectionField.Default("primaryuser_.person_.hlagdisplayname"));
            var result = QuerySelectBuilder.BuildSelectAttributesClause(MetadataProvider.Entity("asset"), QueryCacheKey.QueryMode.Detail, dto);

            Assert.AreEqual(("select CASE WHEN LOCATE('@',primaryuser_person_.PERSONID) > 0 THEN '(' || SUBSTR(primaryuser_person_.PERSONID,1,LOCATE('@',primaryuser_person_.PERSONID)-1) || ') ' || COALESCE(primaryuser_person_.DISPLAYNAME,'-- Name Not Set --') ELSE '(' || primaryuser_person_.PERSONID || ') ' || COALESCE(primaryuser_person_.DISPLAYNAME,'-- Name Not Set --') END as primaryuser_person_hlagdisplayname "), result);
        }
        public void TestRelationshipQuery()
        {
            var dto = new SearchRequestDto();

            dto.AppendProjectionField(ProjectionField.Default("description"));
            dto.AppendSearchEntry("status", "('120 Active','OPERATING')");
            dto.AppendSearchEntry("usercustodianuser_.personid", "xxx");
            var result = QueryFromBuilder.Build(MetadataProvider.Entity("asset"), dto);

            Assert.AreEqual("from asset as asset left join AssetUserCust as usercustodianuser_ on (asset.assetnum = usercustodianuser_.assetnum and asset.siteid = usercustodianuser_.siteid and usercustodianuser_.isuser = 1)", result);
        }
Example #5
0
        private static SearchRequestDto GetPersonGroupSearchDTO()
        {
            var dto = new SearchRequestDto();

            dto.AppendSearchEntry(PersonGroupColumn, HapagPersonGroupConstants.BaseHapagPrefix);
            dto.AppendProjectionField(ProjectionField.Default(PersonGroupColumn));
            dto.AppendProjectionField(ProjectionField.Default(PersonIdColumn));
            dto.AppendProjectionField(ProjectionField.Default("rowstamp"));
            dto.AppendProjectionField(ProjectionField.Default("rowstamp1"));
            return(dto);
        }
        public void TestReplace_Nulls()
        {
            var dto = new SearchRequestDto();

            dto.AppendProjectionField(ProjectionField.Default("#null1"));
            dto.AppendProjectionField(ProjectionField.Default("#null2"));
            //unmappped
            dto.AppendProjectionField(ProjectionField.Default("#attr"));
            dto.AppendProjectionField(ProjectionField.Default("description"));
            var result = QuerySelectBuilder.BuildSelectAttributesClause(MetadataProvider.Entity("sr"), QueryCacheKey.QueryMode.List, dto);

            Assert.AreEqual(("select null, null, SR.description as description "), result);
        }
Example #7
0
        private IEnumerable <IAssociationOption> GetBuilding(string location)
        {
            var dto = new SearchRequestDto();

            dto.AppendSearchEntry("CLASSSTRUCTUREID", "BUILDING");
            dto.AppendProjectionField(ProjectionField.Default("description"));
            dto.AppendProjectionField(ProjectionField.Default("location"));
            return(BuildingFloorRoomManager.DoGetLocation(location, dto, dict => {
                var rawLabel = (String)dict["description"];
                var rawValue = (String)dict["location"];
                //TODO: fix label
                return new AssociationOption(rawValue.Split('/')[0], rawLabel);
            }));
        }
        public void IncidentHardwareReport()
        {
            var dto = new SearchRequestDto();

            dto.AppendProjectionField(ProjectionField.Default("asset_assetloccomm_commoditiesownedby_.description"));
            dto.AppendProjectionField(ProjectionField.Default("asset_assetloccomm_.commodity"));

            var completeOne = MetadataProvider.Application("incident");
            var metadata    = completeOne.ApplyPolicies(new ApplicationMetadataSchemaKey("hardwarerepair"), InMemoryUser.TestInstance(),
                                                        ClientPlatform.Web);
            ApplicationSchemaDefinition schema;
            var sliced = SlicedEntityMetadataBuilder.GetInstance(MetadataProvider.Entity("incident"), metadata.Schema);
            var result = QueryFromBuilder.Build(sliced, dto);

            Assert.AreEqual("from incident as incident left join asset as asset_ on (incident.assetnum = asset_.assetnum and incident.siteid = asset_.siteid)left join assetloccomm as asset_assetloccomm_ on (asset_.assetnum = asset_assetloccomm_.assetnum and asset_.siteid = asset_assetloccomm_.siteid)left join commodities as asset_assetloccomm_commoditiesownedby_ on (asset_assetloccomm_.commodity = asset_assetloccomm_commoditiesownedby_.commodity and asset_assetloccomm_.itemsetid = asset_assetloccomm_commoditiesownedby_.itemsetid and (asset_assetloccomm_commoditiesownedby_.description like 'Asset owened by%'))", result);
        }
        public void TestInverseRelationship()
        {
//            var dto = new SearchRequestDto();
//            var completeOne = MetadataProvider.Application("change");
//            var metadata = completeOne.ApplyPolicies(new ApplicationMetadataSchemaKey("list"), InMemoryUser.TestInstance(),
//                ClientPlatform.Web);
//            ApplicationSchemaDefinition schema;
//            var sliced = SlicedEntityMetadataBuilder.GetInstance(MetadataProvider.Entity("change"), metadata.Schema);
//            var result = QueryFromBuilder.Build(MetadataProvider.Entity("wochange"), dto);

            var dto = new SearchRequestDto();

            dto.AppendProjectionField(ProjectionField.Default("sr_.description"));
            var result = QueryFromBuilder.Build(MetadataProvider.Entity("wochange"), dto);

            Assert.AreEqual("from wochange as wochange left join SR as sr_ on (wochange.origrecordid = sr_.ticketid and wochange.origrecordclass = 'SR' and wochange.woclass = 'CHANGE')", result);
        }
Example #10
0
 private static SearchRequestDto BuildDTO(SearchRequestDto dto = null)
 {
     if (dto == null)
     {
         dto = new SearchRequestDto();
     }
     dto.AppendProjectionField(ProjectionField.Default("firstname"));
     dto.AppendProjectionField(ProjectionField.Default("lastname"));
     dto.AppendProjectionField(ProjectionField.Default("status"));
     dto.AppendProjectionField(ProjectionField.Default("locationorg"));
     dto.AppendProjectionField(ProjectionField.Default("email_.emailaddress"));
     dto.AppendProjectionField(ProjectionField.Default("phone_.phonenum"));
     dto.AppendProjectionField(ProjectionField.Default("language"));
     dto.AppendProjectionField(ProjectionField.Default("department"));
     dto.AppendProjectionField(ProjectionField.Default("personid"));
     dto.AppendProjectionField(ProjectionField.Default("maxuser_.defsite"));
     dto.AppendProjectionField(ProjectionField.Default("maxuser_.loginid"));
     dto.AppendProjectionField(new ProjectionField("rowstamp1", "maxuser_rowstamp"));
     dto.AppendProjectionField(ProjectionField.Default("rowstamp"));
     return(dto);
 }
Example #11
0
        //for each assetnum/site tuple the
        public IDictionary <R0042AssetKey, ISet <string> > GetClosedImacIdsForR0042(List <string> assetIds, int month, int year)
        {
            var result = new Dictionary <R0042AssetKey, ISet <string> >();

            var compAppMetadata = MetadataProvider.Application(ApplicationName());
            var dto             = new PaginatedSearchRequestDto {
                NeedsCountUpdate = false
            };

            dto.ProjectionFields.Add(ProjectionField.Default("ticketid"));
            dto.ProjectionFields.Add(ProjectionField.Default("ticketuid"));
            dto.ProjectionFields.Add(ProjectionField.Default("assetnum"));
            dto.ProjectionFields.Add(ProjectionField.Default("siteid"));
            dto.ProjectionFields.Add(ProjectionField.Default("woactivity_.OWNERGROUP"));

            dto.AppendWhereClauseFormat("woactivity_.OWNERGROUP = 'I-EUS-DE-CSC-SDK-ASSET' and month(woactivity_.ACTFINISH) = {0} and year(woactivity_.ACTFINISH) = {1} and imac.assetnum in ({2})", month, year, BaseQueryUtil.GenerateInString(assetIds));
            var entityMetadata     = MetadataProvider.SlicedEntityMetadata(new ApplicationMetadataSchemaKey("detail"), "imac");
            var searchEntityResult = EntityRepository.GetAsRawDictionary(entityMetadata, dto);


            foreach (var imac in searchEntityResult.ResultList)
            {
                var key = new R0042AssetKey {
                    AssetNum = imac["assetnum"].ToString(),
                    SiteId   = imac["siteid"].ToString()
                };
                if (result.ContainsKey(key))
                {
                    result[key].Add(imac["ticketid"].ToString());
                }
                else
                {
                    result[key] = new HashSet <string> {
                        imac["ticketid"].ToString()
                    };
                }
            }

            return(result);
        }
Example #12
0
        public IEnumerable <FaqData> GetList()
        {
            var dto = new SearchRequestDto();

            dto.AppendSearchEntry("pluspinsertcustomer", "HLC-%");
            dto.AppendSearchEntry("status", "ACTIVE");
            dto.AppendProjectionField(ProjectionField.Default("solutionid"));
            dto.AppendProjectionField(ProjectionField.Default("description"));
            var result           = EntityRepository.GetAsRawDictionary(MetadataProvider.Entity("solution"), dto);
            var attributeHolders = result.ResultList;

            Log.DebugFormat("db size {0}", attributeHolders.Count());
            var treeDataList = new List <FaqData>();

            foreach (var attributeHolder in attributeHolders)
            {
                var solutionId  = (int)attributeHolder["solutionid"];
                var description = (string)attributeHolder["description"];
                treeDataList.Add(new FaqData(solutionId, description));
            }
            Log.DebugFormat("returned list size {0}", treeDataList.Count());
            return(treeDataList);
        }