private string NAOCodeToFieldValue(string naoCode, PIItemLocationInfo il)
        {
            switch (naoCode)
            {
            case PINumberAssignmentOrder.EmptySort:
                return(null);

            case PINumberAssignmentOrder.ByLocationID:
                return(il.LocationCD ?? string.Empty);

            case PINumberAssignmentOrder.ByInventoryID:
                return(il.InventoryCD ?? string.Empty);

            case PINumberAssignmentOrder.BySubItem:
                return(il.SubItemCD ?? string.Empty);

            case PINumberAssignmentOrder.ByLotSerial:
                return(il.LotSerialNbr ?? string.Empty);

            case PINumberAssignmentOrder.ByInventoryDescription:
                return(il.Description ?? string.Empty);

            default:
                throw new PXException(Messages.UnknownPiTagSortOrder);
            }
        }
        private void AddFieldIfNAOCodeSet(List <string> sortColumns, string naoCode, PIItemLocationInfo il)
        {
            string fieldValue = NAOCodeToFieldValue(naoCode, il);

            if (fieldValue != null)
            {
                sortColumns.Add(fieldValue);
            }
        }
        private string[] GetSortingKey(PIItemLocationInfo il)
        {
            var keys = new List <string>();

            AddFieldIfNAOCodeSet(keys, piClass.NAO1, il);
            AddFieldIfNAOCodeSet(keys, piClass.NAO2, il);
            AddFieldIfNAOCodeSet(keys, piClass.NAO3, il);
            AddFieldIfNAOCodeSet(keys, piClass.NAO4, il);
            return(keys.ToArray());
        }
        public int Compare(PIItemLocationInfo x, PIItemLocationInfo y)
        {
            var xKeys = GetSortingKey(x);
            var yKeys = GetSortingKey(y);

            int result = 0;

            for (int i = 0; i < xKeys.Length; i++)
            {
                result = string.Compare(xKeys[i], yKeys[i], StringComparison.InvariantCultureIgnoreCase);
                if (result != 0)
                {
                    break;
                }
            }
            return(result);
        }