Exemple #1
0
        /// <summary>
        /// Searches the nodes.
        /// </summary>
        /// <param name="searchGuid">The search GUID.</param>
        /// <returns></returns>
        public int SearchNodes(Guid searchGuid)
        {
            DataCommand cmd = CatalogDataHelper.CreateDataCommand();

            cmd.CommandText = String.Format("ecf_CatalogNodeSearch");
            cmd.Parameters  = new DataParameters();
            cmd.Parameters.Add(new DataParameter("ApplicationId", CatalogConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier));
            cmd.Parameters.Add(new DataParameter("SearchSetId", searchGuid, DataParameterType.UniqueIdentifier));
            cmd.Parameters.Add(new DataParameter("Language", SearchParameters.Language, DataParameterType.NVarChar, 50));
            cmd.Parameters.Add(new DataParameter("Catalogs", CommerceHelper.ConvertToString(SearchParameters.CatalogNames, ","), DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("CatalogNodes", CommerceHelper.ConvertToString(SearchParameters.CatalogNodes, ","), DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("SQLClause", SearchParameters.SqlWhereClause, DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("MetaSQLClause", SearchParameters.SqlMetaWhereClause, DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("FTSPhrase", SearchParameters.FreeTextSearchPhrase, DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("AdvancedFTSPhrase", SearchParameters.AdvancedFreeTextSearchPhrase, DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("OrderBy", SearchParameters.OrderByClause, DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("Namespace", SearchOptions.Namespace, DataParameterType.NVarChar, 1024));
            cmd.Parameters.Add(new DataParameter("Classes", CommerceHelper.ConvertToString(SearchOptions.Classes, ","), DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("StartingRec", SearchOptions.StartingRecord, DataParameterType.Int));
            cmd.Parameters.Add(new DataParameter("NumRecords", SearchOptions.RecordsToRetrieve, DataParameterType.Int));
            DataParameter param = new DataParameter("RecordCount", DataParameterType.Int);

            param.Direction = ParameterDirection.InputOutput;
            param.Value     = 0;
            cmd.Parameters.Add(param);

            DataService.ExecuteNonExec(cmd);

            return(Int32.Parse(cmd.Parameters["RecordCount"].Value.ToString()));
        }
Exemple #2
0
        protected override IEnumerable <ScriptReference> GetScriptReferences()
        {
            ScriptReference reference = new ScriptReference();

            reference.Path = CommerceHelper.GetAbsolutePath("~/Apps/Core/Layout/Scripts/WsLayoutExtender.js");

            return(new ScriptReference[] { reference });
        }
 protected void rptPurchases_OnItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
     {
         ProductPurchase dataItem = (ProductPurchase)e.Item.DataItem;
         Label           label    = e.Item.FindControl("lblTitle") as Label;
         label.Text = CommerceHelper.PurchasedProductTitle(dataItem);
     }
 }
Exemple #4
0
        /// <summary>
        /// During page load, the required JS files are loaded
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Page.IsPostBack)
            {
            }
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "NWTD_jquery_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/jquery-1.3.2.min.js"));
            string scriptText = "NWTD.CartList.controlIDs.push('" + this.udpCartViewer.UniqueID + "')";

            Page.ClientScript.RegisterClientScriptInclude("NWTD_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/NWTD.js"));
            Page.ClientScript.RegisterClientScriptInclude("CartList_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/CartList.js"));
            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "CartPage", scriptText, true);
        }
Exemple #5
0
        /// <summary>
        /// Sets the bind grid flag.
        /// </summary>
        /// <param name="gridId">The grid id.</param>
        /// <param name="value">if set to <c>true</c> [value].</param>
        public static void SetBindGridFlag(string gridId, bool value)
        {
            string key = String.Concat(NeedToBindGridKey, "_", gridId);

            if (value)
            {
                CommerceHelper.SetContextParameter(key, value);
            }
            else // remove from context
            {
                CommerceHelper.RemoveContextParameter(key);
            }
        }
 protected void ResponseSubmitButton_Click(object sender, EventArgs e)
 {
     this.ResponseEmailRequired1.Validate();
     if (this.Page.IsValid)
     {
         if (CommerceHelper.SendAdResponse(this.ProductID, base.Server.HtmlEncode(this.ResponseContactNameTextBox.Text), base.Server.HtmlEncode(this.ResponseContactEmailTextBox.Text), base.Server.HtmlEncode(this.ResponseCommentsTextBox.Text)))
         {
             this.SetActivePanel(this.EmailSentPanel);
         }
         else
         {
             this.SetActivePanel(this.EmailNotSentPanel);
         }
     }
 }
 protected void EmailSubmitButton_Click(object sender, EventArgs e)
 {
     this.EmailSenderAddressTextBoxValidator1.Validate();
     this.EmailRecipientAddressTextBoxValidator1.Validate();
     if (this.Page.IsValid)
     {
         if (CommerceHelper.SendTellFriendEmail(this.ProductID, base.Server.HtmlEncode(this.EmailSenderNameTextBox.Text), base.Server.HtmlEncode(this.EmailSenderAddressTextBox.Text), base.Server.HtmlEncode(this.EmailRecipientAddressTextBox.Text), base.Server.HtmlEncode(this.EmailSubjectTextBox.Text), base.Server.HtmlEncode(this.EmailMessageTextBox.Text)))
         {
             this.SetActivePanel(this.EmailSentPanel);
         }
         else
         {
             this.SetActivePanel(this.EmailNotSentPanel);
         }
     }
 }
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(FileSizeArgument) || String.IsNullOrEmpty(FileSizeArgument))
            {
                return;
            }

            GridServerTemplateContainer container = this.Parent as GridServerTemplateContainer;

            if (container != null)
            {
                object fileSize = container.DataItem[FileSizeArgument];
                if (fileSize != null)
                {
                    long size = 0;
                    if (long.TryParse(fileSize.ToString(), out size))
                    {
                        SizeText.Text = CommerceHelper.ByteSizeToStr(size);
                    }
                }
            }
        }
        private DataTable GenerateTemplatesDataSource()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Id", typeof(string)));
            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Description", typeof(string)));
            dt.Columns.Add(new DataColumn("ImageUrl", typeof(string)));

            foreach (WorkspaceTemplateInfo wti in WorkspaceTemplateFactory.GetTemplateInfos())
            {
                DataRow row = dt.NewRow();
                row["Id"]          = wti.Uid;
                row["Title"]       = UtilHelper.GetResFileString(wti.Title);
                row["Description"] = UtilHelper.GetResFileString(wti.Description);
                row["ImageUrl"]    = CommerceHelper.GetAbsolutePath(wti.ImageUrl);

                dt.Rows.Add(row);
            }

            return(dt);
        }
