private static OperationResult InsertAllSignedNotes(SignedDocument document) { OperationResult operationResult = new Models.OperationResult(); if (string.IsNullOrEmpty(document.DocumentID.ToString())) { document.DocumentID = 0; } //if (string.IsNullOrEmpty(document.DateSigned)) //{ // document.DateSigned = string.Empty; //} if (string.IsNullOrEmpty(document.PatientID.ToString())) { document.PatientID = 0; } if (string.IsNullOrEmpty(document.PatientName)) { document.PatientName = string.Empty; } if (string.IsNullOrEmpty(document.CareProviderID.ToString())) { document.CareProviderID = 0; } if (string.IsNullOrEmpty(document.CareProviderName)) { document.CareProviderName = string.Empty; } if (string.IsNullOrEmpty(document.PrimaryCareProviderID.ToString())) { document.PrimaryCareProviderID = 0; } if (string.IsNullOrEmpty(document.PrimaryCareProvider)) { document.PrimaryCareProvider = string.Empty; } if (string.IsNullOrEmpty(document.ReferringCareProviderID.ToString())) { document.ReferringCareProviderID = 0; } if (string.IsNullOrEmpty(document.ReferringCareProvider)) { document.ReferringCareProvider = string.Empty; } if (string.IsNullOrEmpty(document.DocTypeName)) { document.DocTypeName = string.Empty; } if (string.IsNullOrEmpty(document.SignerID.ToString())) { document.SignerID = 0; } using (IDbConnection db = new SqlConnection(ConfigurationValues.WaldenFaxConnection)) { try { const string query = "INSERT INTO [AllSignedNotes]" + " (" + " [DocumentID]" + " ,[VisitID]" + " ,[DateSigned]" + " ,[PatientID]" + " ,[PatientName]" + " ,[CareProviderID]" + " ,[CareProviderName]" + " ,[PrimaryCareProviderID]" + " ,[PrimaryCareProvider]" + " ,[ReferringCareProviderID]" + " ,[ReferringCareProvider]" + " ,[DocTypeName]" + " ,[SignerID]" + ")" + " VALUES" + " (" + " @DocumentID,@VisitID ,@DateSigned , @PatientID, @PatientName, @CareProviderID, @CareProviderName," + " @PrimaryCareProviderID, @PrimaryCareProvider, @ReferringCareProviderID, @ReferringCareProvider," + " @DocTypeName, @SignerID" + " )"; int rowsAffectd = db.Execute(query, new { @DocumentID = document.DocumentID, @VisitID = document.VisitID, @DateSigned = document.DateSigned, @PatientID = document.PatientID, @PatientName = document.PatientName, @CareProviderID = document.CareProviderID, @CareProviderName = document.CareProviderName, @PrimaryCareProviderID = document.PrimaryCareProviderID, @PrimaryCareProvider = document.ReferringCareProvider, @ReferringCareProviderID = document.ReferringCareProviderID, @ReferringCareProvider = document.ReferringCareProvider, @DocTypeName = document.DocTypeName, @SignerID = document.SignerID }); operationResult.Success = true; operationResult.AddMessage("Success"); return operationResult; } catch (Exception er) { operationResult.Success = false; operationResult.AddMessage(er.ToString()); return operationResult; } } }
private static OperationResult AddReportingRecord(SentNotesFax sentNotesFax) { OperationResult operationResult = new Models.OperationResult(); string now = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); using (IDbConnection db = new SqlConnection(ConfigurationValues.WaldenFaxConnection)) { try { const string query = "INSERT INTO [FaxesSent]" + "(" + "[DocumentID]" + " ,[PatientID]" + " ,[PatientName]" + " ,[ToProviderID]" + " ,[ToProviderName]" + " ,[FromProviderID]" + " ,[FromProviderName]" + " ,[DateTimeCreated]" + " ,[DateTimeSent]" + " ,[SendID]" + ")" + "VALUES" + "(" + "@DocumentID,@PatientID,@PatientName,@ToProviderID,@ToProviderName,@FromProviderID" + ",@FromProviderName,@DateTimeCreated,@DateTimeSent,@SendID)"; int rowsAffectd = db.Execute(query, new { @DocumentID = sentNotesFax.DocumentID, @PatientID = sentNotesFax.PatientID, @PatientName = sentNotesFax.PatientName, @ToProviderID = sentNotesFax.ToProviderID, @ToProviderName = sentNotesFax.ToProviderName, @FromProviderID = sentNotesFax.FromProviderID, @FromProviderName = sentNotesFax.FromProviderName, @DateTimeCreated = now, @DateTimeSent = now, @SendID = sentNotesFax.SendID }); int sendFaxId = GetSendFaxID(); operationResult.Success = true; operationResult.AddMessage(sendFaxId.ToString()); return operationResult; } catch (Exception er) { operationResult.Success = false; operationResult.AddMessage(er.ToString()); return operationResult; } } throw new NotImplementedException(); }
private static OperationResult SendFax(SendFax sendFax) { OperationResult operationResult = new Models.OperationResult(); using (IDbConnection db = new SqlConnection(ConfigurationValues.WaldenFaxConnection)) { try { const string query = "INSERT INTO [FaxesSendServer](" + "[AccountID]" + ",[UserID]" + ",[FaxName]" + ",[FaxPath]" + ",[FaxNumber]" + ",[RecipientName]" + ",[Notes]" + ",[PageCount]" + ",[FaxSent]" + ",[InUse]" + ",[ToTif]" + ",[CallWait]" + ",[TimesCalled]" + ",[Status]" + ",[ShowFax]" + ",[CreateTime]" + ",[CompletionTime]" + ",[DateStamp])" + " VALUES(" + "@AccountID" + ",@UserID" + ",@FaxName" + ",@FaxPath" + ",@FaxNumber" + ",@RecipientName" + ",@Notes" + ",@PageCount" + ",@FaxSent" + ",@InUse" + ",@ToTif" + ",@CallWait" + ",@TimesCalled" + ",@Status" + ",@ShowFax" + ",@CreateTime" + ",@CompletionTime" + ",@DateStamp)"; int rowsAffectd = db.Execute(query, new { @AccountID = sendFax.AccountID, @UserID = sendFax.UserID, @FaxName = sendFax.FaxName, @FaxPath = sendFax.FaxPath, @FaxNumber = sendFax.FaxNumber, @RecipientName = sendFax.RecipientName, @Notes = sendFax.Notes, @PageCount = sendFax.PageCount, @FaxSent = sendFax.FaxSent, @InUse = sendFax.InUse, @ToTif = sendFax.ToTif, @CallWait = sendFax.CallWait, @TimesCalled = sendFax.TimesCalled, @Status = sendFax.Status, @ShowFax = sendFax.ShowFax, @CreateTime = sendFax.CreateTime, @CompletionTime = sendFax.CompletionTime, @DateStamp = sendFax.DateStamp }); int sendFaxId = GetSendFaxID(); operationResult.Success = true; operationResult.AddMessage(sendFaxId.ToString()); return operationResult; } catch (Exception er) { operationResult.Success = false; operationResult.AddMessage(er.ToString()); return operationResult; } } }
public OperationResult SendTheFax(string faxName, string faxPath, string recipientName, string faxNumber,string sendID,string applicationPath) { OperationResult operationResult = new OperationResult(); FileStream fileStream; StreamReader reader = null; ; Stream data = null; WebResponse response = null; StreamWriter streamWriter = null; faxName = faxName.Replace("&", ""); recipientName = recipientName.Replace("&", ""); try { fileName = ConfigurationValues.ProcessFaxPath; fileStream = File.Create(fileName); fileStream.Close(); streamWriter = File.AppendText(fileName); streamWriter.WriteLine("<?xml version=”1.0” encoding=”UTF-8”?>"); streamWriter.WriteLine("<schedule_fax>"); streamWriter.WriteLine("<cover_page>"); streamWriter.WriteLine("<enabled>false</enabled>"); streamWriter.WriteLine("</cover_page>"); streamWriter.WriteLine("<sender>"); streamWriter.WriteLine("<name>" + faxName + "</name>"); streamWriter.WriteLine("<email_address>" + sendID + "</email_address>"); streamWriter.WriteLine("</sender>"); streamWriter.WriteLine("<recipient>"); streamWriter.WriteLine("<name>" + recipientName + "</name>"); streamWriter.WriteLine("<fax_number>" + faxNumber + "</fax_number>"); streamWriter.WriteLine("</recipient>"); streamWriter.WriteLine("<attachment>"); streamWriter.WriteLine("<location>inline</location>"); streamWriter.WriteLine("<name>test.pdf</name>"); streamWriter.WriteLine("<receipt_attachment>never</receipt_attachment>"); streamWriter.WriteLine("<content_type>application/pdf</content_type>"); streamWriter.WriteLine("<content_transfer_encoding>base64</content_transfer_encoding>"); streamWriter.WriteLine("<content>"); streamWriter.WriteLine(EncodePDFDocument(faxPath)); streamWriter.WriteLine("</content>"); streamWriter.WriteLine("</attachment>"); streamWriter.WriteLine("<max_tries>3</max_tries>"); streamWriter.WriteLine("<priority>1</priority>"); streamWriter.WriteLine("<try_interval>600</try_interval>"); streamWriter.WriteLine("<receipt>never</receipt>"); streamWriter.WriteLine("<receipt_attachment>none</receipt_attachment>"); streamWriter.WriteLine("</schedule_fax>"); streamWriter.Close(); ServicePointManager.Expect100Continue = false; //Create a request using a URL that can receive a post. //WebRequest request = WebRequest.Create("http://216.133.69.247/ffws/v1/ofax"); WebRequest request = WebRequest.Create("http://192.168.105.92/ffws/v1/ofax"); string authInfo = "admin:admin"; //string authInfo = userName + ":" + userPassword; authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo)); request.Headers["Authorization"] = "Basic " + authInfo; //Add authentication to request //request.Credentials = new NetworkCredential("admin", "admin"); //Set the Method property of the request to POST. request.Method = "POST"; //Set the ContentType property of the WebRequest. request.ContentType = "application/xml"; //Get File size //FileInfo fileSize = new FileInfo("C:/Users/test/Documents/Visual Studio 2008/Projects/sendFax/sendFax/schedule.xml"); FileInfo fileSize = new FileInfo(fileName); int len = (int)fileSize.Length; //Set the ContentLength property of the WebRequest. request.ContentLength = len; //Get the request stream. Stream dataStream = request.GetRequestStream(); StreamReader textIn = new StreamReader(new FileStream(fileName, FileMode.Open, FileAccess.Read)); string TextLines = textIn.ReadToEnd(); byte[] byteArray = Encoding.UTF8.GetBytes(TextLines); //Write the data to the request stream. dataStream.Write(byteArray, 0, byteArray.Length); textIn.Close(); //Close the Stream object. dataStream.Close(); //Get the response. response = request.GetResponse(); //Display the status. Console.WriteLine(((HttpWebResponse)response).StatusDescription); //Get the stream containing content returned by the server. data = response.GetResponseStream(); //Open the stream using a StreamReader for easy access. reader = new StreamReader(data); //Read the content. string responseFromServer = reader.ReadToEnd(); //Display the content. Console.WriteLine(responseFromServer); //Clean up the streams. reader.Close(); data.Close(); response.Close(); operationResult.Success = true; return operationResult; } catch(Exception er) { try { //Clean up the streams. reader.Close(); } catch { } try { data.Close(); } catch { } try { response.Close(); } catch { } try { streamWriter.Close(); } catch { } operationResult.Success = false; operationResult.AddMessage(er.ToString()); return operationResult; } }