当前位置: 首页>>代码示例>>C#>>正文


C# Item.GetAge方法代码示例

本文整理汇总了C#中Item.GetAge方法的典型用法代码示例。如果您正苦于以下问题:C# Item.GetAge方法的具体用法?C# Item.GetAge怎么用?C# Item.GetAge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Item的用法示例。


在下文中一共展示了Item.GetAge方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadItemDB

    //  The Table getputs.item has the following schema:
    //  getputs.item [IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, UpVotes, DownVotes, Spam]
    //  The Table getputs.user has the following schema:
    //  getputs.item [UID, Password, Date, EMail, About, Admin, Points]
    private void LoadItemDB(ProcessingEngine.Sort sortType)
    {
        List<Item> itemList = new List<Item>();

        //  SELECT * FROM item where IID = ( SELECT IID FROM saveditems where UID = 'vatsal');
        //  SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks FROM getputs.item WHERE IID = ( SELECT IID FROM saveditems WHERE UID = 'vatsal') ORDER BY DATE_FORMAT(Date, '%Y-%m-%d %k:%i:%S') DESC LIMIT 25;
        string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags, AvgRating, NRated FROM item WHERE IID IN ( SELECT IID FROM saveditems where UID = '" + UID + "') ORDER BY DATE_FORMAT(Date, '%Y-%m-%d %k:%i:%S') DESC LIMIT " + engine.MaxItems.ToString() + ";";
        MySqlDataReader retList;

        retList = dbOps.ExecuteReader(queryString);

        if (retList != null && retList.HasRows)
        {
            while (retList.Read())
            {
                Item item = new Item();
                item.IID = Convert.ToInt32(retList["IID"]);
                item.Title = Convert.ToString(retList["Title"]);
                item.Link = Convert.ToString(retList["Link"]);
                item.Text = Convert.ToString(retList["Text"]);
                item.Date = Convert.ToString(retList["Date"]);
                item.UID = Convert.ToString(retList["UID"]);
                item.NComments = Convert.ToInt32(retList["NComments"]);
                item.Category = Convert.ToString(retList["Category"]);
                item.Clicks = Convert.ToInt32(retList["Clicks"]);

                item.NSaved = Convert.ToInt32(retList["NSaved"]);
                item.NEMailed = Convert.ToInt32(retList["NEMailed"]);

                item.TagString = Convert.ToString(retList["Tags"]);
                item.TagList = general.ConvertCSVToList(item.TagString);

                item.AvgRating = Convert.ToDouble(retList["AvgRating"]);
                item.NRated = Convert.ToInt32(retList["NRated"]);

                item.Age = item.GetAge(item.Date);
                //  item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age);
                item.Marks = item.GetMarks(item);

                if (!string.IsNullOrEmpty(item.Link))
                {
                    item.Text = string.Empty;
                }

                itemList.Add(item);
            }
            retList.Close();
        }

        if (sortType == ProcessingEngine.Sort.Hot)
        {
            itemList = engine.SortItems(itemList, sortType);
        }

        //  LoadItemTable(itemList);

        ItemDisplayer.ShowItemsOptions itemOptions = ItemDisplayer.ShowItemsOptions.ShowUIDLink
            | ItemDisplayer.ShowItemsOptions.ShowTime
            | ItemDisplayer.ShowItemsOptions.ShowCategoryLink
            | ItemDisplayer.ShowItemsOptions.ShowEMailLink
            | ItemDisplayer.ShowItemsOptions.ShowCommentsLink
            | ItemDisplayer.ShowItemsOptions.ShowImage
            | ItemDisplayer.ShowItemsOptions.ShowRatings
            | ItemDisplayer.ShowItemsOptions.ShowTags
            | ItemDisplayer.ShowItemsOptions.CountClicks
            | ItemDisplayer.ShowItemsOptions.ShowPreviousNextLinks;
        string itemTable = itemDisplayer.LoadItemTable(itemList, itemOptions, itemLayoutOptions, startItem, UID, sort, links.SavedPageLink.Replace("~\\", ""));
        ItemDiv.InnerHtml = itemTable;
    }
