private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            int    id     = dgAccountManagement.SelectedIndex;
            int    number = -1;
            int    num    = 555 + 2 * id;
            string port2  = "5" + num;

            SystemConfigBLL bLL = new SystemConfigBLL();

            Task.Run(() =>
            {
                List <string> devicesList = ProcessUtils.AdbDevices();
                foreach (string deviceIP in devicesList)
                {
                    if (deviceIP.IndexOf(port2) > 0)
                    {
                        string port                     = deviceIP.Remove(0, deviceIP.Length - 4);
                        string connectDeviceCmd         = string.Format("{0}/adb -s {1} shell", ProcessUtils.LDPath, deviceIP);
                        string cmdPs                    = string.Format("ps");
                        string cmdExit                  = string.Format("exit");
                        DeviceOperation deviceOperation = new DeviceOperation();
                        deviceOperation
                        .SetCmd(connectDeviceCmd)
                        .SetCmd(cmdPs)
                        .SetCmd(cmdExit)
                        .Run2(id, out number);

                        switch (number)
                        {
                        case 0:
                            List <SystemConfig> model = bLL.GetSystemConfigList(id);
                            if (model.Count > 0)
                            {
                                model[0].state = 0;
                                bLL.UpdateSystemConfig(model[0]);
                            }
                            else
                            {
                                SystemConfig sc = new SystemConfig();
                                sc.uid          = id;
                                sc.state        = 0;
                                bLL.AddSystemConfig(sc);
                            }
                            break;

                        case 1:
                            model = bLL.GetSystemConfigList(id);
                            if (model.Count > 0)
                            {
                                model[0].state = 1;
                                bLL.UpdateSystemConfig(model[0]);
                            }
                            else
                            {
                                SystemConfig sc = new SystemConfig();
                                sc.uid          = id;
                                sc.state        = 0;
                                bLL.AddSystemConfig(sc);
                            }
                            break;
                        }
                        //1表示已启动了0表示为没启动com.facebook.katana;判断模拟器是否启动facebook应用,有返回没启动

                        if (number == 0)
                        {
                            #region 启动Facebook
                            if (_runningGroupIndex == -1)
                            {
                                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Error_Please_Launch_A_Vm", SystemLanguageManager.Instance.CultureInfo));
                                return;
                            }
                            string packagename       = "com.facebook.katana";
                            List <Phonenum> listPhon = new PhonenumBLL().SelectPhoneNumber();

                            for (int i = 0; i < VmManager.Instance.Column; i++)
                            {
                                int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i];
                                if (vmIndex != -1)
                                {
                                    ProcessUtils.AdbOpenApps(vmIndex, packagename);
                                }
                            }
                            break;
                            #endregion
                        }
                    }

                    LoginInfo li = new LoginInfo();
                    li.index     = id;
                    li.port      = port2;
                    if (th == null || !th.IsAlive)
                    {
                        th = new Thread(new  ParameterizedThreadStart(AutomaticLogin));
                        th.IsBackground = true;
                        th.Start(li);
                    }
                }
            });
        }