feat: Implement full recipe selection process in SelectRecipe
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -71,30 +71,62 @@ namespace Project.WebUI
|
|||||||
_host.HandleCommand(command);
|
_host.HandleCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SelectRecipe(string recipeId)
|
/// <summary>
|
||||||
|
/// 마이그레이션완료
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="recipeTitle"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string SelectRecipe(string recipeTitle)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"[C#] Selecting Recipe: {recipeId}");
|
Console.WriteLine($"[C#] Selecting Recipe: {recipeTitle}");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string recipePath = Path.Combine(_recipeFolder, $"{recipeId}.json");
|
// Check if system is running
|
||||||
|
if (PUB.sm.Step == eSMStep.RUN || PUB.sm.Step == eSMStep.WAITSTART || PUB.sm.Step == eSMStep.PAUSE)
|
||||||
if (!File.Exists(recipePath))
|
|
||||||
{
|
{
|
||||||
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);
|
return JsonConvert.SerializeObject(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
string json = File.ReadAllText(recipePath);
|
// Select model using PUB.SelectModelV
|
||||||
var recipeData = JsonConvert.DeserializeObject<dynamic>(json);
|
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 };
|
// Convert DataRow to Dictionary
|
||||||
|
var recipeData = new Dictionary<string, object>();
|
||||||
|
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);
|
return JsonConvert.SerializeObject(response2);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var response = new { success = false, message = "Failed to select recipe" };
|
||||||
|
return JsonConvert.SerializeObject(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"[ERROR] Failed to select recipe: {ex.Message}");
|
Console.WriteLine($"[ERROR] Failed to select recipe: {ex.Message}");
|
||||||
|
|||||||
Reference in New Issue
Block a user