예제 #1
0
 /// <summary>
 /// Send messages
 /// </summary>
 private static void Send()
 {
     foreach (var s in listID)
     {
         option = new OptionMessage(s, login);
         _facebookHttpRequest.SendMessage(login, Message, option);
         if (_facebookHttpRequest.OutputMessage == "Message Sent")
         {
             Console.WriteLine("Đã gửi thành công đến " + s);
         }
         else
         {
             Console.WriteLine("Đã có lỗi xảy ra!");
         }
         Thread.Sleep(300);
     }
     Console.WriteLine("Đã hoàn tất!");
 }
예제 #2
0
        /// <summary>
        /// This Method used to send Message for this Person indetify with ID
        /// </summary>
        /// <param name="id">User id</param>
        private void SendMessage(string id)
        {
            try
            {
                option = new OptionMessage(id, auth);
                switch (request.SendMessage(auth, GetMessageContent(), option))
                {
                case "Message Sent":
                    if (sucess.InvokeRequired)
                    {
                        sucess.Invoke((MethodInvoker) delegate
                        {
                            UpdateGrid(UpdateGridOptions.Sucsess, new SucsessGrid()
                            {
                                Entity = id, Message = "Message was Sent", CreateAt = DateTime.Now
                            });
                        });
                    }
                    else
                    {
                        UpdateGrid(UpdateGridOptions.Sucsess, new SucsessGrid()
                        {
                            Entity = id, Message = "Message was Sent", CreateAt = DateTime.Now
                        });
                    }
                    SentCount++;
                    MessegesSentCount.Invoke((MethodInvoker) delegate
                    {
                        // Running on the UI thread
                        MessegesSentCount.Text = SentCount.ToString();
                    });
                    break;

                case "Facebook Auth Error":
                    if (error.InvokeRequired)
                    {
                        error.Invoke((MethodInvoker) delegate
                        {
                            UpdateGrid(UpdateGridOptions.Failed, new FiledGrid()
                            {
                                Entity = id, Errors = "Canet Send Message", CreateAt = DateTime.Now
                            });
                        });
                    }
                    else
                    {
                        UpdateGrid(UpdateGridOptions.Failed, new FiledGrid()
                        {
                            Entity = id, Errors = "Canet Send Message", CreateAt = DateTime.Now
                        });
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                if (error.InvokeRequired)
                {
                    error.Invoke((MethodInvoker) delegate
                    {
                        UpdateGrid(UpdateGridOptions.Failed, new FiledGrid()
                        {
                            Entity = id, Errors = ex.Message, CreateAt = DateTime.Now
                        });
                    });
                }
                else
                {
                    UpdateGrid(UpdateGridOptions.Failed, new FiledGrid()
                    {
                        Entity = id, Errors = ex.Message, CreateAt = DateTime.Now
                    });
                }
            }
        }