示例#1
0
        void ITextContentProvider.ClearCategories(Models.TextContent content)
        {
            var list = content.GetRepository().GetCategoryData();

            list.RemoveAll(it => it.ContentUUID.EqualsOrNullEmpty(content.UUID, StringComparison.CurrentCultureIgnoreCase));

            content.GetRepository().SaveCategoryData(list);
        }
示例#2
0
        void ITextContentProvider.AddCategories(Models.TextContent content, params Models.Category[] categories)
        {
            var list = content.GetRepository().GetCategoryData();

            foreach (var category in categories)
            {
                list.Add(category);
            }
            content.GetRepository().SaveCategoryData(list);
        }
示例#3
0
        public void ClearCategories(Models.TextContent content)
        {
            var bucket = content.GetRepository().GetClient();

            var view = bucket.GetView(content.GetRepository().GetDefaultViewDesign(), "CategorisData_By_ContentUUID").Stale(StaleMode.False).Reduce(false);
            var ret  = view.Where(it => it.Info["value"].ToString().Equals(content.UUID)).Select(it => it.ItemId);

            ret.ForEach((key, index) =>
            {
                bucket.Remove(key);
            });
        }
示例#4
0
        void ITextContentProvider.DeleteCategories(Models.TextContent content, params Models.Category[] categories)
        {
            var list = content.GetRepository().GetCategoryData();

            foreach (var category in categories)
            {
                var index = list.IndexOf(category);
                if (index != -1)
                {
                    list.RemoveAt(index);
                }
            }
            content.GetRepository().SaveCategoryData(list);
        }
示例#5
0
        public void Delete(Models.TextContent content)
        {
            var bucket = content.GetRepository().GetClient();

            bucket.ExecuteRemove(content.UUID, PersistTo.One);
            TextContentFileHelper.DeleteFiles(content);
        }
