public ActionResult Edit() { document = (DocumentAccess)Session["document"]; document.Type = Request.Form["fileType"]; if (Request.Form["trainings"] == "") { document.TrainingId = 0; } else { document.TrainingId = Convert.ToInt32(Request.Form["trainings"]); } document.Description = Request.Form["description"]; if (documentService.Update(document)) { if (document.TrainingId == 0) { return(RedirectToAction("DocumentWithoutTraining")); } else { return(RedirectToAction("Index")); } } return(View("Edit")); }
/// <summary> /// 设置书籍是否公开 /// </summary> /// <param name="bookid"></param> /// <param name="access"></param> public void SetBookState(long bookid, DocumentAccess access) { using (var db = this.OpenDb()) { CreateTableIfNotExist(); db.Execute("update books set is_public= @is_public where id=@id", new { id = bookid, is_public = access }); } }
/// <summary> /// Creates an instace of the PolicyDocument using the stream provided with an Xml document. /// </summary> /// <param name="xmlDocument">The stream containing an Xml document.</param> /// <param name="version">The version of the schema that will be used to validate.</param> /// <param name="access">The type of PolicyDocument</param> /// <returns>An instance of a PolicyDocument.</returns> public static PolicyDocumentReadWrite LoadPolicyDocument(Stream xmlDocument, XacmlVersion version, DocumentAccess access) { // Validate the parameters if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } return LoadPolicyDocument(new StreamReader(xmlDocument), version, access); }
/// <summary> /// 根据给定的xml文档字符串创建一个策略文档。 /// </summary> /// <param name="xmlDocument">xml文档片段</param> /// <param name="access">文档可访问性</param> /// <returns>一个策略文档实例</returns> public static PolicyDocumentReadWrite LoadPolicyDocument(string xmlDocument, DocumentAccess access) { if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } XacmlVersion version = GetXacmlVersion(new StreamReader(xmlDocument)); return LoadPolicyDocument(new StringReader(xmlDocument), version, access); }
/// <summary> /// 根据给定的xml文档字符串创建一个策略文档。 /// </summary> /// <param name="xmlDocument">xml文档片段</param> /// <param name="access">文档可访问性</param> /// <returns>一个策略文档实例</returns> public static PolicyDocumentReadWrite LoadPolicyDocument(string xmlDocument, DocumentAccess access) { if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } XacmlVersion version = GetXacmlVersion(new StreamReader(xmlDocument)); return(LoadPolicyDocument(new StringReader(xmlDocument), version, access)); }
/// <summary> /// 设置书籍是否公开 /// </summary> /// <param name="bookid"></param> /// <param name="access"></param> /// <returns></returns> public ActionResult SetBookState(long bookid, DocumentAccess access) { try { docMgr.SetBookState(bookid, access); return(Success()); } catch (Exception ex) { return(Fail(ex.Message)); } }
public ActionResult ChangeDocAccess(int docId, DocumentAccess oldIdAccess) { var model = new AccessViewModel() { DocumentID = docId, OldAccess = oldIdAccess, NewAccess = oldIdAccess, ListAccess = accessRepository.GetAccess() }; return(PartialView(model)); }
/// <summary> /// Creates an instace of the PolicyDocument using the provided Xml document string. /// </summary> /// <param name="xmlDocument">The Xml document fragment.</param> /// <param name="access">The type of PolicyDocument</param> /// <returns>An instance of a PolicyDocument.</returns> public static pol.PolicyDocumentReadWrite LoadPolicyDocument( string xmlDocument, DocumentAccess access ) { // Validate the parameters if( xmlDocument == null ) { throw new ArgumentNullException( nameof(xmlDocument) ); } // Read the document to determine the version of the schema used. XacmlVersion version = GetXacmlVersion( new StreamReader( xmlDocument ) ); return LoadPolicyDocument( new StringReader( xmlDocument ), version, access ); }
private Document getDocument(int id) { try { DocumentAccess db = new DocumentAccess(); Document document = db.GetOne(id); return(document); } catch (Exception ex) { return(null); } }
public static ContextDocumentReadWrite Create(XmlReader reader, XacmlVersion schemaVersion, DocumentAccess access) { if (reader == null) { throw new ArgumentNullException("reader"); } switch (access) { case DocumentAccess.ReadOnly: return new ContextDocument(reader, schemaVersion); case DocumentAccess.ReadWrite: return new ContextDocumentReadWrite(reader, schemaVersion); } return null; }
public ActionResult CreateBook(string name, string description, string category) { ViewBag.Action = "CreateBook"; try { DocumentAccess access = Request["is_public"] == "on" ? DocumentAccess.PUBLIC : DocumentAccess.PRIVATE; var id = docMgr.CreateBook(this.UserId, name, description, category, "", access); return(RedirectToAction("EditBook", new { id = id })); } catch (Exception ex) { TempData.Add("Error", ex.Message); } return(View()); }
public static PolicyDocumentReadWrite Create(XmlReader reader, XacmlVersion version, DocumentAccess access) { // Validate the parameters if (reader == null) { throw new ArgumentNullException("reader"); } if (access.Equals(DocumentAccess.ReadOnly)) { return new PolicyDocument(reader, version); } else if (access.Equals(DocumentAccess.ReadWrite)) { return new PolicyDocumentReadWrite(reader, version); } return null; }
//Delete a document which doesn't belonge to any training. public ActionResult DeleteFromWithoutTrainingList(int id = 0, string documentName = null) { if (id == 0) { TempData["message"] = "Please select an entry."; return(RedirectToAction("Index")); } documents = (List <DocumentAccess>)Session["documents"]; foreach (var item in documents) { if (item.DocumentId == id) { document = item; Session.Add("document", document); } } var path = Path.Combine(Server.MapPath("~/App_Data/File"), documentName); FileInfo file = new FileInfo(path); if (file.Exists) { try { file.Delete(); List <int> idList = new List <int>(); idList.Add(document.DocumentId); documentService.Delete(idList); TempData["message"] = "Document has been deleted"; return(RedirectToAction("DocumentWithoutTraining")); } catch (Exception ex) { TempData["message"] = "Failed to delete the document " + documentName + " . Error: " + ex.GetBaseException().Message; return(RedirectToAction("DocumentWithoutTraining")); } } else { TempData["message"] = "Can not find the document."; return(RedirectToAction("DocumentWithoutTraining")); } }
/// <summary> /// 创建或更新文档 /// </summary> /// <param name="id"></param> /// <param name="content"></param> /// <param name="title"></param> /// <param name="category"></param> public void Update(long id, string content, string title, string category, DocumentAccess access, string userId) { using (var db = this.OpenDb()) { CreateTableIfNotExist(); SaveCategory(id, category, db); db.Execute("update documents_owner set update_at=datetime('now', 'localtime'), is_public=@access, creator=@userId where id=@id", new { id = id, access = access, userId = userId }); db.Execute("update documents set title=@title, content=@content, category=@category where rowid=@rowid", new { rowid = id, title = title, content = content, category = category }); _indexMgr.AddOrUpdateDocIndex(new Doc { Id = id.ToString(), Category = category, Content = content, Title = title, Operate = Operate.AddOrUpdate }); //ClearNotExistsAtachFile(id); } }
//Edit document infomation. public ActionResult Edit(int id = 0) { if (id == 0) { TempData["message"] = "Please select an entry."; return(RedirectToAction("Index")); } SelectListItem PDF = new SelectListItem() { Text = "PDF File", Value = "PDF" }; SelectListItem PPT = new SelectListItem() { Text = "PPT File", Value = "PPT" }; SelectListItem DOC = new SelectListItem() { Text = "Word", Value = "DOC" }; SelectListItem EXCEL = new SelectListItem() { Text = "EXCEL", Value = "EXCEL" }; documents = (List <DocumentAccess>)Session["documents"]; foreach (var item in documents) { if (item.DocumentId == id) { document = item; Session.Add("document", document); } } trainings = trainingService.GetTrainingData(); ViewBag.trainings = new SelectList(trainings, "trainingId", "trainingName", document.TrainingId); ViewBag.fileType = new SelectList(new SelectListItem[] { PDF, PPT, DOC, EXCEL }, "Value", "Text", document.Type); ViewBag.document = document; return(View()); }
/// <summary> /// Удаление документы из базы /// </summary> public void DeleteDocument(int documentID, DocumentAccess access) { if (access == DocumentAccess.Partial) { RemoveDocumentFromM2M(documentID); } using (var connection = this.factory.CreateConnection()) { connection.ConnectionString = this.connectionString; var command = (SqlCommand)connection.CreateCommand(); command.CommandText = string.Format( "DELETE FROM Documents " + "WHERE DocumentID = {0}", documentID); command.CommandType = CommandType.Text; connection.Open(); command.ExecuteNonQuery(); } }
/// <summary> /// Creates an instace of the PolicyDocument using the stream provided with an Xml document. /// </summary> /// <param name="xmlDocument">The stream containing an Xml document.</param> /// <param name="access">The type of PolicyDocument</param> /// <returns>An instance of a PolicyDocument.</returns> public static PolicyDocumentReadWrite LoadPolicyDocument(Stream xmlDocument, DocumentAccess access) { // Validate the parameters if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } // Validate the stream if (!xmlDocument.CanSeek) { throw new ArgumentException(Properties.Resource.exc_invalid_stream_parameter_canseek, "xmlDocument"); } // Read the document to determine the version of the schema used. XacmlVersion version = GetXacmlVersion(new StreamReader(xmlDocument)); xmlDocument.Position = 0; return(LoadPolicyDocument(new StreamReader(xmlDocument), version, access)); }
/// <summary> /// Creates an instace of the PolicyDocument using the stream provided with an Xml document. /// </summary> /// <param name="xmlDocument">The stream containing an Xml document.</param> /// <param name="access">The type of PolicyDocument</param> /// <returns>An instance of a PolicyDocument.</returns> public static PolicyDocumentReadWrite LoadPolicyDocument(Stream xmlDocument, DocumentAccess access) { // Validate the parameters if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } // Validate the stream if (!xmlDocument.CanSeek) { throw new ArgumentException(Properties.Resource.exc_invalid_stream_parameter_canseek, "xmlDocument"); } // Read the document to determine the version of the schema used. XacmlVersion version = GetXacmlVersion(new StreamReader(xmlDocument)); xmlDocument.Position = 0; return LoadPolicyDocument(new StreamReader(xmlDocument), version, access); }
/// <summary> /// Сменить доступ к документу /// </summary> public void ChangeAccess(int documentID, DocumentAccess newAccess, DocumentAccess oldAccess) { if (oldAccess == DocumentAccess.Partial && newAccess != DocumentAccess.Partial) { RemoveDocumentFromM2M(documentID); } using (var connection = this.factory.CreateConnection()) { connection.ConnectionString = this.connectionString; var command = (SqlCommand)connection.CreateCommand(); command.CommandText = string.Format( "UPDATE Documents SET AccessID = '{0}' WHERE DocumentID = '{1}'", (int)newAccess, documentID); command.CommandType = CommandType.Text; connection.Open(); command.ExecuteNonQuery(); } }
/// <summary> /// 根据给定的xml文档字符串创建一个策略文档。 /// </summary> /// <param name="xmlDocument">xml文档片段</param> /// <param name="version">用于验证的模式版本号</param> /// <param name="access">文档可访问性</param> /// <returns>一个策略文档实例</returns> public static PolicyDocumentReadWrite LoadPolicyDocument(TextReader xmlDocument, XacmlVersion version, DocumentAccess access) { if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } return LoadPolicyDocument(new XmlTextReader(xmlDocument), version, access); }
/// <summary> /// Creates an instace of the PolicyDocument using the provided Xml document string. /// </summary> /// <param name="xmlDocument">The Xml document fragment.</param> /// <param name="version">The version of the schema that will be used to validate.</param> /// <param name="access">The type of PolicyDocument</param> /// <returns>An instance of a PolicyDocument.</returns> public static pol.PolicyDocumentReadWrite LoadPolicyDocument( TextReader xmlDocument, XacmlVersion version, DocumentAccess access ) { // Validate the parameters if( xmlDocument == null ) { throw new ArgumentNullException( nameof(xmlDocument) ); } return LoadPolicyDocument( new XmlTextReader( xmlDocument ), version, access ); }
/// <summary> /// Creates an instance of the ContextDocument using the XmlReader instance provided. /// </summary> /// <param name="reader">The XmlReader used to read the Xml document.</param> /// <param name="schemaVersion">The versoin of the schema used to validate the document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument.</returns> public static ContextDocumentReadWrite LoadContextDocument(XmlReader reader, XacmlVersion schemaVersion, DocumentAccess access) { return(ContextDocument.Create(reader, schemaVersion, access)); }
/// <summary> /// Creates an instace of the ContextDocument using the stream provided with an Xml document. /// </summary> /// <param name="xmlDocument">The stream containing an Xml document.</param> /// <param name="schemaVersion">The version of the schema used to validate the document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument.</returns> public static ContextDocumentReadWrite LoadContextDocument(Stream xmlDocument, XacmlVersion schemaVersion, DocumentAccess access) { if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } return(LoadContextDocument(new XmlTextReader(new StreamReader(xmlDocument)), schemaVersion, access)); }
public ActionResult documentAccessReport() { var viewModel = new DocumentAccess(); var doc_acc = new List <Document_Access_Log>(); var typeslist = new List <DocType>(); var doclist = new List <Doc>(); var personlist = new List <DocPerson>(); var accesslist = new List <DocAcc>(); var runcount1 = 0; var runcount2 = 0; foreach (var item in db.Document_Repository) { if (db.Document_Access_Log.Any(x => x.Document_Seq == item.Document_Seq)) { var type = db.Document_Type.Find(item.Document_Type_ID); if (!typeslist.Any(x => x.doc_type == type.Document_Type_Name)) { var doctype = new DocType(); doctype.doc_type = type.Document_Type_Name; var doctype_ = (db.Document_Access_Log.Where(x => x.Document_Repository.Document_Type_ID == type.Document_Type_ID)); var unique = (doctype_.GroupBy(x => x.Document_Seq)).Count(); runcount1 = runcount1 + unique; doctype.doc_count = runcount1; typeslist.Add(doctype); } var doc = new Doc(); doc.doc_id = item.Document_Seq; doc.doc_name = db.Document_Repository.Find(item.Document_Seq).Document_Name; var ext = (from d in db.Document_Extension where d.Document_Extension_ID == item.Document_Extension_ID select d.Extension_Type).Single(); doc.doc_ext = ext; var count = (db.Document_Access_Log.Where(x => x.Document_Seq == doc.doc_id)).Count(); runcount2 = runcount2 + count; doc.count = runcount2; var doc_access = (db.Document_Access_Log.Where(x => x.Document_Seq == item.Document_Seq)).ToList(); //var test = (db.Document_Access_Log.Where(x => x.Document_Seq == item.Document_Seq).Select(x => x.Person_Session_Log).Distinct()).ToList(); foreach (var da in doc_access) { //attempted code at creating the 3rd control break at person //var id = (from b in db.Person_Session_Log // where b.Session_ID == da.Session_ID // select b.Person_ID).Single(); //var person_count = (from f in db.Person_Session_Log // where f.Session_ID == da.Session_ID // select f.Person_ID).Distinct().Count(); //doc.person_count = person_count; //var docperson = new DocPerson(); //var person = (from b in db.Person_Session_Log // where b.Session_ID == da.Session_ID // select b.Person_ID).Single(); //docperson.person_id = person; //var pName = (from c in db.Registered_Person // where c.Person_ID == person // select c.Person_Name).Single(); //docperson.person_name = pName; //var access = (from g in db.Person_Session_Log // where g.Session_ID == da.Session_ID // select g); //int i = 0; //foreach (var p in access) //{ // if (p.Person_ID == person) // { // i = i + 1; // } //} //docperson.access_count = i; //var acc = new DocAcc(); //acc.accessed = da.Access_DateTime; //personlist.Add(docperson); //accesslist.Add(acc); doc_acc.Add(da); } doclist.Add(doc); } } viewModel.doc_types = typeslist; viewModel.docs = doclist; viewModel.doc_access = doc_acc; //viewModel.doc_persons = personlist; //viewModel.doc_acc = accesslist; return(View(viewModel)); }
/// <summary> /// Creates an instace of the PolicyDocument using the provided Xml document string. /// </summary> /// <param name="xmlDocument">The Xml document fragment.</param> /// <param name="access">The type of PolicyDocument</param> /// <returns>An instance of a PolicyDocument.</returns> public static pol.PolicyDocumentReadWrite LoadPolicyDocument(string xmlDocument, DocumentAccess access) { // Validate the parameters if (xmlDocument == null) { throw new ArgumentNullException(nameof(xmlDocument)); } // Read the document to determine the version of the schema used. XacmlVersion version = GetXacmlVersion(new StreamReader(xmlDocument)); return(LoadPolicyDocument(new StringReader(xmlDocument), version, access)); }
/// <summary> /// Creates an instace of the PolicyDocument using the stream provided with an Xml document. /// </summary> /// <param name="xmlDocument">The stream containing an Xml document.</param> /// <param name="version">The version of the schema that will be used to validate.</param> /// <param name="access">The type of PolicyDocument</param> /// <returns>An instance of a PolicyDocument.</returns> public static PolicyDocumentReadWrite LoadPolicyDocument(Stream xmlDocument, XacmlVersion version, DocumentAccess access) { // Validate the parameters if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } return(LoadPolicyDocument(new StreamReader(xmlDocument), version, access)); }
/// <summary> /// Creates an instace of the ContextDocument using the stream provided with an Xml document. /// </summary> /// <param name="xmlDocument">The stream containing an Xml document.</param> /// <param name="schemaVersion">The version of the schema used to validate the document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument.</returns> public static ctx.ContextDocumentReadWrite LoadContextDocument( Stream xmlDocument, XacmlVersion schemaVersion, DocumentAccess access ) { // Validate the parameters if( xmlDocument == null ) { throw new ArgumentNullException( "xmlDocument" ); } return LoadContextDocument( new XmlTextReader( new StreamReader( xmlDocument ) ), schemaVersion, access ); }
/// <summary> /// 创建 Book /// </summary> /// <param name="userId"></param> /// <param name="name"></param> /// <param name="description"></param> /// <param name="category"></param> /// <param name="image_url"></param> /// <returns></returns> public long CreateBook(string userId, string name, string description, string category, string image_url, DocumentAccess access) { if (string.IsNullOrWhiteSpace(name)) { throw new Exception("书名不能为空"); } using (var db = this.OpenDb()) { CreateTableIfNotExist(); var bookid = GetId("book"); db.Execute(@" insert into books(id, creator, name, description, category, image_url, is_public) values(@id, @creator, @name, @description, @category, @image_url, @is_public); insert into book_owner(book_id, user_id, is_owner) values(@id, @creator, 1); ", new { id = bookid, creator = userId, name, description, category, image_url, is_public = access }); _indexMgr.AddOrUpdateDocIndex(new Doc { Id = bookid.ToString(), Category = category, Content = description, Title = name, Operate = Operate.AddOrUpdate }); return(bookid); } }
/// <summary> /// 根据给定的xml文档字符串创建一个策略文档。 /// </summary> /// <param name="xmlDocument">xml文档片段</param> /// <param name="version">用于验证的模式版本号</param> /// <param name="access">文档可访问性</param> /// <returns>一个策略文档实例</returns> public static PolicyDocumentReadWrite LoadPolicyDocument(TextReader xmlDocument, XacmlVersion version, DocumentAccess access) { if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } return(LoadPolicyDocument(new XmlTextReader(xmlDocument), version, access)); }
/// <summary> /// Creates an instace of the PolicyDocument using the provided Xml document string. /// </summary> /// <param name="xmlDocument">The Xml document fragment.</param> /// <param name="version">The version of the schema that will be used to validate.</param> /// <param name="access">The type of PolicyDocument</param> /// <returns>An instance of a PolicyDocument.</returns> public static pol.PolicyDocumentReadWrite LoadPolicyDocument(TextReader xmlDocument, XacmlVersion version, DocumentAccess access) { // Validate the parameters if (xmlDocument == null) { throw new ArgumentNullException(nameof(xmlDocument)); } return(LoadPolicyDocument(new XmlTextReader(xmlDocument), version, access)); }
/// <summary> /// 更新书本 /// </summary> /// <param name="userid"></param> /// <param name="bookid"></param> /// <param name="name"></param> /// <param name="description"></param> /// <param name="category"></param> /// <param name="image_url"></param> public void UpdateBook(string userid, long bookid, string name, string description, string category, string image_url, DocumentAccess access) { if (string.IsNullOrWhiteSpace(name)) { throw new Exception("书名不能为空"); } using (var db = this.OpenDb()) { CreateTableIfNotExist(); CheckPermissionForUpdateBook(userid, db, bookid); db.Execute("update books set name=@name, description=@description, category=@category, image_url=@image_url, is_public = @is_public, update_at = datetime('now', 'localtime') where id=@id", new { name = name, description = description, category = category, image_url = image_url, id = bookid, is_public = access }); _indexMgr.AddOrUpdateDocIndex(new Doc { Id = bookid.ToString(), Category = category, Content = description, Title = name, Operate = Operate.AddOrUpdate }); } }
/// <summary> /// Creates an instance of the PolicyDocument using the XmlReader instance provided. /// </summary> /// <param name="reader">The XmlReader used to read the Xml document.</param> /// <param name="version">The version of the schema that will be used to validate.</param> /// <param name="access">The type of PolicyDocument</param> /// <returns>An instance of a PolicyDocument.</returns> public static pol.PolicyDocumentReadWrite LoadPolicyDocument(XmlReader reader, XacmlVersion version, DocumentAccess access) { // Validate the parameters if (reader == null) { throw new ArgumentNullException(nameof(reader)); } if (access.Equals(DocumentAccess.ReadOnly)) { return(new pol.PolicyDocument(reader, version)); } else if (access.Equals(DocumentAccess.ReadWrite)) { return(new pol.PolicyDocumentReadWrite(reader, version)); } return(null); }
/// <summary> /// Creates an instance of the ContextDocument using the XmlReader instance provided. /// </summary> /// <param name="reader">The XmlReader used to read the Xml document.</param> /// <param name="schemaVersion">The versoin of the schema used to validate the document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument.</returns> public static ctx.ContextDocumentReadWrite LoadContextDocument(XmlReader reader, XacmlVersion schemaVersion, DocumentAccess access) { // Validate the parameters if (reader == null) { throw new ArgumentNullException("reader"); } if (access == DocumentAccess.ReadOnly) { return(new ctx.ContextDocument(reader, schemaVersion)); } else if (access == DocumentAccess.ReadWrite) { return(new ctx.ContextDocumentReadWrite(reader, schemaVersion)); } return(null); }
public DocumentManager(DocumentAccess documentAccess) { _documentAccess = documentAccess; }
/// <summary> /// Creates an instace of the ContextDocument using the stream provided with an Xml document. /// </summary> /// <param name="xmlDocument">The stream containing an Xml document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument.</returns> public static ctx.ContextDocumentReadWrite LoadContextDocument(Stream xmlDocument, DocumentAccess access) { // Validate the parameters if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } // Read the document to determine the version of the schema used. XacmlVersion version = GetXacmlVersion(new StreamReader(xmlDocument)); xmlDocument.Position = 0; return(LoadContextDocument(new XmlTextReader(new StreamReader(xmlDocument)), version, access)); }
public static ContextDocumentReadWrite Create(XmlReader reader, XacmlVersion schemaVersion, DocumentAccess access) { if (reader == null) { throw new ArgumentNullException("reader"); } switch (access) { case DocumentAccess.ReadOnly: return(new ContextDocument(reader, schemaVersion)); case DocumentAccess.ReadWrite: return(new ContextDocumentReadWrite(reader, schemaVersion)); } return(null); }
/// <summary> /// Creates an instace of the ContextDocument using the stream provided with an Xml document. /// </summary> /// <param name="xmlDocument">The stream containing an Xml document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument.</returns> public static ContextDocumentReadWrite LoadContextDocument(Stream xmlDocument, DocumentAccess access) { if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } XacmlVersion version = GetXacmlVersion(new StreamReader(xmlDocument)); xmlDocument.Position = 0; return(LoadContextDocument(new XmlTextReader(new StreamReader(xmlDocument)), version, access)); }
/// <summary> /// 创建文档 /// </summary> /// <param name="content"></param> /// <param name="title"></param> /// <param name="category"></param> /// <param name="userId"></param> /// <returns></returns> public Document Create(string content, string title, string category, string userId, DocumentAccess access) { using (var db = this.OpenDb()) { CreateTableIfNotExist(); var document = new Document { category = category, content = content, creator = userId, rowid = GetId("document"), title = title }; SaveCategory(document.rowid, category, db); db.Execute("insert into documents_owner(id, creator, is_public) values(@id, @creator, @isPublic)", new { id = document.rowid, creator = document.creator, isPublic = access }); db.Execute("insert into documents(rowid, title, content, category) values(@rowid, @title, @content, @category)", new { rowid = document.rowid, title = title, content = content, category = category }); _indexMgr.AddOrUpdateDocIndex(new Doc { Id = document.rowid.ToString(), Category = category, Content = content, Title = title, Operate = Operate.AddOrUpdate }); return(document); } }
/// <summary> /// Creates an instace of the ContextDocument using the provided Xml document string. /// </summary> /// <param name="xmlDocument">The Xml document fragment.</param> /// <param name="schemaVersion">The version of the schema used to validate the document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument/</returns> public static ctx.ContextDocumentReadWrite LoadContextDocument(string xmlDocument, XacmlVersion schemaVersion, DocumentAccess access) { // Validate the parameters if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } return(LoadContextDocument(new XmlTextReader(new StringReader(xmlDocument)), schemaVersion, access)); }
/// <summary> /// Creates an instace of the ContextDocument using the stream provided with an Xml document. /// </summary> /// <param name="xmlDocument">The stream containing an Xml document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument.</returns> public static ctx.ContextDocumentReadWrite LoadContextDocument( Stream xmlDocument, DocumentAccess access ) { // Validate the parameters if( xmlDocument == null ) { throw new ArgumentNullException( "xmlDocument" ); } // Read the document to determine the version of the schema used. XacmlVersion version = GetXacmlVersion( new StreamReader( xmlDocument ) ); xmlDocument.Position = 0; return LoadContextDocument( new XmlTextReader( new StreamReader( xmlDocument ) ), version, access ); }
/// <summary> /// Creates an instace of the ContextDocument using the stream provided with an Xml document. /// </summary> /// <param name="xmlDocument">The stream containing an Xml document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument.</returns> public static ContextDocumentReadWrite LoadContextDocument(Stream xmlDocument, DocumentAccess access) { if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } XacmlVersion version = GetXacmlVersion(new StreamReader(xmlDocument)); xmlDocument.Position = 0; return LoadContextDocument(new XmlTextReader(new StreamReader(xmlDocument)), version, access); }
/// <summary> /// Creates an instance of the ContextDocument using the XmlReader instance provided. /// </summary> /// <param name="reader">The XmlReader used to read the Xml document.</param> /// <param name="schemaVersion">The versoin of the schema used to validate the document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument.</returns> public static ctx.ContextDocumentReadWrite LoadContextDocument( XmlReader reader, XacmlVersion schemaVersion, DocumentAccess access ) { // Validate the parameters if( reader == null ) { throw new ArgumentNullException( "reader" ); } if( access == DocumentAccess.ReadOnly ) { return new ctx.ContextDocument( reader, schemaVersion ); } else if ( access == DocumentAccess.ReadWrite ) { return new ctx.ContextDocumentReadWrite( reader, schemaVersion ); } return null; }
/// <summary> /// Creates an instace of the ContextDocument using the provided Xml document string. /// </summary> /// <param name="xmlDocument">The Xml document fragment.</param> /// <param name="schemaVersion">The version of the schema used to validate the document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument/</returns> public static ContextDocumentReadWrite LoadContextDocument(string xmlDocument, XacmlVersion schemaVersion, DocumentAccess access) { if (xmlDocument == null) { throw new ArgumentNullException("xmlDocument"); } return LoadContextDocument(new XmlTextReader(new StringReader(xmlDocument)), schemaVersion, access); }
/// <summary> /// Creates an instance of the ContextDocument using the XmlReader instance provided. /// </summary> /// <param name="reader">The XmlReader used to read the Xml document.</param> /// <param name="schemaVersion">The versoin of the schema used to validate the document.</param> /// <param name="access">The access to the document (read-write/read-only)</param> /// <returns>An instance of a ContextDocument.</returns> public static ContextDocumentReadWrite LoadContextDocument(XmlReader reader, XacmlVersion schemaVersion, DocumentAccess access) { return ContextDocument.Create(reader, schemaVersion, access); }
/// <summary> /// 根据给定的xml文档字符串创建一个策略文档。 /// </summary> /// <param name="reader">用于读取xml文档的读取器</param> /// <param name="version">用于验证的模式版本号</param> /// <param name="access">文档可访问性</param> /// <returns>一个策略文档实例</returns> public static PolicyDocumentReadWrite LoadPolicyDocument(XmlReader reader, XacmlVersion version, DocumentAccess access) { return PolicyDocument.Create(reader, version, access); }