Exemple #10
0
        /// <summary>
        /// During page load, various scripts are loaded, and the last column of the search results grid for Nevada is shown if the current user is from Nevada
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            NWTD.Web.UI.ClientScript.AddRequiredScripts(this.Page);
            OakTree.Web.UI.ControlHelper.RegisterControlInClientScript(this.Page.ClientScript, this, "SearchResults", string.Empty);

            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "JqueryModal_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/jquery.modal.js"));
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "JqueryValidate_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/jquery.validate.js"));

            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "SearchResults_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/SearchResults.js"));

            if (this.Page.Request.QueryString.Count == 0)
            {
                this.pnlSearchResults.Visible = false;
            }

            //do a few special things if the user is from nevada
            this.gvSearchResults.Columns[this.gvSearchResults.Columns.Count - 1].Visible = this.IsNevadaUser;
            if (this.IsNevadaUser)
            {
                this.pnlResultsWrapper.CssClass = "results-wrapper-nv";
            }

            if (Request.IsAuthenticated)
            {
                global::NWTD.Profile.EnsureCustomerCart();
            }

            //set up the stuff in the cart selector modal
            if (global::NWTD.Orders.Cart.Reminder)
            {
                this.pnlSelectCart.Visible = true;
                List <Mediachase.Commerce.Orders.Cart> carts = global::NWTD.Orders.Cart.CurrentCustomerCarts;

                this.ddlCarts.DataSource = carts;
                this.ddlCarts.DataBind();

                foreach (ListItem item in this.ddlCarts.Items)
                {
                    if (item.Value.Equals(global::NWTD.Profile.ActiveCart))
                    {
                        item.Selected = true;
                        break;
                    }
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// During page load, the required JS files are loaded
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            NWTD.Web.UI.ClientScript.AddRequiredScripts(this.Page);
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "JqueryModal_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/jquery.modal.js"));
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "ManageCarts_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/ManageCarts.js"));

            OakTree.Web.UI.ControlHelper.RegisterControlInClientScript(Page.ClientScript, this, "ManageCarts", "{updatePanelID:'" + this.udpUserCarts.ClientID + "', cartGridID:'" + this.gvUserCarts.ClientID + "'}");
        }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, System.EventArgs e)
    {
        Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "CompareProducts_js", CommerceHelper.GetAbsolutePath("/Scripts/CompareProducts.js"));
        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "CompareViewPageUrl", String.Format("CSCompareProducts.CompareViewPageUrl = \"{0}\";", CMSContext.Current.ResolveUrl("~/compare.aspx")), true);

        //if (!IsPostBack)
        {
            if (!String.IsNullOrEmpty(CurrentMetaClassName) && ProductsToCompare != null)
            {
                hfCurrentComparisonGroup.Value = CurrentMetaClassName;
                BindData();
                pnlCompareProducts.Visible = true;
                ClearCompareButton.Text    = RM.GetString("COMPAREPRODUCTSMODULE_CLEAR");
            }
            else
            {
                pnlCompareProducts.Visible = false;
            }
        }
    }
Exemple #13
0
        /// <summary>
        /// Binds the toolbar.
        /// </summary>
        public void BindToolbar()
        {
            LanguageBar.Rows.Clear();
            TableRow newRow1 = new TableRow();
            TableRow newRow2 = new TableRow();


            using (IDataReader reader = mc.Language.GetAllLanguages())
            {
                while (reader.Read())
                {
                    TableCell newCell1 = new TableCell();
                    TableCell newCell2 = new TableCell();
                    newCell1.Text    = reader["LangId"].ToString();
                    newCell1.Visible = false;
                    newRow1.Cells.Add(newCell1);
                    ImageButton imgBtn  = new ImageButton();
                    CultureInfo culture = CultureInfo.CreateSpecificCulture(reader["LangName"].ToString());
                    if (DisableUnavaliable)
                    {
                        if (AvaliableLanguage != null)
                        {
                            if (AvaliableLanguage.Contains(reader["LangId"]))
                            {
                                imgBtn.ImageUrl = CommonHelper.GetFlagIcon(culture);//CommerceHelper.GetAbsolutePath("~/images/flags/" + reader["LangName"].ToString().Substring(0, 2) + ".gif");
                            }
                            else
                            {
                                imgBtn.ImageUrl = CommerceHelper.GetAbsolutePath("~/images/flags/" + reader["LangName"].ToString().Substring(0, 2) + "_gray.gif");
                            }
                        }
                        else
                        {
                            imgBtn.ImageUrl = CommerceHelper.GetAbsolutePath("~/images/flags/" + reader["LangName"].ToString().Substring(0, 2) + "_gray.gif");
                        }

                        //imgBtn.ImageUrl = CommonHelper.GetFlagIcon(culture);
                    }
                    else
                    {
                        //imgBtn.ImageUrl = CommonHelper.GetFlagIcon(culture);
                        imgBtn.ImageUrl = CommonHelper.GetFlagIcon(CultureInfo.CreateSpecificCulture(reader["LangName"].ToString())); // CommerceHelper.GetAbsolutePath("~/images/flags/" + reader["LangName"].ToString().Substring(0, 2) + ".gif");
                    }

                    imgBtn.AlternateText = culture.DisplayName;

                    imgBtn.Height = 12;
                    imgBtn.Width  = 18;

                    if ((int)reader["LangId"] == CurrentLanguageId)
                    {
                        imgBtn.BorderWidth = 2;
                        imgBtn.BorderColor = System.Drawing.Color.Gold;
                    }
                    else
                    {
                        imgBtn.BorderWidth = 1;
                        imgBtn.BorderColor = System.Drawing.Color.Black;
                    }

                    imgBtn.CommandArgument  = reader["LangId"].ToString();
                    imgBtn.Click           += new ImageClickEventHandler(imgBtn_Click);
                    imgBtn.CausesValidation = false;
                    newCell2.Controls.Add(imgBtn);
                    newRow2.Cells.Add(newCell2);
                }

                reader.Close();
            }
            LanguageBar.Rows.Add(newRow1);
            LanguageBar.Rows.Add(newRow2);
            //HighlightCurrentLanguage();
        }
