Ejemplo n.º 1
0
        /// <summary>
        /// Returns a query that shall be used to pick only the available costcenters
        /// </summary>
        /// <param name="subCustomer"></param>
        /// <param name="personId"></param>
        /// <returns></returns>
        private string BuildCostCentersFromMaximo(string subCustomer, string personId)
        {
            var groupNameToQuery = "'" + HapagPersonGroupConstants.BaseHapagLocationPrefix + subCustomer + "%" + "'";
            var results          =
                _maxDAO.FindByNativeQuery(
                    "select p.persongroup,description from PERSONGROUP p left join persongroupview v on p.PERSONGROUP = v.PERSONGROUP " +
                    "where (p.persongroup  like {0} ) and v.PERSONID = {1} and v.groupdefault = 1"
                    .Fmt(groupNameToQuery, "'" + personId + "'"));
            var list = results.Cast <IEnumerable <KeyValuePair <string, object> > >()
                       .Select(r => r.ToDictionary(pair => pair.Key, pair => pair.Value, StringComparer.OrdinalIgnoreCase)).ToList();
            ISet <string> costcenters = new HashSet <string>();

            foreach (var groupsDescription in list)
            {
                var pg = new PersonGroup()
                {
                    Name        = groupsDescription["persongroup"] as string,
                    Description = groupsDescription["description"] as string,
                };
                var supergroup = HlagLocationUtil.IsSuperGroup(pg);
                if (HlagLocationUtil.IsALocationGroup(pg) && !supergroup)
                {
                    costcenters.Add(HlagLocationUtil.GetCostCenter(pg));
                }
            }
            if (!costcenters.Any())
            {
                return("1!=1");
            }


            var groupedLocation = new HlagGroupedLocation(subCustomer, costcenters, false);

            return(groupedLocation.CostCentersForQuery("glaccount"));
        }
Ejemplo n.º 2
0
 private void AddGroupedLocation(IEnumerable <PersonGroup> groups)
 {
     if (groups == null)
     {
         return;
     }
     foreach (var group in groups)
     {
         var location        = HlagLocationsCache[group].First();
         var groupedLocation = HlagGroupedLocationsCache.FirstOrDefault(f => f.SubCustomer == location.SubCustomer);
         if (groupedLocation == null)
         {
             groupedLocation = new HlagGroupedLocation(location.SubCustomer);
             groupedLocation.FromSuperGroup = location.FromSuperGroup;
             HlagGroupedLocationsCache.Add(groupedLocation);
         }
         groupedLocation.CostCenters.Add(location.CostCenter);
     }
 }
Ejemplo n.º 3
0
        private static HashSet <HlagGroupedLocation> BuildGroupedLocations(IEnumerable <HlagLocation> resultLocations)
        {
            var tempDictionary = new Dictionary <string, TempGroupLocation>();

            foreach (var hlagLocation in resultLocations)
            {
                if (!tempDictionary.ContainsKey(hlagLocation.SubCustomer))
                {
                    tempDictionary.Add(hlagLocation.SubCustomer, new TempGroupLocation(hlagLocation.FromSuperGroup));
                }
                tempDictionary[hlagLocation.SubCustomer].Costcenters.Add(hlagLocation.CostCenter);
            }
            var groupedLocations = new HashSet <HlagGroupedLocation>();

            foreach (var entry in tempDictionary)
            {
                var hlagGroupedLocation = new HlagGroupedLocation(entry.Key, entry.Value.Costcenters,
                                                                  entry.Value.FromSuperGroup);
                groupedLocations.Add(hlagGroupedLocation);
            }

            return(groupedLocations);
        }
Ejemplo n.º 4
0
 protected bool Equals(HlagGroupedLocation other)
 {
     return(string.Equals(SubCustomer, other.SubCustomer));
 }
 public HlagGroupedLocationsNoPrefixDecorator(HlagGroupedLocation groupedLocation)
 {
     _groupedLocation = groupedLocation;
 }