Пример #1
0
        private static void HandleInfo(VerificationCode verificationCode)
        {
            Console.WriteLine($"手机号:{verificationCode.PhoneNum}, 验证码:{verificationCode.Code}");

            try
            {
                var obj = new JObject()
                {
                    { "tasktype", (int)TaskType.SendVerificationCode }, { "txtmsg", verificationCode.Code }
                };
                var list = new JArray();
                obj.Add("list", list);

                int vmIndex = VmManager.Instance.VmModels.Values.FirstOrDefault(vm => vm.PhoneNumber == verificationCode.PhoneNum).Index;

                TaskSch taskSch = new TaskSch()
                {
                    Bodys       = obj.ToString(Formatting.None),
                    MobileIndex = vmIndex,
                    TypeId      = (int)TaskType.SendVerificationCode,
                    Status      = "waiting",
                };

                TasksBLL.CreateTask(taskSch);

                ConfigVals.IsRunning = 1;
                TasksSchedule tasks = new TasksSchedule();
                tasks.ProessTask();
            }
            catch (Exception ex)
            {
                LogUtils.Error($"{ex}");
            }
        }
Пример #2
0
        /// <summary>
        /// 通过好友请求
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_AllowRequestSubmitTask_Click(object sender, RoutedEventArgs e)
        {
            List <int> targets = new List <int>();

            foreach (var item in treeviewAllowRequestFriend.ItemsSourceData)
            {
                foreach (var subItem in item.Children)
                {
                    if (subItem.IsChecked)
                    {
                        targets.Add((int)subItem.Id - 1);
                    }
                }
            }
            if (targets.Count() == 0)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Select_Vm", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            List <int> checkMobiles = targets.ToList();
            TaskSch    task         = new TaskSch();
            TasksBLL   bll          = new TasksBLL();

            int nums = 0;

            for (int m = 0; m < checkMobiles.Count; m++)
            {
                var lists = new JArray
                {
                };
                var obj = new JObject()
                {
                    { "opernums", txt_AllowRequestFriend.Text }, { "tasktype", (int)TaskType.AllowRequestFriend }, { "txtmsg", "" }
                };
                obj.Add("list", lists);

                task.TypeId      = (int)TaskType.AllowRequestFriend;
                task.Remotes     = checkMobiles[m].ToString();
                task.MobileIndex = checkMobiles[m];
                task.Bodys       = obj.ToString(Formatting.None);
                task.Status      = "waiting";
                task.ResultVal   = "";
                task.RepeatNums  = Int32.Parse(txt_AllowRequestFriend.Text);
                task.RandomMins  = Int32.Parse(txt_AllowRequestMinFriend.Text);
                task.RandomMaxs  = Int32.Parse(txt_AllowRequestMaxFriend.Text);
                task.IsWhole     = 0;//checkIsWholeRequestFriend.IsChecked==true ? 1 : 0;
                task.IsStep      = 1;
                task.StartTime   = TimedTaskManager.Instance.StartTime;

                TasksBLL.CreateTask(task);
                nums++;
            }

            //启动任务列表
            GlobalTaskManager.Instance.StartCheckingGlobalTasks();

            MessageDialogManager.ShowDialogAsync(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), nums));
        }
Пример #3
0
        /// <summary>
        /// 通过好友请求
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_AllowRequestSubmitTask_Click(object sender, RoutedEventArgs e)
        {
            var targets = from item in treeviewAllowRequestFriend.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();
            TaskSch    task         = new TaskSch();
            TasksBLL   bll          = new TasksBLL();

            int nums = 0;

            for (int m = 0; m < checkMobiles.Count; m++)
            {
                var lists = new JArray
                {
                };
                var obj = new JObject()
                {
                    { "opernums", txt_AllowRequestFriend.Text }, { "tasktype", (int)TaskType.AllowRequestFriend }, { "txtmsg", "" }
                };
                obj.Add("list", lists);

                task.TypeId      = (int)TaskType.AllowRequestFriend;
                task.Remotes     = checkMobiles[m].ToString();
                task.MobileIndex = checkMobiles[m];
                task.Bodys       = obj.ToString(Formatting.None);
                task.Status      = "waiting";
                task.ResultVal   = "";
                task.RepeatNums  = Int32.Parse(txt_AllowRequestFriend.Text);
                task.RandomMins  = Int32.Parse(txt_AllowRequestMinFriend.Text);
                task.RandomMaxs  = Int32.Parse(txt_AllowRequestMaxFriend.Text);
                task.IsWhole     = 0;//checkIsWholeRequestFriend.IsChecked==true ? 1 : 0;
                task.IsStep      = 1;
                TasksBLL.CreateTask(task);
                nums++;
            }

            //启动任务列表
            if (ConfigVals.IsRunning != 1)
            {
                Task.Run(async() =>
                {
                    await ProessTask();
                });
            }

            MessageDialogManager.ShowDialogAsync(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), nums));
        }
