Esempio n. 1
0
        public static void EnQueue(int productId)
        {
            System.Collections.Generic.IList <int> list = BrowsedProductQueue.GetBrowedProductList();
            int num = 0;

            foreach (int current in list)
            {
                if (productId == current)
                {
                    list.RemoveAt(num);
                    break;
                }
                num++;
            }
            if (list.Count <= 20)
            {
                list.Add(productId);
            }
            else
            {
                list.RemoveAt(0);
                list.Add(productId);
            }
            BrowsedProductQueue.SaveCookie(list);
        }
Esempio n. 2
0
        /// <summary>Removes all predicated elements from an IList.</summary>
        /// <typeparam name="T">The generic type of elements in the IList.</typeparam>
        /// <param name="iList">The IList to perform the predicated removal on.</param>
        /// <param name="predicate">The predicate determining if an element is removed (True) or not (False).</param>
        public static void Remove <T>(this System.Collections.Generic.IList <T> iList, System.Predicate <T> predicate)
        {
            int write_position = 0;

            {
                int i = 0;
                // while (i == write_position) we can avoid the assignment
                for (; i < iList.Count && i == write_position; i++)
                {
                    if (!predicate(iList[i]))
                    {
                        write_position++;
                    }
                }
                // now (i != write_position), assignment required
                for (; i < iList.Count; i++)
                {
                    if (!predicate(iList[i]))
                    {
                        iList[write_position++] = iList[i];
                    }
                }
            }
            // removing from the end of the IList is an O(1) operation
            for (int i = iList.Count - 1; i >= write_position; i--)
            {
                iList.RemoveAt(i);
            }
        }
 /// <summary>
 /// reset buffer index in send buffer
 /// </summary>
 public void ResetSendBuffer()
 {
     currentBufferIndex = 0;
     for (int i = cmdBuffer.Count - 1; i >= 0; i--)
     {
         var buffer = cmdBuffer[i].Array;
         BufferPool.ReleaseBufferToPool(ref buffer);
         cmdBuffer.RemoveAt(i);
     }
 }
Esempio n. 4
0
 /*******************************/
 /// <summary>
 /// Sets the capacity for the specified List
 /// </summary>
 /// <param name="vector">The List which capacity will be set</param>
 /// <param name="newCapacity">The new capacity value</param>
 public static void SetCapacity <T>(System.Collections.Generic.IList <T> vector, int newCapacity) where T : new()
 {
     while (newCapacity > vector.Count)
     {
         vector.Add(new T());
     }
     while (newCapacity < vector.Count)
     {
         vector.RemoveAt(vector.Count - 1);
     }
 }
Esempio n. 5
0
        public static System.Collections.Generic.IList <int> GetBrowedProductList(int maxNum)
        {
            System.Collections.Generic.IList <int> list = BrowsedProductQueue.GetBrowedProductList();
            int count = list.Count;

            if (list.Count > maxNum)
            {
                for (int i = 0; i < count - maxNum; i++)
                {
                    list.RemoveAt(0);
                }
            }
            return(list);
        }
Esempio n. 6
0
        private void BindList(int skip)
        {
            if (this.rp_guest != null)
            {
                System.Collections.Generic.IList <int> browedProductList = BrowsedProductQueue.GetBrowedProductList((skip * this.maxNum) + this.MaxNum);

                int browedListCount = browedProductList.Count;
                if (browedListCount > (skip * this.maxNum) + this.MaxNum)
                {
                    int isRemove = browedListCount - this.maxNum;
                    while (isRemove > 0)
                    {
                        isRemove--;
                        browedProductList.RemoveAt(0);
                    }
                }
                else
                {
                    browedProductList.Clear();
                }
                //DataTable table = ProductBrowser.GetSuggestProductsProducts(browedProductList, 6);
                DataTable table = ProductBrowser.GetVistiedProducts(browedProductList);
                if (table != null)
                {
                    if (table.Rows.Count < this.maxNum)
                    {
                        DataTable dt = ProductBrowser.GetVistiedProducts(this.MaxNum - table.Rows.Count, skip * this.maxNum + 1, skip * this.maxNum + 1 + this.MaxNum);
                        TableToTable(table, dt);
                    }
                }
                else
                {
                    table = ProductBrowser.GetVistiedProducts(this.MaxNum, skip * this.maxNum + 1, skip * this.maxNum + 1 + this.MaxNum);
                }

                if (table.Rows.Count < 5)
                {
                    this.rp_guest.DataSource = null;
                    this.rp_guest.DataBind();
                    return;
                }
                this.rp_guest.DataSource = table;
                this.rp_guest.DataBind();
            }
        }
    /// <summary>
    /// Handles the PreRender 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_PreRender(object sender, EventArgs e)
    {
        string family = "ACCOUNT";

        if (ddlMainView.SelectedItem != null)
        {
            family = ddlMainView.SelectedItem.Value;
        }

        System.Collections.Generic.IList <Plugin> GroupList = PluginManager.GetPluginList(GroupInfo.GetGroupPluginType(family), true, false);
        for (int i = GroupList.Count - 1; i >= 0; i--)
        {
            if (GroupList[i].Family.ToLower() != family.ToLower())
            {
                GroupList.RemoveAt(i);
                continue;
            }
            if (String.IsNullOrEmpty(GroupList[i].DisplayName))
            {
                GroupList[i].DisplayName = GroupList[i].Name;
            }
        }

        /***** Name Collistion with Blob.PluginId *****************************************************/
        //ddlGroup.DataSource = GroupList;
        //ddlGroup.DataTextField = "DisplayName";
        //ddlGroup.DataValueField = "PluginId";
        //ddlGroup.DataBind();
        /*********************************************************************************************/
        ddlGroup.Items.Clear();
        ddlLookupLayoutGroup.Items.Clear();
        foreach (Plugin gl in GroupList)
        {
            ddlGroup.Items.Add(new ListItem(gl.DisplayName, gl.PluginId));
            ddlLookupLayoutGroup.Items.Add(new ListItem(gl.DisplayName, gl.PluginId));
        }

        IUserOptionsService userOption = ApplicationContext.Current.Services.Get <IUserOptionsService>();
        string defFamName = userOption.GetCommonOption(DefaultGroupOptionName(), "DefaultGroup");

        foreach (Plugin grp in GroupList)
        {
            if ((grp.Family.ToLower() == defFamName.Split(':')[0].ToLower()) && (grp.Name == defFamName.Split(':')[1]))
            {
                Utility.SetSelectedValue(ddlGroup, grp.PluginId);
            }
        }
        string defLayoutGroup = userOption.GetCommonOption(DefaultGroupOptionName(), "LookupLayoutGroup");

        defLayoutGroup = (string.IsNullOrEmpty(defLayoutGroup)) ? defFamName : defLayoutGroup;
        foreach (Plugin grp in GroupList)
        {
            if ((grp.Family.ToLower() == defLayoutGroup.Split(':')[0].ToLower()) && (grp.Name == defLayoutGroup.Split(':')[1]))
            {
                Utility.SetSelectedValue(ddlLookupLayoutGroup, grp.PluginId);
            }
        }

        bool   autoFitColumns;
        string autoFitColumnsValue = userOption.GetCommonOption("autoFitColumns", "GroupGridView");

        if (!Boolean.TryParse(autoFitColumnsValue, out autoFitColumns))
        {
            autoFitColumns = true;
        }

        cbAutoFitColumns.Checked = autoFitColumns;
    }