Beispiel #1
0
        public IEnumerable <ResponseFlag> FinalUploadCropImage(UploadMandateModel context)
        {
            List <ResponseFlag> common = new List <ResponseFlag>();
            ResponseFlag        Flag   = new ResponseFlag();

            try
            {
                string croppedFileName = string.Empty;
                string filePath        = string.Empty;
                string ID          = Convert.ToString(Dbsecurity.Decrypt(context.MdtID));
                string No          = Convert.ToString(Dbsecurity.Decrypt(context.RefrenceNo));
                string APPId       = Convert.ToString(Dbsecurity.Decrypt(context.AppID));
                string UserId      = Convert.ToString(Dbsecurity.Decrypt(context.UserId));
                string JPGFilepath = string.Empty;
                croppedFileName = ConfigurationManager.AppSettings["DownloadFileName" + APPId].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".tif";
                filePath        = "../MandateFile/" + APPId + "/" + ID + "/" + croppedFileName;
                string MandateId = ID;

                if (File.Exists(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + MandateId + "/" + ConfigurationManager.AppSettings["DownloadFileName"].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + Convert.ToString(No) + ".tif")) && File.Exists(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + MandateId + "/" + ConfigurationManager.AppSettings["DownloadFileName"].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + Convert.ToString(No) + ".jpg")))
                {
                    croppedFileName = ConfigurationManager.AppSettings["DownloadFileName" + APPId].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg";
                    JPGFilepath     = "../MandateFile/" + APPId + "/" + ID + "/" + croppedFileName;
                    QuickCheck_AngularEntities dbcontext = new QuickCheck_AngularEntities();
                    List <GetLogo>             dataList1 = new List <GetLogo>();
                    var Result2 = dbcontext.MultipleResults("[dbo].[Sp_Mandate]").With <GetLogo>().Execute("@QueryType", "@TIPPath", "@PNGPath", "@MandateId", "@UserId", "UpdatePNGTIP",
                                                                                                           Convert.ToString(filePath), Convert.ToString(JPGFilepath), Convert.ToString(ID), Convert.ToString(UserId));
                    Flag.Flag      = "1";
                    Flag.FlagValue = "Mandate uploaded successfully";
                    common.Add(Flag);
                }
                else
                {
                    QuickCheck_AngularEntities dbcontext = new QuickCheck_AngularEntities();
                    List <GetLogo>             dataList1 = new List <GetLogo>();
                    var Result2 = dbcontext.MultipleResults("[dbo].[Sp_Mandate]").With <GetLogo>().Execute("@QueryType", "@TIPPath", "@PNGPath", "@MandateId", "@UserId", "UpdatePNGTIP",
                                                                                                           null, null, ID, UserId);
                    Flag.Flag      = "1";
                    Flag.FlagValue = "Image is not Properly Uploaded,Please Upload again";
                    common.Add(Flag);
                }
                // }
            }
            catch (Exception ex)
            {
                Flag.Flag      = "1";
                Flag.FlagValue = "Image is not Properly Uploaded,Please Upload again";
                common.Add(Flag);
            }


            return(common);
        }
Beispiel #2
0
        public IEnumerable <ResponseFlag> ViewCropImage(UploadMandateModel context)
        {
            List <ResponseFlag> common = new List <ResponseFlag>();
            ResponseFlag        Flag   = new ResponseFlag();
            string ID     = Convert.ToString(Dbsecurity.Decrypt(context.MdtID));
            string No     = Convert.ToString(Dbsecurity.Decrypt(context.RefrenceNo));
            string APPId  = Convert.ToString(Dbsecurity.Decrypt(context.AppID));
            string UserId = Convert.ToString(Dbsecurity.Decrypt(context.UserId));

            try
            {
                QuickCheck_AngularEntities dbcontext = new QuickCheck_AngularEntities();
                List <BindGrid>            dataList1 = new List <BindGrid>();
                var Result2 = dbcontext.MultipleResults("[dbo].[Sp_Mandate]").With <BindGrid>().Execute("@QueryType", "@MandateId", "@AppId", "EditMandate", ID, APPId);
                Flag.IsPrint = dataList1.Cast <BindGrid>().ToList().Select(x => x.IsPrint).First().ToString();
                Flag.IsScan  = dataList1.Cast <BindGrid>().ToList().Select(x => x.IsScan).First().ToString();
                Flag.Flag    = "1";
                common.Add(Flag);
            }
            catch (Exception ex) { throw ex; }
            return(common);
        }
 public IEnumerable <ResponseFlag> ViewCopscan([FromBody]  UploadMandateModel context)
 {
     return(ViewCropmandate.ViewCropImage(context));
 }
 public IEnumerable <ResponseFlag> GetA4Cropbase64([FromBody]  UploadMandateModel context)
 {
     return(Uploadmandate.GetA4CropImage(context));
 }
 public IEnumerable <ResponseFlag> CropUploadA4scan([FromBody]  UploadMandateModel context)
 {
     return(Uploadmandate.CropUploadA4Image(context));
 }
