Example #1
0
        public static CatalogItemDetails GetCatalogItem(string catalogID, string accountItemID)
        {
            CatalogItemDetails details = null;

            try
            {
                using (_certonaService = new CertonaServiceClient())
                {
                    try
                    {
                        UserDTO user = FormsAuthenticationWrapper.User;
                        var     catalogItemRequest = new GetCatalogItemRequest()
                        {
                            User          = user,
                            AccountID     = user.LastAccountID,
                            AccountItemID = accountItemID,
                            CatalogID     = catalogID
                        };

                        var catalogItemResponse = _certonaService.GetCatalogItem(catalogItemRequest);

                        if (catalogItemResponse.Success && catalogItemResponse.CatalogItem != null)
                        {
                            details = new CatalogItemDetails()
                            {
                                CatalogAssociatedItems = catalogItemResponse.CatalogItem.CatalogItemAssociatedItem.Select(
                                    r => new ItemAssociatedItem
                                {
                                    ItemID       = r.ItemID,
                                    DisplayOrder = r.DisplayOrder
                                }).ToList()
                            };

                            if (catalogItemResponse.CatalogItem.CatalogItemInfo != null)
                            {
                                details.CatalogItemInfo = new ItemInfo(catalogItemResponse.CatalogItem.CatalogItemInfo);
                            }

                            details.CatalogItemMetaData = catalogItemResponse.CatalogItem.CatalogItemMetaData.Select(
                                r => new ItemMetaData
                            {
                                CatalogID    = r.CatalogID,
                                FunctionName = r.FunctionName,
                                LevelName    = r.LevelName,
                                GroupName    = r.GroupName
                            }).ToList();

                            details.CatalogMetaData = catalogItemResponse.CatalogItem.CatalogMetaData.Select(
                                r => new MetaData
                            {
                                CatalogID = r.CatalogID,
                                Name1     = r.Name1,
                                Name2     = r.Name2,
                                Name3     = r.Name3
                            }).ToList();

                            details.CatalogMetaData2 = catalogItemResponse.CatalogItem.CatalogMetaData2.Select(
                                r => new MetaData
                            {
                                CatalogID = r.CatalogID,
                                Name1     = r.Name1,
                                Name2     = r.Name2,
                                Name3     = r.Name3
                            }).ToList();

                            details.CatalogMapping = catalogItemResponse.CatalogItem.CatalogMapping.Select(
                                r => new CatalogMapping
                            {
                                CatalogID      = r.CatalogID,
                                ResonanceField = r.ResonanceField,
                                CustomerField  = r.CustomerField,
                                Description    = r.Description,
                                AttributeType  = r.AttributeType,
                                CustomVariable = r.CustomVariable,
                                IsRuleEnabled  = r.IsRuleEnabled,
                                IsMapped       = r.IsMapped,
                                XSLTransform   = r.XSLTransform,
                                OLAPLevel      = r.OLAPLevel
                            }).ToList();
                        }
                    }
                    catch (TimeoutException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                    catch (CommunicationException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(details);
        }