Пример #1
0
        /// <summary>
        /// 任务处理
        /// </summary>
        /// <returns></returns>
        public int ProessTask()
        {
            int res = 0;
            //TasksBLL tasksbll = new TasksBLL();
            int    resnum = TasksBLL.CountByStatus();
            int    intval = 0;
            Random r      = new Random();

            while (resnum > 0)
            {
                intval++;
                List <TaskSch> list = TasksBLL.GetTasksList("waiting", 1);
                if (list != null && list.Count > 0)
                {
                    foreach (var item in list)
                    {
                        string mobileIndex = "";
                        mobileIndex = item.MobileIndex.ToString();  //需要匹配出对应的客户端标识

                        int flag = 0;
                        for (int i = 0; i < item.RepeatNums; i++)
                        {
                            flag = SocketServer.SendTaskInstruct(Int32.Parse(mobileIndex), item.TypeId, item.Id, item.Bodys);
                            int waittime = r.Next(item.RandomMins, item.RandomMaxs);
                            Thread.Sleep(waittime);
                        }

                        TasksBLL.UpdateTaskStatus(item.Id, flag);
                        resnum--;
                    }
                }
                if (resnum <= 0)
                {
                    resnum = TasksBLL.CountByStatus();
                }
            }
            ConfigVals.IsRunning = 0;
            return(res);
        }
Пример #2
0
        /// <summary>
        /// 查询任务
        /// </summary>
        public void getTasksList()
        {
            colNo.Header        = resourceManager.GetString("Col_Id", cultureInfo);
            colTaskType.Header  = resourceManager.GetString("Col_TaskType", cultureInfo);
            colPhone.Header     = resourceManager.GetString("Col_Phone", cultureInfo);
            colParameter.Header = resourceManager.GetString("Col_Parameter", cultureInfo);
            colStatus.Header    = resourceManager.GetString("Col_Status", cultureInfo);
            //colResult.Header = resourceManager.GetString("Col_Result", cultureInfo);
            ColType.Header       = resourceManager.GetString("Col_Type", cultureInfo);
            colTime.Header       = resourceManager.GetString("Col_Time", cultureInfo);
            colStartTime.Header  = resourceManager.GetString("Col_Starttime", cultureInfo);
            colLastExTime.Header = resourceManager.GetString("Col_Lasttime", cultureInfo);

            List <TaskSch> list = TasksBLL.GetTasksList("-1", 2, 1000);

            if (list != null && list.Count() > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    list[i].MobileIndex = list[i].MobileIndex + 1;
                    if (list[i].StartTime2 != "")
                    {
                        list[i].TaskType = resourceManager.GetString("Facebook_TimedTask", cultureInfo);
                    }
                    if (list[i].TypeId == 1)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Import_Address_List", cultureInfo);
                    }
                    else if (list[i].TypeId == 2)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("MomentType_Text", cultureInfo);
                    }
                    else if (list[i].TypeId == 3)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("MomentType_Picture", cultureInfo);
                    }
                    else if (list[i].TypeId == 4)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("MomentType_Picture_Text", cultureInfo);
                    }
                    else if (list[i].TypeId == 5)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("MsgType_Text", cultureInfo);
                    }
                    else if (list[i].TypeId == 6)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("MsgType_Picture", cultureInfo);
                    }
                    else if (list[i].TypeId == 7)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("MsgType_Picture_Text", cultureInfo);
                    }
                    else if (list[i].TypeId == 8)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("MsgType_Video", cultureInfo);
                    }
                    else if (list[i].TypeId == 9)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("MsgType_Video_Text", cultureInfo);
                    }
                    else if (list[i].TypeId == 11)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("WhatsApp_Op_TaskType_UpNickName", cultureInfo);
                    }
                    else if (list[i].TypeId == 15)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Group_MsgType_Picture_Text", cultureInfo);
                    }
                    else if (list[i].TypeId == 16)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Group_MsgType_Text", cultureInfo);
                    }
                    else if (list[i].TypeId == 17)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Group_MsgType_Video", cultureInfo);
                    }
                    else if (list[i].TypeId == 101)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("AddListPhoneNums", cultureInfo);
                    }
                    else if (list[i].TypeId == 20)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("AddFriendByFriend", cultureInfo);
                    }
                    else if (list[i].TypeId == 21)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("AddHomePageFriend", cultureInfo);
                    }
                    else if (list[i].TypeId == 22)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("AddRecommFriend", cultureInfo);
                    }
                    else if (list[i].TypeId == 23)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Facebook_AllowFriend", cultureInfo);
                    }
                    else if (list[i].TypeId == 24)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Facebook_SearchAndAddFriend", cultureInfo);
                    }
                    else if (list[i].TypeId == 25)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Facebook_SearchAndAddGroup", cultureInfo);
                    }
                    else if (list[i].TypeId == 26)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Facebook_FocusHomePage", cultureInfo);
                    }
                    else if (list[i].TypeId == 27)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Facebook_InvitingFriends", cultureInfo);
                    }
                    else if (list[i].TypeId == 28)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Facebook_InviteFriendsLike", cultureInfo);
                    }
                    else if (list[i].TypeId == 29)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Facebook_TimelineLike", cultureInfo);
                    }
                    else if (list[i].TypeId == 30)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Facebook_FriendTimelineLike", cultureInfo);
                    }
                    else if (list[i].TypeId == 31)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Facebook_SendHomepage", cultureInfo);
                    }
                    else if (list[i].TypeId == 32)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Facebook_PublishPost", cultureInfo);
                    }
                    else if (list[i].TypeId == (int)TaskType.AddGroupUsers)
                    {
                        list[i].TypeDescripton = resourceManager.GetString("Facebook_AddGroupUser", cultureInfo);
                    }
                    else
                    {
                        list[i].TypeDescripton = resourceManager.GetString("WhatsApp_Op_Other", cultureInfo);
                    }
                }
            }
            datagrid.ItemsSource = list;
        }