Exemple #1
0
        /// <summary>
        /// Gets the catalog nodes. Results are cached.
        /// </summary>
        /// <param name="catalogName">Name of the catalog.</param>
        /// <param name="parentNodeCode">The parent node code.</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        internal static CatalogNodes GetCatalogNodes(string catalogName, string parentNodeCode, CatalogNodeResponseGroup responseGroup)
        {
            // Assign new cache key, specific for site guid and response groups requested
            string cacheKey = CatalogCache.CreateCacheKey("catalognodes-catalogname-code", responseGroup.CacheKey, catalogName, parentNodeCode);

            CatalogNodes nodes = new CatalogNodes();

            // check cache first
            object cachedObject = CatalogCache.Get(cacheKey);

            if (cachedObject != null)
            {
                nodes = (CatalogNodes)cachedObject;
            }
            else
            {
                CatalogNodeDto dto = GetCatalogNodesDto(catalogName, parentNodeCode, responseGroup);

                // Load Node
                if (dto.CatalogNode.Count > 0)
                {
                    nodes = LoadNodes(dto, null, false, responseGroup);
                }

                CatalogCache.Insert(cacheKey, nodes, CatalogConfiguration.Instance.Cache.CatalogNodeTimeout);
            }

            return(nodes);
        }
Exemple #2
0
        /// <summary>
        /// Finds the nodes dto.
        /// </summary>
        /// <param name="search">The search.</param>
        /// <param name="recordsCount">The records count.</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        internal static CatalogNodeDto FindNodesDto(CatalogSearch search, ref int recordsCount, CatalogNodeResponseGroup responseGroup)
        {
            // Assign new cache key, specific for site guid and response groups requested
            string cacheKey = String.Empty;

            // Only cache results if specified
            if (search.SearchOptions.CacheResults)
            {
                cacheKey = CatalogCache.CreateCacheKey("catalog-nodesdto", responseGroup.CacheKey, search.CacheKey);

                // check cache first
                object cachedObject = CatalogCache.Get(cacheKey);

                if (cachedObject != null)
                {
                    return((CatalogNodeDto)cachedObject);
                }
            }

            CatalogNodeDto dto = FindNodesDto2(search, ref recordsCount, responseGroup);

            if (!String.IsNullOrEmpty(cacheKey)) // cache results
            {
                // Insert to the cache collection
                CatalogCache.Insert(cacheKey, dto, search.SearchOptions.CacheTimeout);
            }

            return(dto);
        }
