You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
314 lines
13 KiB
314 lines
13 KiB
using Swift.DAL.BL.System.Utility;
|
|
using Swift.DAL.OnlineAgent;
|
|
using Swift.DAL.SwiftDAL;
|
|
using Swift.web.Library;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace Swift.web.MobileRemit.Admin.Operation.RenewID
|
|
{
|
|
public partial class DocumentManage : System.Web.UI.Page
|
|
{
|
|
private readonly RemittanceLibrary _sl = new RemittanceLibrary();
|
|
private readonly OnlineCustomerDao _oC = new OnlineCustomerDao();
|
|
private const string ViewFunctionId = "41901000";
|
|
private const string DeleteFunctionId = "41901020";
|
|
private const string ProcessFunctionId = "41901010";
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
Authenticate();
|
|
if (!IsPostBack)
|
|
{
|
|
msg.Visible = false;
|
|
string cdId = GetStatic.ReadQueryString("cdId", "");
|
|
string fileType = GetStatic.ReadQueryString("fileType", "");
|
|
|
|
var result = _oC.GetCustomerDocumentByDocumentIdTmp(cdId, GetStatic.GetUser());
|
|
|
|
if (result != null)
|
|
{
|
|
if (result["fileName"].ToString() != "")
|
|
{
|
|
lblName.Text = result["fullName"].ToString() + " / " + result["memberShipId"].ToString();
|
|
lblUsername.Text = result["username"].ToString();
|
|
lblIdType.Text = result["idType"].ToString();
|
|
lblIdIssuedExpiryDate.Text = result["idDetailDate"].ToString();
|
|
lblIdNumber.Text = result["idNumber"].ToString();
|
|
|
|
var registerDate = result["createdDate"].ToString();
|
|
hdnRegDate.Value = registerDate;
|
|
var customerId = result["customerId"].ToString();
|
|
hdncustomerId.Value = customerId;
|
|
var membershipId = result["membershipId"].ToString();
|
|
hdnMembershipId.Value = membershipId;
|
|
var fileName = result["fileName"].ToString();
|
|
hdnFileName.Value = fileName;
|
|
var createdBy = result["createdBy"].ToString();
|
|
hdnCreatedBy.Value = createdBy;
|
|
var isMoved = result["isMoved"].ToString();
|
|
string imageUrl = "/Handler/CustomerSignature.ashx?showType=Y®isterDate=" + Convert.ToDateTime(registerDate).ToString("yyyy-MM-dd") + "&customerId=" + customerId + "&membershipNo=" + membershipId + "&fileName=" + fileName + "&isMoved=" + isMoved;
|
|
|
|
fileDisplay.ImageUrl = imageUrl;
|
|
pdfDiv.Visible = false;
|
|
}
|
|
return;
|
|
//}
|
|
}
|
|
msg.InnerText = "File Not Found";
|
|
msg.Visible = true;
|
|
}
|
|
}
|
|
|
|
private void Authenticate()
|
|
{
|
|
_sl.CheckAuthentication(ViewFunctionId);
|
|
btnProcesssFile.Enabled = true;
|
|
if (!_sl.HasRight(ProcessFunctionId))
|
|
{
|
|
btnProcesssFile.Enabled = false;
|
|
}
|
|
}
|
|
|
|
public string GetFileType()
|
|
{
|
|
return GetStatic.ReadQueryString("fileType", "");
|
|
}
|
|
|
|
protected void processsFile_Click(object sender, EventArgs e)
|
|
{
|
|
if (!_sl.HasRight(ProcessFunctionId))
|
|
{
|
|
GetStatic.AlertMessage(this, "You do not have permission to process document!");
|
|
return;
|
|
}
|
|
var id = GetStatic.ReadQueryString("cdId", "");
|
|
DataRow docDetais = _oC.GetCustomerDocPathData(id, "doc-path-tmp", GetStatic.GetUser());
|
|
if (docDetais == null)
|
|
{
|
|
GetStatic.AlertMessage(this, "Invalid document, no customer data found!");
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
|
|
#region CROP
|
|
//string root = ConfigurationManager.AppSettings["filePath"];
|
|
//var saveFileLocation = root + "\\doc\\tmp\\";
|
|
//if (!Directory.Exists(saveFileLocation))
|
|
// Directory.CreateDirectory(saveFileLocation);
|
|
|
|
//var x = Convert.ToInt32(_xField.Value);
|
|
//var y = Convert.ToInt32(_yField.Value);
|
|
//var width = Convert.ToInt32(_widthField.Value);
|
|
//var height = Convert.ToInt32(_heightField.Value);
|
|
|
|
|
|
|
|
//using (var photo = System.Drawing.Image.FromFile(imgloc + docDetais["fileName"].ToString()))
|
|
//using (var result = new Bitmap(width, height, photo.PixelFormat))
|
|
//{
|
|
// result.SetResolution(
|
|
// photo.HorizontalResolution,
|
|
// photo.VerticalResolution);
|
|
|
|
// using (var g = Graphics.FromImage(result))
|
|
// {
|
|
// g.InterpolationMode =
|
|
// InterpolationMode.HighQualityBicubic;
|
|
// g.DrawImage(photo,
|
|
// new Rectangle(0, 0, width, height),
|
|
// new Rectangle(x, y, width, height),
|
|
// GraphicsUnit.Pixel);
|
|
// photo.Dispose();
|
|
|
|
// bool folderExists = Directory.Exists(imgloc + "deleted\\");
|
|
// if (!folderExists)
|
|
// Directory.CreateDirectory(imgloc + "deleted\\");
|
|
|
|
// String filename_initial = imgloc + "deleted\\" + docDetais["fileName"].ToString();
|
|
// String filename_current = filename_initial;
|
|
// var count = 0;
|
|
// while (File.Exists(filename_current))
|
|
// {
|
|
// count++;
|
|
// filename_current = Path.GetDirectoryName(filename_initial)
|
|
// + Path.DirectorySeparatorChar
|
|
// + Path.GetFileNameWithoutExtension(filename_initial)
|
|
// + count.ToString()
|
|
// + Path.GetExtension(filename_initial);
|
|
// }
|
|
|
|
// File.Move(imgloc + hdnFileName.Value, filename_current);
|
|
|
|
// var original_imagePath = root + "\\doc\\tmp\\" + id + "_org_" + hdnFileName.Value;
|
|
// string saved_file_name = imgloc + hdnFileName.Value;
|
|
|
|
// result.Save(original_imagePath);
|
|
// CompressImageDao ci = new CompressImageDao();
|
|
|
|
// System.IO.FileInfo fi = new System.IO.FileInfo(original_imagePath);
|
|
// if (!ci.CompressImageAndSave((fi.Length / 1024), original_imagePath, saved_file_name))
|
|
// {
|
|
// result.Save(imgloc + hdnFileName.Value);
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
Exception ex = null;
|
|
if (MoveDocument(docDetais, out ex))
|
|
{
|
|
DbResult dbResult = _oC.MoveCustomerDocumentnew(id, GetStatic.GetUser());
|
|
if (dbResult.ErrorCode == "0")
|
|
{
|
|
|
|
GetStatic.SetMessage(dbResult);
|
|
string filePath = docDetais["docPath"].ToString();
|
|
string fileName = docDetais["fileName"].ToString();
|
|
|
|
string targetPath = GetStatic.GetCustomerFilePath() + "CustomerDocument\\" + filePath.Split('|')[2].Replace("-", "\\") + "\\" + filePath.Split('|')[1] + "\\Renew";
|
|
string destFilepath = Path.Combine(targetPath, fileName);
|
|
|
|
GetStatic.CallJSFunction(this, "AfterSave('" + dbResult.Msg + "')");
|
|
DownloadFM(fileName, destFilepath);
|
|
|
|
return;
|
|
|
|
|
|
// Response.Write("<script>window.close();</script>");
|
|
// GetStatic.AlertMessage(this, dbResult.Msg);
|
|
// Response.Redirect("/MobileRemit/Agent/RenewID/Manage.aspx");
|
|
}
|
|
else
|
|
{
|
|
HttpContext.Current.Session["message"] = dbResult;
|
|
GetStatic.AlertMessage(this, dbResult.Msg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
var errorid = GetStatic.LogError(ex).Id;
|
|
GetStatic.AlertMessage(this, "Exception occured while moving Doc: error " + errorid);
|
|
}
|
|
}
|
|
|
|
private void DownloadFM(string filename, string path)
|
|
{
|
|
try
|
|
{
|
|
var photo = System.Drawing.Image.FromFile(path);
|
|
|
|
ImageConverter _imageConverter = new ImageConverter();
|
|
byte[] bytes = (byte[])_imageConverter.ConvertTo(photo, typeof(byte[]));
|
|
|
|
Response.Clear();
|
|
Response.ClearContent();
|
|
Response.ClearHeaders();
|
|
|
|
string contentDisposition;
|
|
if (Request.Browser.Browser == "IE")
|
|
contentDisposition = "attachment; filename=" + Uri.EscapeDataString(filename);
|
|
else
|
|
{
|
|
contentDisposition = "attachment; filename*=UTF-8''" + Uri.EscapeDataString(filename);
|
|
}
|
|
Response.AddHeader("Content-Disposition", contentDisposition);
|
|
Response.AddHeader("Content-Length", bytes.Length.ToString());
|
|
Response.AddHeader("X-Download-Options", "noopen");
|
|
Response.ContentType = "application/octet-stream";
|
|
Response.OutputStream.Write(bytes, 0, bytes.Length);
|
|
|
|
|
|
Response.Flush();
|
|
Response.End();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var errorid = GetStatic.LogError(ex).Id;
|
|
GetStatic.AlertMessage(this, "Exception occured while downloading : errorId " + errorid);
|
|
|
|
}
|
|
}
|
|
|
|
private bool MoveDocument(DataRow docDetais, out Exception exception)
|
|
{
|
|
try
|
|
{
|
|
string filePath = docDetais["docPath"].ToString();
|
|
string fileName = docDetais["fileName"].ToString();
|
|
string sourcePath = GetStatic.GetCustomerFilePath() + "CustomerDocument\\VerifyDocumentUpload\\";
|
|
string targetPath = GetStatic.GetCustomerFilePath() + "CustomerDocument\\" + filePath.Split('|')[2].Replace("-", "\\") + "\\" + filePath.Split('|')[1]+ "\\Renew";
|
|
|
|
string sourceFile = Path.Combine(sourcePath, fileName);
|
|
string destFile = Path.Combine(targetPath, fileName);
|
|
|
|
if (!Directory.Exists(targetPath))
|
|
{
|
|
Directory.CreateDirectory(targetPath);
|
|
}
|
|
|
|
|
|
String filename_current = destFile;
|
|
var count = 0;
|
|
while (File.Exists(filename_current))
|
|
{
|
|
count++;
|
|
filename_current = Path.GetDirectoryName(destFile)
|
|
+ Path.DirectorySeparatorChar
|
|
+ Path.GetFileNameWithoutExtension(destFile)
|
|
+ count.ToString()
|
|
+ Path.GetExtension(destFile);
|
|
}
|
|
|
|
File.Move(sourceFile, filename_current);
|
|
|
|
exception = null;
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
exception = ex;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
protected void btnRotate_Click(object sender, EventArgs e)
|
|
{
|
|
string root = ConfigurationManager.AppSettings["filePath"];
|
|
var saveFileLocation = root + "\\doc\\tmp\\";
|
|
if (!Directory.Exists(saveFileLocation))
|
|
Directory.CreateDirectory(saveFileLocation);
|
|
|
|
var imgloc = GetStatic.GetCustomerFilePath() + "CustomerDocument\\VerifyDocumentUpload\\";
|
|
|
|
string path = imgloc + hdnFileName.Value;
|
|
|
|
using (System.Drawing.Image image = System.Drawing.Image.FromFile(path))
|
|
{
|
|
var rawFormat = image.RawFormat;
|
|
image.RotateFlip(RotateFlipType.Rotate90FlipNone);
|
|
image.Save(path, rawFormat);
|
|
}
|
|
}
|
|
}
|
|
}
|