当前位置: 首页>>代码示例>>C#>>正文


C# Models.GetSchema方法代码示例

本文整理汇总了C#中Models.GetSchema方法的典型用法代码示例。如果您正苦于以下问题:C# Models.GetSchema方法的具体用法?C# Models.GetSchema怎么用?C# Models.GetSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Models的用法示例。


在下文中一共展示了Models.GetSchema方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Delete

 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);
 }
开发者ID:Epitomy,项目名称:CMS,代码行数:8,代码来源:TextContentProvider.cs

示例2: Add

        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();
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:12,代码来源:TextContentProvider.cs

示例3: Update

        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();
                }
            }
        }
开发者ID:FordSoft,项目名称:CMS,代码行数:42,代码来源:TextContentProvider.cs

示例4: Update

        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();
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:15,代码来源:TextContentProvider.cs

示例5: Add

        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;
            }
        }
开发者ID:FordSoft,项目名称:CMS,代码行数:52,代码来源:TextContentProvider.cs


注:本文中的Models.GetSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。