private bool FileBundlingProcess(FolderInfo uploadFolderInfo, int itemIndex) { string[] paths = uploadFolderInfo.LocalPath.Split(new char[] { '\\' }); string localDirectory = paths[paths.Length - 1]; GalleryBundlingRequest request = new GalleryBundlingRequest(); request.FileServerId = _fileServerInfo.Id; request.Token = ClientConfig.Token; request.Account = ClientConfig.Account; request.PassWord = ClientConfig.PassWord; request.OriginalAbsoluteFileDirectory = _fileServerInfo.OriginalFileServerRootDirectory + uploadFolderInfo.LevelPath.Replace("|", "\\\\") + "\\\\" + localDirectory; CommonResponse response = _proxy.FileBundling(request); if (!response.IsSuccessful) { string errorInfo = string.Format("目录:{0}\r\n服务端目录打包异常:{1}", uploadFolderInfo.LocalPath, response.ResultMessage); Tools.LogWrite(errorInfo); uploadFolderInfo.UploadResult.AppendLine(response.ResultMessage); UploadDirectoryTurnToFail(uploadFolderInfo, itemIndex); } return response.IsSuccessful; }
public CommonResponse FileBundling(GalleryBundlingRequest request) { CommonResponse response = new CommonResponse(); response.IsSuccessful = false; string packageSavePath = string.Empty; try { bool isPermission = Authentication(request.Token, request.FileServerId, request.Account, request.PassWord); if (!isPermission) { response.IsSuccessful = false; response.ResultMessage = "您没有访问该文件服务器接口的权限!"; return response; } if (!Directory.Exists(request.OriginalAbsoluteFileDirectory)) { response.IsSuccessful = false; response.ResultMessage = string.Format("待打包目录:{0} 不存在!" , request.OriginalAbsoluteFileDirectory); return response; } packageSavePath = Path.Combine(request.OriginalAbsoluteFileDirectory, "Package.zip"); if (File.Exists(packageSavePath)) { File.Delete(packageSavePath); } string fileName = string.Empty; List<string> listFile = new List<string>(); foreach (string file in Directory.GetFiles(request.OriginalAbsoluteFileDirectory)) { fileName = Path.GetFileName(file).ToLower(); if (fileName != "video.rar") { listFile.Add(file); } } if (listFile.Count > 0) { Tools.FileCompress(listFile, packageSavePath); response.IsSuccessful = true; response.ResultMessage = string.Empty; } else { response.IsSuccessful = false; response.ResultMessage = string.Format("待打包目录:{0} 为空目录!" ,request.OriginalAbsoluteFileDirectory); } } catch (Exception ex) { response.IsSuccessful = false; response.ResultMessage = ex.ToString(); Tools.LogWrite(ex.ToString()); } return response; }