-
Notifications
You must be signed in to change notification settings - Fork 0
/
Messageria_EnviarDM.aspx.cs
82 lines (68 loc) · 3.12 KB
/
Messageria_EnviarDM.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AmosBatista.MensagemSecreta.App;
using System.Text;
using System.Collections;
namespace AmosBatista.ComicServer.WebServer
{
public partial class Messageria_EnviarDM : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Expires = -1;
//var userProcessedInternalList = new SortedList<string, string>();
var errorMessage = new StringBuilder();
// Validating the information sent
if (Request["userList"] == null)
errorMessage.AppendLine("Não foi informado nenhuma conta do Twitter para enviar a mensagem. Por favor, informe um usuário ou uma lista de usuários válidos. ");
else
{
if (Request["userList"].Trim() == "")
errorMessage.AppendLine("O campo de usuários do Twitter está em branco. Por favor, informe um usuário ou uma lista de usuários válidos. ");
}
if (Request["message"] == null)
errorMessage.AppendLine("Nenhuma mensagem foi definida para envio. Favor informar uma mensagem. ");
else
{
if (Request["message"].Trim() == "")
errorMessage.AppendLine("Nenhuma mensagem foi definida para envio. Favor informar uma mensagem. ");
}
// Informing the error message
if (errorMessage.Length > 0)
{
lblStatusMessage.Text = errorMessage.ToString();
}
else
{
lblStatusMessage.Text = "A requisição foi efetuada.";
// Reading the user list and preparing the list
string[] userList = Request["userList"].Split(",".ToCharArray());
// For each user in the list
var twitterMessageAPP = new TwitterAPI();
string twitterAPPResponse;
var strUserList = new StringBuilder();
lblProcessedUserList.Text = "Verifique abaixo os usuários que foram processados, e a mensagem de seu status:";
for (int userCont = 0; (userCont < userList.Length) || (userList.Length == 1); userCont++)
{
try
{
// Call the app and send the message
twitterAPPResponse = twitterMessageAPP.SendTwitterDirectMessage(userList[userCont], Request["message"]);
strUserList.Append(userList[userCont] + " - " + twitterAPPResponse + ";");
}
catch (Exception ex)
{
strUserList.Append("Ocorreu a seguinte falha ao executar requisições e ela foi interrompida: " + ex.Message);
break;
}
}
// Showing the result
userProcessedList.Text = strUserList.ToString();
}
}
}
}