Ejemplo n.º 1
0
        public void SetFileCategory(string strFileHash, string category)
        {
            CElement Element = (CElement)this[CKernel.StringToHash(strFileHash)];

            if (Element != null)
            {
                CCategory cat = CKernel.CategoriesList.GetCategoryByName(category);
                if (cat != null)
                {
                    Element.File.CategoryID = cat.ID;
                }
                else
                {
                    Element.File.CategoryID = 0;
                }
            }
        }
Ejemplo n.º 2
0
        public bool AddorUpdateCategory(uint ID, string name, string auto, uint color)
        {
            uint      newID       = ID;
            CCategory newCategory = null;

            //if ID>0 check if already exists
            if (newID > 0)
            {
                foreach (CCategory category in List)
                {
                    if (category.ID == newID)
                    {
                        newCategory = category;
                    }
                }
            }
            else
            {
                uint maxID = 1;
                foreach (CCategory category in List)
                {
                    if (category.ID >= maxID)
                    {
                        maxID = category.ID + 1;
                    }
                }
                newID = maxID;
            }

            if (newCategory == null)
            {
                newCategory = new CCategory();
                List.Add(newCategory);
            }

            newCategory.ID         = newID;
            newCategory.Name       = name;
            newCategory.Color      = color;
            newCategory.AutoString = auto;
            return(true);
        }
Ejemplo n.º 3
0
 private void m_SetValueFromXmlElement(XmlElement element)
 {
     try
     {
         XmlNodeList nodes = element.ChildNodes;
         foreach (XmlElement el in nodes)
         {
             if (el.Name == "Category")
             {
                 CCategory category = new CCategory();
                 category.Name       = el.Attributes["Name"].InnerText;
                 category.AutoString = el.Attributes["AutoString"].InnerText;
                 category.Color      = uint.Parse(el.Attributes["Color"].InnerText);
                 category.ID         = uint.Parse(el.Attributes["ID"].InnerText);
                 List.Add(category);
             }
         }
     }
     catch
     {
         CLog.Log(Constants.Log.Info, "Error loading categories list");
     }
 }