private void Publicar(string arg1, string name, string time, string message = "") { try { string test = GetPageAccessToken(_accessToken); var Variab = new Variables(); var fb = new FacebookClient(test); // make sure to add event handler for PostCompleted. fb.PostCompleted += (o, e) => { // incase you support cancellation, make sure to check // e.Cancelled property first even before checking (e.Error!=null). if (e.Cancelled) { // for this example, we can ignore as we don't allow this // example to be cancelled. // you can check e.Error for reasons behind the cancellation. var cancellationError = e.Error; } else if (e.Error != null) { // error occurred this.BeginInvoke(new MethodInvoker( () => { //MessageBox.Show(e.Error.Message); })); } else { // the request was completed successfully // now we can either cast it to IDictionary<string, object> or IList<object> // depending on the type. or we could use dynamic. dynamic result = e.GetResultData(); _lastMessageId = result.id; // make sure to be on the right thread when working with ui. this.BeginInvoke(new MethodInvoker( () => { //MessageBox.Show("Message Posted successfully"); //txtMessage.Text = string.Empty; //btnDeleteLastMessage.Enabled = true; })); } }; dynamic parameters = new ExpandoObject(); parameters.privacy = new { value = "ALL_FRIENDS", }; parameters.name = name; parameters.message = message; if (arg1.Contains("/wow/en/item/") == true) { parameters.link = "http://us.battle.net" + arg1; } else { parameters.link = "http://us.battle.net/" + arg1; } //parameters.link = "http://us.battle.net/wow/en/character/quelthalas/Amadoflimd/" + arg1; //s.ResponseUri.AbsoluteUri parameters.caption = "Realm: " + Variables.Realm; fb.PostAsync("/" + Variables.PageID + "/feed", parameters); StreamWriter sw = new StreamWriter("C:\\UpdatesGuild.txt", true); //Write a line of text sw.WriteLine(name); //sw.WriteLine(Environment.NewLine); //sw.Flush(); //Close the file sw.Close(); } catch (Exception ex) { } }
private void timer1_Tick(object sender, EventArgs e) { timer1.Stop(); try { var Variab = new Variables(); string PathLog = "http://us.battle.net/wow/en/guild/" + Variables.Realm + "/" + Variables.Guild + "/"; try { WebRequest request = WebRequest.Create(PathLog); request.Timeout = 4000; WebResponse response = request.GetResponse(); data = response.GetResponseStream(); response = null; string html = String.Empty; } catch (Exception ex) { } System.IO.StreamReader sr = new StreamReader(data); string line = null; while ((sr.Peek() >= 0)) { string resultlist = null; line = sr.ReadLine(); if (((line.Contains("/achievement#") == true) || (line.Contains("<a href=\"/wow/en/item/") == true)) && line.Contains("</a>") == true && line.Contains("class=\"icon\"") == false) { string linea = line; string url; //linea.Replace("</a>", ""); ////linea.Replace('\t', string.Empty); //int index1 = linea.IndexOf('\t'); // 2B. //int index2 = linea.IndexOf('t', index1 + 1); int index1; int index2; if (line.Contains("The guild") == true) { linea = linea.Replace("'", ""); index1 = linea.IndexOf('"'); // 2B. index2 = linea.IndexOf('"', index1 + 1); url = linea.Substring(index1 + 1, (index2) - (index1 + 1)); linea = linea.Remove(0, 1); // 2D. index1 = linea.IndexOf('<'); index2 = linea.IndexOf('>', index1 + 1); linea = linea.Remove(index1, (index2 + 1) - index1); // 2D. index1 = linea.IndexOf('<'); index2 = linea.IndexOf('>', index1 + 1); linea = linea.Remove(index1, (index2 + 1) - index1); // 2D. } else { linea = linea.Replace("'", ""); index1 = linea.IndexOf('<'); index2 = linea.IndexOf('>', index1 + 1); linea = linea.Remove(index1, (index2 + 1) - index1); // 2D. index1 = linea.IndexOf('"'); // 2B. index2 = linea.IndexOf('"', index1 + 1); url = linea.Substring(index1 + 1, (index2) - (index1 + 1)); linea = linea.Remove(0, 1); // 2D. index1 = linea.IndexOf('<'); index2 = linea.IndexOf('>', index1 + 1); linea = linea.Remove(index1, (index2 + 1) - index1); // 2D. index1 = linea.IndexOf('<'); index2 = linea.IndexOf('>', index1 + 1); linea = linea.Remove(index1, (index2 + 1) - index1); // 2D. index1 = linea.IndexOf('<'); index2 = linea.IndexOf('>', index1 + 1); linea = linea.Remove(index1, (index2 + 1) - index1); // 2D. } if (line.Contains("Completed step") == true) { //COMPLETED STEP index1 = linea.IndexOf('<'); index2 = linea.IndexOf('>', index1 + 1); linea = linea.Remove(index1, (index2 + 1) - index1); // 2D. index1 = linea.IndexOf('<'); index2 = linea.IndexOf('>', index1 + 1); linea = linea.Remove(index1, (index2 + 1) - index1); // 2D. } //linea = linea.Replace(">", ""); var items = new List<string>(); //File.Create("C:\\Updates.txt"); using (var stream = File.OpenRead("C:\\UpdatesGuild.txt")) // open file using (var reader = new StreamReader(stream)) // read the stream with TextReader { string linex; // read until no more lines are present while ((linex = reader.ReadLine()) != null) { items.Add(linex); } reader.Close(); } foreach (string result in items) // Loop through List with foreach { if (result == linea) { resultlist = linea; } } if (resultlist != linea) { double times; times = Convert.ToDouble(time); list.Add(linea); //arg1 = arg1.Replace("Quest accepted: ", ""); Tiempo(1); DateTime NextMonth = DateAndTime.DateAdd("s", times, "01/01/1970 00:00:00"); Publicar(url, linea, NextMonth.ToString(), linea); } } //if (line.Contains("[\"type\"]") == true) //{ // type = line.Replace("[\"type\"] ", ""); // type = type.Replace("= ", ""); // type = type.Replace(",", ""); // type = type.Replace("\t", ""); // type = type.Replace(@"""", ""); // //type = line.Replace(" ", ""); //} //if (line.Contains("[\"time\"]") == true) //{ // time = line.Replace("[\"time\"] ", ""); // time = time.Replace("= ", ""); // time = time.Replace(",", ""); // time = time.Replace("\t", ""); // time = time.Replace(@"""", ""); // //type = line.Replace(" ", ""); //} //if (line.Contains("[\"arg1\"]") == true) //{ // arg1 = line.Replace("[\"arg1\"] ", ""); // arg1 = arg1.Replace("= ", ""); // arg1 = arg1.Replace(",", ""); // arg1 = arg1.Replace("\t", ""); // arg1 = arg1.Replace(@"""", ""); // //arg1 = line.Replace(" ", ""); //} //if (line.Contains("[\"arg2\"]") == true) //{ // arg2 = line.Replace("[\"arg2\"] ", ""); // arg2 = arg2.Replace("= ", ""); // arg2 = arg2.Replace(",", ""); // arg2 = arg2.Replace("\t", ""); // arg2 = arg2.Replace(@"""", ""); // //arg2 = line.Replace(" ", ""); //} } sr.Dispose(); //sr2.Dispose(); //File.Delete("C:/ElephantFB.lua"); //File.Copy("C:/Elephant.lua", "C:/ElephantFB.lua"); //while //{ //} } catch (Exception ex) { //MessageBox.Show(ex.Message); } timer1.Start(); }