コード例 #1
0
    public void GetRDLCContents()
    {
        #region Get RDLC Contents

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

        DataSet    _DataSetGetRdlCName      = null;
        DataSet    _DataSetRdlForMainReport = null;
        DataSet    _DataSetRdlForSubReport  = null;
        DataRow[]  dr              = null;
        DataRow[]  _drSubReport    = null;
        string     _OrderingMethod = "";
        string     strErrorMessage = "";
        LogManager objLogManager   = null;

        ReportParameter[] _RptParam = null;
        int LocationId = 1;
        //End
        //Block For ReportPath
        reportViewer1 = new ReportViewer();
        //Ref to Task#2660
        string FileName = "";
        int    seq      = 1;
        try
        {
            _ReportPath = Server.MapPath(".") + ConfigurationManager.AppSettings["MedicationPerscriptionReportUrl"];
            if (_ReportPath == "") //Check For Report Path
            {
                strErrorMessage = "ReportPath is Missing In WebConfig";
                ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID,
                                                    "ShowError('" + strErrorMessage + "', true);", true);
                return;
            }
        }
        catch (Exception ex)
        {
            LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);

            strErrorMessage = "ReportPath Key is Missing In WebConfig";
            ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID,
                                                "ShowError('" + strErrorMessage + "', true);", true);
            return;
        }
        finally
        {
            objLogManager = null;
        }

        try
        {
            //  _DataSetRdl = new DataSet();//Commented by Vikas Vyas On Dated March 04 2008
            ClientMedication objectClientMedications = null;
            objectClientMedications = new ClientMedication();

            //Get the Name of the Rdlc,StoredProcedure from DocumentCodes,DocumentCodesRDLSubReports
            _DataSetGetRdlCName = objectClientMedications.GetRdlCNameDataBase(1026);
            _DataSetGetRdlCName.Tables[0].TableName = "DocumentCodes";
            _DataSetGetRdlCName.Tables[1].TableName = "DocumentCodesRDLSubReports";


            if (_DataSetGetRdlCName.Tables["DocumentCodes"].Rows.Count > 0)
            {
                dr = _DataSetGetRdlCName.Tables["DocumentCodes"].Select();
                //because DocumentCodes table only contain one row


                //_OrderingMethod = OrderingMethod;


                //Check For Main Report
                if ((dr[0]["DocumentName"] != DBNull.Value || !String.IsNullOrEmpty(dr[0]["DocumentName"].ToString())) &&
                    (dr[0]["ViewStoredProcedure"] != DBNull.Value ||
                     !String.IsNullOrEmpty(dr[0]["ViewStoredProcedure"].ToString())))
                {
                    #region Get the StoredProceudreName and Execute

                    string _StoredProcedureName = "";
                    string _ReportName          = "";
                    _StoredProcedureName = dr[0]["ViewStoredProcedure"].ToString(); //Get the StoredProcedure Name
                    _ReportName          = dr[0]["DocumentName"].ToString();

                    reportViewer1.ProcessingMode         = ProcessingMode.Local;
                    reportViewer1.LocalReport.ReportPath = _ReportPath + "\\" + _ReportName + ".rdlc";
                    reportViewer1.LocalReport.DataSources.Clear();

                    if (Session["VersionIdForConsentDetailPage"] != null)
                    {
                        _DataSetRdlForMainReport =
                            objectClientMedications.GetDataForHarborStandardConsentRdlC(_StoredProcedureName,
                                                                                        Convert.ToInt32(
                                                                                            (((StreamlinePrinciple)
                                                                                              Context.User).Client
                                                                                             .ClientId)),
                                                                                        Convert.ToString(
                                                                                            HiddenFieldClientmedicationIdForConsent
                                                                                            .Value),
                                                                                        Convert.ToInt32(
                                                                                            Session[
                                                                                                "VersionIdForConsentDetailPage"
                                                                                            ].ToString()));
                    }
                    else if (Session["ChangedOrderMedicationIds"] != null)
                    {
                        //Codition modified by Loveena in ref to Task#2962
                        if (HiddenFieldDocumentVersionId.Value != "")
                        {
                            _DataSetRdlForMainReport =
                                objectClientMedications.GetDataForHarborStandardConsentRdlC(_StoredProcedureName,
                                                                                            Convert.ToInt32(
                                                                                                (((StreamlinePrinciple)
                                                                                                  Context.User).Client
                                                                                                 .ClientId)),
                                                                                            Session[
                                                                                                "ChangedOrderMedicationIds"
                                                                                            ].ToString(),
                                                                                            Convert.ToInt32(
                                                                                                HiddenFieldDocumentVersionId
                                                                                                .Value));
                        }
                        else
                        {
                            if (HiddenFieldImageConsentClick == null)
                            {
                                HiddenFieldImageConsentClick =
                                    (HiddenField)Page.FindControl("HiddenFieldImageConsentClick");
                                HiddenFieldImageConsentClick.Value =
                                    ((HiddenField)Page.FindControl("HiddenFieldImageConsentClick")).Value;
                            }
                            if (HiddenFieldImageConsentClick.Value == "Patient Consent")
                            {
                                _DataSetRdlForMainReport =
                                    objectClientMedications.GetDataForHarborStandardConsentRdlC(_StoredProcedureName,
                                                                                                Convert.ToInt32(
                                                                                                    (((
                                                                                                          StreamlinePrinciple
                                                                                                          )Context.User)
                                                                                                     .Client.ClientId)),
                                                                                                Session[
                                                                                                    "ChangedOrderMedicationIds"
                                                                                                ].ToString(), 0);
                            }
                        }
                    }

                    var DataSource = new ReportDataSource("RDLReportDataSet_" + _StoredProcedureName,
                                                          _DataSetRdlForMainReport.Tables[0]);
                    var dstemp = (DataSet)Session["DataSetRdlTemp"];
                    if (dstemp == null)
                    {
                        dstemp = _DataSetRdlForMainReport;
                    }
                    else
                    {
                        dstemp.Merge(_DataSetRdlForMainReport);
                    }
                    Session["DataSetRdlTemp"] = dstemp;
                    //HiddenFieldStoredProcedureName.Value = _StoredProcedureName;
                    //HiddenFieldReportName.Value = _ReportName;

                    #endregion

                    if (_DataSetGetRdlCName.Tables["DocumentCodesRDLSubReports"].Rows.Count > 0)
                    {
                        _drSubReport = _DataSetGetRdlCName.Tables["DocumentCodesRDLSubReports"].Select();

                        reportViewer1.LocalReport.SubreportProcessing -= SetSubDataSource;
                        reportViewer1.LocalReport.SubreportProcessing += SetSubDataSource;

                        for (int i = 0; i < _drSubReport.Length; i++) //Loop
                        {
                            if ((_drSubReport[i]["SubReportName"] != DBNull.Value ||
                                 !String.IsNullOrEmpty(_drSubReport[i]["SubReportName"].ToString())) &&
                                (_drSubReport[i]["StoredProcedure"] != DBNull.Value ||
                                 !String.IsNullOrEmpty(_drSubReport[i]["StoredProcedure"].ToString())))
                            {
                                #region Get the StoredProcedureName For SubReport and Execute

                                string _SubReportStoredProcedure = "";
                                string _SubReportName            = "";
                                _SubReportStoredProcedure = _drSubReport[i]["StoredProcedure"].ToString();
                                _SubReportName            = _drSubReport[i]["SubReportName"].ToString();
                                //Get Data For SubReport
                                //Added By Chandan Task#85 MM #1.7
                                if (Session["VersionIdForConsentDetailPage"] != null) //By Anuj for Yellow checkBox
                                {
                                    _DataSetRdlForSubReport =
                                        objectClientMedications.GetDataForHarborStandardConsentRdlC(
                                            _SubReportStoredProcedure,
                                            Convert.ToInt32((((StreamlinePrinciple)Context.User).Client.ClientId)),
                                            Convert.ToString(HiddenFieldClientmedicationIdForConsent.Value),
                                            Convert.ToInt32(Session["VersionIdForConsentDetailPage"].ToString()));
                                }
                                else if (HiddenFieldDocumentVersionId.Value != "")
                                {
                                    _DataSetRdlForSubReport =
                                        objectClientMedications.GetDataForHarborStandardConsentRdlC(
                                            _SubReportStoredProcedure,
                                            Convert.ToInt32((((StreamlinePrinciple)Context.User).Client.ClientId)),
                                            Session["ChangedOrderMedicationIds"].ToString(),
                                            Convert.ToInt32(HiddenFieldDocumentVersionId.Value));
                                }
                                else
                                {
                                    if (HiddenFieldImageConsentClick.Value == "Patient Consent")
                                    {
                                        //Code added by Loveena in ref to Task#2962
                                        if (_SubReportStoredProcedure != "csp_RDLHarborConsentElectronicSignature")
                                        {
                                            _DataSetRdlForSubReport =
                                                objectClientMedications.GetDataForHarborStandardConsentRdlC(
                                                    _SubReportStoredProcedure,
                                                    Convert.ToInt32(
                                                        (((StreamlinePrinciple)Context.User).Client.ClientId)),
                                                    Session["ChangedOrderMedicationIds"].ToString(), 0);
                                        }
                                    }
                                }
                                var rds = new ReportDataSource(_SubReportName, _DataSetRdlForSubReport.Tables[0]);
                                reportViewer1.LocalReport.DataSources.Add(rds);
                                string strRootPath = Server.MapPath(".");

                                var RdlSubReport = new StreamReader(_ReportPath + "\\" + _SubReportName.Trim() + ".rdlc");

                                reportViewer1.LocalReport.LoadReportDefinition(RdlSubReport);

                                #endregion
                            }
                        } //End For Loop
                    }
                    //Following parameters added with ref to Task 2371 SC-Support
                    _RptParam    = new ReportParameter[3];
                    _RptParam[0] = new ReportParameter("ClientId",
                                                       Convert.ToString(
                                                           ((StreamlinePrinciple)Context.User).Client.ClientId));
                    if (Session["VersionIdForConsentDetailPage"] != null)
                    {
                        _RptParam[1] = new ReportParameter("ClientMedicationId",
                                                           Convert.ToString(
                                                               HiddenFieldClientmedicationIdForConsent.Value));
                    }
                    else
                    {
                        _RptParam[1] = new ReportParameter("ClientMedicationId",
                                                           Session["ChangedOrderMedicationIds"].ToString());
                    }
                    _RptParam[2] = new ReportParameter("ClientName",
                                                       Convert.ToString(
                                                           ((StreamlinePrinciple)Context.User).Client.LastName + ", " +
                                                           ((StreamlinePrinciple)Context.User).Client.FirstName));
                    reportViewer1.LocalReport.SetParameters(_RptParam);

                    reportViewer1.LocalReport.Refresh();
                    reportViewer1.LocalReport.DataSources.Add(DataSource);
                    //ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID.ToString(), "ShowPrintDiv('" + Session["ChangedOrderMedicationIds"].ToString() + "');", true);
                }
            }

            #endregion

            //Ref to Task#2660
            if (ConfigurationSettings.AppSettings["SaveJpegOutput"].ToLower() == "true")
            {
                if (Directory.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name)))
                {
                    if (!Directory.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS")))
                    {
                        Directory.CreateDirectory(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS"));
                    }

                    foreach (
                        string file in Directory.GetFiles(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\")))
                    {
                        FileName = file.Substring(file.LastIndexOf("\\") + 1);
                        if ((FileName.IndexOf("JPEG") >= 0 || FileName.IndexOf("jpeg") >= 0))
                        {
                            //Added by Chandan on 16th Feb2010 ref task#2797
                            if (
                                File.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS") + "\\" +
                                            FileName))
                            {
                                if (FileName.ToUpper().IndexOf(".RDLC") == -1)
                                {
                                    File.Delete(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\" + FileName));
                                }
                            }
                            else
                            {
                                while (seq < 1000)
                                {
                                    seq = seq + 1;
                                    if (
                                        !File.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS") +
                                                     "\\" + FileName))
                                    {
                                        File.Move(file,
                                                  Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS") +
                                                  "\\" + FileName);
                                        break;
                                    }
                                    else
                                    {
                                        FileName = ApplicationCommonFunctions.GetFileName(FileName, seq);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                #region DeleteOldRenderedImages

                try
                {
                    using (var objRDLC = new RDLCPrint())
                    {
                        objRDLC.DeleteRenderedImages(Server.MapPath("RDLC\\" + Context.User.Identity.Name));
                    }
                }
                catch (Exception ex)
                {
                    LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
                }

                #endregion
            }

            string ScriptId = "";
            ////Added by Rohit. Ref ticket#84
            string         reportType = "PDF";
            IList <Stream> m_streams;
            m_streams = new List <Stream>();
            Warning[] warnings;
            string    deviceInfo = "<DeviceInfo><OutputFormat>PDF</OutputFormat><StartPage>0</StartPage></DeviceInfo>";
            try
            {
                if (Session["imgId"] == null)
                {
                    var rand = new Random();
                    if (Session["ChangedOrderMedicationIds"] != null)
                    {
                        string[] ClientMedicationIds = Session["ChangedOrderMedicationIds"].ToString().Split(',');
                        //Modified by Malathi Shiva on 09/July/2015 - Modified the conversion to handle null values
                        //Int32 ClientMedicationId = Convert.ToInt32(ClientMedicationIds[0]);
                        Int32 ClientMedicationId;
                        int.TryParse(ClientMedicationIds[0].ToString(), out ClientMedicationId);

                        ClientMedicationId = ClientMedicationId + rand.Next();
                        Session["imgId"]   = ClientMedicationId;
                        //Session["imgId"] = Session["ChangedOrderMedicationIds"];
                    }
                    else
                    {
                        if (HiddenFieldClientmedicationIdForConsent.Value != "" &&
                            HiddenFieldClientmedicationIdForConsent.Value != null)
                        {
                            Session["imgId"] = Convert.ToInt32(HiddenFieldClientmedicationIdForConsent.Value) +
                                               rand.Next();
                        }
                        //                        Session["imgId"] = Convert.ToString(HiddenFieldClientmedicationIdForConsent.Value);
                    }
                }
                else
                {
                    Session["imgId"] = Convert.ToInt32(Session["imgId"]) + 1;
                }
                ScriptId = Session["imgId"] + "_" + DateTime.Now.ToString("yyyyMMHHMMss") + "." + seq.ToString();
            }
            catch (Exception ex)
            {
            }

            using (var objRDLC = new RDLCPrint())
            {
                //In case of Ordering method as X Chart copy will be printed
                //objRDLC.Run(this.reportViewer1.LocalReport, Server.MapPath("RDLC\\" + Context.User.Identity.Name), Session["imgId"].ToString(), false, false);
                objRDLC.RunConsent(reportViewer1.LocalReport, Server.MapPath("RDLC\\" + Context.User.Identity.Name),
                                   ScriptId, false, false);

                //Added by Rohit. Ref ticket#84
                renderedBytes = reportViewer1.LocalReport.Render(reportType, deviceInfo, out mimeType, out encoding,
                                                                 out fileNameExtension, out streams, out warnings);
            }
            if (Session["VersionIdForConsentDetailPage"] != null)
            {
                if (HiddenFieldCheckImageClick.Value == "G")
                {
                    ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID,
                                                        "ShowPrintDiv('" + ScriptId + "','G');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID,
                                                        "ShowPrintDiv('" + ScriptId + "','Y');", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID,
                                                    "ShowPrintDiv('" + ScriptId + "');", true);
            }
            //Session["ImgIdForMDSigned"] = Session["imgId"];
            Session["ImgIdForMDSigned"] = ScriptId;
        }
        catch (Exception ex)
        {
            LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
        }
        finally
        {
            //    //Added by Vikas Vyas In ref to task 2334 On Dated March 04th 2008

            _DataSetGetRdlCName      = null;
            _DataSetRdlForMainReport = null;
            _DataSetRdlForSubReport  = null;
            _RptParam = null;
            if (Session["VersionIdForConsentDetailPage"] != null)
            {
                Session["VersionIdForConsentDetailPage"] = null;
            }
            if (Session["imgId"] != null)
            {
                Session["imgId"] = null;
            }

            ////End
        }
    }
コード例 #2
0
    public void GetRDLCContents()
    {
        #region Get RDLC Contents

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


        DataSet    _DataSetGetRdlCName      = null;
        DataSet    _DataSetRdlForMainReport = null;
        DataSet    _DataSetRdlForSubReport  = null;
        DataRow[]  dr              = null;
        DataRow[]  _drSubReport    = null;
        string     _OrderingMethod = "";
        string     strErrorMessage = "";
        LogManager objLogManager   = null;

        ReportParameter[] _RptParam = null;
        //Ref to Task#2660
        string FileName = "";
        int    seq      = 1;
        reportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer();

        try
        {
            _ReportPath = Server.MapPath(".") + System.Configuration.ConfigurationManager.AppSettings["MedicationPerscriptionReportUrl"];
            if (_ReportPath == "")//Check For Report Path
            {
                strErrorMessage = "ReportPath is Missing In WebConfig";
                ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID.ToString(), "ShowError('" + strErrorMessage + "', true);", true);
                return;
            }
        }
        catch (Exception ex)
        {
            Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);

            strErrorMessage = "ReportPath Key is Missing In WebConfig";
            ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID.ToString(), "ShowError('" + strErrorMessage + "', true);", true);
            return;
        }
        finally
        {
            objLogManager = null;
        }

        try
        {
            //Ref to Task#2660
            if (System.Configuration.ConfigurationSettings.AppSettings["SaveJpegOutput"].ToLower() == "true")
            {
                if (System.IO.Directory.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name)))
                {
                    if (!System.IO.Directory.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS")))
                    {
                        System.IO.Directory.CreateDirectory(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS"));
                    }

                    foreach (string file in Directory.GetFiles(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\")))
                    {
                        FileName = file.Substring(file.LastIndexOf("\\") + 1);
                        if ((FileName.IndexOf("JPEG") >= 0 || FileName.IndexOf("jpeg") >= 0))
                        {
                            //Added by Chandan on 16th Feb2010 ref task#2797
                            if (System.IO.File.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS") + "\\" + FileName))
                            {
                                if (FileName.ToUpper().IndexOf(".RDLC") == -1)
                                {
                                    System.IO.File.Delete(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\" + FileName));
                                }
                            }
                            else
                            {
                                while (seq < 1000)
                                {
                                    seq = seq + 1;
                                    if (!System.IO.File.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS") + "\\" + FileName))
                                    {
                                        System.IO.File.Move(file, Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS") + "\\" + FileName);
                                        break;
                                    }
                                    else
                                    {
                                        FileName = ApplicationCommonFunctions.GetFileName(FileName, seq);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                #region DeleteOldRenderedImages
                try
                {
                    using (Streamline.BaseLayer.RDLCPrint objRDLC = new RDLCPrint())
                    {
                        objRDLC.DeleteRenderedImages(Server.MapPath("RDLC\\" + Context.User.Identity.Name));
                    }
                }
                catch (Exception ex)
                {
                    Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
                }

                #endregion
            }
            //  _DataSetRdl = new DataSet();//Commented by Vikas Vyas On Dated March 04 2008
            Streamline.UserBusinessServices.ClientMedication objectClientMedications = null;
            objectClientMedications = new ClientMedication();
            //Added by Chandan for getting Location Id

            #region Added by Vikas Vyas


            _DataSetGetRdlCName = objectClientMedications.GetRdlCNameDataBase(1028);

            _DataSetGetRdlCName.Tables[0].TableName = "DocumentCodes";
            _DataSetGetRdlCName.Tables[1].TableName = "DocumentCodesRDLSubReports";


            if (_DataSetGetRdlCName.Tables["DocumentCodes"].Rows.Count > 0)
            {
                dr = _DataSetGetRdlCName.Tables["DocumentCodes"].Select();//because DocumentCodes table only contain one row



                //Check For Main Report
                if ((dr[0]["DocumentName"] != DBNull.Value || !String.IsNullOrEmpty(dr[0]["DocumentName"].ToString())) && (dr[0]["ViewStoredProcedure"] != DBNull.Value || !String.IsNullOrEmpty(dr[0]["ViewStoredProcedure"].ToString())))
                {
                    #region Get the StoredProceudreName and Execute
                    string _StoredProcedureName = "";
                    string _ReportName          = "";
                    _StoredProcedureName = dr[0]["ViewStoredProcedure"].ToString();//Get the StoredProcedure Name
                    _ReportName          = dr[0]["DocumentName"].ToString();

                    this.reportViewer1.ProcessingMode         = Microsoft.Reporting.WebForms.ProcessingMode.Local;
                    this.reportViewer1.LocalReport.ReportPath = _ReportPath + "\\" + _ReportName + ".rdlc";
                    this.reportViewer1.LocalReport.DataSources.Clear();


                    //Get Data For Main Report
                    //One More Parameter Added by Chandan Task#85 MM1.7
                    _DataSetRdlForMainReport = objectClientMedications.GetDataForPrescriberRdlC(_StoredProcedureName, ((Streamline.BaseLayer.StreamlineIdentity)Context.User.Identity).UserId, LabelReviewDateTime.Text, HiddenFieldRDLCurrentDateTime.Value);
                    //Microsoft.Reporting.WebForms.ReportDataSource DataSource = new ReportDataSource("RdlReportDataSet_" + _StoredProcedureName, _DataSetRdlForMainReport.Tables[0]);


                    Microsoft.Reporting.WebForms.ReportDataSource DataSource = new Microsoft.Reporting.WebForms.ReportDataSource("RDLReportDataSet_" + _StoredProcedureName, _DataSetRdlForMainReport.Tables[0]);
                    //Added by Chandan 0n 18th Dec 2008
                    //Session["DataSetRdlTemp"] = null;
                    DataSet dstemp = (DataSet)Session["DataSetRdlTemp"];
                    if (dstemp == null)
                    {
                        dstemp = _DataSetRdlForMainReport;
                    }
                    else
                    {
                        dstemp.Merge(_DataSetRdlForMainReport);
                    }
                    Session["DataSetRdlTemp"] = dstemp;
                    //HiddenFieldStoredProcedureName.Value = _StoredProcedureName;
                    //HiddenFieldReportName.Value = _ReportName;

                    #endregion

                    //Code addded by Loveena in ref to Task#2597
                    //Following parameters added with ref to Task 2371 SC-Support
                    _RptParam    = new ReportParameter[3];
                    _RptParam[0] = new ReportParameter("PrescriberId", ((Streamline.BaseLayer.StreamlineIdentity)Context.User.Identity).UserId.ToString());
                    _RptParam[1] = new ReportParameter("LastReviewTime", LabelReviewDateTime.Text);
                    _RptParam[2] = new ReportParameter("ServerTime", HiddenFieldRDLCurrentDateTime.Value);
                    reportViewer1.LocalReport.SetParameters(_RptParam);

                    reportViewer1.LocalReport.Refresh();
                    reportViewer1.LocalReport.DataSources.Add(DataSource);
                }
            }



            #endregion



            //Added by Rohit. Ref ticket#84
            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>";

            if (Session["imgId"] == null)
            {
                Session["imgId"] = 0;
            }
            else
            {
                Session["imgId"] = Convert.ToInt32(Session["imgId"]) + 1;
            }

            string ScriptId = Session["imgId"] + "_" + DateTime.Now.ToString("yyyyMMHHMMss") + "." + seq.ToString();

            try
            {
                using (Streamline.BaseLayer.RDLCPrint objRDLC = new RDLCPrint())
                {
                    //In case of Ordering method as X Chart copy will be printed

                    objRDLC.RunPreview(this.reportViewer1.LocalReport, Server.MapPath("RDLC\\" + Context.User.Identity.Name), ScriptId, false, false);

                    //Added by Rohit. Ref ticket#84
                    renderedBytes = reportViewer1.LocalReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

                    ShowReport(ScriptId);
                }
            }
            catch (Exception ex)
            {
                Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
            }
            finally
            {
                objLogManager = null;
            }
        }
        catch (Exception ex)
        {
            Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
        }
        finally
        {
            //    //Added by Vikas Vyas In ref to task 2334 On Dated March 04th 2008

            _DataSetGetRdlCName      = null;
            _DataSetRdlForMainReport = null;
            _DataSetRdlForSubReport  = null;
            _RptParam = null;
            ////End
        }

        #endregion
    }
コード例 #3
0
        public void GetRDLCContents()
        {
            #region Get RDLC Contents

            string     _ReportPath = "";
            string     mimeType;
            string     encoding;
            string     fileNameExtension;
            string[]   streams;
            DataSet    _DataSetGetRdlCName      = null;
            DataSet    _DataSetRdlForMainReport = null;
            DataSet    _DataSetRdlForSubReport  = null;
            DataRow[]  dr              = null;
            DataRow[]  _drSubReport    = null;
            string     _OrderingMethod = "";
            string     strErrorMessage = "";
            LogManager objLogManager   = null;

            ReportParameter[] _RptParam = null;
            int LocationId = 1;
            reportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer();
            string strIds = "";
            try
            {
                _ReportPath = Server.MapPath(".") + System.Configuration.ConfigurationManager.AppSettings["MedicationPerscriptionReportUrl"];
                if (_ReportPath == "")
                {
                    strErrorMessage = "ReportPath is Missing In WebConfig";
                    ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID.ToString(), "ShowError('" + strErrorMessage + "', true);", true);
                    return;
                }
            }
            catch (Exception ex)
            {
                Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
                strErrorMessage = "ReportPath Key is Missing In WebConfig";
                ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID.ToString(), "ShowError('" + strErrorMessage + "', true);", true);
                return;
            }
            finally
            {
                objLogManager = null;
            }
            try
            {
                Streamline.UserBusinessServices.ClientMedication objectClientMedications = null;
                objectClientMedications = new ClientMedication();
                _DataSetGetRdlCName     = objectClientMedications.GetRdlCNameDataBase(1026);
                _DataSetGetRdlCName.Tables[0].TableName = "DocumentCodes";
                _DataSetGetRdlCName.Tables[1].TableName = "DocumentCodesRDLSubReports";
                if (_DataSetGetRdlCName.Tables["DocumentCodes"].Rows.Count > 0)
                {
                    dr = _DataSetGetRdlCName.Tables["DocumentCodes"].Select();
                    if ((dr[0]["DocumentName"] != DBNull.Value || !String.IsNullOrEmpty(dr[0]["DocumentName"].ToString())) && (dr[0]["ViewStoredProcedure"] != DBNull.Value || !String.IsNullOrEmpty(dr[0]["ViewStoredProcedure"].ToString())))
                    {
                        #region Get the StoredProceudreName and Execute
                        string _StoredProcedureName = "";
                        string _ReportName          = "";
                        _StoredProcedureName = dr[0]["ViewStoredProcedure"].ToString();
                        _ReportName          = dr[0]["DocumentName"].ToString();
                        this.reportViewer1.ProcessingMode         = Microsoft.Reporting.WebForms.ProcessingMode.Local;
                        this.reportViewer1.LocalReport.ReportPath = _ReportPath + "\\" + _ReportName + ".rdlc";
                        this.reportViewer1.LocalReport.DataSources.Clear();
                        //Testing By Vikas Vyas
                        reportViewer1.LocalReport.Refresh();
                        //End

                        string str = Session["MedicationIdsForConsentDetailPage"].ToString();
                        _DataSetRdlForMainReport = objectClientMedications.GetDataForHarborStandardConsentRdlC(_StoredProcedureName, Convert.ToInt32((((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client.ClientId)), str, Convert.ToInt32(HiddenFieldLatestDocumentVersionId.Value));
                        Microsoft.Reporting.WebForms.ReportDataSource DataSource = new Microsoft.Reporting.WebForms.ReportDataSource("RDLReportDataSet_" + _StoredProcedureName, _DataSetRdlForMainReport.Tables[0]);
                        DataSet dstemp = (DataSet)Session["DataSetRdlTemp"];
                        if (dstemp == null)
                        {
                            dstemp = _DataSetRdlForMainReport;
                        }
                        else
                        {
                            dstemp.Merge(_DataSetRdlForMainReport);
                        }
                        Session["DataSetRdlTemp"] = dstemp;

                        #endregion
                        if (_DataSetGetRdlCName.Tables["DocumentCodesRDLSubReports"].Rows.Count > 0)
                        {
                            _drSubReport = _DataSetGetRdlCName.Tables["DocumentCodesRDLSubReports"].Select();
                            reportViewer1.LocalReport.SubreportProcessing -= new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(SetSubDataSource);
                            reportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(SetSubDataSource);
                            for (int i = 0; i < _drSubReport.Length; i++)
                            {
                                if ((_drSubReport[i]["SubReportName"] != DBNull.Value || !String.IsNullOrEmpty(_drSubReport[i]["SubReportName"].ToString())) && (_drSubReport[i]["StoredProcedure"] != DBNull.Value || !String.IsNullOrEmpty(_drSubReport[i]["StoredProcedure"].ToString())))
                                {
                                    #region Get the StoredProcedureName For SubReport and Execute
                                    string _SubReportStoredProcedure = "";
                                    string _SubReportName            = "";
                                    _SubReportStoredProcedure = _drSubReport[i]["StoredProcedure"].ToString();
                                    _SubReportName            = _drSubReport[i]["SubReportName"].ToString();
                                    string str2 = Session["MedicationIdsForConsentDetailPage"].ToString();
                                    _DataSetRdlForSubReport = objectClientMedications.GetDataForHarborStandardConsentRdlC(_SubReportStoredProcedure, Convert.ToInt32((((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client.ClientId)), str2, Convert.ToInt32(HiddenFieldLatestDocumentVersionId.Value));
                                    Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(_SubReportName, _DataSetRdlForSubReport.Tables[0]);
                                    reportViewer1.LocalReport.DataSources.Add(rds);
                                    string strRootPath = Server.MapPath(".");
                                    System.IO.StreamReader RdlSubReport = new System.IO.StreamReader(_ReportPath + "\\" + _SubReportName.Trim() + ".rdlc");
                                    reportViewer1.LocalReport.LoadReportDefinition(RdlSubReport);
                                    #endregion
                                }
                            }
                        }
                        _RptParam    = new ReportParameter[3];
                        _RptParam[0] = new ReportParameter("ClientId", Convert.ToString(((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client.ClientId));
                        string str1 = Session["MedicationIdsForConsentDetailPage"].ToString();
                        _RptParam[1] = new ReportParameter("ClientMedicationId", str1);
                        _RptParam[2] = new ReportParameter("ClientName", Convert.ToString(((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client.LastName + ", " + ((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client.FirstName));
                        reportViewer1.LocalReport.SetParameters(_RptParam);
                        reportViewer1.LocalReport.Refresh();
                        reportViewer1.LocalReport.DataSources.Add(DataSource);
                        strIds = str1;
                        //ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID.ToString(), "ShowPrintDiv('" + Session["ChangedOrderMedicationIds"].ToString() + "');", true);
                    }
                }
                #endregion
                try
                {
                    if (Session["imgId1"] == null || Session["imgId1"] == "")
                    {
                        string str = Session["MedicationIdsForConsentDetailPage"].ToString();
                        Session["imgId1"] = str;
                    }
                    else
                    {
                        Session["imgId1"] = Convert.ToInt32(Session["imgId1"]) + 1;
                    }
                }
                catch (Exception ex)
                {
                }
                #region DeleteOldRenderedImages
                try
                {
                    using (Streamline.BaseLayer.RDLCPrint objRDLC = new RDLCPrint())
                    {
                        objRDLC.DeleteRenderedImages(Server.MapPath("RDLC\\" + Context.User.Identity.Name));
                    }
                }
                catch (Exception ex)
                {
                    Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
                }
                #endregion

                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>";
                //try
                //{
                //    if (Session["imgId1"] == null)
                //    {
                //        string str = Session["MedicationIdsForConsentDetailPage"].ToString();
                //        Session["imgId1"] = str;
                //    }
                //    else
                //    {
                //        Session["imgId1"] = Convert.ToInt32(Session["imgId1"]) + 1;
                //    }
                //}
                //catch (Exception ex)
                //{
                //}
                if (Session["imgId1"] == null)
                {
                    Session["imgId1"] = strIds;
                }
                using (Streamline.BaseLayer.RDLCPrint objRDLC = new RDLCPrint())
                {
                    //objRDLC.Run(this.reportViewer1.LocalReport, Server.MapPath("RDLC\\" + Context.User.Identity.Name), Session["imgId1"].ToString(), false, false);
                    objRDLC.RunConsent(this.reportViewer1.LocalReport, Server.MapPath("RDLC\\" + Context.User.Identity.Name), Session["imgId1"].ToString(), false, false);

                    renderedBytes = reportViewer1.LocalReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
                }
                //ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID.ToString(), "ShowPrintDiv('" + Session["imgId1"].ToString() + "');", true);
            }
            catch (Exception ex)
            {
                Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
            }
            finally
            {
                _DataSetGetRdlCName      = null;
                _DataSetRdlForMainReport = null;
                _DataSetRdlForSubReport  = null;
                _RptParam = null;
            }
        }
コード例 #4
0
    /// <summary>
    /// <Description>Used to get Rdlc contents as per task#1(Venture)</Description>
    ///<Author>Pradeep</Author>
    /// <CreatedOn>2Dec,2009</CreatedOn>
    /// </summary>
    public void GetRDLCContents()
    {
        string _ReportPath = "";
        string mimeType;
        string encoding;
        string fileNameExtension;

        string[] streams;

        DataSet _DataSetGetRdlCName      = null;
        DataSet _DataSetRdlForMainReport = null;
        DataSet _DataSetRdlForSubReport  = null;

        DataRow[]  dr              = null;
        DataRow[]  _drSubReport    = null;
        string     _OrderingMethod = "";
        string     strErrorMessage = "";
        LogManager objLogManager   = null;
        //Ref to Task#2660
        string FileName = "";
        int    seq      = 1;

        ReportParameter[] _RptParam = null;

        reportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer();
        try
        {
            _ReportPath = Server.MapPath(".") + System.Configuration.ConfigurationManager.AppSettings["MedicationPerscriptionReportUrl"];
            if (_ReportPath == "")//Check For Report Path
            {
                strErrorMessage = "ReportPath is Missing In WebConfig";
                //ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID.ToString(), "ShowError('" + strErrorMessage + "', true);", true);
                return;
            }
        }
        catch (Exception ex)
        {
            Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);

            strErrorMessage = "ReportPath Key is Missing In WebConfig";
            //ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), ClientID.ToString(), "ShowError('" + strErrorMessage + "', true);", true);
            return;
        }
        finally
        {
            objLogManager = null;
        }
        try
        {
            //Ref to Task#2660
            if (System.Configuration.ConfigurationSettings.AppSettings["SaveJpegOutput"].ToLower() == "true")
            {
                if (System.IO.Directory.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name)))
                {
                    if (!System.IO.Directory.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS")))
                    {
                        System.IO.Directory.CreateDirectory(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS"));
                    }

                    foreach (string file in Directory.GetFiles(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\")))
                    {
                        FileName = file.Substring(file.LastIndexOf("\\") + 1);
                        if ((FileName.IndexOf("JPEG") >= 0 || FileName.IndexOf("jpeg") >= 0))
                        {
                            //Added by Chandan on 16th Feb2010 ref task#2797
                            if (System.IO.File.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS") + "\\" + FileName))
                            {
                                if (FileName.ToUpper().IndexOf(".RDLC") == -1)
                                {
                                    System.IO.File.Delete(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\" + FileName));
                                }
                            }
                            else
                            {
                                while (seq < 1000)
                                {
                                    seq = seq + 1;
                                    if (!System.IO.File.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS") + "\\" + FileName))
                                    {
                                        System.IO.File.Move(file, Server.MapPath("RDLC\\" + Context.User.Identity.Name + "\\JPEGS") + "\\" + FileName);
                                        break;
                                    }
                                    else
                                    {
                                        //string FirstName = FileName.Substring(0, FileName.IndexOf("."));
                                        //string LastName = FileName.Substring(FileName.IndexOf(".") + 1);
                                        //string MiddleName = LastName.Substring(0, LastName.IndexOf("."));
                                        //MiddleName = MiddleName.Replace(MiddleName, seq.ToString());

                                        //FileName = FileName.Replace(FileName.Substring(FileName.IndexOf(".") + 1).Substring(0, FileName.Substring(FileName.IndexOf(".") + 1).IndexOf(".")), seq.ToString());
                                        FileName = ApplicationCommonFunctions.GetFileName(FileName, seq);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                //Code added to delete the rendered images
                try
                {
                    using (Streamline.BaseLayer.RDLCPrint objRDLC = new RDLCPrint())
                    {
                        objRDLC.DeleteRenderedImages(Server.MapPath("RDLC\\" + Context.User.Identity.Name));
                    }
                }
                catch (Exception ex)
                {
                    Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
                }
            }
            Streamline.UserBusinessServices.ClientMedication objectClientMedications = null;
            objectClientMedications = new ClientMedication();
            _DataSetGetRdlCName     = objectClientMedications.GetRdlCNameDataBase(1035);

            _DataSetGetRdlCName.Tables[0].TableName = "DocumentCodes";
            _DataSetGetRdlCName.Tables[1].TableName = "DocumentCodesRDLSubReports";
            if (Request.QueryString["MedicationId"] != null || Request.QueryString["MedicationId"] != string.Empty)
            {
                clientMedicationId = Convert.ToInt32(Request.QueryString["MedicationId"].ToString());
            }
            if (Request.QueryString["OrderName"] != null || Request.QueryString["OrderName"] != string.Empty)
            {
                method = Convert.ToString(Request.QueryString["OrderName"].ToString());
            }
            if (Request.QueryString["StaffId"] != null || Request.QueryString["StaffId"] != string.Empty)
            {
                staffId = Convert.ToInt32(Request.QueryString["StaffId"].ToString());
            }
            //if (Request.QueryString["PharmacyId"] != null || Request.QueryString["PharmacyId"] != string.Empty)
            //{
            //    pharmacyId = Convert.ToInt32(Request.QueryString["PharmacyId"].ToString());
            //}
            DataSet dataSetClientSummary = null;
            if (Session["DataSetClientSummary"] != null)
            {
                dataSetClientSummary = (DataSet)Session["DataSetClientSummary"];
                DataRow[] dataRowPharmacy = dataSetClientSummary.Tables["ClientPharmacies"].Select("SequenceNumber=1");
                if (dataRowPharmacy.Length > 0)
                {
                    string _PharmacyId = dataRowPharmacy[0]["PharmacyId"] == DBNull.Value ? string.Empty : dataRowPharmacy[0]["PharmacyId"].ToString();
                    if (_PharmacyId.Trim() != string.Empty && pharmacyId == 0)
                    {
                        pharmacyId = Convert.ToInt32(_PharmacyId);
                    }
                }
            }
            if (_DataSetGetRdlCName.Tables["DocumentCodes"].Rows.Count > 0)
            {
                dr = _DataSetGetRdlCName.Tables["DocumentCodes"].Select();//because DocumentCodes table only contain one row
                //Check For Main Report
                if ((dr[0]["DocumentName"] != DBNull.Value || !String.IsNullOrEmpty(dr[0]["DocumentName"].ToString())) && (dr[0]["ViewStoredProcedure"] != DBNull.Value || !String.IsNullOrEmpty(dr[0]["ViewStoredProcedure"].ToString())))
                {
                    #region --Get the StoredProceudreName and Execute
                    string _StoredProcedureName = "";
                    string _ReportName          = "";
                    _StoredProcedureName = dr[0]["ViewStoredProcedure"].ToString();//Get the StoredProcedure Name
                    _ReportName          = dr[0]["DocumentName"].ToString();
                    this.reportViewer1.ProcessingMode         = Microsoft.Reporting.WebForms.ProcessingMode.Local;
                    this.reportViewer1.LocalReport.ReportPath = _ReportPath + "\\" + _ReportName + ".rdlc";
                    this.reportViewer1.LocalReport.DataSources.Clear();

                    _DataSetRdlForMainReport = objectClientMedications.GetDataForDisContinueRdlC(_StoredProcedureName, clientMedicationId, method, staffId, pharmacyId);

                    Microsoft.Reporting.WebForms.ReportDataSource DataSource = new Microsoft.Reporting.WebForms.ReportDataSource("RDLDiscontinueDataSet_" + _StoredProcedureName, _DataSetRdlForMainReport.Tables[0]);
                    DataSet dataSetTemp = new DataSet();
                    dataSetTemp.Merge(_DataSetRdlForMainReport);
                    #endregion --Get the StoredProceudreName and Execute
                    _RptParam    = new ReportParameter[4];
                    _RptParam[0] = new ReportParameter("ClientMedicationId", Convert.ToString(clientMedicationId));
                    _RptParam[1] = new ReportParameter("Method", method);
                    _RptParam[2] = new ReportParameter("InitiatedBy", Convert.ToString(staffId));
                    _RptParam[3] = new ReportParameter("PharmacyId", "0");
                    reportViewer1.LocalReport.SetParameters(_RptParam);

                    reportViewer1.LocalReport.Refresh();
                    reportViewer1.LocalReport.DataSources.Add(DataSource);
                }
            }
            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>";

            if (Session["imgId"] == null)
            {
                Session["imgId"] = 0;
            }
            else
            {
                Session["imgId"] = Convert.ToInt32(Session["imgId"]) + 1;
            }

            string ScriptId = Session["imgId"] + "_" + DateTime.Now.ToString("yyyyMMHHMMss") + "." + seq.ToString();

            try
            {
                using (Streamline.BaseLayer.RDLCPrint objRDLC = new RDLCPrint())
                {
                    //In case of Ordering method as X Chart copy will be printed

                    //objRDLC.RunPreview(this.reportViewer1.LocalReport, Server.MapPath("RDLC\\" + Context.User.Identity.Name), Session["imgId"].ToString(), false, false);
                    objRDLC.Run(this.reportViewer1.LocalReport, Server.MapPath("RDLC\\" + Context.User.Identity.Name), ScriptId, false, false);

                    //Added by Rohit. Ref ticket#84
                    renderedBytes = reportViewer1.LocalReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

                    ShowReport(ScriptId);
                }
            }
            catch (Exception ex)
            {
                Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
            }
            finally
            {
                objLogManager = null;
            }
        }
        catch (Exception ex)
        {
            Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this);
        }
    }