Exemple #14
0
        /// <summary>
        /// Gets the bind grid flag.
        /// </summary>
        /// <param name="gridId">The grid id.</param>
        /// <returns></returns>
        public static bool GetBindGridFlag(string gridId)
        {
            string key = String.Concat(NeedToBindGridKey, "_", gridId);

            return(CommerceHelper.GetContextParameter <bool>(key, false));
        }
Exemple #15
0
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, System.EventArgs e)
 {
     DataBind();
     Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "CompareProducts_js", CommerceHelper.GetAbsolutePath("/Scripts/CompareProducts.js"));
     Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "CompareViewPageUrl", String.Format("CSCompareProducts.CompareViewPageUrl = \"{0}\";", CMSContext.Current.ResolveUrl("~/compare.aspx")), true);
 }
Exemple #16
0
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "checkout_js", CommerceHelper.GetAbsolutePath("Scripts/checkout.js"));
     Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "jquery_js", CommerceHelper.GetAbsolutePath("Scripts/jquery.js"));
     Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "thickbox_js", CommerceHelper.GetAbsolutePath("Scripts/thickbox.js"));
     Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "thickbox_js_imgLoader", String.Format("var tb_pathToImage = '{0}';", CommerceHelper.GetAbsolutePath("App_Themes/Everything/images/loading_rss.gif")), true);
 }
Exemple #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            NWTD.Web.UI.ClientScript.AddRequiredScripts(this.Page);
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "Search_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/Search.js"));

            FacetGroup[] facets = SearchFilterHelper.Current.GetFacets(false, new TimeSpan());


            foreach (FacetGroup facetgroup in facets)
            {
                switch (facetgroup.FieldName)
                {
                case "Grade":
                    ddlGrades.DataSource = facetgroup.Facets;
                    ddlGrades.DataBind();
                    ddlGrades.Items.Insert(0, new ListItem(facetgroup.Name, string.Empty));
                    break;

                case "Publisher":
                    ddlPublisher.DataSource = facetgroup.Facets;
                    ddlPublisher.DataBind();
                    ddlPublisher.Items.Insert(0, new ListItem(facetgroup.Name, string.Empty));
                    break;

                case "Year":
                    ddlYear.DataSource = facetgroup.Facets;
                    ddlYear.DataBind();
                    ddlYear.Items.Insert(0, new ListItem(facetgroup.Name, string.Empty));
                    break;

                case "Subject":
                    ddlSubject.DataSource = facetgroup.Facets;
                    ddlSubject.DataBind();
                    ddlSubject.Items.Insert(0, new ListItem(facetgroup.Name, string.Empty));
                    break;

                case "Type":
                    ddlType.DataSource = facetgroup.Facets;
                    ddlType.DataBind();
                    ddlType.Items.Insert(0, new ListItem(facetgroup.Name, string.Empty));
                    break;
                }
            }
        }
