private StackPanel MakeAnalyzerInfoArea(string message, EvaluationData dropData, bool after) { StackPanel stackPanel = new StackPanel(); if (dropData.DroppingDone) { // data about drop string infotxt = ""; string detRule = DropCriterion.ToString(dropData.DeterminativeCriterion.Type); infotxt = ListUsedCriteria(dropData); stackPanel.Children.Add(MakeMakeAnalyzerInfoLabel(message + " by " + detRule + ": " + DropCriterion.ToString(dropData.Side).ToUpper() + " with Quality: " + Math.Round(dropData.DroppingQuality, 3))); stackPanel.Children.Add(MakeMakeAnalyzerInfoLabel("Criteria: " + infotxt)); } else { if (after) { stackPanel.Children.Add(MakeMakeAnalyzerInfoLabel(message + " with Overall Quality: " + Math.Round(dropData.Evaluation.EvaluationQuality, 3))); } else { stackPanel.Children.Add(MakeMakeAnalyzerInfoLabel(message)); } } return(stackPanel); }
public EvaluationData CreateOrUpdate(int gameId, int actorId, string key, long quantity) { EvaluationData resource; var resources = Get(gameId, actorId, new[] { key }); if (resources.Any()) { var existingResource = GetSingleResourceFromList(resources); resource = AddQuantity(existingResource.Id, quantity); } else { resource = new EvaluationData { GameId = gameId, ActorId = actorId, Key = key, Value = quantity.ToString(), EvaluationDataType = EvaluationDataType.Long, Category = EvaluationDataCategory.Resource, }; Create(resource); } return(resource); }
/* * IMAGE MODERATION * This example moderates images from URLs. */ public static void ModerateImages(ContentModeratorClient client, string urlFile, string outputFile) { Console.WriteLine("--------------------------------------------------------------"); Console.WriteLine(); Console.WriteLine("IMAGE MODERATION"); Console.WriteLine(); // Create an object to store the image moderation results. List <EvaluationData> evaluationData = new List <EvaluationData>(); using (client) { // Read image URLs from the input file and evaluate each one. using (StreamReader inputReader = new StreamReader(urlFile)) { while (!inputReader.EndOfStream) { string line = inputReader.ReadLine().Trim(); if (line != String.Empty) { Console.WriteLine("Evaluating {0}...", Path.GetFileName(line)); var imageUrl = new BodyModel("URL", line.Trim()); var imageData = new EvaluationData { ImageUrl = imageUrl.Value, // Evaluate for adult and racy content. ImageModeration = client.ImageModeration.EvaluateUrlInput("application/json", imageUrl, true) }; Thread.Sleep(1000); // Detect and extract text. imageData.TextDetection = client.ImageModeration.OCRUrlInput("eng", "application/json", imageUrl, true); Thread.Sleep(1000); // Detect faces. imageData.FaceDetection = client.ImageModeration.FindFacesUrlInput("application/json", imageUrl, true); Thread.Sleep(1000); // Add results to Evaluation object evaluationData.Add(imageData); } } } // Save the moderation results to a file. using (StreamWriter outputWriter = new StreamWriter(outputFile, false)) { outputWriter.WriteLine(JsonConvert.SerializeObject( evaluationData, Formatting.Indented)); outputWriter.Flush(); outputWriter.Close(); } Console.WriteLine(); Console.WriteLine("Image moderation results written to output file: " + outputFile); Console.WriteLine(); } }
public void ThreatCountTest() { var board = new FastBoardNode(); var evalData = new EvaluationData(); board[new Index(5, 'E')] = (Team.White, FastPiece.King); evalData.Prepare(board); Assert.That(evalData.White.Threats.Count, Is.EqualTo(6)); Assert.That(evalData.Black.Threats.Count, Is.EqualTo(0)); board[new Index(5, 'E')] = (Team.White, FastPiece.Knight); evalData.Prepare(board); Assert.That(evalData.White.Threats.Count, Is.EqualTo(12)); Assert.That(evalData.Black.Threats.Count, Is.EqualTo(0)); board[new Index(5, 'E')] = (Team.Black, FastPiece.Squire); evalData.Prepare(board); Assert.That(evalData.White.Threats.Count, Is.EqualTo(0)); Assert.That(evalData.Black.Threats.Count, Is.EqualTo(6)); board[new Index(5, 'E')] = (Team.Black, FastPiece.Pawn); evalData.Prepare(board); Assert.That(evalData.White.Threats.Count, Is.EqualTo(0)); Assert.That(evalData.Black.Threats.Count, Is.EqualTo(2)); board[new Index(5, 'E')] = (Team.None, FastPiece.Pawn); board[new Index(1, 'D')] = (Team.Black, FastPiece.Pawn); evalData.Prepare(board); Assert.That(evalData.White.Threats.Count, Is.EqualTo(0)); Assert.That(evalData.Black.Threats.Count, Is.EqualTo(0)); }
public EvaluationData Get(int gameId, int actorId, string key, EvaluationDataType dataType, LeaderboardType sortType) { if (((int)sortType == 3 && ((int)dataType == 1 || (int)dataType == 2)) || ((int)sortType < 3 && ((int)dataType == 0 || (int)dataType == 3))) { throw new ArgumentException($"Cannot get EvaluationData for LeaderboardType {sortType} and EvaluationDataType {dataType} as it would always return zero results."); } EvaluationData data = null; string value = null; switch (sortType) { case LeaderboardType.Highest: TryGetMax(gameId, actorId, key, out data, dataType); break; case LeaderboardType.Lowest: TryGetMin(gameId, actorId, key, out data, dataType); break; case LeaderboardType.Cumulative: switch (dataType) { case EvaluationDataType.Long: value = SumLong(gameId, actorId, key).ToString(CultureInfo.InvariantCulture); break; case EvaluationDataType.Float: value = SumFloat(gameId, actorId, key).ToString(CultureInfo.InvariantCulture); break; } break; case LeaderboardType.Count: value = CountKeys(gameId, actorId, key, dataType).ToString(CultureInfo.InvariantCulture); break; case LeaderboardType.Earliest: TryGetEarliest(gameId, actorId, key, out data, dataType); break; case LeaderboardType.Latest: TryGetLatest(gameId, actorId, key, out data, dataType); break; } if (data == null) { data = new EvaluationData { ActorId = actorId, GameId = gameId, Category = _category, EvaluationDataType = dataType, Key = key, Value = value }; } return(data); }
public static string EvaluateImage(string urlToProcess) { var client = Clients.NewClient(); EvaluationData imageData = ImageToText.EvaluateImage(client, urlToProcess); return(imageData.TextDetection.Text); }
private static void ValidateData(EvaluationData data) { if (data.MatchId == null) { throw new InvalidDataException("Cannot save Match data with no EntityId. EntityId needs to be set to the match's Id."); } }
public void SetData(EvaluationData data) { if (Date != null) { Date.text = data.GetDate(); } Title.text = data.GetTraining(); if (SubTitle != null) { SubTitle.text = data.GetAngle(); } for (int i = 0; i < Starlist.Count; i++) { var img = Starlist[i]; if (data.StarCount > i) { CommonFunc.SetImageFile("star", ref img); } else { CommonFunc.SetImageFile("star_empty", ref img); } } Msg.text = data.Msg; }
public static void HandleDetatchedEvaluationData(this SUGARContext context, EvaluationData evaluationData) { if (evaluationData != null && context.Entry(evaluationData).State == EntityState.Detached) { context.EvaluationData.Attach(evaluationData); } }
public HomeController(ILogger <HomeController> logger, [FromServices] EnvReader envReader, [FromServices] EvaluationData evaluationData, [FromServices] EmailService emailService) { _logger = logger; _envReader = envReader; _evaluationData = evaluationData; _emailService = emailService; }
public void OnClickOK() { Action la = () => { EvaluationData eData = null; if (TrainingType == CommonData.TRAINING_TYPE.TRAINING_POSE) { var dic = new Dictionary <CommonData.TRAINING_ANGLE, int>(); var e = AngleTypeList.GetEnumerator(); while (e.MoveNext()) { dic.Add(e.Current.Key, e.Current.Value); } eData = new EvaluationData( DateTime.Now.Ticks, CommonData.TRAINING_TYPE.TRAINING_POSE, TrainingCount, PoseType, dic, StarCount, Msg.text.ToString()); TKManager.Instance.Mydata.AddEvaluationData(eData); } else { eData = new EvaluationData( DateTime.Now.Ticks, CommonData.TRAINING_TYPE.TRAINING_TEMPO, TrainingCount, StarCount, Msg.text.ToString()); TKManager.Instance.Mydata.AddEvaluationData(eData); } FirebaseManager.Instance.SetEvaluationData(eData, () => { FirebaseManager.Instance.FirebaseLoadWait = false; }); }; Action ca = () => { TKManager.Instance.Mydata.AddSeasonPoint(TrainingPoint); TKManager.Instance.SaveFile(); PopupMgr.Instance.DismissPopup(); }; StartCoroutine(FirebaseManager.Instance.LoadingData(la, ca)); if (EndAction != null) { EndAction(); } }
public bool TryGetEarliest(int gameId, int actorId, string key, out EvaluationData earliest, EvaluationDataType evaluationDataType, DateTime?start = null, DateTime?end = null) { var didGetEarliest = _evaluationDataDbController.TryGetEarliest(gameId, actorId, key, out earliest, evaluationDataType, start, end); _logger.LogDebug($"Earliest {earliest?.ToString() ?? "Null"} for: GameId: {gameId}, ActorId {actorId}, Key: {key}, EvaluationDataType: {evaluationDataType}, Start: {start}, End: {end}"); return(didGetEarliest); }
public bool TryGetMin(int gameId, int actorId, string key, out EvaluationData value, EvaluationDataType evaluationDataType, DateTime?start = null, DateTime?end = null) { var dataFound = _evaluationDataDbController.TryGetMin(gameId, actorId, key, out value, evaluationDataType, start, end); _logger.LogDebug($"Lowest: {value?.ToString() ?? "Null"} for: GameId: {gameId}, ActorId {actorId}, Key: {key}, EvaluationDataType: {evaluationDataType}, Start: {start}, End: {end}"); return(dataFound); }
public void Remove(EvaluationData data) { using (var context = ContextFactory.Create()) { context.EvaluationData.Remove(data); context.SaveChanges(); } }
public EvaluationController(ILogger <EvaluationController> logger, [FromServices] EnvReader envReader, [FromServices] EvaluationData evaluationData, [FromServices] EmailService emailService, ZhaoContext context, UserManager <IdentityUser> userManager) { _logger = logger; _envReader = envReader; _evaluationData = evaluationData; _emailService = emailService; _context = context; _userManager = userManager; }
private bool IsMatch(EvaluationData lhs, EvaluationData rhs) { return(lhs.ActorId == rhs.ActorId && lhs.GameId == rhs.GameId && lhs.Category == rhs.Category && lhs.EvaluationDataType == rhs.EvaluationDataType && lhs.Key == rhs.Key && lhs.Value == rhs.Value); }
public EvaluationData Update(EvaluationData updatedData) { using (var context = ContextFactory.Create()) { context.EvaluationData.Update(updatedData); context.SaveChanges(); return(updatedData); } }
public EvaluationData Update(EvaluationData data) { ValidateData(data); data = _evaluationDataDbController.Update(data); _logger.LogInformation($"Updated: {data?.Id}"); return(data); }
private void OnEvaluationDataAdded(EvaluationData evaluationData) { if (_EvaluationDataToEvaluationMapper.TryGetRelated(evaluationData, out var evaluations)) { var gameIds = GetGameIdsFromEvaluations(evaluations); var sessions = _sessionTracker.GetByGames(gameIds); var progress = _progressEvaluator.EvaluateSessions(sessions, evaluations); _progressNotificationCache.Update(progress); } }
// searching and filtering on the basis of name private void textBoxSearch_TextChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(textBoxSearch.Text)) { EvaluationData.DataSource = null; EvaluationData.Rows.Clear(); EvaluationData.Columns.Clear(); dataTable = new DataTable(); SqlConnection conn = new SqlConnection(conURL); conn.Open(); String str = "SELECT * FROM Evaluation where Name = @Name"; SqlCommand cmd = new SqlCommand(str, conn); cmd.Parameters.Add(new SqlParameter("@Name", textBoxSearch.Text)); SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = cmd; sda.Fill(dataTable); // fill the data table with this data EvaluationData.DataSource = dataTable; // assign to data grid sda.Update(dataTable); conn.Close(); //add button column DataGridViewButtonColumn button = new DataGridViewButtonColumn(); button.HeaderText = "Delete Data"; button.Name = "button"; button.Text = "DELETE"; button.UseColumnTextForButtonValue = true; EvaluationData.Columns.Add(button); //add button column DataGridViewButtonColumn button1 = new DataGridViewButtonColumn(); button1.HeaderText = "Update Data"; button1.Name = "button1"; button1.Text = "UPDATE"; button1.UseColumnTextForButtonValue = true; EvaluationData.Columns.Add(button1); // adjust their widths when the data changes. EvaluationData.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } else { EvaluationData.DataSource = null; EvaluationData.Rows.Clear(); EvaluationData.Columns.Clear(); update(); } }
public EvaluationData Add(EvaluationData newData) { ValidateData(newData); newData = _evaluationDataDbController.Create(newData); _logger.LogInformation($"{newData?.Id}"); EvaluationDataAddedEvent?.Invoke(newData); return(newData); }
public bool TryGetEarliest(int gameId, int actorId, string key, out EvaluationData value, EvaluationDataType evaluationDataType, DateTime?start = null, DateTime?end = null) { var list = List(gameId, actorId, key, evaluationDataType, start, end); if (list.Count > 0) { value = list.OrderBy(s => s.DateCreated).First(); return(true); } value = null; return(false); }
public bool TryGetMin(int gameId, int actorId, string key, out EvaluationData value, EvaluationDataType evaluationDataType, DateTime?start = null, DateTime?end = null) { var list = List(gameId, actorId, key, evaluationDataType, start, end); if (list.Count > 0) { value = list.OrderBy(s => Convert.ToDouble(s.Value)).First(); return(true); } value = null; return(false); }
protected void ValidateData(EvaluationData data) { if (data.Category != _category) { throw new InvalidDataException( $"Cannot save datas with category: {data.Category} with controller for mismatched category: {_category}"); } if (!IsValid(data, out var failure)) { throw new ArgumentException(failure); } }
public EvaluationData ValidateImage(string url) { var url1 = new BodyModel("URL", url); var imageData = new EvaluationData(); imageData.ImageUrl = url1.Value; // Evaluate for adult and racy content. imageData.ImageModeration = _contentModeratorClient.ImageModeration.EvaluateUrlInput("application/json", url1, true); Thread.Sleep(1000); return(imageData); }
public static bool IsValid(EvaluationData data, out string failure) { failure = null; if (!RegexUtil.IsAlphaNumericUnderscoreNotEmpty(data.Key)) { failure = $"Invalid Key {data.Key}. Keys must be non-empty strings containing only alpha-numeric characters and underscores."; } else if (!ParseCheck(data)) { failure = $"Invalid Value {data.Value} for EvaluationDataType {data.EvaluationDataType}"; } return(failure == null); }
public bool TryGetRelated(EvaluationData evaluationData, out ICollection <Evaluation> evaluations) { var didGetRelated = false; evaluations = null; var mappedKey = CreateMappingKey(evaluationData.GameId, evaluationData.EvaluationDataType, evaluationData.Key); if (_mappings.TryGetValue(mappedKey, out var relatedEvalautions)) { evaluations = relatedEvalautions.Values; didGetRelated = true; } return(didGetRelated); }
public static ResourceResponse ToResourceContract(this EvaluationData evaluationData) { if (evaluationData == null) { return(null); } return(new ResourceResponse { ActorId = evaluationData.ActorId, GameId = evaluationData.GameId, Key = evaluationData.Key, Quantity = long.Parse(evaluationData.Value), DateCreated = evaluationData.DateCreated, DateModified = evaluationData.DateCreated }); }
public void SetEvaluationData(EvaluationData data, Action endAction) { if (data == null) { endAction(); return; } string userID = TKManager.Instance.Mydata.Index; Dictionary <string, object> sendData = new Dictionary <string, object>(); if (data.TrainingType == CommonData.TRAINING_TYPE.TRAINING_TEMPO) { sendData.Add("USER_ID", userID); sendData.Add("TKDate", data.TKDate); sendData.Add("TrainingType", data.TrainingType.ToString()); sendData.Add("TrainingCount", data.TrainingCount); sendData.Add("StarCount", data.StarCount); sendData.Add("Msg", data.Msg); } else { sendData.Add("USER_ID", userID); sendData.Add("TKDate", data.TKDate); sendData.Add("TrainingType", data.TrainingType.ToString()); sendData.Add("TrainingCount", data.TrainingCount); sendData.Add("PoseType", data.PoseType.ToString()); sendData.Add("AngleTypeList", data.AngleTypeList_Str); sendData.Add("StarCount", data.StarCount); sendData.Add("Msg", data.Msg); } mDatabaseRef.Child("EvaluationData").Child(userID).Child(data.TKDate).SetValueAsync(sendData).ContinueWith(task => { if (task.IsFaulted) { // Handle the error... } else if (task.IsCompleted) { endAction(); // Debug.LogFormat("UserInfo: Index : {0} NickName {1} Point {2}", TKManager.Instance.MyData.Index, TKManager.Instance.MyData.NickName, TKManager.Instance.MyData.Point); } }); }
private void SetCompleted(Evaluation evaluation, int actorId) { var evaluationDataCoreController = new EvaluationDataController(EvaluationDataLogger, ContextFactory, evaluation.EvaluationType.ToEvaluationDataCategory()); var evaluationData = new EvaluationData { Category = evaluation.EvaluationType.ToEvaluationDataCategory(), Key = evaluation.Token, GameId = evaluation.GameId, ActorId = actorId, EvaluationDataType = EvaluationDataType.String, Value = null }; evaluationDataCoreController.Add(evaluationData); ProcessEvaluationRewards(evaluation, actorId); }