StoreSystem.cs 1.5 KB
using log4net;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.ServiceProcess;
using System.Text;
 

namespace KTKSingleStoreSystem
{
    public partial class StoreSystem : ServiceBase
    {
        public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        public StoreSystem()
        {
            InitializeComponent();
        }
        private KTK_SA_BoxBean store = null;
        protected override void OnStart(string[] args)
        {
            LogUtil.info(LOGGER, "Server OnStart Begin!");
            this.store = SAStoreManager.InitStore();
            if (store == null)
            {
                LogUtil.error(LOGGER, "加载料仓失败");
                return;
            }
        //    store.StartRun();
            LogUtil.info(LOGGER, "Server OnStart End!");
        }

        protected override void OnStop()
        {
            LogUtil.info(LOGGER, "Server OnStop Begin !");
            if (store != null)
            {
                if (store.storeRunStatus > StoreRunStatus.Wait)
                {
                    store.StopRun();
                }
           
                KNDManager.CloseAllDO(); 
                KNDManager.CloseAllConnection();
            }
            LogUtil.info(LOGGER, "Server OnStop End !");
        }
    }
}