private async Task <List <CommonLibrary.DatabaseModels.Task> > GenerateTrack(ChoiceCategory choice, HttpClient client, CreateTask createTask, CommonLibrary.Clients.Model.User user) { var res = await client.PostAsJsonAsync($"{consulWrapper["track-api"]["Scenerios"]}/sql", choice); var open = await res.Content.ReadAsAsync <Scenerio>(); if (open == null) { res = await client.PostAsJsonAsync($"{consulWrapper["track-api"]["Scenerios"]}/sql", new ChoiceCategory { CategoryType = 1058, ViewCategory = 565, Category = 801 }); open = await res.Content.ReadAsAsync <Scenerio>(); } var tasks = new List <CommonLibrary.DatabaseModels.Task>(); foreach (var track in open.ScenerioTasks.Select(x => x.Track)) { var task = new CommonLibrary.DatabaseModels.Task { Name = createTask.Name, Category = open.CategoryID, Creator = user.ID, Description = createTask.Data, Scenario = open.ID, Type = open.TypeID, Email = user.Email, ChangeLogs = new List <ChangeLog>() }; var actionFirst = track.ActionInTracks.OrderBy(x => x.ID).First(); task.ChangeLogs.Add(new ChangeLog { Creator = user.ID, Action = actionFirst.Action.ID, Task = task, DateTime = DateTime.Now }); tasks.Add(task); context.Add(task); context.SaveChanges(); await SendEmail(task, actionFirst.Action, AdressType.New); } return(tasks); }
public void ResetAllChoices() { /* Local */ type = null; finalChoice = null; choice = 4; /* in scriptableObject */ // TODO: MOVE LOGIC TO SCRIPTABLE OBJECT runtimeChoiceManager.ResetRun(); }
public async System.Threading.Tasks.Task <List <int> > Create(CreateTask createTask) { if (!this.IsAuth()) { return(null); } var user = this.GetUserByToken(this.Token()); List <CommonLibrary.DatabaseModels.Task> tasks = new List <CommonLibrary.DatabaseModels.Task>(); using (var client = new HttpClient()) { try { var res = await client.GetAsync($"{consulWrapper["recognition-api"]["Recognition"]}/ChoiceCategory?data={createTask.Data}"); ChoiceCategory choice = await res.Content.ReadAsAsync <ChoiceCategory>(); tasks.AddRange(await GenerateTrack(choice, client, createTask, user)); } catch (Exception) { } client.DefaultRequestHeaders.Add("token", this.Login("qwer")); var userRes = await client.GetAsync("http://172.20.10.6:8000/api/Users?role=worker"); var users = await userRes.Content.ReadAsAsync <List <CommonLibrary.Clients.Model.User> >(); foreach (var task in tasks) { int actionID = task.ChangeLogs.First().Action; var action = await NetworkMethodModel.Get <CommonLibrary.DatabaseModels.Action>(consulWrapper["track-api"]["Actions"], actionID); if (action.IsAuto) { if (AutoWorker.HandlerTask(task, action, users)) { await Save(task); await ToNextState(task.ID, true); } } } return(tasks.Select(x => x.ID).ToList()); } }
void ConvertChoiceToGameObject(int choice, string choiceType) { int indexMaximum; // how many things can you choose from switch (choiceType) { case "Item": //type = item; indexMaximum = 2; break; case "Character": type = character; goto default; case "Minion": type = minion; goto default; case "Modifier": type = modifier; goto default; case "Theme": type = theme; goto default; default: // Character, Minion, Modifier, Theme indexMaximum = 3; break; } switch (choice) { case 1: finalChoice = type.Options[choice - 1]; break; case 2: finalChoice = type.Options[choice - 1]; break; case 3: if (indexMaximum == 3) { finalChoice = type.Options[choice - 1]; } else { goto default; } break; default: choice = Random.Range(1, indexMaximum + 1); finalChoice = type.Options[choice - 1]; this.choice = choice; break; } StartCoroutine(LockAfterDelay()); }
public async Task <ActionResult <Scenerio> > GetByChoice(ChoiceCategory sql) { return(await context.Scenerios.FirstOrDefaultAsync(x => x.CategoryID == sql.Category && x.TypeID == sql.CategoryType && x.ViewCategoryID == sql.ViewCategory)); }