コード例 #1
0
        public ServiceStarter()
        {
            Console.WriteLine("\nEnter ServiceStarter ctor\n");
            #region Use SQLite

            using (DB db = new DB("OpenALPRQueueMilestone", true))
            {
                settings = db.GetSettings();
            }

            Console.WriteLine("\nDB setup exit\n");
            ProxySingleton.Port = settings.ServicePort.ToString();
            #endregion
            currentPerson           = new User(User.AutoExporterServiceName);
            ProxySingleton.HostName = Dns.GetHostName();
            Chatting.Initialize(currentPerson);
            Chatting.UserEnter   += ServerConnection_UserEnter;
            Chatting.UserLeave   += ServerConnection_UserLeave;
            Chatting.InfoArrived += ServerConnection_MessageArrived;
            Task.Run(() => Chatting.MonitorClientToServerQueue());
            Chatting.WhisperGui(new Info {
                MsgId = MessageId.ConnectedToMilestoneServer, Bool = true
            });
            Console.WriteLine("\nExit ServiceStarter ctor\n");
        }
コード例 #2
0
 private void ServerConnection_MessageArrived(object sender, ChatEventArgs e)
 {
     switch (e.Message.MessageInfo.MsgId)
     {
     case MessageId.ConnectedToMilestoneToServer:
         Chatting.WhisperGui(new Info {
             MsgId = MessageId.ConnectedToMilestoneServer, Bool = IsConnectedToMilestoneServer
         });
         break;
     }
 }
コード例 #3
0
        public void OnStop()
        {
            Chatting.WhisperGui(new Info {
                MsgId = MessageId.ConnectedToMilestoneServer, Bool = false
            });
            IsClosing = true;
            Program.Log.Debug("On stop");
            Program.Log.Info($"Stopping {Program.ProductName} service");

            if (worker != null)
            {
                worker.Close();
            }

            if (workerTask != null && workerTask.Status != TaskStatus.RanToCompletion)
            {
                workerTask.Dispose();
                workerTask = null;
            }

            if (milestoneServer != null)
            {
                milestoneServer.Close();
            }

            try
            {
                Chatting.UserEnter   -= ServerConnection_UserEnter;
                Chatting.UserLeave   -= ServerConnection_UserLeave;
                Chatting.InfoArrived -= ServerConnection_MessageArrived;
                Chatting.Close();
            }
            catch (Exception ex)
            {
                Program.Log.Error("OnStop", ex);
            }
        }