Esempio n. 1
0
        public static Category ToCategory(this BsonDocument doc)
        {
            Category category = new Category();
            category.CategoryFolder = doc["CategoryFolder"].ToString();
            category.CategoryUUID = doc["CategoryUUID"].ToString();
            category.ContentUUID = doc["ContentUUID"].ToString();

            return category;
        }
Esempio n. 2
0
        public MySqlCommand AddCategory(Repository repository, Category category)
        {
            string sql = string.Format("INSERT INTO `{0}`(UUID,CategoryFolder,CategoryUUID) VALUES(?UUID,?CategoryFolder,?CategoryUUID)"
                , repository.GetCategoryTableName());
            MySqlCommand command = new MySqlCommand();
            command.CommandText = sql;
            command.Parameters.Add(new MySqlParameter("?UUID", category.ContentUUID));
            command.Parameters.Add(new MySqlParameter("?CategoryFolder", category.CategoryFolder));
            command.Parameters.Add(new MySqlParameter("?CategoryUUID", category.CategoryUUID));

            return command;
        }
Esempio n. 3
0
        public SqlCeCommand AddCategory(Repository repository, Category category)
        {
            string sql = string.Format("INSERT INTO [{0}](UUID,CategoryFolder,CategoryUUID) VALUES(@UUID,@CategoryFolder,@CategoryUUID)"
                 , repository.GetCategoryTableName());
            SqlCeCommand command = new SqlCeCommand();
            command.CommandText = sql;
            command.Parameters.Add(new SqlCeParameter("@UUID", category.ContentUUID));
            command.Parameters.Add(new SqlCeParameter("@CategoryFolder", category.CategoryFolder));
            command.Parameters.Add(new SqlCeParameter("@CategoryUUID", category.CategoryUUID));

            return command;
        }
Esempio n. 4
0
        public void Export_Categories_Data()
        {
            TextContent news1 = new TextContent(repository.Name, newsSchema.Name, textFolder.FullName);
            news1["Title"] = "title1";
            news1["body"] = "body1";
            provider.Add(news1);

            TextContent category1 = new TextContent(repository.Name, "category", "category");
            category1["Title"] = "category1";
            provider.Add(category1);

            var categories = new Category[] { new Category() { ContentUUID = news1.UUID, CategoryFolder = category1.FolderName, CategoryUUID = category1.UUID } };

            provider.AddCategories(news1, categories);

            var exportedCategories = provider.ExportCategoryData(repository);

            Assert.IsTrue(exportedCategories.Count() > 1);
        }
Esempio n. 5
0
        public SqlCommand DeleteCategory(Repository repository, Category category)
        {
            string sql = string.Format("DELETE FROM [{0}] WHERE UUID=@UUID AND CategoryFolder=@CategoryFolder AND CategoryUUID=@CategoryUUID"
                 , repository.GetCategoryTableName());
            SqlCommand command = new SqlCommand();
            command.CommandText = sql;
            command.Parameters.Add(new SqlParameter("@UUID", category.ContentUUID));
            command.Parameters.Add(new SqlParameter("@CategoryFolder", category.CategoryFolder));
            command.Parameters.Add(new SqlParameter("@CategoryUUID", category.CategoryUUID));

            return command;
        }
Esempio n. 6
0
        public IEnumerable<Category> QueryCategories(TextContent content)
        {
            List<Category> list = new List<Category>();
            SqlCeConnection connection;
            using (var dataReader = SQLCeHelper.ExecuteReader(content.GetRepository().GetConnectionString(),
                dbCommands.QueryCategories(content), out connection))
            {
                try
                {
                    while (dataReader.Read())
                    {
                        Category category = new Category()
                        {
                            CategoryFolder = dataReader.GetString(dataReader.GetOrdinal("CategoryFolder")),
                            CategoryUUID = dataReader.GetString(dataReader.GetOrdinal("CategoryUUID")),
                            ContentUUID = dataReader.GetString(dataReader.GetOrdinal("UUID")),
                        };
                        list.Add(category);
                    }

                }
                finally
                {
                    dataReader.Close();
                    connection.Close();
                }
            }
            return list;
        }
Esempio n. 7
0
 public IEnumerable<Category> ExportCategoryData(Repository repository)
 {
     var connectionString = repository.GetConnectionString();
     string sql = string.Format("SELECT UUID,CategoryFolder,CategoryUUID FROM [{0}] ", repository.GetCategoryTableName());
     List<Category> list = new List<Category>();
     SqlCeConnection connection;
     using (var reader = SQLCeHelper.ExecuteReader(connectionString, new SqlCeCommand() { CommandText = sql }, out connection))
     {
         try
         {
             while (reader.Read())
             {
                 Category category = new Category();
                 category.ContentUUID = reader.GetString(0);
                 category.CategoryFolder = reader.GetString(1);
                 category.CategoryUUID = reader.GetString(2);
                 list.Add(category);
             }
         }
         finally
         {
             reader.Close();
             connection.Close();
         }
     }
     return list;
 }
Esempio n. 8
0
        public IEnumerable<Category> QueryCategories(TextContent content)
        {
            MongoCollection<BsonDocument> collection = content.GetRepository().GetCategoriesCollection();
            var query = MongoDBHelper.EQIgnoreCase("ContentUUID", content.UUID);
            var documents = collection.Find(query);
            List<Category> list = new List<Category>();

            foreach (var doc in documents)
            {
                Category category = new Category()
                {
                    CategoryFolder = doc["CategoryFolder"].AsString,
                    CategoryUUID = doc["CategoryUUID"].AsString,
                    ContentUUID = doc["ContentUUID"].AsString
                };

                list.Add(category);
            }

            return list;
        }
Esempio n. 9
0
        public void Insert_Delete_Category()
        {
            TextContent news1 = new TextContent(repository.Name, newsSchema.Name, textFolder.FullName);
            news1["Title"] = "title1";
            news1["body"] = "body1";
            provider.Add(news1);

            TextContent category1 = new TextContent(repository.Name, "category", "category");
            category1["Title"] = "category1";
            provider.Add(category1);

            var categories = new Category[] { new Category() { ContentUUID = news1.UUID, CategoryFolder = category1.FolderName, CategoryUUID = category1.UUID } };

            provider.AddCategories(news1, categories);
            provider.DeleteCategories(news1, categories);
            provider.AddCategories(news1, categories);
            provider.ClearCategories(news1);

            provider.ClearCategories(news1);
        }
Esempio n. 10
0
 public IEnumerable<Category> ExportCategoryData(Repository repository)
 {
     string sql = string.Format("SELECT UUID,CategoryFolder,CategoryUUID FROM `{0}` ", repository.GetCategoryTableName());
     List<Category> list = new List<Category>();
     MySqlConnection connection;
     using (var reader = MysqlHelper.ExecuteReader(repository, new MySqlCommand() { CommandText = sql }, out connection))
     {
         while (reader.Read())
         {
             Category category = new Category();
             category.ContentUUID = reader.GetString(0);
             category.CategoryFolder = reader.GetString(1);
             category.CategoryUUID = reader.GetString(2);
             list.Add(category);
         }
         connection.Close();
     }
     return list;
 }
Esempio n. 11
0
        public static Category ToCategory(this IViewRow row)
        {
            Category category = new Category();
            var dict = row.Info["value"] as Dictionary<string, object>;

            category.CategoryFolder = dict["CategoryFolder"] as string;
            category.CategoryUUID = dict["CategoryUUID"] as string;
            category.ContentUUID = dict["ContentUUID"] as string;

            return category;
        }