// POST: api/SendToUser public IHttpActionResult Post([FromBody]FaxFolders sendTo) { try { FaxRepository faxData = new FaxRepository(); faxData.SendFileToAnotherUser(sendTo); return Ok(); } catch { return BadRequest(); } }
// POST: api/HoldFolders public IHttpActionResult Post([FromBody]Folder folder) { FaxRepository faxData = new FaxRepository(); OperationResult operationResult = faxData.AddFolder(folder); if (operationResult.Success) { return Ok(); } else { return BadRequest(); } }
// GET: api/HoldFolders/5 public IEnumerable<InboundFaxDocument> Get(string id) { if (id == "S" | id == "I" | id == "P" ) { FaxRepository faxData = new FaxRepository(); return faxData.GetHoldFolders(id); } else { FaxRepository faxData = new FaxRepository(); return faxData.GetFilesInFolder(id); } }
// GET: api/ViewSplitDocument public SplitDocument Get(string id) { FaxRepository faxData = new FaxRepository(); string fullPath = faxData.GetFullPathInboundFax(id); SplitDocument splitDocument = new SplitDocument(); string[] path = fullPath.Split('\\'); splitDocument.Path = ConfigurationValues.PdfFolder + path[path.Length - 1]; File.Copy(fullPath, ConfigurationValues.WhereToCopyPDfTo + path[path.Length - 1], true ); splitDocument.PageCount = Utility.GetPDFPageCount(ConfigurationValues.WhereToCopyPDfTo + path[path.Length - 1]); return splitDocument; }
// GET: api/FolderList/5 public IEnumerable<KendoTreeViewViewModel> Get(string id) { FaxRepository faxData = new FaxRepository(); string path = string.Empty; if (id.Substring(1, 1) == ":") { path = id; } else { path = ConfigurationValues.DefaultFolderFaxes; } var directories = Directory.GetDirectories(path).Select(dir => new KendoTreeViewViewModel { Id = dir, HasChildren = true, Name = Path.GetFileName(dir) }); var result = directories.ToList(); for (int i = 0; i < result.Count; i++) { string newName = faxData.GetPostOfficeFaxFolderTranslation(result[i].Name); if (newName != "None") { result[i].Name = newName; } } //result.AddRange(directories); result = result.OrderBy(x => x.HasChildren).ToList(); FolderRepository folderData = new FolderRepository(); for (int i = 0; i < result.Count; i++) { result[i] = folderData.GetCheckedFolders(result[i]); } return result; }
// GET: api/SendFaxAgain public string Get() { var queryString = this.Request.GetQueryNameValuePairs().ToList(); string sendID = queryString[0].Value; string faxNumber = queryString[1].Value; FaxRepository faxData = new FaxRepository(); bool returnValue = faxData.SendFaxAgain(faxNumber, sendID); if (returnValue) { } else { } return "OK"; }
// POST: api/MoveFilesPrint public void Post([FromBody]MoveFile moveFile) { FaxRepository faxData = new FaxRepository(); faxData.MoveFileToPrintFolder(moveFile); }
// GET: api/MoveFilesPrint/5 public string Get(string id) { FaxRepository faxData = new FaxRepository(); return faxData.MoveResendFileToView(id); }
// POST: api/SendFax public IHttpActionResult Post([FromBody] Fax faxValues) { System.IO.Directory.CreateDirectory(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName()); Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Start Creating Fax"); OperationResult createFaxRecordOperationResult = new Models.OperationResult(); OperationResult sendFaxToMultiTechOperationResult = new Models.OperationResult(); FaxRepository faxData = new FaxRepository(); DocumentRepository documentData = new DocumentRepository(); string[] faxesToSendList = faxValues.FaxTo.Split('~'); SendFax sendFax = new SendFax(); try { for (int i = 0; i < faxesToSendList.Length - 1; i++) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Getting fax information"); FaxingInformation faxingInformatonInitial = new FaxingInformation(); faxingInformatonInitial.DocumentList = faxValues.DocumentList; faxingInformatonInitial.FaxTo = faxesToSendList[i]; faxingInformatonInitial.Notes = faxValues.Notes; faxingInformatonInitial.From = faxValues.From; faxingInformatonInitial.Cover = faxValues.Cover; faxingInformatonInitial.CoverSheetOnly = faxValues.CoverOnly; Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Getting fax information"); //Create Fax FaxingInformation faxingInformatonComplete = sendFax.CreateFax(faxingInformatonInitial); System.IO.File.Copy(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName() + "\\" + faxingInformatonComplete.FaxName, ConfigurationValues.PernamentFaxPath + faxingInformatonComplete.FaxName, true); createFaxRecordOperationResult = faxData.SendFax(faxingInformatonComplete, ConfigurationValues.PernamentFaxPath + faxingInformatonComplete.FaxName, faxValues.From, faxValues.Notes); if (createFaxRecordOperationResult.Success) { sendFaxToMultiTechOperationResult = sendFaxMultitech.SendTheFax(faxingInformatonComplete.Name, faxingInformatonComplete.FaxPath, faxValues.From, faxingInformatonComplete.FaxNumber, createFaxRecordOperationResult.MessageList[0], ConfigurationValues.ApplicationPath); if (sendFaxToMultiTechOperationResult.Success) { if (faxValues.SendToEmr == "F") { ArchiveDocument = new ArchiveDocument(); CurrentDocuments faxTodocument = documentData.GetCurrentDocumentPathPdf(Utility.GetUserName()); string[] filesToDelete = faxTodocument.CurrentDocumentList.Split('~'); for (int j = 0; j < filesToDelete.Length - 1; j++) { try { string[] fileParts = filesToDelete[j].Split('\\'); ArchiveDocument.ArchiveTheDocument(fileParts[fileParts.Length - 1], filesToDelete[j], Utility.GetUserName()); File.Delete(filesToDelete[j]); } catch { } documentData.DeleteDocumentInFolder(filesToDelete[j]); } Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Begin Delete file"); File.Delete(faxingInformatonComplete.FaxPath); File.Delete(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName() + "\\cover.pdf"); Logging.LogErrors(ConfigurationValues.ErrorLogPath, "end delete file"); } } else { faxData.UpdateFaxRecord(sendFaxToMultiTechOperationResult.MessageList[0]); return BadRequest(sendFaxToMultiTechOperationResult.MessageList[0]); } } else { return BadRequest(createFaxRecordOperationResult.MessageList[0]); } } } catch (Exception er) { return BadRequest(er.ToString()); } CurrentDocuments documentsToDelete = documentData.GetCurrentDocumentPathPdf(Utility.GetUserName()); try { File.Delete(documentData.GetFullPathToDocument(Utility.GetUserName())); } catch { } string[] faxesToDelete = documentsToDelete.CurrentDocumentList.Split('~'); try { for (int i = 0; i < faxesToDelete.Length - 1; i++) { System.IO.File.Delete(ConfigurationValues.OutboundFaxDirectory + "\\" + Utility.GetUserName() + "\\" + faxesToDelete[i]); } } catch { } return Ok(); }
public FaxingInformation CreateFax(FaxingInformation faxingInformation) { string temporaryPath = string.Empty; faxingInformation.FaxName = Guid.NewGuid().ToString() + ".pdf"; FaxRepository faxData = new FaxRepository(); string[] firstFaxTo = faxingInformation.FaxTo.Split('~'); List<FaxToInformation> data = new List<FaxToInformation>(); if (faxingInformation.FaxTo.Substring(0, 1) == "G") { data = faxData.GetFaxToInformationGreenway(firstFaxTo[0]); } else { data = faxData.GetFaxToInformation(firstFaxTo[0]); } try { faxingInformation.FaxTo = data[0].Name; } catch { } try { DocumentRepository documentData = new DocumentRepository(); CurrentDocuments faxTodocument = documentData.GetCurrentDocumentPathPdf(Utility.GetUserName()); Logging.LogErrors(ConfigurationValues.ErrorLogPath, faxTodocument.PathToCurrentPdfDocument); MemoryStream newPdfStream = Utility.CreateMemoryStreamFromPdf(faxTodocument.PathToCurrentPdfDocument); temporaryPath = ConfigurationValues.TemporaryFaxPath + Utility.GetUserName() + "\\" + faxingInformation.FaxName; Logging.LogErrors(ConfigurationValues.ErrorLogPath, temporaryPath); FileStream newPdfStreamFile = new FileStream(temporaryPath, FileMode.Create); newPdfStream.WriteTo(newPdfStreamFile); Logging.LogErrors(ConfigurationValues.ErrorLogPath, "writing to file"); newPdfStream.Close(); Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Closing stream"); newPdfStreamFile.Close(); MemoryStream coverSheet = CreateCoverSheetV2(faxingInformation.FaxTo, data[0].FaxNumber, Utility.GetPDFPageCount(newPdfStreamFile.Name), faxingInformation.Notes, faxingInformation.From, int.Parse(faxingInformation.Cover)); faxingInformation.PageCount = Utility.GetPDFPageCount(newPdfStreamFile.Name); faxingInformation.FaxNumber = UpdatedFaxNumber(data[0].FaxNumber); faxingInformation.Name = faxingInformation.FaxTo; FileStream presStream = new FileStream(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName() + "\\cover.pdf", FileMode.Create); coverSheet.WriteTo(presStream); coverSheet.Close(); presStream.Close(); if (faxingInformation.CoverSheetOnly == "T") { File.Copy(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName() + "\\cover.pdf", newPdfStreamFile.Name, true); File.Delete(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName() + "\\cover.pdf"); } else { Utility.MergeTwoPDFDocuments(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName() + "\\cover.pdf", newPdfStreamFile.Name); } faxingInformation.FaxPath = newPdfStreamFile.Name; return faxingInformation; } catch (Exception er) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); return faxingInformation; } }
// GET: api/InboundFax public IEnumerable<InboundFaxDocument> Get() { FaxRepository faxData = new FaxRepository(); return faxData.GetInboundFaxList(); }