private void btnUpdateCounts_Click(object sender, EventArgs e) { int numForums = 0; int numTopics = 0; int numPosts = 0; CategoryCollection categories = RepositoryRegistry.CategoryRepository.GetAll(); foreach (Category category in categories) { numForums += category.Forums.Count; foreach (Forum forum in category.Forums) { forum.TopicCount = forum.Topics.Count; numTopics += forum.TopicCount; forum.PostCount = 0; foreach (Topic topic in forum.Topics) { forum.PostCount += topic.Messages.Count; numPosts += forum.PostCount; } RepositoryRegistry.ForumRepository.Save(forum); } } WebPartParent.TopicCount = numTopics; WebPartParent.ForumCount = numForums; WebPartParent.PostCount = numPosts; WebPartParent.PersistProperties(); }
/// <summary> /// foamliu, 2009/04/15, 生成样本. /// </summary> /// <param name="set"></param> private static ExampleSet GetExamples(CategoryCollection collect) { const int Rows = 4; const int Columns = 4; const int CellWidth = 100; const int CellHeight = 100; const int ExampleNumber = 640; ExampleSet set = new ExampleSet(); set.Examples.Clear(); Random rand = new Random(); for (int i = 0; i < ExampleNumber; i++) { int x = (int)(rand.NextDouble() * Columns * CellWidth); int y = (int)(rand.NextDouble() * Rows * CellHeight); Example e = new Example(); e.X = new SparseVector(2); e.X[0] = x; e.X[1] = y; e.Label = collect.GetCategoryById( GetCat(x, y, CellWidth, CellHeight)); set.AddExample(e); } return(set); }
public Binary_SVM_GradientDescent(CategoryCollection collect) { m_categoryCollection = collect; // It was said that for text classification, linear kernel is the best choice, // because of the already-high-enough feature dimension m_kernel = new LinearKernel(); }
private void DisplayCategory() { Controls.Add(new LiteralControl("<table width=100% cellspacing=0 cellpadding=3>")); Controls.Add(new LiteralControl("<tr>")); Controls.Add(new LiteralControl("<td width=1% class=\"ms-ToolPaneTitle\"> </td>")); Controls.Add(new LiteralControl("<td align=left class=\"ms-ToolPaneTitle\">Forum</td>")); Controls.Add(new LiteralControl("<td align=center width=7% class=\"ms-ToolPaneTitle\">Topics</td>")); Controls.Add(new LiteralControl("<td align=center width=7% class=\"ms-ToolPaneTitle\">Posts</td>")); Controls.Add(new LiteralControl("<td align=center width=25% class=\"ms-ToolPaneTitle\">Last Post</td>")); Controls.Add(new LiteralControl("</tr>")); UserSession session = GetSession(); CategoryCollection categories = session.UserCategories; foreach (Category category in categories) { string categoryName = category.Name; int categoryId = category.Id; if (category.HasAccess(ForumApplication.Instance.CurrentUser, Permission.Rights.Read)) { Controls.Add(new LiteralControl("<tr>")); string link = ForumApplication.Instance.GetLink(SharePointForumControls.ViewForums, "category={0}", categoryId); Controls.Add(new LiteralControl(string.Format("<td class=\"ms-TPHeader\" colspan=5><a href=\"{0}\"><strong>{1}</strong></a></td>", link, categoryName))); Controls.Add(new LiteralControl("</tr>")); ForumCollection forumCollection = category.Forums; if (forumCollection.Count > 0) { DisplayForum(forumCollection); } } } Controls.Add(new LiteralControl("</table>")); }
private void AppendChildren(Category parent, ref StringBuilder html) { string rootCss = ""; List <Category> childCategories; if (parent == null) { //childCategories = RootCategories; childCategories = CategoryCollection.GetTopLevelCategories(storeId, IncludeHiddenCategories); rootCss = CssClassForOuterList; } else { childCategories = parent.GetChildCategoriesInSortedOrder(IncludeHiddenCategories).ToList(); } if (childCategories.Count > 0) { html.AppendFormat("<{0}{1}>", containingElementTag, !string.IsNullOrEmpty(rootCss) ? " class=\"" + rootCss + "\"" : ""); foreach (Category child in childCategories) { html.AppendFormat(@"<{0} id=""{1}""{2}>{3}", itemElementTag, htmlPrefixCategoryId + child.Id, GetCategoryCssAttribute(child), GetCategoryName(child)); if (!MaxNestingLevel.HasValue || (child.NestingLevel.Value < MaxNestingLevel.Value)) { AppendChildren(child, ref html); } html.AppendFormat("</{0}>", itemElementTag); } html.AppendFormat("</{0}>", containingElementTag); } }
protected override void OnDataShow() { base.OnDataShow(); CategoryCollection categoryList = new CategoryCollection(); this.cmbCategory.DataSource = categoryList; this.cmbCategory.DisplayMember = "DisplayName"; this.cmbCategory.Select(); if (!Objectbase.IsNullOrEmpty(this.mEntry)) { this.CheckPermission(); if (!this.mEntry.IsNew) { this.cmbCategory.Enabled = this.cmbCompany.Enabled = this.cmbItem.Enabled = false; } this.cmbCategory.SelectedItem = this.mEntry.Category as Category; this.cmbCompany.SelectedItem = this.mEntry.Company as Company; this.cmbItem.SelectedItem = this.mEntry.Item as Item; this.cmbBillType.SelectedIndex = !string.IsNullOrEmpty(this.mEntry.BillType) ? cmbBillType.FindStringExact(this.mEntry.BillType.ToString()) : 0; this.nupQuantity.Value = this.mEntry.Quantity; this.nupWholeSaleRate.Value = this.mEntry.WholesaleRate; this.numAmount.Value = this.mEntry.Amount; if (!string.IsNullOrEmpty(this.mEntry.ExpiryDate.ToString()) && (this.mEntry.ExpiryDate != DateTime.MinValue)) { this.dtpExpiryDate.Value = mEntry.ExpiryDate; } this.numMRP.Value = this.mEntry.MRP; } }
private void FillListControls() { RoleController roleController = new RoleController(); List <RoleInfo> roleInfos = roleController.GetPortalRoles(PortalId).ToList <RoleInfo>(); ddlDnnRole.DataSource = roleInfos; ddlDnnRole.DataValueField = "RoleID"; ddlDnnRole.DataTextField = "RoleName"; ddlDnnRole.DataBind(); ddlDnnRole.Items.Insert(0, new ListItem() { Value = "-1", Text = "All Users" }); ddlDnnRole.Items.Insert(0, ""); List <Product> products = ProductCollection.GetAll(StoreContext.CurrentStore.Id.Value); chkAppliesToProducts.DataSource = products; chkAppliesToProducts.DataValueField = ProductMetadata.PropertyNames.Id; chkAppliesToProducts.DataTextField = ProductMetadata.PropertyNames.Name; chkAppliesToProducts.DataBind(); List <Category> categories = CategoryCollection.GetCategoryList(StoreContext.CurrentStore.Id.Value, true); chkAppliesToCategories.Items.Clear(); foreach (var c in categories) { string indent = "...".Repeat(c.NestingLevel.GetValueOrDefault(0)); chkAppliesToCategories.Items.Add(new ListItem() { Value = c.Id.ToString(), Text = indent + c.Name }); } }
protected void tree_GetChildrenData(DeluxeTreeNode parentNode, DeluxeTreeNodeCollection result, string callBackContext) { string cssclass = parentNode.CssClass; CategoryCollection root = CategoryAdapter.Instance.GetByParentCode(parentNode.Value); foreach (var item in root) { DeluxeTreeNode node = new DeluxeTreeNode(item.DisplayName, item.Code); if (IsLastNode(item.Code)) { node.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal; node.CssClass = "treeNodeThree"; node.Expanded = true; } else { node.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.LazyLoading; } node.NodeCloseImg = "../../../Images/wenjianjia.gif"; node.NodeOpenImg = "../../../Images/wenjianjia.gif"; result.Add(node); } }
public CategoryCollection GetCollection() { string str = textBox1.Text; CategoryCollection collection = _serializer.Deserialize(str); return(collection); }
private void ShowCollection(CategoryCollection collection) { string str = _serializer.Serialize(collection); textBox1.Text = str; _original = str; }
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()); }
private void ChangeCategoryMap(SiteMapResolveEventArgs e, SiteMapNode currentNode) { try { SiteMapNode tempNode = currentNode; Category category = CategoryManager.GetCategoryByID(CategoryId); if (0 != CategoryId) { tempNode.Url = SEOHelper.GetCategoryURL(category.CategoryID); CategoryCollection categCollection = CategoryManager.GetBreadCrumb(category.CategoryID); string categoryPath = categCollection.Aggregate(String.Empty, (current, c) => current + String.Format( String.IsNullOrEmpty(current) ? "{0}" : "/{0}", c.Name)); tempNode.Title = categoryPath; tempNode.Description = categoryPath; } } catch { } }
private static CategoryCollection getCategoriesByTitleFilteringToOne(List<Category> currentCategories, Category[] sourceCategories) { CategoryCollection result = new CategoryCollection(); var sourceTitles = sourceCategories.Select(cat => cat.CategoryName).ToArray(); var categoriesToSet = sourceTitles.Select(title => currentCategories.FirstOrDefault(cat => cat.Title == title)) .Where(cat => cat != null); result.CollectionContent.AddRange(categoriesToSet); if (result.CollectionContent.Count > 1) { bool removeProject = false; bool removeNews = false; if (result.CollectionContent.Any(cat => cat.Title == "Events")) { removeProject = true; removeNews = true; } if (result.CollectionContent.Any(cat => cat.Title == "Projects")) { removeNews = true; } result.CollectionContent.RemoveAll(cat => { if ((cat.Title == "News" && removeNews) || (cat.Title == "Projects" && removeProject)) return true; return false; }); } return result; }
public CategoryCollection FetchAll() { CategoryCollection coll = new CategoryCollection(); Query qry = new Query(Category.Schema); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
public OrderControl() { InitializeComponent(); ListTempItem = new List <TempOrderItem>(); dgvOrderItem.AutoGenerateColumns = false; dgvCategory.AutoGenerateColumns = false; var listCategory = new CategoryCollection().Where(Category.Columns.Active, true).Load(); dgvCategory.DataSource = listCategory; ListProduct = new ProductCollection().Where(Product.Columns.Active, true).Load().ToList(); cmbSearch.DataSource = ListProduct; cmbSearch.DisplayMember = "IdName"; cmbSearch.ValueMember = "Id"; cmbSearch.AutoCompleteMode = AutoCompleteMode.SuggestAppend; cmbSearch.AutoCompleteSource = AutoCompleteSource.ListItems; txtOrderNote.Text = Utilities.orderNote == null ? "" : Utilities.orderNote.Note; var ListCustomer = new CustomerCollection().Where(Customer.Columns.Active, true).Load().OrderBy(c => c.Name).ToList(); dgvCustomer.AutoGenerateColumns = false; dgvCustomer.DataSource = ListCustomer; }
public void Save(CategoryCollection collection) { foreach (Category category in collection) { _dao.Save(category); } }
public ProductCategoriesCheckedListBox(ApplicationProduct product) { this.selectedItems = new CategoryCollection(); this.Product = product; this.FormattingEnabled = true; this.Size = new System.Drawing.Size(180, 130); }
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; }
void Initialize() { _rawCollection = LocalDataManager.Instance.GetConfig <CategoryCollection>(typeof(CrossPromoData).Name); _collection = new JArray(_rawCollection.Collections); PromoData = _collection.TryAndFindList <CrossPromoData>(x => x != null); }
private static List <ProbabilityScoreIndex> IdentifyLemmaConformation(IEnumerable <string> command, IEnumerable <CommandType> highestProbableCommands) { try { var identifiedCategoryCollection = new List <CategoryCollection>(); foreach (var highestProbableCommand in highestProbableCommands) { var categoryCollection = new CategoryCollection { Name = highestProbableCommand.ToString(), Category = Conversions.ConvertEnumToInt( Conversions.ConvertStringToEnum <CommandType>(highestProbableCommand.ToString())) }; var splittedCommand = highestProbableCommand.ToString().Split('_'); var newSplittedCommandList = splittedCommand.Where(cmd => !String.IsNullOrEmpty(cmd)).ToList(); categoryCollection.List = newSplittedCommandList; identifiedCategoryCollection.Add(categoryCollection); } List <ProbabilityScoreIndex> probabilityScoreIndices; new NaiveCommandCategorization(identifiedCategoryCollection).CalculateProbabilityOfSegments(command, false, out probabilityScoreIndices); return(new NaiveCommandCategorization().GetHighestProbabilityScoreIndeces(probabilityScoreIndices)); } catch (Exception ex) { Log.ErrorLog(ex); throw; } }
/// <summary> /// Fetches the associated categories by product id. /// </summary> /// <param name="productId">The product id.</param> /// <returns></returns> public CategoryCollection FetchAssociatedCategoriesByProductId(int productId) { IDataReader reader = SPs.FetchAssociatedCategoriesByProductId(productId).GetReader(); CategoryCollection categoryCollection = new CategoryCollection(); categoryCollection.LoadAndCloseReader(reader); return categoryCollection; }
protected void CreateMenu() { CategoryCollection breadCrumb = null; var currentCategory = CategoryManager.GetCategoryById(CommonHelper.QueryStringInt("CategoryId")); if (currentCategory == null) { var product = ProductManager.GetProductById(CommonHelper.QueryStringInt("ProductId")); if (product != null) { var productCategories = product.ProductCategories; if (productCategories.Count > 0) { currentCategory = productCategories[0].Category; } } } if (currentCategory != null) { breadCrumb = CategoryManager.GetBreadCrumb(currentCategory.CategoryId); } else { breadCrumb = new CategoryCollection(); } CreateChildMenu(breadCrumb, 0, currentCategory, 0); }
// Insert Catagory : American // hard code parentCatagory private static int InsertCatagory(string catagoryName) { try { catagoryName = catagoryName.TrimStart().TrimEnd(); Category category; CategoryCollection coll = CategoryManager.GetAllCategories(92, true, 7); if (coll != null && coll.Count > 0) { foreach (Category c in coll) { if (c.Name.ToLower().Equals(catagoryName.ToLower())) { return(c.CategoryId); } } } // Save catagory category = CategoryManager.InsertCategory(catagoryName, catagoryName, 3, string.Empty, string.Empty, string.Empty, string.Empty, 92, 0, 10, string.Empty, false, true, false, 1, DateTime.Now, DateTime.Now); category = CategoryManager.UpdateCategory(category.CategoryId, category.Name, category.Description, category.TemplateId, string.Empty, string.Empty, string.Empty, string.Empty, category.ParentCategoryId, category.PictureId, 10, category.PriceRanges, category.ShowOnHomePage, category.Published, category.Deleted, category.DisplayOrder, category.CreatedOn, DateTime.Now); return(category.CategoryId); } catch (Exception ex) { Console.WriteLine(catagoryName + " InsertCatagory Error: " + ex.Message); tempBuilder.Append(catagoryName + " -- InsertCatagory Error " + ex.Message + System.Environment.NewLine); return(-1); } }
protected void CreateChildMenu(CategoryCollection breadCrumb, int rootCategoryId, Category currentCategory, int level) { int padding = level++ *15; foreach (var category in CategoryManager.GetAllCategories(rootCategoryId)) { var link = new NopCommerceLi(); phCategories.Controls.Add(link); string categoryURL = SEOHelper.GetCategoryUrl(category.CategoryId); if (currentCategory != null && currentCategory.CategoryId == category.CategoryId) { link.CssClass = "active"; } else { link.CssClass = "inactive"; } link.HyperLink.NavigateUrl = categoryURL; link.HyperLink.Text = Server.HtmlEncode(category.Name); if (padding > 0) { link.LiLeftMargin = padding.ToString(); } for (int i = 0; i <= breadCrumb.Count - 1; i++) { if (breadCrumb[i].CategoryId == category.CategoryId) { CreateChildMenu(breadCrumb, category.CategoryId, currentCategory, level); } } } }
/// <summary> /// Handles the <see cref="CustomValidator.ServerValidate"/> event of the <c>UniqueNameValidator</c> control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="args">The <see cref="ServerValidateEventArgs"/> instance containing the event data.</param> protected void UniqueNameValidator_ServerValidate(object source, ServerValidateEventArgs args) { var gridItem = Engage.Utility.FindParentControl <GridDataItem>((CustomValidator)source); var categoryId = gridItem.ItemIndex >= 0 ? (int)gridItem.OwnerTableView.DataKeyValues[gridItem.ItemIndex]["Id"] : -1; args.IsValid = !CategoryCollection.Load(this.PortalId).Any(category => category.Id != categoryId && category.Name.Equals(args.Value, StringComparison.CurrentCultureIgnoreCase)); }
private void GetCategories() { cats = new CategoryController().GetCachedCategories(); var parents = cats.FindAll( delegate(Category c) { return(c.ParentId >= 0); }); if (cats != null && cats.Count > 0) { Category_List.Visible = true; CategoryCollection source = new CategoryController().GetTopLevelCachedCategories(); source.Sort( delegate(Category c, Category c1) { return(c.Name.CompareTo(c1.Name)); }); Categories_List.DataSource = source; Categories_List.ItemDataBound += Categories_List_ItemDataBound; Categories_List.DataBind(); } else { Category_List.Visible = false; } }
/// <summary> /// Raises the <see cref="Control.Init"/> event. /// </summary> /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param> protected override void OnInit(EventArgs e) { if (!this.PermissionsService.CanManageCategories) { this.DenyAccess(); } base.OnInit(e); this.Load += this.Page_Load; this.CategoriesGrid.ColumnCreated += this.CategoriesGrid_ColumnCreated; this.CategoriesGrid.DeleteCommand += this.CategoriesGrid_DeleteCommand; this.CategoriesGrid.ItemCreated += this.CategoriesGrid_ItemCreated; this.CategoriesGrid.NeedDataSource += this.CategoriesGrid_NeedDataSource; this.CategoriesGrid.InsertCommand += this.CategoriesGrid_InsertCommand; this.CategoriesGrid.UpdateCommand += this.CategoriesGrid_UpdateCommand; this.CategoriesGrid.ItemDataBound += this.CategoriesGrid_ItemDataBound; this.PreRender += (s, o) => this.HideExpandColumnRecursive(this.CategoriesGrid.MasterTableView); this.parentCategories = CategoryCollection.Load(this.PortalId); foreach (var category in this.parentCategories.Where(c => string.IsNullOrEmpty(c.Name))) { category.Name = this.GetDefaultCategoryName(); } }
/// <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 void BindingCategory() { try { CategoryCollection col = null; col = this.LoadCategory(txtSearch.Text.Trim(), Convert.ToInt32(ddlHandleCategoryID.SelectedValue)); if (col == null) { col = new CategoryCollection(); // lblCount.Text = "Có 0" + " record"; rptData.DataSource = col; rptData.DataBind(); } else { lblcount.Text = "Có " + col.Count.ToString() + " record"; lblcount.ForeColor = System.Drawing.Color.Blue; anpPager.RecordCount = col.Count; anpPager.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); anpPager.ShowFirstLast = false; col = this.GetSubData(col, anpPager.StartRecordIndex - 1, anpPager.EndRecordIndex); rptData.DataSource = col; rptData.DataBind(); } } catch (Exception ex) { Global.WriteLogError("BindingCategory()" + ex); } }
protected override void OnDataShow() { base.OnDataShow(); this.CheckPermission(); this.Text = "Manage Patient Medicine"; CategoryCollection categoryList = new CategoryCollection(); this.cmbCategory.DataSource = categoryList; this.cmbCategory.DisplayMember = "DisplayName"; CompanyCollection companyList = new CompanyCollection(); this.cmbCompany.DataSource = companyList; this.cmbCompany.DisplayMember = "DisplayName"; cmbPatientType.Select(); if (this.mPatientBill.Patient != null) { if (this.mPatientBill.Patient.IsIPD) { this.cmbPatientType.SelectedItem = "I.P.D"; } else if (this.mPatientBill.Patient.IsOPD) { this.cmbPatientType.SelectedItem = "O.P.D"; } //else // this.cmbPatientType.SelectedItem = "Other"; } if (!string.IsNullOrEmpty(this.mPatientBill.Other)) { this.cmbPatientType.SelectedItem = "Other"; this.txtOtherPatientName.Text = this.mPatientBill.Other; lblOtherPatientName.Visible = txtOtherPatientName.Visible = true; cmbPatient.Visible = lblPatient.Visible = false; } this.cmbPatient.SelectedItem = this.mPatientBill.Patient != null ? this.mPatientBill.Patient as Patient : null; this.txtOtherPatientName.Text = this.mPatientBill.Other; this.dtpBillDate.Value = this.mPatientBill.PatientBillDate != DateTime.MinValue ? this.mPatientBill.PatientBillDate : DateTime.Now.Date; LoadPatientAllMedicine(GetSelectedProcedure(this.dgvData)); if (isPatientMedicineSaleEdit) { this.cmbCategory.SelectedItem = mEntry.Category; this.cmbCompany.SelectedItem = mEntry.Company; this.cmbItem.SelectedItem = mEntry.Item; this.nupQuantity.Value = mEntry.Quantity; this.nupAmount.Value = mEntry.Amount; this.txtNotes.Text = mEntry.Note; } else { this.cmbCategory.SelectedItem = this.cmbCompany.SelectedItem = this.cmbItem.SelectedItem = null; } }
private void DeleteCategory(object param) { commandBuffer.Add(new Helpers.CategoryCommand <InvoiceCategory> { CommandType = Helpers.CommandEnum.Remove, Item = SelectedInvoiceCategory }); CategoryCollection.Remove(SelectedInvoiceCategory); }
public Category(object key, string text, params Category[] subcategories) { this.Key = key; this.Content = (object)text; this._children = new CategoryCollection((IEnumerable<Category>)subcategories); this._children.CollectionChanged += new NotifyCollectionChangedEventHandler(this.Subcategories_CollectionChanged); this._children.CollectionResetting += new EventHandler(this.Children_CollectionResetting); }
private void DeleteCategory(object param) { commandBuffer.Add(new Helpers.CategoryCommand <BuildingChargeBasisCategory> { CommandType = Helpers.CommandEnum.Remove, Item = SelectedCostCategory }); CategoryCollection.Remove(SelectedCostCategory); }
/// <summary> /// Loads the category info into the static CategoryList /// </summary> public static void Load() { catList = new CategoryCollection(); IDataReader rdr = Category.FetchAll(OrderBy.Asc("listOrder")); catList.Load(rdr); rdr.Close(); }
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); }
private ConfigurationDialog() { InitializeComponent(); ((RibbonStyle.TabStripProfessionalRenderer)RibbonStrip.Renderer).HaloColor = Color.FromArgb(254, 209, 94); ((RibbonStyle.TabStripProfessionalRenderer)RibbonStrip.Renderer).BaseColor = Color.FromArgb(215, 227, 242); categories = new CategoryCollection(); ConfigurableEntities = new List<ConfigurableEntityDescriptor>(5); }
internal static CategoryCollectionWrapper GetInstance() { CategoryCollection real = default(CategoryCollection); RealInstanceFactory(ref real); var instance = (CategoryCollectionWrapper) CategoryCollectionWrapper.GetWrapper(real); InstanceFactory(ref instance); if (instance == null) Assert.Inconclusive("Could not Create Test Instance"); return instance; }
public CategoryCollection GetMainCategories() { CategoryCollection categories = new CategoryCollection(); PredicateExpression filter = new PredicateExpression(); filter.Add(new FieldCompareNullPredicate(CategoryFields.BaseCategoryId)); categories.GetMulti(filter); return categories; }
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); }
internal static void Update_Activity_CategoryCollection(Activity activity, CategoryCollection localCollection, CategoryCollection masterCollection) { if (localCollection == null) { activity.CategoryCollection = CategoryCollection.CreateDefault(); localCollection = activity.CategoryCollection; } localCollection.CollectionContent = masterCollection.CollectionContent; if (localCollection.OrderFilterIDList == null) localCollection.OrderFilterIDList = new List<string>(); }
public void Delete(long Id, ref IAuctionTransaction trans) { using (var records = new CategoryCollection()) { var filter = new PredicateExpression(CategoryFields.Id == Id); if (trans != null) { trans.Add(records); } records.DeleteMulti(filter); } }
internal static IEnumerable<ShortTextObject> getCategoryCollectionTexts(CategoryCollection categoryCollection, Func<Category, string> categoryToStringFunc) { return categoryCollection.GetIDSelectedArray() .Select(category => { var textShort = ShortTextObject.CreateDefault(); //textShort.Content = category.CategoryName; textShort.Content = categoryToStringFunc(category); return textShort; }) .OrderBy(text => text.Content); }
public IList<Category> GetByAccount(long accountId, ref IAuctionTransaction trans) { using (var records = new CategoryCollection()) { var filter = new PredicateExpression(CategoryFields.AccountId == accountId); if (trans != null) { trans.Add(records); } records.GetMulti(filter, 0); return records.ToList().Select(c => new Category() { Id = c.Id, Name = c.Name, AccountId = c.AccountId }).ToList(); } }
public Category Get(long Id, ref IAuctionTransaction trans) { using (var records = new CategoryCollection()) { var filter = new PredicateExpression(CategoryFields.Id == Id); if (trans != null) { trans.Add(records); } records.GetMulti(filter, 1); var c = records.ToList().FirstOrDefault(); return new Category() { Id = c.Id, Name = c.Name, AccountId = c.AccountId}; } }
public static CategoryCollection GetCategories(int hostID) { CacheManager<string, CategoryCollection> categoryCache = GetCache(); string cacheKey = String.Format("KickCategories_{0}", hostID); CategoryCollection categories = categoryCache[cacheKey]; if (categories == null) { categories = new CategoryCollection(); SubSonic.OrderBy orderBy = SubSonic.OrderBy.Asc(Category.Columns.Name); categories.LoadAndCloseReader(Category.FetchByParameter(Category.Columns.HostID, hostID, orderBy)); categoryCache.Insert(cacheKey, categories, CacheHelper.CACHE_DURATION_IN_SECONDS); } return categories; }
public Contracts.GenericListResult<Contracts.GenericReference> GetSmallGroupCategories() { Contracts.GenericListResult<Contracts.GenericReference> list = new Contracts.GenericListResult<Contracts.GenericReference>(); CategoryCollection categories = new CategoryCollection(); list.Items = new List<Contracts.GenericReference>(); list.Total = categories.Count; list.Max = list.Total; list.Start = 0; foreach (Category category in categories) { list.Items.Add(new Contracts.GenericReference(category)); } return list; }
public void Update(ref Category category, ref IAuctionTransaction trans) { using (var records = new CategoryCollection()) { var filter = new PredicateExpression(CategoryFields.Id == category.Id); var c = new CategoryEntity { AccountId = category.AccountId, Name = category.Name }; if (trans != null) { trans.Add(records); } records.UpdateMulti(c, filter); } }
/// <summary> /// Generate the list of all categories /// </summary> private void GenerateCatList() { pnlCatList.Controls.Clear(); ddlParentCat.Items.Clear(); //Get List of all categories CategoryCollection AllCats = new CategoryCollection().Where("parent", null); AllCats.Load(); // Add the null value in there ddlParentCat.Items.Add(new ListItem("_", "NULL")); for (int i = 0; i < AllCats.Count; i++) { VL.Controls.CommonControl newParentCat = (VL.Controls.CommonControl)LoadControl(VL.Config.GetConfigPath("CatEditItem")); newParentCat.initControl(AllCats[i]); pnlCatList.Controls.Add(newParentCat); //Add to the drop down list of all parent category. //We will use that to add a new category ListItem newLItem = new ListItem(AllCats[i].CatName, AllCats[i].CategoryID.ToString()); ddlParentCat.Items.Add(newLItem); } }
public static CategoryCollection GetTargetItemCategories(CategoryCollection sourceCategories, CategoryCollection targetCategoryCollection, Dictionary<string, string> categoryMap) { var targetItemCategories = new CategoryCollection(); //targetItemCategories.CollectionContent.AddRange(targetCategoryCollection.CollectionContent); var activeCategories = sourceCategories.GetIDSelectedArray(); List<string> targetCategoryIDs = new List<string>(); foreach (var activeCategory in activeCategories) { if (categoryMap.ContainsKey(activeCategory.ID)) { targetCategoryIDs.Add(categoryMap[activeCategory.ID]); } } targetCategoryIDs = targetCategoryIDs.Distinct().ToList(); //targetItemCategories.SelectedIDCommaSeparated = string.Join(",", targetCategoryIDs.ToArray()); targetItemCategories.CollectionContent .AddRange(targetCategoryIDs .Select(catID => targetCategoryCollection.CollectionContent.FirstOrDefault(cat => cat.ID == catID)) .Where(cat => cat != null)); return targetItemCategories; }
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())); } }
/// <summary> /// Initialize the control /// </summary> /// <param name="inObj"></param> public override void initControl(params object[] inObj) { //Show information of this category _thisCat = (VL.ORM.Category)inObj[0]; lblCatID.InnerText = _thisCat.CategoryID.ToString(); txtName.Text = _thisCat.CatName; txtURLRewrite.Text = _thisCat.URLRewrite; txtArrange.Text = _thisCat.Arrange.ToString(); lblLinkCount.InnerText = _thisCat.CatLinks().Count.ToString() + " links"; //Find the child cat in the list CategoryCollection childCats = new CategoryCollection().Where("parent", _thisCat.CategoryID); childCats.Load(); //Generate all child categories if (childCats.Count > 0) { foreach (Category item in childCats) { VL.Controls.CommonControl childItem = (VL.Controls.CommonControl)LoadControl(VL.Config.GetConfigPath("CatEditItem")); childItem.initControl(item); pnlChildCats.Controls.Add(childItem); } } }
/// <summary> /// Gets all Sub-Categories by the specified Category Id /// </summary> /// <param name="categoryId"></param> /// <returns></returns> public CategoryCollection GetSubCategories(int categoryId) { CategoryCollection categories = new CategoryCollection(); Query q = Category.CreateQuery(); q.AndWhere(Category.Columns.ParentId, categoryId); q.OrderByDesc(Category.Columns.Name); categories.LoadAndCloseReader(q.ExecuteReader()); return categories; }
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; } }
FillNodes(rootNodes, 1); ddlParentCategory.Items.Insert(0, new ListItem(LocalizationUtility.GetText("lblRoot"), "0")); } /// <summary> /// Fills the nodes. /// </summary> /// <param name="nodes">The nodes.</param> /// <param name="level">The level.</param> private void FillNodes(DataRow[] nodes, int level) { DataRow[] childNodes; int oldLevel = level; string name = string.Empty; for(int i = 0; i <= nodes.GetUpperBound(0); i++) { for(int j = 0;j < level;j++) { name += "-"; } name += nodes[i]["Name"].ToString(); ddlParentCategory.Items.Add(new ListItem(name, nodes[i]["CategoryId"].ToString())); name = string.Empty; childNodes = nodes[i].GetChildRows("ParentChild"); if(childNodes.GetUpperBound(0) >= 0) { level = level + 1; FillNodes(childNodes, level); } level = oldLevel;
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); }
public override void Dispose() { base.Dispose(); Accounts.Dispose(); Incomes.Dispose(); Packages.Dispose(); Categories.Dispose(); Accounts = new AccountCollection(); Incomes = new IncomeCollection(); Packages = new PackageCollection(); Categories = new CategoryCollection(); _BackgroundRun = null; _BackgroundUpdateBalances = null; }
public CategoryCollection FetchByQuery(Query qry) { CategoryCollection coll = new CategoryCollection(); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
public CategoryCollection FetchByID(object CategoryID) { CategoryCollection coll = new CategoryCollection().Where("CategoryID", CategoryID).Load(); return coll; }