public bool SaveResult(string userId, TestResult result, out string error) { var user = _dataContext.Users.Where(u => u.Id == Guid.Parse(userId)).FirstOrDefault(); if (user.Equals(null)) { error = "User not found"; return(false); } var user_result = new UserResults { User = user, Result = result.SocType }; _dataContext.UserResults.Add(user_result); try { _dataContext.SaveChanges(); } catch (DbUpdateException ex) { error = ex.Message; return(false); } error = null; return(true); }
private async Task SearchAllResultAsync() { var netWorkDataResult = await this._netWorkServices.GetAsync <SearchResultModel>("Search", "Search", new { keyWord = KeyWord, Global.Enums.SearchResultType.All, limit = Settings.Default.LimitPerPage }); if (netWorkDataResult.Successed) { var temp = netWorkDataResult.Data; this._tabKeyAndTotal["1"] = temp.Musics.Key; this._tabKeyAndTotal["2"] = temp.Artists.Key; this._tabKeyAndTotal["3"] = temp.Albums.Key; this._tabKeyAndTotal["4"] = temp.Mvs.Key; this._tabKeyAndTotal["5"] = temp.PlayLists.Key; this._tabKeyAndTotal["6"] = temp.Radios.Key; this._tabKeyAndTotal["7"] = temp.Users.Key; await Task.WhenAll(MusicResults.AddRangeAsync(temp.Musics.Value), ArtistResults.AddRangeAsync(temp.Artists.Value), AlbumResults.AddRangeAsync(temp.Albums.Value), MvResults.AddRangeAsync(temp.Mvs.Value), UserResults.AddRangeAsync(temp.Users.Value), PlayListResults.AddRangeAsync(temp.PlayLists.Value)); this._tabKeyAndOffset["1"] = 0; this._tabKeyAndOffset["2"] = 0; this._tabKeyAndOffset["3"] = 0; this._tabKeyAndOffset["4"] = 0; this._tabKeyAndOffset["5"] = 0; this._tabKeyAndOffset["6"] = 0; this._tabKeyAndOffset["7"] = 0; } else { //todo 网络连接失败 } }
private void CreateRows(UserResults userResults) { RowItem rowUserName = Instantiate(RowUserNamePrefab.gameObject).GetComponent <RowItem>(); rowUserName.Init(); rowUserName.TxtCols[0].text = userResults.UserName; m_Rows.Add(rowUserName); rowUserName.transform.SetParent(m_PnlVerticalGroup); rowUserName.transform.localScale = Vector3.one; int i = 0; userResults.Results.ForEach(result => { RowItem rowResult = Instantiate(RowResultPrefab.gameObject).GetComponent <RowItem>(); rowResult.Init(); rowResult.TxtCols[0].text = result.Date; rowResult.TxtCols[1].text = result.Person; rowResult.TxtCols[2].text = result.ResultValue; rowResult.ImgBg.enabled = (i % 2) == 0; m_Rows.Add(rowResult); rowResult.transform.SetParent(m_PnlVerticalGroup); rowResult.transform.localScale = Vector3.one; i++; }); }
/// <summary> /// Показать. /// </summary> public void Show(UsersResults usersResults, string topUser) { if (m_Rows == null) { m_Rows = new List <RowItem>(); } else { m_Rows.ForEach(item => Destroy(item.gameObject)); m_Rows.Clear(); } gameObject.SetActive(true); UserResults ur = usersResults.Results.Find(r => r.UserName == topUser); if (ur != null) { CreateRows(ur); } usersResults.Results.FindAll(r => r.UserName != topUser).ForEach(userResults => { CreateRows(userResults); }); }
/// <summary> /// Перезапуск приложения. /// </summary> public void Restart() { if (VuforiaBehaviour.Instance.enabled) { VuforiaBehaviour.Instance.enabled = false; } CurrentTaskID = 0; AnswerAttempt = 0; m_UserResults = null; }
public ActionResult GetCustomers(CustomersFilter filters) { using (DellAppDB db = new DellAppDB()) { UserResults userResult = new UserResults(); userResult.UserSys = db.UserSys.Where(p => p.Email.Equals(User.Identity.Name)).FirstOrDefault(); if (userResult.UserSys.UserRoleId == 1) { userResult.Customers = db.Customer.ToList(); } return(View(userResult)); } }
//Search public async Task <JsonResult> Search(UserSearchQuery model) { var result = new UserResults(); try { var response = await userService.GetAllAsync(model); result.Users = response.Users; result.Total = response.Total; } catch (Exception e) { Console.WriteLine(e); throw; } return(Json(result, JsonRequestBehavior.AllowGet)); }
//I don't entirely understand this but it seems to put this script in a waiting state until the json exists IEnumerator ReadFile() { //yield return new WaitUntil(() => !IsFileReady("Passin.json")); yield return(new WaitUntil(() => IsFileReady("Passout.json"))); string message = ""; while (!IsFileReady("Passout.json")) { } while (message.Length == 0) { message = File.ReadAllText("Passout.json"); } if (message != null) { UserResults ur = JsonUtility.FromJson <UserResults>(message); while (File.Exists("Passout.json")) { File.Delete("Passout.json"); } if (ur.Result) { UserInfo.SignedIn = true; if (isLogin) { PlayerInventory.Inventory = JsonUtility.FromJson <ListWrapper>(ur.Userinventory); } Debug.Log("Signed In: " + UserInfo.SignedIn); SceneManager.LoadScene(1); } else { ErrorResults.text = ur.Comment; } } }
//I don't entirely understand this but it seems to put this script in a waiting state until the json exists IEnumerator ReadSaveFile() { yield return(new WaitUntil(() => IsFileReady(UserInfo.SignedInUser + "Result.json"))); string message = ""; while (!IsFileReady(UserInfo.SignedInUser + "Result.json")) { } while (message.Length == 0) { message = File.ReadAllText(UserInfo.SignedInUser + "Result.json"); } if (message != null) { UserResults ur = JsonUtility.FromJson <UserResults>(message); while (File.Exists(UserInfo.SignedInUser + "Result.json")) { File.Delete(UserInfo.SignedInUser + "Result.json"); } UserInfo.SaveResult = ur.Result; } }
private async void SearchResultNextPageCommandExecute(string tabKey) { if (this._tabKeyAndOffset.ContainsKey(tabKey)) { this._nextPageCancel?.Cancel(); var newCancel = new CancellationTokenSource(); this._nextPageCancel = newCancel; if (Settings.Default.LimitPerPage * (_tabKeyAndOffset[tabKey] + 1) < _tabKeyAndTotal[tabKey]) { try { var netWorkDataResult = await this._netWorkServices.GetAsync <SearchResultModel>("Search", "Search", new { KeyWord, SearchResultType = this._tabKeyAndType[tabKey], limit = Settings.Default.LimitPerPage, offset = ++this._tabKeyAndOffset[tabKey] }); if (!netWorkDataResult.Successed) { //todo 网络连接失败 throw new OperationCanceledException(); } var temp = netWorkDataResult.Data; switch (_tabKeyAndType[tabKey]) { case Global.Enums.SearchResultType.Music: this.MusicResults.AddRange(temp.Musics.Value); break; case Global.Enums.SearchResultType.Artist: ArtistResults.AddRange(temp.Artists.Value); break; case Global.Enums.SearchResultType.Album: AlbumResults.AddRange(temp.Albums.Value); break; case Global.Enums.SearchResultType.PlayList: PlayListResults.AddRange(temp.PlayLists.Value); break; case Global.Enums.SearchResultType.User: UserResults.AddRange(temp.Users.Value); break; case Global.Enums.SearchResultType.MV: MvResults.AddRange(temp.Mvs.Value); break; case Global.Enums.SearchResultType.Radio: break; default: break; } } catch (OperationCanceledException) { } } if (newCancel == this._nextPageCancel) { this._nextPageCancel = null; } } }
private void cmb_SelectUserReport_SelectedIndexChanged(object sender, EventArgs e) { string Username = cmb_SelectUserReport.Text; int SelectedIndex = cmb_SelectUserReport.SelectedIndex; listView_UserReports.Items.Clear(); listView_AttitudeReports.Items.Clear(); if (Username == "*" || SelectedIndex == -1) { return; } UserModelDataTransferObject SelectedUser; using (UserController userController = new UserController()) SelectedUser = userController.GetUserByName(Username); long UserID = SelectedUser.UserID; List <Result> UserResults; using (ResultController resultController = new ResultController()) UserResults = resultController.GetForUser(UserID); UserResults = UserResults.OrderBy(r => r.SurveyID).ThenByDescending(r => r.Date).ToList(); SurveyController surveyController = new SurveyController(); foreach (Result result in UserResults) { string SurveyName = surveyController.Get(result.SurveyID).SurveyName; listView_UserReports.Items.Add(new ListViewItem(listView_UserReports.Groups["default"]) { Text = result.ToString(), Tag = result.ResultID }); } //Get list of lastest User Reports List <long> UsedSurveyID = new List <long>(); List <Result> LastUserReports = new List <Result>(); foreach (Result result in UserResults) { if (!UsedSurveyID.Contains(result.SurveyID)) { UsedSurveyID.Add(result.SurveyID); LastUserReports.Add(result); } } UsedSurveyID = null; //Calculate Attitude Score using (AttitudeController attitudeController = new AttitudeController()) using (AttitudeDefinitionController attitudeDefinitionController = new AttitudeDefinitionController()) using (ResultDefinitionController resultDefinitionController = new ResultDefinitionController()) { List <Attitude> attitudes = attitudeController.GetAttitudes(); listView_AttitudeReports.Items.Clear(); foreach (Attitude attitude in attitudes) { long AttitudeSum = 0; bool Found = false; List <AttitudeDefinition> attitudeDefinitions = attitudeDefinitionController.GetRelation(attitude.AttitudeID); foreach (AttitudeDefinition attitudeDefinition in attitudeDefinitions) { long QuestionID = attitudeDefinition.QuestionID; foreach (Result result in LastUserReports) { List <ResultDefinition> resultDefinitions = resultDefinitionController.Get(result.ResultID); Found = false; foreach (ResultDefinition resultDefinition in resultDefinitions) { if (resultDefinition.QuestionID == QuestionID) { AttitudeSum += resultDefinition.ResultAnswer; Found = true; break; } } if (Found) { break; } } string SurveyName = surveyController.GetByQuestion(QuestionID).SurveyName; if (!Found) { listView_AttitudeReports.Items.Add( new ListViewItem(listView_AttitudeReports.Groups["default"]) { ForeColor = Color.Red, Text = attitude.AttitudeName + " - requires '" + SurveyName + "'", Tag = attitude.AttitudeID }); break; } } if (Found) { listView_AttitudeReports.Items.Add( new ListViewItem(listView_AttitudeReports.Groups["default"]) { Text = attitude.AttitudeName + " - " + AttitudeSum, Tag = attitude.AttitudeID }); } } } }