コード例 #1
0
        public IHttpActionResult ConvertToImage(String instrumentIdAndDate)
        {
            CheckImageModel checkImageModel = new CheckImageModel();

            SearchEngineIWOWService searchEngineService = new SearchEngineIWOWService();

            checkImageModel = searchEngineService.ManageCheckImage(instrumentIdAndDate);
            //byte[] file = GetFile(id);
            //HttpResponseMessage result = Request.CreateResponse(HttpStatusCode.OK);
            string content = Convert.ToBase64String(checkImageModel.fileByte64) + "FILENAME:" + checkImageModel.fileName;

            return(Ok(content));
        }
コード例 #2
0
        public CheckImageModel GetImageForContribution(int imgId)
        {
            System.Data.Linq.Binary iBinary = (from i in CurrentImageDatabase.Others
                                               where i.Id == imgId
                                               select i.First).FirstOrDefault();

            CheckImageModel chkModel = new CheckImageModel
            {
                ImageId         = imgId,
                checkImageBytes = iBinary.ToArray()
            };

            return(chkModel);
        }
コード例 #3
0
        // GET: Dialog/GetcheckImage
        public ActionResult GetCheckImage(int id)
        {
            if (id.IsNull())
            {
                id = 0;
            }

            int imgId = (from c in CurrentDatabase.Contributions
                         where c.ContributionId == id
                         select c.ImageID).FirstOrDefault();
            CheckImageModel chkImageModel = new CheckImageModel();

            if (imgId != 0)
            {
                chkImageModel = GetImageForContribution(imgId);
            }

            return(PartialView("~/Areas/Dialog/Views/GetCheckImage/GetCheckImage.cshtml", chkImageModel));
        }
コード例 #4
0
        public CheckImageModel GetImageForContribution(int contributionId)
        {
            int imgId = (from c in CurrentDatabase.Contributions
                         where c.ContributionId == contributionId
                         select c.ImageID).FirstOrDefault();

            CheckImageModel chkModel = null;

            if (imgId != 0)
            {
                System.Data.Linq.Binary iBinary = (from i in CurrentImageDatabase.Others
                                                   where i.Id == imgId
                                                   select i.First).FirstOrDefault();

                chkModel = new CheckImageModel
                {
                    ImageId         = imgId,
                    checkImageBytes = iBinary.ToArray()
                };
            }
            return(chkModel ?? new CheckImageModel());
        }
コード例 #5
0
        // GET: Dialog/RawCheckImage
        public ActionResult RawCheckImage(int id)
        {
            CheckImageModel chkImageModel = GetImageForContribution(id);

            return(new FileContentResult(chkImageModel.checkImageBytes, "image/png"));
        }
コード例 #6
0
        // GET: Dialog/GetcheckImage
        public ActionResult GetCheckImage(int id)
        {
            CheckImageModel chkImageModel = GetImageForContribution(id);

            return(PartialView("~/Areas/Dialog/Views/GetCheckImage/GetCheckImage.cshtml", chkImageModel));
        }
コード例 #7
0
        public CheckImageModel ManageCheckImage(string checkDetailParams)
        {
            CheckImageModel checkImageModel = new CheckImageModel();
            var             chk             = "";
            var             instrument_id   = "";

            byte[] imgByteView1            = null;
            byte[] imgByteView2            = null;
            string accountNo               = checkDetailParams.Split('|')[0];
            string instrumentIdDate        = checkDetailParams.Split('|')[1];
            string instrumentIdCheckNumber = checkDetailParams.Split('|')[2];
            string instrumentAmount        = checkDetailParams.Split('|')[3];
            string instrumentBRSTN         = checkDetailParams.Split('|')[4];


            string sqlQuery = @"SELECT A.instrument_id, A.VIEW1, A.VIEW2, b.CAR_AMOUNT
                                FROM tbl_images A JOIN tbl_inward B
                                ON A.instrument_id = b.instrument_id
                                WHERE B.payee_acno = '" + accountNo + "' AND B.TRANSACTION_DATE = '" + instrumentIdDate + "'AND B.instrument_number = '" + instrumentIdCheckNumber + "'";


            string str = "";


            using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["EXPRESS_SBC_CONN"].ConnectionString))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand(sqlQuery, connection);
                    connection.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    DataSet       ds     = new DataSet();
                    reader.Close();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(ds);
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        //imgByte = Encoding.ASCII.GetBytes(dr["VIEW2"].ToString());
                        //imgByte = Encoding.ASCII.GetBytes(dr["VIEW1"].ToString());
                        imgByteView1  = (byte[])dr["VIEW1"];
                        imgByteView2  = (byte[])dr["VIEW2"];
                        instrument_id = dr["instrument_id"].ToString();
                        //str = Convert.ToBase64String(imgByteView1);
                        chk = "data:Image/jpeg;base64," + str;
                    }
                    //File.WriteAllBytes(@"C:\\Users\\206867\\Desktop\\1_files\\sample2.jpg", imgByteView1);
                    if (!File.Exists(sbcCheckImageLoc + "\\" + instrument_id + "_front.jpg") && !File.Exists(sbcCheckImageLoc + "\\" + instrument_id + "_back.jpg"))
                    {
                        File.WriteAllBytes(sbcCheckImageLoc + "\\" + instrument_id + "_front.jpg", imgByteView1);
                        File.WriteAllBytes(sbcCheckImageLoc + "\\" + instrument_id + "_back.jpg", imgByteView2);

                        createPdf(instrumentIdCheckNumber, instrumentIdDate, instrumentAmount, accountNo, instrumentBRSTN, instrument_id);
                    }
                }
                catch (Exception e)
                {
                    System.Console.WriteLine(e.Message);
                }
            }


            string fileName = sbcCheckImageLoc + "\\" + instrument_id + ".pdf";

            byte[]     buff = File.ReadAllBytes(fileName);
            FileStream fs   = new FileStream(fileName,
                                             FileMode.Open,
                                             FileAccess.Read);
            BinaryReader br       = new BinaryReader(fs);
            long         numBytes = new FileInfo(fileName).Length;

            buff = br.ReadBytes((int)numBytes);


            checkImageModel.fileByte64 = buff;
            checkImageModel.fileName   = instrumentIdCheckNumber;

            return(checkImageModel);
        }