Пример #4
0
        protected void HandleCreateTask(object sender, EventArgs e)
        {
            string titleTask     = title.Text;
            String startDateTask = startDate.Text;
            String endDateTask   = endDate.Text;
            String statusTask    = TaskStatus.InProgress;
            bool   IsPrivate     = privateScope.Checked;
            string urlFile       = null;

            if (fileInput.HasFile)
            {
                try
                {
                    string fileName = Path.GetFileName(fileInput.FileName);
                    fileInput.SaveAs(Server.MapPath("~") + "/Upload/" + fileName);
                    urlFile = "/Upload/" + fileName;
                }   catch (Exception ex)
                {
                }
            }

            // find list selected user
            List <int> arr = new List <int>();

            foreach (GridViewRow row in usersGridView.Rows)
            {
                CheckBox checkBox = (CheckBox)row.FindControl("checkbox");
                if (checkBox.Checked)
                {
                    arr.Add(Int32.Parse(usersGridView.DataKeys[row.RowIndex].Value.ToString()));
                }
            }

            TasksDTO task    = new TasksDTO(titleTask, startDateTask, endDateTask, statusTask, IsPrivate, urlFile);
            int      ownerId = Convert.ToInt32(Session["id"].ToString());

            TasksBLL.CreateTask(task, arr, ownerId);

            TasksBLL.expiringTask();
            GridViewTaskBind();
            GridViewUserBind();
            GridViewTasksDayOfWeek(null); // get current date time

            Helper.Toast(this, Page.ClientScript, "success", "Create task sussess");
        }
Пример #5
0
        /// <summary>
        /// 提交任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGroupFriendSubmit_Click(object sender, RoutedEventArgs e)
        {
            var targets = from item in treeviewAddGroupUser.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();
            TaskSch    task         = new TaskSch();
            TasksBLL   bll          = new TasksBLL();

            //小组数量
            List <string> groupStr  = new List <string>();
            TextRange     textPages = new TextRange(rtbAddPageFriend.Document.ContentStart, rtbAddPageFriend.Document.ContentEnd);

            if (!string.IsNullOrEmpty(textPages.Text))
            {
                groupStr = textPages.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.None).ToList();
                groupStr = groupStr.Where(s => !string.IsNullOrEmpty(s)).ToList();
            }
            if (groupStr.Count != checkMobiles.Count)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Facebook_Check_GroupNums", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            int nums = 0;

            for (int m = 0; m < checkMobiles.Count; m++)
            {
                var lists = new JArray
                {
                };
                var obj = new JObject()
                {
                    { "opernums", txt_GroupFriendFriend.Text }, { "tasktype", (int)TaskType.AddPageFriends }, { "txtmsg", "" }
                };
                lists.Add(groupStr[m]);
                obj.Add("list", lists);

                task.TypeId      = (int)TaskType.AddGroupUsers;
                task.Remotes     = checkMobiles[m].ToString();
                task.MobileIndex = checkMobiles[m];
                task.Bodys       = obj.ToString(Formatting.None);
                task.Status      = "waiting";
                task.ResultVal   = "";
                task.RepeatNums  = Int32.Parse(txt_GroupFriendFriend.Text);
                task.RandomMins  = Int32.Parse(txt_GroupFriendMinFriend.Text);
                task.RandomMaxs  = Int32.Parse(txt_GroupFriendMaxFriend.Text);
                task.InputName   = groupStr[m];
                task.IsStep      = 1;
                TasksBLL.CreateTask(task);
                nums++;
            }

            //启动任务列表
            if (ConfigVals.IsRunning != 1)
            {
                Task.Run(async() =>
                {
                    await ProessTask();
                });
            }

            MessageDialogManager.ShowDialogAsync(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), nums));
        }
