Thursday 18 November 2010

Using Malwarebytes

Clicking an image will take you to a larger image.

Step 1) The scan will complete. Click OK in the popup box.



Step 2) Click "Show Results" in the main window.



Step 3) Ensure all items are selected (they are by default), and click "Remove Selected"



Step 4) Minimise (or close) the log that pops up




Step 5) Click Yes in the popup box to reboot the machine to complete the process.

Wednesday 28 April 2010

Updating Wireless Network - Windows 7

This entry is a bit of a bespoke entry for a forum member who is having a bit of trouble.

Basically, he needs to enable WPA2 on his WiFi network and had some questions about what he would need to do on a Windows 7 Laptop.

The instructions that follow offer a simple example of what he would need to do.

Click the Start Orb

Select Control Panel

Click on Network and Internet

Click on View network status and tasks

Click on Manage wireless networks (Left hand pane)




Select the appropriate network

Click Remove

Click Yes

Close the "Manage wireless networks that use ..." window

Click the Network Icon in the System Tray




Select the desired network

Ensure the "Connect automatically" box is ticked

Enter the password when prompted



Done.

Thursday 22 April 2010

My First Case Mod

Below follows evidence of my first attempt at case modding, a window mod.

I only used a Dremel 400 with reinforced Metal Cutoff discs and a couple of different hand files.

It's not 100% complete, but at very least the first stage is complete.

I intend to get some U-Channelling to finish the edges, put some different coloured perspex/acrylic behind the cut outs, and possibly re-paint the panel to a different colour.

The panel came from an ATX case that I don't use at the moment, which in my mind made it a great 1st project, in case something went wrong.

Anyway here are the photos:



1) I forgot to take a proper "before" photo:





























2) My initial, very ambitious, design:





























3) The first couple of cuts:




























4) Some slight modifications to the initial design:




























5) Finished cutting and filing:




















































6) A comparison of the cutoff discs I used (on the right) to a fresh one out of the pack (on the left):


Friday 2 April 2010

Getting involved with SlickTicket

Today I've been writting some code to add an "Export to PDF" button to the ticket view of SlickTicket, an open source, web based help desk application. SlickTicket, and the SlickTicket codeplex site.

It is written in C# (C Sharp), and has provided me with a nice entry platform into the world of .NET development.

I wanted to add the ability to print out a ticket including all the comments (entries added since the initial submission) without having to print it from the web browser.

After finding out about the ability of iTextSharp to create PDFs using C#, I was initially obsessed with trying to convert the already created HTML to a PDF. After a little head banging, as the ability of iTextSharp to parse HTML is a bit limited, I decided to scrap that method and then focus on dynamically creating the PDF.

The code I ended up with is as follows:



//Namespaces required in addition to defaults on Ticket.aspx.cs:
//using iTextSharp.text;
//using iTextSharp.text.pdf;
//using System.Threading;

protected void btnExport_Click(object sender, EventArgs e)
{
//The following code creates a PDF of the Ticket view, with a logo in the top right corner

//The path for the PDF to be written to
string strPath = Request.PhysicalApplicationPath.ToString() + "Ticket_" + t.id + ".pdf";
//The path of the font to be used to create the PDF
string strFontPath = Request.PhysicalApplicationPath.ToString() + "Fonts\\Calibri.ttf";
//The path of the Logo to be used in the PDF
string strLogoPath = Request.PhysicalApplicationPath.ToString() + "Images\\Logo.png";

//Defining the layout of the sections to be used in the Ticket body
//It is done this way to simplify the logic of the strTicket definition
string strTicketDetails = "Details: " + t.details + "\n";
string strTicketDate = "Date Submitted: " + t.submitted.ToString().Substring(0, 10) + "\n";
string strTicketPriority = "Priority: " + t.priority1.priority_name + "\n";

//Defining the Title and Sub-title strings
string strTitle = "Ticket " + t.id + " - " + t.title;
string strTitle2 = "Owner: " + t.user.userName.capitalize() + " (" + t.sub_unit1.unit.unit_name + " - " + t.sub_unit1.sub_unit_name + ")" + "\n" + "Status: " + t.statuse.status_name;

//Defining the Ticket body string
string strTicket = strTicketDate + strTicketPriority + strTicketDetails;

//Creation of a document-object
Document document = new Document();

try
{
//Writer that listens to the document and directs a PDF-stream to a file
PdfWriter.GetInstance(document, new FileStream(strPath, FileMode.Create));

//Open the document
document.Open();

//Adding fonts
BaseFont fntBase = BaseFont.CreateFont(strFontPath, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
Font fntUse = new Font(fntBase, 11, Font.NORMAL);
Font fntTitle = new Font(fntBase, 16, Font.BOLD);
Font fntSubTitle = new Font(fntBase, 14, Font.BOLD);
Font fntBreak = new Font(fntBase, 5, Font.NORMAL);

//Adding the Logo to the top of the page
iTextSharp.text.Image imgLogo = iTextSharp.text.Image.GetInstance(strLogoPath);
imgLogo.Alignment = iTextSharp.text.Image.RIGHT_ALIGN;
document.Add(imgLogo);

//Defining the blank paragraph "pBlank"
Paragraph pBreak = new Paragraph(" ", fntBreak);

//Adding the title
document.Add(new Paragraph(strTitle, fntTitle));
//Adding the sub-title
document.Add(new Paragraph(strTitle2, fntSubTitle));
//Adding a gap between the sub-title and the body text
document.Add(pBreak);
//Adding the body
document.Add(new Paragraph(strTicket, fntUse));
//Adding a gap
document.Add(pBreak);

//Comment building code
IEnumerable<comment> comments = Tickets.Comments.List(db, t.id);
foreach (comment c in comments)
{
//This changes the Submitted date to a string, and returns the date in dd/mm/yyyy format
string cDateFull = c.submitted.ToString();
string cDate = "No Date Given";
if (cDateFull.Length > 10)
{
cDate = cDateFull.Substring(0, 10);
}

//Defining the layout of the Comment body section(s)
string strComment =
"Date: " + cDate + "\n" +
"Priority: " + c.priority.priority_name + "\n" +
"Details: " + c.comment1;

//Adding the comment to the PDF
document.Add(new Paragraph(strComment, fntUse));
//Adding a gap
document.Add(pBreak);
}
}
//These are included in the iTextSharp Examples
catch (DocumentException de)
{
Console.Error.WriteLine(de.Message);
}
catch (IOException ioe)
{
Console.Error.WriteLine(ioe.Message);
}

//Close the pdf
document.Close();

if (File.Exists(strPath))
{
//Run a seperate thread that will delete the server copy of the PDF after 5 seconds
Thread thrWait = new Thread(deleteMe);
thrWait.Start(strPath);
}

//Offer the user a chance to download the PDF
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AddHeader
("Content-Disposition", "attachment; filename=Ticket_" + t.id + ".pdf");
Response.TransmitFile(strPath);

}
static void deleteMe(object fileObject)
{
string filePath = (string)fileObject;
Thread.Sleep(5000);
if (File.Exists(filePath))
{
File.Delete(filePath);
}
}



I simply refernced that code with a simple ASP Button on the Ticket.aspx page

<asp:button id="btnExportPdf" runat="server" onclick="btnExport_Click" text="Export to PDF">

If you plan on doing the same, or similar, I'd recommend putting the button between pnlShowTicket and pnlDisplay. Personally, I used another ASP Panel, and set it so the button aligned to the right.