本文整理汇总了C#中Kooboo.CMS.Content.Models.Repository类的典型用法代码示例。如果您正苦于以下问题:C# Repository类的具体用法?C# Repository怎么用?C# Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Repository类属于Kooboo.CMS.Content.Models命名空间,在下文中一共展示了Repository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SimpleQueryTests
static SimpleQueryTests()
{
repository = new Repository("SimpleQueryTests");
schema = new Schema(repository, "news");
schema.AddColumn(new Column()
{
Name = "Title",
DataType = DataType.String,
Length = 256
});
schema.AddColumn(new Column()
{
Name = "Comments",
DataType = DataType.Int
});
folder = new TextFolder(repository, "news");
folder.SchemaName = schema.Name;
ProviderFactory providerFactory = new ProviderFactory();
Providers.DefaultProviderFactory = providerFactory;
providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
providerFactory.GetProvider<ISchemaProvider>().Add(schema);
providerFactory.GetProvider<ITextFolderProvider>().Add(folder);
InitializeData();
}
开发者ID:Godoy,项目名称:CMS,代码行数:27,代码来源:SimpleQueryTests.cs
示例2: Generate
public string Generate(Repository repository, Models.DataRuleSetting dataRule, bool inlineEdit)
{
if (dataRule.DataRule is DataRuleBase)
{
var dataRuleBase = (DataRuleBase)dataRule.DataRule;
var schema = dataRuleBase.GetSchema(repository).AsActual();
string html = @"
<div>
<h3 class=""title""{3}><%= ViewBag.{0}.{1}%></h3>
<div class=""content"">
{2}
</div>
</div>";
string columnTp = @"
<div{2}>
<%= ViewBag.{1}.{0}%>
</div>
";
var titleField = schema.GetSummarizeColumn().Name;
var editField = " <%:ViewHelper.Edit(ViewBag.{0},\"{1}\")%>";
schema = schema.AsActual();
StringBuilder sb = new StringBuilder();
foreach (var column in schema.Columns)
{
if (!column.Name.EqualsOrNullEmpty(titleField, StringComparison.CurrentCultureIgnoreCase))
{
sb.AppendFormat(columnTp, column.Name, dataRule.DataName, inlineEdit ? string.Format(editField, dataRule.DataName, column.Name) : "");
}
}
return string.Format(html, dataRule.DataName, schema.GetSummarizeColumn().Name, sb.ToString(), inlineEdit ? string.Format(editField, dataRule.DataName, titleField) : "");
}
return string.Empty;
}
开发者ID:Godoy,项目名称:CMS,代码行数:35,代码来源:WebFormDetailCodeSnippet.cs
示例3: QueryTests
public QueryTests()
{
EmptyUserKeyGenerator.DefaultGenerator = new EmptyUserKeyGenerator();
Providers.DefaultProviderFactory = new MongoDB.ProviderFactory();
repository = new Repository(Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10).ToString());
Providers.DefaultProviderFactory.GetProvider<IRepositoryProvider>().Add(repository);
categorySchema = new Schema(repository, "category") { IsDummy = false };
categorySchema.AddColumn(new Column() { Name = "Title" });
categoryFolder = new TextFolder(repository, "Category") { SchemaName = categorySchema.Name, IsDummy = false };
Providers.DefaultProviderFactory.GetProvider<ITextFolderProvider>().Add(categoryFolder);
newsSchema = new Schema(repository, "News") { IsDummy = false };
newsSchema.AddColumn(new Column() { Name = "title", DataType = Data.DataType.String });
newsSchema.AddColumn(new Column() { Name = "Body", DataType = Data.DataType.String });
newsSchema.AddColumn(new Column() { Name = "Comments", DataType = Data.DataType.Int });
Providers.DefaultProviderFactory.GetProvider<ISchemaProvider>().Add(newsSchema);
newsFolder = new TextFolder(repository, "News") { SchemaName = newsSchema.Name, Categories = new List<CategoryFolder>() { new CategoryFolder() { FolderName = categoryFolder.FullName, SingleChoice = false } }, OrderSetting = new OrderSetting() { FieldName = "Sequence", Direction = OrderDirection.Descending } };
Providers.DefaultProviderFactory.GetProvider<ITextFolderProvider>().Add(newsFolder);
commentSchema = new Schema(repository, "Comment") { IsDummy = false };
commentSchema.AddColumn(new Column() { Name = "Title" });
Providers.DefaultProviderFactory.GetProvider<ISchemaProvider>().Add(commentSchema);
category1 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.FullName);
category1["title"] = "category1";
provider.Add(category1);
category2 = new TextContent(repository.Name, categorySchema.Name, categoryFolder.FullName);
category2["title"] = "category2";
provider.Add(category2);
newsContent = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
newsContent["title"] = "news1";
newsContent["body"] = "body";
newsContent["comments"] = 1;
provider.Add(newsContent);
news2 = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
news2["title"] = "news2";
news2["body"] = "body";
news2["comments"] = 0;
provider.Add(news2);
news3 = new TextContent(repository.Name, newsSchema.Name, newsFolder.FullName);
news3["title"] = "news2";
news3["body"] = "body";
news3["comments"] = 5;
provider.Add(news3);
provider.AddCategories(newsContent, new Category() { ContentUUID = newsContent.UUID, CategoryUUID = category1.UUID, CategoryFolder = category1.FolderName });
provider.AddCategories(newsContent, new Category() { ContentUUID = newsContent.UUID, CategoryUUID = category2.UUID, CategoryFolder = category2.FolderName });
commenContent = new TextContent(repository.Name, commentSchema.Name, "");
commenContent.ParentFolder = newsContent.FolderName;
commenContent.ParentUUID = newsContent.UUID;
commenContent["title"] = "comment1";
provider.Add(commenContent);
}
开发者ID:Epitomy,项目名称:CMS,代码行数:60,代码来源:QueryTests.cs
示例4: Import
public void Import(Repository repository, MediaFolder folder, System.IO.Stream zipStream, bool @override)
{
using (ZipFile zipFile = ZipFile.Read(zipStream))
{
foreach (ZipEntry item in zipFile)
{
if (item.IsDirectory)
{
}
else
{
var path = Path.GetDirectoryName(item.FileName);
var fileName = Path.GetFileName(item.FileName);
var currentFolder = CreateMediaFolderByPath(folder, path);
Add(currentFolder);
var stream = new MemoryStream();
item.Extract(stream);
stream.Position = 0;
ServiceFactory.MediaContentManager.Add(repository, currentFolder,
fileName, stream, true);
}
}
}
}
开发者ID:Epitomy,项目名称:CMS,代码行数:25,代码来源:MediaFolderProvider.cs
示例5: Update
public virtual MediaContent Update(Repository repository, MediaFolder mediaFolder, string uuid, string fileName, Stream fileStream,
string userid, MediaContentMetadata metadata)
{
IsAllowExtension(fileName, mediaFolder.AllowedExtensions);
var binaryContent = mediaFolder.CreateQuery().WhereEquals("UUID", uuid).First();
var old = new MediaContent(binaryContent);
binaryContent.UserId = userid;
binaryContent.UtcLastModificationDate = DateTime.UtcNow;
binaryContent.FileName = fileName;
binaryContent.UserKey = fileName;
binaryContent.UUID = fileName;
if (fileStream != null)
{
binaryContent.ContentFile = new ContentFile()
{
Name = fileName,
FileName = fileName,
Stream = fileStream
};
Provider.SaveContentStream(old, fileStream);
}
binaryContent.Metadata = metadata;
Provider.Update(binaryContent, old);
return binaryContent;
}
开发者ID:Godoy,项目名称:CMS,代码行数:31,代码来源:MediaContentManager.cs
示例6: GetStore
public virtual IDocumentStore GetStore(string repositoryName)
{
if (!stores.ContainsKey(repositoryName))
{
lock (stores)
{
if (!stores.ContainsKey(repositoryName))
{
var store = CreateStore(repositoryName);
store.Initialize();
var repository = new Repository(repositoryName);
if (store.DatabaseCommands.GetIndex(repository.GetCategoryIndex()) == null)
{
IDictionary<string, string> analyzers = new Dictionary<string, string>();
analyzers.Add("ContentUUID", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing");
analyzers.Add("CategoryFolder", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing");
analyzers.Add("CategoryUUID", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing");
store.DatabaseCommands.PutIndex(repository.GetCategoryIndex(), new IndexDefinition()
{
Map = @"from doc in docs where doc[""@metadata""][""Raven-Entity-Name""]==""Categories"" select new {doc.ContentUUID,doc.CategoryFolder,doc.CategoryUUID}"
//Analyzers = analyzers
}, true);
}
stores[repositoryName] = store;
}
}
}
return stores[repositoryName];
}
开发者ID:bbqchickenrobot,项目名称:CMS-RavenDBProvider,代码行数:32,代码来源:Database.cs
示例7: CreateDocument
public CmisObject CreateDocument(string repositoryId, NCMIS.ObjectModel.CmisProperties properties, string folderId, NCMIS.ObjectModel.ContentStream contentStream)
{
FolderObjectService folderObjectService = (FolderObjectService)ObjectService.GetService(typeof(Folder));
if (folderObjectService.IsSystemFolder(folderId))
{
throw new Exception("Could not create document under system folder.");
}
Kooboo.CMS.Content.Models.Repository repository = new Repository(repositoryId);
string objectId = folderId;
folderObjectService.TryPraseObjectId(folderId, out folderId);
var folder = CmisFolderHelper.Parse(repository, folderId);
if (folder is TextFolder)
{
var textFolder = (TextFolder)folder.AsActual();
var content = Services.ServiceFactory.TextContentManager.Add(repository, textFolder, UserId, properties.ToNameValueCollection(), contentStream.ToFileCollection(), null);
return ObjectConvertor.ToCmis(content, false);
}
else if (folder is MediaFolder)
{
var mediaFolder = (MediaFolder)folder.AsActual();
if (contentStream != null)
{
var content = Services.ServiceFactory.MediaContentManager.Add(repository, mediaFolder, UserId, contentStream.Filename, new MemoryStream(contentStream.Stream));
return ObjectConvertor.ToCmis(content, false);
}
}
return ObjectConvertor.EmptyCmisObject();
}
开发者ID:Godoy,项目名称:CMS,代码行数:32,代码来源:DocumentObjectService.cs
示例8: Add
public virtual MediaContent Add(Repository repository, MediaFolder mediaFolder, string fileName, Stream fileStream, bool @overrided,
string userId, MediaContentMetadata metadata)
{
fileName = UrlUtility.ToUrlString(Path.GetFileNameWithoutExtension(fileName)) + Path.GetExtension(fileName);
IsAllowExtension(fileName, mediaFolder.AllowedExtensions);
var mediaContent = new MediaContent(repository.Name, mediaFolder.FullName);
mediaContent.UserId = userId;
mediaContent.Published = true;
mediaContent.FileName = fileName;
mediaContent.UserKey = fileName;
mediaContent.UUID = fileName;
mediaContent.ContentFile = new ContentFile()
{
Name = fileName,
FileName = fileName,
Stream = fileStream
};
mediaContent.UtcLastModificationDate = mediaContent.UtcCreationDate = DateTime.UtcNow;
mediaContent.Metadata = metadata;
Provider.Add(mediaContent, @overrided);
return mediaContent;
}
开发者ID:Godoy,项目名称:CMS,代码行数:29,代码来源:MediaContentManager.cs
示例9: ParentQueryTests
static ParentQueryTests()
{
repository = new Repository("ParentQueryTests");
commentSchema = new Schema(repository, "comments");
commentSchema.AddColumn(new Column() { Name = "title", DataType = Kooboo.Data.DataType.String, Length = 256 });
newsSchema = new Schema(repository, "news") { ChildSchemas = new[] { commentSchema.Name } };
newsSchema.AddColumn(new Column()
{
Name = "Title",
DataType = Kooboo.Data.DataType.String,
Length = 256
});
newsSchema.AddColumn(new Column()
{
Name = "Comments",
DataType = Kooboo.Data.DataType.Int
});
newsFolder = new TextFolder(repository, "news") { SchemaName = newsSchema.Name };
ProviderFactory providerFactory = new ProviderFactory();
Providers.DefaultProviderFactory = providerFactory;
providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
providerFactory.GetProvider<ISchemaProvider>().Add(commentSchema);
providerFactory.GetProvider<ISchemaProvider>().Add(newsSchema);
providerFactory.GetProvider<ITextFolderProvider>().Add(newsFolder);
InitializeData();
}
开发者ID:Godoy,项目名称:CMS,代码行数:31,代码来源:ParentQueryTests.cs
示例10: ResetSchema
public int ResetSchema(Repository repository, Schema[] schemas)
{
var root = SchemaPath.GetBaseDir(repository);
var paths = schemas.Select(it => Path.Combine(root, it.Name));
return ResetSchema(repository, schemas, paths);
}
开发者ID:Qupy,项目名称:Extensions,代码行数:7,代码来源:SchemaResetService.cs
示例11: RepositoryPath
public RepositoryPath(Repository repository)
{
this.PhysicalPath = Path.Combine(BasePhysicalPath, repository.Name);
this.VirtualPath = UrlUtility.Combine(BaseVirtualPath, repository.Name);
this.SettingFile = Path.Combine(PhysicalPath, PathHelper.SettingFileName);
}
开发者ID:Godoy,项目名称:CMS,代码行数:7,代码来源:RepositoryPath.cs
示例12: Export
public void Export(Repository repository, string baseFolder, string[] folders, string[] docs, Stream outputStream)
{
ZipFile zipFile = new ZipFile();
var basePrefix = StorageNamesEncoder.EncodeContainerName(repository.Name) + "/" + MediaBlobHelper.MediaDirectoryName + "/";
if (!string.IsNullOrEmpty(baseFolder))
{
var baseMediaFolder = ServiceFactory.MediaFolderManager.Get(repository, baseFolder);
basePrefix = baseMediaFolder.GetMediaFolderItemPath(null) + "/";
}
var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
//add file
if (docs != null)
{
foreach (var doc in docs)
{
var blob = blobClient.GetBlockBlobReference(basePrefix + StorageNamesEncoder.EncodeBlobName(doc));
var bytes = blob.DownloadByteArray();
zipFile.AddEntry(doc, bytes);
}
}
//add folders
if (folders != null)
{
foreach (var folder in folders)
{
var folderName = folder.Split('~').LastOrDefault();
zipFolder(blobClient, basePrefix, folderName, "", ref zipFile);
}
}
zipFile.Save(outputStream);
}
开发者ID:Tsingbo-Kooboo,项目名称:KoobooMvc5,代码行数:34,代码来源:MediaFolderProvider.cs
示例13: Generate
public string Generate(Repository repository, Models.DataRuleSetting dataRule)
{
if (dataRule.DataRule is DataRuleBase)
{
var dataRuleBase = (DataRuleBase)dataRule.DataRule;
var schema = dataRuleBase.GetSchema(repository).AsActual();
string html = @"
<ul>
<%foreach (var item in ViewBag.{0})
{{%>
<li>
<%: Html.FrontHtml().PageLink(item.{1}, ""{2}/detail"", new {{ UserKey = item.UserKey}}) %>
</li>
<%}}%>
</ul>";
var snippet = string.Format(html, dataRule.DataName, schema.GetSummarizeColumn().Name, schema.Name);
if (dataRule.DataRule.EnablePaging())
{
snippet += Environment.NewLine + string.Format("<%: Html.FrontHtml().Pager(ViewBag.{0}) %>", dataRule.DataName);
}
return snippet;
}
return string.Empty;
}
开发者ID:Godoy,项目名称:CMS,代码行数:26,代码来源:ListCodeSnippet.cs
示例14: Generate
public string Generate(Repository repository, Models.DataRuleSetting dataRule)
{
if (dataRule.DataRule is DataRuleBase)
{
var dataRuleBase = (DataRuleBase)dataRule.DataRule;
var schema = dataRuleBase.GetSchema(repository).AsActual();
string html = @"
<h2><%: ViewBag.{0}.{1} ?? """" %></h2>
<ul class=""detail {2}-detail"">
{3}
</ul>";
string columnTp = @"
<li>
{0}:
<p> <%: ViewBag.{1}.{0} ?? """" %> </p>
</li>
";
var titleField = schema.GetSummarizeColumn().Name;
schema = schema.AsActual();
StringBuilder sb = new StringBuilder();
foreach (var column in schema.Columns)
{
if (!column.Name.EqualsOrNullEmpty(titleField, StringComparison.CurrentCultureIgnoreCase))
{
sb.AppendFormat(columnTp, column.Name, dataRule.DataName);
}
}
return string.Format(html, dataRule.DataName, schema.GetSummarizeColumn().Name, schema.Name, sb.ToString());
}
return string.Empty;
}
开发者ID:Godoy,项目名称:CMS,代码行数:33,代码来源:DetailCodeSnippet.cs
示例15: CopyDocument
public string CopyDocument(string repositoryId, string sourceId, NCMIS.ObjectModel.CmisProperties properties, string folderId)
{
string id;
if (!TryPraseObjectId(sourceId, out id))
throw new Exception("Invalid docuemnt id. parameter name \"sourceId\"");
string contentUUID;
Kooboo.CMS.Content.Models.Repository repository = new Repository(repositoryId);
var sourceFolder = ParseDocumentId(repository, id, out contentUUID);
IContentManager contentManager;
IContentQuery<ContentBase> contentQuery;
if (sourceFolder is TextFolder)
{
contentManager = ServiceFactory.TextContentManager;
contentQuery = ((TextFolder)sourceFolder).CreateQuery().WhereEquals("UUID", contentUUID);
}
else
{
contentManager = ServiceFactory.MediaContentManager;
contentQuery = ((MediaFolder)sourceFolder).CreateQuery().WhereEquals("UUID", contentUUID);
}
FolderObjectService folderObjectService = (FolderObjectService)ObjectService.GetService(typeof(Folder));
string objectId = folderId;
folderObjectService.TryPraseObjectId(folderId, out folderId);
var targetFolder = CmisFolderHelper.Parse(repository, folderId);
var content = contentManager.Copy(contentQuery.First(), targetFolder, null, properties.ToNameValueCollection());
return GetObjectId(content);
}
开发者ID:Godoy,项目名称:CMS,代码行数:30,代码来源:DocumentObjectService.cs
示例16: CategoriesQueryTests
static CategoriesQueryTests()
{
repository = new Repository("CategoriesQueryTests");
categorySchema = new Schema(repository, "category");
categorySchema.AddColumn(new Column() { Name = "title", DataType = DataType.String, Length = 256 });
categoryFolder = new TextFolder(repository, "category") { SchemaName = categorySchema.Name };
newsSchema = new Schema(repository, "news");
newsSchema.AddColumn(new Column()
{
Name = "Title",
DataType = DataType.String,
Length = 256
});
newsSchema.AddColumn(new Column()
{
Name = "Comments",
DataType = DataType.Int
});
newsFolder = new TextFolder(repository, "news") { SchemaName = newsSchema.Name, CategoryFolders = new[] { categoryFolder.Name } };
ProviderFactory providerFactory = new ProviderFactory();
Providers.DefaultProviderFactory = providerFactory;
providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
providerFactory.GetProvider<ISchemaProvider>().Add(categorySchema);
providerFactory.GetProvider<ISchemaProvider>().Add(newsSchema);
providerFactory.GetProvider<ITextFolderProvider>().Add(newsFolder);
providerFactory.GetProvider<ITextFolderProvider>().Add(categoryFolder);
InitializeData();
}
开发者ID:Epitomy,项目名称:CMS,代码行数:33,代码来源:CategoriesQueryTests.cs
示例17: InitializeDatabase
public static void InitializeDatabase(Repository repository)
{
//if (!SqlServerSettings.Instance.SharingDatabase)
//{
// if (SqlServerSettings.Instance.GetConnection(repository.Name) == null)
// {
// lock (locker)
// {
// if (SqlServerSettings.Instance.GetConnection(repository.Name) == null)
// {
// var dataFile = GetDatabaseFile(repository);
// var connectionString = GetIndividualDatabaseConnectionString(SqlServerSettings.Instance.CreateDatabaseSetting, repository);
// if (!File.Exists(dataFile))
// {
// CreateDatabase(repository, SqlServerSettings.Instance.CreateDatabaseSetting);
// }
// SqlServerSettings.Instance.AddConnection(new ConnectionSetting() { Name = repository.Name, ConnectionString = connectionString });
// SqlServerSettings.Instance.Save();
// }
// }
// }
//}
SchemaManager.InitializeRepositoryDatabase(repository);
}
开发者ID:Godoy,项目名称:CMS,代码行数:27,代码来源:DatabaseHelper.cs
示例18: DeleteRepositoryContainer
public static void DeleteRepositoryContainer(Repository repository)
{
var blobClient = CloudStorageAccountHelper.GetStorageAccount().CreateCloudBlobClient();
var container = blobClient.GetContainerReference(repository.Name.ToLower());
container.Delete();
}
开发者ID:rongzhi-Kooboo,项目名称:CMS,代码行数:8,代码来源:MediaBlobHelper.cs
示例19: InitializeMediaContents
public void InitializeMediaContents(Repository repository)
{
Kooboo.CMS.Content.Persistence.Default.MediaFolderProvider fileMediaFolderProvider = new Default.MediaFolderProvider();
foreach (var item in fileMediaFolderProvider.All(repository))
{
ImportMediaFolderDataCascading(fileMediaFolderProvider.Get(item));
}
}
开发者ID:Epitomy,项目名称:CMS,代码行数:8,代码来源:MediaContentProvider.cs
示例20: Delete
public virtual ActionResult Delete(string repositoryName)
{
if (!string.IsNullOrEmpty(repositoryName))
{
var repository = new Repository(repositoryName);
Manager.Remove(repository);
}
return RedirectToAction("Index", "Home");
}
开发者ID:kooboo-jifeng,项目名称:CMS,代码行数:9,代码来源:RepositoryController.cs
注:本文中的Kooboo.CMS.Content.Models.Repository类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论