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.
 
 
 
 
 

131 lines
5.8 KiB

using Swift.DAL.OnlineAgent;
using Swift.web.Library;
using System;
using System.IO;
using System.Text;
namespace Swift.web.Remit.Administration.CustomerRegistration
{
public partial class DocumentView : System.Web.UI.Page
{
private const string ViewFunctionId = "20208000";
private const string ViewDocFunctionId = "20208020";
private const string ViewFunctionIdAgent = "";
private const string ViewDocFunctionIdAgent = "";
private readonly RemittanceLibrary _sl = new RemittanceLibrary();
private readonly OnlineCustomerDao _oC = new OnlineCustomerDao();
protected void Page_Load(object sender, EventArgs e)
{
//Authenticate();
_sl.CheckSession();
if (!IsPostBack)
{
msg.Visible = false;
string cdId = GetStatic.ReadQueryString("cdId", "");
string fileType = GetStatic.ReadQueryString("fileType", "");
string fileDescription = GetStatic.ReadQueryString("fileDescription", "");
var result = _oC.GetCustomerDocumentByDocumentId(cdId, GetStatic.GetUser(), fileDescription);
if (result != null)
{
if (result["fileName"].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;
string imageUrl = "/Handler/CustomerSignature.ashx?fileDesc="+ result["filedescription"].ToString() + "&registerDate=" + Convert.ToDateTime(registerDate).ToString("yyyy-MM-dd") + "&customerId=" + customerId + "&membershipNo=" + membershipId + "&fileName=" + fileName + "&fileDescription=" + fileDescription ;
if (GetFileType() == "application/pdf")
{
pdfDiv.Src = imageUrl;//GetStatic.GetCustomerFilePath() + "CustomerDocument\\" + Convert.ToDateTime(registerDate).ToString("yyyy-MM-dd").Replace("-", "\\") + "\\" + membershipId + "\\" + fileName; ;
pdfDiv.Visible = true;
imageDiv.Visible = false;
}
else if (GetFileType() == "letter" || GetFileType() == "receiver")
{
pdfDiv.Src = imageUrl;//GetStatic.GetCustomerFilePath() + "CustomerDocument\\" + Convert.ToDateTime(registerDate).ToString("yyyy-MM-dd").Replace("-", "\\") + "\\" + membershipId + "\\" + fileName; ;
pdfDiv.Visible = true;
imageDiv.Visible = false;
}
else
{
fileDisplay.ImageUrl = imageUrl;
pdfDiv.Visible = false;
imageDiv.Visible = true;
}
}
if (fileType == "image")
{
downloadFile.Visible = false;
}
else
{
downloadFile.Visible = true;
}
return;
//}
}
msg.InnerText = "File Not Found";
msg.Visible = true;
}
}
private void Authenticate()
{
_sl.CheckAuthentication(GetFunctionIdByUserType(ViewFunctionIdAgent, ViewFunctionId) + "," + GetFunctionIdByUserType(ViewDocFunctionIdAgent, ViewDocFunctionId));
}
public string GetFunctionIdByUserType(string functionIdAgent, string functionIdAdmin)
{
return (GetStatic.GetUserType() == "HO") ? functionIdAdmin : functionIdAgent;
}
protected void downloadFile_Click(object sender, EventArgs e)
{
try
{
string filePath = GetStatic.GetCustomerFilePath() + "CustomerDocument\\" + Convert.ToDateTime(hdnRegDate.Value).ToString("yyyy-MM-dd").Replace("-", "\\") + "\\" + hdnMembershipId.Value + "\\" + hdnFileName.Value;
var imageName = hdnFileName.Value;
//var registrationData = imageName.Split('_')[5].Split('.')[0].ToString() + "\\";
//registrationData = registrationData.Replace("-", "\\");
var path = filePath;
if (!File.Exists(path))
{
msgDiv.Visible = true;
msgLabel.Text = "File Not Found";
Page_Load(sender, e);
return;
}
FileInfo ObjArchivo = new FileInfo(path);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + hdnFileName.Value);
Response.AddHeader("Content-Length", ObjArchivo.Length.ToString());
Response.ContentType = hdnFileType.Value;
Response.WriteFile(ObjArchivo.FullName);
Response.End();
}
catch (Exception ex)
{
throw ex;
}
}
public string GetFileType()
{
return GetStatic.ReadQueryString("fileType", "");
}
}
}