Пример #6
0
        private void btnSubmitTask_FriendsSomePraise_Click(object sender, RoutedEventArgs e)
        {
            var targets = from item in tvInviteToPraise.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;
            }
            int    operationTimes;
            string strOperationTimes = txtOperationTimes.Text.Trim();

            if (!int.TryParse(strOperationTimes, out operationTimes))
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Number_Of_Operations_Per_Cell_Phone", SystemLanguageManager.Instance.CultureInfo));
                return;
            }
            string groups = txtGroupNamePraise.Text.Trim();

            string[] groupArr = groups.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            if (groupArr?.Length == 0)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Group_Name", SystemLanguageManager.Instance.CultureInfo));

                return;
            }

            //List<Task<bool>> tasks = new List<Task<bool>>();
            TaskSch task = new TaskSch();

            //List<int> remotes = new List<int>();

            for (int i = 0; i < targets.Count(); i++)
            {
                //tasks.Add(TasksSchedule.InviteFriendsToLikeAsync(targets.ElementAt(i), groupArr[0], operationTimes));

                var lists = new JArray()
                {
                };
                var obj = new JObject()
                {
                    { "opernums", txtOperationTimes.Text }, { "tasktype", (int)TaskType.InviteFriendsLike }, { "txtmsg", "" }
                };
                obj.Add("list", lists);

                int id = Guid.NewGuid().GetHashCode();
                //remotes.Add(id);
                task.Remotes     = $"{id}";
                task.TypeId      = (int)TaskType.InviteFriendsLike;
                task.MobileIndex = targets.ElementAt(i);
                task.Bodys       = obj.ToString(Formatting.None);
                task.Status      = "waiting";
                task.ResultVal   = "";
                task.RepeatNums  = Convert.ToInt32(txtOperationTimes.Text.Trim());
                task.RandomMins  = Convert.ToInt32(tbBeginningIntervMin.Text.Trim());
                task.RandomMaxs  = Convert.ToInt32(txtEndingIntervaMax.Text.Trim());
                task.InputName   = groupArr[0];
                task.IsStep      = 1;

                TasksBLL.CreateTask(task);
            }

            MessageQueueManager.Instance.AddInfo(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), targets.Count()));

            //启动任务列表
            if (ConfigVals.IsRunning != 1)
            {
                Task.Run(async() =>
                {
                    await ProessTask();
                });
            }
        }
Пример #7
0
        private void btnSubmitTask_TimelineLike2_Click(object sender, RoutedEventArgs e)
        {
            string str_slideTimes  = tbSlideNumber2.Text.Trim();
            string str_likeTimes   = tbLikeNumber2.Text.Trim();
            string str_minInterval = tbBeginningInterval2.Text.Trim();
            string str_maxInterval = tbEndingInterval2.Text.Trim();
            string str_friendNum   = tbClickFriendsNumber.Text.Trim();

            int slideTimes, likeTimes, friendNum, minInterval, maxInterval;

            if (!int.TryParse(str_slideTimes, out slideTimes))
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Invalid_Slide_Time", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            if (!int.TryParse(str_likeTimes, out likeTimes))
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Invalid_Like_Time", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            if (!int.TryParse(str_minInterval, out minInterval) || !int.TryParse(str_maxInterval, out maxInterval))
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Invalid_Interval", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            if (minInterval >= maxInterval)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Starting_Interval_Greater_Than_Ending", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            if (minInterval < 1)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Starting_Interval_Less_Than_One", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            if (!int.TryParse(str_friendNum, out friendNum))
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Invalid_Friend_Num", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            var targets = from item in treeviewTimeline2.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<Task<bool>> tasks = new List<Task<bool>>();

            TaskSch taskSch = new TaskSch();

            //List<int> remotes = new List<int>();

            foreach (var target in targets)
            {
                //tasks.Add(TasksSchedule.FriendTimelineLike(target, slideTimes, likeTimes, friendNum, minInterval, maxInterval));


                var list = new JArray();
                var obj  = new JObject()
                {
                    //{"slidenums",slideTimes },
                    { "opernums", likeTimes },
                    { "tasktype", (int)TaskType.FriendTimelineLike },
                    { "txtmsg", "" }
                };
                obj.Add("list", list);


                int id = Guid.NewGuid().GetHashCode();

                //remotes.Add(id);

                taskSch.Remotes     = $"{id}";
                taskSch.TypeId      = (int)TaskType.FriendTimelineLike;
                taskSch.MobileIndex = target;
                taskSch.Bodys       = obj.ToString(Formatting.None);
                taskSch.Status      = "waiting";
                taskSch.ResultVal   = string.Empty;
                taskSch.SlideNums   = slideTimes;
                taskSch.FriendNums  = friendNum;
                taskSch.RepeatNums  = likeTimes;
                taskSch.RandomMins  = minInterval;
                taskSch.RandomMaxs  = maxInterval;
                //taskSch.InputName = friendArr[i];
                taskSch.IsStep    = 1;
                taskSch.StartTime = TimedTaskManager.Instance.StartTime;

                TasksBLL.CreateTask(taskSch);
            }

            MessageQueueManager.Instance.AddInfo(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), targets.Count()));

            GlobalTaskManager.Instance.StartCheckingGlobalTasks();


            //try
            //{
            //    MessageQueueManager.Instance.AddInfo(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), tasks.Count));

            //    EventAggregatorManager.Instance.EventAggregator.GetEvent<TaskUpdatedEvent>().Publish($"{tasks.Count}/{tasks.Count}");

            //    bool[] results = await Task.WhenAll(tasks);

            //    EventAggregatorManager.Instance.EventAggregator.GetEvent<TaskUpdatedEvent>().Publish($"0/{tasks.Count}");

            //    for (int i = 0; i < results.Length; i++)
            //    {
            //        int status = results[i] ? 1 : -1;
            //        int remote = remotes[i];
            //        TasksDAL.UpdateTaskStatusByRemotes($"{remote}", status);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    EventAggregatorManager.Instance.EventAggregator.GetEvent<TaskUpdatedEvent>().Publish($"0/{tasks.Count}");

            //    MessageDialogManager.ShowDialogAsync(ex.Message);
            //}
        }
