// Copyright 2005 by Omar Al Zabir. All rights are reserved.
//
// If you like this code then feel free to go ahead and use it.
// The only thing I ask is that you don't remove or alter my copyright notice.
//
// Your use of this software is entirely at your own risk. I make no claims or
// warrantees about the reliability or fitness of this code for any particular purpose.
// If you make changes or additions to this code please mark your code as being yours.
//
// website http://www.oazabir.com, email OmarAlZabir@gmail.com, msn oazabir@hotmail.com
using System;
using System.Text;
using System.Net;
using System.Web;
using System.Xml;
using System.IO;
using System.Collections;
using System.Xml.Xsl;
using System.Xml.XPath;
using GotDotNet.Exslt;
namespace RSSTests{
using RSSCommon;
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//HtmlTransform();
//EXSLT();
//FeedProcessor();
HttpPostTest();
}
static void HttpPostTest()
{
HttpWebRequest req = null;
try
{
req = (HttpWebRequest) HttpWebRequest.Create(new Uri("http://sourceforge.net/tracker/index.php"));
}
catch (Exception err)
{
return;
}
CookieContainer CookieCont= new CookieContainer();
req.AllowAutoRedirect = true;
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)";
req.CookieContainer = CookieCont;
req.Referer = "http://sourceforge.net/tracker/?func=add&group_id=140453&atid=746427";
req.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-powerpoint, application/vnd.ms-excel, */*";
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
StringBuilder postData = new StringBuilder();
postData.AppendFormat("{0}={1}&", HttpUtility.UrlEncode("group_id"), HttpUtility.UrlEncode("140453"));
postData.AppendFormat("{0}={1}&", HttpUtility.UrlEncode("atid"), HttpUtility.UrlEncode("746427"));
postData.AppendFormat("{0}={1}&", HttpUtility.UrlEncode("func"), HttpUtility.UrlEncode("postadd"));
postData.AppendFormat("{0}={1}&", HttpUtility.UrlEncode("summary"), HttpUtility.UrlEncode("Bug post"));
postData.AppendFormat("{0}={1}&", HttpUtility.UrlEncode("details"), HttpUtility.UrlEncode("Testing bug post"));
postData.Remove(postData.Length - 1, 1);
byte[] postDataBytes = Encoding.UTF8.GetBytes(postData.ToString());
req.ContentLength = postDataBytes.Length;
Stream postDataStream = req.GetRequestStream();
postDataStream.Write(postDataBytes, 0, postDataBytes.Length);
postDataStream.Close();
HttpWebResponse resp = null;
try
{
resp = (HttpWebResponse) req.GetResponse();
}
catch (WebException err)
{
return;
}
catch
{
return;
}
Stream rcvStream = resp.GetResponseStream();
byte[] respBytes = new byte[256];
//int byteCount;
resp.Close();
rcvStream.Close();
}
static void EXSLT()
{
ExsltTransform xslt = new ExsltTransform();
xslt.SupportedFunctions = ExsltFunctionNamespace.All;
xslt.MultiOutput = false;
xslt.Load("atomtorss2.xslt");
xslt.Transform("atom.xml", "rss.xml");
}
static void HtmlTransform()
{
ExsltTransform xslt = new ExsltTransform();
xslt.SupportedFunctions = ExsltFunctionNamespace.All;
xslt.MultiOutput = false;
xslt.Load("outlook.xslt");
xslt.Transform("msdnblogs.xml", "msdnblogs.html");
}
static void FeedProcessor()
{
FeedProcessor processor = new FeedProcessor();
//XmlTextReader reader = new XmlTextReader( @"D:\WORK\Blogs\rss2.xml" );
XmlTextReader reader = new XmlTextReader( @"rss2.xml" );
IList channels = processor.Parse( reader );
reader.Close();
StreamWriter streamWriter = new StreamWriter( @"out.xml" );
XmlTextWriter writer = new XmlTextWriter( streamWriter );
foreach( RssChannel channel in channels )
{
channel.WriteHeader( writer );
channel.WriteStartElement( writer );
foreach( RssFeed feed in channel.Feeds )
{
streamWriter.Write( feed.XML );
}
channel.WriteEndElement(writer);
channel.WriteFooter( writer );
}
writer.Close();
}
}
}
|