public LiveChequePath UpdateLiveChequePath(LiveChequePath liveChequePath) { int rowsAffected = this._db.Execute("LiveChequePaths_Update", new { Id = liveChequePath.Id, BankId = liveChequePath.BankId, ChequeId = liveChequePath.ChequeId, NumericalAmountCroppedImagePath = liveChequePath.NumericalAmountCroppedImagePath, AmountCroppedImagePath = liveChequePath.AmountCroppedImagePath, DateCroppedImagePath = liveChequePath.DateCroppedImagePath, MICRCroppedImagePath = liveChequePath.MICRCroppedImagePath, PayeeCroppedImagePath = liveChequePath.PayeeCroppedImagePath, SignatureCroppedImagePath = liveChequePath.SignatureCroppedImagePath, LiveChequeImageFrontPath = liveChequePath.LiveChequeImageFrontPath, LiveChequeImageBackPath = liveChequePath.LiveChequeImageBackPath }, commandType: CommandType.StoredProcedure); if (rowsAffected > 0) { return(liveChequePath); } return(liveChequePath); }
public User Post([FromBody] LiveChequePath liveChequePath) { User detectedUser = new User(); MICRProcess micr = new MICRProcess(); string AccountNumber = ""; try { AccountNumber = micr.GetAccountNumber(liveChequePath.MICRCroppedImagePath).Substring(0, 10); //test purpose //string fakeaccountNo = "1500045100"; //AccountNumber = fakeaccountNo; detectedUser = _userRepository.GetUserByAccountNumber(AccountNumber); DateProcess dateVal = new DateProcess(); string detDate = dateVal.CheckDate(liveChequePath.DateCroppedImagePath); detectedUser.DetectedDate = detDate.Remove(detDate.Length - 2); return(detectedUser); } catch (Exception e) { User detectedUser1 = new User(); detectedUser1.Path = AccountNumber; detectedUser1.Id = 0; return(detectedUser1); } }
public LiveChequePath ProcessImages(FileInfo[] files, LiveChequePath liveChequePath) { var comparableImages = new List <ComparableImage>(); var tempath = Path.GetTempFileName(); File.Delete(tempath); Directory.CreateDirectory(tempath); var tempFiles = new FileInfo[files.Length]; for (int i = 0; i < files.Length; i++) { var file = files[i]; var nfilename = tempath + "\\" + Path.GetFileName(file.FullName); File.Copy(file.FullName, nfilename); tempFiles[i] = new FileInfo(nfilename); } foreach (var file in tempFiles) { var comparableImage = new ComparableImage(file); comparableImages.Add(comparableImage); } var similarityImagesSorted = new List <SimilarityImages>(); for (var j = 1; j < comparableImages.Count; j++) { var source = comparableImages[0]; var destination = comparableImages[j]; var similarity = source.CalculateSimilarity(destination); var sim = new SimilarityImages(source, destination, similarity); similarityImagesSorted.Add(sim); } similarityImagesSorted.Sort(); similarityImagesSorted.Reverse(); if (similarityImagesSorted[0].Similarity >= 80) { string selectedCheque = similarityImagesSorted[0].Destination.ToString(); Cheque selectedChequeData = _chequeRepository.GetChequeDataByChequePath(selectedCheque); liveChequePath.ChequeId = selectedChequeData.Id; liveChequePath.BankId = selectedChequeData.BankId; return(liveChequePath); } else { System.Console.Write("No Matching Cheque in DB"); return(liveChequePath); } }
public LiveChequePath ChequeDetection(string liveChequePath1) { DirectoryInfo firstfile = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ChequeImageData/ArchievedCheques/")); FileInfo[] garbagefiles = firstfile.GetFiles("1*"); if (garbagefiles.Count() != 0) { File.Delete(HttpContext.Current.Server.MapPath(@"~/ChequeImageData/ArchievedCheques/") + garbagefiles[0]); } //mycode var directory = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/LiveChequeImageData/")); var myFile = (from f in directory.GetFiles() orderby f.LastWriteTime descending select f).First(); string deleteLiveChequePath = myFile.ToString(); var appDataPath = HttpContext.Current.Server.MapPath(@"~/ChequeImageData/ArchievedCheques/"); myFile.CopyTo(appDataPath + myFile, true); var path = HttpContext.Current.Server.MapPath("~/LiveChequeImageData/"); File.Delete(path + deleteLiveChequePath); FileInfo[] files; DirectoryInfo directoryInfo; directoryInfo = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ChequeImageData/ArchievedCheques/")); files = directoryInfo.GetFiles("*.jpg"); ChequeProcess chequeProcess = new ChequeProcess(); LiveChequePath liveChequePath = new LiveChequePath(); liveChequePath.LiveChequeImageFrontPath = liveChequePath1; return(chequeProcess.ProcessImages(files, liveChequePath)); }
public LiveChequePath Post([FromBody] LiveChequePath liveChequePath) { Dictionary <string, string> pathList = new Dictionary <string, string>(); CropPointsController loadCropPoints = new CropPointsController(); CropPoint cropPointData = new CropPoint(); LiveChequeCrop liveChequeCrop = new LiveChequeCrop(); cropPointData.BankId = liveChequePath.BankId; cropPointData.ChequeId = liveChequePath.ChequeId; foreach (var CropId in CropTypeFactory.CropTypes) { cropPointData.CropType = CropId; CropPoint CropPoints = loadCropPoints.GetByCropType(cropPointData); if (CropPoints == null) { return(liveChequePath); } pathList.Add(cropPointData.CropType.ToString(), liveChequeCrop.SaveCroppedImage(liveChequePath.LiveChequeImageFrontPath, CropId, CropPoints)); switch (CropId) { case CropType.NumericalAmount: liveChequePath.NumericalAmountCroppedImagePath = pathList["NumericalAmount"]; break; case CropType.Amount: liveChequePath.AmountCroppedImagePath = pathList["Amount"]; break; case CropType.Date: liveChequePath.DateCroppedImagePath = pathList["Date"]; break; case CropType.MICR: liveChequePath.MICRCroppedImagePath = pathList["MICR"]; break; case CropType.Payee: liveChequePath.PayeeCroppedImagePath = pathList["Payee"]; break; case CropType.Signature: liveChequePath.SignatureCroppedImagePath = pathList["Signature"]; break; } } //DirectoryInfo firstfile = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ChequeImageData/ArchievedCheques/")); //FileInfo[] garbagefiles = firstfile.GetFiles("1*"); //if (garbagefiles.Count() != 0) //{ // File.Delete(HttpContext.Current.Server.MapPath(@"~/ChequeImageData/ArchievedCheques/") + garbagefiles[0]); //} //var directory = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ChequeImageData/ArchievedCheques/")); //var myFile = (from f in directory.GetFiles() // orderby f.LastWriteTime descending // select f).Last(); //var path = HttpContext.Current.Server.MapPath("~/ChequeImageData/ArchievedCheques/"); //File.Delete(path + myFile.ToString()); return(_liveChequePathRepository.InsertLiveChequePath(liveChequePath)); }
public LiveChequePath Put([FromBody] LiveChequePath liveChequePath) { return(_liveChequePathRepository.UpdateLiveChequePath(liveChequePath)); }