public void ProcessRequest(HttpContext context) { int ShowID = Convert.ToInt32(context.Request["showid"]); Shows show = new Shows(ShowID); StringBuilder builder = new StringBuilder(); builder.Append("Discounts\n\r"); builder.AppendFormat("{0} Show Date:{1}\n\r", show.ShowName, show.ShowDate.ToString("dd MMM yyyy")); builder.Append("Payment Date,Show Ref,Account Name,Amount\n\r"); var masterList = Transaction.getDiscountsForShow(ShowID); decimal total = 0; foreach (var row in masterList) { var u = new User(row.Userid); builder.Append(string.Format("{0:dd MMM yyyy},{1},{2},{3:0.00}\n\r", row.TransactionDate, row.RefCode, u.Name, row.Cheque)); total += row.Cheque; total += row.Amount; } builder.AppendFormat("\n\r,,,,Total {0:0.00}\n\r\n\r", total); context.Response.ClearContent(); context.Response.ContentType = "application/csv"; context.Response.AddHeader("content-disposition", String.Format("inline;filename=ChequeList-{0:ddMMMyyyy}.csv", show.ShowDate)); context.Response.Write(builder); }
public HandlerDetailsModel(int id, bool isAdmin = false) : base() { EnteredShows = ShowEntered.GetEnteredShows(id); SavedShows = Shows.getSavedShows(id); var msgs = Messenger.GetMessages(); Messages = new List<MessengerModel>(); foreach (var messengerDto in msgs) { Messages.Add(new MessengerModel() { Id = messengerDto.Id, CreatedDate = messengerDto.CreatedDate, EndDate = messengerDto.EndDate, Message = messengerDto.Message }); } Dogs = Business.Dogs.GetAllDogsForHandler(id, DateTime.Now); AvailableShows = Shows.getPublishedShows(id); if (isAdmin) UnpublishedShows = Shows.GetUnpublishedShows(); var user = new User(id); UserName = user.Name; LongTimeLogin = (user.LastLoginDate - DateTime.Now).Days < -25; user.UpdateLogin(); }
public static void Send(User user, MailMessage mailMessage) { try { SmtpClient client = new SmtpClient(); mailMessage.From = new MailAddress("*****@*****.**", "First Place Processing"); mailMessage.To.Add(new MailAddress(user.EmailAddress, user.Name)); client.Send(mailMessage); } catch(Exception ex ) { AppException.LogError(string.Format("Send:{0} {1} {2}", user.ID, user.EmailAddress, ex.StackTrace)); } }
public void DeleteEntry(int ShowId, int UserId) { Shows thisShow = new Shows(ShowId); User thisUser = new User(UserId); Transaction trans = new Transaction(UserId, ShowId); if (trans.EnteredBy == (int)Transaction.ENTERED_BY.ONLINE_ENTRY) { CancelEntry.Cancel(thisUser, thisShow); } else { CancelEntry.Cancel(thisUser, thisShow); } }
private void sendEmail(User user, String body) { SmtpClient client = new SmtpClient(); MailAddress from = new MailAddress("*****@*****.**", "First Place Processing"); MailAddress to = new MailAddress(user.EmailAddress, user.Name); MailMessage message = new MailMessage(from, to); message.Body = Environment.NewLine; message.Subject = "First Places Processing Automatic Registration"; message.Body += "Welcome To First Place Processing" + Environment.NewLine + Environment.NewLine; message.Body += "Your address and dog details have already been entered into our system. "; var hidden = user.Password.Substring(0, 1) + (new String('*', user.Password.Length - 2)) + user.Password.Substring(user.Password.Length - 1, 1); message.Body += "Your password is: [" + hidden + "]" + Environment.NewLine; message.Body += Environment.NewLine + Environment.NewLine; client.Send(message); }
protected void Page_Load(object sender, EventArgs e) { String tmp = Context.Request["verify"].ToString(); if (tmp.Length > 0) { String[] guid = tmp.Split('-'); if (guid.Length == 5 && guid[4].Length == 12) { int id = Convert.ToInt32(guid[4].Substring(guid[4].Length - 4, 4)); User user = new User(id); if (user.EmailAddress.Length > 0) { var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var stringChars = new char[8]; var random = new Random(); for (int i = 0; i < stringChars.Length; i++) { stringChars[i] = chars[random.Next(chars.Length)]; } user.Password = new String(stringChars); user.Update(); sendEmail(user, ""); Session["message"] = "<h2>Thank you for getting in touch.</h2><p>An email has been sent to you with your password.</p>"; } else { } } } tmp = Context.Request["quick"].ToString(); if (tmp.Length > 0) { String[] guid = tmp.Split('-'); if (guid.Length == 5 && guid[4].Length == 12) { int id = Convert.ToInt32(guid[4].Substring(guid[4].Length - 4, 4)); User user = new User(id); } } Response.Redirect("/"); }
public void SendEmail(User user, String body) { try { var client = new SmtpClient(); var message = new MailMessage { From = new MailAddress("*****@*****.**", "First Place Processing") }; message.To.Add(new MailAddress(user.EmailAddress, user.Name)); message.Body = Environment.NewLine; if (body.Length > 0) { message.Subject = "First Places Processing Email Verification"; message.Body += "Welcome To First Place Processing Registrations" + Environment.NewLine + Environment.NewLine; message.Body += "Thank you for registering with us." + Environment.NewLine + Environment.NewLine + "Please click on the link below to verify that you are you." + Environment.NewLine + Environment.NewLine; message.Body += _baseUrl + "?verify=" + body + Environment.NewLine + Environment.NewLine; AppException.LogEvent($"Register user to {user.EmailAddress}"); } else { AppException.LogEvent($"Resending Password to {user.EmailAddress}"); message.Subject = "First Places Processing Password Reminder"; message.Body = Environment.NewLine; } var hidden = user.Password.Substring(0, 1) + (new String('*', user.Password.Length - 2)) + user.Password.Substring(user.Password.Length - 1, 1); message.Body += "Your password is: [" + hidden + "]" + Environment.NewLine; message.Body += Environment.NewLine + Environment.NewLine; message.Body += @"Replace the * with the appropriate characters and remove the square brackets. If you still can't remember your password, reply to this email and we will reset it at the earliest opportunity." + Environment.NewLine; message.Body += Environment.NewLine + Environment.NewLine; message.Body += "Thanks" + Environment.NewLine; client.Send(message); } catch (Exception e) { AppException.LogError( $"Exception Resending Password: {e.Message} {e.StackTrace} uid:{user.ID} {user.Password.Length}"); } }
public JsonResult AddJudge(Fpp.Core.Models.JudgeDetails judgeDetails) { var uid = 0; if (judgeDetails.UserId <= 0) { User u = new User(); u.Name = judgeDetails.Name; String[] str = u.Name.Split(' '); u.FirstName = str[0]; u.LastName = ""; if (str.Length > 1) { for (int i = 1; i < str.Length; i++) { if (u.LastName.Length > 0) u.LastName += " "; u.LastName += str[i]; } } u.EmailAddress = judgeDetails.Email; u.Mobile = judgeDetails.Mobile; u.Address = judgeDetails.Address; u.Postcode = judgeDetails.PostCode; u.Password = "******"; uid = u.Create(); u.AccountVerified(); } else { uid = judgeDetails.UserId; } Judge j = new Judge(judgeDetails.JudgeId); j.ShowID = judgeDetails.ShowId; j.UserID = uid; j.JudgeName = judgeDetails.Name; j.Notes = judgeDetails.Notes; j.ShowDetailsID = judgeDetails.ShowDetailsId; j.Save(); return Json(new { UserId = uid, JudgeId = j.ID, Status = 0 }); }
public static StatusCls UpgradeDog(UpgradeDogView upgradeDogView) { var status = new StatusCls(); AppException.LogEvent($"Upgrade Dog (UserID={upgradeDogView.UserId}, DogId={upgradeDogView.DogId})"); try { DateTime activeDate; var currentUser = new User(upgradeDogView.UserId); var dog = new Dogs(upgradeDogView.DogId); DogHistory.Add(upgradeDogView); var mm = new MailMessage(); var oldgrade = dog.Grade; if (upgradeDogView.UpgradeType == 0) { mm.Subject = "First Place Processing - Confirmation of grade change"; var body = "This is a confirmation of grade change of your dog: " + dog.KCName + " from grade " + oldgrade + " to grade " + upgradeDogView.NewGrade + Environment.NewLine + Environment.NewLine + "Your dog will be grade " + upgradeDogView.NewGrade + " from the " + upgradeDogView.WinDate.AddDays(25).ToString("dd MMM yyyy") + Environment.NewLine + Environment.NewLine; mm.Body = body; activeDate = upgradeDogView.WinDate.Add(new TimeSpan(25, 0, 0, 0)); } else { mm.Subject = "First Place Processing - Confirmation of grade change"; var body = "This is a confirmation of grade change of your dog: " + dog.KCName + " from grade " + oldgrade + " to grade " + upgradeDogView.NewGrade + Environment.NewLine + Environment.NewLine; mm.Body = body; activeDate = DateTime.Now; } EmailManager.Send(currentUser, mm); if (activeDate > DateTime.Now) { status.Extra = activeDate.ToString("dd MMM yyyy"); } } catch (Exception e) { AppException.LogEvent($"Error:UpgradeDog:{e.Message} {e.StackTrace}"); } return status; }
public JsonResult ResendReg(RegisterModel register) { User user = new User(register.EmailAddress); if (user.UserID > 0) { string body = Guid.NewGuid().ToString(); body = body.Substring(0, body.Length - 4) + user.UserID.ToString().PadLeft(4, '0'); new EmailManager().SendEmail(user, body); return Json(new { Status = 0, Message = "Password Sent." }); } else { AppException.LogEvent($"email does not exists {register.EmailAddress}"); return Json(new { Status = 1, Message = "" }); } }
public JsonResult Register(RegisterModel register) { register.Name = register.Name.Replace("'", "''").Replace(";", "").Replace("--", "").Replace("/*", ""); register.EmailAddress = register.EmailAddress.Replace("'", "").Replace(";", "").Replace("--", "").Replace("/*", ""); register.Password = register.Password.Replace("'", "").Replace(";", "").Replace("--", "").Replace("/*", ""); User user = new User(register.EmailAddress); if (user.UserID > 0) { AppException.LogError($"Already registered (REG) {register.EmailAddress}"); return Json(new { Status = 1, Message = "This email address can is already registered." }); } else { string[] n = register.Name.Split(' '); string first, last; if (n.Length == 0) { first = ""; last = ""; } else { first = n[0]; last = n.Length > 1 ? n[1] : ""; } user = new User { EmailAddress = register.EmailAddress, Name = register.Name, FirstName = first, LastName = last, Password = register.Password, Address = "", Postcode = "", HomePhone = "" }; int newId = user.Create(); AppException.LogEvent("New User Created: " + newId.ToString()); string body = Guid.NewGuid().ToString(); body = body.Substring(0, body.Length - 4) + newId.ToString().PadLeft(4, '0'); new EmailManager().SendEmail(user, body); return Json(new { Status = 0, Message = "Account Created." }); } }
public void SendEntryEmail(int ShowId, int UserId, String userRefNo) { Shows show = new Shows(ShowId); User currentUser = new User(UserId); // // if entered show, send email saying entered show String htmlContents = readTemplate("EnteredShow", "html", show, userRefNo); String plainContents = readTemplate("EnteredShow", "txt", show, userRefNo); MailMessage mm = new MailMessage(); String classesEnteredHtml = "<table>"; String Classes_entered_plain = ""; List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(ShowId); List<Dogs> dogList = Dogs.GetAllDogsForHandler(UserId, show.ShowDate); var multiClasses = TeamPairsManager.GetTeamPairClasses(ShowId); var multiTeams = TeamPairsManager.GetTeamPairsForShow(ShowId, multiClasses); foreach (Dogs d in dogList) { DogClasses dogClasses = new DogClasses(d.ID, ShowId); dogClasses.getDogsClasses(ShowId); if (d.Grade != 0) { bool dogEntered = false; foreach (ShowClasses cls in classList) { int clsIndex = dogClasses.Classlist.IndexOf(cls.ID); if (clsIndex > -1) { if (!dogEntered) { classesEnteredHtml += String.Format("<tr style='font-weight:bold;'><td colspan='3'><b>{0} ({1}) {2} </b></td></tr>", d.PetName, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option")); Classes_entered_plain += String.Format("{1}{0}{1}--------------------------------{1} ({2}) {3}", d.PetName, Environment.NewLine, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option")); } classesEnteredHtml += "<tr>"; classesEnteredHtml += String.Format("<td style='width:25px'></td><td>{0}</td><td>{1} {2} {3} {4} {5}</td>", cls.ClassNo, cls.NormalName(withClassNo: false)); Classes_entered_plain += String.Format("{0} - {1} {2} {3} {4} {5} {6}", cls.ClassNo, cls.NormalName(withClassNo: false), Environment.NewLine); classesEnteredHtml += "</tr>"; dogEntered = true; } } } } foreach (var team in multiTeams.Where(t => t.UserId == UserId)) { if (team.Team) { classesEnteredHtml += $@" <tr style='height:25px' ><td colspan='3'></td><tr> <td>Team Name<br>{team.TeamDetails.TeamName.Replace("'", "'")}</td> <td colspan='2'>Captain<br/>{team.TeamDetails.Captain.Replace("'", "'")}</td> </tr>"; Classes_entered_plain += $@"Team Name:{team.TeamDetails.TeamName.Replace("'", "'")} Team Captain:{team.TeamDetails .Captain.Replace("'", "'")}{Environment.NewLine}"; foreach (var member in team.Members) { classesEnteredHtml += $@" <tr> <td> {member.HandlerName.Replace("'", "'")}</td> <td colspan='2'>{member.DogName.Replace("'", "'")}</td> </tr><tr> "; Classes_entered_plain += $@" {member.HandlerName.Replace("'", "'")}, {member.DogName.Replace("'", "'")}{Environment.NewLine}"; } } } classesEnteredHtml += " </table>"; Classes_entered_plain += Environment.NewLine; htmlContents = htmlContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy")); plainContents = plainContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy")); htmlContents = htmlContents.Replace("[CLASSES_ENTERED]", classesEnteredHtml); plainContents = plainContents.Replace("[CLASSES_ENTERED]", Classes_entered_plain); string campingdetails_html = ""; string campingdetails_plain = ""; var usershowid = Convert.ToInt32(userRefNo); var uc = new UserCamping(usershowid); if (uc.ID > -1) { campingdetails_html = $"<h3>Camping Details</h3><div>Party Name: <b>{uc.PitchDetails[0].PartyName}</b><br>{uc.PitchDetails[0].CampingDays}</div>"; campingdetails_plain = $"Party Name: {uc.PitchDetails[0].PartyName}\n\r{uc.PitchDetails[0].CampingDays}"; } htmlContents = htmlContents.Replace("[CAMPING_DETAILS]", campingdetails_html); plainContents = plainContents.Replace("[CAMPING_DETAILS]", campingdetails_plain); var helpingdetailsHtml = ""; var helpersList = Helpers.HelperForShow(ShowId, UserId); if (helpersList.Count > 0) { helpingdetailsHtml += "<div id='helperdetails' class='infoText'><h3>Helping Details</h3>"; foreach (var helper in helpersList) { var judge = ""; if (helper.JudgeID > -1) { var j = new Judge(helper.JudgeID); judge = "Judge: " + j.Name; } var ring = ""; if (helper.RingNo > 0) { ring = "Ring No:" + helper.RingNo.ToString(); } helpingdetailsHtml += $"<div >{helper.HelpDate:ddd dd MMM} - {helper.expandJob()} {judge} {ring}</div>"; } helpingdetailsHtml += "</div>"; helpingdetailsHtml += "\n"; } htmlContents = htmlContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml); plainContents = plainContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml); var totals = 0m; var table = CreateTotalsSummaryEmail(ShowId, UserId, ref totals); var htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); var plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.AlternateViews.Add(plainView); mm.AlternateViews.Add(htmlView); var client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(currentUser.EmailAddress, currentUser.Name)); mm.Subject = $"Entry Confirmation {show.ShowName} ({show.ShowDate:dd MMM yyyy})"; try { client.Send(mm); } catch (Exception e) { AppException.LogError("Error SendEntry:" + e.Message + "-" + e.StackTrace); } }
public UserShows SendMessage(EmailMessage emailMessage) { UserShows us = null; try { // if entered show, send email saying entered show us = new UserShows(emailMessage.UserShowId); User user = new User(us.Userid); if (user.EmailAddress.Length < 5) { throw new Exception("NoEmai"); } var thisShow = new Shows(us.ShowID); var htmlContents = readTemplate("AdminEmailHandler", "html", thisShow, null); var plainContents = readTemplate("AdminEmailHandler", "txt", thisShow, null); htmlContents = htmlContents.Replace("[BODY]", emailMessage.body.Replace("\n", "<br>")); plainContents = plainContents.Replace("[BODY]", emailMessage.body); var mm = new MailMessage(); var htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); var plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.Body = plainContents; mm.AlternateViews.Add(htmlView); SmtpClient client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(user.EmailAddress, user.Name)); mm.Subject = emailMessage.Subject; client.Send(mm); us.ContactStatus = 1; us.ContactDate = DateTime.Now; us.SaveContactDetails(); } catch (Exception e) { AppException.LogEvent("SendMessage: " + e.Message + " " + e.StackTrace); } return us; }
private PdfPCell userHelpingDetails(UserShows userShow) { User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); PdfPCell panelCell = new PdfPCell(); panelCell.BorderWidth = 1; panelCell.Padding = 4; PdfPTable panelTable = new PdfPTable(new float[] { 150, 150, 400}); panelCell.AddElement(panelTable); var cell = new PdfPCell(new Phrase(new Chunk("Helper Details", headerFont))); cell.BorderWidth = 0; cell.Colspan = 3; cell.PaddingBottom = 10; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Help Date", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Ring No", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Job", judgeFont))) {BorderWidth = 0}; panelTable.AddCell(cell); var helpers = Business.Helpers.HelperForShow(userShow.ShowID, userShow.Userid); if (helpers.Any() && helpers.FirstOrDefault().RingNo > -1) { foreach(var h in helpers) { cell = new PdfPCell(new Phrase(new Chunk($"{h.HelpDate:ddd dd MMM}", judgeFont))) {BorderWidth = 0}; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk($"{h.RingNo}", judgeFont))) {BorderWidth = 0}; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk($"{h.JobDetails}", judgeFont))) {BorderWidth = 0}; panelTable.AddCell(cell); } } else { panelCell = new PdfPCell(); panelCell.BorderWidth = 0; } return panelCell; }
private PdfPCell userCampingDetails(UserShows userShow) { User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); PdfPCell panelCell = new PdfPCell(); panelCell.BorderWidth = 1; panelCell.Padding = 4; PdfPTable panelTable = new PdfPTable(new float[] { 500}); panelCell.AddElement(panelTable); PdfPCell cell; var campingSummary = new UserCamping(userShow.ID); if (campingSummary != null && campingSummary.PitchDetails.Any()) { cell = new PdfPCell(new Phrase(new Chunk("Camping Details", headerFont))); cell.BorderWidth = 0; cell.PaddingBottom = 10; panelTable.AddCell(cell); var camp = campingSummary.PitchDetails[0]; if (!string.IsNullOrEmpty(camp.PartyName)) { cell = new PdfPCell(new Phrase(new Chunk(string.Format("Party Name:{0}", camp.PartyName), judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); } var para = new Paragraph() { new Phrase("Camping Pitch:", judgeFont) }; foreach (var pitch in campingSummary.PitchDetails ) { para.Add(new Phrase(pitch.PitchNo.ToString() + " ", judgeFont)); } cell = new PdfPCell(para); cell.BorderWidth = 0; panelTable.AddCell(cell); var tmp = ""; foreach(var day in camp.CampingDays.Split(',') ) { if (tmp.Length > 0) tmp += ", "; DateTime dt; DateTime.TryParseExact(day, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt); tmp += dt.ToString("ddd dd MMM"); } cell = new PdfPCell(new Phrase(new Chunk(tmp, judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); } else { panelCell = new PdfPCell(); panelCell.BorderWidth = 0; } return panelCell; }
private PdfPCell getShowDetailsInfo(UserShows userShow) { User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); PdfPCell panelCell = new PdfPCell(); panelCell.BorderWidth = 1; panelCell.Padding = 4; PdfPTable panelTable = new PdfPTable(new float[] { 135, 200 }); panelCell.AddElement(panelTable); PdfPCell cell; cell = new PdfPCell(new Phrase(new Chunk("Account Name:", headerFont))); cell.NoWrap = true; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; cell.PaddingBottom = 10; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(currentUser.Name, headerFont))); cell.BorderWidth = 0; cell.PaddingBottom = 10; panelTable.AddCell(cell); panelTable.AddCell(new PdfPCell(new Phrase("Show Name:", headerFont)) { BorderWidth = 0, NoWrap = true, HorizontalAlignment = Element.ALIGN_LEFT }); panelTable.AddCell(new PdfPCell(new Phrase(show.ShowName, headerFont)) { BorderWidth = 0 }); panelTable.AddCell(new PdfPCell(new Phrase("Venue:", headerFont)) { BorderWidth = 0, NoWrap = true, HorizontalAlignment = Element.ALIGN_LEFT }); panelTable.AddCell(new PdfPCell(new Paragraph() { new Phrase(show.Venue), new Phrase(Chunk.NEWLINE), new Phrase(show.VenuePostcode) }) { BorderWidth = 0 }); if (userShow.ID > -1) { cell = new PdfPCell(new Phrase(new Chunk("Show Ref:", headerFont))); cell.NoWrap = true; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(userShow.ID.ToString(), headerFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); } return panelCell; }
private void printRingForUser(UserShows userShow, int UserID, Document doc, ref List<int> defaultUsers, ref int pageCount) { float[] ringColumns = new float[] { 300, 300, 300, 300 }; User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); List<ShowDetails> showDetailsList = ShowDetails.GetShowDetails(userShow.ShowID); Rings r = new Rings(); DataSet ringList = r.GetAllRingsForShow(userShow.ShowID, "ShowDate"); Dogs d = new Dogs(); DogClasses dc = new DogClasses(); DateTime dt = DateTime.Now; string currentJudge = ""; int currentRingID = 0; int ShowDetailsID = -1; int PrevShowDetailsID = -1; PdfPTable rings = new PdfPTable(ringColumns); int ringCnt = 0; PdfPCell cell = null; PdfPTable ringDetails = null; PdfPTable classDetailsTable = null; List<int> dogsRunningToday = new List<int>(); PdfPTable headerPage = null; List<TeamPairsTrioDto> pairsTeams = new List<TeamPairsTrioDto>(); try { foreach (DataRow ringRow in ringList.Tables[0].Rows) { Rings ring = new Rings(ringRow); int RingID = Convert.ToInt32(ringRow["RingID"]); int EntryType = Convert.ToInt32(ringRow["EntryType"]); int Lho = Convert.ToInt32(ringRow["Lho"]); ShowDetailsID = Convert.ToInt32(ringRow["ShowDetailsID"]); if (ringRow.IsNull("ClassID")) { continue; } int ClassID = Convert.ToInt32(ringRow["ClassID"]); int ClassNo = Convert.ToInt32(ringRow["ClsNo"]); DateTime rowDT = Convert.ToDateTime(ringRow["ShowDate"]); if (rowDT != dt) { if (currentRingID != 0) { if (ringCnt % MaxColumns != 0) { var remind = ringCnt % MaxColumns; while (remind-- > 0) { cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; rings.AddCell(cell); } } if (dogsRunningToday.Count() > 0 || UserID == -1) { doc.Add(headerPage); doc.Add(rings); if (UserID > -1) { if (currentUser.UserID != UserID) { User defaultHandler = new User(UserID); } } doc.NewPage(); pageCount++; } } dogsRunningToday.Clear(); if (UserID > -1) { if (currentUser.UserID == UserID) { headerPage = DrawHeader(show, rowDT, currentUser, userShow); } else { User defaultHandler = new User(UserID); headerPage = DrawHeader(show, rowDT, defaultHandler, userShow); } } else { headerPage = DrawHeader(show, rowDT, null, null); } dt = rowDT; rings = new PdfPTable(ringColumns); rings.WidthPercentage = 100; ringCnt = 0; } if (currentRingID != RingID) { currentJudge = ""; ringCnt++; ringDetails = new PdfPTable(1); rings.AddCell(new PdfPCell(ringDetails)); //List<Judge> judgeList = Judge.getJudgesForRingList(RingID); string JudgeName = Judge.getJudgeForClass(ClassID).Name; int ClsCount = DogClasses.GetDogsInRing(RingID); cell = new PdfPCell(new Phrase(new Chunk(string.Format("Ring No {0} ({1})", ringRow["RingNo"].ToString(), ClsCount), judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); if (currentJudge != JudgeName) { cell = new PdfPCell(new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(JudgeName), judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); currentJudge = JudgeName; } currentRingID = RingID; classDetailsTable = new PdfPTable(DetailsColWidths); classDetailsTable.DefaultCell.BorderWidth = 0; ringDetails.AddCell(classDetailsTable); } else { string JudgeName = Judge.getJudgeForClass(ClassID).Name; if (currentJudge != JudgeName) { cell = new PdfPCell(new Phrase(new Chunk(" ", judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(JudgeName), judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); classDetailsTable = new PdfPTable(DetailsColWidths); classDetailsTable.DefaultCell.BorderWidth = 0; ringDetails.AddCell(classDetailsTable); currentJudge = JudgeName; } } DataSet dogsList = d.GetDogsInClass(userShow.Userid, ClassID); int dogsInClass = d.dogsInClassCount(ClassID); List<DogClassCount> dcCounts = DogClasses.GetEntryCountsByClassId(userShow.ShowID, ClassID); String clsName; var part = Convert.ToInt32(ringRow["Part"]); var lhoInd = ""; var dogsInClassDisplay = ""; if (dcCounts.Count > 1) { if (Lho == 1) { dogsInClassDisplay = String.Format("({0}/{1})", dcCounts[0].Count, dcCounts[1].Count); } else { dogsInClassDisplay = String.Format("({0}/{1})", dcCounts[1].Count, dcCounts[0].Count); } } else { dogsInClassDisplay = String.Format("({0})", dogsInClass); } if (Lho == 1) { lhoInd = "(FH 1st)"; } else if (Lho == 2) { lhoInd = "(LHO 1st)"; } if (EntryType != 10) { clsName = new ShowClasses(ClassID).NormalName(withClassNo:false, useAbbrFlag:true); } else { clsName = String.Format("{0} {1} {2} ", ShowClasses.expandHeight(ringRow), ringRow["LongName"].ToString().Trim(), ringRow["name"].ToString().Trim()); } clsName = clsName.Replace("(Special Class", "S"); clsName = clsName.Replace("(Money Class", "Money"); clsName = clsName.Replace("First Place Processing", "FPP"); clsName = clsName.Replace("First Contact", "FC"); clsName = clsName.Replace("Qualifier", "Q"); if (part > 0 && EntryType != 10) { clsName += "Pt " + part; } if (dogsList.Tables[0].Rows.Count > 0) { /* Combined 1-7 All Allsorts Agility sponsored by paws for a walk Combined 6-7 Medium Agility * */ var WrapClassDescription = clsName.Length > 45; Phrase[] tmpCells = new Phrase[3]; tmpCells[0] = new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogInClass)); tmpCells[1] = new Phrase(new Chunk(clsName, dogInClass)); tmpCells[2] = new Phrase(new Chunk(dogsInClassDisplay, dogNotInClass )); int countDogs = 0; int DefaultHandler; Paragraph p = new Paragraph(); List<Paragraph> allDogsInClass = new List<Paragraph>(); foreach (DataRow dogRow in dogsList.Tables[0].Rows) { var dogLho = Convert.ToInt32(dogRow["Lho"]); int DogID = Convert.ToInt32(dogRow["DogID"]); DefaultHandler = Convert.ToInt32(dogRow["DefaultHandler"]); if (DefaultHandler == 0) DefaultHandler = -1; if ((DefaultHandler == -1 && currentUser.UserID == UserID) || (DefaultHandler == UserID) ) { if (countDogs == 0) { cell = new PdfPCell(tmpCells[0]); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); var namePara = new Paragraph(); namePara.Add(tmpCells[1]); namePara.Add(new Phrase(new Chunk(lhoInd, lhoFontBold))); p.Add(namePara); } if (!dogsRunningToday.Contains(DogID)) { dogsRunningToday.Add(DogID); } String dogName = dogRow["DogName"].ToString(); if (dogName.Length == 0) { dogName = dogRow["KCName"].ToString(); } var chunk = new Chunk(" ", dogDetailsInClass); chunk.SetBackground(new Color(System.Drawing.ColorTranslator.FromHtml(dogRow["DogColour"].ToString()))); var dogPara = new Paragraph(); dogPara.Add(new Phrase(chunk)); if (TeamPairsManager.isMultiDog( EntryType )) { pairsTeams.Add(new TeamPairsTrioDto { ClassId = ClassID, ClassNo = ClassNo, DogId = DogID, DogName = dogName, RO = -1 }); } dogPara.Add(new Phrase(new Chunk(String.Format(" [{1}] {0}", Fpp.Core.Utils.TitleCaseString(dogName), dogRow["RO"]), dogDetailsInClass))); dogPara.Add(new Phrase(new Chunk(String.Format("{0}", (dogLho == 0 ? "" : " (LHO)")), font8))); dogPara.Add(Chunk.NEWLINE); int AltHandler = Convert.ToInt32(dogRow["AltHandler"]); String HandlerName = ""; if (AltHandler > 0) { User u = new User(AltHandler); HandlerName = u.Name; dogPara.Add(new Phrase(new Chunk(String.Format("Handler:{0}", Fpp.Core.Utils.TitleCaseString(HandlerName)), dogInClass))); } allDogsInClass.Add(dogPara); countDogs++; } else { if (defaultUsers != null && defaultUsers.IndexOf(DefaultHandler) == -1) { defaultUsers.Add(DefaultHandler); } } } if (countDogs == 0) { cell = new PdfPCell(new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); var namePara = new Paragraph(); namePara.Add(new Phrase(new Chunk(clsName, dogNotInClass))); namePara.Add(new Phrase(new Chunk(lhoInd, lhoFontBold))); p.Add(namePara); cell = new PdfPCell(p); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dogsInClassDisplay, dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); } else { cell = new PdfPCell(p); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); cell = new PdfPCell(tmpCells[2]); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", dogDetailsInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); var tbl4Dogs = new PdfPTable(1); foreach (var item in allDogsInClass) { cell = new PdfPCell(new Phrase(item)); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; tbl4Dogs.AddCell(cell); } cell = new PdfPCell(); cell.BorderWidth = 0; cell.FixedHeight = 4f; tbl4Dogs.AddCell(cell); cell = new PdfPCell(tbl4Dogs); cell.BorderWidth = 0; cell.Colspan = 2; classDetailsTable.AddCell(cell); } } else { cell = new PdfPCell(new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); var namePara = new Paragraph(); namePara.Add(new Phrase(new Chunk(clsName, dogNotInClass))); namePara.Add(new Phrase(new Chunk(lhoInd, lhoFontBold))); cell = new PdfPCell(namePara); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dogsInClassDisplay, dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); } PrevShowDetailsID = ShowDetailsID; } if (dogsRunningToday.Count() > 0 || UserID == -1) { if (ringCnt % MaxColumns != 0) { var remind = ringCnt % MaxColumns; while (remind-- > 0) { cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; rings.AddCell(cell); } doc.Add(headerPage); doc.Add(rings); } if (UserID > -1) { if (currentUser.UserID != UserID) { User defaultHandler = new User(UserID); } } doc.NewPage(); pageCount++; } else { if (dogsRunningToday.Count() > 0) { if (ringCnt % MaxColumns != 0) { var remind = ringCnt % MaxColumns; while (remind-- > 0) { cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; rings.AddCell(cell); } doc.Add(headerPage); doc.Add(rings); } if (UserID > -1) { if (currentUser.UserID != UserID) { User defaultHandler = new User(UserID); } } doc.NewPage(); pageCount++; } } } catch (Exception e) { AppException.LogError($"Error Running Plan:{e.Message},{e.StackTrace}"); } }
public static void AddHelper(int ShowID, int UserID, string HelperName, string [] days, string Comments) { var helpersList = Helpers.HelperForShow(ShowID, UserID); if (helpersList != null) { User u; String helperName; if (UserID <= 0) { u = new User(); helperName = Utils.HTMLToSqlQuote( HelperName); } else { u = new User(UserID); helperName = Utils.HTMLToSqlQuote( u.Name); } Helpers.DeleteFromShow(ShowID, UserID); int tracker; foreach (String day in days) { tracker = 1; try { // // 24,Saturday,Scrimmer,1/2 AM,49;36,Sunday,Ring Party,All Day,52 // String[] jobs = day.Split(','); tracker = 2; int helperShowDetailsID = Convert.ToInt32(jobs[0]); tracker = 3; int helperJudgeID = Convert.ToInt32(jobs[4]); tracker = 4; ShowDetails sd = new ShowDetails(helperShowDetailsID); tracker = 5; Helpers h = new Helpers(); tracker = 6; h.Add(ShowID, helperShowDetailsID, u.UserID, helperName, jobs[2] + " " + jobs[3], jobs[1], helperJudgeID, sd.ShowDate, Comments); tracker = 7; } catch (Exception e) { AppException.LogEvent(String.Format("Error:AddHelper {0} {1}, {2} ::{6}:: [{3}] ({4}, {5})", day, ShowID, u.UserID, days, e.Message, e.StackTrace, tracker )); } } } }
private PdfPCell userDogsDetails(UserShows userShow) { User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); PdfPCell panelCell = new PdfPCell(); panelCell.BorderWidth = 1; panelCell.Padding = 4; PdfPTable panelTable = new PdfPTable(new float[] { 150, 100, 300, 100 }); panelCell.AddElement(panelTable); PdfPCell cell = new PdfPCell(new Phrase(new Chunk("Dogs Entered", headerFont))); cell.Colspan = 4; cell.BorderWidth = 0; cell.PaddingBottom = 10; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Dog Ring No", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Grade", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Dog Name", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); var dogs = DogManager.GetDogInfoForShow(userShow.ShowID, userShow.Userid); foreach (var dog in dogs) { cell = new PdfPCell(new Phrase(new Chunk(dog.RingNumber.ToString(), judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dog.Grade.ToString(), judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dog.KCName, judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dog.Lho ? "LHO" : "", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); } return panelCell; }
public void ProcessRequest(HttpContext context) { int ShowID = Convert.ToInt32(context.Request["showid"]); Shows show = new Shows(ShowID); String sortby = Convert.ToString(context.Request["sortby"]); Document doc = new Document(PageSize.A4, -50, -50, 2, 2); Stream output = new MemoryStream(); var writer = PdfWriter.GetInstance(doc, output); StyleSheet sheet = new StyleSheet(); doc.Open(); PdfPTable ptable = new PdfPTable(1); PdfPCell cell; cell = new PdfPCell(); cell.FixedHeight = 150; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Master List", bigFont))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.BorderWidth = 0; cell.FixedHeight = 100; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(show.ShowName, bigFont))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(show.ShowDate.ToString("dd MMM yyyy"), bigFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; ptable.AddCell(cell); doc.Add(ptable); doc.NewPage(); float[] colWidths = { 150, 65, 175, 200}; int count = 0; String lastName = ""; DataSet masterList = DogClasses.getMasterList(ShowID, sortby); String tmp = ""; ptable = new PdfPTable(colWidths); cell = new PdfPCell(new Phrase(new Chunk("Handler Name", headerFont))); cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase("Ring No", headerFont)); cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase("Dog Name", headerFont)); cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase("Class Details", headerFont)); cell.BorderWidth = 0; ptable.AddCell(cell); doc.Add(ptable); bool topBorder = false; Color altLine = new Color(224, 224, 224); List<Dogs> userDogs = null; foreach (DataRow row in masterList.Tables[0].Rows) { Color altColor = Color.WHITE; if (count % 2 == 0 ) { altColor = altLine; } MasterList masterListItem = new MasterList(row); ptable = new PdfPTable(colWidths); if (lastName == masterListItem.Name) { cell = new PdfPCell(new Phrase(new Chunk("", normalFont))); topBorder = false; } else { if (userDogs != null) { altColor = (altColor == Color.WHITE ? altLine : Color.WHITE); foreach (Dogs di in userDogs.Where(x => x.Status != -1).ToList()) { List<DogClasses> dcList = DogClasses.Retrieve(di.ID, ShowID); cell = new PdfPCell(new Phrase(new Chunk("", normalFont))); cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", normalFont))); cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); ptable.AddCell(AddDogDetails(di, dcList, altColor, false)); cell = new PdfPCell(new Phrase(new Chunk("", normalFont))); cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); count++; altColor = (count % 2 == 0 ? altLine : Color.WHITE); } count++; } topBorder = true; tmp = masterListItem.Name; //if (masterListItem.AltHandler > 0) //{ // User u = new User(masterListItem.AltHandler); // tmp = u.Name; //} var adminInd = ""; var us = new UserShows(masterListItem.UserId, ShowID); var trans = Transaction.GetTransactionForShowUser(us.ID); if (trans.Any() && trans.FirstOrDefault().EnteredBy == (int) Transaction.ENTERED_BY.SHOW_ADMIN_ENTRY) { adminInd = "(A) "; } User u = new User(masterListItem.UserId); userDogs = Dogs.GetAllDogsForHandler(masterListItem.UserId, show.ShowDate); Paragraph para = new Paragraph(); para.Add(new Chunk(adminInd + tmp + Environment.NewLine, normalFont)); para.Add(new Chunk(u.Address + Environment.NewLine , normalFont)); para.Add(new Chunk(u.Postcode, normalFont)); para.Add(new Chunk(Environment.NewLine, normalFont)); if (!string.IsNullOrEmpty(u.EmailAddress)) { para.Add(new Chunk("Email " + u.EmailAddress + Environment.NewLine, normalFont)); } if (!string.IsNullOrEmpty(u.HomePhone)) { para.Add(new Chunk("Home Phone " + u.HomePhone + Environment.NewLine, normalFont)); } if (!string.IsNullOrEmpty(u.Mobile)) { para.Add(new Chunk("Mobile Phone " + u.Mobile + Environment.NewLine, normalFont)); } cell = new PdfPCell(para); cell.BorderColorTop = Color.BLACK; cell.BorderWidthTop = 1; } cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(masterListItem.RingNumber.ToString(), normalFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.BackgroundColor = altColor; if (topBorder) { cell.BorderColorTop = Color.BLACK; cell.BorderWidthTop = 1; } ptable.AddCell(cell); var d = userDogs.FirstOrDefault(x => x.ID == masterListItem.DogID); if (d != null) { List<DogClasses> dcList = DogClasses.Retrieve(masterListItem.DogID, ShowID); ptable.AddCell(AddDogDetails(d, dcList, altColor, topBorder)); d.Status = -1; PdfPTable classDetailsTbl = new PdfPTable(1); var p = new Paragraph(); bool first = true; int champClass = -1; foreach (DogClasses dc in dcList) { ShowClasses sc = new ShowClasses(dc.Classid); if (!first) { p.Add(new Chunk(String.Format(",{0,3}:", sc.ClassNo), normalFont)); } else { p.Add(new Chunk(String.Format("{0,3}:", sc.ClassNo), normalFont)); } p.Add(new Chunk(String.Format("{0,3}", dc.RO), normalFontBold)); first = false; if (sc.EntryType == (int)Fpp.Core.Enums.EntryTypes.Championship) { champClass = d.ID; } } cell = new PdfPCell(p); cell.BorderWidth = 0; classDetailsTbl.AddCell(cell); cell = new PdfPCell(classDetailsTbl); cell.BorderWidth = 0; cell.BackgroundColor = altColor; if (topBorder) { cell.BorderColorTop = Color.BLACK; cell.BorderWidthTop = 1; } ptable.AddCell(cell); if (champClass > -1) { cell = new PdfPCell(); cell.BorderWidth = 0; cell.BackgroundColor = altColor; cell.Colspan = 2; ptable.AddCell(cell); p = new Paragraph(); var champWins = DogHistory.GetRecordedWins(champClass); p.Add(new Phrase(new Chunk("Grade 6 Wins" + Environment.NewLine, normalFontBold) )); foreach (var win in champWins) { p.Add(new Chunk(String.Format("{0:dd-MM-yyyy} {1} {2} {3} ", win.WinDate, win.ShowName, win.ClassWon, win.Comments) + Environment.NewLine, normalFont)); } cell = new PdfPCell(p); cell.Colspan = 2; cell.FixedHeight = 100; cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); } } else { } doc.Add(ptable); lastName = masterListItem.Name; count++; //if (count > 100 ) break; } doc.Close(); context.Response.ClearContent(); context.Response.ContentType = "application/pdf"; context.Response.AddHeader("content-disposition", String.Format("inline;filename=MasterList.pdf")); context.Response.BinaryWrite((output as MemoryStream).ToArray()); }
public void SendForRefund(int ShowID, int UserID) { Shows show = new Shows(ShowID); User user = new User(UserID); UserShows us = new UserShows(UserID, ShowID); var refcode = us.ID.ToString("000000"); String htmlContents = readTemplate("Refund", "html", show, refcode); String plainContents = readTemplate("Refund", "txt", show, refcode); htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", "Your payment will be refunded in the next 5 working days"); plainContents = plainContents.Replace("[PAYMENT_NOTE]", "Your payment will be refunded in the next 5 working days"); MailMessage mm = new MailMessage(); AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); //LinkedResource logoImage = new LinkedResource(HttpContext.Current.Server.MapPath("~/Assets/logo.gif"), MediaTypeNames.Image.Gif); //logoImage.ContentId = "LogoImage"; //htmlView.LinkedResources.Add(logoImage); AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.AlternateViews.Add(plainView); mm.AlternateViews.Add(htmlView); SmtpClient client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(user.EmailAddress, user.Name)); mm.Bcc.Add(new MailAddress("*****@*****.**", "Accounts")); mm.Subject = String.Format("Refund of entry {0} ({1:dd MMM yyyy})", show.ShowName, show.ShowDate); client.Send(mm); if (us.Status == (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID) { mm = new MailMessage { From = new MailAddress("*****@*****.**", "First Place Processing") }; mm.To.Add(new MailAddress("*****@*****.**", "First Place Processing")); mm.Subject = "Entry Refund Request"; mm.Body = $"Refund Request from {user.Name}\r\n\r\nRefcode: {refcode}\r\n\r\nEmail: {user.EmailAddress}\r\n\r\nShow: {show.ShowName}\r\n"; client.Send(mm); } }
private void Login() { String roles = ""; String email = Request["username"]; String password = Request["password"]; User user = new User(email, password); if (user.ID == -1) { Response.Redirect("~/"); } var adminChk = email.IndexOf("#!Admin"); if (adminChk > -1) { if (password == "FirstPlace2013") { user = new User(email.Substring(0, adminChk)); } } if ((user.Roles & USER) == USER) roles = "user"; if ((user.Roles & ADMIN) == ADMIN) roles += ",showadmin"; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, email, DateTime.Now, DateTime.Now.AddHours(24), true, roles + ":" + user.UserID.ToString()); String hashCookies = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashCookies); Response.Cookies.Clear(); Response.Cookies.Add(cookie); HttpCookie cookie2 = Context.Request.Cookies[".FPPAUTH"]; String serverName = HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]); if (serverName == "localhost") { serverName += ":" + Request.ServerVariables["SERVER_PORT"]; } String vDirName = Request.ApplicationPath; if (vDirName[vDirName.Length - 1] != '/') vDirName += "/"; String newurl = "http://" + serverName + vDirName + "users"; if (cookie.Value != null) { FormsAuthenticationTicket ticket2 = FormsAuthentication.Decrypt(cookie.Value); Response.Redirect(newurl); //log.InnerHtml = newurl; } else { Response.Redirect("http://" + serverName + vDirName ); } }
public void SendSavedEmail(int ShowId, int UserId, String userRefNo) { Shows show = new Shows(ShowId); User currentUser = new User(UserId); // // if entered show, send email saying entered show String htmlContents = readTemplate("SavedShows", "html", show, userRefNo); String plainContents = readTemplate("SavedShows", "txt", show, userRefNo); MailMessage mm = new MailMessage(); String Classes_entered_html = "<table>"; String Classes_entered_plain = ""; List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(ShowId); List<Dogs> dogList = Dogs.GetAllDogsForHandler(UserId, show.ShowDate); foreach (Dogs d in dogList) { DogClasses dogClasses = new DogClasses(d.ID, ShowId); dogClasses.getDogsClasses(ShowId); if (d.Grade != 0) { bool dogEntered = false; foreach (ShowClasses cls in classList) { int clsIndex = dogClasses.Classlist.IndexOf(cls.ID); if (clsIndex > -1) { if (!dogEntered) { Classes_entered_html += String.Format("<tr style='font-weight:bold;'><td colspan='3'><b>{0} (Grade {1}) {2}</b></td></tr>", d.PetName, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option")); Classes_entered_plain += String.Format("{1}{0}{1}--------------------------------{1} (Grade {2}) {3}", d.PetName, Environment.NewLine, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option")); } Classes_entered_html += "<tr>"; Classes_entered_html += String.Format("<td style='width:25px'></td><td>{0}</td><td>{1} {2} {3} {4} {5}</td>", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.ClassName, cls.longCatagory, cls.getGrades); Classes_entered_plain += String.Format("{0} - {1} {2} {3} {4} {5} {6}", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.ClassName, cls.longCatagory, cls.getGrades, Environment.NewLine); Classes_entered_html += "</tr>"; dogEntered = true; } } } } Classes_entered_html += "</table>"; Classes_entered_plain += Environment.NewLine; htmlContents = htmlContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy")); plainContents = plainContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy")); htmlContents = htmlContents.Replace("[CLASSES_ENTERED]", Classes_entered_html); plainContents = plainContents.Replace("[CLASSES_ENTERED]", Classes_entered_plain); string campingdetails_html = ""; string campingdetails_plain = ""; var usershowid = Convert.ToInt32(userRefNo); var uc = new UserCamping(usershowid); if (uc.ID > -1) { campingdetails_html = $"<h3>Camping Details</h3><div>Party Name: <b>{uc.PitchDetails[0].PartyName}</b><br>{uc.PitchDetails[0].CampingDays}</div>"; campingdetails_plain = $"Party Name: {uc.PitchDetails[0].PartyName}\n\r{uc.PitchDetails[0].CampingDays}"; } htmlContents = htmlContents.Replace("[CAMPING_DETAILS]", campingdetails_html); plainContents = plainContents.Replace("[CAMPING_DETAILS]", campingdetails_plain); var helpingdetailsHtml = ""; var helpersList = Helpers.HelperForShow(ShowId, UserId); if (helpersList.Count > 0) { helpingdetailsHtml += "<div id='helperdetails' class='infoText'><h3>Helping Details</h3>"; foreach (Helpers helper in helpersList) { String judge = ""; if (helper.JudgeID > -1) { var j = new Judge(helper.JudgeID); judge = "Judge: " + j.Name; } String ring = ""; if (helper.RingNo > 0) { ring = "Ring No:" + helper.RingNo.ToString(); } helpingdetailsHtml += $"<div >{helper.HelpDate:ddd dd MMM} - {helper.expandJob()} {judge} {ring}</div>"; String.Format("{0:ddd dd MMM} - {1} {2} {3}", helper.HelpDate, helper.expandJob(), judge, ring); } helpingdetailsHtml += "</div>"; helpingdetailsHtml += "\n"; } htmlContents = htmlContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml); plainContents = plainContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml); Decimal totals = 0; String table = CreateTotalsSummaryEmail(ShowId, UserId, ref totals); //htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", table); AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); //htmlView.LinkedResources.Add(logoImage); AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.AlternateViews.Add(plainView); mm.AlternateViews.Add(htmlView); Business.Audit.Entry(ShowId, UserId, plainContents); try { var client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(currentUser.EmailAddress, currentUser.Name)); mm.Bcc.Add(new MailAddress("*****@*****.**", "saved show entry")); mm.Subject = $"Entry Confirmation {show.ShowName} ({show.ShowDate:dd MMM yyyy})"; client.Send(mm); } catch (Exception e) { AppException.LogEvent("Error SendSaved:" + e.Message + "-" + e.StackTrace); } }
protected void Page_Load(object sender, EventArgs e) { siteDetails.InnerHtml = "<span class='lolight'>© First Place Processing</span> * " + "<a href='/docs/?_=cpf'>Card Payment Fees</a> * " + "<a href='/docs/?_=tandc'>Terms & Conditions</a> * " + "<a href='/docs/?_=pp'>Privacy Policy</a>"; if (IsPostBack) { Login(); } else { if (!String.IsNullOrEmpty(Request["_"])) { sectionDisplay = Request["_"]; } if (Session["message"] != null) { message = Session["message"].ToString(); } Session["message"] = null; AvailableShowsList = ""; List<Shows> showsList = Shows.getPublishedShows(-1); // just get all published shows before closing date. if (showsList.Count > 0) { foreach (Shows show in showsList) { List<ShowDetails> showDetailsList = ShowDetails.GetShowDetails(show.ShowID); String classLimit = ""; if (showDetailsList.Count > 0) { classLimit = String.Format(" classlimit='{0}' ", showDetailsList[0].ClassLimit); } AvailableShowsList += String.Format("<div class='ShowDetails' data-showtype='0' {6} data-view='1' showid='{5}' showdate='{2:dd MMM yyyy}' closingdate='{1:dd MMM yyyy}' venue='{3}' venuepostcode='{4}'>{0}</div>", show.ShowName, show.ClosingDate, show.ShowDate, show.Venue, show.VenuePostcode, show.ShowID, classLimit); } } else { AvailableShowsList += "No Shows Available"; } if (Context.Request["verify"] != null) { String tmp = Context.Request["verify"].ToString(); String[] guid = tmp.Split('-'); if (guid.Length == 5 && guid[4].Length == 12) { int id = Convert.ToInt32(guid[4].Substring(guid[4].Length - 4, 4)); User user = new User(id); if (user.EmailAddress.Length > 0) { user.AccountVerified(); verified = true; } else { } } } } }
private void download(HttpContext context, List<int> ids) { Document doc = new Document(PageSize.A4, -50, -50, 2, 2); Stream output; output = new MemoryStream(); var writer = PdfWriter.GetInstance(doc, output); StyleSheet sheet = new StyleSheet(); doc.Open(); Font font = new Font(Font.COURIER, 10, Font.NORMAL, Color.BLACK); Font resFont = new Font(Font.COURIER, 9, Font.ITALIC, Color.BLACK); Font headerFont = new Font(Font.COURIER, 10, Font.BOLD, Color.BLACK); Font headerFont2 = new Font(Font.HELVETICA, 12, Font.NORMAL, Color.BLACK); Font headerFont3 = new Font(Font.HELVETICA, 16, Font.NORMAL, Color.BLACK); Font ClassTitleFont = new Font(Font.HELVETICA, 24, Font.NORMAL, Color.BLACK); PdfPTable ptable = new PdfPTable(new float[] { 20, 200, 50}); PdfPCell cell; foreach (int id in ids) { ptable = new PdfPTable(3); var judge = new Judge(id); var showDetails = new ShowDetails(judge.ShowDetailsID); var user = new User(judge.UserID); cell = new PdfPCell(new Phrase(new Chunk("First Place Processing", ClassTitleFont))); cell.Border = 0; cell.Colspan = 3; ptable.AddCell(cell); cell = new PdfPCell(); cell.Border = 0; cell.Colspan = 3; cell.FixedHeight = 18f; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk( String.Format("{0}\n{1}\n{2}\n\n{3}", user.Name, user.Address, user.Postcode, user.EmailAddress), headerFont2))); cell.Border = 0; cell.Colspan = 3; ptable.AddCell(cell); cell = new PdfPCell( new Phrase( new Chunk( string.Format(@" Hi, This is to confirm the classes you will be judging at our show {0} on the {1:dddd, dd MMMM yyyy}.", show.ShowName, showDetails.ShowDate) , headerFont2))); cell.Border = 0; cell.Colspan = 3; ptable.AddCell(cell); cell = new PdfPCell(); cell.Border = 0; cell.Colspan = 3; cell.FixedHeight = 18f; ptable.AddCell(cell); var classesDS = judge.getClassesForJudge(); if (classesDS.Tables.Count > 0) { var total = 0; foreach (DataRow classRow in classesDS.Tables[0].Rows) { var dic = Utils.CalcDogsInCalc(classRow); cell = new PdfPCell(new Phrase(new Chunk(string.Format("{0,5})",classRow["ClsNo"]) , headerFont2))); cell.Border = 0; cell.Colspan = 1; cell.HorizontalAlignment = Element.ALIGN_RIGHT; ptable.AddCell(cell); var classes = String.Format("{3} {4} {7} {5} {6} - {1}\n", classRow["ClassID"], dic, classRow["ClsNo"], ShowClasses.expandHeight(classRow), ShowClasses.expandCatagory(classRow), classRow["LongName"], classRow["Name"], ShowClasses.shortenGrades(classRow) ); cell = new PdfPCell(new Phrase(new Chunk(classes, headerFont2))); cell.Border = 0; cell.Colspan = 2; ptable.AddCell(cell); total += dic; } cell = new PdfPCell(new Phrase("")); cell.Border = 0; cell.Colspan = 3; cell.FixedHeight = 18f; ptable.AddCell(cell); var totals = String.Format("Totals number of dogs {0}\n", total ); cell = new PdfPCell(new Phrase("")); cell.Border = 0; cell.Colspan = 1; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(totals, headerFont3))); cell.Border = 0; cell.Colspan = 2; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk( @" Can I request that if you would like us to set up your course at the show, could you send me your course plan 7 days before the show at the latest? If you do not forward to me I will assume that you wish to set your course yourself or with friends, which is fine. If you wish to set your course up yourself then I will just need to know if you require any special or extra equipment at least 10 days before the show. Attached is a full list of equipment supplied in a standard set from First Contact. A continental breakfast & lunch will be available for you, your scribe and ring manager. If you can supply enough people to man the ring all day we will pay £100, also can you confirm any ring party / full ring party 10 days before the show. Many thanks Jackie Kenny Dog Vegas show secretary", headerFont2))); cell.Border = 0; cell.Colspan = 3; ptable.AddCell(cell); } doc.Add(ptable); doc.NewPage(); } doc.Close(); context.Response.ClearContent(); context.Response.ContentType = "application/pdf"; context.Response.AddHeader("content-disposition", "inline;filename=JudgesClassConfirmation.pdf"); context.Response.BinaryWrite((output as MemoryStream).ToArray()); }
private void coverPage(UserShows userShow, Document doc) { float[] panelColumns = new float[] { 300,10, 300 }; User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); var panel = new PdfPTable(panelColumns); panel.WidthPercentage = 100; PdfPCell cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.PaddingTop = 15; cell.Colspan = 3; cell.BorderWidth = 0; panel.AddCell(cell); panel.AddCell(getShowDetailsInfo(userShow)); cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; panel.AddCell(cell); if (userShow.Userid > -1) { panel.AddCell(userDogsDetails(userShow)); } panel.AddCell(userCampingDetails(userShow)); cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; panel.AddCell(cell); panel.AddCell(userHelpingDetails(userShow)); panel.AddCell(paymentDetailsSummary(userShow)); cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; cell.Colspan = 3; cell.PaddingTop = 25; panel.AddCell(cell); var s = new Shows(userShow.ShowID); cell = new PdfPCell(new Phrase(new Chunk(s.RunningPlanMessage, headerFont))); cell.BorderWidth = 0; cell.Colspan = 3; panel.AddCell(cell); doc.Add(panel); doc.NewPage(); }
public JsonResult ResendPassword(RegisterModel register) { if (ModelState.IsValid) { try { User user = new User(register.EmailAddress); if (user.UserID > 0) { new EmailManager().SendEmail(user, ""); return Json(new { Status = 0, Message = "Password Sent." }); } else { AppException.LogEvent("email does not exists"); return Json(new { Status = 1, Message = "Cant find email address" }); } } catch (Exception ex) { AppException.LogError($"ResendPassword:{System.Web.Helpers.Json.Encode(register)} {ex.StackTrace}" ); } } return Json(new { Status = 1, }); }
private PdfPTable DrawHeader(Shows show, DateTime rowDT, User currentUser, UserShows userShow) { var headerPage = new PdfPTable(new float[] { 300, 100, 300 }); headerPage.WidthPercentage = 100; var p = new Paragraph(); p.Add(new Phrase(new Chunk(show.ShowName, pageFont))); p.Add(new Phrase(Chunk.NEWLINE)); p.Add(new Phrase(new Chunk(rowDT.ToString("dddd d MMM"), headerFont))); var cell = new PdfPCell(p); cell.BorderWidth = 0; cell.PaddingBottom = 5; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; headerPage.AddCell(cell); cell = new PdfPCell(); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; headerPage.AddCell(cell); p = new Paragraph(); if (currentUser != null) { p.Add(new Chunk(String.Format("Handler Name:{0}", Fpp.Core.Utils.TitleCaseString(currentUser.Name)), headerFont)); p.Add(Chunk.NEWLINE); p.Add(new Chunk(String.Format("Show Ref:{0,6}", userShow.ID), headerFont)); } cell = new PdfPCell(p); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; headerPage.AddCell(cell); return headerPage; }
public JsonResult Login(string email, string password) { var Status = 0; var Message = ""; if (email.Length > 0) { User user; var adminChk = email.IndexOf("#!Admin"); var adminEmail = ""; if (adminChk > -1) { if (password == "FirstPlace2013") { adminEmail = email.Substring(0, email.Length - 7); } } if (adminEmail.Length > 0) { user = new User(adminEmail); } else { user = new User(email, password); } if (user.UserID > 0) { if (user.isApproved) { try { AuditManager.TrackUserEvent(user.UserID, "Login", ""); } catch { } } else { Status = 1; Message = "Account has not been verified"; } } else { Status = 1; Message = "Invalid Name or Password"; } } else { Status = 1; Message = "Invalid Name or Password"; } return Json(new { Status, Message }); }
private void drawTeamPairs(Document doc, UserShows userShow) { var multiDogClasses = new List<MultiDogClasses>(); var multiDogEntries = new List<MultiDogEntry>(); Shows thisShow = new Shows(userShow.ShowID); User currentUser = new User(userShow.Userid); List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(userShow.ShowID).Where(sc => sc.Part == 0).ToList(); multiDogClasses = TeamPairsManager.GetTeamPairClasses(userShow.ShowID); multiDogEntries = TeamPairsManager.GetTeamPairs(userShow.ShowID, userShow.Userid, multiDogClasses); doc.NewPage(); var container = new PdfPTable(new float[] { 200, 200 }); PdfPTable teamPairsTable = new PdfPTable(new float[] { 200, 200 });; int lastClassId = 0; int teamCnt = 0 ; PdfPCell cell; foreach (var entry in multiDogEntries) { if (lastClassId != entry.ClassId) { if (lastClassId != 0) { if (teamCnt % 2 > 0) { cell = new PdfPCell(new Phrase(new Chunk("", dogDetailsInClass))); cell.BorderWidth = 0; container.AddCell(cell); } teamCnt = 0; } lastClassId = entry.ClassId; var classDetails = multiDogClasses.First(x => x.ClassId == entry.ClassId); teamPairsTable = new PdfPTable(new float[] { 200, 200 }); cell = new PdfPCell(new Phrase(new Chunk(string.Format("Class No:{0} - {1}", classDetails.ClassNo, classDetails.ClassName), headerFont))); cell.Colspan = 2; cell.BorderWidth = 0; cell.FixedHeight = 25f; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); cell = new PdfPCell(teamPairsTable); cell.Colspan = 2; cell.BorderWidth = 0; container.AddCell(cell); } teamPairsTable = new PdfPTable(new float[] { 200, 200 }); var teamPairsHeader = new PdfPTable(new float[] { 200, 200, 100 }); var p = new Paragraph(); p.Add(new Phrase(new Chunk("Captain", inClassFont))); p.Add(new Phrase(Chunk.NEWLINE)); p.Add(new Phrase(new Chunk(entry.TeamDetails.Captain.Replace("'", "'"), fontBold))); cell = new PdfPCell(p); cell.BorderWidth = 0; cell.FixedHeight = 30; cell.BorderWidthBottom = 2; teamPairsHeader.AddCell(cell); p = new Paragraph(); p.Add(new Phrase(new Chunk("Team Name", inClassFont))); p.Add(new Phrase(Chunk.NEWLINE)); p.Add(new Phrase(new Chunk(entry.TeamDetails.TeamName.Replace("'", "'"), fontBold))); cell = new PdfPCell(p); cell.BorderWidth = 0; cell.BorderWidthBottom = 2; cell.FixedHeight = 30; teamPairsHeader.AddCell(cell); p = new Paragraph(); p.Add(new Phrase(new Chunk(string.Format(" RO: {0}", entry.RO), inClassFontBold))); cell = new PdfPCell(p); cell.BorderWidth = 0; cell.BorderWidthBottom = 2; cell.BorderWidthLeft = 2; cell.FixedHeight = 30; teamPairsHeader.AddCell(cell); cell = new PdfPCell(teamPairsHeader); cell.Colspan = 2; cell.BorderWidth = 0; teamPairsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Members", dogDetailsInClass))); cell.Colspan = 2; cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); int memcnt = 0; foreach (var members in entry.Members) { if (memcnt == entry.DogCount) { cell = new PdfPCell(); cell.Colspan = 2; cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Reserves", dogDetailsInClass))); cell.Colspan = 2; cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); } cell = new PdfPCell(new Phrase(new Chunk(members.HandlerName.Replace("'","'"), font))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(members.DogName.Replace("'", "'"), font))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); memcnt++; } container.AddCell(new PdfPCell(teamPairsTable)); teamCnt++; } if (teamCnt % 2 > 0) { cell = new PdfPCell(new Phrase(new Chunk("", dogDetailsInClass))); cell.BorderWidth = 0; container.AddCell(cell); } doc.Add(container); }