Пример #8
0
        private void btnSubmitTask_SearchFriend_Click(object sender, RoutedEventArgs e)
        {
            var targets = from item in treeviewSearchFriend.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;
            }


            int    addTimes;
            string strAddTimes = tbAddTimes.Text.Trim();

            if (!int.TryParse(strAddTimes, out addTimes))
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Invalid_Operation_Times", SystemLanguageManager.Instance.CultureInfo));

                return;
            }

            string friends = tbFriends.Text.Trim();

            string[] friendArr = friends.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);


            if (friendArr?.Length != targets.Count())
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("NumOfPhone_Friends_Mismatch", SystemLanguageManager.Instance.CultureInfo));

                return;
            }


            //List<Task<bool>> tasks = new List<Task<bool>>();

            TaskSch taskSch = new TaskSch();

            //List<int> remotes = new List<int>();

            for (int i = 0; i < targets.Count(); i++)
            {
                var list = new JArray();
                var obj  = new JObject()
                {
                    { "opernums", addTimes },
                    { "tasktype", (int)TaskType.SearchAndAddFriend },
                    { "txtmsg", "" }
                };
                obj.Add("list", list);


                int id = Guid.NewGuid().GetHashCode();

                //remotes.Add(id);

                taskSch.Remotes     = $"{id}";
                taskSch.TypeId      = (int)TaskType.SearchAndAddFriend;
                taskSch.MobileIndex = targets.ElementAt(i);
                taskSch.Bodys       = obj.ToString(Formatting.None);
                taskSch.Status      = "waiting";
                taskSch.ResultVal   = string.Empty;
                taskSch.RepeatNums  = addTimes;
                taskSch.RandomMins  = 1;
                taskSch.RandomMaxs  = 2;
                taskSch.InputName   = friendArr[i];
                taskSch.IsStep      = 1;

                TasksBLL.CreateTask(taskSch);
            }

            MessageQueueManager.Instance.AddInfo(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), targets.Count()));

            if (ConfigVals.IsRunning != 1)
            {
                Task.Run(async() =>
                {
                    await ProessTask();
                });
            }


            //try
            //{
            //    MessageQueueManager.Instance.AddInfo(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), tasks.Count));
            //    EventAggregatorManager.Instance.EventAggregator.GetEvent<TaskUpdatedEvent>().Publish($"{tasks.Count}/{tasks.Count}");

            //    bool[] results = await Task.WhenAll(tasks);

            //    EventAggregatorManager.Instance.EventAggregator.GetEvent<TaskUpdatedEvent>().Publish($"0/{tasks.Count}");

            //    for (int i = 0; i < results.Length; i++)
            //    {
            //        int status = results[i] ? 1 : -1;
            //        int remote = remotes[i];
            //        TasksDAL.UpdateTaskStatusByRemotes($"{remote}", status);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    EventAggregatorManager.Instance.EventAggregator.GetEvent<TaskUpdatedEvent>().Publish($"0/{tasks.Count}");

            //    MessageDialogManager.ShowDialogAsync(ex.Message);
            //}
        }
Пример #9
0
        /// <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));
        }
