private static string UploadBlob(CloudBlobContainer container, LegalDocument legalDocument, string caseNo) { string blockreference = "case" + caseNo + "$" + legalDocument.FileName + "$" + legalDocument.DocumentNumber + "$" + legalDocument.Id.ToString() + "_" + legalDocument.DocumentType; CloudBlockBlob blockBlob = container.GetBlockBlobReference(blockreference); Stream stream = new MemoryStream(legalDocument.DocumentData); //try //{ // //set metadata // blockBlob.Metadata.Clear(); // blockBlob.Metadata["fileName"]= legalDocument.FileName; // blockBlob.Metadata["documentNumber"]= legalDocument.DocumentNumber; // blockBlob.Metadata["documentType"]= legalDocument.DocumentType; // blockBlob.SetMetadata(); // // //} //catch (Exception ex) //{ // throw; //} blockBlob.UploadFromStream(stream); string[] arrayuri = blockBlob.Uri.AbsoluteUri.ToString().Split('$');// Replace('$', '/'); string azureuri = arrayuri[0] + "/" + arrayuri[3]; return(azureuri); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Will,WillDateSigned,WillLastUpdated,WillCopy,FamilyAware,MedPowerOfAttorney,MedPowerOfAttorneyName,DateMedPowerOfAttorney,DateUpdatedMedPowerOfAttorney,MedPowerOfAttorneyCopyOnFile,HealthCareProxy,HealthCareProxyName,HealthCareProxyDateSign,HealthCareProxyLastUpdate,DoNotResuscitate,DnrDateSign,DnrDateUpdate,OrganDonorDocument,OrganDonorDocumentDateSign,OrganDonorDocumentLastUpdate,DocumentLocation,DocumentContactFirstName,DocumentContactLastName,DocumentContactPhone,AttorneyFirstName,AttorneyLastName,AttorneyPhone,Comments")] LegalDocument legalDocument) { if (id != legalDocument.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(legalDocument); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LegalDocumentExists(legalDocument.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(legalDocument)); }
void before_each() { legalDocument = new LegalDocument(); legalDocument.TermsOfService = true; legalDocument.TypedOutAcceptance = "I Agree"; }
public static LegalDocument AddLegalDocument(LegalDocument document) { using (var repo = new CRUDRepository <LegalDocument>()) { document.CreateDate = DateTime.Now; return(repo.Add(document)); } }
public static List <Customer> GetCustomers() { string GetQuery = "Select * from Customer"; List <Customer> customerList = new List <Customer>(); Customer customer = null; List <LegalDocument> legalDocumentList = new List <LegalDocument>(); LegalDocument legalDocument = null; using (SqlConnection connection = new SqlConnection(sqlConnectionString)) { SqlCommand command = new SqlCommand(GetQuery, connection); command.Connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { customer = new Customer(); customer.CustomerId = Convert.ToInt32(reader["CustomerId"]); customer.CaseId = reader["CaseId"].ToString(); customer.FirstName = reader["FirstName"].ToString(); customer.LastName = reader["LastName"].ToString(); customerList.Add(customer); } reader.Close(); //GetQuery = "SELECT * FROM CUSTOMER CUST INNER JOIN LegalDocument ld ON ld.CustomerId = cust.CustomerId"; GetQuery = "SELECT * FROM LegalDocument"; command = new SqlCommand(GetQuery, connection); reader = command.ExecuteReader(); while (reader.Read()) { legalDocument = new LegalDocument(); legalDocument.Id = new Guid(reader["LegalDocumentID"].ToString()); legalDocument.CustomerId = Convert.ToInt32(reader["CustomerId"]); legalDocument.FileName = reader["FileName"].ToString(); legalDocument.DocumentType = reader["DocumentType"].ToString(); legalDocument.ContentType = reader["ContentType"].ToString(); legalDocument.StoragePath = reader["StoragePath"].ToString(); foreach (var cust in customerList) { if (cust.CustomerId == legalDocument.CustomerId) { cust.LegalDocuments.Add(legalDocument); break; } } } } return(customerList); }
private static string UploadBlob(CloudBlobDirectory caseDirectory, LegalDocument legalDocument) { CloudBlockBlob blockBlob = caseDirectory.GetBlockBlobReference(legalDocument.Id.ToString() + "_" + legalDocument.DocumentType); Stream stream = new MemoryStream(legalDocument.DocumentData); blockBlob.UploadFromStream(stream); string azureuri = blockBlob.Uri.AbsoluteUri.ToString(); return(azureuri); }
public async Task <IActionResult> Create([Bind("ID,Will,WillDateSigned,WillLastUpdated,WillCopy,FamilyAware,MedPowerOfAttorney,MedPowerOfAttorneyName,DateMedPowerOfAttorney,DateUpdatedMedPowerOfAttorney,MedPowerOfAttorneyCopyOnFile,HealthCareProxy,HealthCareProxyName,HealthCareProxyDateSign,HealthCareProxyLastUpdate,DoNotResuscitate,DnrDateSign,DnrDateUpdate,OrganDonorDocument,OrganDonorDocumentDateSign,OrganDonorDocumentLastUpdate,DocumentLocation,DocumentContactFirstName,DocumentContactLastName,DocumentContactPhone,AttorneyFirstName,AttorneyLastName,AttorneyPhone,Comments")] LegalDocument legalDocument) { if (ModelState.IsValid) { _context.Add(legalDocument); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(legalDocument)); }
public static LegalDocument Update(LegalDocument document) { using (var repo = new CRUDRepository <LegalDocument>()) { var doc = repo.GetQuery <LegalDocument>(x => x.Id == document.Id).FirstOrDefault(); if (doc != null) { doc.Filename = document.Filename; doc.Url = document.Url; repo.Update(doc); return(doc); } return(null); } }
private static bool InsertLegalDocs(int customerId, LegalDocument legalDocument, SqlConnection sqlConn) { string INSERT = "INSERT INTO LegalDocument (LegalDocumentID, CustomerId, FileName, DocumentType, ContentType, StoragePath, DocumentNumber) VALUES (@LegalDocumentID, @CustomerId, @FileName, @DocumentType, @ContentType, @StoragePath, @DocumentNumber)"; using (SqlCommand sqlCommand = new SqlCommand(INSERT, sqlConn)) { sqlCommand.Parameters.Add("@LegalDocumentID", SqlDbType.UniqueIdentifier).Value = legalDocument.Id; sqlCommand.Parameters.Add("@CustomerId", SqlDbType.Int).Value = customerId; sqlCommand.Parameters.Add("@FileName", SqlDbType.VarChar).Value = legalDocument.FileName; sqlCommand.Parameters.Add("@DocumentType", SqlDbType.VarChar).Value = legalDocument.DocumentType; sqlCommand.Parameters.Add("@ContentType", SqlDbType.VarChar).Value = legalDocument.ContentType; sqlCommand.Parameters.Add("@StoragePath", SqlDbType.VarChar).Value = legalDocument.StoragePath; sqlCommand.Parameters.Add("@DocumentNumber", SqlDbType.VarChar).Value = legalDocument.DocumentNumber; sqlCommand.ExecuteNonQuery(); } return(true); }
private static async Task <bool> CreateOrEditCustomer(Customer customer, HttpFileCollectionBase uploadedFiles, string url) { var content = new MultipartContent(); List <LegalDocument> legalDocs = new List <LegalDocument>(); for (int i = 0; i < uploadedFiles.Count; i++) { var file = uploadedFiles[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); //*********************** OCR Calling and Processing ******************************// byte[] byteData = OCRServices.ConvertStreamToByteArray(file.InputStream); string ocrJsonResult = await OCRServices.CallOCR(byteData); CustomerFile custFile = OCRServices.ProcessOCR(ocrJsonResult); //*********************** OCR Calling and Processing ******************************// LegalDocument legalDoc = new LegalDocument() { FileName = fileName, Extension = Path.GetExtension(fileName), Id = Guid.NewGuid(), DocumentData = byteData, //GetFileBytes(file.InputStream), DocumentType = custFile.DocumentType, //OCRCallApi(i) // changed here for document type DocumentNumber = custFile.DocumentNumber, ContentType = file.ContentType }; legalDocs.Add(legalDoc); //StreamContent streamContent = new StreamContent(file.InputStream); //streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); //ContentDispositionHeaderValue cd = new ContentDispositionHeaderValue("attachment"); //cd.FileName = legalDoc.Id + legalDoc.Extension; //streamContent.Headers.ContentDisposition = cd; //content.Add(streamContent); } } customer.LegalDocuments = legalDocs; var objectContent = new ObjectContent <Customer>(customer, new System.Net.Http.Formatting.JsonMediaTypeFormatter()); content.Add(objectContent); //HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, _path); //request.Content = content; HttpResponseMessage response = await SendApiRequest(url, content); if (response.IsSuccessStatusCode) { return(true); } return(false); }