示例#6
0
        public void Add(Models.TextContent content)
        {
            try
            {
                content.StoreFiles();

                ((IPersistable)content).OnSaving();
                var command = dbCommands.Add(content);
                if (command != null)
                {
                    if (SQLServerTransactionUnit.Current != null)
                    {
                        SQLServerTransactionUnit.Current.RegisterCommand(command);
                        SQLServerTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)content).OnSaved(); });
                    }
                    else
                    {
                        SQLServerHelper.BatchExecuteNonQuery(content.GetRepository(), command);
                        ((IPersistable)content).OnSaved();
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#7
0
        public void DeleteCategories(Models.TextContent content, params Models.Category[] categories)
        {
            var bucket = content.GetRepository().GetClient();

            categories.ForEach((it, index) =>
            {
                bucket.ExecuteRemove(it.GetDocumentKey(), PersistTo.One);
            });
        }
示例#8
0
        public void Add(Models.TextContent content)
        {
            content.StoreFiles();

            ((IPersistable)content).OnSaving();
            var bucket = content.GetRepository().GetClient();

            //bucket.Store(StoreMode.Set, "Schema." + content.UUID, content.ToJson());
            bucket.ExecuteStore(StoreMode.Set, content.UUID, content.ToJson(), PersistTo.One);
            ((IPersistable)content).OnSaved();
        }
示例#9
0
 public void DeleteCategories(Models.TextContent content, params Models.Category[] categories)
 {
     //((IPersistable)content).OnSaving();
     if (categories != null && categories.Length > 0)
     {
         MongoCollection <BsonDocument> collection = content.GetRepository().GetCategoriesCollection();
         var query = MongoDBQuery.Query.Or(categories.Select(it => it.ToQuery()).ToArray());
         collection.Remove(query);
     }
     //((IPersistable)content).OnSaved();
 }
示例#10
0
        public void ClearCategories(Models.TextContent content)
        {
            //((IPersistable)content).OnSaving();
            MongoCollection <BsonDocument> collection = content.GetRepository().GetCategoriesCollection();
            var query = new QueryDocument {
                { "ContentUUID", content.UUID }
            };

            collection.Remove(query);
            //((IPersistable)content).OnSaved();
        }
示例#11
0
        public void AddCategories(Models.TextContent content, params Models.Category[] categories)
        {
            //((IPersistable)content).OnSaving();
            if (categories != null && categories.Length > 0)
            {
                MongoCollection <BsonDocument> collection = content.GetRepository().GetCategoriesCollection();
                collection.InsertBatch(categories.Select(it => it.ToBsonDocument()).ToArray());
            }

            //((IPersistable)content).OnSaved();
        }
示例#12
0
        public void Delete(Models.TextContent content)
        {
            var database = content.GetRepository().GetDatabase();
            MongoCollection <BsonDocument> collection = database.GetCollection(content.GetSchema().GetSchemaCollectionName());
            var query = new QueryDocument {
                { "UUID", content.UUID }
            };

            collection.Remove(query);
            TextContentFileHelper.DeleteFiles(content);
        }
示例#13
0
        public void AddCategories(Models.TextContent content, params Models.Category[] categories)
        {
            if (categories != null && categories.Length > 0)
            {
                var bucket = content.GetRepository().GetClient();

                categories.ForEach((it, index) =>
                {
                    bucket.ExecuteStore(StoreMode.Set, it.GetDocumentKey(), it.ToJson(), PersistTo.One);
                });
            }
        }
示例#14
0
        public void Add(Models.TextContent content)
        {
            try
            {
                content.StoreFiles();
                ((IPersistable)content).OnSaving();

                var folder = content.GetFolder().GetActualFolder();
                var schema = content.GetSchema().GetActualSchema();
                if (folder != null && folder.StoreInAPI)
                {
                    var proxy = new BackendProxy();

                    var additionalData = new Dictionary <string, object>()
                    {
                        { "CreatedBy", AuthHelper.GetCurrentUserName() },
                        { "ModifiedBy", AuthHelper.GetCurrentUserName() },
                        { "OwnerId", AuthHelper.GetCurrentUserName() }
                    };

                    //Get payload
                    //
                    var payload = JsonConvert.SerializeObject(content,
                                                              new CustomJsonDictionaryConverter(schema.GetJsonSerializationIgnoreProperties(), additionalData));

                    //Send data to API
                    //
                    proxy.Execute("POST", schema.Name, payload);
                }
                else
                {
                    var command = dbCommands.Add(content);
                    if (command != null)
                    {
                        if (SQLServerTransactionUnit.Current != null)
                        {
                            SQLServerTransactionUnit.Current.RegisterCommand(command);
                            SQLServerTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)content).OnSaved(); });
                        }
                        else
                        {
                            SQLServerHelper.BatchExecuteNonQuery(content.GetRepository(), command);
                            ((IPersistable)content).OnSaved();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#15
0
        public void Add(Models.TextContent content)
        {
            content.Remove("_id");

            content.StoreFiles();

            ((IPersistable)content).OnSaving();
            var database = content.GetRepository().GetDatabase();
            MongoCollection <BsonDocument> collection = database.GetCollection(content.GetSchema().GetSchemaCollectionName());

            collection.Insert(content.ToBsonDocument());
            ((IPersistable)content).OnSaved();
        }
示例#16
0
        public void Delete(Models.TextContent content)
        {
            var command = dbCommands.Delete(content);

            if (MySQLTransactionUnit.Current != null)
            {
                MySQLTransactionUnit.Current.RegisterCommand(command);
                MySQLTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)content).OnSaved(); });
            }
            else
            {
                MysqlHelper.BatchExecuteNonQuery(content.GetRepository(), command);
            }
        }
示例#17
0
        public void Update(Models.TextContent @new, Models.TextContent old)
        {
            //if (@new["_id"] == null && old["_id"] != null)
            //{
            //    @new["_id"] = old["_id"];
            //}

            @new.StoreFiles();
            ((IPersistable)@new).OnSaving();
            var bucket = old.GetRepository().GetClient();

            bucket.ExecuteStore(StoreMode.Replace, old.UUID, @new.ToJson(), PersistTo.One);
            ((IPersistable)@new).OnSaved();
        }
