예제 #1
0
        public void OnEndExceptions(IAsyncResult ar)
        {
            List <SeafarerImage> SeafarerImage = new List <SeafarerImage>();
            QRCodeEncoder        rq            = new QRCodeEncoder();

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

            Immigration = (List <CrewImmigration>)Session["immigration"];
            for (var i = 0; Immigration.Count > i; i++)
            {
                myImage = rq.Encode(txtUniqeID.Text + "+" + Immigration[i].LOEControlNumber + "+" + Immigration[i].Joindate.Value.ToString("MMMM") + " " + Immigration[i].Joindate.Value.Day.ToString() + " " + Immigration[i].Joindate.Value.Year.ToString() + "+" + Immigration[i].Vessel + "+" + Immigration[i].Seaport);


                SeafarerImage.Add(new SeafarerImage
                {
                    Image      = GlobalCode.Field2BitmapByte(myImage),
                    ImageType  = "jpg",
                    LOENumber  = Immigration[i].LOEControlNumber,
                    SeaparerID = GlobalCode.Field2Long(txtUniqeID.Text),
                    LogInUser  = GlobalCode.Field2String(Session["UserName"])
                });
            }



            ImmigrationBLL BLL = new ImmigrationBLL();

            BLL.InsertQRCode(SeafarerImage);


            //foreach (ListViewItem item in Immigration.Items)
            //{
            //    txtJoindate = (TextBox)item.FindControl("txtJoindate");
            //    txtJoinShip = (TextBox)item.FindControl("txtJoinShip");
            //    txtJoinPort = (TextBox)item.FindControl("txtJoinPort");
            //    HPLOENumber = (HiddenField)item.FindControl("uoHiddenFieldControlNo");

            //    myImage = rq.Encode(txtUniqeID.Text + "+" + HPLOENumber.Value + "+" + txtJoindate.Text + "+" + txtJoinShip.Text + "+" + txtJoinPort.Text);


            //    SeafarerImage.Add(new SeafarerImage
            //    {
            //        Image = GlobalCode.Field2BitmapByte(myImage),
            //        ImageType = "jpg",
            //        LOENumber = HPLOENumber.Value,
            //        SeaparerID = GlobalCode.Field2Long(txtUniqeID.Text)
            //    });

            //}



            //if (immigration[0].SeafarerImage.Count > 0)
            //{
            //    uoImageCM.ImageUrl = GlobalCode.Field2PictureImage(GlobalCode.Field2BitmapByte(myImage), "jpg");
            //}
        }
예제 #2
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);
        }