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.

85 lines
3.7 KiB

  1. using Swift.DAL.OnlineAgent;
  2. using Swift.web.Library;
  3. using System;
  4. using System.IO;
  5. namespace Swift.web.Remit.Administration.CustomerSetup
  6. {
  7. public partial class DocumentView : System.Web.UI.Page
  8. {
  9. private const string ViewFunctionId = "20111300";
  10. private const string ViewFunctionIdAgent = "40120000";
  11. private const string ViewDocFunctionId = "20111330";
  12. private const string ViewDocFunctionIdAgent = "40120030";
  13. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  14. private readonly OnlineCustomerDao _oC = new OnlineCustomerDao();
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. _sl.CheckSession();
  18. if (!IsPostBack)
  19. {
  20. msg.Visible = false;
  21. string cdId = GetStatic.ReadQueryString("cdId", "");
  22. var result = _oC.GetCustomerDocumentByDocumentId(cdId, GetStatic.GetUser());
  23. if (result != null)
  24. {
  25. hdnDocumentTypeId.Value = result["cdId"].ToString();
  26. hdnMembershipId.Value = result["membershipId"].ToString();
  27. hdnFileName.Value = result["fileName"].ToString();
  28. //var filePath = GetStatic.GetFilePath() + "CustomerDocument\\" + result["customerId"] + "\\" + result["fileName"] + "";
  29. //if (File.Exists(filePath))
  30. //{
  31. //Response.ContentType = result["fileType"].ToString();
  32. //Response.WriteFile(filePath);
  33. if (result["fileName"].ToString() != "")
  34. fileDisplay.ImageUrl = "../../../AgentPanel/OnlineAgent/CustomerSetup/GetFileView.ashx?imageName=" + result["fileName"] + "&customerId=" + result["membershipId"] + "&fileType=" + result["fileType"].ToString();
  35. downloadFile.Visible = true;
  36. return;
  37. //}
  38. }
  39. msg.InnerText = "File Not Found";
  40. msg.Visible = true;
  41. }
  42. }
  43. private void Authenticate()
  44. {
  45. _sl.CheckAuthentication(GetFunctionIdByUserType(ViewFunctionIdAgent, ViewFunctionId) + "," + GetFunctionIdByUserType(ViewDocFunctionIdAgent, ViewDocFunctionId));
  46. }
  47. public string GetFunctionIdByUserType(string functionIdAgent, string functionIdAdmin)
  48. {
  49. return (GetStatic.GetUserType() == "HO") ? functionIdAdmin : functionIdAgent;
  50. }
  51. protected void downloadFile_Click(object sender, EventArgs e)
  52. {
  53. try
  54. {
  55. var imageName = hdnFileName.Value;
  56. var dirLocation = imageName.Split('_')[3].ToString() + "\\" + imageName.Split('_')[4].ToString() + "\\" + imageName.Split('_')[5].Split('.')[0].ToString() + "\\";
  57. var path = GetStatic.GetCustomerFilePath() + "CustomerDocument\\" + dirLocation + hdnMembershipId.Value + "\\" + imageName;
  58. if (!File.Exists(path))
  59. {
  60. msgDiv.Visible = true;
  61. msgLabel.Text = "File Not Found";
  62. Page_Load(sender, e);
  63. return;
  64. }
  65. FileInfo ObjArchivo = new FileInfo(path);
  66. Response.Clear();
  67. Response.AddHeader("Content-Disposition", "attachment; filename=" + hdnFileName.Value);
  68. Response.AddHeader("Content-Length", ObjArchivo.Length.ToString());
  69. Response.ContentType = hdnFileType.Value;
  70. Response.WriteFile(ObjArchivo.FullName);
  71. Response.End();
  72. }
  73. catch (Exception ex)
  74. {
  75. throw ex;
  76. }
  77. }
  78. }
  79. }