Exemplo n.º 1
0
        void myTimerServer_OnTick(object state)
        {
            try
            {
                if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday ||
                    DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
                {
                    return;
                }

                DateTime sDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 30, 0);
                DateTime eDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 15, 40, 0);

                if (DateTime.Now >= sDate &&
                    DateTime.Now <= eDate
                    )
                {
                    LogWrite(LogType.INFORMATION, "SERVER DISCONNECT");
                    myXASessionClass.DisconnectServer();

                    LogWrite(LogType.INFORMATION, "SERVER CONNECT");
                    AutoLogIn_Exec();
                }
            }
            catch (Exception e)
            {
                EventLog.WriteEntry("OrderForm-myTimerServer_OnTick", e.ToString());
            }
        }
Exemplo n.º 2
0
        private void CleanResources()
        {
            if (_xingSession == null)
            {
                return;
            }

            if (_loggedIn == true)
            {
                _xingSession.Logout();
            }

            if (_xingSession.IsConnected() == true)
            {
                _xingSession.DisconnectServer();
            }

            if (_xingSession != null)
            {
                Marshal.ReleaseComObject(_xingSession);
                _xingSession = null;
            }
        }