Ejemplo n.º 1
0
        //-----------------------------------------------------------------------------------------
        public static List <CommentsCollection> BuildList(string _folder)
        {
            try
            {
                List <CommentsCollection> result = new List <CommentsCollection>();

                List <string> listSub = new List <string>();
                if (Directory.Exists(_folder))
                {
                    listSub.AddRange(Directory.GetDirectories(_folder).ToList());
                }

                //if (Directory.Exists(TaxonUtils.GetCommentDirectory()))
                //    listSub.Add(TaxonUtils.GetCommentDirectory());

                foreach (string s in listSub)
                {
                    string subFolder = s.Split(System.IO.Path.DirectorySeparatorChar).Last();
                    if (subFolder.StartsWith("_"))
                    {
                        continue;
                    }
                    CommentsCollection collection = new CommentsCollection(s, System.IO.Path.GetFileName(s));
                    result.Add(collection);
                }

                SortList(result);
                return(result);
            }
            catch (Exception) { }
            return(null);
        }
Ejemplo n.º 2
0
        public static CommentFileCreateResult CommentFileCreate(TaxonTreeNode _node)
        {
            if (_node == null)
            {
                return(CommentFileCreateResult.Failed);
            }

            if (TaxonComments.Manager.AvailableCollections.Count == 0)
            {
                return(CommentFileCreateResult.NoCollection);
            }
            CommentsCollection collection = TaxonComments.Manager.AvailableCollections[0];

            string name = CommentFilename(_node.Desc);

            if (string.IsNullOrEmpty(name))
            {
                return(CommentFileCreateResult.NoNameAndID);
            }

            string path = CommentFileDesc.BuildHtlmName(collection, name);

            if (File.Exists(path))
            {
                return(CommentFileCreateResult.ExistsAlready);
            }

            Manager.CreateHtmlComment(path, name);
            Manager.CleanCommentInMemory(0);
            return(CommentFileCreateResult.Success);
        }
Ejemplo n.º 3
0
 public void MoveDown(CommentsCollection _collection)
 {
     if (!CanMoveDown(_collection))
     {
         return;
     }
     foreach (CommentsCollection collection in AvailableCollections)
     {
         collection.PriorityOrder = 2 * (collection.PriorityOrder + 1);
     }
     _collection.PriorityOrder += 3;
     CommentsCollection.SortList(Collections);
 }
Ejemplo n.º 4
0
 public static CommentFileDesc CreateOnlyIfFileExists(CommentsCollection _collection, string _name)
 {
     try
     {
         string path = Path.Combine(_collection.Path, _name + ".html");
         if (File.Exists(path))
         {
             return(new CommentFileDesc(_collection, _name));
         }
     }
     catch (Exception e)
     {
         Loggers.WriteError(LogTags.Data, "Loading comment for " + _name + " raise an exception:\n" + e.Message);
     }
     return(null);
 }
Ejemplo n.º 5
0
 public static string BuildHtlmName(CommentsCollection _collection, string _name)
 {
     return(_collection.Path + System.IO.Path.DirectorySeparatorChar + _name + ".html");
 }
Ejemplo n.º 6
0
 public CommentFileDesc(CommentsCollection _collection, string _name)
 {
     Collection = _collection;
     Name       = _name;
 }
Ejemplo n.º 7
0
        public bool CanMoveDown(CommentsCollection _collection)
        {
            int index = AvailableCollections.IndexOf(_collection);

            return((index != -1) && (index != AvailableCollections.Count - 1));
        }
Ejemplo n.º 8
0
        public bool CanMoveUp(CommentsCollection _collection)
        {
            int index = AvailableCollections.IndexOf(_collection);

            return(index > 0);
        }
Ejemplo n.º 9
0
 public void SaveCollections()
 {
     CommentsCollection.SaveInfos(Collections);
 }
Ejemplo n.º 10
0
 public void UpdateAvailableCollections()
 {
     AvailableCollections = CommentsCollection.Available(Collections);
 }