示例#18
0
        public void Delete(Models.TextContent content)
        {
            var command = dbCommands.Delete(content);

            if (SQLCeTransactionUnit.Current != null)
            {
                SQLCeTransactionUnit.Current.RegisterCommand(command);
                SQLCeTransactionUnit.Current.RegisterPostAction(delegate() { TextContentFileHelper.DeleteFiles(content); });
            }
            else
            {
                SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), command);
                TextContentFileHelper.DeleteFiles(content);
            }
        }
示例#19
0
        public void Update(Models.TextContent @new, Models.TextContent old)
        {
            if (@new["_id"] == null && old["_id"] != null)
            {
                @new["_id"] = old["_id"];
            }

            @new.StoreFiles();
            ((IPersistable)@new).OnSaving();
            var database = old.GetRepository().GetDatabase();
            MongoCollection <BsonDocument> collection = database.GetCollection(old.GetSchema().GetSchemaCollectionName());
            var query = new QueryDocument {
                { "UUID", old.UUID }
            };

            collection.Update(query, @new.ToUpdateDocument());
            ((IPersistable)@new).OnSaved();
        }
示例#20
0
        public void Update(Models.TextContent @new, Models.TextContent old)
        {
            @new.StoreFiles();

            ((IPersistable)@new).OnSaving();
            var command = dbCommands.Update(@new);

            if (SQLCeTransactionUnit.Current != null)
            {
                SQLCeTransactionUnit.Current.RegisterCommand(command);
                SQLCeTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)@new).OnSaved(); });
            }
            else
            {
                SQLCeHelper.ExecuteNonQuery(@new.GetRepository().GetConnectionString(), command);
                ((IPersistable)@new).OnSaved();
            }
        }
示例#21
0
        public void Update(Models.TextContent @new, Models.TextContent old)
        {
            @new.StoreFiles();

            ((IPersistable)@new).OnSaving();

            var folder = @new.GetFolder().GetActualFolder();
            var schema = @new.GetSchema().GetActualSchema();

            if (folder != null && folder.StoreInAPI)
            {
                var proxyBackend = new BackendProxy();

                //Add additional data
                //
                var additionalData = new Dictionary <string, object>
                {
                    { "ModifiedBy", AuthHelper.GetCurrentUserName() }
                };

                //Get payload
                //
                var payload = JsonConvert.SerializeObject(@new, new CustomJsonDictionaryConverter(schema.GetJsonSerializationIgnoreProperties(), additionalData));

                //Send data to API
                //
                proxyBackend.Execute("PUT", string.Format("{0}({1})", schema.Name, @new.Id), payload);
            }
            else
            {
                var command = dbCommands.Update(@new);
                if (SQLServerTransactionUnit.Current != null)
                {
                    SQLServerTransactionUnit.Current.RegisterCommand(command);
                    SQLServerTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)@new).OnSaved(); });
                }
                else
                {
                    SQLServerHelper.BatchExecuteNonQuery(@new.GetRepository(), command);
                    ((IPersistable)@new).OnSaved();
                }
            }
        }
示例#22
0
        public void Add(Models.TextContent content)
        {
            content.StoreFiles();

            ((IPersistable)content).OnSaving();
            var command = dbCommands.Add(content);

            if (command != null)
            {
                if (SQLCeTransactionUnit.Current != null)
                {
                    SQLCeTransactionUnit.Current.RegisterCommand(command);
                    SQLCeTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)content).OnSaved(); });
                }
                else
                {
                    SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), command);
                    ((IPersistable)content).OnSaved();
                }
            }
        }
示例#23
0
 public void DeleteCategories(Models.TextContent content, params Models.Category[] categories)
 {
     SQLServerHelper.BatchExecuteNonQuery(content.GetRepository(),
                                          categories.Select(it => dbCommands.DeleteCategory(content.GetRepository(), it)).ToArray());
 }
示例#24
0
 public void DeleteCategories(Models.TextContent content, params Models.Category[] categories)
 {
     SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(),
                                 categories.Select(it => dbCommands.DeleteCategory(content.GetRepository(), it)).ToArray());
 }
示例#25
0
 public IEnumerable <Models.Category> QueryCategories(Models.TextContent content)
 {
     return(content.GetRepository().QueryCategoriesBy(content.UUID).Select(it => it.ToCategory()).Where(it => it.ContentUUID.Equals(content.UUID)));
 }