private void BtBuild_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { this.Invoke(new Action(() => { LbResult.Text = "开始检索并生成目录文件,请稍候……"; })); beginTime = DateTime.Now; string path = TbPath.Text; string parentPath = DirTool.Parent(path); FileCodeHelper fcode = new FileCodeHelper(); if (Directory.Exists(path) && Directory.Exists(parentPath)) { List <string> fileList = FileTool.GetAllFile(path); if (!ListTool.IsNullOrEmpty(fileList)) { VersionModel version = new VersionModel() { Number = DateTime.Now.Second, Path = path, FileList = new List <VersionFile>(), }; foreach (var item in fileList) { version.FileList.Add(new VersionFile() { File = item.Replace(path, ""), MD5 = fcode.GetMD5(item), }); } string file = string.Format(@"{0}\version.txt", parentPath); string json = JsonTool.ToStr(version); TxtTool.Create(file, json); } } endTime = DateTime.Now; this.Invoke(new Action(() => { LbResult.Text = string.Format("生成完成,用时:{0}秒。", (endTime - beginTime).TotalSeconds); })); }); }
private void CreateVersionMap() { string versionNumber = TbVersionNumber.Text; string ftpPath = TbFtpPath.Text; string[] beginClose = TbBeginClose.Text.Split(';'); string[] endRun = TbEndRun.Text.Split(';'); string path = TbPath.Text; string parentPath = DirTool.Parent(path); FileCodeTool fcode = new FileCodeTool(); if (Directory.Exists(path) && Directory.Exists(parentPath)) { List <string> fileList = FileTool.GetAllFile(path); if (!ListTool.IsNullOrEmpty(fileList)) { VersionModel version = new VersionModel() { Number = versionNumber, ServerPath = ftpPath, BeginCloseProcess = beginClose, EndRunProcess = endRun, FileList = new List <VersionFile>() }; foreach (var item in fileList) { version.FileList.Add(new VersionFile() { File = item.Replace(path, ""), MD5 = fcode.GetMD5(item), }); } string file = string.Format(@"{0}\update.version", parentPath, versionNumber); string json = JsonTool.ToStr(version); TxtTool.Create(file, json); } } }
private void ConnectLocalByProcess() { try { Process[] process = Process.GetProcessesByName("USBManager.Service"); if (Ls.Ok(process)) { string file = process[0].MainModule.FileName; if (File.Exists(file)) { string path = DirTool.Parent(file); string set_file = DirTool.Combine(path, "USBManagerServiceSettings.ini"); int port = IniTool.GetInt(set_file, "Tx", "TcppPort", 0); if (port > 0) { Connect("127.0.0.1", port); Close(); } } } } catch { } }