using System; using System.Collections.Generic; using System.Text; using MySql.Data.MySqlClient; using System.Data; using log4net; using log4net.Config; using mobiledata; using mobilesecurity; using System.Net.Mail; using System.Net; using iTextSharp.text; using iTextSharp.text.pdf; using System.IO; namespace mobileshop { class Program { static void addHeaderTable(Document d) { PdfPTable header = new PdfPTable(3); header.WidthPercentage=(100); header.DefaultCell.BackgroundColor=BaseColor.BLACK; Font font = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, BaseColor.WHITE); Phrase p = new Phrase("Foobar Film Festival", font); header.AddCell(p); header.DefaultCell.HorizontalAlignment = (Element.ALIGN_CENTER); p = new Phrase("2013/05/15", font); header.AddCell(p); header.DefaultCell.HorizontalAlignment = (Element.ALIGN_RIGHT); p = new Phrase("page 1", font); header.AddCell(p); d.Add(header); d.Add(new Paragraph()); } static PdfPTable createPDFTable() { // a table with three columns PdfPTable table = new PdfPTable(3); table.SpacingBefore = 30; // the cell object PdfPCell cell; // we add a cell with colspan 3 cell = new PdfPCell(new Phrase("Cell with colspan 3")); cell.Colspan = 3; table.AddCell(cell); // now we add a cell with rowspan 2 cell = new PdfPCell(new Phrase("Cell with rowspan 2")); cell.Rowspan=2; table.AddCell(cell); // we add the four remaining cells with addCell() table.AddCell("row 1; cell 1"); table.AddCell("row 1; cell 2"); table.AddCell("row 2; cell 1"); table.AddCell("row 2; cell 2"); return table; } static void generatePDFTest() { // step 1 Document document = new Document(); // step 2 PdfWriter.GetInstance(document, new System.IO.FileStream("D:\\prvi.pdf", System.IO.FileMode.Create)); // step 3 document.Open(); addHeaderTable(document); // step 4 document.Add(createPDFTable()); // step 5 document.Close(); } static string attachmentPath = "D:\\prvi.pdf"; static void sendMailTest() { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("nemanja.kojic@etf.rs", "Nemanja Kojic"); mail.To.Add("nemanja.kojic@etf.rs"); mail.Subject = "Test Mail"; mail.Body = "This is for testing SMTP mail from GMAIL"; Attachment att = null; if (File.Exists(attachmentPath)) { att = new Attachment(attachmentPath); mail.Attachments.Add(att); } SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("si3iep", "si3iep.123"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); att.Dispose(); } static void Main(string[] args) { // Configure log4net from app.config file. XmlConfigurator.Configure(); // Initialize data access API. MobileDataManager.init(Properties.Settings.Default.nemanjaConnectionString, DatabaseKind.MySql); // Call API functions. // MobileDataManager.instance.createUser("Nemanja", "Kojic", "nemanja.kojic@etf.rs", "si3iep"); //string result = SecurityUtils.ComputeHash("tref"); //Console.WriteLine("result:" + result); //Console.WriteLine("result size:" + result.Length); //bool ok = SecurityUtils.VerifyHash("tref", result); //Console.WriteLine(ok); //User u = MobileDataManager.instance.getUser("nemanja.kojic@etf.rs", "si3iep"); // Console.WriteLine(u.Surname); // ServiceReference1.WebServiceSoapClient cl = new ServiceReference1.WebServiceSoapClient() ; // ServiceReference1.User u1 = cl.HelloWorld(); TimeService.TimeServiceSoapClient t = new TimeService.TimeServiceSoapClient(); Console.WriteLine(t.GetTime()); TimeService.TimeRecord tr = t.GetTimeRecord(); // Console.WriteLine(u1.Surname); generatePDFTest(); sendMailTest(); if (File.Exists(attachmentPath)) { File.Delete(attachmentPath); } } } }