Beispiel #6
0
 public IEnumerable <ResponseFlag> FinaluploadCopscan([FromBody]  UploadMandateModel context)
 {
     return(ScanUploadmandate.FinalUploadCropImage(context));
 }
Beispiel #7
0
        public IEnumerable <ResponseFlag> UploadCropImage(UploadMandateModel context)
        {
            List <ResponseFlag> common = new List <ResponseFlag>();

            ResponseFlag Flag = new ResponseFlag();

            string UserId      = Dbsecurity.Decrypt(context.UserId);
            string ID          = Convert.ToString(Dbsecurity.Decrypt(context.MdtID));
            string No          = Convert.ToString(Dbsecurity.Decrypt(context.RefrenceNo));
            string APPId       = Convert.ToString(Dbsecurity.Decrypt(context.AppID));
            string extension   = string.Empty;
            string JPGFilepath = string.Empty;

            byte[] bytes = System.Convert.FromBase64String(context.ScannedImage);
            extension = context.Extention;
            if (extension == ".jpg" || extension == ".jpeg" || extension == ".png" || extension == ".gif" || extension == ".bmp")
            {
                string fileName1 = ConfigurationManager.AppSettings["DownloadFileName"].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg";
                if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/FullMandate/" + APPId + "/" + ID)))
                {
                    Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/FullMandate/" + APPId + "/" + ID));
                }
                System.IO.DirectoryInfo di = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/FullMandate/" + APPId + "/" + ID));
                foreach (FileInfo file in di.GetFiles())
                {
                    file.Delete();
                }
                string targetPath = HttpContext.Current.Server.MapPath("~/FullMandate/" + APPId + "/" + ID + @"\" + fileName1);
                using (System.Drawing.Image image = new Bitmap(new MemoryStream(bytes)))
                {
                    image.Save(targetPath, ImageFormat.Png);
                }
            }
            bool Flag1 = Directory.Exists(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + ID));

            if (!Flag1)
            {
                Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + ID));
            }
            else
            {
                System.IO.DirectoryInfo di = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + ID));
                foreach (FileInfo file in di.GetFiles())
                {
                    file.Delete();
                }
            }
            string croppedFileName = string.Empty;
            string croppedFilePath = string.Empty;

            string fileName = ConfigurationManager.AppSettings["DownloadFileName"].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg";
            string filePath = Path.Combine(HttpContext.Current.Server.MapPath("~/FullMandate/"), ConfigurationManager.AppSettings["DownloadFileName" + context.AppID].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg");

            if (File.Exists(filePath))
            {
                System.Drawing.Image orgImg     = System.Drawing.Image.FromFile(filePath);
                Rectangle            areaToCrop = new Rectangle(Convert.ToInt32(0),
                                                                Convert.ToInt32(0),
                                                                Convert.ToInt32(orgImg.Width),
                                                                Convert.ToInt32(orgImg.Height));

                if (orgImg.Width > orgImg.Height)
                {
                    Greater = true;
                }
                else
                {
                    Greater = false;
                }
                try
                {
                    Bitmap bitMap = new Bitmap(orgImg.Width, orgImg.Height, System.Drawing.Imaging.PixelFormat.Format16bppRgb555);
                    using (Graphics g = Graphics.FromImage(bitMap))
                    {
                        //Draw image to screen
                        g.DrawImage(orgImg, new Rectangle(0, 0, bitMap.Width, bitMap.Height), areaToCrop, GraphicsUnit.Pixel);
                        g.CompositingQuality = CompositingQuality.HighQuality;
                        g.SmoothingMode      = SmoothingMode.HighQuality;
                        g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    }

                    bitMap.SetResolution(96, 96);
                    croppedFileName = ConfigurationManager.AppSettings["DownloadFileName" + APPId].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg";
                    //Create path to store the cropped image
                    if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/CropImage/" + APPId + "/" + ID)))
                    {
                        Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/CropImage/" + APPId + "/" + ID));
                    }
                    croppedFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~/CropImage/" + APPId + "/" + ID), croppedFileName);
                    bitMap.Save(croppedFilePath);
                    var CropImagePath = Path.Combine(HttpContext.Current.Server.MapPath("~/CropImage/" + APPId + "/" + ID), ConfigurationManager.AppSettings["DownloadFileName" + APPId].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg");
                    System.Drawing.Image CropImage = System.Drawing.Image.FromFile(CropImagePath);
                    using (var image = CropImage)
                    {
                        int newWidth  = 0;
                        int newHeight = 0;
                        if (Greater == true)
                        {
                            newWidth  = 827;    // New Width of Image in Pixel
                            newHeight = 356;
                            //newWidth = 4000; // New Width of Image in Pixel
                            //newHeight = 1700;
                        }
                        else
                        {
                            newWidth  = 356;
                            newHeight = 827;
                            //newWidth = 1700;
                            //newHeight = 4000;
                        }

                        var thumbImg     = new Bitmap(newWidth, newHeight, System.Drawing.Imaging.PixelFormat.Format16bppRgb555);
                        var thumbGraph   = Graphics.FromImage(thumbImg);
                        var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);

                        thumbGraph.DrawImage(image, imgRectangle);
                        thumbImg.SetResolution(100, 100);

                        System.Drawing.Bitmap b0 = CopyToBpp(thumbImg, 8);
                        b0.SetResolution(100, 100);
                        JPGFilepath     = "../MandateFile/" + APPId + "/" + ID + "/" + croppedFileName;
                        croppedFileName = ConfigurationManager.AppSettings["DownloadFileName"].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg";
                        croppedFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~/CropImage/" + APPId + "/" + ID), croppedFileName);
                        ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Jpeg);
                        System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;
                        EncoderParameters myEncoderParameters    = new EncoderParameters(1);
                        EncoderParameter  myEncoderParameter     = new EncoderParameter(myEncoder, 50L);
                        myEncoderParameters.Param[0] = myEncoderParameter;
                        b0.Save(croppedFilePath, jpgEncoder, myEncoderParameters);
                    }
                    var CropImagePath1 = Path.Combine(HttpContext.Current.Server.MapPath("~/CropImage/" + APPId + "/" + ID), ConfigurationManager.AppSettings["DownloadFileName" + APPId].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg");
                    System.Drawing.Image CropImage1 = System.Drawing.Image.FromFile(CropImagePath1);
                    bool result = true;
                    using (var image1 = CropImage1)
                    {
                        int newWidth  = 0;
                        int newHeight = 0;
                        if (Greater == true)
                        {
                            newWidth  = CropImage1.Width;
                            newHeight = CropImage1.Height;
                            //newWidth = 2800;
                            //newHeight = 1200;
                        }
                        else
                        {
                            newWidth  = CropImage1.Width;
                            newHeight = CropImage1.Height;
                            //newWidth = 1200;
                            //newHeight = 2800;
                        }
                        var thumbImg1     = new Bitmap(newWidth, newHeight);
                        var thumbGraph1   = Graphics.FromImage(thumbImg1);
                        var imgRectangle1 = new Rectangle(0, 0, newWidth, newHeight);
                        thumbGraph1.DrawImage(image1, imgRectangle1);
                        System.Drawing.Bitmap b1 = CopyToBpp(thumbImg1, 1);
                        b1.SetResolution(200, 200);
                        croppedFileName = ConfigurationManager.AppSettings["DownloadFileName"].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg";
                        croppedFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~/CropImage/" + APPId + "/" + ID), croppedFileName);

                        ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Tiff);
                        System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Compression;
                        EncoderParameters myEncoderParameters    = new EncoderParameters(1);
                        EncoderParameter  myEncoderParameter     = new EncoderParameter(myEncoder,
                                                                                        (long)EncoderValue.CompressionCCITT4);
                        myEncoderParameters.Param[0] = myEncoderParameter;
                        b1.Save(croppedFilePath, jpgEncoder, myEncoderParameters);
                        List <Checklogo> dataList = new List <Checklogo>();
                        var Result2 = dbcontext.MultipleResults("[dbo].[Sp_Mandate]").With <Checklogo>().Execute("@QueryType", "@MandateId", "CheckLogo", ID);
                        dataList = Result2.FirstOrDefault().Cast <Checklogo>().ToList();
                        string isQR = dataList.Cast <Checklogo>().ToList().Select(x => x.PrintQR).First().ToString();
                        if (isQR == "True")
                        {
                            result = (Convert.ToString(ID + "_" + No) == GetMandatefromQR(croppedFilePath, ID)) ? true : false;
                        }
                    }
                    orgImg.Dispose();
                    bitMap = null;
                    if (File.Exists(CropImagePath1))
                    {
                        File.Delete(CropImagePath1);
                    }
                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }
                    if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/FullMandate/" + APPId + "/" + ID)))
                    {
                        Directory.Delete(HttpContext.Current.Server.MapPath("~/FullMandate/" + APPId + "/" + ID));
                    }
                    if (Directory.Exists(HttpContext.Current.Server.MapPath("~/CropImage/" + APPId + "/" + ID)))
                    {
                        Directory.Delete(HttpContext.Current.Server.MapPath("~/CropImage/" + APPId + "/" + ID));
                    }
                    if (result)
                    {
                        Flag.Flag      = "1";
                        Flag.FlagValue = "Image cropped and saved successfully";
                        string Fullmandatepath = Path.Combine(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + ID), ConfigurationManager.AppSettings["DownloadFileName"].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg");
                        Flag.Base64image = base64image.ConvertImageBase64(Fullmandatepath);
                        common.Add(Flag);
                        QuickCheck_AngularEntities dbcontext = new QuickCheck_AngularEntities();
                        List <GetLogo>             dataList1 = new List <GetLogo>();
                        var Result2 = dbcontext.MultipleResults("[dbo].[Sp_Mandate]").With <GetLogo>().Execute("@QueryType", "@TIPPath", "@PNGPath", "@MandateId", "@UserId", "UpdatePNGTIP",
                                                                                                               Convert.ToString(filePath), Convert.ToString(JPGFilepath), Convert.ToString(ID), UserId);
                    }
                    else
                    {
                        Flag.Flag      = "0";
                        Flag.FlagValue = "Invalid Mandate. Please Re-Upload Valid Mandate";
                        common.Add(Flag);

                        if (File.Exists(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + ID + "/" + ConfigurationManager.AppSettings["DownloadFileName"].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".tif")))
                        {
                            File.Delete(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + ID + "/" + ConfigurationManager.AppSettings["DownloadFileName"].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".tif"));
                        }

                        if (File.Exists(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + ID + "/" + ConfigurationManager.AppSettings["DownloadFileName"].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg")))
                        {
                            File.Delete(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + ID + "/" + ConfigurationManager.AppSettings["DownloadFileName"].ToString() + "_" + DateTime.Now.ToString("ddMMyyyy") + "_" + No + ".jpg"));
                        }

                        List <GetLogo>             dataList1 = new List <GetLogo>();
                        QuickCheck_AngularEntities dbcontext = new QuickCheck_AngularEntities();
                        var Result2 = dbcontext.MultipleResults("[dbo].[Sp_Mandate]").With <GetLogo>().Execute("@QueryType", "@TIPPath", "@PNGPath", "@MandateId", "@UserId", "UpdatePNGTIP",
                                                                                                               null, null, ID, UserId);
                        if (Directory.Exists(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + ID)))
                        {
                            Directory.Delete(HttpContext.Current.Server.MapPath("~/MandateFile/" + APPId + "/" + ID));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Flag.Flag      = "0";
                    Flag.FlagValue = "Oops!! error occured : " + ex.Message.ToString();
                    common.Add(Flag);
                }
                finally
                {
                    fileName        = string.Empty;
                    filePath        = string.Empty;
                    croppedFileName = string.Empty;
                    croppedFilePath = string.Empty;
                }
            }
            return(common);
        }