public void Post(string url, string verb, string content) { var qtask = new QueuedTask2() { AccountId = LocalAccountId, Url = url, PostData = content, Verb = verb }; lock (Database.Main) Database.Main.Insert(qtask); FlushTasks(); }
// // TODO ITEMS: // * Need to change this to use HttpWebRequest, since I need to erad // the result back and create a tweet out of it, and insert in DB. // // * Report error to the user? Perhaps have a priority flag // (posts show dialog, btu starring does not? // // Runs on a thread from the threadpool. void PostTask(QueuedTask2 [] tasks) { var client = GetClient (); try { Util.PushNetworkActive (); foreach (var task in tasks){ Uri taskUri = new Uri (task.Url); client.Headers [HttpRequestHeader.Authorization] = OAuthAuthorizer.AuthorizeRequest (OAuthConfig, OAuthToken, OAuthTokenSecret, "POST", taskUri, task.PostData); try { var res = client.UploadData (taskUri, task.Verb, Encoding.UTF8.GetBytes (task.PostData)); //var r = new StreamReader (new MemoryStream (res)); //Console.WriteLine (r.ReadToEnd ()); } catch (Exception e){ // Can happen if we had already favorited this status Console.WriteLine ("Can happen if we already favorited: {0}", e); } lock (Database.Main) Database.Main.Execute ("DELETE FROM QueuedTask2 WHERE TaskId = ?", task.TaskId); } } catch (Exception e) { Console.WriteLine (e); } finally { Util.PopNetworkActive (); } }
public void Post(string url, string verb, string content) { var qtask = new QueuedTask2 () { AccountId = LocalAccountId, Url = url, PostData = content, Verb = verb }; lock (Database.Main) Database.Main.Insert (qtask); FlushTasks (); }