Exemple #18
0
        protected override int CreateSystemRow(FillDataMode Mode, int RowIndex, params object[] Item)
        {
            int    i = 0;
            object objSysRowAction = Item[i++];
            //CatalogNode
            object objCode         = Item[i++];
            object objParentCode   = Item[i++];
            object objName         = Item[i++];
            object objStartDate    = Item[i++];
            object objEndDate      = Item[i++];
            object objTemplateName = Item[i++];
            object objIsActive     = Item[i++];
            object objSortOrder    = Item[i++];
            //SEO
            object objSeoTitle       = Item[i++];
            object objSeoUrl         = Item[i++];
            object objSeoDescription = Item[i++];
            object objSeoKeywords    = Item[i++];

            CatalogNodeDto.CatalogNodeRow nodeRow = null;

            try
            {
                RowAction sysRowAction = RowAction.Default;

                if (objSysRowAction != null)
                {
                    sysRowAction = GetRowActionEnum((string)objSysRowAction);
                }

                string Code;
                if (!String.IsNullOrEmpty((string)objCode))
                {
                    Code = (string)objCode;
                }
                else
                {
                    throw new AbsentValue("Code");
                }

                int parentNodeId = 0;
                if (objParentCode != null)
                {
                    if (!objParentCode.Equals(String.Empty))
                    {
                        CatalogNodeDto parentNodeDto = CatalogNodeManager.GetCatalogNodeDto((string)objParentCode, new CatalogNodeResponseGroup(CatalogNodeResponseGroup.ResponseGroup.CatalogNodeInfo));
                        if (parentNodeDto.CatalogNode.Count > 0)
                        {
                            parentNodeId = parentNodeDto.CatalogNode[0].CatalogNodeId;
                        }
                    }
                }

                bool           bIsNew         = false;
                CatalogNodeDto catalogNodeDto = CatalogNodeManager.GetCatalogNodeDto(Code, new CatalogNodeResponseGroup(CatalogNodeResponseGroup.ResponseGroup.CatalogNodeFull));
                if (catalogNodeDto.CatalogNode.Count > 0)
                {
                    if (sysRowAction == RowAction.Insert)
                    {
                        throw new MDPImportException(String.Format("The Catalog Node with Code '{0}' already exists.", Code));
                    }

                    nodeRow = catalogNodeDto.CatalogNode[0];

                    if (sysRowAction == RowAction.Delete)
                    {
                        CatalogContext.Current.DeleteCatalogNode(nodeRow.CatalogNodeId, nodeRow.CatalogId);
                        return(0);
                    }

                    if (objParentCode != null && parentNodeId > -1)
                    {
                        nodeRow.ParentNodeId = parentNodeId;
                    }
                }
                else
                {
                    if (sysRowAction == RowAction.Update)
                    {
                        throw new MDPImportException(String.Format("The Catalog Node with code '{0}' does not exists.", Code));
                    }

                    if (sysRowAction == RowAction.Delete)
                    {
                        throw new MDPImportException(String.Format("The Catalog Node with code '{0}' does not exists.", Code));
                    }

                    nodeRow = catalogNodeDto.CatalogNode.NewCatalogNodeRow();
                    nodeRow.ApplicationId = CatalogConfiguration.Instance.ApplicationId;
                    nodeRow.CatalogId     = _CatalogId;
                    nodeRow.Code          = Code;
                    nodeRow.ParentNodeId  = parentNodeId;
                    nodeRow.Name          = String.Empty;
                    nodeRow.StartDate     = DateTime.UtcNow;
                    nodeRow.EndDate       = DateTime.UtcNow.AddYears(3);
                    nodeRow.TemplateName  = String.Empty;
                    nodeRow.IsActive      = false;
                    nodeRow.SortOrder     = 0;
                    bIsNew = true;
                }

                if (objName != null)
                {
                    nodeRow.Name = (string)objName;
                }

                if (objStartDate != null)
                {
                    nodeRow.StartDate = ((DateTime)objStartDate).ToUniversalTime();
                }

                if (objEndDate != null)
                {
                    nodeRow.EndDate = ((DateTime)objEndDate).ToUniversalTime();
                }

                if (objTemplateName != null)
                {
                    nodeRow.TemplateName = (string)objTemplateName;
                }

                if (objIsActive != null)
                {
                    nodeRow.IsActive = (bool)objIsActive;
                }

                if (objSortOrder != null)
                {
                    nodeRow.SortOrder = (int)objSortOrder;
                }

                int oldMetaClassId = 0;
                if (!_isSystemClass && _metaClassId > 0)
                {
                    if (!bIsNew)
                    {
                        oldMetaClassId = nodeRow.MetaClassId;
                    }

                    nodeRow.MetaClassId = _metaClassId;
                }
                else if (bIsNew)
                {
                    throw new MDPImportException("The new category cannot be created without metaclass definition.");
                }

                if (bIsNew)
                {
                    catalogNodeDto.CatalogNode.AddCatalogNodeRow(nodeRow);
                }

                //SEO
                CatalogNodeDto.CatalogItemSeoRow catalogItemSeoRow = null;
                bool bSeoIsNew = false;
                if (!String.IsNullOrEmpty(this.Context.Language))
                {
                    if (catalogNodeDto.CatalogItemSeo.Count > 0)
                    {
                        DataRow[] drs = catalogNodeDto.CatalogItemSeo.Select(String.Format("LanguageCode LIKE '{0}' AND CatalogNodeId = {1}", this.Context.Language, nodeRow.CatalogNodeId));
                        if (drs.Length > 0)
                        {
                            catalogItemSeoRow = (CatalogNodeDto.CatalogItemSeoRow)drs[0];
                        }
                    }

                    if (catalogItemSeoRow == null)
                    {
                        catalogItemSeoRow = catalogNodeDto.CatalogItemSeo.NewCatalogItemSeoRow();
                        catalogItemSeoRow.ApplicationId = CatalogConfiguration.Instance.ApplicationId;
                        catalogItemSeoRow.LanguageCode  = this.Context.Language.ToLower();
                        catalogItemSeoRow.CatalogNodeId = nodeRow.CatalogNodeId;
                        catalogItemSeoRow.Description   = String.Empty;
                        catalogItemSeoRow.Keywords      = String.Empty;
                        bSeoIsNew = true;
                    }

                    if (objSeoTitle != null)
                    {
                        catalogItemSeoRow.Title = (string)objSeoTitle;
                    }

                    if (objSeoUrl != null)
                    {
                        catalogItemSeoRow.Uri = (string)objSeoUrl;
                    }
                    else if (bSeoIsNew)
                    {
                        // Auto generate the URL if empty
                        string name = catalogNodeDto.CatalogNode[0].Name;
                        string url  = String.Format("{0}.aspx", CommerceHelper.CleanUrlField(name));

                        int index = 1;
                        while (CatalogContext.Current.GetCatalogEntryByUriDto(url, this.Context.Language).CatalogEntry.Count != 0 || CatalogContext.Current.GetCatalogNodeDto(url, this.Context.Language).CatalogNode.Count != 0)
                        {
                            url = String.Format("{0}-{1}.aspx", CommerceHelper.CleanUrlField(name), index.ToString());
                            index++;
                        }

                        catalogItemSeoRow.Uri = url;
                    }


                    if (objSeoDescription != null)
                    {
                        catalogItemSeoRow.Description = (string)objSeoDescription;
                    }

                    if (objSeoKeywords != null)
                    {
                        catalogItemSeoRow.Keywords = (string)objSeoKeywords;
                    }

                    if (bSeoIsNew)
                    {
                        catalogNodeDto.CatalogItemSeo.AddCatalogItemSeoRow(catalogItemSeoRow);
                    }
                }

                using (TransactionScope tx = new TransactionScope())
                {
                    // Save modifications
                    if (catalogNodeDto.HasChanges())
                    {
                        CatalogContext.Current.SaveCatalogNode(catalogNodeDto);
                    }

                    if (!bIsNew && !_isSystemClass && oldMetaClassId != nodeRow.MetaClassId)
                    {
                        MetaObject.Delete(this.Context, nodeRow.CatalogNodeId, oldMetaClassId);
                        MetaObject obj = MetaObject.NewObject(this.Context, nodeRow.CatalogNodeId, nodeRow.MetaClassId);
                        obj.AcceptChanges(this.Context);
                    }

                    tx.Complete();
                }
            }
            catch (Exception ex)
            {
                throw new MDPImportException(ex.Message, null, RowIndex, null, null, Item);
            }

            return(nodeRow.CatalogNodeId);
        }
        protected override int CreateSystemRow(FillDataMode mode, int RowIndex, params object[] item)
        {
            int    i = 0;
            object objSysRowAction = item[i++];
            //Entry
            object objCode          = item[i++];
            object objName          = item[i++];
            object objClassTypeId   = item[i++];
            object objStartDate     = item[i++];
            object objEndDate       = item[i++];
            object objTemplateName  = item[i++];
            object objIsActive      = item[i++];
            object objCategoryCodes = item[i++];
            object objSortOrder     = item[i++];
            //SEO
            object objSeoTitle       = item[i++];
            object objSeoUrl         = item[i++];
            object objSeoDescription = item[i++];
            object objSeoKeywords    = item[i++];

            CatalogEntryDto.CatalogEntryRow entryRow = null;

            try
            {
                RowAction sysRowAction = RowAction.Default;

                if (objSysRowAction != null)
                {
                    sysRowAction = GetRowActionEnum((string)objSysRowAction);
                }

                string code;
                if (objCode != null)
                {
                    code = (string)objCode;
                }
                else
                {
                    throw new AbsentValue("Code");
                }

                bool            bIsNew          = false;
                CatalogEntryDto catalogEntryDto = CatalogEntryManager.GetCatalogEntryDto(code, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
                if (catalogEntryDto.CatalogEntry.Count > 0)
                {
                    if (sysRowAction == RowAction.Insert)
                    {
                        throw new MDPImportException(String.Format("The Entry with code '{0}' already exists.", code));
                    }

                    entryRow = catalogEntryDto.CatalogEntry[0];

                    if (sysRowAction == RowAction.Delete)
                    {
                        CatalogContext.Current.DeleteCatalogEntry(entryRow.CatalogEntryId, true);
                        return(0);
                    }
                }
                else
                {
                    if (sysRowAction == RowAction.Update)
                    {
                        throw new MDPImportException(String.Format("The Entry with code '{0}' does not exists.", code));
                    }

                    if (sysRowAction == RowAction.Delete)
                    {
                        throw new MDPImportException(String.Format("The Entry with code '{0}' does not exists.", code));
                    }

                    entryRow = catalogEntryDto.CatalogEntry.NewCatalogEntryRow();
                    entryRow.ApplicationId = CatalogConfiguration.Instance.ApplicationId;
                    entryRow.CatalogId     = _CatalogId;
                    entryRow.Code          = code;
                    bIsNew = true;
                }

                //Entry
                if (objName != null)
                {
                    string Name = (string)objName;
                    entryRow.Name = Name;
                }
                else if (bIsNew)
                {
                    throw new AbsentValue("Name");
                }

                if (objClassTypeId != null)
                {
                    string classTypeId = (string)objClassTypeId;
                    entryRow.ClassTypeId = classTypeId;
                }
                else if (bIsNew)
                {
                    entryRow.ClassTypeId = EntryType.Product;
                }

                if (objStartDate != null)
                {
                    DateTime startDate = (DateTime)objStartDate;
                    entryRow.StartDate = startDate.ToUniversalTime();
                }
                else if (bIsNew)
                {
                    entryRow.StartDate = DateTime.UtcNow;
                }

                if (objEndDate != null)
                {
                    DateTime endDate = (DateTime)objEndDate;
                    entryRow.EndDate = endDate.ToUniversalTime();
                }
                else if (bIsNew)
                {
                    entryRow.EndDate = DateTime.UtcNow.AddYears(1);
                }

                if (objTemplateName != null)
                {
                    string templateName = (string)objTemplateName;
                    entryRow.TemplateName = templateName;
                }
                else if (bIsNew)
                {
                    entryRow.TemplateName = String.Empty;
                }

                if (objIsActive != null)
                {
                    bool IsActive = (bool)objIsActive;
                    entryRow.IsActive = IsActive;
                }
                else if (bIsNew)
                {
                    entryRow.IsActive = false;
                }

                int oldMetaClassId = 0;
                if (!_isSystemClass && _metaClassId > 0)
                {
                    if (!bIsNew)
                    {
                        oldMetaClassId = entryRow.MetaClassId;
                    }

                    entryRow.MetaClassId = _metaClassId;
                }
                else if (bIsNew)
                {
                    throw new MDPImportException("The new entry cannot be created without metaclass definition.");
                }

                if (bIsNew)
                {
                    catalogEntryDto.CatalogEntry.AddCatalogEntryRow(entryRow);
                }
                else
                {
                    entryRow.SerializedData = null;
                }

                //SEO
                CatalogEntryDto.CatalogItemSeoRow catalogItemSeoRow = null;
                bool bSeoIsNew = false;
                if (!String.IsNullOrEmpty(this.Context.Language))
                {
                    if (catalogEntryDto.CatalogItemSeo.Count > 0)
                    {
                        DataRow[] drs = catalogEntryDto.CatalogItemSeo.Select(String.Format("LanguageCode LIKE '{0}' AND CatalogEntryId = {1}", this.Context.Language, entryRow.CatalogEntryId));
                        if (drs.Length > 0)
                        {
                            catalogItemSeoRow = (CatalogEntryDto.CatalogItemSeoRow)drs[0];
                        }
                    }

                    if (catalogItemSeoRow == null)
                    {
                        catalogItemSeoRow = catalogEntryDto.CatalogItemSeo.NewCatalogItemSeoRow();
                        catalogItemSeoRow.ApplicationId  = CatalogConfiguration.Instance.ApplicationId;
                        catalogItemSeoRow.LanguageCode   = this.Context.Language.ToLower();
                        catalogItemSeoRow.CatalogEntryId = entryRow.CatalogEntryId;
                        bSeoIsNew = true;
                    }

                    if (objSeoTitle != null)
                    {
                        catalogItemSeoRow.Title = (string)objSeoTitle;
                    }

                    if (objSeoUrl != null)
                    {
                        catalogItemSeoRow.Uri = (string)objSeoUrl;
                    }
                    else if (bSeoIsNew)
                    {
                        // Auto generate the URL if empty
                        string name = catalogEntryDto.CatalogEntry.Count > 0 ? catalogEntryDto.CatalogEntry[0].Name : "";
                        string url  = String.Format("{0}.aspx", CommerceHelper.CleanUrlField(name));

                        int index = 1;
                        while (CatalogContext.Current.GetCatalogEntryByUriDto(url, this.Context.Language).CatalogEntry.Count != 0 || CatalogContext.Current.GetCatalogNodeDto(url, this.Context.Language).CatalogNode.Count != 0)
                        {
                            url = String.Format("{0}-{1}.aspx", CommerceHelper.CleanUrlField(name), index.ToString());
                            index++;
                        }

                        catalogItemSeoRow.Uri = url;
                    }

                    if (objSeoDescription != null)
                    {
                        catalogItemSeoRow.Description = (string)objSeoDescription;
                    }

                    if (objSeoKeywords != null)
                    {
                        catalogItemSeoRow.Keywords = (string)objSeoKeywords;
                    }

                    if (bSeoIsNew)
                    {
                        catalogEntryDto.CatalogItemSeo.AddCatalogItemSeoRow(catalogItemSeoRow);
                    }
                }

                using (TransactionScope tx = new TransactionScope())
                {
                    // Save modifications
                    if (catalogEntryDto.HasChanges())
                    {
                        CatalogContext.Current.SaveCatalogEntry(catalogEntryDto);
                    }

                    int sortOrder = -1;
                    if (objSortOrder != null)
                    {
                        sortOrder = (int)objSortOrder;
                    }

                    if (objCategoryCodes != null)
                    {
                        //NodeEntryRelation

                        string[] categoryCodes = ((string)objCategoryCodes).Split(',');

                        Catalog.Dto.CatalogRelationDto catalogRelationDto = FrameworkContext.Current.CatalogSystem.GetCatalogRelationDto(this._CatalogId, 0, entryRow.CatalogEntryId, String.Empty, new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.NodeEntry));

                        Catalog.Dto.CatalogNodeDto catalogNodeDto = FrameworkContext.Current.CatalogSystem.GetCatalogNodesDto(this._CatalogId);
                        if (catalogNodeDto.CatalogNode.Count > 0)
                        {
                            //remove product from category
                            if (catalogRelationDto.NodeEntryRelation.Count > 0)
                            {
                                foreach (CatalogRelationDto.NodeEntryRelationRow nodeEntryRelationRow in catalogRelationDto.NodeEntryRelation)
                                {
                                    DataRow[] catalogNodeDataRows = catalogNodeDto.CatalogNode.Select(String.Format("CatalogNodeId = {0}", nodeEntryRelationRow.CatalogNodeId));
                                    if (catalogNodeDataRows.Length > 0)
                                    {
                                        Catalog.Dto.CatalogNodeDto.CatalogNodeRow catalogNode = (Catalog.Dto.CatalogNodeDto.CatalogNodeRow)catalogNodeDataRows[0];

                                        bool bExist = false;
                                        foreach (string categoryCode in categoryCodes)
                                        {
                                            if (catalogNode.Code.Equals(categoryCode))
                                            {
                                                if (sortOrder >= 0)
                                                {
                                                    nodeEntryRelationRow.SortOrder = sortOrder;
                                                }

                                                bExist = true;
                                                break;
                                            }
                                        }
                                        if (!bExist)
                                        {
                                            nodeEntryRelationRow.Delete();
                                        }
                                    }
                                }
                            }

                            //add entry to category
                            foreach (string categoryCode in categoryCodes)
                            {
                                DataRow[] catalogNodeDataRows = catalogNodeDto.CatalogNode.Select(String.Format("Code = '{0}'", categoryCode.Replace("'", "''")));
                                if (catalogNodeDataRows.Length > 0)
                                {
                                    Catalog.Dto.CatalogNodeDto.CatalogNodeRow catalogNode = (Catalog.Dto.CatalogNodeDto.CatalogNodeRow)catalogNodeDataRows[0];

                                    DataRow[] nodeEntryRelationDataRows = catalogRelationDto.NodeEntryRelation.Select(String.Format("CatalogNodeId = {0}", catalogNode.CatalogNodeId));
                                    if (nodeEntryRelationDataRows.Length == 0)
                                    {
                                        Catalog.Dto.CatalogRelationDto.NodeEntryRelationRow row = catalogRelationDto.NodeEntryRelation.NewNodeEntryRelationRow();
                                        row.CatalogId      = this._CatalogId;
                                        row.CatalogEntryId = entryRow.CatalogEntryId;
                                        row.CatalogNodeId  = catalogNode.CatalogNodeId;

                                        if (sortOrder >= 0)
                                        {
                                            row.SortOrder = sortOrder;
                                        }
                                        else
                                        {
                                            row.SortOrder = 0;
                                        }

                                        catalogRelationDto.NodeEntryRelation.AddNodeEntryRelationRow(row);
                                    }
                                }
                            }
                        }

                        if (catalogRelationDto.HasChanges())
                        {
                            CatalogContext.Current.SaveCatalogRelationDto(catalogRelationDto);
                        }
                    }

                    if (!bIsNew && !_isSystemClass && oldMetaClassId != entryRow.MetaClassId)
                    {
                        MetaObject.Delete(this.Context, entryRow.CatalogEntryId, oldMetaClassId);
                        MetaObject obj = MetaObject.NewObject(this.Context, entryRow.CatalogEntryId, entryRow.MetaClassId);
                        obj.AcceptChanges(this.Context);
                    }

                    tx.Complete();
                }
            }
            catch (Exception ex)
            {
                throw new MDPImportException(ex.Message, null, RowIndex, null, null, item);
            }

            return(entryRow.CatalogEntryId);
        }
