protected void SaveFBMAttachment(int fbmid, bool SyncAttachment) { string sourchfilepath = ""; string destinationpath = ""; DataTable dt = new DataTable(); if (Request.QueryString["FBMID"] != null) { dt = BLL_FBM_Report.FBMAttachmentSearch(Convert.ToInt32(Request.QueryString["FBMID"].ToString())); } DataTable vdtFile = (DataTable)ViewState["vdtFile"]; foreach (DataRow dr in vdtFile.Rows) { sourchfilepath = Server.MapPath(@"~/QMS\\TempUpload\\"); sourchfilepath += dr["FileGuid"].ToString() + dr["FileExtn"].ToString(); destinationpath = Server.MapPath(@"~/Uploads\\FBM\\"); destinationpath += dr["FileGuid"].ToString() + dr["FileExtn"].ToString(); BLL_FBM_Report.FBMAttachmentSave(Convert.ToInt32(Session["userid"].ToString()), fbmid, dr["FileName"].ToString(), dr["FileGuid"].ToString() + dr["FileExtn"].ToString()); if (!File.Exists(destinationpath)) { File.Copy(sourchfilepath, destinationpath); } } }
protected void BindFBMAttachment(int fbmid) { DataTable dt = BLL_FBM_Report.FBMAttachmentSearch(fbmid); gvFBMAtt.DataSource = dt; gvFBMAtt.DataBind(); }
protected void SendEmail(int fbmid) { string ToMail = ""; int crewfbmidout = 0; if (optForUser.SelectedValue == "COMPANY") //company { ToMail = ConfigurationManager.AppSettings["FBM_TO_COMPANY_EMAIL"].ToString(); } else if (optForUser.SelectedValue == "OFFICE") //office { ToMail = ConfigurationManager.AppSettings["FBM_TO_OFFICE_EMAIL"].ToString(); } else if (optForUser.SelectedValue == "SHIP") // ship email { ToMail = ConfigurationManager.AppSettings["FBM_TO_OFFICE_EMAIL"].ToString(); } // if there is a Attachment is associated with FBM Then Send an Email to IT Department. DataTable dtAttachments = BLL_FBM_Report.FBMAttachmentSearch(fbmid); DataSet ds = BLL_FBM_Report.FBMReportList(Convert.ToInt32(fbmid)); // Check the attachment if (dtAttachments.Rows.Count > 0) { // IF USER TYPE IS SHIP THEN EMAI SHOULD GO TO IT DEPT FOR REDUCING THE FILE. if (ds.Tables[0].Rows[0]["FOR_USER"].ToString().ToUpper() == "SHIP") { StringBuilder sbEmailbody = new StringBuilder(); string subject = "FBM Number :" + ds.Tables[0].Rows[0]["FBM_NUMBER"].ToString(); string path = System.Configuration.ConfigurationManager.AppSettings["APP_URL"].ToString() + @"\uploads\FBM\\"; sbEmailbody.Append("Dear IT,"); sbEmailbody.AppendLine("<br><br>"); sbEmailbody.AppendLine("A FBM has been sent with one or more attachments to it."); sbEmailbody.AppendLine("<br><br>"); sbEmailbody.AppendLine("Arrange to reduce the size of the attachment/s listed below:"); sbEmailbody.AppendLine("<br><br>"); foreach (DataRow dr in dtAttachments.Rows) { sbEmailbody.Append(dr["FILEPATH"].ToString()); sbEmailbody.AppendLine("<br>"); } sbEmailbody.Append("This file is located in folder: <a href=" + path + ">" + path + "</a>"); //sbEmailbody.Append("<a href=" + path + ">" + path + "</a>"); sbEmailbody.AppendLine("<br><br>"); sbEmailbody.AppendLine("Best Regards,"); sbEmailbody.AppendLine("<br>"); sbEmailbody.AppendLine("Jibe AutoMessenger"); if (ds.Tables[0].Rows.Count > 0) { subject = ds.Tables[0].Rows[0]["FBM_NUMBER"].ToString(); } int val = BLL_FBM_Report.FBMCrewMailSave(Convert.ToInt32(Session["userid"].ToString()), subject, ToMail, "", sbEmailbody.ToString(), ref crewfbmidout); } //IF USER TYPE IS COMPANY OR OFFICE THEN NO ACTION AS PER SATVINDER SIR. else { //string filepathSave = @"\\server01\uploads\FBM\"; //int val = BLL_FBM_Report.FBMCrewMailSave(Convert.ToInt32(Session["userid"].ToString()), txtSubject.Text, ToMail, "", txtMailBody.Text, ref crewfbmidout); //foreach (DataRow dr in dtAttachments.Rows) //{ // BLL_FBM_Report.FBMCrewAttachmentSave(Convert.ToInt32(Session["userid"].ToString()), crewfbmidout, dr[2].ToString(), filepathSave + dr[2].ToString()); //} } } }