protected override void OnStart(string[] args) { // TODO: 在此处添加代码以启动服务。 _server = WebApiStartup.RunWebServer(); Task.Factory.StartNew(() => { syncServiceThread = Thread.CurrentThread; SyncServiceClientStartup.AutoSync(); }); Task.Factory.StartNew(() => { marketingThread = Thread.CurrentThread; MarketingManager.InitStoreMarketing(); }); Task.Factory.StartNew(() => { clientThread = Thread.CurrentThread; client = new PosStoreClient(); }); //Task.Factory.StartNew(() => //{ // storeManagerThread = Thread.CurrentThread; // IISExpressSeverManager manager = new IISExpressSeverManager(); // var config = StoreManageCenterConfig.GetConfig(); // var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Store"); // manager.Run(config.Port, path, "v4.0", "IIS"); //}); }
static void Main(string[] args) { PosStoreClient client = new PosStoreClient(); while (true) { Console.WriteLine("按Q退出!"); if (Console.ReadKey().Key.ToString().ToLower() == "q") { client.Dispose(); break; } } }
public override void Execute(PosStoreClient posStoreClient, PosStorePackageInfo package) { var datas = package.Read <MemberNoDto>(); MemberNo memberNo = new MemberNo(datas.CompanyId, datas.StoreId); if (memberNo.GetNumber() <= datas.Number) { memberNo.Reset(datas.Number); } else { posStoreClient.SendObject(this.CmdCode, new MemberNoDto() { CompanyId = memberNo.CompanyId, StoreId = memberNo.StoreId, Name = memberNo.Name, Number = memberNo.GetNumber(), SwiftNumberMode = memberNo.SwiftNumberMode }); } }
protected override void OnStop() { // TODO: 在此处添加代码以执行停止服务所需的关闭操作。 if (_server != null) { _server.Dispose(); _server = null; } if (client != null) { client.Close(); client.Dispose(); client = null; } if (marketingThread != null && marketingThread.ThreadState == System.Threading.ThreadState.Running) { marketingThread.Abort(); marketingThread = null; } if (syncServiceThread != null && syncServiceThread.ThreadState == System.Threading.ThreadState.Running) { syncServiceThread.Abort(); syncServiceThread = null; } if (clientThread != null && clientThread.ThreadState == System.Threading.ThreadState.Running) { clientThread.Abort(); clientThread = null; } if (storeManagerThread != null && storeManagerThread.ThreadState == System.Threading.ThreadState.Running) { storeManagerThread.Abort(); storeManagerThread = null; } base.OnStop(); base.Dispose(); }