public IActionResult Create(StoredDocument doc) { if (ModelState.IsValid) { int inx = _service.StoreDocument(doc); if (inx > 0) { return(RedirectToAction("Details", inx)); } } return(View(doc)); }
public object GetDocByApacheLucene(StoredDocument doc) { //TODO throw new NotImplementedException(); }
public object GetDocByTikaondotner(StoredDocument doc) { //TODO throw new NotImplementedException(); }
public object GetSepcyfiedDocument(StoredDocument doc) { throw new NotImplementedException(); }
public int StoreDocument(StoredDocument doc) { _dbContext.Documents.Add(doc); _dbContext.SaveChanges(); return(_dbContext.Documents.Find(doc).Id); }
public ActionResult StoreDocument( [FromBody] string Document, [FromBody] string UniqueId, [FromBody] string SignerName) { byte[] bPDF; // create temporary ServerTextControl using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { tx.Create(); // load the document tx.Load(Convert.FromBase64String(Document), TXTextControl.BinaryStreamType.InternalUnicodeFormat); TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings() { CreatorApplication = "TX Text Control Sample Application", }; // save the document as PDF tx.Save(out bPDF, TXTextControl.BinaryStreamType.AdobePDF, saveSettings); } // calculate the MD5 checksum of the binary data // and store in SignedDocument object SignedDocument document = new SignedDocument() { Checksum = Checksum.CalculateMD5(bPDF) }; // define a Blockchain object Blockchain bcDocument; // if the blockchain exists, load it if (System.IO.File.Exists( Server.MapPath("~/App_Data/Blockchains/" + UniqueId + ".bc"))) { string bc = System.IO.File.ReadAllText( Server.MapPath("~/App_Data/Blockchains/" + UniqueId + ".bc")); bcDocument = JsonConvert.DeserializeObject <Blockchain>(bc); } else { bcDocument = new Blockchain(true); // otherwise create a new blockchain } // add a new block to the blockchain and store the SignedDocument object bcDocument.AddBlock(new Block(DateTime.Now, null, JsonConvert.SerializeObject(document))); // store the blockchain as a file System.IO.File.WriteAllText( Server.MapPath("~/App_Data/Blockchains/" + UniqueId + ".bc"), JsonConvert.SerializeObject(bcDocument)); // create and return a view model with the PDF and the unique document ID StoredDocument storedDocument = new StoredDocument() { PDF = Convert.ToBase64String(bPDF), DocumentId = UniqueId }; return(new JsonResult() { Data = storedDocument, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }