Exemple #1
0
        public virtual bool UnBindDevice(string deviceuser_id, string checkUser)
        {
            DeviceUserDao dao        = new DeviceUserDao(AppConfig.mainDbKey);
            DeviceUser    deviceUser = dao.Get(deviceuser_id);

            if (deviceUser != null)
            {
                deviceUser.Status         = 0;
                deviceUser.LastUpdateTime = DateTime.Now;
                deviceUser.LastUpdateUID  = checkUser;
                dao.Update(deviceUser);


                List <Tuple <string, string, object> > pars = new List <Tuple <string, string, object> >();
                pars.Add(new Tuple <string, string, object>("id", "=", deviceUser.DeviceID));
                List <Device> devices = deviceDao.QueryList(pars);

                if (devices.Count > 0)
                {
                    try
                    {
                        //踢用户
                        SmartBox.Console.Service.ServiceReference1.ManagerServiceClient cli = new Service.ServiceReference1.ManagerServiceClient();
                        cli.ForceQuitClient(devices[0].ID, devices[0].Resource);
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Error(ex);
                    }
                }

                string send_msg_after_device_unbind = ConfigurationManager.AppSettings["send_msg_after_device_unbind"];
                if (!String.IsNullOrEmpty(send_msg_after_device_unbind) && send_msg_after_device_unbind.ToLower() == "true")
                {
                    SmartBox.Console.Reminder.Reminder reminder = new Reminder.Reminder();

                    try
                    {
                        string s = "";
                        if (devices.Count > 0)
                        {
                            s = devices[0].Model + "(" + deviceUser.DeviceID + ")";
                        }
                        reminder.RemindByMobile(deviceUser.UID, "", "设备挂失", "您的账号与设备" + s + "已解除绑定!");
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Error(ex);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        public virtual bool PassDevice(string duaid, string checkUser)
        {
            try
            {
                DeviceUserApplyDao dao = new DeviceUserApplyDao(AppConfig.mainDbKey);
                DeviceUserApply    dua = dao.Get(duaid);

                if (dua != null)
                {
                    dua.CheckTime = DateTime.Now;
                    dua.CheckUid  = checkUser;
                    dua.Status    = 1;
                    dao.Update(dua);

                    DeviceUserDao duDao = new DeviceUserDao(AppConfig.mainDbKey);
                    List <KeyValuePair <string, object> > pars = new List <KeyValuePair <string, object> >();
                    pars.Add(new KeyValuePair <string, object>("ID", dua.DeviceUserID));

                    DeviceUser du = duDao.Get(pars);
                    du.Status         = 1;
                    du.LastUpdateTime = DateTime.Now;
                    du.LastUpdateUID  = checkUser;
                    duDao.Update(du);

                    string send_msg_after_device_user_auth = ConfigurationManager.AppSettings["send_msg_after_device_user_auth"];
                    if (!String.IsNullOrEmpty(send_msg_after_device_user_auth) && send_msg_after_device_user_auth.ToLower() == "true")
                    {
                        string send_msg_after_device_user_auth_content = ConfigurationManager.AppSettings["send_msg_after_device_user_auth_content"];
                        if (String.IsNullOrEmpty(send_msg_after_device_user_auth_content))
                        {
                            send_msg_after_device_user_auth_content = "设备审核通过";
                        }
                        SmartBox.Console.Reminder.Reminder reminder = new Reminder.Reminder();
                        try
                        {
                            reminder.RemindByMobile(du.UID, "", "设备审核通过", send_msg_after_device_user_auth_content);
                        }
                        catch (Exception ex)
                        {
                            Log4NetHelper.Error(ex);
                        }
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error(ex);
                return(false);
            }
        }
Exemple #3
0
        public virtual bool NotPassDevice(string deviceuserapplyid, string checkUser, GlobalParam parm, string refuse_msg)
        {
            DeviceUserApply dua = DeviceUserApplyDao.Get(deviceuserapplyid);

            SmartBox.Console.Reminder.Reminder reminder = new Reminder.Reminder();
            if (dua != null)
            {
                bool disable_device_after_notpass_device = (parm.ConfigValue == "1");

                dua.CheckTime = DateTime.Now;
                dua.CheckUid  = checkUser;
                dua.Status    = disable_device_after_notpass_device ? 3 : 2;
                DeviceUserApplyDao.Update(dua);


                DeviceUserDao duDao = new DeviceUserDao(AppConfig.mainDbKey);
                List <KeyValuePair <string, object> > pars = new List <KeyValuePair <string, object> >();
                pars.Add(new KeyValuePair <string, object>("ID", dua.DeviceUserID));

                DeviceUser du = duDao.Get(pars);
                du.Status = 2;
                if (disable_device_after_notpass_device)
                {
                    du.NoUseReason = 1;
                }
                duDao.Update(du);

                try
                {
                    string content = "";
                    string send_refuse_msg_after_device_user_auth = ConfigurationManager.AppSettings["send_refuse_msg_after_device_user_auth"];
                    if (send_refuse_msg_after_device_user_auth != null && send_refuse_msg_after_device_user_auth.ToLower() == "true")
                    {
                        content = ConfigurationManager.AppSettings["send_refuse_msg_after_device_user_auth_content"] + refuse_msg;
                    }

                    if (!String.IsNullOrEmpty(content))
                    {
                        reminder.RemindByMobile(du.UID, "", "设备审核未通过", content);
                    }
                }
                catch (Exception ex)
                {
                    Log4NetHelper.Error(ex);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public virtual bool UnBindDevice(string deviceuser_id, string checkUser)
        {
            DeviceUserDao dao = new DeviceUserDao(AppConfig.mainDbKey);
            DeviceUser deviceUser = dao.Get(deviceuser_id);
            if (deviceUser != null)
            {
                deviceUser.Status = 0;
                deviceUser.LastUpdateTime = DateTime.Now;
                deviceUser.LastUpdateUID = checkUser;
                dao.Update(deviceUser);

                List<Tuple<string, string, object>> pars = new List<Tuple<string, string, object>>();
                pars.Add(new Tuple<string, string, object>("id", "=", deviceUser.DeviceID));
                List<Device> devices = deviceDao.QueryList(pars);

                if (devices.Count > 0)
                {
                    try
                    {
                        //踢用户
                        SmartBox.Console.Service.ServiceReference1.ManagerServiceClient cli = new Service.ServiceReference1.ManagerServiceClient();
                        cli.ForceQuitClient(devices[0].ID, devices[0].Resource);
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Error(ex);
                    }
                }

                string send_msg_after_device_unbind = ConfigurationManager.AppSettings["send_msg_after_device_unbind"];
                if (!String.IsNullOrEmpty(send_msg_after_device_unbind) && send_msg_after_device_unbind.ToLower() == "true")
                {
                    SmartBox.Console.Reminder.Reminder reminder = new Reminder.Reminder();

                    try
                    {
                        string s = "";
                        if (devices.Count > 0)
                            s = devices[0].Model + "(" + deviceUser.DeviceID + ")";
                        reminder.RemindByMobile(deviceUser.UID, "", "设备挂失", "您的账号与设备" + s + "已解除绑定!");
                    }
                    catch (Exception ex)
                    {
                        Log4NetHelper.Error(ex);
                    }
                }
                return true;
            }
            else
            {
                return false;
            }
        }
        public virtual bool PassDevice(string duaid, string checkUser)
        {
            try
            {
                DeviceUserApplyDao dao = new DeviceUserApplyDao(AppConfig.mainDbKey);
                DeviceUserApply dua = dao.Get(duaid);

                if (dua != null)
                {
                    dua.CheckTime = DateTime.Now;
                    dua.CheckUid = checkUser;
                    dua.Status = 1;
                    dao.Update(dua);

                    DeviceUserDao duDao = new DeviceUserDao(AppConfig.mainDbKey);
                    List<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>();
                    pars.Add(new KeyValuePair<string, object>("ID", dua.DeviceUserID));

                    DeviceUser du = duDao.Get(pars);
                    du.Status = 1;
                    du.LastUpdateTime = DateTime.Now;
                    du.LastUpdateUID = checkUser;
                    duDao.Update(du);

                    string send_msg_after_device_user_auth = ConfigurationManager.AppSettings["send_msg_after_device_user_auth"];
                    if (!String.IsNullOrEmpty(send_msg_after_device_user_auth) && send_msg_after_device_user_auth.ToLower() == "true")
                    {
                        string send_msg_after_device_user_auth_content = ConfigurationManager.AppSettings["send_msg_after_device_user_auth_content"];
                        if (String.IsNullOrEmpty(send_msg_after_device_user_auth_content))
                            send_msg_after_device_user_auth_content = "设备审核通过";
                        SmartBox.Console.Reminder.Reminder reminder = new Reminder.Reminder();
                        try
                        {
                            reminder.RemindByMobile(du.UID, "", "设备审核通过", send_msg_after_device_user_auth_content);
                        }
                        catch (Exception ex)
                        {
                            Log4NetHelper.Error(ex);
                        }
                    }
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error(ex);
                return false;
            }
        }