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


C# Category.RecursiveName方法代码示例

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


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

示例1: AddFavoriteCategory

        public bool AddFavoriteCategory(Category category, string siteId)
        {
            var siteName = RemoveInvalidChars(siteId);
            string categoryHierarchyName = RemoveInvalidChars(category.RecursiveName("|"));

            using (var cnn = OpenConnection())
            {
                using (var cmd = cnn.CreateCommand())
                {
                    //check if the category is already in the favorite list
                    cmd.CommandText = string.Format("select CAT_ID from FAVORITE_Categories where CAT_Hierarchy='{0}' AND CAT_SITE_ID='{1}'", categoryHierarchyName, siteName);
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            Log.Info("Favorite Category {0} already in database", category.Name);
                            return true;
                        }
                    }

                    Log.Info("inserting favorite category on site {0} with name: {1}, desc: {2}, image: {3}",
                        siteName, category.Name, category.Description, category.Thumb, siteName);

                    string sql = string.Format(
                            "insert into FAVORITE_Categories(CAT_Name,CAT_Desc,CAT_ThumbUrl,CAT_Hierarchy,CAT_SITE_ID)VALUES('{0}','{1}','{2}','{3}','{4}')",
                            RemoveInvalidChars(category.Name), category.Description == null ? "" : RemoveInvalidChars(category.Description), category.Thumb, categoryHierarchyName, siteName);
                    cmd.CommandText = sql;
                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        Log.Info("Favorite Category {0} inserted successfully into database", category.Name);
                        return true;
                    }
                    else
                    {
                        Log.Warn("Favorite Category {0} failed to insert into database", category.Name);
                        return false;
                    }
                }
            }
        }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:40,代码来源:FavoriteDB.cs

示例2: SetPreferredLayout

		public bool SetPreferredLayout(string siteName, Category cat, int Layout)
		{
			try
			{
				if (string.IsNullOrEmpty(siteName)) return false;
				DatabaseUtility.RemoveInvalidChars(ref siteName);
				string categoryHierarchyName = cat != null ? EscapeString(DatabaseUtility.RemoveInvalidChars(cat.RecursiveName("|"))) : "";
				m_db.Execute(string.Format("insert into PREFERRED_LAYOUT(Site_Name, Category_Hierarchy, Layout) VALUES ('{0}','{1}',{2})", siteName, categoryHierarchyName, Layout));
				return m_db.ChangedRows() > 0;
			}
			catch (Exception ex)
			{
				Log.Instance.Warn("Exception storing preferred Layout in DB: {0}", ex.ToString());
				return false;
			}
		}
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:16,代码来源:FavoritesDatabase.cs

示例3: GetPreferredLayout

		public MediaPortal.GUI.Library.GUIFacadeControl.Layout? GetPreferredLayout(string siteName, Category cat)
		{
			try
			{
				if (string.IsNullOrEmpty(siteName)) return null;
				DatabaseUtility.RemoveInvalidChars(ref siteName);
				string categoryHierarchyName = cat != null ? EscapeString(DatabaseUtility.RemoveInvalidChars(cat.RecursiveName("|"))) : "";
				if (!string.IsNullOrEmpty(categoryHierarchyName))
				{
					var resultSet = m_db.Execute(string.Format("SELECT Layout FROM PREFERRED_LAYOUT WHERE Site_Name = '{0}' AND Category_Hierarchy = '{1}'", siteName, categoryHierarchyName));
					if (resultSet.Rows.Count > 0)
					{
						return (MediaPortal.GUI.Library.GUIFacadeControl.Layout)int.Parse(DatabaseUtility.Get(resultSet, 0, "Layout"));
					}
				}
				return null;
			}
			catch (Exception ex)
			{
				Log.Instance.Warn("Exception getting preferred Layout from DB: {0}", ex.ToString());
				return null;
			}
		}
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:23,代码来源:FavoritesDatabase.cs

示例4: AddFavoriteCategory

        public bool AddFavoriteCategory(Category cat, string siteName)
        {
			DatabaseUtility.RemoveInvalidChars(ref siteName);
            string categoryHierarchyName = EscapeString(cat.RecursiveName("|"));

            //check if the category is already in the favorite list
            if (m_db.Execute(string.Format("select CAT_ID from FAVORITE_Categories where CAT_Hierarchy='{0}' AND CAT_SITE_ID='{1}'", categoryHierarchyName, siteName)).Rows.Count > 0)
            {
                Log.Instance.Info("Favorite Category {0} already in database", cat.Name);
                return true;
            }

            Log.Instance.Info("inserting favorite category on site {0} with name: {1}, desc: {2}, image: {3}", 
                siteName, cat.Name, cat.Description, cat.Thumb, siteName);

            string lsSQL =
                string.Format(
                    "insert into FAVORITE_Categories(CAT_Name,CAT_Desc,CAT_ThumbUrl,CAT_Hierarchy,CAT_SITE_ID)VALUES('{0}','{1}','{2}','{3}','{4}')",
                    DatabaseUtility.RemoveInvalidChars(cat.Name), cat.Description == null ? "" : DatabaseUtility.RemoveInvalidChars(cat.Description), cat.Thumb, categoryHierarchyName, siteName);
            m_db.Execute(lsSQL);
            if (m_db.ChangedRows() > 0)
            {
                Log.Instance.Info("Favorite Category {0} inserted successfully into database", cat.Name);
                return true;
            }
            else
            {
                Log.Instance.Warn("Favorite Category {0} failed to insert into database", cat.Name);
                return false;
            }
        }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:31,代码来源:FavoritesDatabase.cs


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