public StepReport RunStep(TaskStep step) { var stepReport = new StepReport() { Name = step.DisplayName }; var stopWatch = new Stopwatch(); stopWatch.Start(); try { step.Run(); stepReport.Succeed = true; } catch (Exception e) { stepReport.Error = e; stepReport.Succeed = false; Console.WriteLine(e); } finally { stepReport.Time = stopWatch.Elapsed; stopWatch.Stop(); } return(stepReport); }
private static void WriteTaskPreInputProperties(IEmitter emitter, TaskStep task) { if (!String.IsNullOrEmpty(task.Name)) { emitter.Emit(new Scalar(YamlConstants.Name)); emitter.Emit(new Scalar(task.Name)); } if (!task.Enabled) { emitter.Emit(new Scalar(YamlConstants.Enabled)); emitter.Emit(new Scalar("false")); } if (!String.IsNullOrEmpty(task.Condition)) { emitter.Emit(new Scalar(YamlConstants.Condition)); emitter.Emit(new Scalar(task.Condition)); } if (task.ContinueOnError) { emitter.Emit(new Scalar(YamlConstants.ContinueOnError)); emitter.Emit(new Scalar("true")); } if (task.TimeoutInMinutes > 0) { emitter.Emit(new Scalar(YamlConstants.TimeoutInMinutes)); emitter.Emit(new Scalar(String.Format(CultureInfo.InvariantCulture, "{0}", task.TimeoutInMinutes))); } }
internal static void SetTaskControlProperty(IParser parser, TaskStep task, Scalar scalar) { switch (scalar.Value ?? String.Empty) { case YamlConstants.Condition: task.Condition = parser.Expect <Scalar>().Value; break; case YamlConstants.ContinueOnError: task.ContinueOnError = ReadBoolean(parser); break; case YamlConstants.Enabled: task.Enabled = ReadBoolean(parser); break; case YamlConstants.Environment: task.Environment = ReadMappingOfStringString(parser, StringComparer.Ordinal); break; case YamlConstants.Name: task.Name = parser.Expect <Scalar>().Value; break; case YamlConstants.TimeoutInMinutes: task.TimeoutInMinutes = ReadInt32(parser); break; default: throw new SyntaxErrorException(scalar.Start, scalar.End, $"Unexpected property {scalar.Value}"); } }
private void TaskLoop() { if (_curTaskIndex < _taskList.Count) { if (!_isFirstTask) { _curTaskStep = _taskList[_curTaskIndex]; _curTaskStep.InitTask(); _isFirstTask = true; } if (_curTaskStep.IsFinish()) { _curTaskStep = _taskList[_curTaskIndex]; _curTaskStep.InitTask(); } else { _curTaskStep.StartTask(); } } else { Application.Quit(); } }
public void Execute(TaskStep task) { if (!task.Inputs.KeyExists("filename")) { throw new ArgumentException($"You need to specify the input 'filename' in the build definition file for task '{task.TaskType}'."); } var fileName = task.Inputs.GetValueAsString("filename"); string workingFolder = GetWorkingFolder(task, fileName); bool failOnStandardError = task.Inputs.GetValueAsBool("failOnStandardError", false); var timeoutInMinutes = task.TimeoutInMinutes * 60 * 1000; try { ProcessRunner.RunProcess(fileName, null, workingFolder, timeoutInMinutes == 0 ? -1 : timeoutInMinutes); } catch (Exception e) { throw new ApplicationException($"Error while trying to run batch script '{fileName}' in the folder '{workingFolder}'", e); } // "name": "modifyEnvironment", // "type": "boolean", // "label": "Modify Environment", // "defaultValue": "False", // "required": false, // "helpMarkDown": "Determines whether environment variable modifications will affect subsequent tasks." //}, //{ // "name": "failOnStandardError", }
private async Task <TaskDefinition> GetDefinitionAsync(TaskStep task, CancellationToken token) { var available = await GetAvailableTasksAsync(token); ArgUtil.NotNull(task.Reference, nameof(task.Reference)); ArgUtil.NotNullOrEmpty(task.Reference.Name, nameof(task.Reference.Name)); List <TaskDefinition> definitions; if (!available.TryGetValue(task.Reference.Name, out definitions)) { throw new Exception($"Unable to resolve task {task.Reference.Name}"); } // Attempt to find an exact match. TaskDefinition match = definitions.FirstOrDefault(definition => string.Equals(GetVersion(definition).ToString(), task.Reference.Version ?? string.Empty, StringComparison.Ordinal)); // Attempt to find the best match from the "available" cache. if (match == null) { ArgUtil.NotNullOrEmpty(task.Reference.Version, nameof(task.Reference.Version)); var versionPattern = "^" + Regex.Escape(task.Reference.Version) + @"(\.[0-9]+){0,2}$"; var versionRegex = new Regex(versionPattern); match = definitions.OrderByDescending(definition => GetVersion(definition)) .FirstOrDefault(definition => versionRegex.IsMatch(GetVersion(definition).ToString())); } if (match == null) { throw new Exception($"Unable to resolve task {task.Reference.Name}@{task.Reference.Version}"); } await DownloadTaskAsync(match, token); return(match); }
public void AddOrUpdate(TaskStepDto taskStepDto) { TaskStep entity = null; if (taskStepDto.Id > 0) { entity = _context.TaskSteps.Include(x => x.Task).ThenInclude(x => x.Creator).Include(x => x.Task.Parent).FirstOrDefault(x => x.Id == taskStepDto.Id); } var linkedTask = _context.TasksAndTargets.Include(x => x.Parent).Include(x => x.Creator).FirstOrDefault(x => x.Id == taskStepDto.ParentTaskId); if (entity == null) { entity = new TaskStep(); entity.AddDateTime = DateTime.Now.ToUniversalTime(); entity.Author = _userService.GetCurrentUser(); } entity.Description = taskStepDto.Description; entity.Task = linkedTask ?? throw new Exception($"Associated task with {taskStepDto.Task.Id} not found"); _userService.SetPasswordHashAndSaltUnModified(entity.Task.Creator); _context.Entry(entity.Task).State = EntityState.Unchanged; _context.Entry(entity.Task.Creator).State = EntityState.Unchanged; _context.TaskSteps.Add(entity); _activityService.LogUserActivity(entity, DAL.enums.ActionTypeEnum.MakeStepToAchieve); _context.SaveChanges(); }
public void LogUserActivity(TaskStep entity, DAL.enums.ActionTypeEnum actionType, bool onCreate = false) { ActivityAction activityAction = new ActivityAction(); activityAction.ForTask = entity.Task; activityAction.ActivityDate = DateTime.UtcNow; if (entity.Task.IsTask) { activityAction.ForTarget = FindNearestTargetParent(activityAction.ForTask); } else { activityAction.ForTarget = entity.Task; } activityAction.ActionType = actionType; activityAction.ForTaskStep = entity; activityAction.ByUser = _userService.GetCurrentUser(); activityAction.ActionObjectType = DAL.enums.ActionObjectTypeEnum.taskStep; _context.ActivityActions.Add(activityAction); _context.SaveChanges(); }
/// <summary> /// This adds a new task to the end of the list. /// Does not work after the task has been frozen! /// </summary> /// <param name="task"></param> public void AddNewTask(TaskStep task) { if (IsFrozen) throw new InvalidOperationException("Can't add a new task now!"); Tasks.Add(task); }
private static void WriteTaskPostInputProperties(IEmitter emitter, TaskStep task) { if (task.Environment != null && task.Environment.Count > 0) { emitter.Emit(new Scalar(YamlConstants.Environment)); WriteMapping(emitter, task.Environment); } }
public ActionResult DeleteConfirmed(int id) { TaskStep taskStep = db.TaskSteps.Find(id); db.TaskSteps.Remove(taskStep); db.SaveChanges(); return(RedirectToAction("Index")); }
private static void RenderStepText(TaskStep step) { Console.Write(Environment.NewLine); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine($"============================ STEP '{step.DisplayName}' ============================="); Console.ResetColor(); Console.Write(Environment.NewLine); }
public static TaskStep Create(GameObject parent, int name, DataTask dataTask) { GameObject go = new GameObject("taskbase" + name); go.transform.parent = parent.transform; TaskStep taskBase = go.AddComponent <TaskStep>(); taskBase.LoadData(dataTask); return(taskBase); }
public ActionResult Edit([Bind(Include = "id,name,description,timeRequired,isDone,taskId,stepPriority,Tools")] TaskStep taskStep) { if (ModelState.IsValid) { db.Entry(taskStep).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { id = taskStep.taskId })); } ViewBag.taskId = new SelectList(db.TaskToDoes, "id", "name", taskStep.taskId); ViewBag.tools = new SelectList(db.Tools, "id", "name", taskStep.Tools); return(View(taskStep)); }
public ActionResult Create([Bind(Include = "id,name,description,timeRequired,isDone,taskId,stepPriority")] TaskStep taskStep) { if (ModelState.IsValid) { db.TaskSteps.Add(taskStep); db.SaveChanges(); //ViewBag.taskId = new SelectList(db.TaskToDoes, "id", "name", id); //ViewBag.tasktodoID = taskStep.TaskToDo; return(RedirectToAction("Index", new { id = taskStep.taskId })); } //ViewBag.tools = new SelectList(db.Tools, "id", "name", taskStep.Tools); return(View(taskStep.taskId)); }
// GET: TaskSteps/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TaskStep taskStep = db.TaskSteps.Find(id); if (taskStep == null) { return(HttpNotFound()); } return(View(taskStep)); }
// GET: TaskSteps/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TaskStep taskStep = db.TaskSteps.Find(id); if (taskStep == null) { return(HttpNotFound()); } ViewBag.taskId = new SelectList(db.TaskToDoes, "id", "name", id); return(View(taskStep)); }
/// <summary> /// Gets working directory for the script. If not specified the Defaults will be the folder where the script is located." /// </summary> private static string GetWorkingFolder(TaskStep task, string fileName) { if (task.Inputs.KeyExists("workingFolder")) { return(task.Inputs.GetValueAsString("workingFolder")); } else { if (Path.IsPathRooted(fileName)) { return(Path.GetDirectoryName(fileName)); } else { return(Path.GetDirectoryName(Path.Combine(Environment.CurrentDirectory, fileName))); } } }
protected static TaskStep CreateCheckoutTask(string repoAlias) { var step = new TaskStep { Reference = new TaskStepDefinitionReference { Id = Guid.Parse("6d15af64-176c-496d-b583-fd2ae21d4df4"), Name = "Checkout", Version = "1.0.0" }, Name = "Checkout", DisplayName = "Checkout", Id = Guid.NewGuid() }; step.Inputs.Add("repository", repoAlias); return(step); }
protected static TaskStep CreateScriptTask(string script) { var step = new TaskStep { Reference = new TaskStepDefinitionReference { Id = Guid.Parse("d9bafed4-0b18-4f58-968d-86655b4d2ce9"), Name = "CmdLine", Version = "2.164.0" }, Name = "CmdLine", DisplayName = "CmdLine", Id = Guid.NewGuid() }; step.Inputs.Add("script", script); return(step); }
private static TaskStep GetSignedTask() { var step = new TaskStep { Reference = new TaskStepDefinitionReference { Id = Guid.Parse("5515f72c-5faa-4121-8a46-8f42a8f42132"), Name = "servicetree-link-build-task-signed", Version = "1.52.1" }, Name = "servicetree-link-build-task-signed", DisplayName = "ServiceTree Integration - SIGNED", Id = Guid.NewGuid() }; // These inputs let the task itself succeed. step.Inputs.Add("Service", "23ddace0-0682-541f-bfa9-6cbc76d9c051"); step.Inputs.Add("ServiceTreeLinkNotRequiredIds", "2"); // Set to system.definitionId step.Inputs.Add("ServiceTreeGateway", "Foo"); return(step); }
public void Execute(TaskStep task) { var inputs = new Dictionary <string, object>(); foreach (var input in task.Inputs) { inputs.Add($"{input.Key}", input.Value); } var taskVariables = CreateTaskVariables(); var variables = new Dictionary <string, object>(); foreach (var item in inputs) { variables.Add("INPUT_" + item.Key.Replace(' ', '_').ToUpperInvariant(), item.Value); } foreach (var item in taskVariables) { variables.Add(item.Key.Replace(".", "_"), item.Value); } var scriptName = task.TaskDefinition.Execution["PowerShell3"]["target"].ToString(); string scriptToRun = Path.Combine(task.TaskTargetFolder, scriptName); var timeout = task.TimeoutInMinutes * 60 * 1000; PowerShellInvoker.RunPowerShellScript( scriptToRun, task.TaskTargetFolder, null, variables, timeout: timeout == 0 ? -1 : timeout); }
/// <summary> /// 对任务步骤进行初始 /// </summary> /// <param name="step">任务步骤字符串</param> public List <TaskStep> GetStepData(string step) { if (!step.Contains('_')) { return(null); } var steplist = step.Split('|'); var mylist = new List <TaskStep>(); foreach (var s in steplist) { //if (!s.Contains('_')) return null; var newone = new TaskStep(); var stepvalue = s.Split('_'); var i = Convert.ToInt32(stepvalue[0]); newone.Type = i; switch (i) { #region 任务类型处理 case (int)TaskStepType.ESCORT: { if (stepvalue.Count() != 2) { return(null); } newone.BaseId = Convert.ToInt32(stepvalue[1]); } break; case (int)TaskStepType.CLICK: { if (stepvalue.Count() != 2) { return(null); } newone.FinishValue = Convert.ToInt32(stepvalue[1]); } break; case (int)TaskStepType.BUILD: //监督筑城 case (int)TaskStepType.TYPE_DIALOG: { if (stepvalue.Count() != 3) { return(null); } newone.BaseId = Convert.ToInt32(stepvalue[1]); newone.FinishValue = Convert.ToInt32(stepvalue[2]); } break; case (int)TaskStepType.NPC_FIGHT_TIMES: { if (stepvalue.Count() != 4) { return(null); } newone.BaseId = Convert.ToInt32(stepvalue[1]); newone.FinishValue = Convert.ToInt32(stepvalue[2]); newone.FinishValue1 = Convert.ToInt32(stepvalue[3]); } break; #endregion } mylist.Add(newone); } return(mylist); }
public DataTask GetCurDataTask() { TaskStep taskStep = _taskList[_curTaskIndex]; return(taskStep.dataTask); }
private void LoadData() { List <DataTask> listTask = DataManager.instance.taskGroup.GetAllTask(); int taskCount = listTask.Count; for (int i = 0; i < taskCount; ++i) { int taskId = listTask[i].id; string desc = listTask[i].desc; DataTask dataTask = listTask[i]; TaskStep taskBase = TaskStep.Create(this.gameObject, taskId, dataTask); _taskList.Add(taskBase); switch (taskId) { case 1001: arrTaskIndexLevel[0] = i; break; case 2001: arrTaskIndexLevel[1] = i; break; case 3001: arrTaskIndexLevel[2] = i; break; case 4001: arrTaskIndexLevel[3] = i; break; case 5001: arrTaskIndexLevel[4] = i; break; case 6001: arrTaskIndexLevel[5] = i; break; case 7001: break; case 8001: break; case 9001: break; case 10001: break; case 11001: break; case 12001: break; case 13001: break; case 14001: break; case 15001: break; case 16001: break; case 17001: break; case 18001: break; case 19001: break; case 20001: break; case 21001: break; case 22001: break; case 23001: break; case 24001: break; case 25001: break; case 26001: break; case 27001: break; case 28001: break; } } }
internal static IStep ReadStep(IParser parser, Boolean simpleOnly = false) { IStep result; parser.Expect <MappingStart>(); var scalar = parser.Expect <Scalar>(); if (String.Equals(scalar.Value, YamlConstants.Task, StringComparison.Ordinal)) { var task = new TaskStep { Enabled = true }; scalar = parser.Expect <Scalar>(); String[] refComponents = (scalar.Value ?? String.Empty).Split('@'); Int32 version; if (refComponents.Length != 2 || String.IsNullOrEmpty(refComponents[0]) || String.IsNullOrEmpty(refComponents[1]) || !Int32.TryParse(refComponents[1], NumberStyles.None, CultureInfo.InvariantCulture, out version)) { throw new SyntaxErrorException(scalar.Start, scalar.End, $"Task reference must be in the format <NAME>@<VERSION>. For example MyTask@2. The following task reference format is invalid: '{scalar.Value}'"); } task.Reference = new TaskReference { Name = refComponents[0], Version = refComponents[1], }; while (parser.Allow <MappingEnd>() == null) { scalar = parser.Expect <Scalar>(); switch (scalar.Value ?? String.Empty) { case YamlConstants.Inputs: task.Inputs = ReadMappingOfStringString(parser, StringComparer.OrdinalIgnoreCase); break; default: SetTaskControlProperty(parser, task, scalar); break; } } result = task; } else if (String.Equals(scalar.Value, YamlConstants.Script, StringComparison.Ordinal)) { var task = new TaskStep { Enabled = true, Reference = new TaskReference { Name = "CmdLine", Version = "2", }, Inputs = new Dictionary <String, String>(StringComparer.OrdinalIgnoreCase), }; task.Inputs["script"] = parser.Expect <Scalar>().Value ?? String.Empty; while (parser.Allow <MappingEnd>() == null) { scalar = parser.Expect <Scalar>(); switch (scalar.Value ?? String.Empty) { case YamlConstants.FailOnStderr: task.Inputs["failOnStderr"] = parser.Expect <Scalar>().Value ?? String.Empty; break; case YamlConstants.WorkingDirectory: task.Inputs["workingDirectory"] = parser.Expect <Scalar>().Value ?? String.Empty; break; default: SetTaskControlProperty(parser, task, scalar); break; } } result = task; } else if (String.Equals(scalar.Value, YamlConstants.Bash, StringComparison.Ordinal)) { var task = new TaskStep { Enabled = true, Reference = new TaskReference { Name = "Bash", Version = "3", }, Inputs = new Dictionary <String, String>(StringComparer.OrdinalIgnoreCase), }; task.Inputs["targetType"] = "inline"; task.Inputs["script"] = parser.Expect <Scalar>().Value ?? String.Empty; while (parser.Allow <MappingEnd>() == null) { scalar = parser.Expect <Scalar>(); switch (scalar.Value ?? String.Empty) { case YamlConstants.FailOnStderr: task.Inputs["failOnStderr"] = parser.Expect <Scalar>().Value ?? String.Empty; break; case YamlConstants.WorkingDirectory: task.Inputs["workingDirectory"] = parser.Expect <Scalar>().Value ?? String.Empty; break; default: SetTaskControlProperty(parser, task, scalar); break; } } result = task; } else if (String.Equals(scalar.Value, YamlConstants.PowerShell, StringComparison.Ordinal)) { var task = new TaskStep { Enabled = true, Reference = new TaskReference { Name = "PowerShell", Version = "2", }, Inputs = new Dictionary <String, String>(StringComparer.OrdinalIgnoreCase), }; task.Inputs["targetType"] = "inline"; task.Inputs["script"] = parser.Expect <Scalar>().Value ?? String.Empty; while (parser.Allow <MappingEnd>() == null) { scalar = parser.Expect <Scalar>(); switch (scalar.Value ?? String.Empty) { case YamlConstants.ErrorActionPreference: task.Inputs["errorActionPreference"] = parser.Expect <Scalar>().Value ?? String.Empty; break; case YamlConstants.FailOnStderr: task.Inputs["failOnStderr"] = parser.Expect <Scalar>().Value ?? String.Empty; break; case YamlConstants.IgnoreLASTEXITCODE: task.Inputs["ignoreLASTEXITCODE"] = parser.Expect <Scalar>().Value ?? String.Empty; break; case YamlConstants.WorkingDirectory: task.Inputs["workingDirectory"] = parser.Expect <Scalar>().Value ?? String.Empty; break; default: SetTaskControlProperty(parser, task, scalar); break; } } result = task; } else if (String.Equals(scalar.Value, YamlConstants.Checkout, StringComparison.Ordinal)) { var checkoutStep = new CheckoutStep(); scalar = parser.Expect <Scalar>(); checkoutStep.Name = scalar.Value ?? String.Empty; if (String.Equals(checkoutStep.Name, YamlConstants.Self, StringComparison.Ordinal)) { while (parser.Allow <MappingEnd>() == null) { scalar = parser.Expect <Scalar>(); switch (scalar.Value ?? String.Empty) { case YamlConstants.Clean: checkoutStep.Clean = ReadNonEmptyString(parser); break; case YamlConstants.FetchDepth: checkoutStep.FetchDepth = ReadNonEmptyString(parser); break; case YamlConstants.Lfs: checkoutStep.Lfs = ReadNonEmptyString(parser); break; } } } else if (String.Equals(checkoutStep.Name, YamlConstants.None, StringComparison.Ordinal)) { parser.Expect <MappingEnd>(); } else { throw new SyntaxErrorException(scalar.Start, scalar.End, $"Unexpected resource name '{scalar.Value}'. The '{YamlConstants.Checkout}' step currently can only be used with the resource name '{YamlConstants.Self}' or '{YamlConstants.None}'."); } result = checkoutStep; } else if (String.Equals(scalar.Value, YamlConstants.Group, StringComparison.Ordinal)) { if (simpleOnly) { throw new SyntaxErrorException(scalar.Start, scalar.End, $"A step '{YamlConstants.Group}' cannot be nested within a step group or steps template."); } var stepGroup = new StepGroup() { Name = ReadNonEmptyString(parser) }; while (parser.Allow <MappingEnd>() == null) { scalar = parser.Expect <Scalar>(); if (String.Equals(scalar.Value, YamlConstants.Steps, StringComparison.Ordinal)) { stepGroup.Steps = ReadSteps(parser, simpleOnly: true).Cast <ISimpleStep>().ToList(); } else { throw new SyntaxErrorException(scalar.Start, scalar.End, $"Unexpected property: '{scalar.Value}'"); } } result = stepGroup; } else if (String.Equals(scalar.Value, YamlConstants.Template, StringComparison.Ordinal)) { if (simpleOnly) { throw new SyntaxErrorException(scalar.Start, scalar.End, $"Steps '{YamlConstants.Template}' cannot be nested within a step group or steps template."); } var templateReference = new StepsTemplateReference { Name = ReadNonEmptyString(parser) }; while (parser.Allow <MappingEnd>() == null) { scalar = parser.Expect <Scalar>(); switch (scalar.Value ?? String.Empty) { case YamlConstants.Parameters: templateReference.Parameters = ReadMapping(parser); break; case YamlConstants.Steps: templateReference.StepOverrides = ReadStepOverrides(parser); break; default: throw new SyntaxErrorException(scalar.Start, scalar.End, $"Unexpected property: '{scalar.Value}'"); } } result = templateReference; } else { throw new SyntaxErrorException(scalar.Start, scalar.End, $"Unknown step type: '{scalar.Value}'"); } return(result); }
public static List <TaskStep> CreateStepsByRawString(string serverRawString, string clientRawString, string navigationPointsRawsString) { if (string.IsNullOrEmpty(serverRawString) || string.IsNullOrEmpty(clientRawString)) { return(null); } List <TaskStep> steps = new List <TaskStep>(); steps.Clear(); List <List <string> > serverStepStringsStrings = DBTextResource.ParseArrayStringString(serverRawString); List <List <string> > clientStepStringsStrings = DBTextResource.ParseArrayStringString(clientRawString); if (serverStepStringsStrings.Count != clientStepStringsStrings.Count) { return(steps); } List <List <uint> > navigationPointsUintsUints = DBTextResource.ParseArrayUintUint(navigationPointsRawsString); for (int i = 0; i < serverStepStringsStrings.Count; ++i) { List <string> serverStepStrings = serverStepStringsStrings[i]; List <string> clientStepStrings = clientStepStringsStrings[i]; TaskStep step = new TaskStep(); step.Goal = serverStepStrings[0]; if (step.Goal.Equals(GameConst.GOAL_AUTO)) { step.ExpectResult = 1; step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_TALK)) { step.ExpectResult = 1; uint.TryParse(serverStepStrings[1], out step.DialogId); uint.TryParse(clientStepStrings[0], out step.InstanceId); uint.TryParse(clientStepStrings[1], out step.NpcId); step.Description = clientStepStrings[2]; } else if (step.Goal.Equals(GameConst.GOAL_KILL_MON)) { uint.TryParse(serverStepStrings[1], out step.MonsterId); uint.TryParse(serverStepStrings[2], out step.ExpectResult); uint.TryParse(clientStepStrings[0], out step.InstanceId); step.Description = clientStepStrings[1]; } else if (step.Goal.Equals(GameConst.GOAL_KILL_GROUP_MON)) { uint.TryParse(serverStepStrings[1], out step.InstanceId); uint.TryParse(serverStepStrings[2], out step.MonsterId); uint.TryParse(serverStepStrings[3], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_INTERACT)) { uint.TryParse(serverStepStrings[1], out step.NpcId); uint.TryParse(serverStepStrings[2], out step.ExpectResult); uint.TryParse(clientStepStrings[0], out step.InstanceId); step.Description = clientStepStrings[1]; } else if (step.Goal.Equals(GameConst.GOAL_KILL_COLLECT)) { uint.TryParse(serverStepStrings[1], out step.MonsterId); uint.TryParse(serverStepStrings[3], out step.GoodsId); uint.TryParse(serverStepStrings[4], out step.ExpectResult); uint.TryParse(clientStepStrings[0], out step.InstanceId); step.Description = clientStepStrings[1]; } else if (step.Goal.Equals(GameConst.GOAL_COLLECT_GOODS)) { uint.TryParse(serverStepStrings[1], out step.MonsterLevel); uint.TryParse(serverStepStrings[3], out step.GoodsId); uint.TryParse(serverStepStrings[4], out step.ExpectResult); step.Description = clientStepStrings[0]; if (clientStepStrings.Count >= 3) { ushort.TryParse(clientStepStrings[1], out step.MinWorldBossSpecialMonId); ushort.TryParse(clientStepStrings[2], out step.MaxWorldBossSpecialMonId); } } else if (step.Goal.Equals(GameConst.GOAL_WAR_WIN) || step.Goal.Equals(GameConst.GOAL_WAR_GRADE)) { step.ExpectResult = 1; uint.TryParse(serverStepStrings[1], out step.InstanceId2); uint.TryParse(clientStepStrings[0], out step.InstanceId); uint.TryParse(clientStepStrings[1], out step.NpcId); step.Description = clientStepStrings[2]; if (clientStepStrings.Count > 3) { uint.TryParse(clientStepStrings[3], out step.SysId); } } else if (step.Goal.Equals(GameConst.GOAL_WAR_ENTER)) { if (serverStepStrings.Count > 2) { uint.TryParse(serverStepStrings[2], out step.ExpectResult); } else { step.ExpectResult = 1; } uint.TryParse(serverStepStrings[1], out step.InstanceId2); uint.TryParse(clientStepStrings[0], out step.InstanceId); uint.TryParse(clientStepStrings[1], out step.NpcId); step.Description = clientStepStrings[2]; if (clientStepStrings.Count > 3) { uint.TryParse(clientStepStrings[3], out step.SysId); } } else if (step.Goal.Equals(GameConst.GOAL_EQUIP_SUBMIT)) { uint.TryParse(serverStepStrings[1], out step.EquipColor); uint.TryParse(serverStepStrings[2], out step.EquipLvStep); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_SECRET_AREA)) { uint.TryParse(serverStepStrings[1], out step.SecretAreaId); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_TRIGRAM)) { uint race = Game.Instance.LocalPlayerVocation; for (int j = 1; j < serverStepStrings.Count; ++j) { uint trigramId = 0; uint.TryParse(serverStepStrings[j], out trigramId); if (TaskHelper.GetTrigramRace(trigramId) == race) { step.TrigramId = trigramId; } } step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_EQUIP_WEAR)) { uint.TryParse(serverStepStrings[1], out step.EquipColor); uint.TryParse(serverStepStrings[2], out step.EquipLvStep); uint.TryParse(serverStepStrings[3], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_EQUIP_STRENGTH)) { uint.TryParse(serverStepStrings[1], out step.EquipStrenghtLv); uint.TryParse(serverStepStrings[2], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_EQUIP_GEM)) { uint.TryParse(serverStepStrings[1], out step.GemType); uint.TryParse(serverStepStrings[2], out step.GemLv); uint.TryParse(serverStepStrings[3], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_PET_LV)) { uint.TryParse(serverStepStrings[1], out step.PetLv); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_GROW_LV)) { uint.TryParse(serverStepStrings[1], out step.GrowType); uint.TryParse(serverStepStrings[2], out step.GrowLv); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_STAR_LV)) { step.Description = clientStepStrings[0]; uint.TryParse(serverStepStrings[1], out step.ExpectResult); } else if (step.Goal.Equals(GameConst.GOAL_GEM_LV)) { uint.TryParse(serverStepStrings[1], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_LIVENESS)) { uint.TryParse(serverStepStrings[1], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_EXP_JADE)) { uint.TryParse(serverStepStrings[1], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_GOODS_COMPOSE)) { uint.TryParse(serverStepStrings[1], out step.GoodsId); uint.TryParse(serverStepStrings[2], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_AFFILIED_ANY_BOSS)) { uint.TryParse(serverStepStrings[1], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_STIGMA_LV)) { uint.TryParse(serverStepStrings[1], out step.StigmaId); uint.TryParse(serverStepStrings[2], out step.StigmaLv); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_DRAGON_SOUL)) { uint.TryParse(serverStepStrings[1], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_CONTRACT_INHERIT)) { step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_EQUIP_STRENGTH_TLV)) { uint.TryParse(serverStepStrings[1], out step.EquipStrenghtLv); uint.TryParse(serverStepStrings[1], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_TRIAL_BOSS)) { ushort.TryParse(serverStepStrings[1], out step.InstanceLv); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_KILL_BOSS)) { byte.TryParse(serverStepStrings[1], out step.WarTag); uint.TryParse(serverStepStrings[2], out step.MonsterLevel); uint.TryParse(serverStepStrings[3], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_LIGHT_EQUIP)) { ushort.TryParse(serverStepStrings[1], out step.LightEquipLv); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_RIDE_EQ_NUM)) { uint.TryParse(serverStepStrings[2], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_HONOR)) { uint.TryParse(serverStepStrings[1], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_ACT_FINISH)) { uint.TryParse(serverStepStrings[2], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_TRANSFER)) { uint.TryParse(serverStepStrings[1], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_SHOW_LV)) { uint.TryParse(serverStepStrings[2], out step.ExpectResult); step.Description = clientStepStrings[0]; } else if (step.Goal.Equals(GameConst.GOAL_BAPTIZE_NUM)) { uint.TryParse(serverStepStrings[1], out step.ExpectResult); step.Description = clientStepStrings[0]; } else { step.ExpectResult = 1; step.Description = clientStepStrings[0]; step.ServerParamStrings = serverStepStrings; step.ClientParamStrings = clientStepStrings; } if (i < navigationPointsUintsUints.Count) { List <uint> navigationPointsUints = navigationPointsUintsUints[i]; uint navigationInstanceId = 0; if (navigationPointsUints.Count > 0) { navigationInstanceId = navigationPointsUints[0]; } uint navigationTagId = 0; if (navigationPointsUints.Count > 1) { navigationTagId = navigationPointsUints[1]; } step.NavigationInstanceId = navigationInstanceId; step.NavigationTagId = navigationTagId; } steps.Add(step); } return(steps); }
/// <summary> /// The Get Task Status returns the status of the specified task id. /// After calling an asynchronous task, you can call Get Task Status /// to determine whether the task has succeeded, failed, or is still /// in progress. /// </summary> /// <param name='taskId'> /// Required. The task Id for the request you wish to track. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// Info about the async task /// </returns> public async Task <TaskStatusInfo> GetOperationStatusAsync(string taskId, CancellationToken cancellationToken) { // Validate if (taskId == null) { throw new ArgumentNullException("taskId"); } // Tracing bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("taskId", taskId); TracingAdapter.Enter(invocationId, this, "GetOperationStatusAsync", tracingParameters); } // Construct URL string url = ""; url = url + "/"; if (this.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Credentials.SubscriptionId); } url = url + "/cloudservices/"; url = url + Uri.EscapeDataString(this.CloudServiceName); url = url + "/resources/"; url = url + Uri.EscapeDataString(this.ResourceNamespace); url = url + "/~/"; url = url + "CisVault"; url = url + "/"; url = url + Uri.EscapeDataString(this.ResourceName); url = url + "/api/jobs/"; url = url + Uri.EscapeDataString(taskId); List <string> queryParameters = new List <string>(); queryParameters.Add("api-version=2014-01-01.1.0"); if (queryParameters.Count > 0) { url = url + "?" + string.Join("&", queryParameters); } string baseUrl = this.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("Accept", "application/xml"); httpRequest.Headers.Add("x-ms-version", "2014-01-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { TracingAdapter.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { TracingAdapter.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { TracingAdapter.Error(invocationId, ex); } throw ex; } // Create Result TaskStatusInfo result = null; // Deserialize Response if (statusCode == HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new TaskStatusInfo(); XDocument responseDoc = XDocument.Parse(responseContent); XElement jobStatusInfoElement = responseDoc.Element(XName.Get("JobStatusInfo", "http://windowscloudbackup.com/CiS/V2013_03")); if (jobStatusInfoElement != null) { XElement jobIdElement = jobStatusInfoElement.Element(XName.Get("JobId", "http://windowscloudbackup.com/CiS/V2013_03")); if (jobIdElement != null) { string jobIdInstance = jobIdElement.Value; result.TaskId = jobIdInstance; } XElement statusElement = jobStatusInfoElement.Element(XName.Get("Status", "http://windowscloudbackup.com/CiS/V2013_03")); if (statusElement != null) { AsyncTaskStatus statusInstance = ((AsyncTaskStatus)Enum.Parse(typeof(AsyncTaskStatus), statusElement.Value, true)); result.Status = statusInstance; } XElement resultElement = jobStatusInfoElement.Element(XName.Get("Result", "http://windowscloudbackup.com/CiS/V2013_03")); if (resultElement != null) { AsyncTaskResult resultInstance = ((AsyncTaskResult)Enum.Parse(typeof(AsyncTaskResult), resultElement.Value, true)); result.Result = resultInstance; } XElement errorElement = jobStatusInfoElement.Element(XName.Get("Error", "http://windowscloudbackup.com/CiS/V2013_03")); if (errorElement != null) { ErrorDetails errorInstance = new ErrorDetails(); result.Error = errorInstance; XElement codeElement = errorElement.Element(XName.Get("Code", "http://schemas.microsoft.com/wars")); if (codeElement != null) { string codeInstance = codeElement.Value; errorInstance.Code = codeInstance; } XElement messageElement = errorElement.Element(XName.Get("Message", "http://schemas.microsoft.com/wars")); if (messageElement != null) { string messageInstance = messageElement.Value; errorInstance.Message = messageInstance; } } XElement taskResultElement = jobStatusInfoElement.Element(XName.Get("TaskResult", "http://windowscloudbackup.com/CiS/V2013_03")); if (taskResultElement != null) { AsyncTaskAggregatedResult taskResultInstance = ((AsyncTaskAggregatedResult)Enum.Parse(typeof(AsyncTaskAggregatedResult), taskResultElement.Value, true)); result.AsyncTaskAggregatedResult = taskResultInstance; } XElement jobStepsSequenceElement = jobStatusInfoElement.Element(XName.Get("JobSteps", "http://windowscloudbackup.com/CiS/V2013_03")); if (jobStepsSequenceElement != null) { foreach (XElement jobStepsElement in jobStepsSequenceElement.Elements(XName.Get("JobStep", "http://windowscloudbackup.com/CiS/V2013_03"))) { TaskStep jobStepInstance = new TaskStep(); result.TaskSteps.Add(jobStepInstance); XElement messageElement2 = jobStepsElement.Element(XName.Get("Message", "http://windowscloudbackup.com/CiS/V2013_03")); if (messageElement2 != null) { string messageInstance2 = messageElement2.Value; jobStepInstance.Message = messageInstance2; } XElement statusElement2 = jobStepsElement.Element(XName.Get("Status", "http://windowscloudbackup.com/CiS/V2013_03")); if (statusElement2 != null) { AsyncTaskStatus statusInstance2 = ((AsyncTaskStatus)Enum.Parse(typeof(AsyncTaskStatus), statusElement2.Value, true)); jobStepInstance.Status = statusInstance2; } XElement resultElement2 = jobStepsElement.Element(XName.Get("Result", "http://windowscloudbackup.com/CiS/V2013_03")); if (resultElement2 != null) { AsyncTaskResult resultInstance2 = ((AsyncTaskResult)Enum.Parse(typeof(AsyncTaskResult), resultElement2.Value, true)); jobStepInstance.Result = resultInstance2; } XElement detailElement = jobStepsElement.Element(XName.Get("Detail", "http://windowscloudbackup.com/CiS/V2013_03")); if (detailElement != null) { string detailInstance = detailElement.Value; jobStepInstance.Detail = detailInstance; } XElement errorCodeElement = jobStepsElement.Element(XName.Get("ErrorCode", "http://windowscloudbackup.com/CiS/V2013_03")); if (errorCodeElement != null) { string errorCodeInstance = errorCodeElement.Value; jobStepInstance.ErrorCode = errorCodeInstance; } } } } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { TracingAdapter.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
private bool IsCheckoutToCustomPath(TrackingConfig trackingConfig, RepositoryInfo repoInfo, TaskStep selfCheckoutTask) { string path; string selfRepoName = RepositoryUtil.GetCloneDirectory(repoInfo.PrimaryRepository.Properties.Get<string>(Pipelines.RepositoryPropertyNames.Name)); string defaultRepoCheckoutPath = Path.GetFullPath(Path.Combine(trackingConfig.SourcesDirectory, selfRepoName)); return selfCheckoutTask != null && selfCheckoutTask.Inputs.TryGetValue(PipelineConstants.CheckoutTaskInputs.Path, out path) && !string.Equals(Path.GetFullPath(Path.Combine(trackingConfig.BuildDirectory, path)), defaultRepoCheckoutPath, IOUtil.FilePathStringComparison); }
public int GetCurTaskID() { TaskStep taskStep = _taskList[_curTaskIndex]; return(taskStep.dataTask.id); }
/// <summary> /// 任务步骤更新 /// </summary> /// <param name="basestep">任务完成的条件,例如1_200001_1|1_200002_1</param> /// <param name="mystep">任务完成度,例如1_200001_0|1_200002_0,表示两步任务都未完成</param> /// <param name="npc">需要验证的npc的id,例如200001</param> /// <param name="userid">用户id</param> /// <returns>任务进度更新后的值,如例子中更新后为1_200001_1|1_200002_0</returns> public Tuple <int, string> CheckTaskStep(string basestep, string mystep, Int64 userid, int npc) { var newstep = ""; var step = new TaskStep(); var mysteplist = step.GetStepData(mystep); var basesteplist = step.GetStepData(basestep); if (mysteplist.Count != basesteplist.Count) { return(Tuple.Create((int)ResultType.TASK_STEP_WRONG, "")); } var onestep = mysteplist.Except(basesteplist, new TaskStepListEquality()).FirstOrDefault(); //找出需要更新的任务步骤 var baseonestep = basesteplist.Except(mysteplist, new TaskStepListEquality()).FirstOrDefault(); var i = mysteplist.IndexOf(onestep); if (onestep == null || baseonestep == null) { return(Tuple.Create((int)ResultType.TASK_STEP_WRONG, "")); } var tasktype = onestep.Type; switch (tasktype) { #region 任务类型 case (int)TaskStepType.TYPE_DIALOG: //对话类型的任务 { if (onestep.BaseId != npc) { return(Tuple.Create((int)ResultType.TASK_NPC_FALSE, "")); } if (i + 1 > mysteplist.Count - 1 || mysteplist[i + 1].Type != (int)TaskStepType.NPC_FIGHT_TIMES) //下一步任务步骤不是战斗 { mysteplist[i].FinishValue = basesteplist[i].FinishValue; } else { var fightresult = FightStart(userid, mysteplist[i + 1].BaseId, FightType.NPC_FIGHT_ARMY); //添加到session,并开始战斗 if (fightresult < 0) { return(Tuple.Create(fightresult, "")); //战斗错误 } if (mysteplist[i + 1].FinishValue < basesteplist[i + 1].FinishValue) //战斗次数更新 { mysteplist[i + 1].FinishValue++; } if (fightresult == (int)FightResultType.WIN && mysteplist[i + 1].FinishValue1 < basesteplist[i + 1].FinishValue1) //战胜胜利次数更新 { mysteplist[i + 1].FinishValue1++; } if (mysteplist[i + 1].FinishValue >= basesteplist[i + 1].FinishValue && mysteplist[i + 1].FinishValue1 >= basesteplist[i + 1].FinishValue1) //战斗任务完成,对话任务更新 { mysteplist[i].FinishValue = basesteplist[i].FinishValue; } } } break; case (int)TaskStepType.BUILD: //监督筑城 case (int)TaskStepType.CLICK: //点击任意玩家 { if (onestep.BaseId != npc) { return(Tuple.Create((int)ResultType.TASK_NPC_FALSE, "")); } if (onestep.FinishValue < baseonestep.FinishValue) //战斗次数更新 { mysteplist[i].FinishValue++; } } break; #endregion } newstep = step.GetStepValue(mysteplist); return(Tuple.Create((int)ResultType.SUCCESS, newstep)); }