private async void btnLaunchWhatsApp_Click(object sender, RoutedEventArgs e) { if (_runningGroupIndex == -1) { MessageBox.Show(resourceManager.GetString("Error_Please_Launch_A_Vm", cultureInfo)); return; } string packagename = "com.whatsapp"; List <Phonenum> listPhon = new PhonenumBLL().SelectPhoneNumber(); for (int i = 0; i < VmManager.Instance.Column; i++) { int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i]; //获取imei、androidid值 di = new System.Collections.Generic.Dictionary <int, Wx.Qunkong360.Wpf.Abstract.VmModel>(VmManager.Instance._vmModels); if (vmIndex != -1) { ProcessUtils.AdbOpenApps(vmIndex, packagename); } #region 获取登录信息 List <Simulators> list = SimulatorsBLL.GetSimulatorsList(); int listcount = list.Count; if (listPhon.Count != 0) { AppOptViewModel.simulators.Add(new Simulators() { id = i + listcount + 1, phonenum = listPhon[i].PhoneNum.Substring(1), imei = di[i].Imei, androidid = di[i].AndroidId, created = listPhon[i].Created }); } #endregion } string installNewestAppLog = await AppUpgradeHelper.Instance.InstallNewestApp(); LogUtils.Information(installNewestAppLog); }
/// <summary> /// 更新号码发送结果 /// </summary> /// <param name="phone"></param> /// <param name="response"></param> /// <returns></returns> public int UpdatePhoneStatus(int phone, int response) { int res = PhonenumBLL.updatePhoneStatus(phone, response); return(res); }
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); } } }); }
/// <summary> /// 确定导入号码文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnImport_Click(object sender, RoutedEventArgs e) { //移动文件到指定的目录 var targets = from item in treeviewImportList.ItemsSourceData.FirstOrDefault().Children where item.IsChecked select(int) item.Id - 1; if (targets.Count() == 0) { MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Select_Vm", SystemLanguageManager.Instance.CultureInfo)); return; } List <int> checkMobiles = targets.ToList(); List <string> phoneStr = new List <string>(); TextRange textRange = new TextRange(rtbPhoneNums.Document.ContentStart, rtbPhoneNums.Document.ContentEnd); if (!string.IsNullOrEmpty(textRange.Text)) { phoneStr = textRange.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.None).ToList(); phoneStr = phoneStr.Where(s => !string.IsNullOrEmpty(s)).ToList(); } int flag = 0; if (tbContactPath.Text != "") { StreamReader sr = new StreamReader(tbContactPath.Text, Encoding.Default); string line; while ((line = sr.ReadLine()) != null) { phoneStr.Add(line.ToString()); if (phoneStr.Count > 100000) { flag = -1; break; } } } if (flag == -1) { MessageDialogManager.ShowDialogAsync(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Exceed_Max_Import_Num", SystemLanguageManager.Instance.CultureInfo))); return; } //插入到任务表中 int sr1 = 21 / 1; int onenums = phoneStr.Count / checkMobiles.Count; PhonenumBLL phonebll = new PhonenumBLL(); //TasksBLL taskbll = new TasksBLL(); for (int m = 0; m < checkMobiles.Count; m++) { int res = 0; List <string> strIds = new List <string>(); if (checkMobiles.Count > 1 && m == checkMobiles.Count - 1) { onenums = phoneStr.Count; } for (int i = 0; i < onenums; i++) { Phonenum phone = new Phonenum(); phone.PhoneNum = phoneStr[i]; phone.SimulatorId = checkMobiles[m]; phone.Status = 0; //待导入 int nflag = phonebll.InsertPhoneNum(phone); if (nflag > 0) { res++; } strIds.Add(phone.PhoneNum); } if (strIds != null && strIds.Count > 0) { for (int j = 0; j < strIds.Count; j++) { phoneStr.Remove(strIds[j]); } } //号码写入文件 string filepath = CopyPhoneNumsFile(strIds, checkMobiles[m]); var lists = new JArray { }; if (filepath != "") { lists.Add(filepath); var obj = new JObject() { { "tasktype", 1 }, { "txtmsg", "" } }; obj.Add("list", lists); //插入任务 TaskSch tasks = new TaskSch(); tasks.TypeId = 1; tasks.Remotes = checkMobiles[m].ToString(); tasks.MobileIndex = checkMobiles[m]; tasks.Bodys = obj.ToString(Formatting.None); //tasks.Bodys = JsonConvert.SerializeObject(new string[] { "tasktype:1", "txtmsg:", "filepath:"+ filepath, "nums:"+res}); tasks.Status = "waiting"; tasks.ResultVal = ""; tasks.RepeatNums = 1; tasks.RandomMins = 5; tasks.RandomMaxs = 12; tasks.IsStep = 0; TasksBLL.CreateTask(tasks); } } //启动任务列表 if (ConfigVals.IsRunning != 1) { Task.Run(async() => { await ProessTask(); }); } MessageDialogManager.ShowDialogAsync(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), checkMobiles.Count)); }