Exemple #20
0
        /// <summary>
        /// When the page loads, we'll get the hyperlinks set up, and make sure the js for this control is present
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            global::NWTD.Profile.SetSaleInformation();

            if (!NWTD.Orders.Cart.CartCanBeEdited(this.SelectedCartHelper.Cart))
            {
                this.hlISBNQuickEntryBottom.Visible = false;
                this.hlISBNQuickEntryTop.Visible    = false;
                this.btnDeleteSelected.Visible      = false;
                this.btnDeleteSelectedTop.Visible   = false;
                this.btnSaveChanges.Visible         = false;
                this.btnSubmitTop.Visible           = false;
                this.btnSubmit.Visible = false;
            }

            NWTD.Web.UI.ClientScript.AddRequiredScripts(this.Page);
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "Cart_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/Cart.js"));
            OakTree.Web.UI.ControlHelper.RegisterControlInClientScript(Page.ClientScript, this, "Carts", "{updatePanelID:'" + this.udpViewCart.ClientID + "'}");

            string quickISBNUrl = NavigationManager.GetUrl("QuickISBN", new object[] { "cart", this.SelectedCartName });

            this.hlISBNQuickEntryBottom.NavigateUrl = quickISBNUrl;
            this.hlISBNQuickEntryTop.NavigateUrl    = quickISBNUrl;
        }
