Friday, July 23, 2010

HelpFull links on SSRS

http://www.simple-talk.com/sql/reporting-services/ten-common-sql-server-reporting-services-challenges-and-solutions/

http://www.beansoftware.com/ASP.NET-Tutorials/SQL-Server-Reporting-Services.aspx

Thursday, July 15, 2010

Decryption Code for AlertPay EPD

string Salt_Key = [Your IPN Security Code];
private readonly byte[] Ivector = Encoding.Default.GetBytes("alertpay");
private string Decrypt(string Input)
{
byte[] Buffer = Convert.FromBase64String(Input);
TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider();
tripleDES.Key = Encoding.Default.GetBytes(Salt_Key);
tripleDES.IV = Ivector;
//tripleDES.Padding = PaddingMode.Zeros;
tripleDES.Mode = CipherMode.CBC;
ICryptoTransform Transform = tripleDES.CreateDecryptor();
return HttpUtility.UrlDecode(Encoding.Default.GetString(Transform.TransformFinalBlock(Buffer, 0, Buffer.Length)));
}

protected void Page_Load(object sender, EventArgs e)
{
string data = [your encrypted Data];
string[] Result = Decrypt(data).Split(new char[] { '&' });
foreach(string s in Result)
Response.Write(s + "
");
}

Friday, July 9, 2010

Image Thumbnails Nice Code

using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Drawing.Imaging;



string photoPath = Server.MapPath("1.jpg");
int thumbnailSize = 50;
Bitmap photo = new Bitmap(photoPath);
int width, height;
if (photo.Width > photo.Height)
{
width = thumbnailSize;
height = photo.Height * thumbnailSize / photo.Width;
}
else
{
width = photo.Width * thumbnailSize / photo.Height;
height = thumbnailSize;
}
Bitmap target = new Bitmap(width, height);
using (Graphics graphics = Graphics.FromImage(target))
{
graphics.CompositingQuality = CompositingQuality.HighSpeed;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.DrawImage(photo, 0, 0, width, height);
target.Save(Server.MapPath("/2.jpg"));
img.ImageUrl = "~/2.jpg";
}

Thursday, April 29, 2010

calling pagemethod / Web methods from jquery

Thursday, April 22, 2010

Removing html tags in coding, .Net Syndication

protected void Page_Load(object sender, EventArgs e)
{
// Get the books ordered by pubdate in descending order
//PubsDataContext db = new PubsDataContext();
//var dataItems = from book in db.Titles
// orderby book.pubdate descending
// select book;
// Determine the maximum number of items to show in the feed
DataSet ds = new RSSBAL().GetRSS();
const int maxItemsInFeed = 10;
// Determine whether we're outputting an Atom or RSS feed
bool outputRss = (Request.QueryString["Type"] == "RSS");
bool outputAtom = !outputRss;
// Output the appropriate ContentType
if (outputRss)
Response.ContentType = "application/rss+xml";
else if (outputAtom)
Response.ContentType = "application/atom+xml";
// Create the feed and specify the feed's attributes
SyndicationFeed myFeed = new SyndicationFeed();
myFeed.Title = TextSyndicationContent.CreatePlaintextContent("Published Pages by Ingram");
myFeed.Description = TextSyndicationContent.CreatePlaintextContent("A syndication of the most recently published Pages by Ingram.");
myFeed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(GetFullyQualifiedUrl("~/Home.aspx"))));
myFeed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(GetFullyQualifiedUrl(Request.RawUrl))));
myFeed.Copyright = TextSyndicationContent.CreatePlaintextContent("Copyright Ingram Micro");
myFeed.Language = "en-us";
// Creat and populate a list of SyndicationItems
List feedItems = new List();
foreach (DataRow t in ds.Tables[0].Rows)
{
// Atom items MUST have an author, so if there are no authors for this content item then go to next item in loop
//if (outputAtom && t.TitleAuthors.Count == 0)
// continue;
SyndicationItem item = new SyndicationItem();
item.Title = TextSyndicationContent.CreatePlaintextContent(t["PageTitle"].ToString());
item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(GetFullyQualifiedUrl(t["URL"].ToString()))));
item.Summary = TextSyndicationContent.CreatePlaintextContent(StripTagsCharArray(t["PageDesc"].ToString()));
item.PublishDate = Convert.ToDateTime(t["ModifiedDate"]);
if (Convert.ToBoolean(t["IsMain"]) == true)
{
item.Categories.Add(new SyndicationCategory("Main Pages"));
}
else
{
item.Categories.Add(new SyndicationCategory("Sub Pages"));
}
// Add the item to the feed
feedItems.Add(item);
}
myFeed.Items = feedItems;
// Return the feed's XML content as the response
XmlWriterSettings outputSettings = new XmlWriterSettings();
outputSettings.Indent = true; //(Uncomment for readability during testing)
XmlWriter feedWriter = XmlWriter.Create(Response.OutputStream, outputSettings);
if (outputAtom)
{
// Use Atom 1.0
Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter(myFeed);
atomFormatter.WriteTo(feedWriter);
}
else if (outputRss)
{
// Emit RSS 2.0
Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(myFeed);
rssFormatter.WriteTo(feedWriter);
}
feedWriter.Close();
}
private string GetFullyQualifiedUrl(string url)
{
return string.Concat(Request.Url.GetLeftPart(UriPartial.Authority), ResolveUrl(url));
}
public static string StripTagsCharArray(string source)
{
char[] array = new char[source.Length];
int arrayIndex = 0;
bool inside = false;
for (int i = 0; i < source.Length; i++)
{
char let = source[i];
if (let == '<')
{
inside = true;
continue;
}
if (let == '>')
{
inside = false;
continue;
}
if (!inside)
{
array[arrayIndex] = let;
arrayIndex++;
}
}
return new string(array, 0, arrayIndex);
}