public JsonResult guardaDocumentoOriginacion1() { var usr = (Login)System.Web.HttpContext.Current.Session["usr"]; if (usr == null) { Login(); return(null); } HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase; DocumentoOriginacion _doc = new DocumentoOriginacion(); //Extraer Documentos var ext = Path.GetExtension(hpf.FileName); //Crea Entidad para guardar _doc.folder = Request.Form["folder"]; _doc.dependencia = double.Parse(Request.Form["dependencia"]); _doc.producto = double.Parse(Request.Form["producto"]); _doc.expedienteCompleto = 1; _doc.firma = 0; _doc.nombreDoc = hpf.FileName; _doc.codigo_doc = null; //DocumentoOriginacion _doc = JsonConvert.DeserializeObject<DocumentoOriginacion>(documento); ManageDocuments manage = new ManageDocuments(); LogHelper.WriteLog("Controller", "ProfileController", "guardaDocumentoOriginacion1", new Exception(), "Subir Expediente Completo"); manage.CargarExpedienteCompleto(ref _doc, hpf); LogHelper.WriteLog("Controller", "ProfileController", "guardaDocumentoOriginacion1", new Exception(), "Respuesta Carga de Expediente Completo"); return(new JsonResult { Data = _doc, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult EditarArchvio(string archivo, string opcion) { var usr = (Login)System.Web.HttpContext.Current.Session["usr"]; if (usr == null) { Login(); return(null); } string[] wordKey = new string[] { "SELECT", "FROM", "WHERE", "=" }; for (var i = 0; i < wordKey.Length; i++) { if (opcion.IndexOf(wordKey[i]) > -1) { Login(); return(null); } } ParamGuias _doc = JsonConvert.DeserializeObject <ParamGuias>(archivo); var data = new ManageDocuments().EditarArchivo(ref _doc, opcion); return(new JsonResult { Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult GetIdTablas(double codigo) { var usr = (Login)System.Web.HttpContext.Current.Session["usr"]; if (usr == null) { Login(); return(null); } var data = new ManageDocuments().GetIdTablas(codigo); return(new JsonResult { Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult GetUploadDocuments() { var usr = (Login)System.Web.HttpContext.Current.Session["usr"]; if (usr == null) { RedirectToAction("Index", "Home"); return(null); } string executiveID = usr.userName; var documents = new ManageDocuments().GetUploadDocuments(executiveID); return(new JsonResult { Data = documents, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult EliminarArchvio(double codigo, string opcion) { var usr = (Login)System.Web.HttpContext.Current.Session["usr"]; if (usr == null) { Login(); return(null); } string[] wordKey = new string[] { "SELECT", "FROM", "WHERE", "=" }; for (var i = 0; i < wordKey.Length; i++) { if (opcion.IndexOf(wordKey[i]) > -1) { Login(); return(null); } } var data = new ManageDocuments().EliminarArchvio(codigo, opcion); return(new JsonResult { Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
protected void Submit(object sender, EventArgs e) { CloudFuns obj = new CloudFuns(); int docid = obj.FetchMax("uploads", "uploadid"); string userid = Convert.ToString(Session["userid"]); string newname = "NA", encfilename = "", filePath = "", metaxml = ""; string input = "", output = "", seckey = "", ext = ""; long sizebytes = 0; int dd = DateTime.Now.Day; int mm = DateTime.Now.Month; int yy = DateTime.Now.Year; string today = dd + "-" + mm + "-" + yy; int hr = DateTime.Now.Hour; string now = hr + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second; try { if (filedocument.HasFile) { string filename = filedocument.FileName; ext = System.IO.Path.GetExtension(filename); filePath = Server.MapPath("UserDocs/") + userid + "/"; metaxml = docid + "_xml.xml"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } newname = "doc" + docid + ext; //--------------------------------- input = filePath + "/" + newname; encfilename = "doc" + docid + "_enc" + ext; output = filePath + "/" + encfilename; if (File.Exists(input)) { File.Delete(input); } // save file for encryption filedocument.SaveAs(input); // Calculate SHA Hash of the original document SHATracker track = new SHATracker(); string shavalue = track.GetSHA1Hash(input); FileInfo f = new FileInfo(input); sizebytes = f.Length; // Generate Keys Random r = new Random(); seckey = "SEC" + docid + "@" + r.Next(111, 999); string dockey = docid + newname + "|D@C_" + now.Replace(":", ""); // read all bytes from uploaded file byte[] file = System.IO.File.ReadAllBytes(input); // reverse and store file bytes into another byte array int filelength = file.Length; int index = filelength - 1; byte[] rev_file = new byte[filelength]; foreach (byte b in file) { rev_file[index] = b; index--; } // create a file from reversed bytes and store on local server string rev_file_path = filePath + "/rev_file" + docid + ext; try { if (File.Exists(rev_file_path)) { FileStream fs = new FileStream(rev_file_path, FileMode.Open, FileAccess.Read, FileShare.None); fs.Close(); File.Delete(rev_file_path); } } catch (Exception ex) { } File.WriteAllBytes(rev_file_path, rev_file); // encrypt the file if (File.Exists(output)) { File.Delete(output); } Cryptography cobj = new Cryptography(); cobj.EncryptAES(rev_file_path, output, dockey); // Store data in DB ArrayList data = new ArrayList(); data.Clear(); data.Add(docid); data.Add(txttitle.Text); data.Add(sizebytes); data.Add(txtdesc.Text); data.Add(userid); data.Add(metaxml); data.Add(dockey); data.Add(seckey); data.Add(today); data.Add(now); data.Add(encfilename); ManageDocuments dobj = new ManageDocuments(); if (dobj.NewDoc(data)) { // create metadata XML file and store on local server DataSet dsxml = new DataSet(); dsxml.Tables.Add(); dsxml.Tables[0].Columns.Add(); dsxml.Tables[0].Columns[0].ColumnName = "dochash"; dsxml.Tables[0].Columns.Add(); dsxml.Tables[0].Columns[1].ColumnName = "uploaddt"; dsxml.Tables[0].Columns.Add(); dsxml.Tables[0].Columns[2].ColumnName = "uploadtime"; dsxml.Tables[0].Columns.Add(); dsxml.Tables[0].Columns[3].ColumnName = "docid"; dsxml.Tables[0].Rows.Add(); dsxml.Tables[0].Rows[0][0] = shavalue; dsxml.Tables[0].Rows[0][1] = today; dsxml.Tables[0].Rows[0][2] = now; dsxml.Tables[0].Rows[0][3] = docid; if (File.Exists(filePath + metaxml)) { File.Delete(filePath + metaxml); } dsxml.WriteXml(filePath + metaxml); // store file on storage and backup server BackupHost info = new BackupHost(); WebClient oclient = new WebClient(); byte[] responseArray = oclient.UploadFile("http://" + info.StorageHostName + ":" + info.StorageHostPort + "/Receiver.aspx?path=" + userid, "POST", output); byte[] responseArray1 = oclient.UploadFile("http://" + info.BackupHostName + ":" + info.BackupHostPort + "/Receiver.aspx?path=" + userid, "POST", output); value = 1; if (File.Exists(input)) { File.Delete(input); } if (File.Exists(output)) { File.Delete(output); } try { if (File.Exists(rev_file_path)) { FileStream fs = null; try { fs = new FileStream(rev_file_path, FileMode.Open, FileAccess.ReadWrite, FileShare.None); fs.Close(); } catch (Exception ex) { } File.Delete(rev_file_path); } } catch (Exception ex) { } GetClientDetails dtl = new GetClientDetails(userid); string name = dtl.ClientName; string email = dtl.ClientEmailId; EmailService mail = new EmailService(); mail.sendSecKey(email, seckey, name, txttitle.Text); RecordUsage rec = new RecordUsage(); rec.record(userid, "upload"); rec.record(userid, "encryption"); } else { value = 0; } } } catch (Exception ex) { value = 0; } if (value == 1) { message = "File uploaded successfully.."; title = "Success Report"; } else if (value == 0) { message = "Sorry.!! File upload failed.. Try again.."; title = "Failure Report"; } string script = "window.onload = function(){ alert('"; script += message; script += "')};"; ClientScript.RegisterStartupScript(this.GetType(), title, script, true); ClearInputs(Page.Controls); }