/// <summary> /// 文件上传 /// </summary> /// <param name="guid">唯一编码</param> /// <param name="systemPath">系统路径</param> /// <param name="type">操作文件访问方式</param> public static void File_UpLoad(Guid guid, string systemPath, 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() == 0) { FM_FilePath fileInfo = new FM_FilePath(); fileInfo.FileUnique = guid; fileInfo.FilePath = "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/" + fileInfo.FileUnique.ToString(); fileInfo.FileType = systemPath.Substring(systemPath.LastIndexOf(".")); fileInfo.OperationDate = ServerTime.Time; ctx.FM_FilePath.InsertOnSubmit(fileInfo); DateTime tempdateTime = ServerTime.Time; if (type == CE_CommunicationMode.Socket) { FileServiceSocket serverSocket = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP, GlobalObject.GlobalParameter.FTPServerAdvancedUser, GlobalObject.GlobalParameter.FTPServerAdvancedPassword); serverSocket.Upload(systemPath, fileInfo.FilePath); } else if (type == CE_CommunicationMode.FTP) { FileServiceFTP serverFTP = new FileServiceFTP(GlobalObject.GlobalParameter.FTPServerIP, GlobalObject.GlobalParameter.FTPServerAdvancedUser, GlobalObject.GlobalParameter.FTPServerAdvancedPassword); serverFTP.Upload(systemPath, fileInfo.FilePath); } TimeSpan span = ServerTime.Time - tempdateTime; ctx.SubmitChanges(); } else { throw new Exception("文件唯一编码重复"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 文件上传业务 /// </summary> /// <param name="localhostFilePath">本机文件路径</param> /// <param name="ftpFilePath">FTP文件路径</param> /// <param name="guid">文件唯一编码</param> /// <param name="fileType">文件类型</param> public void FileUpLoad(string localhostFilePath, string ftpFilePath, string guid, string fileType) { FileServiceFTP serverFTP = new FileServiceFTP(GlobalObject.GlobalParameter.FTPServerIP, GlobalObject.GlobalParameter.FTPServerAdvancedUser, GlobalObject.GlobalParameter.FTPServerAdvancedPassword); serverFTP.Upload(localhostFilePath, ftpFilePath + guid); try { //生成SWF文件,以便在线阅读 GlobalObject.WebServiceHelper.FileParse(ftpFilePath + guid, fileType.Substring(1)); } catch (Exception) { return; } }