Exemple #21
0
    /// <summary>
    /// Binds the data.
    /// </summary>
    private void BindData()
    {
        if (DataSource == null)
        {
            this.Visible = false;
            return;
        }

        List <ItemAsset> assets = new List <ItemAsset>();

        if (!String.IsNullOrEmpty(GroupName))
        {
            foreach (ItemAsset asset in DataSource)
            {
                if (asset.GroupName.Equals(GroupName))
                {
                    assets.Add(asset);
                }
            }
        }
        else
        {
            foreach (ItemAsset asset in DataSource)
            {
                assets.Add(asset);
            }
        }

        this.Visible = true;

        List <FolderElement> elements = new List <FolderElement>();

        foreach (ItemAsset asset in assets)
        {
            if (asset.AssetType.Equals("file"))
            {
                FolderElement[] myElements = FolderElement.List <FolderElement>(FolderElement.GetAssignedMetaClass(), new FilterElement[] { new FilterElement("FolderElementId", FilterElementType.Equal, asset.AssetKey) });
                if (myElements.Length > 0)
                {
                    elements.Add(myElements[0]);
                }
            }
            else
            {
                FolderElement[] myElements = FolderElement.List <FolderElement>(FolderElement.GetAssignedMetaClass(), new FilterElement[] { new FilterElement("ParentId", FilterElementType.Equal, asset.AssetKey) });
                if (myElements.Length > 0)
                {
                    foreach (FolderElement myElement in myElements)
                    {
                        elements.Add(myElement);
                    }
                }
            }
        }

        DataTable table = new DataTable();

        table.Columns.Add(new DataColumn("ID", typeof(string)));
        table.Columns.Add(new DataColumn("Name", typeof(string)));
        table.Columns.Add(new DataColumn("Size", typeof(string)));
        table.Columns.Add(new DataColumn("Url", typeof(string)));
        table.Columns.Add(new DataColumn("Filename", typeof(string)));
        table.Columns.Add(new DataColumn("Icon", typeof(string)));
        table.Columns.Add(new DataColumn("Created", typeof(DateTime)));

        foreach (FolderElement element in elements)
        {
            DataRow newRow = table.NewRow();

            newRow["ID"]   = element.PrimaryKeyId.ToString();
            newRow["Name"] = element.Name;

            BlobStorageProvider prov = BlobStorage.Providers[element.BlobStorageProvider];
            BlobInfo            info = prov.GetInfo(new Guid(element.BlobUid.ToString()));

            newRow["FileName"] = info.FileName;
            newRow["Url"]      = String.Format("~{0}", element.GetUrl()); //DownloadFileUrlBuilder.GetUrl("iis", info);
            newRow["Icon"]     = CommonHelper.GetIcon(info.FileName);
            newRow["Created"]  = info.Created;
            newRow["Size"]     = CommerceHelper.ByteSizeToStr(info.ContentSize);

            table.Rows.Add(newRow);
        }

        DownloadsList.DataSource = table;
        DownloadsList.DataBind();
    }
        protected void AdDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var product = e.Item.DataItem as SueetieProduct;

            if (base.CurrentSueetieProduct.ProductTypeID == 1)
            {
                var breadcrumb = e.Item.FindControl("CommerceCrumbs1") as CommerceBreadCrumbs;
                if (breadcrumb != null)
                {
                    breadcrumb.CurrentCategoryID = base.CurrentSueetieProduct.CategoryID;
                }

                var sizeLiteral = e.Item.FindControl("ltSize") as Literal;
                if (sizeLiteral != null)
                {
                    var filePath = product.ResolveFilePath(this.Server);
                    var fileInfo = new FileInfo(filePath);
                    var fileSize = fileInfo.Length;

                    if (fileSize >= 1000 * 1000)
                    {
                        sizeLiteral.Text = string.Format("{0:#.##} Mo", (float)fileSize / (1000 * 1000));
                    }
                    else
                    {
                        sizeLiteral.Text = string.Format("{0:#.##} Ko", fileSize / 1000);
                    }
                }
            }
            else
            {
                HtmlTableRow row = e.Item.FindControl("rwSize") as HtmlTableRow;
                row.Visible = false;
            }

            if (base.CurrentSueetieProduct.ProductTypeID != 5)
            {
                Literal literal2 = e.Item.FindControl("ltPrice") as Literal;
                literal2.Text = CommerceHelper.FreeIt(base.CurrentSueetieProduct.Price);
            }
            else
            {
                HtmlTableRow row2 = e.Item.FindControl("rwPrice") as HtmlTableRow;
                row2.Visible = false;
            }

            if (product != null)
            {
                this.hyperlinkTitle.Text        = product.Title;
                this.hyperlinkTitle.NavigateUrl = string.Format("ShowProduct.aspx?id={0}", product.ProductID);
                this.SubTitleLabel.Text         = product.SubTitle;
                if (product.StatusTypeID == 100)
                {
                    if (base.CurrentSueetieUser.UserID != product.UserID)
                    {
                        Products.UpdateProductViewCount(this.ProductID);
                    }
                }
                else
                {
                    this.AdActions.Visible = false;
                }
            }
        }
        /// <summary>
        /// During page load, get all the required JS loaded
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            NWTD.Web.UI.ClientScript.AddRequiredScripts(this.Page);
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "DistrictSelector_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/DistrictSelector.js"));

            if (this.Page.IsPostBack)
            {
                return;
            }
            this.ddlState.DataSource = this.States;
            this.ddlState.DataBind();
        }
        /// <summary>
        /// When the page loads, we have to bind all the existing information about the cart to the edit fields in the wizard
        /// We also need to do some branching for Level A and B users, showing and hiding the appropriate controls.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.OrderMessage.Text = string.Empty;

            NWTD.Web.UI.ClientScript.AddRequiredScripts(this.Page);
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "JqueryModal_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/jquery.modal.js"));
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "CheckoutSummary_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/CheckoutSummary.js"));

            if (this.CheckoutCart == null)
            {
                this.OrderMessage.Text         = "You are trying to view the summary for a cart that does not exist;";
                this.pnlOrderSubmitted.Visible = false;
                this.pnlOrderSummary.Visible   = false;
                return;
            }


            CMSContext.Current.OverrideAccess = true;

            if (this.CheckoutCart.Status == NWTD.Orders.Cart.CART_STATUS.SUBMITTED.ToString())
            {
                this.ShowOrderComplete();


                //Response.Redirect(NavigationManager.GetUrl("ManageCarts"));
            }

            global::NWTD.Profile.SetSaleInformation();

            btnSubmitCart.Visible = this.UserIsLevelA;


            //populate the shiping and billing address fields
            if (this.UserIsLevelA)
            {
                //Level A Address Binding

                this.pnlShippingAndTax.Visible = true;
                //this.lblTitle.Text = "Order Summary";

                //The following adds the WebConfirmationNumber to the form header/title of the OrderSummary PDF (Heath Gardner 08/19/13)
                string webConf = this.CheckoutCart.GetString("WebConfirmation").ToString();
                if (!String.IsNullOrEmpty(webConf))
                {
                    //Create the form header/title text
                    string fullTitle = string.Format("Submitted Order -- Confirmation # {0}", webConf);
                    //Set the form header/title equal to the formatted text
                    this.lblTitle.Text = fullTitle;
                }
                else //deal with any NULL confirmation number
                {
                    this.lblTitle.Text = "Submitted Order -- Confirmation";
                }
                ////
                this.pnlLevelANotifications.Visible     = true;
                this.pnlLevelBNotifications.Visible     = false;
                this.btnPrintFooter.Visible             = false;
                this.btnPrintHeader.Visible             = true;
                this.lblRequisitionNotSubmitted.Visible = false;
            }

            //set the grid to have the line items as its data source
            this.gvCart.DataSource = this.CheckoutCartHelper.LineItems;
            this.gvCart.DataBind();
        }
