コード例 #1
0
 public void SendToFax(int PharmacyId)
 {
     try
     {
         Stream fs = new FileStream(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\DiscontinueMedicationScript.pdf"), FileMode.Create);
         fs.Write(renderedBytes, 0, renderedBytes.Length);
         fs.Close();
         Streamline.Faxing.StreamlineFax _streamlineFax = new Streamline.Faxing.StreamlineFax();
         //_strFaxFailed = _streamlineFax.SendFax(PharmacyId, ((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client.ClientId, (Server.MapPath("RDLC") + "\\" + Context.User.Identity.Name + "\\DiscontinueMedicationScript.pdf"), "Prescription Medication Script");
         faxUniqueId = _streamlineFax.SendFax(PharmacyId,
                                              ((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client
                                              .ClientId,
                                              (Server.MapPath("RDLC") + "\\" + Context.User.Identity.Name +
                                               "\\DiscontinueMedicationScript.pdf"), "Prescription Medication Script");
         _strFaxFailed = (faxUniqueId == "false");
     }
     catch (System.Runtime.InteropServices.COMException ex)
     {
         if (ex.Data["CustomExceptionInformation"] == null)
         {
             ex.Data["CustomExceptionInformation"] = "Source function SendToFax() of DiscontinuationMedicationRdlc";
         }
         else
         {
             ex.Data["CustomExceptionInformation"] = "";
         }
         if (ex.Data["DatasetInfo"] == null)
         {
             ex.Data["DatasetInfo"] = null;
         }
         Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
     }
 }
コード例 #2
0
    public bool SendToFax(int ScriptReason, int PharmacyId)
    {
        #region Sending Fax
        // Declare objects
        DataSet DataSetTemp = null;
        string  FaxUniqueId = "";
        try
        {
            DataSetClientScriptActivities = new Streamline.UserBusinessServices.DataSets.DataSetClientScripts();

            #region Get RDLC Contents

            string   _ReportPath = "";
            string   mimeType;
            string   encoding;
            string   fileNameExtension;
            string[] streams;
            byte[]   renderedBytes;

            DataSet _DataSetRdl = new DataSet();
            Streamline.UserBusinessServices.ClientMedication objectClientMedications = null;

            objectClientMedications = new ClientMedication();
            reportViewer1           = new Microsoft.Reporting.WebForms.ReportViewer();
            _DataSetRdl             = objectClientMedications.GetClientMedicationRDLDataSet(Convert.ToInt32(HiddenFieldLatestClientMedicationScriptId.Value));
            _ReportPath             = Server.MapPath("RDLC\\MedicationReport.rdlc");
            ProcessRdlReport("DataSetMedication_ssp_SCGetClientMedicationScriptDatatry", _DataSetRdl, _ReportPath);


            string         reportType = "PDF";
            IList <Stream> m_streams;
            m_streams = new List <Stream>();
            Microsoft.Reporting.WebForms.Warning[] warnings;
            string deviceInfo = "<DeviceInfo><OutputFormat>PDF</OutputFormat><StartPage>0</StartPage></DeviceInfo>";
            renderedBytes = reportViewer1.LocalReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

            // Create PDF from rendered Bytes to send as an attachment

            //Stream fs = new FileStream(Server.MapPath("RDLC\\MedicationScript.pdf"), FileMode.Create);
            Stream fs = new FileStream(Server.MapPath("RDLC") + "\\" + Context.User.Identity.Name + "\\MedicationScript.pdf", FileMode.Create);
            fs.Write(renderedBytes, 0, renderedBytes.Length);
            fs.Close();

            #endregion

            //Send to Fax server

            try
            {
                Streamline.Faxing.StreamlineFax _streamlineFax = new Streamline.Faxing.StreamlineFax();
                //FaxUniqueId = _streamlineFax.SendFax(PharmacyId, ((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client.ClientId, (Server.MapPath("RDLC") + "\\" + Context.User.Identity.Name + "\\MedicationScript.pdf"), "Prescription Medication Script") ? "True" : "";
                FaxUniqueId = _streamlineFax.SendFax(PharmacyId, ((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client.ClientId, (Server.MapPath("RDLC") + "\\" + Context.User.Identity.Name + "\\MedicationScript.pdf"), "Prescription Medication Script");
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                if (ex.Data["CustomExceptionInformation"] == null)
                {
                    ex.Data["CustomExceptionInformation"] = "Source function SendToFax() of Print Order Dialog";
                }
                else
                {
                    ex.Data["CustomExceptionInformation"] = "";
                }
                if (ex.Data["DatasetInfo"] == null)
                {
                    ex.Data["DatasetInfo"] = null;
                }
                Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
            }


            #region InsertRowsIntoClientScriptActivities
            ////Insert Rows into ClientScriptActivities
            DataRow drClientMedicationScriptsActivity = DataSetClientScriptActivities.Tables["ClientMedicationScriptActivities"].NewRow();
            drClientMedicationScriptsActivity["ClientMedicationScriptId"] = Convert.ToInt32(HiddenFieldLatestClientMedicationScriptId.Value);
            drClientMedicationScriptsActivity["Method"]                = 'F';
            drClientMedicationScriptsActivity["PharmacyId"]            = PharmacyId;
            drClientMedicationScriptsActivity["Reason"]                = ScriptReason;
            drClientMedicationScriptsActivity["FaxStatusDate"]         = DateTime.Now;
            drClientMedicationScriptsActivity["FaxStatus"]             = "QUEUED";
            drClientMedicationScriptsActivity["FaxExternalIdentifier"] = FaxUniqueId;
            drClientMedicationScriptsActivity["RowIdentifier"]         = System.Guid.NewGuid();
            drClientMedicationScriptsActivity["CreatedBy"]             = ((Streamline.BaseLayer.StreamlineIdentity)Context.User.Identity).UserCode;
            drClientMedicationScriptsActivity["CreatedDate"]           = DateTime.Now;
            drClientMedicationScriptsActivity["ModifiedBy"]            = ((Streamline.BaseLayer.StreamlineIdentity)Context.User.Identity).UserCode;
            drClientMedicationScriptsActivity["ModifiedDate"]          = DateTime.Now;
            DataSetClientScriptActivities.Tables["ClientMedicationScriptActivities"].Rows.Add(drClientMedicationScriptsActivity);
            using (
                ClientMedication _clientMedication = objectClientMedications != null
                                                         ? objectClientMedications
                                                         : new ClientMedication())
            {
                _clientMedication.SetRenderedImageData(DataSetClientScriptActivities, drClientMedicationScriptsActivity,
                                                       ((Streamline.BaseLayer.StreamlineIdentity)Context.User.Identity)
                                                       .UserCode, renderedBytes);
            }
            DataSetTemp = objectClientMedications.UpdateClientScriptActivities(DataSetClientScriptActivities);


            #endregion



            if (DataSetTemp.Tables["ClientMedicationScriptActivities"].Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }



        catch (System.Runtime.InteropServices.COMException ex)
        {
            string strEx = ex.Message.ToString();
            throw (ex);
        }
        finally
        {
            DataSetTemp = null;
        }

        #endregion
    }