Exemplo n.º 1
0
        /// <summary>
        /// Created by:     Josephine Monteza
        /// Date Created:   07/May/2014
        /// Description:    Export Report
        /// ----------------------------------------------------
        /// </summary>
        public bool ExportPDFAll(string exportType, string reportsTitle, string sUserID)
        {
            try
            {
                Warning[] warnings  = null;
                string[]  streamIds = null;
                string    mimeType  = string.Empty;
                string    encoding  = string.Empty;
                string    extension = string.Empty;
                string    filetype  = string.Empty;
                // just gets the Report title... make your own method
                //ReportViewer needs a specific type (not always the same as the extension)

                filetype = exportType == "PDF" ? "PDF" : exportType;

                string sServerUser   = ConfigurationSettings.AppSettings["ReportUser"].ToString();
                string sServerPwd    = ConfigurationSettings.AppSettings["ReportPwd"].ToString();
                string sServerDomain = ConfigurationSettings.AppSettings["ReportDomain"].ToString();

                IReportServerCredentials irsc = new ReportCredentials(sServerUser, sServerPwd, sServerDomain);

                ReportViewer1.ServerReport.ReportServerCredentials = irsc;

                // Create report parameter
                ReportParameter paramUser = new ReportParameter();
                paramUser.Name = "pUserID";
                paramUser.Values.Add(sUserID);

                // Set the report parameters for the report
                ReportViewer1.ServerReport.SetParameters(
                    new ReportParameter[] { paramUser });


                byte[] bytes = ReportViewer1.ServerReport.Render(filetype, null, // deviceinfo not needed for csv
                                                                 out mimeType, out encoding, out extension, out streamIds, out warnings);
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();
                System.Web.HttpContext.Current.Response.ContentType = mimeType;
                System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + reportsTitle + "." + exportType);
                System.Web.HttpContext.Current.Response.BinaryWrite(bytes);

                FileStream fs = new FileStream(Server.MapPath("~/Extract/CrewAdmin/" + reportsTitle + "." + exportType), FileMode.OpenOrCreate);

                fs.Write(bytes, 0, bytes.Length);
                fs.Close();

                System.Web.HttpContext.Current.Response.Flush();
                // System.Web.HttpContext.Current.Response.End();
                //HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
            catch (Exception ex)
            {
                //throw ex;
            }
            finally
            {
            }
            return(true);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Reports oReport = new Reports(0, dsn);

            if (Request.QueryString["r"] != null && Request.QueryString["r"] != "")
            {
                try
                {
                    Variables oVariable   = new Variables(intEnvironment);
                    Functions oFunction   = new Functions(0, dsn, intEnvironment);
                    int       intReport   = Int32.Parse(oFunction.decryptQueryString(Request.QueryString["r"]));
                    string    strReport   = oReport.Get(intReport, "path");
                    string    strPhysical = oReport.Get(intReport, "physical");
                    if (strReport != "")
                    {
                        ReportViewer1.Visible = true;
                        bool   boolOLD = (oReport.Get(intReport, "old") == "1");
                        string strURL  = "";
                        if (boolOLD == false)
                        {
                            DataSet dsKey = oFunction.GetSetupValuesByKey(Environment.MachineName + "_REPORTING");
                            if (dsKey.Tables[0].Rows.Count > 0)
                            {
                                strURL = dsKey.Tables[0].Rows[0]["Value"].ToString();
                            }
                        }
                        //else
                        //    strURL = oVariable.DefaultReportURL_OLD();
                        if (strURL != "")
                        {
                            Uri u = new Uri(strURL);
                            ReportViewer1.ServerReport.ReportServerUrl = u;
                            ReportViewer1.ServerReport.ReportPath      = strReport;
                            ReportCredentials oReportCredential = new ReportCredentials(0, dsn, intEnvironment);
                            ReportViewer1.ServerReport.ReportServerCredentials = oReportCredential;
                            ReportViewer1.ZoomPercent          = 10;
                            ReportViewer1.ShowToolBar          = false;
                            ReportViewer1.WaitMessageFont.Size = FontUnit.XXSmall;
                            ReportViewer1.SizeToReportContent  = true;
                        }
                        else
                        {
                            divNA.Visible = true;
                        }
                    }
                    else
                    {
                        divNA.Visible = true;
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Reports oReport = new Reports(0, dsn);

            if (!IsPostBack)
            {
                if (Request.QueryString["n"] != null && Request.QueryString["n"] != "")
                {
                    try
                    {
                        Variables oVariable = new Variables(intEnvironment);
                        Functions oFunction = new Functions(0, dsn, intEnvironment);
                        string    strURL    = "";
                        DataSet   dsKey     = oFunction.GetSetupValuesByKey(Environment.MachineName + "_REPORTING");
                        if (dsKey.Tables[0].Rows.Count > 0)
                        {
                            strURL = dsKey.Tables[0].Rows[0]["Value"].ToString();
                        }
                        if (strURL != "")
                        {
                            Uri u = new Uri(strURL);
                            ReportViewer1.ServerReport.ReportServerUrl = u;
                            ReportViewer1.ServerReport.ReportPath      = "/Project Reports/Infrastructure Project Status Scorecard";
                            ReportViewer1.ShowParameterPrompts         = false;
                            ReportCredentials oReportCredential = new ReportCredentials(0, dsn, intEnvironment);
                            ReportViewer1.ServerReport.ReportServerCredentials = oReportCredential;
                            ReportParameter[] parameters = new ReportParameter[1];
                            parameters[0] = new ReportParameter("Project", oFunction.decryptQueryString(Request.QueryString["n"]));
                            ReportViewer1.ServerReport.SetParameters(parameters);
                            ReportViewer1.ZoomPercent = 100;
                            ReportViewer1.ServerReport.Refresh();
                            panShow.Visible = true;
                        }
                        else
                        {
                            Response.Write("Invalid Reporting URL ~ " + Environment.MachineName + "_REPORTING");
                        }
                    }
                    catch (Exception ex)
                    {
                        panError.Visible = true;
                        Response.Write(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Created by:     Josephine Monteza
        /// Date Created:   07/May/2014
        /// Description:    Export Report
        /// ----------------------------------------------------
        /// </summary>
        public bool ExportPDFCrewverification(string exportType, string reportsTitle, string SeafareID, string LOENumber, string joindate, string Vessel, string Port)
        {
            try
            {
                List <SeafarerImage>           SeafarerImage = new List <SeafarerImage>();
                MGW.QRCode.Codec.QRCodeEncoder rq            = new MGW.QRCode.Codec.QRCodeEncoder();

                System.Drawing.Bitmap  myImage;
                List <CrewImmigration> Immigration = new List <CrewImmigration>();

                DateTime Mydate = new DateTime();
                Mydate = GlobalCode.Field2DateTime(joindate);


                myImage = rq.Encode(SeafareID + "+" + LOENumber + "+" + Mydate.ToString("MMMM") + " " + Mydate.Day.ToString() + " " + Mydate.Year.ToString() + "+" + Vessel + "+" + Port);
                SeafarerImage.Add(new SeafarerImage
                {
                    Image      = GlobalCode.Field2BitmapByte(myImage),
                    ImageType  = "jpg",
                    LOENumber  = LOENumber,
                    SeaparerID = GlobalCode.Field2Long(SeafareID),
                    LogInUser  = GlobalCode.Field2String(Session["UserName"])
                });



                TRAVELMART.BLL.ImmigrationBLL BLL = new TRAVELMART.BLL.ImmigrationBLL();
                BLL.InsertQRCode(SeafarerImage);


                Warning[] warnings  = null;
                string[]  streamIds = null;
                string    mimeType  = string.Empty;
                string    encoding  = string.Empty;
                string    extension = string.Empty;
                string    filetype  = string.Empty;
                // just gets the Report title... make your own method
                //ReportViewer needs a specific type (not always the same as the extension)

                filetype = exportType == "PDF" ? "PDF" : exportType;

                string sServerUser   = ConfigurationSettings.AppSettings["ReportUser"].ToString();
                string sServerPwd    = ConfigurationSettings.AppSettings["ReportPwd"].ToString();
                string sServerDomain = ConfigurationSettings.AppSettings["ReportDomain"].ToString();

                IReportServerCredentials irsc = new ReportCredentials(sServerUser, sServerPwd, sServerDomain);

                ReportViewer1.ServerReport.ReportServerCredentials = irsc;
                ReportParameter[] ParamReport = new ReportParameter[2];
                ParamReport[0] = new ReportParameter("pSeafarerID", SeafareID);
                ParamReport[1] = new ReportParameter("pLOEControlNumber", LOENumber);

                //// Create report parameter
                //ReportParameter ParamReport = new ReportParameter();
                //ParamReport.Name = "pSeafarerID";
                //ParamReport.Values.Add(SeafareID);
                //ParamReport.Name = "pLOEControlNumber";
                //ParamReport.Values.Add(LOENumber);


                ReportViewer1.ServerReport.SetParameters(ParamReport);



                //paramUser.Values.Add(sUserID);

                // Set the report parameters for the report
                //ReportViewer1.ServerReport.SetParameters(
                //    new ReportParameter[] { ParamReport });


                byte[] bytes = ReportViewer1.ServerReport.Render(filetype, null, // deviceinfo not needed for csv
                                                                 out mimeType, out encoding, out extension, out streamIds, out warnings);
                System.Web.HttpContext.Current.Response.Buffer = true;
                System.Web.HttpContext.Current.Response.Clear();
                System.Web.HttpContext.Current.Response.ContentType = mimeType;
                System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + reportsTitle + "." + exportType);
                System.Web.HttpContext.Current.Response.BinaryWrite(bytes);

                FileStream fs = new FileStream(Server.MapPath("~/Extract/Immigration/" + reportsTitle + "." + exportType), FileMode.OpenOrCreate);

                fs.Write(bytes, 0, bytes.Length);
                fs.Close();

                System.Web.HttpContext.Current.Response.Flush();
                // System.Web.HttpContext.Current.Response.End();
                //HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
            catch (Exception ex)
            {
                //throw ex;
            }
            finally
            {
            }
            return(true);
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Reports oReport = new Reports(0, dsn);

            if (!IsPostBack)
            {
                int intApplication = -1;
                if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "")
                {
                    intApplication = Int32.Parse(Request.QueryString["applicationid"]);
                }
                if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "")
                {
                    intApplication = Int32.Parse(Request.Cookies["application"].Value);
                }
                if (intApplication > -1 && Request.QueryString["r"] != null && Request.QueryString["r"] != "")
                {
                    try
                    {
                        Variables oVariable = new Variables(intEnvironment);
                        Functions oFunction = new Functions(0, dsn, intEnvironment);
                        int       intReport = Int32.Parse(oFunction.decryptQueryString(Request.QueryString["r"]));
                        string    strReport = oReport.Get(intReport, "path");
                        if (strReport != "")
                        {
                            bool   boolOLD = (oReport.Get(intReport, "old") == "1");
                            string strURL  = "";
                            if (boolOLD == false)
                            {
                                DataSet dsKey = oFunction.GetSetupValuesByKey(Environment.MachineName + "_REPORTING");
                                if (dsKey.Tables[0].Rows.Count > 0)
                                {
                                    strURL = dsKey.Tables[0].Rows[0]["Value"].ToString();
                                }
                            }
                            //else
                            //    strURL = oVariable.DefaultReportURL_OLD();
                            if (strURL != "")
                            {
                                Uri u = new Uri(strURL);
                                ReportViewer1.ServerReport.ReportServerUrl = u;
                                ReportViewer1.ServerReport.ReportPath      = strReport;
                                ReportCredentials oReportCredential = new ReportCredentials(0, dsn, intEnvironment);
                                ReportViewer1.ServerReport.ReportServerCredentials = oReportCredential;
                                ReportViewer1.ZoomPercent = Int32.Parse(oReport.Get(intReport, "percentage"));
                                if (oReport.Get(intReport, "application") == "1")
                                {
                                    ReportParameter[] parameters = new ReportParameter[1];
                                    parameters[0] = new ReportParameter("applicationid", intApplication.ToString());
                                    ReportViewer1.ServerReport.SetParameters(parameters);
                                    // ???
                                    ReportViewer1.ServerReport.Refresh();
                                }
                            }
                            else
                            {
                                Response.Write("Invalid Reporting URL ~ " + Environment.MachineName + "_REPORTING");
                            }
                        }
                        else
                        {
                            Response.Write("Invalid Report Path");
                        }
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.Message);
                    }
                }
            }
        }