Exemple #3
0
        /// <summary>
        /// Deletes the catalog node.
        /// </summary>
        /// <param name="catalogNodeId">The catalog node id.</param>
        /// <param name="catalogId">The catalog id.</param>
        /// <param name="catalogNodeDto">The catalog node Dto.</param>
        /// <param name="catalogDto">The catalog Dto.</param>
        internal static void DeleteNodeRecursive(int catalogNodeId, int catalogId, ref CatalogNodeDto catalogNodeDto, ref CatalogRelationDto catalogRelationDto)
        {
            CatalogNodeDto.CatalogNodeRow row = catalogNodeDto.CatalogNode.FindByCatalogNodeId(catalogNodeId);
            if (row != null)
            {
                DataRow[] catalogRelations = catalogRelationDto.CatalogNodeRelation.Select(String.Format("CatalogId = {0} AND ParentNodeId = {1}", catalogId, catalogNodeId));
                foreach (DataRow catalogRelation in catalogRelations)
                {
                    catalogRelation.Delete();
                }

                DataRow[] nodeEntryRelations = catalogRelationDto.NodeEntryRelation.Select(String.Format("CatalogId = {0} AND CatalogNodeId = {1}", catalogId, catalogNodeId));
                foreach (DataRow nodeEntryRelation in nodeEntryRelations)
                {
                    nodeEntryRelation.Delete();
                }

                row.Delete();

                DataRow[] catalogNodes = catalogNodeDto.CatalogNode.Select(String.Format("ParentNodeId = {0}", catalogNodeId));
                if (catalogNodes.Length > 0)
                {
                    foreach (DataRow catalogNode in catalogNodes)
                    {
                        DeleteNodeRecursive((int)catalogNode["CatalogNodeId"], catalogId, ref catalogNodeDto, ref catalogRelationDto);
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Gets the catalog node. Results are cached.
        /// </summary>
        /// <param name="uri">The URI.</param>
        /// <param name="languageCode">The language code.</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        internal static CatalogNode GetCatalogNode(string uri, string languageCode, CatalogNodeResponseGroup responseGroup)
        {
            // Assign new cache key, specific for site guid and response groups requested
            string cacheKey = CatalogCache.CreateCacheKey("catalognode-objects-uri", responseGroup.CacheKey, uri, languageCode);

            CatalogNode node = null;

            // check cache first
            object cachedObject = CatalogCache.Get(cacheKey);

            if (cachedObject != null)
            {
                node = (CatalogNode)cachedObject;
            }

            // Load the object
            if (node == null)
            {
                CatalogNodeDto dto = GetCatalogNodeDto(uri, languageCode, responseGroup);

                // Load node
                if (dto.CatalogNode.Count > 0)
                {
                    node = LoadNode(dto.CatalogNode[0], false, responseGroup);
                }
                else
                {
                    node = new CatalogNode();
                }

                CatalogCache.Insert(cacheKey, node, CatalogConfiguration.Instance.Cache.CatalogNodeTimeout);
            }

            return(node);
        }
Exemple #5
0
        /// <summary>
        /// Finds the nodes dto2.
        /// </summary>
        /// <param name="search">The search.</param>
        /// <param name="recordsCount">The records count.</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        private static CatalogNodeDto FindNodesDto2(CatalogSearch search, ref int recordsCount, CatalogNodeResponseGroup responseGroup)
        {
            CatalogNodeDto dto = null;

            Guid searchGuid = Guid.NewGuid();

            // Perform order search
            recordsCount = search.SearchNodes(searchGuid);

            CatalogNodeAdmin admin = new CatalogNodeAdmin();

            // Load results and return them back
            admin.LoadSearchResults(searchGuid);

            dto = admin.CurrentDto;

            if (dto.CatalogNode.Count > 0)
            {
                foreach (CatalogNodeDto.CatalogNodeRow row in dto.CatalogNode.Rows)
                {
                    LoadNode(admin, row, responseGroup);
                }
            }

            /*
             * if (admin.CurrentDto.CatalogNode.Count > 0)
             * {
             *  MetaDataContext.Current = CatalogContext.MetaDataContext;
             *  foreach (CatalogNodeDto.CatalogNodeRow row in admin.CurrentDto.CatalogNode.Rows)
             *      MetaHelper.FillMetaData(row, row.MetaClassId, row.CatalogNodeId, true);
             * }
             * */

            return(admin.CurrentDto);
        }
Exemple #6
0
        /// <summary>
        /// Moves the catalog node.
        /// </summary>
        /// <param name="catalogId">The catalog id.</param>
        /// <param name="catalogNodeId">The catalog node id.</param>
        /// <param name="targetCatalogId">The target catalog id.</param>
        /// <param name="targetCatalogNodeId">The target catalog node id.</param>
        private void MoveCatalogNode(int catalogId, int catalogNodeId, int targetCatalogId, int targetCatalogNodeId)
        {
            if (catalogId != targetCatalogId || catalogNodeId != targetCatalogNodeId)
            {
                if (catalogNodeId > 0)
                {
                    CatalogNodeDto catalogNodeDto = CatalogContext.Current.GetCatalogNodeDto(catalogNodeId);
                    if (catalogNodeDto.CatalogNode.Count > 0)
                    {
                        catalogNodeDto.CatalogNode[0].CatalogId    = targetCatalogId;
                        catalogNodeDto.CatalogNode[0].ParentNodeId = targetCatalogNodeId;
                        CatalogContext.Current.SaveCatalogNode(catalogNodeDto);

                        CatalogNodeDto childCatalogNodesDto = CatalogContext.Current.GetCatalogNodesDto(catalogId, catalogNodeDto.CatalogNode[0].CatalogNodeId);
                        if (childCatalogNodesDto.CatalogNode.Count > 0)
                        {
                            for (int i = 0; i < childCatalogNodesDto.CatalogNode.Count; i++)
                            {
                                MoveCatalogNode(catalogId, childCatalogNodesDto.CatalogNode[i].CatalogNodeId, targetCatalogId, catalogNodeDto.CatalogNode[0].CatalogNodeId);
                            }
                        }

                        CatalogEntryDto catalogEntriesDto = CatalogContext.Current.GetCatalogEntriesDto(catalogId, catalogNodeDto.CatalogNode[0].CatalogNodeId);
                        if (catalogEntriesDto.CatalogEntry.Count > 0)
                        {
                            for (int i = 0; i < catalogEntriesDto.CatalogEntry.Count; i++)
                            {
                                MoveNodeEntry(catalogId, catalogNodeDto.CatalogNode[0].CatalogNodeId, catalogEntriesDto.CatalogEntry[i].CatalogEntryId, targetCatalogId, catalogNodeDto.CatalogNode[0].CatalogNodeId);
                            }
                        }
                    }
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Saves the changes.
        /// </summary>
        /// <param name="context">The context.</param>
        public void SaveChanges(IDictionary context)
        {
            CatalogNodeDto dto = (CatalogNodeDto)context["CatalogNodeDto"];

            dto.CatalogNode.RowChanged += new DataRowChangeEventHandler(CatalogNode_RowChanged);
            //MetaDataTab.SaveChanges(context);
        }
Exemple #8
0
 /// <summary>
 /// Raises the node updating event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The <see cref="Mediachase.Commerce.Catalog.Events.NodeEventArgs"/> instance containing the event data.</param>
 public void RaiseNodeUpdatingEvent(CatalogNodeDto sender, NodeEventArgs args)
 {
     if (NodeUpdating != null)
     {
         NodeUpdating(sender, args);
     }
 }
        public ActionResult <List <CatalogNodeDto> > GetFirstTwoNestingLevels()
        {
            List <CatalogNodeDto> topLevelCatalogNodes = new List <CatalogNodeDto>();

            foreach (Catalog currTopCatalog in _directoryFacade.GetSubcatalogs(0))
            {
                CatalogNodeDto currTopCatalogNode = new CatalogNodeDto
                {
                    Id    = currTopCatalog.Id,
                    Name  = currTopCatalog.Name,
                    Order = currTopCatalog.OrderInParentCatalog
                };
                topLevelCatalogNodes.Add(currTopCatalogNode);
                foreach (Catalog currSubcatalog in _directoryFacade.GetSubcatalogs(currTopCatalog.Id))
                {
                    CatalogNodeDto currSubcatalogNode = new CatalogNodeDto
                    {
                        Id    = currSubcatalog.Id,
                        Name  = currSubcatalog.Name,
                        Order = currSubcatalog.OrderInParentCatalog
                    };
                    currTopCatalogNode.ChildrenNodes.Add(currSubcatalogNode);
                }
            }
            return(Ok(topLevelCatalogNodes));
        }
Exemple #10
0
        private void WalkCatalogNodes(ICatalogSystem catalogSystem, CatalogNodeDto nodes, CatalogDto.CatalogRow catalog, Dictionary <int, CatalogEntryDto.CatalogEntryRow> catalogEntryRows)
        {
            foreach (CatalogNodeDto.CatalogNodeRow node in nodes.CatalogNode)
            {
                CatalogSearchParameters pars    = new CatalogSearchParameters();
                CatalogSearchOptions    options = new CatalogSearchOptions {
                    CacheResults = false
                };
                pars.CatalogNames.Add(catalog.Name);
                pars.CatalogNodes.Add(node.Code);
                //CatalogEntryDto entries = CatalogContext.Current.FindItemsDto(
                //    pars,
                //    options,
                //    ref count,
                //    new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
                CatalogEntryDto entries = catalogSystem.GetCatalogEntriesDto(catalog.CatalogId, node.CatalogNodeId,
                                                                             new CatalogEntryResponseGroup(
                                                                                 CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo));

                _log.DebugFormat("Entries in Node: {0} (Count: {1})", node.Name, entries.CatalogEntry.Rows.Count);
                foreach (CatalogEntryDto.CatalogEntryRow entry in entries.CatalogEntry)
                {
                    // _log.DebugFormat("{3}: {0} ({1} - {2})", entry.Name, entry.Code, entry.CatalogEntryId, entry.ClassTypeId);
                    if (catalogEntryRows.ContainsKey(entry.CatalogEntryId) == false)
                    {
                        catalogEntryRows.Add(entry.CatalogEntryId, entry);
                    }
                }

                // Get Subnodes
                CatalogNodeDto subNodes = catalogSystem.GetCatalogNodesDto(catalog.CatalogId, node.CatalogNodeId);
                WalkCatalogNodes(catalogSystem, subNodes, catalog, catalogEntryRows);
            }
        }
Exemple #11
0
        public static string GetNodeUrl(string id)
        {
            string url = String.Empty;

            CatalogNodeDto node = CatalogContext.Current.GetCatalogNodeDto(id);

            if (node.CatalogItemSeo.Count > 0)
            {
                foreach (CatalogNodeDto.CatalogItemSeoRow seo in node.CatalogItemSeo.Rows)
                {
                    if (seo.LanguageCode.Equals(CMSContext.Current.LanguageName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        url = "~/" + seo.Uri;
                        break;
                    }
                }
            }

            if (String.IsNullOrEmpty(url))
            {
                return(CMSContext.Current.ResolveUrl(NavigationManager.GetUrl("NodeView", "nc", id)));
            }
            else
            {
                return(CMSContext.Current.ResolveUrl(url));
            }
        }
Exemple #12
0
        public void Search_BrowseEntries()
        {
            ICatalogSystem system = CatalogContext.Current;

            // Get catalog lists
            CatalogDto catalogs = system.GetCatalogDto();

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                string catalogName = catalog.Name;

                // Get Catalog Nodes
                CatalogNodeDto nodes = system.GetCatalogNodesDto(catalogName);
                foreach (CatalogNodeDto.CatalogNodeRow node in nodes.CatalogNode)
                {
                    CatalogSearchParameters pars    = new CatalogSearchParameters();
                    CatalogSearchOptions    options = new CatalogSearchOptions();
                    options.CacheResults = true;

                    pars.CatalogNames.Add(catalogName);
                    pars.CatalogNodes.Add(node.Code);

                    Entries entries = CatalogContext.Current.FindItems(pars, options, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
                }
            }
        }
Exemple #13
0
        public void Search_JoinQuery()
        {
            ICatalogSystem system = CatalogContext.Current;

            // Get catalog lists
            CatalogDto catalogs = system.GetCatalogDto();

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                string catalogName = catalog.Name;

                // Get Catalog Nodes
                CatalogNodeDto nodes = system.GetCatalogNodesDto(catalogName);
                foreach (CatalogNodeDto.CatalogNodeRow node in nodes.CatalogNode)
                {
                    CatalogSearchParameters pars    = new CatalogSearchParameters();
                    CatalogSearchOptions    options = new CatalogSearchOptions();
                    options.CacheResults = true;

                    pars.CatalogNames.Add(catalogName);
                    pars.CatalogNodes.Add(node.Code);
                    pars.JoinType           = "inner join";
                    pars.Language           = "en-us";
                    pars.JoinSourceTable    = "CatalogEntry";
                    pars.JoinTargetQuery    = "(select distinct ObjectId, DisplayName from CatalogEntryEx) CatalogEntryEx";
                    pars.JoinSourceTableKey = "CatalogEntryId";
                    pars.JoinTargetTableKey = "CatalogEntryEx.ObjectId";
                    pars.OrderByClause      = "CatalogEntryEx.DisplayName";

                    Entries entries = CatalogContext.Current.FindItems(pars, options, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
                }
            }
        }
Exemple #14
0
        private void MoveNode(string nodeCode, int newParent)
        {
            CatalogNodeDto catalogNodeDto = CatalogContext.Current.GetCatalogNodeDto(nodeCode, new CatalogNodeResponseGroup(CatalogNodeResponseGroup.ResponseGroup.CatalogNodeFull));

            // Move node to new parent
            _logger.Information($"Move {nodeCode} to new parent ({newParent}).");
            catalogNodeDto.CatalogNode[0].ParentNodeId = newParent;
            CatalogContext.Current.SaveCatalogNode(catalogNodeDto);
        }
Exemple #15
0
        /// <summary>
        /// Loads the fresh node.
        /// </summary>
        /// <returns></returns>
        private CatalogNodeDto LoadFreshNode()
        {
            CatalogNodeDto node = CatalogContext.Current.GetCatalogNodeDto(CatalogNodeId, new CatalogNodeResponseGroup(CatalogNodeResponseGroup.ResponseGroup.CatalogNodeFull));

            // persist in session
            Session[_CatalogNodeDtoString] = node;

            return(node);
        }
Exemple #16
0
        /// <summary>
        /// Binds the form.
        /// </summary>
        private void BindForm()
        {
            List <string>  languageList = new List <string>();
            CatalogDto     catalogDto   = null;
            CatalogNodeDto dto          = null;

            if (CatalogNodeId > 0)
            {
                dto = CatalogContext.Current.GetCatalogNodeDto(CatalogNodeId);

                // Get list of languages
                if (dto.CatalogNode.Count > 0)
                {
                    catalogDto = CatalogContext.Current.GetCatalogDto(dto.CatalogNode[0].CatalogId);
                }
            }
            else
            {
                // Get list of languages
                catalogDto = CatalogContext.Current.GetCatalogDto(ParentCatalogId);
            }

            if (catalogDto.Catalog.Count > 0)
            {
                languageList.Add(catalogDto.Catalog[0].DefaultLanguage);
            }
            if (catalogDto.CatalogLanguage.Count > 0)
            {
                foreach (CatalogDto.CatalogLanguageRow row in catalogDto.CatalogLanguage.Rows)
                {
                    languageList.Add(row.LanguageCode.ToLower());
                }
            }

            // Bind controls
            SeoCtrl.Controls.Clear();

            foreach (string langCode in languageList)
            {
                Control seoControl = LoadControl("../Modules/SeoTab.ascx");
                ((SeoTab)seoControl).LanguageCode = langCode;

                if (dto != null && dto.CatalogItemSeo.Count > 0)
                {
                    CatalogNodeDto.CatalogItemSeoRow[] rows = (CatalogNodeDto.CatalogItemSeoRow[])dto.CatalogItemSeo.Select(String.Format("LanguageCode='{0}'", langCode));
                    if (rows != null && rows.Length > 0)
                    {
                        ((SeoTab)seoControl).Row = rows[0];
                    }
                }

                SeoCtrl.Controls.Add(seoControl);
            }

            SeoCtrl.DataBind();
        }
Exemple #17
0
        /// <summary>
        /// Creates a line item.
        /// Code copied from OrderHelper.cs.
        /// </summary>
        /// <param name="random">A Random object seeded from the start of test method.</param>
        /// <returns></returns>
        private LineItem createLineItem(Random random, Guid shippingMethod, String shippingMethodName)
        {
            CatalogDto catalogs = CatalogContext.Current.GetCatalogDto();

            CatalogEntryDto.CatalogEntryRow entry = null;
            bool   found       = false;
            string catalogName = String.Empty;

            int seed = 0;

            while (!found)
            {
                seed = random.Next(catalogs.Catalog.Count - 1);
                CatalogDto.CatalogRow catalog = catalogs.Catalog[seed];
                catalogName = catalog.Name;

                // Get Catalog Nodes
                CatalogNodeDto nodes = CatalogContext.Current.GetCatalogNodesDto(catalogName);

                // Pick random node
                if (nodes.CatalogNode.Count > 0)
                {
                    seed = random.Next(nodes.CatalogNode.Count - 1);

                    CatalogNodeDto.CatalogNodeRow node = nodes.CatalogNode[seed];

                    CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntriesDto(catalogName, node.CatalogNodeId);

                    if (entryDto.CatalogEntry.Count > 0)
                    {
                        seed  = random.Next(entryDto.CatalogEntry.Count - 1);
                        entry = entryDto.CatalogEntry[seed];
                        if (entry.IsActive)
                        {
                            found = true;
                        }
                    }
                }
            }

            LineItem lineItem = new LineItem();

            lineItem.DisplayName        = entry.Name;
            lineItem.CatalogEntryId     = entry.Code;
            lineItem.ShippingMethodId   = shippingMethod;
            lineItem.ShippingMethodName = shippingMethodName;
            lineItem.ShippingAddressId  = "Home";
            // Choose a random quantity for chosen product.
            int quantity = random.Next(1, 7);

            lineItem.Quantity    = quantity;
            lineItem.CatalogNode = catalogName;
            lineItem.Discounts.Add(OrderHelper.CreateLineItemDiscount());
            return(lineItem);
        }
Exemple #18
0
    /// <summary>
    /// Creates the child controls tree.
    /// </summary>
    private void CreateChildControlsTree()
    {
        if (!String.IsNullOrEmpty(Code))
        {
            System.Web.UI.Control ctrl = null;

            string id = "Template" + this.ID;
            ctrl = CategoryInfoHolder.FindControl(id);
            if (ctrl == null)
            {
                CatalogNodeDto dto = CatalogContext.Current.GetCatalogNodeDto(Code);

                if (dto.CatalogNode.Count == 0)
                {
                    throw new System.NullReferenceException(String.Format("CatalogNode \"{0}\" not found.", Code));
                }

                string templateUrl = GetTemplateUrl(dto.CatalogNode[0].TemplateName);

                if (String.IsNullOrEmpty(templateUrl))
                {
                    throw new System.NullReferenceException(String.Format("CatalogNode \"{0}\" does not have display template specified.", Code));
                }

                try
                {
                    ctrl = this.LoadControl(templateUrl.ToString());

                    if (ctrl is IContextUserControl)
                    {
                        IDictionary dic = new ListDictionary();
                        dic.Add("Code", Code);
                        dic.Add("CatalogName", CatalogName);
                        ((IContextUserControl)ctrl).LoadContext(dic);
                    }
                }
                catch (HttpException ex)
                {
                    if (ex.GetHttpCode() == 404)
                    {
                        throw new System.IO.FileNotFoundException("Template not found", ex);
                    }
                    else
                    {
                        throw;
                    }
                }

                this.CategoryInfoHolder.Controls.Add(ctrl);
                //Profile.LastCatalogPageUrl = CMSContext.Current.CurrentUrl;
                Session["LastCatalogPageUrl"] = CMSContext.Current.CurrentUrl;
            }
        }
    }
Exemple #19
0
        /// <summary>
        /// Creates the line item.
        /// </summary>
        /// <returns></returns>
        public static LineItem CreateLineItem()
        {
            CatalogDto catalogs = CatalogContext.Current.GetCatalogDto();

            CatalogEntryDto.CatalogEntryRow entry = null;
            bool   found       = false;
            string catalogName = String.Empty;
            Random random      = new Random();

            int seed = 0;

            while (!found)
            {
                seed = random.Next(catalogs.Catalog.Count - 1);
                CatalogDto.CatalogRow catalog = catalogs.Catalog[seed];
                catalogName = catalog.Name;

                // Get Catalog Nodes
                CatalogNodeDto nodes = CatalogContext.Current.GetCatalogNodesDto(catalogName);

                // Pick random node
                if (nodes.CatalogNode.Count > 0)
                {
                    seed = random.Next(nodes.CatalogNode.Count - 1);

                    CatalogNodeDto.CatalogNodeRow node = nodes.CatalogNode[seed];

                    CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntriesDto(catalogName, node.CatalogNodeId);

                    if (entryDto.CatalogEntry.Count > 0)
                    {
                        seed  = random.Next(entryDto.CatalogEntry.Count - 1);
                        entry = entryDto.CatalogEntry[seed];
                        if (entry.IsActive)
                        {
                            found = true;
                        }
                    }
                }
            }

            LineItem lineItem = new LineItem();

            lineItem.DisplayName        = entry.Name;
            lineItem.CatalogEntryId     = entry.Code;
            lineItem.ShippingMethodId   = new Guid("17995798-a2cc-43ad-81e8-bb932f6827e4");
            lineItem.ShippingMethodName = "Online Download";
            lineItem.ShippingAddressId  = "Home";
            lineItem.ListPrice          = 100;
            lineItem.Quantity           = 2;
            lineItem.CatalogNode        = catalogName;
            lineItem.Discounts.Add(CreateLineItemDiscount());
            return(lineItem);
        }
Exemple #20
0
        public void MoveNodeToRootIfNeeded(string catalogNodeId)
        {
            CatalogNodeDto nodeDto = CatalogContext.Current.GetCatalogNodeDto(catalogNodeId);

            if (nodeDto.CatalogNode.Count > 0)
            {
                if (nodeDto.CatalogNode[0].ParentNodeId != 0)
                {
                    MoveNode(nodeDto.CatalogNode[0].Code, 0);
                }
            }
        }
Exemple #21
0
        /// <summary>
        /// Creates the catalog node.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <returns></returns>
        internal static CatalogNode CreateCatalogNode(CatalogNodeDto dto)
        {
            CatalogNode node = new CatalogNode();

            foreach (CatalogNodeDto.CatalogNodeRow row in dto.CatalogNode)
            {
                node.Name = row.Name;
                //node.NodeId = row.CatalogNodeId;
            }

            return(node);
        }
Exemple #22
0
        /// <summary>
        /// Returns an instance of a class that implements the <see cref="T:System.Web.IHttpHandler"></see> interface.
        /// </summary>
        /// <param name="context">An instance of the <see cref="T:System.Web.HttpContext"></see> class that provides references to intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        /// <param name="requestType">The HTTP data transfer method (GET or POST) that the client uses.</param>
        /// <param name="url">The <see cref="P:System.Web.HttpRequest.RawUrl"></see> of the requested resource.</param>
        /// <param name="pathTranslated">The <see cref="P:System.Web.HttpRequest.PhysicalApplicationPath"></see> to the requested resource.</param>
        /// <returns>
        /// A new <see cref="T:System.Web.IHttpHandler"></see> object that processes the request.
        /// </returns>
        public IHttpHandler GetHandler(
            HttpContext context, string requestType, string url, string pathTranslated)
        {
            string newUrl = url;

            if (CMSContext.Current.AppPath.Length != 1)
            {
                newUrl = newUrl.Substring(CMSContext.Current.AppPath.Length);
            }

            if (newUrl.StartsWith("/"))
            {
                newUrl = newUrl.Substring(1);
            }

            CatalogEntryDto entry = CatalogContext.Current.GetCatalogEntryByUriDto(newUrl, CMSContext.Current.LanguageName);

            if (entry.CatalogItemSeo.Count > 0)
            {
                SaveOriginalUrl(context, url);
                Uri    rawUrl = BuildUri(NavigationManager.GetUrl("EntryView", "ec", entry.CatalogEntry[0].Code), HttpContext.Current.Request.IsSecureConnection);
                string filePath;
                string sendToUrlLessQString;
                string sendToUrl = rawUrl.PathAndQuery;
                RewriteUrl(context, sendToUrl, out sendToUrlLessQString, out filePath);

                return(new CmsUriHandler().GetHandler(context, requestType, sendToUrlLessQString, filePath));
            }

            CatalogNodeDto node = CatalogContext.Current.GetCatalogNodeDto(newUrl, CMSContext.Current.LanguageName);

            if (node.CatalogItemSeo.Count > 0)
            {
                SaveOriginalUrl(context, url);
                Uri    rawUrl = BuildUri(NavigationManager.GetUrl("NodeView", "nc", node.CatalogNode[0].Code), HttpContext.Current.Request.IsSecureConnection);
                string filePath;
                string sendToUrlLessQString;
                string sendToUrl = rawUrl.PathAndQuery;
                RewriteUrl(context, sendToUrl, out sendToUrlLessQString, out filePath);

                return(new CmsUriHandler().GetHandler(context, requestType, sendToUrlLessQString, filePath));
            }

            if (!string.IsNullOrEmpty(pathTranslated))
            {
                return(new CmsUriHandler().GetHandler(context, requestType, url, pathTranslated));
                //return PageParser.GetCompiledPageInstance(url, pathTranslated, context);
            }
            else
            {
                return(new CmsUriHandler().GetHandler(context, requestType, url, pathTranslated));
            }
        }
Exemple #23
0
        /// <summary>
        /// Checks the node code.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.Web.UI.WebControls.ServerValidateEventArgs"/> instance containing the event data.</param>
        protected void NodeCodeCheck(object sender, ServerValidateEventArgs args)
        {
            CatalogNodeDto dto = CatalogContext.Current.GetCatalogNodeDto(CodeText.Text);

            if (dto.CatalogNode.Count > 0 && dto.CatalogNode[0].CatalogNodeId != CatalogNodeId)
            {
                args.IsValid = false;
                return;
            }

            args.IsValid = true;
        }
Exemple #24
0
        /// <summary>
        /// Loads the context.
        /// </summary>
        private void LoadContext()
        {
            CatalogNodeDto node = null;

            if (CatalogNodeId > 0)
            {
                if (!this.IsPostBack && (!this.Request.QueryString.ToString().Contains("Callback=yes"))) // load fresh on initial load
                {
                    node = LoadFreshNode();

                    if (node == null)
                    {
                        node = new CatalogNodeDto();
                    }
                }
                else // load from session
                {
                    node = (CatalogNodeDto)Session[_CatalogNodeDtoString];

                    if (node == null)
                    {
                        node = LoadFreshNode();
                    }
                }
            }
            else
            {
                node = (CatalogNodeDto)Session[_CatalogNodeDtoString];

                // create new dto objects if they are null
                if (node == null)
                {
                    node = new CatalogNodeDto();
                }
            }


            if (CatalogNodeId > 0 && node.CatalogNode.Count == 0)
            {
                Response.Redirect("ContentFrame.aspx?_a=Catalog&_v=Catalog-List");
            }

            // Put a dictionary key that can be used by other tabs
            IDictionary dic = new ListDictionary();

            dic.Add(_CatalogNodeDtoString, node);

            // Call tabs load context
            ViewControl.LoadContext(dic);
        }
Exemple #25
0
        protected void WalkCatalog(ICatalogSystem catalogSystem, Dictionary <int, CatalogEntryDto.CatalogEntryRow> catalogEntryRows)
        {
            // Get all catalogs
            CatalogDto catalogs = catalogSystem.GetCatalogDto();

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                // string catalogName = catalog.Name;
                int catalogId = catalog.CatalogId;
                // Get Catalog Nodes
                CatalogNodeDto nodes = catalogSystem.GetCatalogNodesDto(catalogId);
                WalkCatalogNodes(catalogSystem, nodes, catalog, catalogEntryRows);
            }
        }
Exemple #26
0
        /// <summary>
        /// Binds the form.
        /// </summary>
        private void BindForm()
        {
            CatalogDto catalogDto = null;

            if (MetaClassId > 0)
            {
                MetaDataTab.MetaClassId = MetaClassId;
                catalogDto = CatalogContext.Current.GetCatalogDto(ParentCatalogId);
            }
            else if (MetaClassId == 0 && CatalogNodeId == 0 && Session["CatalogNode-MetaClassId"] != null)
            {
                if (!String.IsNullOrEmpty(Session["CatalogNode-MetaClassId"].ToString()))
                {
                    MetaDataTab.MetaClassId = Int32.Parse(Session["CatalogNode-MetaClassId"].ToString());
                    catalogDto = CatalogContext.Current.GetCatalogDto(ParentCatalogId);
                }
            }
            else if (CatalogNodeId > 0)
            {
                MetaDataTab.ObjectId = CatalogNodeId;
                CatalogNodeDto dto = CatalogContext.Current.GetCatalogNodeDto(CatalogNodeId);
                if (dto.CatalogNode.Count > 0)
                {
                    catalogDto = CatalogContext.Current.GetCatalogDto(dto.CatalogNode[0].CatalogId);
                    MetaDataTab.MetaClassId = dto.CatalogNode[0].MetaClassId;
                }
            }

            if (HttpContext.Current.Items["CatalogNode-MetaClassId"] != null)
            {
                MetaDataTab.MetaClassId = Int32.Parse(HttpContext.Current.Items["CatalogNode-MetaClassId"].ToString());
            }

            if (catalogDto != null)
            {
                List <string> list = new List <string>();
                list.Add(catalogDto.Catalog[0].DefaultLanguage);
                if (catalogDto.CatalogLanguage.Count > 0)
                {
                    foreach (CatalogDto.CatalogLanguageRow row in catalogDto.CatalogLanguage.Rows)
                    {
                        list.Add(row.LanguageCode);
                    }

                    MetaDataTab.Languages = list.ToArray();
                }
                MetaDataTab.DataBind();
            }
        }
Exemple #27
0
        public void CatalogSystem_UnitTest_BrowseEntries()
        {
            ICatalogSystem system = CatalogContext.Current;

            // Get catalog lists
            CatalogDto catalogs = system.GetCatalogDto();

            // Number of entries in CatalogEntry table
            int entryCount = 0;

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                string catalogName = catalog.Name;

                // Get Catalog Nodes
                CatalogNodeDto nodes = system.GetCatalogNodesDto(catalogName);
                foreach (CatalogNodeDto.CatalogNodeRow node in nodes.CatalogNode)
                {
                    CatalogSearchParameters pars    = new CatalogSearchParameters();
                    CatalogSearchOptions    options = new CatalogSearchOptions();
                    options.CacheResults = true;

                    pars.Language = "en-us";

                    pars.CatalogNames.Add(catalogName);
                    pars.CatalogNodes.Add(node.Code);

                    // Test does not seem to be working: entries are mostly returning empty.
                    Entries entries = CatalogContext.Current.FindItems(pars, options, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));

                    try
                    {
                        foreach (Entry entry in entries.Entry)
                        {
                            // Something to do? Just looking at entries
                            entryCount++;
                        }
                    }
                    catch (Exception e)
                    {
                        Assert.IsFalse(new NullReferenceException().Equals(e));
                    }
                }
            }
            // As of testing 4/19/09, entryCount incremented 22 times (there are over 1300 entries in the table CatalogEntry)
            Console.WriteLine("Number of entries browsed: {0:d}", entryCount);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemple #28
0
        /// <summary>
        /// Loads the nodes.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        internal static CatalogNodes LoadNodes(CatalogNodeDto dto, CatalogNode parent, bool recursive, CatalogNodeResponseGroup responseGroup)
        {
            List <CatalogNode> nodes = new List <CatalogNode>();

            foreach (CatalogNodeDto.CatalogNodeRow childRow in dto.CatalogNode)
            {
                CatalogNode childNode = LoadNode(childRow, recursive, responseGroup);
                childNode.ParentNode = parent;
                nodes.Add(childNode);
            }

            CatalogNodes n = new CatalogNodes();

            n.CatalogNode = nodes.ToArray();
            return(n);
        }
Exemple #29
0
        /// <summary>
        /// Saves the changes.
        /// </summary>
        /// <param name="context">The context.</param>
        public void SaveChanges(IDictionary context)
        {
            CatalogNodeDto dto = (CatalogNodeDto)context["CatalogNodeDto"];

            CatalogNodeDto.CatalogNodeRow row = null;

            if (dto.CatalogNode == null || dto.CatalogNode.Count == 0)
            {
                row = dto.CatalogNode.NewCatalogNodeRow();
                row.ApplicationId = CatalogConfiguration.Instance.ApplicationId;
            }
            else
            {
                row = dto.CatalogNode[0];
                if (row.MetaClassId != Int32.Parse(MetaClassList.SelectedValue))
                {
                    MetaObject.Delete(CatalogContext.MetaDataContext, row.CatalogNodeId, row.MetaClassId);
                }
            }

            row.Name      = Name.Text;
            row.StartDate = AvailableFrom.Value.ToUniversalTime();
            row.EndDate   = ExpiresOn.Value.ToUniversalTime();
            row.Code      = CodeText.Text;
            row.SortOrder = Int32.Parse(SortOrder.Text);
            row.IsActive  = IsCatalogNodeActive.IsSelected;

            if (ParentCatalogId > 0)
            {
                row.CatalogId = ParentCatalogId;

                if ((ParentCatalogNodeId > 0 && ParentCatalogNodeId != row.CatalogNodeId) || ParentCatalogNodeId == 0)
                {
                    row.ParentNodeId = ParentCatalogNodeId;
                }
            }

            row.TemplateName = DisplayTemplate.SelectedValue;
            row.MetaClassId  = Int32.Parse(MetaClassList.SelectedValue);

            if (row.RowState == DataRowState.Detached)
            {
                dto.CatalogNode.Rows.Add(row);
            }

            dto.CatalogNode.RowChanged += new DataRowChangeEventHandler(CatalogNode_RowChanged);
        }
Exemple #30
0
        /// <summary>
        /// Deletes the catalog node.
        /// </summary>
        /// <param name="catalogNodeId">The catalog node id.</param>
        /// <param name="catalogId">The catalog id.</param>
        internal static void DeleteCatalogNode(int catalogNodeId, int catalogId)
        {
            CatalogNodeDto     catalogNodeDto     = GetCatalogNodesDto(catalogId, new CatalogNodeResponseGroup(CatalogNodeResponseGroup.ResponseGroup.CatalogNodeFull));
            CatalogRelationDto catalogRelationDto = CatalogRelationManager.GetCatalogRelationDto(0, 0, 0, String.Empty, new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.CatalogNode | CatalogRelationResponseGroup.ResponseGroup.NodeEntry));

            DeleteNodeRecursive(catalogNodeId, catalogId, ref catalogNodeDto, ref catalogRelationDto);

            if (catalogRelationDto.HasChanges())
            {
                CatalogRelationManager.SaveCatalogRelation(catalogRelationDto);
            }

            if (catalogNodeDto.HasChanges())
            {
                SaveCatalogNode(catalogNodeDto);
            }
        }