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()); }
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); } }
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); } }
private Models.RingDetails CreateRing(ShowDetails day, Rings ring) { RingDetails rd = new RingDetails { RingId = ring.ID, RingNo = ring.RingNo, JudgeDetails = new List<JudgeDetails>(), ShowDetailsId = ring.ShowDetailsID }; DataSet judgesDS = Rings.GetJudgesForRing(ring.ID); if (judgesDS.Tables[0].Rows.Count > 0) { foreach (DataRow judgeRow in judgesDS.Tables[0].Rows) { Judge judge = new Judge(judgeRow); var judgeDetails = new JudgeDetails { JudgeId = judge.ID, JudgeName = judge.Name, RingOrder = judge.RingOrder, ClassDetails = new List<ClassDetails>(), HelperDetails = new List<Helper>() }; var helperDS = Business.Helpers.GetHelpersForRing(day, ring.ID); if (helperDS.Tables.Count > 0) { foreach (DataRow helperRow in helperDS.Tables[0].Rows) { Business.Helpers h = new Business.Helpers(helperRow); String job = Fpp.Core.Utils.expandJob(h.Job, h.JobDetails); Helper hd = new Helper { HelperId = h.ID, HelperName = h.Name, JobDescription = Business.Helpers.expandHelper(h) }; judgeDetails.HelperDetails.Add(hd); } } DataSet classesDS = judge.getClassesForJudge(); if (classesDS.Tables.Count > 0) { foreach (DataRow classRow in classesDS.Tables[0].Rows) { ShowClasses sc = new ShowClasses(classRow); var Part = Convert.ToInt32(classRow["Part"]); var PartNo = ""; var ClassName = classRow["ShortName"].ToString(); if (sc.EntryType == 10) { ClassName = classRow["Name"].ToString(); if (ClassName.Contains("Jumping")) ClassName = "Jumping"; else if (ClassName.Contains("Agility")) ClassName = "Agility"; else if (ClassName.Contains("Final")) ClassName = "Final"; ClassName = string.Format("{0} {1} {2}", ShowClasses.expandHeightShort(classRow), sc.ShortClassName, ClassName); } else { PartNo = (Part == 0 ? "" : string.Format("Pt {0}", Part)); ClassName = string.Format("{0} {1} {2} {3} {4} {5}", ShowClasses.expandHeightShort(classRow), ShowClasses.expandCatagoryShort(classRow), ClassName, ShowClasses.shortenName(classRow), ShowClasses.shortenGrades(classRow), PartNo); } judgeDetails.ClassDetails.Add(new ClassDetails { ClassId = sc.ID, ClassNo = sc.ClassNo, PartNo = Part, DogsInClass = Fpp.Core.Utils.CalcDogsInCalc(classRow), ClassName = ClassName, Height = sc.Height }); } } rd.JudgeDetails.Add(judgeDetails); } } return rd; }
public bool Delete() { Fpp.Data.ShowDetails showDetails = new Fpp.Data.ShowDetails(ModuleSettings); ShowClasses sc = new ShowClasses(); sc.RemoveRing(ID); Judge j = new Judge(); j.removeRing(ID); Fpp.Business.Helpers h = new Fpp.Business.Helpers(); h.removeRing(ID); _ring.Delete(ID); int ringNo = 1; var rings = GetRingsForShowDayList(_showDetailsID).OrderBy(x => x.RingNo); foreach (var r in rings) { r.RingNo = ringNo; r.Save(); ringNo++; } return true; }
public void RingBoards(Document doc, int ShowId, int RingId) { Font smallFont = new Font(Font.COURIER, 8, Font.NORMAL, Color.BLACK); Font normalFont = new Font(Font.COURIER, 10, Font.NORMAL, Color.BLACK); Font mediumFont = new Font(Font.HELVETICA, 20, Font.NORMAL, Color.BLACK); ShowClasses sc = new ShowClasses(); List<Rings> AllRings = new List<Rings>(); if (RingId == -1) { AllRings = Rings.GetAllRingsForShow(ShowId); } else { AllRings.Add(new Rings(RingId)); } var showDetailsList = ShowDetails.GetShowDetails(ShowId); Shows show = new Shows(ShowId); foreach (var showDetails in showDetailsList) { Rings rings = new Rings(); var ringsForDays = Rings.GetRingsForShowDayList(showDetails.ID); // var groupByRing = ringsForDays.GroupBy(x => x.RingNo); int lastRingNo = 0; foreach (Rings ring in ringsForDays) { if (ring.ID > -1 && lastRingNo != ring.RingNo) { lastRingNo = ring.RingNo; doc.NewPage(); DataSet judgesDS = Rings.GetJudgesForRing(ring.ID); if (judgesDS.Tables[0].Rows.Count > 0) { foreach (DataRow judgeRow in judgesDS.Tables[0].Rows) { Judge judge = new Judge(judgeRow); CreateRing(doc, show, showDetails, ring, judge, "", lastRingNo); } } } } } doc.NewPage(); }
private Models.RingDetails CreateRing(ShowDetails day, Rings ring) { RingDetails rd = new RingDetails { JudgeDetails = new List<JudgeDetails>(), ShowDetailsId = ring.ShowDetailsID }; DataSet judgesDS = Rings.GetJudgesForRing(ring.ID); if (judgesDS.Tables[0].Rows.Count > 0) { foreach (DataRow judgeRow in judgesDS.Tables[0].Rows) { Judge judge = new Judge(judgeRow); var judgeDetails = new JudgeDetails { JudgeId = judge.ID, JudgeName = judge.Name, ClassDetails = new List<ClassDetails>(), HelperDetails = new List<Helper>() }; var helperDs = Business.Helpers.GetHelpersForRing(day, ring.ID); if (helperDs.Tables.Count > 0) { foreach (DataRow helperRow in helperDs.Tables[0].Rows) { var h = new Business.Helpers(helperRow); var hd = new Helper { HelperId = h.ID, HelperName = h.Name, JobDescription = h.Job }; judgeDetails.HelperDetails.Add(hd); } } DataSet classesDS = Rings.GetClassesForRing(ring.ID); classesDS = judge.getClassesForJudge(); if (classesDS.Tables.Count > 0) { foreach (DataRow classRow in classesDS.Tables[0].Rows) { ShowClasses sc = new ShowClasses(classRow); judgeDetails.ClassDetails.Add(new ClassDetails { ClassId = sc.ID, ClassNo = sc.ClassNo, DogsInClass = Fpp.Core.Utils.CalcDogsInCalc(classRow), ClassName = $"{ShowClasses.expandHeightShort(classRow)} {ShowClasses.expandCatagoryShort(classRow)} {classRow["ShortName"]} {classRow["Name"]} {ShowClasses.shortenGrades(classRow)}" }); } } rd.JudgeDetails.Add(judgeDetails); } } return rd; }
private void TrailerSheetRing(Document doc, Shows show, ShowDetails showDetails, Rings ring, Judge judge, String ringTemplate, int lastRingNo) { var trailerColumns = new float[] { 30, 150, 15, 35, 40, 20, 20, 20, 10 }; var cellHeight = 18; var ptable = new PdfPTable(trailerColumns); AddCellToHeader(ptable, string.Format("Ring {0}", ring.RingNo)); AddCellToHeader(ptable, string.Format("{0}", judge.Name)); AddCellToHeader(ptable, ""); AddCellToHeader(ptable, "Walking"); AddCellToHeader(ptable, "Calling up to"); AddCellToHeader(ptable, "End"); AddCellToHeader(ptable, "Final"); AddCellToHeader(ptable, "Closed"); AddCellToHeader(ptable, "P"); doc.Add(ptable); ptable = new PdfPTable(trailerColumns); DataSet classesDS = Rings.GetClassesForRing(ring.ID); classesDS = judge.getClassesForJudge(); var ringTotal = 0; PdfPCell cell; var altRow = Color.LIGHT_GRAY; var topBorderColor = altRow; if (classesDS.Tables.Count > 0) { foreach (DataRow classRow in classesDS.Tables[0].Rows) { var cls = new ShowClasses(Convert.ToInt32(classRow["ClassId"])); altRow = altRow == Color.WHITE ? Color.LIGHT_GRAY : Color.WHITE; topBorderColor = Color.BLACK; var part = Convert.ToInt32(classRow["Part"]); cell = new PdfPCell(new Phrase(new Chunk( string.Format("Class {0}", classRow["ClsNo"]), headerHFont))); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BackgroundColor = altRow; ptable.AddCell(cell); var lhoTableInd = new PdfPTable(1); int clsHeight = Convert.ToInt32(classRow["Height"]); var className = ""; if (clsHeight == 0) { className = string.Format("{0} {1} {2}{3}", classRow["LongName"], classRow["Name"], ShowClasses.shortenGrades(classRow) , (part > 0 ? " - Pt " + part : "")); } else { className = string.Format("{0} {1} {2} {3} {4}{5}", ShowClasses.expandHeight(classRow), ShowClasses.expandCatagory(classRow), classRow["LongName"], classRow["Name"], ShowClasses.shortenGrades(classRow), (part > 0 ? " - Pt " + part : "")); } if (cls.Lho == 1 || cls.Lho == 2 ) { var dcCounts = DogClasses.GetEntryCountsByClassId(show.ID, cls.ID); var innerTable = new PdfPTable(1); var classNameTable = new PdfPTable(2); className = className.Replace("sponsored by", "sp by"); classNameTable.AddCell(new PdfPCell(new Phrase(new Chunk(className, headerHFont))) { HorizontalAlignment = Element.ALIGN_LEFT, BackgroundColor = altRow, NoWrap = true, BorderWidth = 0, }); classNameTable.AddCell(new PdfPCell(new Phrase(new Chunk(dcCounts[0].Lho == 0 ? "Full Height" : "Lower Height", headerHFont))) { HorizontalAlignment = Element.ALIGN_RIGHT, BackgroundColor = altRow, NoWrap = true, BorderWidth = 0, }); innerTable.AddCell(new PdfPCell(classNameTable) { BackgroundColor = altRow, NoWrap = false, BorderWidth = 0, BorderColorBottom = Color.GRAY, BorderWidthBottom = 1 }); innerTable.AddCell(new PdfPCell(new Phrase(new Chunk((dcCounts[1].Lho == 0 ? "Full Height" : "Lower Height"), headerHFont))) { HorizontalAlignment = Element.ALIGN_RIGHT, PaddingRight = 5, BackgroundColor = altRow, NoWrap = false, BorderWidth = 0, }); ptable.AddCell(new PdfPCell(innerTable) { }); innerTable = new PdfPTable(1); foreach (var dcc in dcCounts) { innerTable.AddCell(new PdfPCell(new Phrase(new Chunk(string.Format("{0}", dcc.Count), headerHFont))) { HorizontalAlignment = Element.ALIGN_RIGHT, BackgroundColor = altRow, NoWrap = false, BorderWidth = 0, BorderWidthBottom = 1, BorderColorBottom = Color.GRAY }); } ptable.AddCell(new PdfPCell(innerTable) { HorizontalAlignment = Element.ALIGN_RIGHT}); lhoTableInd.AddCell(new PdfPCell(new Phrase(" ")) { BorderWidth = 0, BorderWidthBottom = 1, BorderColorBottom = Color.GRAY }); lhoTableInd.AddCell(new PdfPCell(new Phrase(" ")) { BorderWidth = 0}); } else { ptable.AddCell(new PdfPCell(new Phrase(new Chunk(className, headerHFont))) { HorizontalAlignment = Element.ALIGN_LEFT, BackgroundColor = altRow, NoWrap = false }); var classTotal = Fpp.Core.Utils.CalcDogsInCalc(classRow); ringTotal += classTotal; cell = new PdfPCell(new Phrase(new Chunk(string.Format("{0, 5}", classTotal), headerHFont))); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BackgroundColor = altRow; ptable.AddCell(cell); } ptable.AddCell(new PdfPCell(lhoTableInd) { BackgroundColor = altRow }); ptable.AddCell(new PdfPCell(lhoTableInd) { BackgroundColor = altRow }); ptable.AddCell(new PdfPCell(lhoTableInd) { BackgroundColor = altRow }); ptable.AddCell(new PdfPCell(lhoTableInd) { BackgroundColor = altRow }); ptable.AddCell(new PdfPCell(lhoTableInd) { BackgroundColor = altRow }); ptable.AddCell(new PdfPCell(lhoTableInd) { BackgroundColor = altRow }); } cell = new PdfPCell(new Phrase(new Chunk("", headerHFont))); cell.FixedHeight = cellHeight; ptable.AddCell(cell); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(string.Format("{0}",ringTotal), headerHFont))); cell.FixedHeight = cellHeight; cell.HorizontalAlignment = Element.ALIGN_RIGHT; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", headerHFont))); cell.FixedHeight = cellHeight; ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", headerHFont))); cell.FixedHeight = cellHeight; cell.BorderWidth = 0; ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); doc.Add(ptable); } }
public int HelperList(Document doc, int ShowId) { var ret = -1; var data = Helpers.GetAllHelpersForShow(ShowId, "Name", 0); var ShowDays = ShowDetails.GetShowDetails(ShowId ); var unallocated = data.Where(x => x.RingNo < 1).OrderBy(z => (int)z.TimePeriod).ToList(); var allocated = data.Where(x => x.RingNo >= 1).OrderBy(y => y.RingNo).ToList(); doc.Open(); var resFont = new Font(Font.COURIER, 8, Font.ITALIC, Color.BLACK); var MaxColumns = 3; var ptable = new PdfPTable(MaxColumns); var show = new Shows(ShowId); var cell = new PdfPCell(new Phrase(new Chunk($"{show.ShowName} Helping List ", ClassTitleFont))) { BorderWidth = 0, Colspan = MaxColumns, FixedHeight = 40 }; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Allocated", ClassTitleFont))) { Colspan = MaxColumns, BorderWidth = 0 }; ptable.AddCell(cell); foreach (var showDay in ShowDays ) { cell = new PdfPCell(new Phrase(new Chunk(showDay.ShowDate.ToString("ddd, dd MMM"), ClassTitleFont))) { Colspan = MaxColumns, BorderWidth = 0, FixedHeight = 30 }; ptable.AddCell(cell); var ringNo = 0; PdfPTable innerTable = null; foreach (var item in allocated.Where(x => x.HelpDate == showDay.ShowDate).OrderBy( v => v.RingNo)) { if (ringNo != item.RingNo) { ringNo = item.RingNo; if (innerTable != null) { ptable.AddCell(innerTable); } innerTable = new PdfPTable(MaxColumns); var j = new Judge(); j.getJudgeForRing(item.RingId); cell = new PdfPCell( new Phrase(new Chunk($"Ring No {ringNo} - {j.JudgeName}", headerFont))) { Colspan = MaxColumns, BorderWidth = 0 }; innerTable.AddCell(cell); } cell = new PdfPCell(new Phrase(new Chunk(Helpers.expandHelper(item), resFont))) { BorderWidth = 0, Colspan = 2 }; if (innerTable != null) { innerTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(item.Name, resFont))) {BorderWidth = 0}; innerTable.AddCell(cell); } } if (innerTable != null) { ptable.AddCell(innerTable); var remainder = (ringNo % MaxColumns ); while (remainder > 0) { cell = new PdfPCell(new Phrase(new Chunk("", headerFont))) { Colspan = MaxColumns, BorderWidth = 0 }; ptable.AddCell(cell); remainder--; } } doc.Add(ptable); doc.NewPage(); ptable = new PdfPTable(MaxColumns); } ptable = new PdfPTable(MaxColumns); cell = new PdfPCell(new Phrase(new Chunk("Unallocated", bigFont))) { Colspan = 3, BorderWidth = 0 }; ptable.AddCell(cell); foreach (var showDay in ShowDays) { cell = new PdfPCell(new Phrase(new Chunk(showDay.ShowDate.ToString("ddd, dd MMM"), bigFont))) { Colspan = 3, BorderWidth = 0 }; ptable.AddCell(cell); foreach (var item in unallocated.Where(x => x.HelpDate == showDay.ShowDate)) { // <div class="helperRow @(item.HandlerType == 1 ? "member" : " ") "> cell = new PdfPCell(new Phrase(new Chunk(Helpers.expandHelper(item), ClassTitleFont))) { BorderWidth = 0, Colspan = 2 }; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(item.Name, ClassTitleFont))) {BorderWidth = 0}; ptable.AddCell(cell); } doc.Add(ptable); doc.NewPage(); ptable = new PdfPTable(MaxColumns); } return ret; }
public void TrailerSheets(Document doc, int ShowId) { Font smallFont = new Font(Font.COURIER, 8, Font.NORMAL, Color.BLACK); Font normalFont = new Font(Font.COURIER, 10, Font.NORMAL, Color.BLACK); Font mediumFont = new Font(Font.HELVETICA, 20, Font.NORMAL, Color.BLACK); ShowClasses sc = new ShowClasses(); List<Rings> AllRings = new List<Rings>(); var showDetailsList = ShowDetails.GetShowDetails(ShowId); Shows show = new Shows(ShowId); var pageBreaks = 0; foreach (var showDetails in showDetailsList) { Rings rings = new Rings(); var ringsForDays = Rings.GetRingsForShowDayList(showDetails.ID); // var groupByRing = ringsForDays.GroupBy(x => x.RingNo); int lastRingNo = 0; foreach (Rings ring in ringsForDays) { if (ring.ID > -1 && lastRingNo != ring.RingNo) { lastRingNo = ring.RingNo; if (pageBreaks % 3 == 0 || ring.RingNo == 1) { doc.NewPage(); pageBreaks = 0; } DataSet judgesDS = Rings.GetJudgesForRing(ring.ID); if (judgesDS.Tables[0].Rows.Count > 0) { foreach (DataRow judgeRow in judgesDS.Tables[0].Rows) { Judge judge = new Judge(judgeRow); TrailerSheetRing(doc, show, showDetails, ring, judge, "", lastRingNo); } } } pageBreaks++; } } doc.NewPage(); }
private void CreateRing(Document doc, Shows show, ShowDetails showDetails, Rings ring, Judge judge, String ringTemplate, int lastRingNo) { var ptable = new PdfPTable(1); var cell = new PdfPCell(new Phrase(new Chunk($"Ring {ring.RingNo}", extremeFont))) { BorderWidth = 0, FixedHeight = 75f, HorizontalAlignment = Element.ALIGN_CENTER }; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk($"{judge.Name}", extremeFont))) { BorderWidth = 0, HorizontalAlignment = Element.ALIGN_CENTER, FixedHeight = 75f }; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(string.Format("{0}", show.ShowName), bigFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(string.Format("{0:dd MMM yyyy}", showDetails.ShowDate), bigFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.FixedHeight = 75f; ptable.AddCell(cell); doc.Add(ptable); ptable = new PdfPTable(new float[] { 50, 25, 400, 100 }); DataSet classesDS = Rings.GetClassesForRing(ring.ID); classesDS = judge.getClassesForJudge(); cell = new PdfPCell(new Phrase(new Chunk("Cls No", headerHFont))); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(""))); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Class Name", headerHFont))); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Dogs In Class", headerHFont))); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; ptable.AddCell(cell); if (classesDS.Tables.Count > 0) { foreach (DataRow classRow in classesDS.Tables[0].Rows) { var part = Convert.ToInt32(classRow["Part"]); cell = new PdfPCell(new Phrase(new Chunk( string.Format("{0}", classRow["ClsNo"]), bigFont))); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(""))); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; ptable.AddCell(cell); int clsHeight = Convert.ToInt32(classRow["Height"]); var partstr = ""; if (Convert.ToInt32(classRow["EntryTypeID"]) == 10) { cell = new PdfPCell(new Phrase(new Chunk( string.Format("{0} {1} {2} {3}", ShowClasses.expandHeight(classRow), classRow["LongName"], classRow["Name"], ShowClasses.shortenGrades(classRow)) , bigSmallFont))); } else { partstr = (part > 0 ? " - Pt " + part : ""); if (clsHeight == 0) { cell = new PdfPCell(new Phrase(new Chunk( string.Format("{0} {1} {2}{3}", classRow["LongName"], classRow["Name"], ShowClasses.shortenGrades(classRow) , partstr) , bigSmallFont))); } else { cell = new PdfPCell(new Phrase(new Chunk( string.Format("{0} {1} {2} {3} {4}{5}", ShowClasses.expandHeight(classRow), ShowClasses.expandCatagory(classRow), classRow["LongName"], classRow["Name"], ShowClasses.shortenGrades(classRow), partstr) , bigSmallFont))); } } cell.Colspan = 1; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(string.Format("{0, 5}", Fpp.Core.Utils.CalcDogsInCalc(classRow)), bigFont))); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", bigFont))); cell.Colspan = 4; //cell.FixedHeight = 25f; cell.BorderWidth = 0; ptable.AddCell(cell); } doc.Add(ptable); } }
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 JsonResult DeleteJudge(int judgeId) { var j = new Judge(judgeId); j.Delete(); ShowClasses.deleteJudgeClasses(judgeId); ShowClasses.removeRingFromClasses(j.RingID); return Json(new { Status = 0, }); }
public JsonResult AddRingJudge(int RingId, int JudgeId, int RingOrder) { Judge j = new Judge(JudgeId); j.RingID = RingId; j.RingOrder = RingOrder; j.Save(); ShowClasses.SetClassesToRing(JudgeId, RingId); return Json(new { Status = 0, }); }
public JsonResult AddJudgeCls(int classId, int judgeId, int showDetailsId) { ShowClasses.updateJudgeClasses(classId, judgeId, showDetailsId); var j = new Judge(judgeId); var sc = new ShowClasses(classId) { RingID = j.RingID }; sc.Update(); return Json(new { Status = 0, JudgesList = Judge.GetAllJudgesForShow(j.ShowID) }); }
private String getEntrySummary(UserShows us) { Shows thisShow = new Shows(us.ShowID); UserDogDetails userDetails = new UserDogDetails(); Dogs dog = new Dogs(); userDetails.DogDetails = Dogs.GetAllDogsForHandler(us.Userid, thisShow.ShowDate); userDetails.UserDetails = new User(us.Userid); UserCamping userCamping = new UserCamping(us.ID); List<Business.Helpers> helpersList = Business.Helpers.HelperForShow(us.ShowID, us.Userid); List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(us.ShowID); String html = "<input type='hidden' name='showid' value='" + us.ShowID.ToString() + "' /><input type='hidden' name='userid' value='" + us.Userid.ToString() + "' /><div class='entryAdminLeft'>"; html += "<div id='showEntryDetails'><ul>"; html += "<li><a href='#showdetails'>Show Details</a></li>"; html += "<li><a href='#entrydetails'>Entry Details</a></li>"; if (userCamping.ID > -1) { html += "<li><a href='#campingdetails'>Camping Details</a></li>"; } if (helpersList.Count > 0) { html += "<li><a href='#helperdetails'>Helper Details</a></li>"; } html += "</ul>"; String schedule = "../Schedules/" + thisShow.ShowDate.ToString("yyyy") + "/"; String entryForm = schedule; String filename = thisShow.ShowName.Replace(' ', '_'); String fthing = thisShow.ShowDate.ToString("dd_yyyy"); schedule += filename + fthing + "Schedule.pdf"; entryForm += filename + fthing + "EntryForm.pdf"; html += "<div id='showdetails'>"; html += "<h2>" + thisShow.ShowName + "</h2>" + "<p>Start Date:" + thisShow.ShowDate.ToString("dd MMM yyyy") + "</p>" + "<p>Closing Date:" + thisShow.ClosingDate.ToString("dd MMM yyyy") + "</p>"; html += "<p>Venue:" + thisShow.Venue + "</p>" + "<p>" + thisShow.VenuePostcode + "(<a target='_blank' href='https://maps.google.co.uk/maps?q=" + thisShow.VenuePostcode + "'>map</a>)</p>"; var showDocs = ShowDocuments.getShowDocumentsFor(us.ShowID); foreach (var doc in showDocs) { html += string.Format("<div><a class='scheduleLocation' target='_blank' href='../Schedules/{2}/{1}'>{0}</a></div>", doc.Name, doc.Url, thisShow.ShowDate.ToString("yyyy")); } html += "</div>"; html += "<div id='entrydetails'>"; html += "<table class='dogsToEnter themeBorder'>"; html += "<tr><th class='dogName'>Dog Name</th><th class='classNos'>Classes</th>"; List<validClassesForDog> validDogClasses = new List<validClassesForDog>(); int dogCnt = 0; foreach (Dogs d in userDetails.DogDetails.Where(d => d.Grade > 0)) { validClassesForDog vc4d = new validClassesForDog(d.ID); validDogClasses.Add(vc4d); DogClasses dc = new DogClasses(d.ID, us.ShowID); dc.getDogsClasses(us.ShowID); String altBackground = "infoTextBackground"; if (dogCnt % 2 == 0) altBackground = "infoTextBackgroundAlt"; html += String.Format("<tr class='dogClass {4}' dogid='{0}' height='{3}' grade='{2}'><td valign='top'><div >{1}</div>{5}</td>", d.ID, d.KCName, d.Grade, d.Height, altBackground, (dc.Lho == 0 ? "": "**** Entered lower height option")); String classesEntered = ""; foreach (ShowClasses cls in classList) { int clsIndex = dc.Classlist.IndexOf(cls.ID); if (clsIndex > -1) { if (classesEntered.Length > 0) { classesEntered += "<br>"; } if (dc.AltHandlerList[clsIndex] > 0) { classesEntered += String.Format("<span class='classNumber althandler' data-althandlerid='{1}'>{0}</span>", cls.ClassNo, dc.AltHandlerList[clsIndex]); } else { //classesEntered += String.Format("<span class='classNumber' style='padding:5px'>{0}</span>", cls.ClassNo); classesEntered += String.Format("<span class='classNumber' style='padding:5px'>{0}</span> {1} {2} {3} {4}", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.longCatagory, cls.getGrades); } } // // if veterans/anysize or anything that is valid for that dog, add to list; if (d.Grade == 99) { if (cls.EntryType == 2) { vc4d.addClassDetails(cls); } } else { if (cls.EntryType == 2 || (d.Height == cls.Height && cls.Grades.Contains(d.Grade.ToString()))) { vc4d.addClassDetails(cls); } } } dogCnt++; html += "<td class=''><div class='classNos'><div class='classContainer'>" + classesEntered + "</div></div></td></tr>"; } html += "</table>"; html += "</div>"; if (userCamping.ID > -1) { String[] campDays = userCamping.PitchDetails[0].CampingDays.Split(','); html += "<div id='campingdetails' class='infoText'>"; html += "<h2>Camping Days Booked</h2><ul>"; foreach (String cdays in campDays.Where(x => x.Length > 0)) { html += "<li>" + CampDateFormat(cdays) + "</li>"; } html += "</ul>"; html += "<p>No of pitches:<span style='color:#fff'>" + userCamping.PitchDetails.Count + "</span></p>"; html += "<p>Camping With:<span style='color:#fff'>" + userCamping.PitchDetails[0].PartyName + "</span></p>"; html += "<p>Special Requests:<span style='color:#fff'>" + userCamping.PitchDetails[0].Comments + "</span></p>"; html += "</div>"; } if (helpersList.Count > 0) { html += "<div id='helperdetails' class='infoText'>"; html += "<h2>Helping Details</h2>"; var helperComment = ""; foreach (Business.Helpers helper in helpersList) { String judge = ""; if (helper.JudgeID > -1) { Judge j = new Judge(helper.JudgeID); judge = "Judge: " + j.Name; } String ring = ""; if (helper.RingNo > 0) { ring = "Ring No:" + helper.RingNo.ToString(); } html += String.Format("<div >{0:ddd dd MMM} - {1} {2} {3}</div>", helper.HelpDate, helper.expandJob(), judge, ring); helperComment = helper.Comments; } if (helperComment.Length > 0) { html += string.Format("<p>{0}</p>", helperComment); } html += "</div>"; } html += "</div>"; return html; }