Exemple #25
0
        //TODO: these should be resources living in THIS project
        /// <summary>
        /// Adds all the required client script to a page at runtime
        /// </summary>
        /// <param name="Page"></param>
        public static void AddRequiredScripts(System.Web.UI.Page Page)
        {
            string script = "var NWTD = NWTD||{};";

            script += string.Format("NWTD.BaseURL='{0}';", System.Web.HttpUtility.UrlEncode(Page.ResolveUrl("~/")));
            script += string.Format("NWTD.CurrentUserID='{0}';", Mediachase.Commerce.Profile.ProfileContext.Current.UserId.ToString());

            Page.ClientScript.RegisterClientScriptResource(typeof(OakTree.Web.UI.ControlResources), OakTree.Web.UI.ControlResources.JQUERY_JS);
            Page.ClientScript.RegisterClientScriptResource(typeof(OakTree.Web.UI.ControlResources), OakTree.Web.UI.ControlResources.OAKTREE_UTILITIES_JS);
            Page.ClientScript.RegisterClientScriptResource(typeof(OakTree.Web.UI.ControlResources), OakTree.Web.UI.ControlResources.OAKTREE_WEB_UI_COOKIE);
            Page.ClientScript.RegisterClientScriptResource(typeof(OakTree.Web.UI.ControlResources), OakTree.Web.UI.ControlResources.OAKTREE_WEB_UI_WEBCONTROLS_JS);

            Page.ClientScript.RegisterClientScriptInclude(typeof(OakTree.Web.UI.ControlResources), "NWTD_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/NWTD.js"));
            Page.ClientScript.RegisterClientScriptBlock(typeof(OakTree.Web.UI.ControlResources), "NWTD_global_js", script, true);
        }
        /// <summary>
        /// During page load, we use lucene search API to get a list of publishers. This information comes from the cache for performance.
        /// That information is bound to the search dropdown.
        /// Also, rebinds the freetext search to the search box.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (NWTD.Profile.CurrentUserLevel.Equals(NWTD.UserLevel.ANONYMOUS))
            {
                this.pnlSearchByPublisher.Visible = false; return;
            }

            NWTD.Web.UI.ClientScript.AddRequiredScripts(this.Page);
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "Search_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/Search.js"));
            this.btnSubmitSearch.Text = this.ButtonText;

            //it would be weird to show the facet if it's already there
            //if (!CMSContext.Current.CurrentUrl.Contains("/catalog/searchresults.aspx")) {
            this.ddlPublisher.Visible = true;

            //The key used for retrieving cache data
            string cacheKey = Mediachase.Commerce.Catalog.CatalogCache.CreateCacheKey("search-publisher-names");

            FacetGroup publisherfacet;

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

            if (cachedObject != null)
            {
                publisherfacet = (FacetGroup)cachedObject;
            }
            else
            {
                //So far, this seems like the best way to ennumerate the existing Publishers
                //Although, it does seem kind of convoluted.
                //Anyway, get the list using search and then cache it
                Mediachase.Search.Extensions.CatalogEntrySearchCriteria criteria = new Mediachase.Search.Extensions.CatalogEntrySearchCriteria();

                if (!string.IsNullOrEmpty(global::NWTD.Catalog.UserStateAvailablityField))
                {
                    //Incorporate the state availablity flag
                    criteria.Add(
                        global::NWTD.Catalog.UserStateAvailablityField,
                        new SimpleValue()
                    {
                        key          = string.Empty,
                        value        = "y",
                        locale       = "en-us",
                        Descriptions = new Descriptions()
                        {
                            defaultLocale = "en-us"
                        }
                    });
                }

                //Create a search criteria object
                criteria.Add(SearchFilterHelper.Current.SearchConfig.SearchFilters.SingleOrDefault(filter => filter.field == "Publisher"));
                var manager = new SearchManager(Mediachase.Commerce.Core.AppContext.Current.ApplicationName);

                //conduct the search
                Mediachase.Search.SearchResults results = manager.Search(criteria);

                //get the results
                FacetGroup[] facets = results.FacetGroups;

                //get the publisher field
                publisherfacet = facets.SingleOrDefault(facet => facet.FieldName == "Publisher");


                //cache the results for five minutes for faster future loads
                TimeSpan cacheTimeout = new TimeSpan(0, 5, 00);
                Mediachase.Commerce.Catalog.CatalogCache.Insert(cacheKey, publisherfacet, cacheTimeout);
            }


            //Bind the publisehrs to the dropdown
            this.ddlPublisher.DataSource = publisherfacet.Facets;
            this.ddlPublisher.DataBind();

            //Add an empty item for searching all publishers
            this.ddlPublisher.Items.Insert(0, new ListItem("All Publishers"));

            //select the currently selected publisehr
            foreach (ListItem item in ddlPublisher.Items)
            {
                if (item.Value == this.SelectedPublisher)
                {
                    item.Selected = true;
                }
            }

            //Re-do the keyword in the textbox as well
            this.tbKeyWord.Text = string.IsNullOrEmpty(this.KeyWords) ?this.DefaultSearchText : this.KeyWords;
            //this.ddlPublisher.SelectedValue = this.Publisher;
        }