Пример #10
0
        private void btnSubmitTask_InviteToGroup_Click(object sender, RoutedEventArgs e)
        {
            List <int> targets = new List <int>();

            foreach (var item in tvInviteToGroup.ItemsSourceData)
            {
                foreach (var subItem in item.Children)
                {
                    if (subItem.IsChecked)
                    {
                        targets.Add((int)subItem.Id - 1);
                    }
                }
            }
            if (targets.Count() == 0)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Select_Vm", SystemLanguageManager.Instance.CultureInfo));
                return;
            }
            int    operationTimes;
            string strOperationTimes = tbOperationTimesPerPhone.Text.Trim();

            if (!int.TryParse(strOperationTimes, out operationTimes))
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Number_Of_Operations_Per_Cell_Phone", SystemLanguageManager.Instance.CultureInfo));
                return;
            }
            string groups = tbGroupName.Text.Trim();

            string[] groupArr = groups.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            if (groupArr?.Length == 0)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Group_Name", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            //List<Task<bool>> tasks = new List<Task<bool>>();
            TaskSch task = new TaskSch();

            //List<int> remotes = new List<int>();

            for (int i = 0; i < targets.Count(); i++)
            {
                //tasks.Add(TasksSchedule.InviteFriendsToGroupAsync(targets.ElementAt(i), groupArr[0], operationTimes));

                var lists = new JArray
                {
                };
                var obj = new JObject()
                {
                    { "opernums", operationTimes }, { "tasktype", (int)TaskType.InvitingFriends }, { "txtmsg", "" }
                };

                obj.Add("list", lists);


                int id = Guid.NewGuid().GetHashCode();
                //remotes.Add(id);
                task.Remotes     = $"{id}";
                task.TypeId      = (int)TaskType.InvitingFriends;
                task.MobileIndex = targets.ElementAt(i);
                task.Bodys       = obj.ToString(Formatting.None);
                task.Status      = "waiting";
                task.ResultVal   = string.Empty;
                task.RepeatNums  = Convert.ToInt32(tbOperationTimesPerPhone.Text.Trim());
                task.RandomMins  = Convert.ToInt32(tbBeginningIntervalMin.Text.Trim());
                task.RandomMaxs  = Convert.ToInt32(tbEndingIntervalMax.Text.Trim());
                task.InputName   = groupArr[0];
                task.IsStep      = 1;
                task.StartTime   = TimedTaskManager.Instance.StartTime;

                TasksBLL.CreateTask(task);
            }

            MessageQueueManager.Instance.AddInfo(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), targets.Count()));

            //启动任务列表
            GlobalTaskManager.Instance.StartCheckingGlobalTasks();
        }
Пример #11
0
        private void btnSubmitTask_AddGroup_Click(object sender, RoutedEventArgs e)
        {
            List <int> targets = new List <int>();

            foreach (var item in treeviewJoinGroup.ItemsSourceData)
            {
                foreach (var subItem in item.Children)
                {
                    if (subItem.IsChecked)
                    {
                        targets.Add((int)subItem.Id - 1);
                    }
                }
            }

            if (targets.Count() == 0)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Select_Vm", SystemLanguageManager.Instance.CultureInfo));

                return;
            }

            int    addTimes;
            string strAddTimes = tbAddTimes2.Text.Trim();

            if (!int.TryParse(strAddTimes, out addTimes))
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Invalid_Operation_Times", SystemLanguageManager.Instance.CultureInfo));

                return;
            }

            string groups = tbGroupName.Text.Trim();

            string[] groupArr = groups.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);


            if (groupArr?.Length != targets.Count())
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("NumOfPhone_Friends_Mismatch", SystemLanguageManager.Instance.CultureInfo));

                return;
            }

            //List<Task<bool>> tasks = new List<Task<bool>>();
            TaskSch taskSch = new TaskSch();

            //List<int> remotes = new List<int>();


            for (int i = 0; i < targets.Count(); i++)
            {
                //tasks.Add(TasksSchedule.JoinGroupAsync(targets.ElementAt(i), groupArr[i], addTimes));

                var list = new JArray();
                var obj  = new JObject()
                {
                    { "opernums", addTimes },
                    { "tasktype", (int)TaskType.SearchAndJoinGroup },
                    { "txtmsg", "" }
                };
                obj.Add("list", list);


                int id = Guid.NewGuid().GetHashCode();

                //remotes.Add(id);

                taskSch.Remotes     = $"{id}";
                taskSch.TypeId      = (int)TaskType.SearchAndJoinGroup;
                taskSch.MobileIndex = targets.ElementAt(i);
                taskSch.Bodys       = obj.ToString(Formatting.None);
                taskSch.Status      = "waiting";
                taskSch.ResultVal   = string.Empty;
                taskSch.RepeatNums  = addTimes;
                taskSch.RandomMins  = 1;
                taskSch.RandomMaxs  = 2;
                taskSch.InputName   = groupArr[i];
                taskSch.IsStep      = 1;

                taskSch.StartTime = TimedTaskManager.Instance.StartTime;

                TasksBLL.CreateTask(taskSch);
            }

            MessageQueueManager.Instance.AddInfo(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), targets.Count()));

            GlobalTaskManager.Instance.StartCheckingGlobalTasks();


            //try
            //{
            //    MessageQueueManager.Instance.AddInfo(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), tasks.Count));

            //    EventAggregatorManager.Instance.EventAggregator.GetEvent<TaskUpdatedEvent>().Publish($"{tasks.Count}/{tasks.Count}");

            //    bool[] results = await Task.WhenAll(tasks);

            //    EventAggregatorManager.Instance.EventAggregator.GetEvent<TaskUpdatedEvent>().Publish($"0/{tasks.Count}");

            //    for (int i = 0; i < results.Length; i++)
            //    {
            //        int status = results[i] ? 1 : -1;
            //        int remote = remotes[i];
            //        TasksDAL.UpdateTaskStatusByRemotes($"{remote}", status);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    EventAggregatorManager.Instance.EventAggregator.GetEvent<TaskUpdatedEvent>().Publish($"0/{tasks.Count}");

            //    MessageDialogManager.ShowDialogAsync(ex.Message);
            //}
        }
