public ActionResult SystemHistoryPDF(String image, String location)
 {
     // Get the user
     if (image == "world.jpg") image = Server.MapPath("/Resources")+"\\world.jpg";
     var user = userRepository.GetUserByUsername(User.Identity.Name);
     //var allPolls = new List<Poll>();
     var allPolls = user.ManagedPolls.Distinct().ToList<Poll>();
     CodeFile1 PDF = new CodeFile1();
     PdfPTable table = PDF.SessionHistory(allPolls, location);
     Image map = Image.GetInstance(new Uri(image));
     map.ScaleToFit(490, 500);
     IList<IElement> elements = new List<IElement>();
     elements.Add(table);
     elements.Add(map);
     PDF.CreatePDF(elements, Server.MapPath("/Resources"), "Session History Report", "");
     return View(new PollReportViewModel());
 }
 public RedirectToRouteResult SystemSessionPdf(String type)
 {
     CodeFile1 pdf = new CodeFile1();
     var userList = userRepository.GetUsers().Where(user => user.IsDeleted == false).ToList<User>();
     PollReportViewModel viewModel = new PollReportViewModel(userList);
     PdfPTable table = pdf.SystemUtilization(Server.MapPath("/Resources"), viewModel);
     IList<IElement> tab = new List<IElement>();
     tab.Add(table);
     pdf.CreatePDF2(tab, Server.MapPath("/Resources"), type);
     return RedirectToAction("SystemUtilizationPDF");
 }
 public ActionResult SystemUtilizationPDF(String urls)
 {
     if (urls!=null)
     {
         CodeFile1 PDF = new CodeFile1();
         Image graph = Image.GetInstance(new Uri("http:" + urls));
         graph.ScaleToFit(490F, 500F);
         IList<IElement> elements = new List<IElement>();
         elements.Add(graph);
         PDF.CreatePDF(elements, Server.MapPath("/Resources"), "System Utilization Report", "");
     }
     return View(new PollReportViewModel());
 }
 public ActionResult QuestionReportTextual(int pollID)
 {
     var poll = pollRepository.GetPollByID(pollID);
     PollReportViewModel model = QuestionViewModel(pollID);
     CodeFile1 tryomg = new CodeFile1();
     PdfPTable table = tryomg.QuestionReport(Server.MapPath("/Resources"), model, null);
     IList<IElement> tab = new List<IElement>();
     tab.Add(table);
     tryomg.CreatePDF(tab, Server.MapPath("/Resources"), "Results by Question Report",poll.name);
     Entity root = null;
     foreach (Entity e in poll.entities)
     {
         if (e.parent == null)
         {
             root = e;
             break;
         }
     }
     model.root = root;
     return View(model);
 }
        public ActionResult QuestionReportTextualPlain(int pollID, String urls,String name,bool? include, int? field, String items, String selectedEntities)
        {
            if (urls == null) return QuestionReportTextualPlain(pollID);

            var poll = pollRepository.GetPollByID(pollID);
            var tryomg = new CodeFile1();
            PollReportViewModel model = QuestionViewModel(pollID);
            model.include = include.GetValueOrDefault(false);
            if (!String.IsNullOrEmpty(selectedEntities))
            {
                int[] sEntities = commaStringToArray(selectedEntities);
                model.selectedEntities = entityRepository.GetEntityByEntityIDs(sEntities);
            }
            if (field!=null) model.field = participantRepository.GetParticipantFieldByID(field.Value);
            if (items != null) model.tick = items.Split('.');
            PdfPTable table = tryomg.GraphicalReport(Server.MapPath("/Resources"), poll, urls, model,null);
            IList<IElement> stuff = new List<IElement>();
            stuff.Add(table);
            tryomg.CreatePDF(stuff, Server.MapPath("/Resources"), name,poll.name);
            var m = new PollReportViewModel(pollID, poll.name);
            return View(new PollReportViewModel(pollID, poll.name));
        }
 public ActionResult DemographicReportTextual()
 {
     PollReportViewModel model = DemographicViewModel();
     CodeFile1 tryomg = new CodeFile1();
     PdfPTable table = tryomg.QuestionReport(Server.MapPath("/Resources"), model, null);
     IList<IElement> stuff = new List<IElement>();
     stuff.Add(table);
     tryomg.CreatePDF(stuff, Server.MapPath("/Resources"),"Results by Question with Demographic Comparison Report",model.name);
     return View(model);
 }
 public ViewResult ApplyQuestionReportTextualFilters(int pollID, int[] entityIDs)
 {
     var poll = pollRepository.GetPollByID(pollID);
     PollReportViewModel model = QuestionViewModel(pollID);
     Entity root = null;
     foreach (Entity e in poll.entities)
     {
         if (e.parent == null)
         {
             root = e;
             break;
         }
     }
     model.root = root;
     if (entityIDs == null)
     {
         model.selectedEntities = new List<Entity>();
     }
     else
     {
         model.selectedEntities = entityRepository.GetEntityByEntityIDs(entityIDs);
         model.filteredResponses = FilteredResponses(pollID, model.selectedEntities);
     }
     CodeFile1 tryomg = new CodeFile1();
     PdfPTable table = tryomg.QuestionReport(Server.MapPath("/Resources"), model, null);
     IList<IElement> tab = new List<IElement>();
     tab.Add(table);
     tryomg.CreatePDF(tab, Server.MapPath("/Resources"), "Results by Question Report", poll.name);
     return View("ReportTextual", model);
 }
 public RedirectToRouteResult SessionPdf(int pollID, String type)
 {
     var tryomg = new CodeFile1();
     var poll = pollRepository.GetPollByID(pollID);
     var viewModel = new PollReportViewModel(pollID, poll.name, poll.participants);
     PdfPTable table = tryomg.SessionParticipation(Server.MapPath("/Resources"),viewModel);
     IList<IElement> tab = new List<IElement>();
     tab.Add(table);
     tryomg.CreatePDF(tab, Server.MapPath("/Resources"), type, poll.name);
     return RedirectToAction("QuestionReportTextualPlain", new { pollID = pollID });
 }
 public RedirectToRouteResult SessionGraphical(int pollID, String type, String urls, String way)
 {
     var pdf = new CodeFile1();
     IList<IElement> cell = new List<IElement>();
     cell.Add(new Paragraph(way, new Font(FontFactory.GetFont("Verdana", 14))) { Alignment = Element.ALIGN_CENTER });
     if (urls.Contains(','))
     {
         String[] url = urls.Split(',');
         foreach (String ur in url) cell.Add(Image.GetInstance(new Uri("http:" + ur)));
         pdf.CreatePDF(cell, Server.MapPath("/Resources"), type, pollRepository.GetPollByID(pollID).name);
     }
     else
     {
         cell.Add(Image.GetInstance(new Uri("http:" + urls)));
         pdf.CreatePDF(cell, Server.MapPath("/Resources"), type, pollRepository.GetPollByID(pollID).name);
     }
     return RedirectToAction("QuestionReportTextualPlain", new { pollID = pollID });
 }
 public void CreatePDF(IList<IElement> table,String path,String type,String pollname)
 {
     MemoryStream outputStream = new MemoryStream();
     Document document = new Document(PageSize.A4, 50, 50, 50, 50);
     PdfWriter write = PdfWriter.GetInstance(document,outputStream);
     document.Open();
     Standard(document, type, path,pollname);
     foreach (IElement element in table) document.Add(element);
     write.CloseStream=false;
     document.Close();
     outputStream.Position = 0;
     PdfReader reader = new PdfReader(outputStream);
     totalPages = reader.NumberOfPages;
     Document doc = new Document(PageSize.A4, 50, 50, 50, 50);
     try
     {
         File.Delete(path + "/MyFirstPDF" + FILE + ".pdf");
     }
     catch (Exception e) { }
     if (FILE == int.MaxValue) directionUp = false;
     else if (FILE == 0) directionUp = true;
     if (directionUp) FILE++;
     else FILE--;
     var output = new FileStream(path+"/MyFirstPDF"+FILE+".pdf", FileMode.Create);
     PdfWriter writer = PdfWriter.GetInstance(doc, output);
     CodeFile1 pageeventhandler = new CodeFile1(totalPages);
     writer.PageEvent = pageeventhandler;
     doc.Open();
     Standard(doc, type, path,pollname);
     foreach (IElement element in table) doc.Add(element);
     doc.Close();
 }