/// <summary> /// 删除一条文件信息,并且删除文件记录信息、FTP文件实体 /// </summary> /// <param name="ctx">数据上下文</param> /// <param name="guid">唯一编码</param> void DeleteFileStruct(DepotManagementDataContext ctx, string guid) { var varData = from a in ctx.ZL_Database_FileStruct where a.ID == new Guid(guid) select a; foreach (ZL_Database_FileStruct item in varData) { if (item.FileUnique != null) { var varFilePath = from a in ctx.FM_FilePath where a.FileUnique == item.FileUnique select a; foreach (FM_FilePath path in varFilePath) { m_serverFTP.Delete(path.FilePath); } ctx.FM_FilePath.DeleteAllOnSubmit(varFilePath); } } ctx.ZL_Database_FileStruct.DeleteAllOnSubmit(varData); }
/// <summary> /// 删除流程 /// </summary> /// <param name="sdbNo">流程编号</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回false </returns> public bool DeleteProcess(string sdbNo, out string error) { error = null; try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; string strSql = " select SDBNo,a.FileUnique,FilePath from ( " + " select FileUnique,SDBNo from dbo.FM_ReviewProcess " + " union all " + " select AuditorFileUnique,SDBNo from dbo.FM_ReviewProcess " + " union all " + " select JudgeFileUnique,SDBNo from dbo.FM_ReviewProcess " + " union all " + " select FileUnique,SDBNo from dbo.FM_ReviewProcessPointListInfo) as a " + " inner join FM_FilePath as b on a.FileUnique = b.FileUnique " + " where a.FileUnique is not null and SDBNo = '" + sdbNo + "'"; DataTable tempDT = GlobalObject.DatabaseServer.QueryInfo(strSql); var varData = from a in ctx.FM_ReviewProcess where a.SDBNo == sdbNo select a; ctx.FM_ReviewProcess.DeleteAllOnSubmit(varData); if (tempDT != null) { FileServiceSocket serverFTP = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP, GlobalObject.GlobalParameter.FTPServerAdvancedUser, GlobalObject.GlobalParameter.FTPServerAdvancedPassword); foreach (DataRow dr in tempDT.Rows) { serverFTP.Delete(dr["FilePath"].ToString()); var varFileInfo = from a in ctx.FM_FilePath where a.FileUnique == (Guid)dr["FileUnique"] select a; ctx.FM_FilePath.DeleteAllOnSubmit(varFileInfo); } } ctx.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 文件删除 /// </summary> /// <param name="guid">文件唯一编码</param> /// <param name="type">操作文件访问方式</param> public static void File_Delete(Guid guid, CE_CommunicationMode type) { try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.FM_FilePath where a.FileUnique == guid select a; if (varData.Count() == 1) { ctx.FM_FilePath.DeleteAllOnSubmit(varData); if (type == CE_CommunicationMode.Socket) { FileServiceSocket serverSocket = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP, GlobalObject.GlobalParameter.FTPServerAdvancedUser, GlobalObject.GlobalParameter.FTPServerAdvancedPassword); serverSocket.Delete(varData.Single().FilePath); } else if (type == CE_CommunicationMode.FTP) { FileServiceFTP serverFTP = new FileServiceFTP(GlobalObject.GlobalParameter.FTPServerIP, GlobalObject.GlobalParameter.FTPServerAdvancedUser, GlobalObject.GlobalParameter.FTPServerAdvancedPassword); serverFTP.Delete(varData.Single().FilePath); } ctx.SubmitChanges(); } else if (varData.Count() == 0) { return; } else { throw new Exception("文件唯一编码重复"); } } catch (Exception ex) { throw new Exception(ex.Message); } }