public override IHierarchicalEnumerable Select() { HttpRequest currentRequest = HttpContext.Current.Request; //if (!currentRequest.IsAuthenticated) // throw new NotSupportedException("The CategoryDataSourceView only presents data in an authenticated context."); CategoryCollection categories = new CategoryCollection(); if (this.viewPath == Category.Root) { Category root = new Category(Guid.Empty); foreach (Category c in root.Childs) categories.Add(new CategoryHierarchyData(c)); return categories; } Category category = (Category)ContentManagementService.GetCategory(this.viewPath); if (category != null) { foreach (Category child in category.Childs) { categories.Add(new CategoryHierarchyData(child)); } } return categories; }
/// <summary> /// foamliu, 2009/12/21, please make sure you've uncompressed "2_newsgroups.7z" in the "data" folder. /// </summary> /// <returns></returns> private static ClassificationProblem CreateText() { const string DataFolder = @"..\data\2_newsgroups"; ClassificationProblem problem = new ClassificationProblem(); ExampleSet t_set = new ExampleSet(); ExampleSet v_set = new ExampleSet(); CategoryCollection collect = new CategoryCollection(); collect.Add(new Category(+1, "+1")); collect.Add(new Category(-1, "-1")); problem.Dimension = 2; problem.CategoryCollection = collect; DirectoryInfo dataFolder = new DirectoryInfo(DataFolder); DirectoryInfo[] subfolders = dataFolder.GetDirectories(); int count = 0; for (int i = 0; i < subfolders.Count(); i++) { DirectoryInfo categoryFolder = subfolders[i]; int cat = i * 2 - 1; // for all the text files in each category FileInfo[] files = categoryFolder.GetFiles(); count = 0; int trainSetCount = Convert.ToInt32(Constants.TrainingSetRatio * files.Count()); for (int j = 0; j < files.Count(); j++) { FileInfo textFile = files[j]; Example e = new Example(); if (++count < trainSetCount) { t_set.AddExample(e); } else { v_set.AddExample(e); } } } problem.TrainingSet = t_set; problem.ValidationSet = v_set; return(problem); }
public override string RenderData() { CategoryCollection cc = null; if (CategoryIds == null || CategoryIds.Length == 0) { cc = new CategoryController().GetTopLevelCachedCategories(); } else { CategoryController controller = new CategoryController(); cc = new CategoryCollection(); foreach (int i in CategoryIds) { Category c = controller.GetCachedCategory(i, true); if (c != null) { cc.Add(c); } } } StringBuilder sb = new StringBuilder("<ul>"); foreach (Category c in cc) { sb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", c.Url, c.Name); } sb.Append("</ul>"); return(sb.ToString()); }
public override string RenderData() { CategoryCollection cc = null; if (CategoryIds == null || CategoryIds.Length == 0) cc = new CategoryController().GetTopLevelCachedCategories(); else { CategoryController controller = new CategoryController(); cc = new CategoryCollection(); foreach (int i in CategoryIds) { Category c = controller.GetCachedCategory(i, true); if(c != null) cc.Add(c); } } StringBuilder sb = new StringBuilder("<ul>"); foreach(Category c in cc) { sb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", c.Url, c.Name); } sb.Append("</ul>"); return sb.ToString(); }
/// <summary> /// Returns all categories along with the uncategorized category /// </summary> /// <returns></returns> public CategoryCollection GetAllCachedCategories() { CategoryCollection cc = ZCache.Get <CategoryCollection>(CacheKey); if (cc == null) { cc = CategoryCollection.FetchAll(); bool foundUncategorized = false; foreach (Category c in cc) { if (c.Name == UncategorizedName) { foundUncategorized = true; break; } } if (!foundUncategorized) { Category uncategorizedCategory = new Category(); uncategorizedCategory.Name = UncategorizedName; uncategorizedCategory.LinkName = "uncategorized"; uncategorizedCategory.Save(); cc.Add(uncategorizedCategory); } ZCache.InsertCache(CacheKey, cc, 90); } return(cc); }
private static ClassificationProblem CreateChessBoard() { ClassificationProblem problem = new ClassificationProblem(); CategoryCollection collect = new CategoryCollection(); collect.Add(new Category(+1, "+1")); collect.Add(new Category(-1, "-1")); problem.Dimension = 2; problem.CategoryCollection = collect; problem.TrainingSet = GetExamples(collect); problem.ValidationSet = GetExamples(collect); return(problem); }
public IHierarchicalEnumerable GetChildren() { CategoryCollection children = new CategoryCollection(); foreach (ICategory child in item.Childs) children.Add(new CategoryHierarchyData(child)); return children; }
public void PopulateConfiguration(CategoryCollection categories) { Category category = new Category(TextResources.Config_Management, TextResources.Config_Management_Description); categories.Add(category); CategoryItem item = new CategoryItem(TextResources.Config_Management_Plugins, TextResources.Config_Management_Plugins_Description, typeof(PluginManagementContent)); item.Image = VisualResources.Image_64x67_Management; category.Items.Add(item); }
public void PopulateConfiguration(CategoryCollection categories) { Category category = new Category(TextResources.Config_General, TextResources.Config_General_Description); CategoryItem item = new CategoryItem(TextResources.Config_General_About, TextResources.Config_General_About_Description, typeof(AboutContent)); item.Image = VisualResources.Image_64x67_Information; category.Items.Add(item); categories.Add(category); }
private void GetChildren(string parentId, CategoryCollection cats) { List <Category> children = GetCategoryByParentID(parentId); for (int i = 0; i < children.Count; i++) { cats.Add(children[i]); GetChildren(children[i].ID, cats); } }
//********************************************************************* // // Generate Collection Helper Methods // // The following methods are used to generate collections of objects. // //********************************************************************* protected CollectionBase GenerateCategoryCollectionFromReader(IDataReader returnData) { CategoryCollection mlsCollection = new CategoryCollection(); while (returnData.Read()) { Category newCategory = new Category((int)returnData["CategoryId"], (int)returnData["ProjectId"], (int)returnData["ParentCategoryId"], (string)returnData["CategoryName"]); mlsCollection.Add(newCategory); } return(mlsCollection); }
public void CategoryAndNamedObjectAreUnique() { CategoryCollection categoryCollection = new CategoryCollection(); categoryCollection.Add("Kursy", new NamedObject("Python")) .Add("Kursy", new NamedObject("Python")) .Add("Kursy", new NamedObject("Python")); categoryCollection.Add("Audiobooki", new NamedObject("HTML")) .Add("Audiobooki", new NamedObject("CSS")) .Add("Audiobooki", new NamedObject("HTML")) .Add("Audiobooki", new NamedObject("HTML")); var firstElement = categoryCollection.ElementAt(0); var secondElement = categoryCollection.ElementAt(1); Assert.AreEqual(2, categoryCollection.Count); Assert.AreEqual(2, firstElement.Value.Count); Assert.AreEqual(1, secondElement.Value.Count); }
/// <summary> /// Gets all categories. /// </summary> /// <returns></returns> public CategoryCollection GetAll() { SharePointListDescriptor items = Provider.GetAllListItems(ForumConstants.Lists_Category); CategoryCollection categoryCollection = new CategoryCollection(); foreach (SharePointListItem listItem in items.SharePointListItems) { categoryCollection.Add(CategoryMapper.CreateDomainObject(listItem)); } return(categoryCollection); }
protected CategoryCollection GetAllCategories(int forParentEntityId) { var result = new CategoryCollection(); var categories = CategoryManager.GetAllCategories(forParentEntityId); foreach (var category in categories) { result.Add(category); result.AddRange(GetAllCategories(category.CategoryId)); } return(result); }
/// <summary> /// Gets a category breadcrumb /// </summary> /// <param name="CategoryID">Category identifier</param> /// <returns>Category</returns> public static CategoryCollection GetBreadCrumb(int CategoryID) { CategoryCollection breadCrumb = new CategoryCollection(); Category category = GetCategoryByID(CategoryID); while (category != null) { breadCrumb.Add(category); category = category.ParentCategory; } breadCrumb.Reverse(); return(breadCrumb); }
/// <summary> /// Gets a category breadcrumb /// </summary> /// <param name="categoryId">Category identifier</param> /// <returns>Category</returns> public static CategoryCollection GetBreadCrumb(int categoryId) { var breadCrumb = new CategoryCollection(); var category = GetCategoryById(categoryId); while (category != null && !category.Deleted && category.Published) { breadCrumb.Add(category); category = category.ParentCategory; } breadCrumb.Reverse(); return(breadCrumb); }
public static CategoryCollection ToDtoCollection(this EntityCollection <CategoryEntity> entities) { OnBeforeEntityCollectionToDtoCollection(entities); var seenObjects = new Hashtable(); var collection = new CategoryCollection(); foreach (var entity in entities) { collection.Add(entity.ToDto(seenObjects, new Hashtable())); } OnAfterEntityCollectionToDtoCollection(entities, collection); return(collection); }
private CategoryCollection GetSubData(CategoryCollection Source, int start, int end) { int iTotalRecord = Source.Count; CategoryCollection subSource = new CategoryCollection(); if (Source != null) { for (int i = start; i < end; i++) { subSource.Add(Source[i]); } } return(subSource); }
/// <summary> /// 取得所有栏目信息 /// </summary> /// <returns></returns> public CategoryCollection GetCategorys() { return(CacheRecord.GetInstance <CategoryCollection>("GetCategorys", () => { CategoryCollection CatColl = new CategoryCollection(); List <Category> list = GetCategoryByParentID(We7Helper.EmptyGUID); foreach (Category c in list) { CatColl.Add(c); AppendChildCategory(c); } return CatColl; })); }
private static CategoryCollection DBMapping(DBCategoryCollection dbCollection) { if (dbCollection == null) { return(null); } var collection = new CategoryCollection(); foreach (var dbItem in dbCollection) { var item = DBMapping(dbItem); collection.Add(item); } return(collection); }
private void AddCategory(object param) { if (string.IsNullOrWhiteSpace(CategoryName)) { LabelError = "Błędna nazwa"; return; } var ic = new InvoiceCategory { CategoryName = CategoryName, CategoryId = Guid.NewGuid(), IsDeleted = false }; CategoryCollection.Add(ic); commandBuffer.Add(new Helpers.CategoryCommand <InvoiceCategory> { CommandType = Helpers.CommandEnum.Add, Item = ic }); }
public static CategoryCollection LoadForVolumeDiscount(Int32 volumeDiscountId, int maximumRows, int startRowIndex, string sortExpression) { //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + Category.GetColumnNames("ac_Categories")); selectQuery.Append(" FROM ac_Categories, ac_CategoryVolumeDiscounts"); selectQuery.Append(" WHERE ac_Categories.CategoryId = ac_CategoryVolumeDiscounts.CategoryId"); selectQuery.Append(" AND ac_CategoryVolumeDiscounts.VolumeDiscountId = @volumeDiscountId"); selectQuery.Append(" AND StoreId = @storeId"); if (!string.IsNullOrEmpty(sortExpression)) { selectQuery.Append(" ORDER BY " + sortExpression); } Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); database.AddInParameter(selectCommand, "@volumeDiscountId", System.Data.DbType.Int32, volumeDiscountId); database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, Token.Instance.StoreId); //EXECUTE THE COMMAND CategoryCollection results = new CategoryCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { Category category = new Category(); Category.LoadDataReader(category, dr); results.Add(category); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
/// <summary> /// 取得树状的子类 /// </summary> /// <param name="keyword"></param> /// <returns></returns> public CategoryCollection GetAllChildrenByKeyword(string keyword) { return(CacheRecord.GetInstance <CategoryCollection>("GetAllChildrenByKeyword$" + keyword, () => { CategoryCollection result = new CategoryCollection(); List <Category> list = Assistant.List <Category>(new Criteria(CriteriaType.Equals, "KeyWord", keyword), new Order[] { new Order("Index"), new Order("ID", OrderMode.Asc) }); if (list != null && list.Count > 0) { list = GetCategoryByParentID(list[0].ID); foreach (Category c in list) { result.Add(c); LoadChildren(c); } } return result; })); }
/// <summary> /// Returns all categories except the uncategorized category /// </summary> /// <returns></returns> public CategoryCollection GetCachedCategories() { CategoryCollection cc = GetAllCachedCategories(); CategoryCollection cc2 = new CategoryCollection(); foreach (Category c in cc) { if (c.Name != UncategorizedName) { cc2.Add(c); } } cc2.Sort(delegate(Category c1, Category c2) { return(Comparer <string> .Default.Compare(c1.Name, c2.Name)); }); return(cc2); }
internal static IEnumerable GetAll(int languageId) { CategoryCollection list = null; string query = string.Format("SELECT * FROM Categories WHERE LanguageId = {0}", languageId); using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString)) { using (SqlCommand cmd = new SqlCommand(query, cnn)) { cmd.CommandType = CommandType.Text; cnn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader != null && reader.HasRows) { list = new CategoryCollection(); while (reader.Read()) { if (reader[0] != null) { Category option = new Category(); option.CategoryId = Convert.ToInt32(reader[0]); option.CategoryName = Convert.ToString(reader[3]); option.UrlName = Convert.ToString(reader[4]); list.Add(option); } } reader.Close(); } } cnn.Close(); } } return(list); }
private void GetFmtChildren(string parentId, CategoryCollection cats, string prefix) { List <Category> children = GetCategoryByParentID(parentId); for (int i = 0; i < children.Count; i++) { cats.Add(children[i]); if (i == children.Count - 1) { children[i].Name = prefix + "└" + children[i].Name; GetFmtChildren(children[i].ID, cats, prefix + " "); } else { children[i].Name = prefix + "├" + children[i].Name; GetFmtChildren(children[i].ID, cats, prefix + "│"); } } }
public static CategoryCollection LoadForCriteria(string sqlCriteria, int maximumRows, int startRowIndex, string sortExpression) { //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + Category.GetColumnNames(string.Empty)); selectQuery.Append(" FROM ac_Categories"); string whereClause = string.IsNullOrEmpty(sqlCriteria) ? string.Empty : " WHERE " + sqlCriteria; selectQuery.Append(whereClause); if (!string.IsNullOrEmpty(sortExpression)) { selectQuery.Append(" ORDER BY " + sortExpression); } Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); //EXECUTE THE COMMAND CategoryCollection results = new CategoryCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { Category category = new Category(); Category.LoadDataReader(category, dr); results.Add(category); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
private CategoryCollection GetTopLevelCachedCategories(bool filterUncategorized) { CategoryCollection cc = new CategoryCollection(); foreach (Category c in GetAllCachedCategories()) { if (c.ParentId <= 0) { if (filterUncategorized && c.Name == UncategorizedName) { continue; } cc.Add(c); } } cc.Sort(delegate(Category c1, Category c2) { return(Comparer <string> .Default.Compare(c1.Name, c2.Name)); }); return(cc); }
private void BindData(CategoryWidget widget) { txtTitle.Text = widget.Title; CategoryCollection cc = new CategoryController().GetTopLevelCachedCategories(); CategoryCollection InUse = new CategoryCollection(); CategoryCollection NotInUse = new CategoryCollection(); NotInUse.AddRange(cc); foreach (int i in widget.CategoryIds) { bool found = false; foreach (Category c in NotInUse) { if (i == c.Id) { InUse.Add(c); found = true; } } if (found) { NotInUse.Remove(InUse[InUse.Count - 1]); } } the_Categories.DataSource = NotInUse; the_Categories.DataBind(); existing_items.Items.Clear(); foreach (Category c in InUse) { existing_items.Items.Add(new OrderedListItem(string.Format(ItemFormat, c.Name, c.Id), c.Name, c.Id.ToString())); } }
private void BindData(CategoryWidget widget) { txtTitle.Text = widget.Title; CategoryCollection cc = new CategoryController().GetTopLevelCachedCategories(); CategoryCollection InUse = new CategoryCollection(); CategoryCollection NotInUse = new CategoryCollection(); NotInUse.AddRange(cc); foreach(int i in widget.CategoryIds) { bool found = false; foreach(Category c in NotInUse) { if(i == c.Id) { InUse.Add(c); found = true; } } if(found) { NotInUse.Remove(InUse[InUse.Count - 1]); } } the_Categories.DataSource = NotInUse; the_Categories.DataBind(); existing_items.Items.Clear(); foreach (Category c in InUse) { existing_items.Items.Add(new Telligent.Glow.OrderedListItem(string.Format(this.ItemFormat, c.Name, c.Id), c.Name, c.Id.ToString())); } }
private static void TestCategoryCollection() { Stopwatch stopwatch = new Stopwatch(); long time1 = stopwatch.TimeMillis(() => { CategoryCollection categoryCollection = new CategoryCollection(); Enumerable.Range(0, 1000000).ForEach(x => categoryCollection.Add("Kategoria", new NamedObject("Nazwa"))); }); long time2 = stopwatch.TimeMillis(() => { CategoryCollection categoryCollection = new CategoryCollection(); var itemsToAdd = Enumerable.Range(0, 1000000).Select(x => new NamedObject("Nazwa")); categoryCollection.AddRange("Kategoria", itemsToAdd); }); ConsoleUtils.WriteResult("Elementy dodane pojedynczo", time1); ConsoleUtils.WriteResult("Elementy dodane wszystkie naraz", time2); }
private static void PopulateProfilesCategory(CategoryCollection categories) { Category profCategory = new Category(Resources.Config_RoamingProfiles, Resources.Config_RoamingProfiles_Description); categories.Add(profCategory); CategoryItem item = new CategoryItem(Resources.Config_RoamingProfiles_NewProfile, Resources.Config_RoamingProfiles_NewProfile_Description, delegate { if (ProfileCreatingDialog.PresentModal() != null) MessageBox.Show(Resources.MsgBox_Text_ProfileCreated, Resources.MsgBox_Title_Completed, MessageBoxButtons.OK, MessageBoxIcon.Information); }); item.Image = Resources.Image_64x67_Add; profCategory.Items.Add(item); item = new CategoryItem(Resources.Config_RoamingProfiles_Manage, Resources.Config_RoamingProfiles_Manage_Description, typeof(ProfileManagement)); item.Image = Resources.Image_64x67_Profile; profCategory.Items.Add(item); item = new CategoryItem(Resources.Config_RoamingProfiles_DefaultProfile, Resources.Config_RoamingProfiles_DefaultProfile_Description, typeof(AutoProfileOptions)); item.Image = Resources.Image_64x67_Favourite; item.IsExpertOption = true; profCategory.Items.Add(item); }
protected void Page_Load(object sender, EventArgs e) { Current.checkLogin(); // Get the link out from the query string if (Request["linkurl"] != null) { _thisLink = new Link(Link.Columns.URLRewrite, Request["linkurl"]); } if (Request["linkid"] != null && _thisLink == null) { _thisLink = new Link(ubConvert.ToInt(Request["linkid"], 0)); } // If, no link? Return to the root // See if user own this link or not // If user's an admin, he has all power if ((_thisLink == null) || (_thisLink.Poster != VL.Current.User.UserID && VL.Current.User.SecurityLevel < 5)) { Response.Redirect(Config.GetConfigPath("Root"), true); } // We have to keep the form value if (!this.IsPostBack) { // If found link, insert the information here txtInputTitle.Text = _thisLink.Title; TxtInputDescription.Text = _thisLink.Description; // Need to get the category out CatLink catLink = new CatLink(CatLink.Columns.LinkID, _thisLink.LinkID); CategoryCollection listCat = new CategoryCollection(); listCat.Add(Category.Get(catLink.CategoryID)); UcCategorySelectionList1.SelectedCategory = listCat; } UcCategorySelectionList1.GenerateList(); }
protected override void HandleRequest(IGraffitiUser user, XmlTextWriter writer) { switch (Context.Request.HttpMethod.ToUpper()) { case "GET": CategoryController controller = new CategoryController(); CategoryCollection cc = null; int count = 1; if(Request.QueryString["id"] != null) { Category category = controller.GetCachedCategory(Int32.Parse(Request.QueryString["id"]), false); cc = new CategoryCollection(); cc.Add(category); } else if (Request.QueryString["name"] != null) { Category category = controller.GetCachedCategory(Request.QueryString["name"], false); cc = new CategoryCollection(); cc.Add(category); } else { cc = controller.GetAllTopLevelCachedCategories(); count = controller.GetAllCachedCategories().Count; } writer.WriteStartElement("categories"); writer.WriteAttributeString("pageIndex", "1"); writer.WriteAttributeString("pageSize", count.ToString() ); writer.WriteAttributeString("totalCategories", count.ToString()); foreach(Category category in cc) { WriteCategoryToXML(category, writer); } writer.WriteEndElement(); writer.Close(); break; case "POST": XmlDocument doc = new XmlDocument(); doc.Load(Request.InputStream); if (Request.Headers["Graffiti-Method"] != "DELETE") { if (GraffitiUsers.IsAdmin(user)) { string xml = CreateUpdateCategory(doc); writer.WriteRaw(xml); } else { UnuathorizedRequest(); } } else { XmlAttribute categoryIdAttribute = doc.SelectSingleNode("/category").Attributes["id"]; foreach (Post p in PostCollection.FetchAll()) { if (p.CategoryId == Int32.Parse(categoryIdAttribute.Value)) { if (p.IsDeleted) { Post.DestroyDeletedPost(p.Id); } else { Response.StatusCode = 500; writer.WriteRaw("<error>You can not delete a category that contains post.</error>"); return; } } } Category.Destroy(Int32.Parse(categoryIdAttribute.Value)); CategoryController.Reset(); writer.WriteRaw("<result id=\"" + Int32.Parse(categoryIdAttribute.Value) + "\">deleted</result>"); } break; default: break; } }
protected override void HandleRequest(IGraffitiUser user, XmlTextWriter writer) { switch (Context.Request.HttpMethod.ToUpper()) { case "GET": CategoryController controller = new CategoryController(); CategoryCollection cc = null; int count = 1; if (Request.QueryString["id"] != null) { Category category = controller.GetCachedCategory(Int32.Parse(Request.QueryString["id"]), false); cc = new CategoryCollection(); cc.Add(category); } else if (Request.QueryString["name"] != null) { Category category = controller.GetCachedCategory(Request.QueryString["name"], false); cc = new CategoryCollection(); cc.Add(category); } else { cc = controller.GetAllTopLevelCachedCategories(); count = controller.GetAllCachedCategories().Count; } writer.WriteStartElement("categories"); writer.WriteAttributeString("pageIndex", "1"); writer.WriteAttributeString("pageSize", count.ToString()); writer.WriteAttributeString("totalCategories", count.ToString()); foreach (Category category in cc) { WriteCategoryToXML(category, writer); } writer.WriteEndElement(); writer.Close(); break; case "POST": XmlDocument doc = new XmlDocument(); doc.Load(Request.InputStream); if (Request.Headers["Graffiti-Method"] != "DELETE") { if (GraffitiUsers.IsAdmin(user)) { string xml = CreateUpdateCategory(doc); writer.WriteRaw(xml); } else { UnuathorizedRequest(); } } else { XmlAttribute categoryIdAttribute = doc.SelectSingleNode("/category").Attributes["id"]; foreach (Post p in PostCollection.FetchAll()) { if (p.CategoryId == Int32.Parse(categoryIdAttribute.Value)) { if (p.IsDeleted) { Post.DestroyDeletedPost(p.Id); } else { Response.StatusCode = 500; writer.WriteRaw("<error>You can not delete a category that contains post.</error>"); return; } } } Category.Destroy(Int32.Parse(categoryIdAttribute.Value)); CategoryController.Reset(); writer.WriteRaw("<result id=\"" + Int32.Parse(categoryIdAttribute.Value) + "\">deleted</result>"); } break; default: break; } }
/// <summary> /// 板一覧を指定したURLでアップデート /// </summary> /// <param name="url"></param> public void OnlineUpdate(string url) { BoardTableUpdateEventArgs e = new BoardTableUpdateEventArgs(); e.LastModified = lastModified; try { InternetClient.DownloadResult result = InternetClient.DownloadData(url, lastModified); if (!result.Success) { OnOnlineUpdated(e); return; } e.LastModified = result.LastModified; CategoryCollection categories = new CategoryCollection(); string[] maybeCategoryTexts = Regex.Split(result.Data, @"^\s*${3,}?", RegexOptions.Multiline); foreach (string maybeCategoryText in maybeCategoryTexts) { Match categoryName = CategoryNamePattern.Match(maybeCategoryText); if (!categoryName.Success) { continue; } Category item = new Category(categoryName.Groups["category"].Value); foreach (Match boardMatch in BoardPattern.Matches(maybeCategoryText)) { BoardInfo info = ThreadUtility.ParseBoardInfo(boardMatch.Groups["url"].Value, item.Name); if (info != null) { info.Name = boardMatch.Groups["subject"].Value; item.Children.Add(info); IBoardInfo oldInfo = FindFromName(info.Name, info.DomainPath); if (oldInfo != null) { Replace(oldInfo, info); } } } if (item.Children.Count > 0) { categories.Add(item); } } if (categories.Count <= 0) { throw new ApplicationException("板一覧の更新に失敗しました"); } this.Clear(); foreach (Category category in categories) { Add(category); } e.Updated = true; } catch (System.Net.WebException ex) { if (ex.Status == WebExceptionStatus.ProtocolError) { HttpWebResponse errorResponse = (HttpWebResponse)ex.Response; if (ContinueStatuses.Contains(errorResponse.StatusCode)) { e.Message = ex.Message; } else if (HttpStatusCode.NotModified != errorResponse.StatusCode) { throw; } } else//プロトコルエラー以外の例外 { e.Message = ex.Message; } } OnOnlineUpdated(e); }
private static void PopulateGeneralCategory(CategoryCollection categories) { Category genCategory = new Category(Resources.Config_General, Resources.Config_General_Behaviour_Description); categories.Add(genCategory); CategoryItem item = new CategoryItem(Resources.Config_General_About, Resources.Config_General_About_Description, typeof(AboutInformation)); item.Image = Resources.Image_64x67_Information; genCategory.Items.Add(item); item = new CategoryItem(Resources.Config_General_Behaviour, Resources.Config_General_Behaviour_Description, typeof(BehaviourOptions)); item.Image = Resources.Image_64x67_Settings; genCategory.Items.Add(item); item = new CategoryItem(Resources.Config_General_Proxy, Resources.Config_General_Proxy_Description, typeof(ProxyOptions)); item.Image = Resources.Image_64x67_Web; genCategory.Items.Add(item); }
/// <summary> /// 绑定树 /// </summary> private void BindTree() { string tempKeyword = Keyword; if (string.IsNullOrEmpty(Keyword)) { tempKeyword = Request["cat"]; } HtmlData = CategoryHelper.CacheRecord.GetInstance <string>("We7.CMS.WebControls.CategoryTreeProvider_" + tempKeyword, () => { StringBuilder sb = new StringBuilder(""); CategoryCollection Categorys = null; if (String.IsNullOrEmpty(Keyword)) { Category cat = CategoryHelper.GetTopAndSiblingByKeyword(Request["cat"]); Categorys = new CategoryCollection(); Categorys.Add(cat); } else { Categorys = new CategoryCollection(); Categorys.Add(CategoryHelper.GetCategoryByKeyword(Keyword)); } bool displayParent = false; for (int i = 0; i < Categorys.Count; i++) { Category ch = Categorys[i]; List <Category> CategoryList = CategoryHelper.GetCategoryByParentID(ch.ID); if (CategoryList != null && CategoryList.Count > 0) { bool isFind = false; for (int j = 0; j < lsCategorys.Count; j++) { if (lsCategorys[j].ID == ch.ID) { isFind = true; break; } } if (isFind) { if (CurrentCategory != null && ch.ID == CurrentCategory.ID) { sb.Append("<li><span class=\"folder TreeMenuTwoProviderCurrent\">" + GetHref(ch.KeyWord, ch.Name, true) + "</span>"); } else { sb.Append("<li><span class=\"folder\">" + GetHref(ch.KeyWord, ch.Name, true) + "</span>"); } } else { sb.Append("<li><span class=\"folder\">" + GetHref(ch.KeyWord, ch.Name, true) + "</span>"); } GetAllChildCategory(sb, ch.ID); } else { //if (CurrentCategory != null && ch.ID == CurrentCategory.ID) //{ // sb.Append("<li><span class=\"file TreeMenuTwoProviderCurrent\"><a href='" + ch.FullUrl + "'>" + ch.Name + "</a></span>"); //} //else //{ sb.Append("<li><span class=\"file\">" + GetHref(ch.KeyWord, ch.Name, false) + "</span>"); //} } sb.Append("</li>"); } if (displayParent) { sb.Append("</ul></li>"); } sb.Append("<script>$(function(){$('#" + this.ClientID + "').treeview({unique:true});});</script>").ToString(); return(sb.ToString()); }); }
public void SelectByCategory (int typeItem) { CategoryCollection.Add (typeItem); }