예제 #1
0
        /// <summary>Get the current List of HC_ and load if necessary.</summary>
        private static CollectionView GetContainers()
        {
            Cache          c    = HttpRuntime.Cache;
            CollectionView view = (CollectionView)c[CACHEENTRYNAME];

            if (view == null)
            {
                using (ContainerList containers = HyperCatalog.Business.Container.GetAll())
                {
                    view = new CollectionView(containers);
                    view.ApplySort("Tag", System.ComponentModel.ListSortDirection.Ascending);
                    c.Insert(CACHEENTRYNAME, view, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(30), CacheItemPriority.High, null);
                }
            } // if
            return(view);
        }     // Load
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["filter"] != null)
        {
            txtFilter.Text = Request["filter"].ToString();
        }
        lbMessage.Visible = false;
        #region Check Capabilities
        if ((SessionState.User.IsReadOnly) || (!SessionState.User.HasCapability(CapabilitiesEnum.LOCALIZE_PRODUCTS)))
        {
            uwToolbar.Items.FromKeyButton("Validate").Enabled = uwToolbar.Items.FromKeyButton("Exclude").Enabled = false;
        }
        if (SessionState.User.Cultures.Count == 0)
        {
            lbMessage.Text       = "Your profile is not correctly set. Contact an administrator to assign the correct culture to your profile.";
            lbMessage.CssClass   = "hc_error";
            lbMessage.Visible    = true;
            DDL_Cultures.Visible = false;
            return;
        }
        #endregion

        if (!Page.IsPostBack)
        {
            #region Load Cultures list
            /// Retrieve all Users Cultures, and keep only primary
            CultureList    dsCultures = SessionState.User.Cultures;
            CollectionView locales    = new CollectionView(dsCultures);
            locales.ApplyFilter("Type", CultureType.Locale, CollectionView.FilterOperand.Equals);
            locales.ApplySort("Name", System.ComponentModel.ListSortDirection.Ascending);
            if (locales.Count > 0)
            {
                DDL_Cultures.DataSource = locales;
                DDL_Cultures.DataBind();
                if (SessionState.Culture.Type != CultureType.Locale)
                {
                    SessionState.Culture = HyperCatalog.Business.Culture.GetByKey(DDL_Cultures.Items[0].Value);
                }
                else
                {
                    DDL_Cultures.Items.FindByValue(SessionState.Culture.Code).Selected = true;
                }
                DisplayData();
            }
            else
            {
                // User has no primary cultures in its scope
                lbMessage.Text       = "Your profile is not correctly set. Contact an administrator to assign the correct culture to your profile.";
                lbMessage.CssClass   = "hc_error";
                lbMessage.Visible    = true;
                DDL_Cultures.Visible = false;
                return;
            }
            #endregion
        }
        else
        {
            // action after changes in PLC edit window
            if (Request["action"] != null && Request["action"].ToString().ToLower() == "reload")
            {
                DisplayData();
            }
        }
        txtFilter.AutoPostBack = false;
        txtFilter.Attributes.Add("onKeyDown", "KeyHandler(this);"); Page.ClientScript.RegisterStartupScript(Page.GetType(), "filtering", "<script defer=true>var txtFilterField;txtFilterField = document.getElementById('" + txtFilter.ClientID + "');</script>");
        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "initCulture", "<script>var curCulture = '" + SessionState.Culture.Code + "';</script>");
    }