public void TestQueryGenerator()
        {
            var l = new HlagGroupedLocation("any", new HashSet <string> {
                "a", "b", "c"
            }, true);
            var query = l.CostCentersForQuery("asset.location");

            Assert.AreEqual("(asset.location like '%a%' or asset.location like '%b%' or asset.location like '%c%')", query);
        }
Exemple #2
0
        /// <summary>
        /// This is the base ticket restriction which states that a given ticket is only visible if:
        ///
        /// 1) it´s declared in the same customer as the user
        /// 2) either its costcenter (either from asset or affectedperson_ itdcomment) is equal to the location´s or it has no costcenter at all declared
        /// </summary>
        /// <param name="ticketQualifier"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        private static string AppendLocationCondition(string ticketQualifier, HlagGroupedLocation location)
        {
            var isImac = ticketQualifier == "imac";

            if (isImac)
            {
                return(String.Format(
                           @"({0}.pluspcustomer in('{1}')
                    and (
                            ({0}.assetnum is not null and {2}) or (imac.CLASSIFICATIONID = '81515000' and {3})
                        )
                 )"
                           , ticketQualifier, location.SubCustomer, location.CostCentersForQuery("asset_.glaccount"),
                           location.ImacDescriptionCostCentersForQuery()));
            }
            return(String.Format(
                       @"({0}.pluspcustomer in('{1}')
                    and (
                            (({2} or affectedperson_.itdcomment is null))
                        )
                 )"
                       , ticketQualifier, location.SubCustomer,
                       location.CostCentersForQuery("affectedperson_.itdcomment")));
        }