public ActionResult SignDocument() { Request.InputStream.Position = 0; System.IO.StreamReader str = new System.IO.StreamReader(Request.InputStream); string sBuf = str.ReadToEndAsync().Result; SignDocument jsonDocument = JsonConvert.DeserializeObject <SignDocument>(sBuf); byte[] doc = Convert.FromBase64String(jsonDocument.Document); // create a new ServerTextControl using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { tx.Create(); // load the signed document tx.Load(doc, TXTextControl.BinaryStreamType.InternalUnicodeFormat); // save the document as the current signed documet tx.Save(Server.MapPath("~/App_Data/documentflows/" + jsonDocument.UniqueId + "/signed.tx"), TXTextControl.StreamType.InternalUnicodeFormat); } // read the document flow structure string jsonFlow = System.IO.File.ReadAllText( Server.MapPath("~/App_Data/documentflows/" + jsonDocument.UniqueId + "/documentflow.json")); DocumentFlow documentflow = Newtonsoft.Json.JsonConvert.DeserializeObject <DocumentFlow>(jsonFlow); Signer signer = documentflow.Signers.Find(x => x.Id == int.Parse(jsonDocument.SignerId)); signer.SignatureComplete = true; // mark as completed // save the flow structure System.IO.File.WriteAllText( Server.MapPath("~/App_Data/documentflows/" + jsonDocument.UniqueId + "/documentflow.json"), Newtonsoft.Json.JsonConvert.SerializeObject(documentflow)); return(new JsonResult() { Data = true }); }
public void SaveSignDocument(Guid authorId, string xml, object model) { var signDocument = new SignDocument(); if (model != null) { signDocument.ClassName = model.GetType().FullName; var entity = model as IEntity; if (entity != null) { signDocument.ObjectId = entity.Id.ToString(); } } signDocument.CreatedTime = DateTime.Now; signDocument.EmployeeId = authorId; signDocument.SignXml = xml; AppContext.SignDocuments.Add(signDocument); AppContext.SaveChanges(); }