开发者ID:vatsal,项目名称:getputs,代码行数:73,代码来源:Saved.aspx.cs

示例2: LoadItemDB

    private List<Item> LoadItemDB(ProcessingEngine.Sort sortType, List<string> preferredCategoriesList)
    {
        List<Item> itemList = new List<Item>();

        string categoriesDBStr = string.Empty;  //  A categories string formatted for Database Retrieval.
        for (int i = 0; i < preferredCategoriesList.Count; i++)
        {
            if (i == preferredCategoriesList.Count - 1)
            {
                categoriesDBStr = categoriesDBStr + "'" + preferredCategoriesList[i] + "'";
            }
            else
            {
                categoriesDBStr = categoriesDBStr + "'" + preferredCategoriesList[i] + "', ";
            }
        }

        //  SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks FROM getputs.item WHERE Category IN ('startups', 'programming');
        //  string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks FROM item WHERE Category IN (" + categoriesDBStr + ");";

        //  string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags, AvgRating, NRated FROM item WHERE Spam = 0 AND (Tags LIKE '%" + tag + "," + "%' OR Tags LIKE '%" + "," + tag + "%' OR Tags LIKE '" + tag + "')  ORDER BY IID DESC LIMIT " + engine.MaxItems.ToString() + ";";
        string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags, AvgRating, NRated FROM item WHERE Spam = 0 AND Category IN (" + categoriesDBStr + ") ORDER BY DATE_FORMAT(Date, '%Y-%m-%d %k:%i:%S') DESC LIMIT " + engine.MaxItems.ToString() + ";";

        MySqlDataReader retList;

        retList = dbOps.ExecuteReader(queryString);

        if (retList != null && retList.HasRows)
        {
            while (retList.Read())
            {
                Item item = new Item();
                item.IID = Convert.ToInt32(retList["IID"]);
                item.Title = Convert.ToString(retList["Title"]);
                item.Link = Convert.ToString(retList["Link"]);
                item.Text = Convert.ToString(retList["Text"]);
                item.Date = Convert.ToString(retList["Date"]);
                item.UID = Convert.ToString(retList["UID"]);
                item.NComments = Convert.ToInt32(retList["NComments"]);
                item.Category = Convert.ToString(retList["Category"]);
                item.Clicks = Convert.ToInt32(retList["Clicks"]);
                item.NSaved = Convert.ToInt32(retList["NSaved"]);
                item.NEMailed = Convert.ToInt32(retList["NEMailed"]);

                item.TagString = Convert.ToString(retList["Tags"]);
                item.TagList = general.ConvertCSVToList(item.TagString);

                item.AvgRating = Convert.ToDouble(retList["AvgRating"]);
                item.NRated = Convert.ToInt32(retList["NRated"]);

                item.Age = item.GetAge(item.Date);
                //  item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age);
                item.Marks = item.GetMarks(item);

                if (!string.IsNullOrEmpty(item.Link))
                {
                    item.Text = string.Empty;
                }

                itemList.Add(item);
            }
            retList.Close();
        }
        if (sortType == ProcessingEngine.Sort.Hot)
        {
            itemList = engine.SortItems(itemList, sortType);
        }

        return itemList;
    }
开发者ID:vatsal,项目名称:getputs,代码行数:70,代码来源:MyNews.aspx.cs

