Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string page  = this.Request.QueryString["page"].ToLower();;
        string id    = this.Request.QueryString["id"];
        string print = this.Request.QueryString["print"];
        string lang  = this.Request.QueryString["lang"];

        if (lang == null)
        {
            lang = "EN";
        }
        PdfAndWord common = new PdfAndWord();

        switch (page)
        {
        case "capa":
            common = new PdfCapa();
            break;

        case "ba":
            common = new PdfBa();
            break;

        case "permit":
            common = new PdfPermit();
            break;

        case "gas":
            common = new PdfGas();
            break;

        case "confined":
            common = new PdfCofined();
            break;

        case "lift":
            common = new PdfLift();
            break;

        case "jsa":
            common = new PdfJsa();
            break;

        case "ei":
            common = new PdfEi();
            break;

        case "hotwork":
            common = new PdfHotwork();
            break;

        case "crane":
            common = new PdfCrane();
            break;

        case "riding":
            common = new PdfRiding();
            break;

        case "wi":
            common = new PdfWi();
            break;

        case "fullroster":
            common = new PdfFullRoster();
            break;

        case "swa":
            common = new PdfSwa();
            break;

        case "capaplan":
            common = new PdfCapaPlan();
            break;

        case "oap":
            common = new PdfOap();
            break;
        }
        SortedList sl = new SortedList();

        sl.Add("id", id);
        sl.Add("lang", lang);
        //sl.Add("UserId", this.UserId);
        //ds = this.da.GetDataSet("usp_PdfGet"+name, sl );
        ds        = this.da.GetDataSet("usp_Pdf" + page, sl);
        common.ds = ds;
        if (lang != "EN")
        {
            common.dsLang = this.da.GetDataSet(" select Name, " + lang + " as Name1 from tbl_Label where page like '%" + page + "%'");
        }
        common.BaseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority;
        common.Lang    = lang;
        if (page == "permit")
        {
            common.Title = this.ds.Tables[2].Rows[0]["Type"].ToString();
        }
        string userName = Ensco.Utilities.UtilitySystem.CurrentUser.UserName;
        //common.Start(this.Response, userName);
        //return;
        //if(print == "1") {
        //    this.FileName = common.Start(null, userName);
        //} else
        //    common.Start(this.Response, userName);
    }
Exemple #2
0
        public FileStreamResult Pdf( )
        {
            try {
                string page  = this.Request.QueryString["page"].ToLower();;
                string id    = this.Request.QueryString["id"];
                string print = this.Request.QueryString["print"];
                string lang  = this.Request.QueryString["lang"];
                if (lang == null)
                {
                    lang = "EN";
                }
                PdfAndWord common = new PdfAndWord();
                switch (page)
                {
                case "capa":
                    common = new PdfCapa();
                    break;

                case "ba":
                    common = new PdfBa();
                    break;

                case "permit":
                    common = new PdfPermit();
                    break;

                case "gas":
                    common = new PdfGas();
                    break;

                case "confined":
                    common = new PdfCofined();
                    break;

                case "lift":
                    common = new PdfLift();
                    break;

                case "jsa":
                    common = new PdfJsa();
                    break;

                case "ei":
                    common = new PdfEi();
                    break;

                case "hotwork":
                    common = new PdfHotwork();
                    break;

                case "crane":
                    common = new PdfCrane();
                    break;

                case "riding":
                    common = new PdfRiding();
                    break;

                case "wi":
                    common = new PdfWi();
                    break;

                case "fullroster":
                    common = new PdfFullRoster();
                    break;

                case "swa":
                    common = new PdfSwa();
                    break;

                case "capaplan":
                    common = new PdfCapaPlan();
                    break;

                case "poblifeboat":
                    common = new PdfPobLifeboat();
                    break;

                case "oap":
                    common = new PdfOap();
                    break;
                }
                SortedList sl = new SortedList();
                sl.Add("id", id);
                sl.Add("lang", lang);
                DataSet ds = this.GetDataSet("usp_Pdf" + page + " '" + id.ToString() + "', '" + lang + "'");
                common.ds = ds;
                if (lang != "EN")
                {
                    common.dsLang = this.da.GetDataSet(" select Name, " + lang + " as Name1 from tbl_Label where page like '%" + page + "%'");
                }
                // common.BaseUrl = HttpContextb .Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority;

                if (this.Request.Url.Authority.ToLower().Contains("localhost"))
                {
                    common.BaseUrl = "http://localhost:82";
                }
                else
                {
                    common.BaseUrl = UtilitySystem.Settings.ConfigSettings["BaseUrlPdf"];
                }
                common.Lang = lang;
                if (page == "permit")
                {
                    common.Title = ds.Tables[2].Rows[0]["Type"].ToString();
                }
                string userName = Ensco.Utilities.UtilitySystem.CurrentUser.UserName;
                //common.Start(System.Web.HttpContext.Current.Response, userName);
                MemoryStream workStream = new MemoryStream();
                common.Start(workStream, userName);
                byte[] byteInfo = workStream.ToArray();
                workStream.Write(byteInfo, 0, byteInfo.Length);
                workStream.Position = 0;

                return(new FileStreamResult(workStream, "application/pdf"));
            } catch (Exception e) {
                this.GetDataSet("insert tbl_error select  getdate(), '" + e.Message.Replace("'", "''") + "'");
            }
            return(null);
            //return;
            //if(print == "1") {
            //    this.FileName = common.Start(null, this.UserName);
            //    // ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp","<script language=JavaScript>document.Pdf2.printAll()</script>");
            //} else
            //    common.Start(this.Response, this.UserName);
        }