Esempio n. 1
0
        public virtual bool LostDevice(string id, string checkUser)
        {
            DeviceUserDao dudao  = new DeviceUserDao(AppConfig.mainDbKey);
            Device        device = deviceDao.Get(id);

            if (device != null)
            {
                device.LostTime = DateTime.Now;
                device.Status   = 2;
                deviceDao.Update(device);

                List <Tuple <string, string, object> > pars = new List <Tuple <string, string, object> >();
                pars.Add(new Tuple <string, string, object>("deviceid", "=", id));
                List <DeviceUser> deviceUsers = dudao.QueryList(pars);

                try
                {
                    Service.ServiceReference1.ManagerServiceClient msc = new Service.ServiceReference1.ManagerServiceClient();
                    msc.ForceQuitClient(device.ID, device.Resource);
                }
                catch (Exception ex)
                {
                    Log4NetHelper.Error(ex);
                }

                string[] uids = null;

                string uid_online = dudao.GetDeviceOnlineUser(id);//根据设备id取最后登陆成功的用户

                string send_msg_after_device_lost = ConfigurationManager.AppSettings["send_msg_after_device_lost"];
                if (!String.IsNullOrEmpty(send_msg_after_device_lost) && send_msg_after_device_lost.ToLower() == "true")
                {
                    SmartBox.Console.Reminder.Reminder reminder = new Reminder.Reminder();
                    string send_msg_after_device_lost_content   = ConfigurationManager.AppSettings["send_msg_after_device_lost_content"];
                    if (String.IsNullOrEmpty(send_msg_after_device_lost_content))
                    {
                        send_msg_after_device_lost_content = "您的设备已经挂失成功!";
                    }

                    //for (int i = 0; i < uids.Length; ++i)
                    //{
                    try
                    {
                        reminder.RemindByMobile(uid_online, "", "设备挂失", send_msg_after_device_lost_content);
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Error(ex);
                    }
                    //}
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        public virtual void LockDevice(string id, string hour, Hashtable r)
        {
            DeviceDao dao = new DeviceDao(AppConfig.mainDbKey);
            Device    d   = dao.Get(id);

            d.LockTime        = DateTime.Now;
            d.Status          = 1;
            d.LockExpireHours = String.IsNullOrEmpty(hour) ? 0 : int.Parse(hour);
            dao.Update(d);
            r["r"] = true;
            SmartBox.Console.Service.ServiceReference1.ManagerServiceClient client = new SmartBox.Console.Service.ServiceReference1.ManagerServiceClient();

            try
            {
                DeviceUserDao duDao = new DeviceUserDao(AppConfig.mainDbKey);
                List <Tuple <string, string, object> > pars = new List <Tuple <string, string, object> >();
                pars.Add(new Tuple <string, string, object>("deviceid", "=", id));
                List <DeviceUser> deviceUsers = duDao.QueryList(pars);
                var rr = from e in deviceUsers select e.UID;

                string[] sessionids = rr.ToArray();
                client.ForceQuitUsers(sessionids);
            }
            catch (Exception e)
            {
                r["d"] += "强制用户退出失败,详细信息:" + e.Message;
            }
        }