protected void LinkButtonAutoDeployLordConfig_Click(object sender, EventArgs e) { if (_server != null) { if (!WebUtil.CheckPrivilege(TheAdminServer.GameServerManager.SecurityObject, OpType.WRITE, Session)) { Response.Redirect(WebConfig.PageNotEnoughPrivilege, true); } else { try { //选择服务器 SelectServerAutomation selectServer = new SelectServerAutomation(); selectServer.Parameter = new object[] { 2, _server.Id }; //创建Lord配置文件 CreateLordConfigAutomation createLord = new CreateLordConfigAutomation(); createLord.Parameter = new object[] { 1, _server.Id }; //上传文件 FileTransferAutomation fileTransAuto = new FileTransferAutomation(); string fileName = _server.Id + "_" + _server.Name + "_guard.cfg"; fileTransAuto.Parameter = new object[] { 1, _server.Id,fileName }; //配置Lord ExeSysCmdAutomation exeSysAuto = new ExeSysCmdAutomation(); string scriptText = ShellScriptManager.TheInstance.GetScript("DeployLordConfig", _server.SystemName); string file = _server.GuardDir + GameServer.FilePathDelimiter + GameServer.UploadFileDir + GameServer.FilePathDelimiter + fileName; string comText = string.Format(scriptText, file, _server.GameDir); exeSysAuto.Parameter = new object[] { 1, comText }; //删除FSEye本地存储文件 DeleteLocalFileAutomation deleteFile = new DeleteLocalFileAutomation(); deleteFile.Parameter = new object[] { 1, fileName }; //把5个Automation连接起来 selectServer.Success = createLord; createLord.Success = fileTransAuto; fileTransAuto.Success = exeSysAuto; exeSysAuto.Success = deleteFile; TheAdminServer.AutomationManager.Do(selectServer, new AutomationContext()); //Session["Auto"] = createLord; //LiteralSaveFile1.Text = StringDef.Doing; //UploadLordConfig.Visible = true; //ShowMessage(StringDef.CreateLordConfigFile + " \"" + fileName + "\" " + StringDef.Colon + StringDef.Success, MessageType.Success); } catch (Exception) { } } } }
public FileTranTask(FileTransferAutomation fileTranAutomation, string sourceFile, string targetFile) { _fileTranAutomation = fileTranAutomation; //FileTranTask(sourceFile, targetFile); if (sourceFile == null || sourceFile.Length == 0) { throw new ArgumentException("SourceFileName can not be null or empty."); } if (targetFile == null || targetFile.Length == 0) { throw new ArgumentException("TargetFileName can not be null or empty."); } _sourceFileName = sourceFile; _targetFileName = targetFile; _offset = 0; }