protected void Page_Load(object sender, EventArgs e) { string totalpath = ""; B_upload = new BuisnessUploads(); if (Request.QueryString["UploadedFrom"] != null && Request.QueryString["UploadedFrom"].ToString() == "OrganizationRequests") { ShareFolderPath = ConfigurationManager.AppSettings["ORDocumentsShareFolderPath"].ToString(); } if (Request.QueryString["Documentid"] != null) { try { // Read the file and convert it to Byte Array string filePath = ShareFolderPath; string profilename = Session["profileName"].ToString(); string filename = ""; // string red = System.Web.HttpUtility.UrlDecode(Request.QueryString["Documentid"].ToString()); // string filenameid = Request.QueryString["Documentid"].ToString().Replace("'", string.Empty).Replace(" ","+"); string Documentid = Decrypt(Request.QueryString["Documentid"].ToString()); SqlParameter[] commandParameters = new SqlParameter[4]; commandParameters[0] = new SqlParameter(); commandParameters[0].ParameterName = "@Id"; commandParameters[0].Value = Documentid; commandParameters[0].SqlDbType = SqlDbType.Int; commandParameters[1] = new SqlParameter(); commandParameters[1].ParameterName = "@TablePrimaryKey"; commandParameters[1].Value = B_upload.GetPrimaryKey(profilename, strConnString); commandParameters[2] = new SqlParameter(); commandParameters[2].ParameterName = "@ProfileName"; commandParameters[2].Value = profilename; commandParameters[3] = new SqlParameter(); commandParameters[3].ParameterName = "@declarationid"; commandParameters[3].Value = Convert.ToInt32(Session["DeclarationId"]); commandParameters[3].SqlDbType = SqlDbType.Int; ds = B_upload.GetTokenvalue(strConnString, "Sp_DwonloadFile", commandParameters); if (ds.Tables[0].Rows.Count > 0) { filename = ds.Tables[0].Rows[0]["NewFileName"].ToString(); } filename = filename.Replace("//", "\\"); string contenttype = ""; if (filename.ToLower().EndsWith("pdf")) { contenttype = "application/pdf"; } else // in prod // contenttype = "image/" + Path.GetExtension(filename.Replace(".", "")); if (filename.ToLower().EndsWith("jpeg") || filename.ToLower().EndsWith("jpg")) { contenttype = "image/jpeg" + Path.GetExtension(filename.Replace(".", ""));// Request.QueryString["FileName"].ToString().Split('.')[Request.QueryString["FileName"].ToString().Split('.').Length - 1];//+ Path.GetExtension(Request.QueryString["FileName"].Replace(".", "")); } else { contenttype = "image/png" + Path.GetExtension(filename.Replace(".", ""));// Request.QueryString["FileName"].ToString().Split('.')[Request.QueryString["FileName"].ToString().Split('.').Length - 1];//+ Path.GetExtension(Request.QueryString["FileName"].Replace(".", "")); } // image/png setConfigValues(); iU.Impersonate(sSLD, sSLUN, sPwd); filePath = ShareFolderPath; // filePath = @"\\10.10.65.3\kgac_upload_dd_test"; totalpath = Path.Combine(filePath, filename); FileStream fs = new FileStream(Path.Combine(filePath, filename), FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); Byte[] bytes = br.ReadBytes((Int32)fs.Length); br.Close(); fs.Close(); iU.Undo(); //Write the file to response Stream Response.Buffer = false; Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = contenttype; Response.AddHeader("content-disposition", "inline;filename=" + filename); Response.BinaryWrite(bytes); Response.Flush(); // Response.End(); B_upload = null; } catch (Exception ex) { // WriteToLogFile(ex ,"From RenderFile'"+ totalpath+"'"); // Response.Redirect("DocumentError.aspx"); Elog = new ErrorLogger(); Elog.WriteToLogFile(ex, "public Page_Load In renderFile Profile name '" + Session["profileName"].ToString() + "'and hidprofile'" + Session["hidrefprofile"].ToString() + "'", "tokenValue = '" + Session["mytokenvalue"].ToString() + "' and sessionID = '" + Session["mysessionId"].ToString() + "' "); Elog = null; Response.Redirect("DocumentRenderError.aspx"); } } }
protected override void InitializeCulture() { Elog = new ErrorLogger(); // to be enabled for security testing /* Uri myReferrer = Request.UrlReferrer; * if (myReferrer == null) * { * * Response.Redirect("DocumentError.aspx"); * * } */ B_upload = new BuisnessUploads(); referredUrl = Request.RawUrl.ToString(); Elog.WriteToLogFile("The First Request From Documents Gallery For Url Verification ", "the requested Raw Url'" + referredUrl + "' "); Session["referredUrl"] = referredUrl.TrimStart('/').ToString(); tokenvalue = Request.QueryString["tokenvalue"]; EncodedToken = tokenvalue; if (tokenvalue != null) { { try { DcryptString = B_upload.DecryptToken(tokenvalue); queryParamArray = DcryptString.Split('+'); Session["mysessionId"] = queryParamArray[1]; Session["mytokenvalue"] = queryParamArray[2]; mytokenvalue = Session["mytokenvalue"].ToString().Split('|')[0]; Tokensalt = Session["mytokenvalue"].ToString().Split('|')[1]; mysessionId = Session["mysessionId"].ToString(); SqlParameter[] commandParameters1 = new SqlParameter[3]; commandParameters1[0] = new SqlParameter(); commandParameters1[0].ParameterName = "@tokenval"; commandParameters1[0].Value = mytokenvalue.ToString().Split('|')[0]; // commandParameters1[0].Value = "512a15ed44064189b440a9293096b4c6"; commandParameters1[1] = new SqlParameter(); commandParameters1[1].ParameterName = "@sessionId"; commandParameters1[1].Value = Session["mysessionId"].ToString(); // commandParameters1[1].Value = "bajbgc15c3aa4rxxahnkmm25"; commandParameters1[2] = new SqlParameter(); commandParameters1[2].ParameterName = "@Tokensalt"; commandParameters1[2].Value = Tokensalt; ds = B_upload.GetTokenvalue(strConnString, "usp_GetTokenInfo_DocUpload", commandParameters1); if (ds.Tables.Count != 0) { if (ds != null && ds.Tables[0].Rows.Count > 0) { try { languageid = ds.Tables[0].Rows[0]["LanguageId"].ToString(); UploadedFrom = ds.Tables[0].Rows[0]["ReferenceProfile"].ToString(); declarationDocumenttype = ds.Tables[0].Rows[0]["DocumentId"].ToString(); hidRefProfile = ds.Tables[0].Rows[0]["ReferenceProfile"].ToString(); ProfileName = ds.Tables[0].Rows[0]["profileName"].ToString(); DeclarationId = ds.Tables[0].Rows[0]["ReferenceId"].ToString(); pageId = ds.Tables[0].Rows[0]["pageId"].ToString(); TablePrimaryKey = B_upload.GetPrimaryKey(ProfileName, strConnString); Ownerlocid = Convert.ToInt32(ds.Tables[0].Rows[0]["ownerlocid"]); Ownerorgid = Convert.ToInt32(ds.Tables[0].Rows[0]["OwnerOrgId"]); ModifiedBy = ds.Tables[0].Rows[0]["ModifiedBy"].ToString(); CreatedBy = ds.Tables[0].Rows[0]["CreatedBy"].ToString(); Session["profileName"] = ProfileName.ToString(); Session["DeclarationId"] = DeclarationId.ToString(); Session["hidRefProfile"] = hidRefProfile.ToString(); lang1 = ds.Tables[0].Rows[0]["LanguageId"].ToString(); AdditionalDocumentFlag = ds.Tables[0].Rows[0]["AdditionalDocumentFlag"].ToString(); AdditionalDocumentId = ds.Tables[0].Rows[0]["AdditionalDocumentId"].ToString(); additionaldocidforreview = ds.Tables[0].Rows[0]["AdditionalDocumentId"].ToString(); DecIdforreview = DeclarationId.ToString(); ThemeId = ds.Tables[0].Rows[0]["ThemeId"].ToString(); } catch (Exception ex) { Elog = new ErrorLogger(); // WriteToLogFile(ex, "protected override void InitializeCulture()"); Elog.WriteToLogFile(ex, "", " from documents gallery protected override void InitializeCulture() in value of usp_GetTokenInfo_DocUpload Param Information => (referredUrl = '" + Session["referredUrl"].ToString() + "') and tokenValue = '" + Session["mytokenvalue"].ToString() + "' and sessionID = '" + Session["mysessionId"].ToString() + "'and tokensalt = '" + Tokensalt + "'"); Elog = null; } } } else { Elog = new ErrorLogger(); // WriteToLogFile("No Value Found For in Sp :usp_GetTokenInfo_DocUpload '" + mytokenvalue + "'"); Elog.WriteToLogFile("", " from documents gallery protected override void InitializeCulture() in value of usp_GetTokenInfo_DocUpload Param Information => (referredUrl = '" + Session["referredUrl"].ToString() + "') and tokenValue = '" + Session["mytokenvalue"].ToString() + "' and sessionID = '" + Session["mysessionId"].ToString() + "'and tokensalt = '" + Tokensalt + "'"); Elog = null; Response.Redirect("DocumentError.aspx"); } } catch (Exception ex) { Elog = new ErrorLogger(); Elog.WriteToLogFile(ex, "", " from documents gallery protected override void InitializeCulture() Param Information => (referredUrl = '" + Session["referredUrl"].ToString() + "') and tokenValue = '" + Session["mytokenvalue"].ToString() + "' and sessionID = '" + Session["mysessionId"].ToString() + "'and tokensalt = '" + Tokensalt + "'"); Elog = null; // WriteToLogFile(ex); } } B_upload = null; } else { Elog = new ErrorLogger(); Elog.WriteToLogFile("", " from documents gallery Null Token Recived Param Information => (referredUrl = '" + Session["referredUrl"].ToString() + "') and tokenValue = '" + Session["mytokenvalue"].ToString() + "' and sessionID = '" + Session["mysessionId"].ToString() + "'and tokensalt = '" + Tokensalt + "'"); Elog = null; // WriteToLogFile("Null Token Recived '" + tokenvalue + "'"); Response.Redirect("DocumentError.aspx"); } // bEnableReviewStatus = checkLaunchFlag(); checkLaunchFlag(); //bEnableReviewStatus = Convert.ToBoolean(launchFlagFrReview); //bEnableRejectStatus = Convert.ToBoolean(launchFlagFrReject); //bEnableApproveStatus = Convert.ToBoolean(launchFlagFrApprove); //bEnableItemAssociationStatus = Convert.ToBoolean(launchFlagFrItemAssociation); // bEnableReviewStatus = true; if (!bEnableReviewStatus) { // Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Not allowed Save Functionality')",true); } if (!string.IsNullOrEmpty(lang1)) { lang = lang1.ToString().ToLower().Substring(0, 2); } this.UICulture = lang; LocRM = captions.ResourceManager; base.InitializeCulture(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["Documentid"] != null) { StringBuilder sb = new StringBuilder(); string dataItem = Request.QueryString["Documentid"].ToString(); Session["decryptedDocid"] = System.Web.HttpUtility.UrlEncode(dataItem.TrimStart(',')); mytokenvalue = Session["mytokenvalue"].ToString().Split('|')[0]; Tokensalt = Session["mytokenvalue"].ToString().Split('|')[1]; SqlParameter[] commandParameters1 = new SqlParameter[3]; commandParameters1[0] = new SqlParameter(); commandParameters1[0].ParameterName = "@tokenval"; commandParameters1[0].Value = mytokenvalue.ToString().Split('|')[0]; commandParameters1[1] = new SqlParameter(); commandParameters1[1].ParameterName = "@sessionId"; commandParameters1[1].Value = Session["mysessionId"].ToString(); commandParameters1[2] = new SqlParameter(); commandParameters1[2].ParameterName = "@Tokensalt"; commandParameters1[2].Value = Tokensalt; ds = B_upload.GetTokenvalue(strConnString, "usp_GetTokenInfo_DocUpload", commandParameters1); if (ds.Tables.Count != 0) { if (ds != null && ds.Tables[0].Rows.Count > 0) { languageid = ds.Tables[0].Rows[0]["LanguageId"].ToString(); UploadedFrom = ds.Tables[0].Rows[0]["ReferenceProfile"].ToString(); declarationDocumenttype = ds.Tables[0].Rows[0]["DocumentId"].ToString(); hidRefProfile = ds.Tables[0].Rows[0]["ReferenceProfile"].ToString(); ProfileName = ds.Tables[0].Rows[0]["profileName"].ToString(); DeclarationId = ds.Tables[0].Rows[0]["ReferenceId"].ToString(); ThemeId = ds.Tables[0].Rows[0]["ThemeId"].ToString(); pageId = ds.Tables[0].Rows[0]["pageId"].ToString(); TablePrimaryKey = B_upload.GetPrimaryKey(ProfileName, strConnString); Ownerlocid = Convert.ToInt32(ds.Tables[0].Rows[0]["ownerlocid"]); Ownerorgid = Convert.ToInt32(ds.Tables[0].Rows[0]["OwnerOrgId"]); ModifiedBy = ds.Tables[0].Rows[0]["ModifiedBy"].ToString(); CreatedBy = ds.Tables[0].Rows[0]["CreatedBy"].ToString(); Session["profileName"] = ProfileName.ToString(); Session["DeclarationId"] = DeclarationId.ToString(); GetDirection.Text = languageid; Session["hidRefProfile"] = hidRefProfile.ToString(); if (languageid == "eng") { ThemeId = ThemeId + ".css"; } else { ThemeId = ThemeId + "_ara.css"; } } else { // WriteToLogFile("No Value Found For in Sp :usp_GetTokenInfo_DocUpload '" + mytokenvalue + "'"); Response.Redirect("DocumentError.aspx"); } } } }