using System; using System.Linq; using WCS_Client.Models; namespace WCS_Client.Workflow { public class SystemConfigWorkflow { /// /// 系统配置写入 /// /// 设备编号 /// 是否启用 /// /// public static string SystemConfigSet(string convNo, bool isStop) { string result = TryCachHelper.TryExecute((db) => { //var srmoutinInfo = db.Queryable().First(v => v.SRMOUTIN_CONVNO == convNo); var systemConfig = db.Queryable().First(v => v.DEVICECODE == convNo); if (systemConfig == null) { throw new Exception(string.Format("未查询到堆垛机出入口[{0}]信息", convNo)); } else { if (db.Updateable() .UpdateColumns(it => new WCS_SystemConfig { ENABLED = isStop, UPDATETIME = DateTime.Now }) .Where(v => v.DEVICECODE == convNo).ExecuteCommand() < 0) { throw new Exception(string.Format("堆垛机出入口[{0}]禁(启)用失败", convNo)); } } }); return result; } public static string AgvSet(string convNo, bool enable, string LCName) { string result = TryCachHelper.TryExecute((db) => { var srmoutinInfo = db.Queryable().First(v => v.POSITION == convNo); if (srmoutinInfo == null) { throw new Exception(string.Format("未查询到产线[{0}]信息", convNo)); } else { if (LCName == "btn_InEnable") { if (db.Updateable() .UpdateColumns(it => new WCS_AGV_Config { INENABLE = enable }) .Where(v => v.POSITION == convNo).ExecuteCommand() < 0) { throw new Exception(string.Format("产线[{0}]入库启用失败", convNo)); } } else if (LCName == "btn_OutEnable") { if (db.Updateable() .UpdateColumns(it => new WCS_AGV_Config { OUTENABLE = enable }) .Where(v => v.POSITION == convNo).ExecuteCommand() < 0) { throw new Exception(string.Format("产线[{0}]出库启用失败", convNo)); } } else if (LCName == "btn_InStop") { if (db.Updateable() .UpdateColumns(it => new WCS_AGV_Config { INENABLE = enable }) .Where(v => v.POSITION == convNo).ExecuteCommand() < 0) { throw new Exception(string.Format("产线[{0}]入库禁用失败", convNo)); } } else if (LCName == "btn_OutStop") { if (db.Updateable() .UpdateColumns(it => new WCS_AGV_Config { OUTENABLE = enable }) .Where(v => v.POSITION == convNo).ExecuteCommand() < 0) { throw new Exception(string.Format("产线[{0}]出库禁用失败", convNo)); } } } }); return result; } } }