Example #1
0
 public void Handle(PublishTextTaskMsg info)
 {
     try
     {
         var postData = GetPublishData(info);
         var r = BuildPostRequest(info);
         r.ContentLength = postData.Length;
         var s = r.GetRequestStream();
         s.Write(postData, 0, postData.Length);
         s.Close();
         var response = (HttpWebResponse)r.GetResponse();
         HandleResponse(response);
     }
     catch(Exception x)
     {
         _publisher.Publish(new ExceptionMsg(x));
     }
 }
Example #2
0
 private byte[] GetPublishData(PublishTextTaskMsg info)
 {
     var obj = new
                {
                    title = info.Title,
                    tags = GetTags(info.Tags),
                    publishdate = info.PublishDate,
                    isMarkdown = true,
                    body = _lastCapturedMarkdown
                };
     var ser = new JavaScriptSerializer();
     var json = ser.Serialize(obj);
     return Encoding.UTF8.GetBytes(json);
 }
Example #3
0
 private static HttpWebRequest BuildPostRequest(PublishTextTaskMsg info)
 {
     var r = (HttpWebRequest)HttpWebRequest.Create(info.Server + "/admin/post");
     r.Headers.Add("X-RfSite-AdminToken", info.Token);
     r.ContentType = "application/json";
     r.Method = "POST";
     return r;
 }