Пример #12
0
        /// <summary>
        /// 提交添加主页好友任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPageFriendSubmit_Click(object sender, RoutedEventArgs e)
        {
            List <int> targets = new List <int>();

            foreach (var item in treeviewAddPageFriend.ItemsSourceData)
            {
                foreach (var subItem in item.Children)
                {
                    if (subItem.IsChecked)
                    {
                        targets.Add((int)subItem.Id - 1);
                    }
                }
            }
            if (targets.Count() == 0)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Select_Vm", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            List <int> checkMobiles = targets.ToList();
            TaskSch    task         = new TaskSch();
            TasksBLL   bll          = new TasksBLL();

            //处理主页数量
            List <string> phoneStr  = new List <string>();
            TextRange     textPages = new TextRange(rtbAddPageFriend.Document.ContentStart, rtbAddPageFriend.Document.ContentEnd);

            if (!string.IsNullOrEmpty(textPages.Text))
            {
                phoneStr = textPages.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.None).ToList();
                phoneStr = phoneStr.Where(s => !string.IsNullOrEmpty(s)).ToList();
            }
            if (phoneStr.Count != checkMobiles.Count)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Check_PageNums", SystemLanguageManager.Instance.CultureInfo));
                return;
            }
            int nums = 0;

            for (int m = 0; m < checkMobiles.Count; m++)
            {
                var lists = new JArray
                {
                };
                var obj = new JObject()
                {
                    { "opernums", txt_PageFriendFriend.Text }, { "tasktype", (int)TaskType.AddPageFriends }, { "txtmsg", "" }
                };
                lists.Add(phoneStr[m]);
                obj.Add("list", lists);

                task.TypeId      = (int)TaskType.AddPageFriends;
                task.Remotes     = checkMobiles[m].ToString();
                task.MobileIndex = checkMobiles[m];
                task.Bodys       = obj.ToString(Formatting.None);
                task.Status      = "waiting";
                task.ResultVal   = "";
                task.RepeatNums  = Int32.Parse(txt_PageFriendFriend.Text);
                task.RandomMins  = Int32.Parse(txt_PageFriendMinFriend.Text);
                task.RandomMaxs  = Int32.Parse(txt_PageFriendMaxFriend.Text);
                task.InputName   = phoneStr[m];
                task.IsStep      = 1;
                task.StartTime   = TimedTaskManager.Instance.StartTime;
                TasksBLL.CreateTask(task);
                nums++;
            }

            //启动任务列表
            GlobalTaskManager.Instance.StartCheckingGlobalTasks();

            MessageDialogManager.ShowDialogAsync(string.Format(SystemLanguageManager.Instance.ResourceManager.GetString("Submitted_Task", SystemLanguageManager.Instance.CultureInfo), nums));
        }