// POST: api/ProcessErrorDocument public IHttpActionResult Post([FromBody]ScannedDocument barCodeText) { //string s1 = value.ArchiveID; DocumentTypeData documentTypeData = new DocumentTypeData(); DocumentsData documentsData = new DocumentsData(); string[] patientId = barCodeText.PatientID.Split(' '); string[] tabId = barCodeText.TabID.Split('~'); barCodeText.ID = documentsData.GetDocumentIDFromPath(System.Configuration.ConfigurationManager.AppSettings["pathToWatchedFolder"] + barCodeText.FullPath); barCodeText.ArchiveID = documentsData.GetArchiveIDFromPath(System.Configuration.ConfigurationManager.AppSettings["pathToWatchedFolder"] + barCodeText.FullPath); try { System.IO.FileStream inFile; byte[] binaryData; try { inFile = new System.IO.FileStream(System.Configuration.ConfigurationManager.AppSettings["pathToErrorFolder"] + barCodeText.FullPath, System.IO.FileMode.Open, System.IO.FileAccess.Read); binaryData = new Byte[inFile.Length]; long bytesRead = inFile.Read(binaryData, 0, (int)inFile.Length); inFile.Close(); } catch (Exception er) { string[] fileNameArray = barCodeText.FullPath.Split('\\'); string fileName = fileNameArray[fileNameArray.Length - 1]; return BadRequest(er.ToString()); } string base64String; try { base64String = System.Convert.ToBase64String(binaryData, 0, binaryData.Length); } catch (System.ArgumentNullException) { string[] fileNameArray = barCodeText.FullPath.Split('\\'); string fileName = fileNameArray[fileNameArray.Length - 1]; return BadRequest(); } ContractBuilder oBuilder = new ContractBuilder(); Greenway.PrimeSuite.DataContracts.Document.DocumentImportChartRequest oRequest = new Greenway.PrimeSuite.DataContracts.Document.DocumentImportChartRequest(); Greenway.PrimeSuite.DataContracts.Document.DocumentImportChartResponse oResponse = new Greenway.PrimeSuite.DataContracts.Document.DocumentImportChartResponse(); oRequest = oBuilder.BuildDocumentImportChartRequest(base64String); oRequest.PrimeSuitePatientId = int.Parse(patientId[0]); oRequest.DocumentTypeID = int.Parse(tabId[0]); oRequest.DocumentName = documentTypeData.GetDocumentNameBasedOnDocumentType(tabId[0]); oRequest.DocumentSignerID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["providerSignerID"]); oRequest.Credentials.PrimeSuiteCredential.PrimeSuiteUserName = System.Configuration.ConfigurationManager.AppSettings["greenwayUserID"]; oRequest.Credentials.PrimeSuiteCredential.PrimeSuiteUserPassword = System.Configuration.ConfigurationManager.AppSettings["greenwayUserPassword"]; EmployeeDesktop.API.Document ocall = new EmployeeDesktop.API.Document(); oResponse = ocall.SendPDF(oRequest, System.Configuration.ConfigurationManager.AppSettings["greenwayServer"]); documentTypeData.UpdateScannedDocuments(barCodeText.ID, oResponse.DocumentID.ToString()); documentTypeData.UpdateDocumentArchive(barCodeText.ArchiveID, "T"); File.Delete(System.Configuration.ConfigurationManager.AppSettings["pathToErrorFolder"] + barCodeText.FullPath); return Ok(); } catch (Exception er) { return BadRequest(er.ToString()); } }
// GET: api/DcoumentType public IEnumerable<DocumentType> Get() { DocumentTypeData documentTypeData = new DocumentTypeData(); return documentTypeData.GetDocumentTypesByID(); }