public ActionResult Checkin([FromBody]CheckinVM checkin) { Console.WriteLine(checkin != null); Console.WriteLine(checkin.resource.author.uniqueName); var username = SuperDataBase.Configs.GetRealUserName(checkin.resource.author.uniqueName); var display = SuperDataBase.Configs.GetDisplayName(username); if (username == null || display == null) return Ok("no user"); var actionPart1 = SuperDataBase.Actions.SpeakActions.Where(x => x.Name.StartsWith("TCheckinFirst")).GetRandom().DeepCopy(); var actionPart2 = SuperDataBase.Actions.SpeakActions.Where(x => x.Name.StartsWith("TCheckinLast")).GetRandom().DeepCopy(); var actionMove = SuperDataBase.Actions["B" + username]; actionPart2.Text = actionPart2.Text.Replace("{userdisplay}", display) .Replace("{comment}", checkin.resource.comment); var seq = new SequenceAction(); seq.AddPararellActions(actionPart1); seq.AddPararellActions(actionMove); seq.AddPararellActions(actionPart2); SuperDataBase.Queue.Add(new ActionContainer(seq)); return Ok("queued"); }
public ActionResult Build([FromBody]BuildVM build) { Console.WriteLine(build != null); var username = SuperDataBase.Configs.GetRealUserName(build.resource.lastChangedBy.uniqueName) ?? SuperDataBase.Configs.GetRealUserName(build.resource.requestedFor.uniqueName) ?? SuperDataBase.Configs.GetRealUserName(build.resource.requestedBy.uniqueName); var display = SuperDataBase.Configs.GetDisplayName(username); if (username == null || display == null) return Ok("no user"); var branch = build.resource.sourceBranch.Split('/').Last(); var part1name = build.resource.result.Equals("succeeded") ? "TBuildSuccessFirst" : "TBuildFailFirst"; var part2name = build.resource.result.Equals("succeeded") ? "TBuildSuccessLast" : "TBuildFailLast"; var actionPart1 = SuperDataBase.Actions.SpeakActions.Where(x => x.Name.StartsWith(part1name)) .GetRandom() .DeepCopy(); var actionPart2 = SuperDataBase.Actions.SpeakActions.Where(x => x.Name.StartsWith(part2name)) .GetRandom() .DeepCopy(); var actionMove = SuperDataBase.Actions["B" + username]; actionPart1.Text = actionPart1.Text.Replace("{branch}", branch); actionPart2.Text = actionPart2.Text.Replace("{userdisplay}", display); var seq = new SequenceAction(); seq.AddPararellActions(actionPart1); seq.AddPararellActions(actionMove); seq.AddPararellActions(actionPart2); SuperDataBase.Queue.Add(new ActionContainer(seq)); return Ok("queued"); }
public RedirectToActionResult Configs(Configs configs) { configs.UserNamesToUserName.RemoveAll(x => string.IsNullOrEmpty(x.From) || string.IsNullOrEmpty(x.To)); configs.UserNameToDisplayName.RemoveAll(x => string.IsNullOrEmpty(x.From) || string.IsNullOrEmpty(x.To)); SuperDataBase.Configs = configs; var actionIPT = SuperDataBase.Actions.SpeakActions.Where( x => x.Name.StartsWith(configs.IPT >= configs.IPTGoodLimit ? "TGoodMark" : "TBadMark")).GetRandom().DeepCopy(); var actionIET = SuperDataBase.Actions.SpeakActions.Where( x => x.Name.StartsWith(configs.IET <= configs.IETGoodLimit? "TGoodMark" : "TBadMark")).GetRandom().DeepCopy(); actionIET.Text = actionIET.Text.Replace("{current}", configs.IET.ToString()).Replace("{mark}", "erros"); actionIPT.Text = actionIPT.Text.Replace("{current}", configs.IPT.ToString()).Replace("{mark}", "produtividade"); SuperDataBase.Actions.SequenceActions.RemoveAll(x => x.Name.Equals("SMarks")); var actionMarks = new SequenceAction("SMarks"); actionMarks.AddPararellActions(actionIET); actionMarks.AddPararellActions(new SavedAction("Rest")); actionMarks.AddPararellActions(actionIPT); SuperDataBase.Actions.SequenceActions.Add(actionMarks); SuperDataBase.Actions.SequenceActions.RemoveAll(x => x.Name.Equals("SRD")); var actionRD = new SequenceAction("SRD"); actionRD.AddPararellActions(SuperDataBase.Actions.SpeakActions.Where(x=>x.Name.StartsWith("TMorningTeam")).GetRandom()); actionRD.AddPararellActions(new SavedAction("Rest")); actionRD.AddPararellActions(actionIET); actionRD.AddPararellActions(new SavedAction("Rest")); actionRD.AddPararellActions(actionIPT); actionRD.AddPararellActions(new SavedAction("Rest")); actionRD.AddPararellActions(SuperDataBase.Actions.SpeakActions.Where(x => x.Name.StartsWith("TTip")).GetRandom()); SuperDataBase.Actions.SequenceActions.Add(actionRD); SuperDataBase.SaveConfigs(); SuperDataBase.SaveActions(); return RedirectToAction("Configs"); }