示例3: LoadItemDetails

    private void LoadItemDetails(string IID)
    {
        item = new Item();

        //  string queryString = "SELECT Title, Link, Text, Date, UID, NComments, Category FROM item WHERE IID=" + IID + ";";
        string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags, AvgRating, NRated FROM item WHERE IID=" + IID + ";";
        MySqlDataReader retList;

        retList = dbOps.ExecuteReader(queryString);

        if (retList != null && retList.HasRows)
        {
            while (retList.Read())
            {
                item.IID = Convert.ToInt32(retList["IID"]);
                item.UID = Convert.ToString(retList["UID"]);
                item.Title = Convert.ToString(retList["Title"]);
                item.Link = Convert.ToString(retList["Link"]);
                item.Text = Convert.ToString(retList["Text"]);
                item.Date = Convert.ToString(retList["Date"]);
                item.NComments = Convert.ToInt32(retList["NComments"]);
                item.Category = Convert.ToString(retList["Category"]);

                item.Clicks = Convert.ToInt32(retList["Clicks"]);
                item.NSaved = Convert.ToInt32(retList["NSaved"]);
                item.NEMailed = Convert.ToInt32(retList["NEMailed"]);

                item.TagString = Convert.ToString(retList["Tags"]);
                item.TagList = general.ConvertCSVToList(item.TagString);

                item.AvgRating = Convert.ToDouble(retList["AvgRating"]);
                item.NRated = Convert.ToInt32(retList["NRated"]);

                item.Age = item.GetAge(item.Date);
                //  item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age);
                item.Marks = item.GetMarks(item);

                if (!string.IsNullOrEmpty(item.Link))
                {
                    item.Text = string.Empty;
                }
            }
            retList.Close();
        }

        Page.Title = item.Title + " - getputs.com";

        //  Vatsal Shah
        //  2009-01-12
        //  The code below is not used. ItemDisplayer.cs is used instead.

        /*
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        string commentString = "discuss";

        List<int> savedItems = null;
        List<int> ratedItems = null;
        if (!string.IsNullOrEmpty(UID))
        {
            //  Get the list of items that have been saved by the User only if the User is logged in.
            savedItems = general.GetSavedItemIID(UID);
            ratedItems = general.GetRatedItemsIID(UID);
        }

        if (!string.IsNullOrEmpty(item.Link))
        {
            //HyperLink linkItemHL = new HyperLink();
            //linkItemHL.CssClass = "CSS_LinkItem";
            //linkItemHL.Text = item.Title;
            ////  linkItemHL.NavigateUrl = links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + item.Link;
            //linkItemHL.NavigateUrl = item.Link;
            //ItemDiv.Controls.Add(linkItemHL);

            string linkItemHL = "<a class='CSS_LinkItem' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + item.Link + "'>" + item.Title + "</a>";
            ItemDiv.Controls.Add(new LiteralControl(linkItemHL));

            Uri uri = new Uri(item.Link);
            string website = uri.Host;

            HyperLink websiteLink = new HyperLink();
            websiteLink.Text = "  " + "[" + website.Replace("www.", "") + "]";
            websiteLink.CssClass = "CSS_ItemDomain";
            websiteLink.Target = "_blank";
            websiteLink.NavigateUrl = "http://" + website;
            ItemDiv.Controls.Add(websiteLink);

        }
        else
        {
            //HyperLink textItemHL = new HyperLink();
            //textItemHL.Text = item.Title;
            //textItemHL.CssClass = "CSS_TextItem";
            ////  textItemHL.NavigateUrl = links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString();
            //textItemHL.NavigateUrl = links.ItemDetailsPageLink + "?iid=" + item.IID.ToString();
            //ItemDiv.Controls.Add(textItemHL);

            string textItemHL = "<a class='CSS_LinkItem' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString() + "'>" + item.Title + "</a>";
            ItemDiv.Controls.Add(new LiteralControl(textItemHL));
        }

//.........这里部分代码省略.........
开发者ID:vatsal,项目名称:getputs,代码行数:101,代码来源:ItemDetails.aspx.cs

示例4: GetSimilarlyTaggedItems

    private List<Item> GetSimilarlyTaggedItems(string tag)
    {
        List<Item> itemList = new List<Item>();

        //  SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags FROM item WHERE Spam = 0 AND (Tags LIKE '%scrabulous,%' OR Tags LIKE '%,scrabulous') ORDER BY IID DESC LIMIT 25;
        string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags, AvgRating, NRated FROM item WHERE Spam = 0 AND (Tags LIKE '%" + tag + "," + "%' OR Tags LIKE '%" + "," + tag + "%' OR Tags LIKE '" + tag + "')  ORDER BY IID DESC LIMIT " + engine.MaxItems.ToString() + ";";
        MySqlDataReader retList;

        retList = dbOps.ExecuteReader(queryString);

        if (retList != null && retList.HasRows)
        {
            while (retList.Read())
            {
                Item item = new Item();
                item.IID = Convert.ToInt32(retList["IID"]);
                item.Title = Convert.ToString(retList["Title"]);
                item.Link = Convert.ToString(retList["Link"]);
                item.Text = Convert.ToString(retList["Text"]);
                item.Date = Convert.ToString(retList["Date"]);
                item.UID = Convert.ToString(retList["UID"]);
                item.NComments = Convert.ToInt32(retList["NComments"]);
                item.Category = Convert.ToString(retList["Category"]);
                item.Clicks = Convert.ToInt32(retList["Clicks"]);
                item.NSaved = Convert.ToInt32(retList["NSaved"]);
                item.NEMailed = Convert.ToInt32(retList["NEMailed"]);

                item.TagString = Convert.ToString(retList["Tags"]);
                item.TagList = general.ConvertCSVToList(item.TagString);

                item.AvgRating = Convert.ToDouble(retList["AvgRating"]);
                item.NRated = Convert.ToInt32(retList["NRated"]);

                item.Age = item.GetAge(item.Date);
                //  item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age);
                item.Marks = item.GetMarks(item);

                if (!string.IsNullOrEmpty(item.Link))
                {
                    item.Text = string.Empty;
                }

                itemList.Add(item);
            }
            retList.Close();
        }
        if (sort == ProcessingEngine.Sort.Hot)
        {
            itemList = engine.SortItems(itemList, sort);
        }

        return itemList;
    }
开发者ID:vatsal,项目名称:getputs,代码行数:53,代码来源:AutoTag.aspx.cs

示例5: LoadSearchResults

    public List<Item> LoadSearchResults(string query)
    {
        List<Item> itemList = new List<Item>();

        string queryString = "SELECT * FROM item WHERE Title LIKE '%" + query + "%' LIMIT " + _maxSearchResults + ";";
        MySqlDataReader retList = dbOps.ExecuteReader(queryString);

        retList = dbOps.ExecuteReader(queryString);

        if (retList != null && retList.HasRows)
        {
            while (retList.Read())
            {
                Item item = new Item();
                item.IID = Convert.ToInt32(retList["IID"]);
                item.Title = Convert.ToString(retList["Title"]);
                item.Link = Convert.ToString(retList["Link"]);
                item.Text = Convert.ToString(retList["Text"]);
                item.Date = Convert.ToString(retList["Date"]);
                item.UID = Convert.ToString(retList["UID"]);
                item.NComments = Convert.ToInt32(retList["NComments"]);
                item.Category = Convert.ToString(retList["Category"]);
                item.Clicks = Convert.ToInt32(retList["Clicks"]);
                item.NSaved = Convert.ToInt32(retList["NSaved"]);
                item.NEMailed = Convert.ToInt32(retList["NEMailed"]);

                item.TagString = Convert.ToString(retList["Tags"]);
                item.TagList = general.ConvertCSVToList(item.TagString);

                item.AvgRating = Convert.ToDouble(retList["AvgRating"]);
                item.NRated = Convert.ToInt32(retList["NRated"]);

                item.Age = item.GetAge(item.Date);
                //  item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age);
                item.Marks = item.GetMarks(item);

                if (!string.IsNullOrEmpty(item.Link))
                {
                    item.Text = string.Empty;
                }

                itemList.Add(item);
            }
            retList.Close();
        }

        return itemList;
        //  ItemDiv.InnerHtml = LoadItems(itemList);
        //  LoadItemTable(itemList);
    }
开发者ID:vatsal,项目名称:getputs,代码行数:50,代码来源:SearchEngine.cs


注:本文中的Item.GetAge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。