/// <summary> /// To save attached files to DB. /// </summary> /// <param name="sender"></param> /// <param name="file"></param> protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { try { Byte[] fileBytes = file.GetContents(); string sPath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Technical"); string sPath1 = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Inspection"); Guid GUID = Guid.NewGuid(); string Flag_Attach = GUID.ToString() + Path.GetExtension(file.FileName); int Office_ID = Convert.ToInt32(Request.QueryString["OFFID"]); int Worklist_ID = Convert.ToInt32(Request.QueryString["WLID"]); int Vessel_ID = Convert.ToInt32(Request.QueryString["VID"]); string _fileName = ""; int FileID = objBLL.Insert_Worklist_Attachment(Vessel_ID, Worklist_ID, Office_ID, UDFLib.Remove_Special_Characters(file.FileName), Flag_Attach, file.FileSize, UDFLib.ConvertToInteger(Session["USERID"])); _fileName = "TEC_" + Vessel_ID + "_" + Worklist_ID + "_" + Office_ID + "_" + "O" + "_" + FileID.ToString() + "_" + Flag_Attach; // This method insert attachments in object table and it will sync to mobile by Pranav Sakpal on 2016-03-23 int Ret = objBLL.Insert_ActivityObject(Vessel_ID, Worklist_ID, Office_ID, _fileName, _fileName, UDFLib.ConvertToInteger(Session["USERID"])); string FullFilename = Path.Combine(sPath, _fileName); //Save attached file to folder FileStream fileStream = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite); fileStream.Write(fileBytes, 0, fileBytes.Length); fileStream.Close(); // This will copy attachments in inspection folder it will sync to mobile by Pranav Sakpal on 2016-03-23 string filecopyname = _fileName; File.Copy(FullFilename, Path.Combine(sPath1, filecopyname), true); Load_Attachments(Vessel_ID, Worklist_ID, Office_ID, GetSessionUserID()); } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }