示例#1
0
        public IEnumerable <IAssociationOption> ParseCommoditiesList(AssociationPostFilterFunctionParameters postParams)
        {
            var comparer = new OptionComparer();
            ISet <IAssociationOption> commodity = new SortedSet <IAssociationOption>();

            foreach (var resultset in postParams.Options)
            {
                AssociationOption result = new AssociationOption(resultset.Value, resultset.Label);
                result.Value = resultset.Value;
                if (resultset.Label == null || resultset.Label.IndexOf('-') == -1)
                {
                    result.Label = MISSING;
                    //commodity.Add(result);
                }
                else
                {
                    string[] arrTemp = resultset.Label.Split('-');
                    if (postParams.Association.Target == "component")
                    {
                        result.Label = (arrTemp.Length > 2) ? arrTemp[2] : MISSING;
                        //Please Confirm Luiz
                        result.Value = result.Label;
                        commodity.Add(result);
                    }
                    else if (postParams.Association.Target == "system")
                    {
                        result.Label = arrTemp[0] + '-' + arrTemp[1];
                        //Please Confirm Luiz
                        result.Value = result.Label;
                        commodity.Add(result);
                    }
                    else if (postParams.Association.Target == "module")
                    {
                        result.Label = (arrTemp.Length > 4) ? ModuleFieldValue(arrTemp) : MISSING;
                        //Please Confirm Luiz
                        result.Value = result.Label;
                        commodity.Add(result);
                    }
                    else if (postParams.Association.Target == "item")
                    {
                        result.Label = (arrTemp.Length > 3) ? arrTemp[3] : MISSING;
                        //Please Confirm Luiz
                        result.Value = result.Label;
                        commodity.Add(result);
                    }
                }
            }

            return(commodity);
        }
        public IEnumerable <IAssociationOption> GetHlagAllCostCenters(OptionFieldProviderParameters parameters)
        {
            ISet <IAssociationOption> costcenters = new SortedSet <IAssociationOption>();
            var currentLocations = LocationManager.FindAllLocations();
            var hlagLocations    = currentLocations as HlagGroupedLocation[] ?? currentLocations.ToArray();

            if (CollectionExtensions.IsNullOrEmpty(hlagLocations))
            {
                Log.Warn(HapagErrorCatalog.Err001);
                return(costcenters);
            }

            foreach (var hlagLocation in hlagLocations)
            {
                foreach (var costcenter in hlagLocation.CostCenters)
                {
                    var result = new AssociationOption(costcenter, costcenter);
                    costcenters.Add(result);
                }
            }
            return(costcenters);
        }
        public IEnumerable <IAssociationOption> GetHlagUserLocationAndCostCenter(OptionFieldProviderParameters parameters)
        {
            ISet <IAssociationOption> costcenters = new SortedSet <IAssociationOption>();
            var currentLocations  = LocationManager.FindAllLocationsOfCurrentUser(parameters.ApplicationMetadata);
            var hlagUserlocations = currentLocations as HlagGroupedLocation[] ?? currentLocations.ToArray();

            if (CollectionExtensions.IsNullOrEmpty(hlagUserlocations))
            {
                Log.Warn(HapagErrorCatalog.Err001);
                return(costcenters);
            }

            foreach (var hlaguserlocation in hlagUserlocations)
            {
                foreach (var costcenter in hlaguserlocation.CostCenters)
                {
                    var result = new AssociationOption(hlaguserlocation.SubCustomerSuffix + "-" + costcenter, hlaguserlocation.Label + " - " + costcenter);
                    costcenters.Add(result);
                }
            }
            return(costcenters);
        }