using System; using System.Collections.Generic; using System.Linq; using System.Text; using Mesnac.Action.Base; using System.Windows.Forms; using Mesnac.Controls.Base; using Mesnac.Action.Feeding.Qingquan.BasicInfo; namespace Mesnac.Action.Feeding.Qingquan.Technology { /// /// 从网络更新配方 /// public class UpdateRecipe : FeedingAction, IAction { public void Run(RuntimeParameter runtime) { base.RunIni(runtime); if (runtime.Sender is Control) { (runtime.Sender as Control).Enabled = false; } try { if (base.NetType == NetTypes.Local) { ICSharpCode.Core.LoggingService.Error("此系统版本为单机版,不能进行数据同步..."); base.ShowMsg(Language(32)); return; } //if (!PlanCommon.PingIpOrDomainName(base.GetConfigValue("ServerIP", "127.0.0.1"))) if (!PlanCommon.IsCanConnectServer()) { //网络不通 base.ShowMsg(Language(33), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DbMCControl mater_codeControl = base.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, string.Format("[pmt_recipe].[{0}]", "mater_code")).FirstOrDefault(); DbMCControl edt_codeControl = base.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, string.Format("[pmt_recipe].[{0}]", "edt_code")).FirstOrDefault(); if (mater_codeControl == null) { //缺少配方编码控件 base.ShowMsg(Language(268), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (edt_codeControl == null) { //缺少配方版本控件 base.ShowMsg(Language(269), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string mater_code = mater_codeControl.BaseControl.MCValue.ToString().Trim(); string edt_code = edt_codeControl.BaseControl.MCValue.ToString().Trim(); if (String.IsNullOrEmpty(mater_code)) { //配方编码为空,不能更新 base.ShowMsg(Language(272), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information); base.DBLog("配方管理", "从网络更新配方", "网络上不存在此配方:" + mater_code +"-版本:" + edt_code + ",更新失败!"); return; } if (String.IsNullOrEmpty(edt_code)) { //配方版本为空,不能更新 base.ShowMsg(Language(273), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information); base.DBLog("配方管理", "从网络更新配方", "网络上不存在此配方版本:" + mater_code + "-版本:" + edt_code + ",更新失败!"); return; } int result = new NetRecipe().DownloadRecipe(base.CurrEquipCode, mater_code, edt_code); //从网络更新配方 if (result == 1) { //更新配方成功 base.ShowMsg(Language(270), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information); base.DBLog("配方管理", "从网络更新配方", "更新成功,配方编码:" + mater_code + "-版本:" + edt_code); return; } else { //更新配方失败 base.ShowMsg(Language(271), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information); base.DBLog("配方管理", "从网络更新配方", "更新失败!"); return; } } catch (Exception ex) { base.LogError(ex.Message); base.LogError(ex.StackTrace); } finally { if (runtime.Sender is Control) { (runtime.Sender as Control).Enabled = true; } } } } }