|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using Mesnac.Action.Base;
|
|
|
using Mesnac.Action.Feeding.Qingquan.BasicInfo;
|
|
|
using System.Windows.Forms;
|
|
|
using Mesnac.Basic;
|
|
|
using Mesnac.Codd.Session;
|
|
|
using Mesnac.Action.Feeding.Qingquan.LockScales;
|
|
|
|
|
|
namespace Mesnac.Action.Feeding.Qingquan.Sys
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 系统数据初始化
|
|
|
/// </summary>
|
|
|
public class SysDataInit : FeedingAction, IAction
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 系统数据初始化入口
|
|
|
/// </summary>
|
|
|
/// <param name="runtime"></param>
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
{
|
|
|
base.RunIni(runtime);
|
|
|
this.InitRecipeCache();
|
|
|
this.InitRecipeWeightCache();
|
|
|
ICSharpCode.Core.LoggingService.Debug("初始化缓存配方...");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 初始化缓存配方
|
|
|
/// </summary>
|
|
|
public void InitRecipeCache()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string xmlRecipeCache_RecipeInfo = base.GetSysValue("RecipeCache_RecipeInfo");
|
|
|
string xmlRecipeCache_PlanInfo = base.GetSysValue("RecipeCache_PlanInfo");
|
|
|
string xmlRecipeCache_AllWeightInfo = base.GetSysValue("RecipeCache_AllWeightInfo");
|
|
|
string xmlRecipeCache_AllMixingInfo = base.GetSysValue("RecipeCache_AllMixingInfo");
|
|
|
|
|
|
RecipeData.RecipeInfo _RecipeInfo = SerializeHandler.DeserializeObject<RecipeData.RecipeInfo>(xmlRecipeCache_RecipeInfo);
|
|
|
RecipeData.PptPlanInfo _PptPlanInfo = SerializeHandler.DeserializeObject<RecipeData.PptPlanInfo>(xmlRecipeCache_PlanInfo);
|
|
|
List<RecipeData.RecipeWeightInfo> _AllWeightInfo = SerializeHandler.DeserializeObject<List<RecipeData.RecipeWeightInfo>>(xmlRecipeCache_AllWeightInfo);
|
|
|
List<RecipeData.RecipeMixingInfo> _AllMixingInfo = SerializeHandler.DeserializeObject<List<RecipeData.RecipeMixingInfo>>(xmlRecipeCache_AllMixingInfo);
|
|
|
|
|
|
RecipeCache.Instance.CacheRecipeInfo(_RecipeInfo);
|
|
|
RecipeCache.Instance.CachePlanInfo(_PptPlanInfo);
|
|
|
RecipeCache.Instance.CacheAllWeightInfo(_AllWeightInfo);
|
|
|
RecipeCache.Instance.CacheAllMixingInfo(_AllMixingInfo);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error("初始化缓存配方失败:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 初始化提前称量缓存信息
|
|
|
/// </summary>
|
|
|
public void InitRecipeWeightCache()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string xmlRecipeWeightCache = base.GetSysValue("RecipeWeightCache");
|
|
|
List<RecipeData.RecipeWeightInfo> _AllWeightInfo = SerializeHandler.DeserializeObject<List<RecipeData.RecipeWeightInfo>>(xmlRecipeWeightCache);
|
|
|
string xmlRecipeWeightCache_CacheFlag = base.GetSysValue("RecipeWeightCache_CacheFlag");
|
|
|
|
|
|
RecipeWeighCache.Instance.CacheAllWeightInfo(_AllWeightInfo);
|
|
|
if (!String.IsNullOrEmpty(xmlRecipeWeightCache_CacheFlag))
|
|
|
{
|
|
|
bool flag = false;
|
|
|
bool.TryParse(xmlRecipeWeightCache_CacheFlag, out flag);
|
|
|
RecipeWeighCache.Instance.CacheFlag = flag;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error("初始化提前称量缓存信息失败:" + ex.Message, ex);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#region 不能连通网络,自动转为单机版
|
|
|
public class SysVersionConfig : FeedingAction, IAction
|
|
|
{
|
|
|
private static bool _isFirstRun = true;
|
|
|
|
|
|
#region IAction 成员
|
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
{
|
|
|
base.RunIni(runtime);
|
|
|
|
|
|
if (base.NetType == NetTypes.Local)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//bool isConnect = PlanCommon.PingIpOrDomainName(base.GetConfigValue("ServerIP", "127.0.0.1"));
|
|
|
bool isConnect = PlanCommon.IsCanConnectServer();
|
|
|
if (!isConnect)
|
|
|
{
|
|
|
//网络连通失败,自动把base.NetType设置为NetTypes.Local
|
|
|
base.SetGlobalNetType(NetTypes.Local);
|
|
|
//RunSchema.Instance.UpdateNodeValueToRunSchema("NetType", "0");
|
|
|
MessageBox.Show("未能连接到网络库,系统自动为您转化为单机版。", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
}
|
|
|
|
|
|
if (SysVersionConfig._isFirstRun == true)
|
|
|
{
|
|
|
//首次运行订阅工作台关闭事件
|
|
|
Mesnac.Gui.Workbench.WorkbenchSingleton.Workbench.ShutDown += new EventHandler(Workbench_ShutDown);
|
|
|
TimerRunService.Instance.Start(); //启动定时器服务
|
|
|
SysVersionConfig._isFirstRun = false;
|
|
|
}
|
|
|
|
|
|
if (base.GetConfigValue("IsLockScales", "0") == "1")
|
|
|
{
|
|
|
//启用锁秤
|
|
|
LockScaleService.Instance.Start(); //启动锁秤服务
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void Workbench_ShutDown(object sender, EventArgs e)
|
|
|
{
|
|
|
TimerRunService.Instance.Stop();
|
|
|
LockScaleService.Instance.Stop();
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
#endregion
|
|
|
}
|