/// <summary> /// 删除订单目录 /// </summary> /// <param name="ftpServerIP">FTP 主机地址</param> /// <param name="folderToDelete">FTP 用户名</param> /// <param name="ftpUserID">FTP 用户名</param> /// <param name="ftpPassword">FTP 密码</param> public static void DeleteOrderDirectory(string ftpServerIP, string folderToDelete, string ftpUserID, string ftpPassword) { try { if (!string.IsNullOrEmpty(ftpServerIP) && !string.IsNullOrEmpty(folderToDelete) && !string.IsNullOrEmpty(ftpUserID) && !string.IsNullOrEmpty(ftpPassword)) { FtpWeb fw = new FtpWeb(ftpServerIP, folderToDelete, ftpUserID, ftpPassword); //进入订单目录 fw.GotoDirectory(folderToDelete, true); //获取规格目录 string[] folders = fw.GetDirectoryList(); foreach (string folder in folders) { if (!string.IsNullOrEmpty(folder) || folder != "") { //进入订单目录 string subFolder = folderToDelete + "/" + folder; fw.GotoDirectory(subFolder, true); //获取文件列表 string[] files = fw.GetFileList("*.*"); if (files != null) { //删除文件 foreach (string file in files) { fw.Delete(file); } } //删除冲印规格文件夹 fw.GotoDirectory(folderToDelete, true); fw.RemoveDirectory(folder); } } //删除订单文件夹 string parentFolder = folderToDelete.Remove(folderToDelete.LastIndexOf('/')); string orderFolder = folderToDelete.Substring(folderToDelete.LastIndexOf('/') + 1); fw.GotoDirectory(parentFolder, true); fw.RemoveDirectory(orderFolder); } else { throw new Exception("FTP 及路径不能为空!"); } } catch (Exception ex) { throw new Exception("删除订单时发生错误,错误信息为:" + ex.Message); } }
//绘制窗口内容 void OnGUI() { EditorGUILayout.HelpBox(_strHelpMsg, _msgType, true); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("路径:" + _strFtpAddress); _strFtpDirectory = EditorGUILayout.TextField(_strFtpDirectory, GUILayout.Width(300), GUILayout.ExpandWidth(true)); if (_ftpWeb != null) { _ftpWeb.GotoDirectory(_strFtpDirectory, true); } EditorGUILayout.EndHorizontal(); if (_operStep != 2) { EditorGUILayout.BeginHorizontal(); _toggle = EditorGUILayout.Toggle("", _toggle, GUILayout.Width(15)); EditorGUILayout.LabelField("删除本地临时luaCode文件夹"); EditorGUILayout.EndHorizontal(); } //操作按钮 EditorGUILayout.BeginHorizontal(); switch (_operStep) { case 0: if (GUILayout.Button("生成luaCode", GUILayout.Width(100), GUILayout.ExpandWidth(true))) { _operStep = 1; if (System.IO.Directory.Exists(_platformPath + "luaCode")) { System.IO.Directory.Delete(_platformPath + "luaCode", true); } string[] metaFiles = Directory.GetFiles(_platformPath + "luaScripts", "*.lua", SearchOption.AllDirectories); string fileCodePath = _platformPath + "fileCode.lua"; if (System.IO.File.Exists(fileCodePath)) { moveFile(fileCodePath, _platformPath + "luaCode/fileCode.lua"); } foreach (string file in metaFiles) { string copyFile = file.Replace("\\", "/"); string endFilePath = copyFile.Replace(_platformPath, _platformPath + "luaCode/"); moveFile(copyFile, endFilePath); } _operStr = "文件生成成功,等待上传"; } if (GUILayout.Button("取消", GUILayout.Width(100), GUILayout.ExpandWidth(true))) { this.CloseWin(); } break; case 1: //this.position = new Rect(960, 540, 515, 145); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("要上传的文件夹:", GUILayout.Width(100)); _uploadPath = EditorGUILayout.TextField(_uploadPath, GUILayout.Width(300), GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("上传", GUILayout.Width(100), GUILayout.ExpandWidth(true))) { string[] files = Directory.GetFiles(_platformPath + _uploadPath, "*.lua", SearchOption.AllDirectories); _fileList = new List <string>(); foreach (string file in files) { _fileList.Add(file); } _allFileCnt = _fileList.Count; _operStep = 2; } if (GUILayout.Button("取消", GUILayout.Width(100), GUILayout.ExpandWidth(true))) { this.CloseWin(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); break; case 2: { if (_fileList.Count > 0) { if (_tempFile == null) { _tempFile = _fileList[0]; _uploadCnt += 1; _operStr = "上传->" + _tempFile.Replace(_platformPath, "") + " ....................(" + _uploadCnt + "/" + _allFileCnt + ")"; //this.Repaint(); } else { _ftpWeb.UploadPath(_tempFile, _platformPath); _fileList.RemoveAt(0); _tempFile = null; } } else { _operStep = 3; _operStr = "上传完成"; } //this.position = new Rect(960, 540, 515, 110); } break; case 3: //this.position = new Rect(960, 540, 515, 135); if (GUILayout.Button("完成", GUILayout.Width(100), GUILayout.ExpandWidth(true))) { this.CloseWin(); } break; } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField(_operStr); }