Exemple #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);
            }
        }
Exemple #2
0
        public virtual bool UnLostDevice(string id, string checkUser)
        {
            Device device = deviceDao.Get(id);

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


                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);

                string uid_online = dudao.GetDeviceOnlineUser(id);//根据设备id取最后登陆成功的用户
                //if (deviceUsers != null && deviceUsers.Count > 0)
                {
                    SmartBox.Console.Reminder.Reminder reminder = new Reminder.Reminder();
                    //for (int i = 0; i < deviceUsers.Count; ++i)
                    {
                        //DeviceUser du = deviceUsers[i];
                        string send_msg_after_device_unlost = ConfigurationManager.AppSettings["send_msg_after_device_unlost"];
                        if (!String.IsNullOrEmpty(send_msg_after_device_unlost) && send_msg_after_device_unlost.ToLower() == "true")
                        {
                            try
                            {
                                reminder.RemindByMobile(uid_online, "", "设备解除挂失", "您的设备已经解除挂失成功!");
                            }
                            catch (Exception ex)
                            {
                                Log4NetHelper.Error(ex);
                            }
                        }
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public virtual bool UnLostDevice(string id, string checkUser)
        {
            Device device = deviceDao.Get(id);
            if (device != null)
            {
                //device.LostTime = DateTime.Now;
                device.UnLostTime = DateTime.Now;
                device.Status = 0;
                deviceDao.Update(device);

                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);

                string uid_online = dudao.GetDeviceOnlineUser(id);//根据设备id取最后登陆成功的用户
                //if (deviceUsers != null && deviceUsers.Count > 0)
                {
                    SmartBox.Console.Reminder.Reminder reminder = new Reminder.Reminder();
                    //for (int i = 0; i < deviceUsers.Count; ++i)
                    {
                        //DeviceUser du = deviceUsers[i];
                        string send_msg_after_device_unlost = ConfigurationManager.AppSettings["send_msg_after_device_unlost"];
                        if (!String.IsNullOrEmpty(send_msg_after_device_unlost) && send_msg_after_device_unlost.ToLower() == "true")
                        {
                            try
                            {
                                reminder.RemindByMobile(uid_online, "", "设备解除挂失", "您的设备已经解除挂失成功!");
                            }
                            catch (Exception ex)
                            {
                                Log4NetHelper.Error(ex);
                            }
                        }
                    }
                }
                return true;
            }
            else
            {
                return false;
            }
        }
        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;
            }
        }