Exemple #27
0
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, System.EventArgs e)
 {
     global::NWTD.Web.UI.ClientScript.AddRequiredScripts(this.Page);
     Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "SideMenuControl_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/SideMenuControl.js"));
 }
Exemple #28
0
        /// <summary>
        /// Sets the bind grid flag.
        /// </summary>
        /// <param name="gridId">The grid id.</param>
        public static void SetBindGridFlag(string gridId)
        {
            string key = String.Concat(NeedToBindGridKey, "_", gridId);

            CommerceHelper.SetContextParameter(key, true);
        }
Exemple #29
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, System.EventArgs e)
    {
        Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "CompareProducts_js", CommerceHelper.GetAbsolutePath("/Scripts/CompareProducts.js"));
        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "CompareViewPageUrl", String.Format("CSCompareProducts.CompareViewPageUrl = \"{0}\";", CMSContext.Current.ResolveUrl("~/compare.aspx")), true);

        if (Product != null)
        {
            string cbReference    = Page.ClientScript.GetCallbackEventReference(this, "arg", "CSCompareProducts.ReceiveServerData", "context");
            String callbackScript = "function CallServer" + Product.CatalogEntryId + "(arg, context) { " + cbReference + ";}";
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), this.UniqueID, callbackScript, true);
        }
    }
Exemple #30
0
 /// <summary>
 /// During page load, add all the necessary JavaScript files
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     NWTD.Web.UI.ClientScript.AddRequiredScripts(this.Page);
     Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "JqueryModal_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/jquery.modal.js"));
     Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "NewCart_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/NewCart.js"));
 }