From e46886cabcd855fe196e5c40f5da711cd5015c1c Mon Sep 17 00:00:00 2001 From: arDTDev Date: Tue, 25 Nov 2025 21:32:55 +0900 Subject: [PATCH] feat: Implement full recipe selection process in SelectRecipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Modified SelectRecipe to use PUB.SelectModelV for actual recipe activation - Added system state check (cannot change model while running/waiting) - Recipe selection now performs complete process: - Loads model data into PUB.Result.vModel - Saves to SETTING.User.LastModelV - Loads barcode patterns (BCDPattern, BCDIgnorePattern) - Updates customer code from model - Clears saved barcode data - Updates barcode configuration - Sets ZPL filename for custom ZPL models - Returns full recipe data after successful selection - Follows Model_Operation.cs toolStripButton10_Click pattern 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- Handler/Project/WebUI/MachineBridge.cs | 56 ++++++++++++++++++++------ 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/Handler/Project/WebUI/MachineBridge.cs b/Handler/Project/WebUI/MachineBridge.cs index a481558..71590c1 100644 --- a/Handler/Project/WebUI/MachineBridge.cs +++ b/Handler/Project/WebUI/MachineBridge.cs @@ -71,29 +71,61 @@ namespace Project.WebUI _host.HandleCommand(command); } - public string SelectRecipe(string recipeId) + /// + /// 마이그레이션완료 + /// + /// + /// + public string SelectRecipe(string recipeTitle) { - Console.WriteLine($"[C#] Selecting Recipe: {recipeId}"); + Console.WriteLine($"[C#] Selecting Recipe: {recipeTitle}"); try { - string recipePath = Path.Combine(_recipeFolder, $"{recipeId}.json"); - - if (!File.Exists(recipePath)) + // Check if system is running + if (PUB.sm.Step == eSMStep.RUN || PUB.sm.Step == eSMStep.WAITSTART || PUB.sm.Step == eSMStep.PAUSE) { - var response = new { success = false, message = "Recipe not found" }; + var response = new { success = false, message = "Cannot change model while system is currently running (waiting)" }; return JsonConvert.SerializeObject(response); } - string json = File.ReadAllText(recipePath); - var recipeData = JsonConvert.DeserializeObject(json); + // Select model using PUB.SelectModelV + bool result = AR.PUB.SelectModelV(recipeTitle, true); - _host.SetCurrentRecipe(recipeId); + if (result) + { + Console.WriteLine($"[INFO] Recipe {recipeTitle} selected successfully"); - Console.WriteLine($"[INFO] Recipe {recipeId} selected successfully"); + // Get the selected model data + var dr = PUB.mdm.GetDataV(recipeTitle); + if (dr == null) + { + var response = new { success = false, message = "Recipe data not found" }; + return JsonConvert.SerializeObject(response); + } - var response2 = new { success = true, message = "Recipe selected successfully", recipeId = recipeId, recipe = recipeData }; - return JsonConvert.SerializeObject(response2); + // Convert DataRow to Dictionary + var recipeData = new Dictionary(); + foreach (System.Data.DataColumn col in dr.Table.Columns) + { + string colName = col.ColumnName; + object value = dr[colName]; + + // DBNull을 null로 변환 + if (value == DBNull.Value) + value = null; + + recipeData[colName] = value; + } + + var response2 = new { success = true, message = "Recipe selected successfully", recipeId = recipeTitle, recipe = recipeData }; + return JsonConvert.SerializeObject(response2); + } + else + { + var response = new { success = false, message = "Failed to select recipe" }; + return JsonConvert.SerializeObject(response); + } } catch (Exception ex) {