Ejemplo n.º 1
0
        public static void SaveAllOnlineSeconds()
        {
            string         newStatus = string.Empty;
            TerminalStatus terminal  = null;

            for (int i = 0; i < lists.Count; i++)
            {
                terminal = lists[i] as TerminalStatus;
                terminal.LastCheckTime = System.DateTime.Now;
                bool online = FT.Commons.Tools.WindowExHelper.CanConnectionTo(terminal.MachineIp);
                newStatus = online ? "在线" : "不在线";

                if (online)
                {
                    terminal.LastOnlineTime = System.DateTime.Now;
                }
                //在线变成不在线状态
                else if (terminal.OnlineStatus == "在线")
                {
                    terminal.LastOutlineTime = System.DateTime.Now;
                }
                FT.DAL.DataAccessFactory.GetDataAccess().ExecuteSql("update yuantuo_terminals set onlineseconds=" + terminal.OnlineSeconds.ToString() + ",date_machine_last_online_time='" + DateTimeHelper.DtToLongString(terminal.LastOnlineTime) + "',date_machine_last_outline_time='" + DateTimeHelper.DtToLongString(terminal.LastOutlineTime) + "' where id=" + terminal.Id.ToString());
                // FT.DAL.Orm.SimpleOrmOperator.Update(terminal);
            }
        }
Ejemplo n.º 2
0
        private static void CheckTerminalOnline()
        {
            string         oldStatus = string.Empty;
            string         newStatus = string.Empty;
            TerminalStatus terminal  = null;

            while (true)
            {
                if (lists == null)
                {
                    System.Threading.Thread.Sleep(3000);
                    continue;
                }
                for (int i = 0; i < lists.Count; i++)
                {
                    terminal  = lists[i] as TerminalStatus;
                    oldStatus = terminal.OnlineStatus;
                    bool online = FT.Commons.Tools.WindowExHelper.CanConnectionTo(terminal.MachineIp);
                    newStatus = online ? "在线" : "不在线";

                    if (oldStatus.Length > 0)
                    {
                        if (online)
                        {
                            terminal.LastOnlineTime = System.DateTime.Now;
                            terminal.OnlineSeconds += threadMiniSecond / 1000;
                        }
                        if (oldStatus != newStatus)
                        {
                            if (online)
                            {
                                // int onlineSec = (int)terminal.LastOutlineTime.Subtract(terminal.LastCheckTime).TotalSeconds;
                                // terminal.OnlineSeconds += onlineSec;
                            }
                            //在线变成不在线状态
                            else
                            {
                                terminal.LastOutlineTime = System.DateTime.Now;
                                //int onlineSec = (int)terminal.LastOutlineTime.Subtract(terminal.LastCheckTime).TotalSeconds;
                                //terminal.OnlineSeconds += onlineSec;
                                terminal.OnlineSeconds += threadMiniSecond / 1000;
                            }
                            FT.DAL.DataAccessFactory.GetDataAccess().ExecuteSql("update yuantuo_terminals set onlineseconds=" + terminal.OnlineSeconds.ToString() + ",date_machine_last_online_time='" + DateTimeHelper.DtToLongString(terminal.LastOnlineTime) + "',date_machine_last_outline_time='" + DateTimeHelper.DtToLongString(terminal.LastOutlineTime) + "' where id=" + terminal.Id.ToString());
                            // FT.DAL.Orm.SimpleOrmOperator.Update(terminal);
                        }
                    }
                    //else if(oldStatus.Length>0&&online)
                    // {
                    // int onlineSec = (int)terminal.LastOutlineTime.Subtract(terminal.LastCheckTime).TotalSeconds;
                    // terminal.OnlineSeconds += threadMiniSecond/1000;
                    // }
                    terminal.OnlineStatus  = newStatus;
                    terminal.LastCheckTime = System.DateTime.Now;
                }
                System.Threading.Thread.Sleep(threadMiniSecond);
            }
        }
Ejemplo n.º 3
0
        public static TerminalStatus GetTerminal(string ip)
        {
            if (lists == null || lists.Count == 0)
            {
                lock (synObject)
                {
                    lists = FT.DAL.Orm.SimpleOrmOperator.QueryListAll(typeof(TerminalStatus));
                }
            }
            TerminalStatus terminal = null;

            for (int i = 0; i < lists.Count; i++)
            {
                terminal = lists[i] as TerminalStatus;
                if (terminal.MachineIp == ip)
                {
                    break;
                }
            }
            return(terminal);
        }
Ejemplo n.º 4
0
 private void LogOrderRecord(TerminalStatus terminal,ProductInfo product,string orderid,double orderPrice,int orderNum,string mobile)
 {
 }