Beispiel #1
0
        public TagType GetTagType(string TagName)
        {
            //Length of inner array is 3, 1 = ID, 2 = Name, 3 = TagType
            List <string[]> results = Query(SqlStatements.GetTagTypeFromTag(TagName));

            return(TagObject.ConvertToTagType(results[0][2][0])); //takes the first char
        }
Beispiel #2
0
        //Delete Tag from Database
        public static string DeleteTag(TagObject tag)
        {
            StringBuilder SQL_Statement = new StringBuilder();

            SQL_Statement.Append("Delete from ReviewTags where TagID in (Select TagID from Tags where Name ='" + tag.Name + "' and TagType = '" + (char)tag.Type + "'); ");
            SQL_Statement.Append("Delete from Tags where Name ='" + tag.Name + "' and TagType = '" + (char)tag.Type + "';");

            return(SQL_Statement.ToString());
        }
Beispiel #3
0
        public List <TagObject> GetAllTags()
        {
            List <TagObject> allTags = new List <TagObject>();
            List <string[]>  results = Query(SqlStatements.GetAllTags);

            foreach (string[] row in results)
            {
                allTags.Add(new TagObject(row[1], TagObject.ConvertToTagType(row[2][0])));
            }
            return(allTags);
        }
Beispiel #4
0
        public TagObject GetTag(string TagName)
        {
            List <string[]> results = Query(SqlStatements.GetTagTypeFromTag(TagName));

            string  Name = results[0][1];
            TagType Type = TagObject.ConvertToTagType(results[0][2][0]); //takes the first char

            TagObject tag = new TagObject(Name, Type);

            return(tag);
        }
Beispiel #5
0
        //Get All the Tags assosiated with a review object
        //Does not set the Review OBject with tags.
        public List <TagObject> GetTagsForReview(Review_Reference ro)
        {
            List <TagObject> ReviewTags = new List <TagObject>();
            List <string[]>  results    = Query(SqlStatements.GetTagsForReview(ro));

            foreach (string[] row in results)
            {
                ReviewTags.Add(new TagObject(row[0], TagObject.ConvertToTagType(row[1][0])));
            }

            return(ReviewTags);
        }
Beispiel #6
0
        private void InitializeTags()
        {
            try
            {
                FileStream       tagFile    = new FileStream(TagFileName, FileMode.Open, FileAccess.ReadWrite);
                StreamReader     reader     = new StreamReader(tagFile);
                StringBuilder    TagStrings = new StringBuilder();
                List <TagObject> TagsToAdd  = new List <TagObject>();

                while (reader.EndOfStream == false)
                {
                    readThroughWhiteSpace();
                    if (reader.EndOfStream == true)
                    {
                        return;
                    }

                    TagType nextTagType = TagObject.ConvertToTagType((char)reader.Read());
                    if (reader.EndOfStream == true)
                    {
                        return;
                    }

                    if ((char)reader.Read() != '<')
                    {
                        throw new Exception("Parse Error");
                    }
                    if (reader.EndOfStream == true)
                    {
                        return;
                    }

                    char nextToAdd = (char)reader.Read();
                    if (reader.EndOfStream == true)
                    {
                        return;
                    }

                    while (nextToAdd != '>')
                    {
                        TagStrings.Append(nextToAdd);
                        nextToAdd = (char)reader.Read();
                        if (nextToAdd != '>' && reader.EndOfStream == true)
                        {
                            throw new Exception("Parse Error");
                        }
                    }

                    TagsToAdd.Add(new TagObject(TagStrings.ToString(), nextTagType));
                    TagStrings.Clear();
                }

                System.Console.WriteLine(SqlStatements.AddTags(TagsToAdd));
                ExecuteNoResponseSQL(SqlStatements.AddTags(TagsToAdd));

                void readThroughWhiteSpace()
                {
                    while (reader.EndOfStream == false && char.IsWhiteSpace((char)reader.Peek()))
                    {
                        reader.Read(); //read it in.
                    }
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                Console.WriteLine("Error in Project set up, tag ini files not found");
            }
        }
Beispiel #7
0
 public void deleteTag(TagObject tag)
 {
     ExecuteNoResponseSQL(SqlStatements.DeleteTag(tag));
 }
Beispiel #8
0
 public void AddTag(TagObject tag)
 {
     ExecuteNoResponseSQL(SqlStatements.AddTag(tag));
 }
 public void RemoveTag(TagObject newTag)
 {
     this.Tags.Remove(newTag);
 }
 public void AddTag(TagObject Tag)
 {
     this.Tags.Add(Tag);
 }
 public bool HasTag(TagObject tag)
 {
     return(this.Tags.Contains(tag));
 }
Beispiel #12
0
 //Add Tag to the table
 public static string AddTag(TagObject tag)
 {
     return("Insert into Tags(Name,TagType) VALUES('" + tag.Name + "','" + (char)tag.Type + "')");
 }