// retrieves all boards public ActionResult GetBoards() { Trello t = new Trello(); var result = t.GetBoards(); return(RedirectToAction("Trello")); }
/// <summary> /// Refreshes the boards list /// </summary> public void RefreshBoardsList() { // show progress bar refreshProgressBar(0f); // get all boards Board[] allBoards = trello.GetBoards(); // select only feedback boards boards = allBoards.Where(b => isFeedbackBoard(b)).ToArray(); // set selected index to current board from config bool foundCurrentBoard = false; for (int i = 0; i < boards.Length; i++) { if (boards[i].id == config.Board.Id) { foundCurrentBoard = true; selectedBoard = i; } } // reset selected board index if it no longer exists on the list if (!foundCurrentBoard) { selectedBoard = 0; } // update progress bars refreshProgressBar(0.8f); // update subscribed check for current board if (boards.Length > 0) { updateSubscribed(); } // clear progress bar EditorUtility.ClearProgressBar(); }
// Email end of day report to management public ActionResult EmailEndOfDayReport(bool isTest = false) { Sb.Clear(); // pull the day's reports and compile into one report var todaysReports = db.tb_Reports.Where(m => System.Data.Entity.DbFunctions.TruncateTime(m.TimeSubmitted) == System.Data.Entity.DbFunctions.TruncateTime(DateTime.Now)); foreach (var rec in todaysReports) { // add each tech report var rep = rec.Report; Sb.Append(rep + "<br/>"); } //collect records var lscCheckouts = db.tb_CSUCheckoutCheckin.Where(m => m.CheckoutDate.Value.Day == DateTime.Now.Day && m.CheckoutLocationFK == "LSC"); var bsbCheckouts = db.tb_CSUCheckoutCheckin.Where(m => m.CheckoutDate.Value.Day == DateTime.Now.Day && m.CheckoutLocationFK == "BSB"); //var tltCheckouts = db.tb_CSUCheckoutCheckin.Where(m => m.CheckoutDate.Value.Day == DateTime.Now.Day && m.CheckoutLocationFK == "TLT"); var checkoutRecords = db.tb_CSUCheckoutCheckin.Where(m => m.CheckinDate == null && m.isLongterm != true); var longtermRecords = db.tb_CSUCheckoutCheckin.Where(m => m.CheckinDate == null && m.isLongterm == true); var lscUniqueIds = new List <string>(); foreach (var rec in lscCheckouts) { if (!lscUniqueIds.Contains(rec.CSU_IDFK)) { lscUniqueIds.Add(rec.CSU_IDFK); } } var bsbUniqueIds = new List <string>(); foreach (var rec in bsbCheckouts) { if (!bsbUniqueIds.Contains(rec.CSU_IDFK)) { bsbUniqueIds.Add(rec.CSU_IDFK); } } Sb.Append("</div><div><h3> # of Checkouts </h3>" + "<li>LSC Total Checkouts: " + lscCheckouts.Count() + " (" + lscUniqueIds.Count() + " unique students)</li>" + "<li>BSB Total Checkouts: " + bsbCheckouts.Count() + " (" + bsbUniqueIds.Count() + " unique students)</li>"); // create html table of items not checked in when report is run, filter by location and longterm Sb.Append("<h1>LSC Items not returned </h1><table border='1px' WIDTH='50%' CELLPADDING='4' CELLSPACING='3' bordercolor='red'> <thead> <tr> <th>First Name</th>" + "<th>Last Name</th>" + "<th>CSU ID</th>" + "<th>Item</th>" + "<th>Checkout Date</th><th>Due Date</th> </tr> </thead> <tbody>"); foreach (var rec in checkoutRecords.Where(m => m.CheckoutLocationFK == "LSC")) { CsuStudent = db.tb_CSUStudent.FirstOrDefault(m => m.CSU_ID == rec.CSU_IDFK); if (CsuStudent == null) { continue; } var name = "<tr><td>" + CsuStudent.FIRST_NAME + " </td><td> " + CsuStudent.LAST_NAME + "</td><td>" + rec.CSU_IDFK + " </td><td> " + rec.ItemUPCFK + "</td><td>" + rec.CheckoutDate + "</td><td>" + rec.DueDate + " </td></tr> "; Sb.Append(name); } Sb.Append("<tr> <tbody> </table>"); Sb.Append("<h1>BSB Items not returned </h1><table border='1px' WIDTH='50%' CELLPADDING='4' CELLSPACING='3' bordercolor='red'> <thead> <tr> <th>First Name</th>" + "<th>Last Name</th>" + "<th>CSU ID</th>" + "<th>Item</th>" + "<th>Checkout Date</th><th>Due Date</th> </tr> </thead> <tbody>"); foreach (var rec in checkoutRecords.Where(m => m.CheckoutLocationFK == "BSB")) { CsuStudent = db.tb_CSUStudent.FirstOrDefault(m => m.CSU_ID == rec.CSU_IDFK); if (CsuStudent == null) { continue; } var name = "<tr><td>" + CsuStudent.FIRST_NAME + " </td><td> " + CsuStudent.LAST_NAME + "</td><td>" + rec.CSU_IDFK + " </td><td> " + rec.ItemUPCFK + "</td><td>" + rec.CheckoutDate + "</td><td>" + rec.DueDate + " </td></tr> "; Sb.Append(name); } Sb.Append("<tr> <tbody> </table>"); Sb.Append("<h1> Items in Longterm </h1><table border='1px' WIDTH='50%' CELLPADDING='4' CELLSPACING='3'> <thead> <tr> <th>First Name</th>" + "<th>Last Name</th>" + "<th>CSU ID</th>" + "<th>Item</th>" + "<th>Checkout Date</th> <th>Due Date</th> </tr> </thead> <tbody> "); foreach (var rec in longtermRecords) { CsuStudent = db.tb_CSUStudent.FirstOrDefault(m => m.CSU_ID == rec.CSU_IDFK); if (CsuStudent == null) { continue; } var name = "<tr><td>" + CsuStudent.FIRST_NAME + " </td><td> " + CsuStudent.LAST_NAME + "</td><td>" + rec.CSU_IDFK + " </td><td> " + rec.ItemUPCFK + "</td><td>" + rec.CheckoutDate + "</td><td>" + rec.DueDate + " </td></tr> "; Sb.Append(name); } Sb.Append("<tr> <tbody> </table>"); // retrieve open repairs and recently completed repairs Trello t = new Trello(); var cards = t.GetCards("notset"); List <Trello.Card> openRepairs = new List <Trello.Card>(); List <Trello.Card> recentlyClosedRepairs = new List <Trello.Card>(); foreach (var card in cards) { if (card.dueComplete == false && card.due != null && !card.name.StartsWith("test")) { openRepairs.Add(card); } else if (card.dueComplete == true && (DateTime.Now < Convert.ToDateTime(card.dateLastActivity).AddHours(24)) && !card.name.StartsWith("test")) { recentlyClosedRepairs.Add(card); } } // add open repairs to report Sb.Append("<h1> Open Repairs </h1><table border='1px' WIDTH='50%' CELLPADDING='4' CELLSPACING='3'> <thead> <tr> <th>Item UPC</th>" + "<th>Repair Request Date</th>" + "<th>Issue</th>" + "<th>Location</th>" + " <th>Due Date</th> </tr> </thead> <tbody> "); foreach (var repair in openRepairs) { var requestDate = t.GetChecklists(repair.id).First().name; var comments = t.GetCardComments(repair.id); string issue = ""; foreach (var comment in comments) { if (Convert.ToDateTime(requestDate) <= Convert.ToDateTime(comment.date)) { issue += "<p>" + comment.text + "</p>"; } } var location = t.GetBoards().Where(m => m.id == repair.idBoard).FirstOrDefault().name; var due = Convert.ToDateTime(repair.due).Date; var row = "<tr><td>" + repair.name + " </td><td> " + requestDate + "</td><td>" + issue + " </td><td> " + location + "</td><td>" + due.ToString() + "</td></tr> "; Sb.Append(row); } Sb.Append("<tr> <tbody> </table>"); if (openRepairs.Count() == 0) { Sb.Append("<p>There are no open repairs.</p>"); } // add recently closed repairs to report Sb.Append("<h1> Completed Repairs </h1><table border='1px' WIDTH='50%' CELLPADDING='4' CELLSPACING='3'> <thead> <tr> <th>Item UPC</th>" + "<th>Repair Request Date</th>" + "<th>Issue</th>" + "<th>Location</th>" + "</tr> </thead> <tbody> "); foreach (var repair in recentlyClosedRepairs) { var requestDate = t.GetChecklists(repair.id).First().name; var comments = t.GetCardComments(repair.id); string issue = ""; foreach (var comment in comments) { if (Convert.ToDateTime(requestDate) <= Convert.ToDateTime(comment.date)) { issue += "<p>" + comment.text + "</p>"; } } var location = t.GetBoards().Where(m => m.id == repair.idBoard).FirstOrDefault().name; var row = "<tr><td>" + repair.name + " </td><td> " + requestDate + "</td><td>" + issue + " </td><td> " + location + "</td></tr> "; Sb.Append(row); } Sb.Append("<tr> <tbody> </table>"); if (recentlyClosedRepairs.Count() == 0) { Sb.Append("<p>There were no repairs closed today.</p>"); } // convert StringBuilder to string var compiledReport = Sb.ToString(); // email compiled report to management (note: will be routed to current user's email if isTest==true) email.EndOfDayReport(compiledReport, isTest); ViewBag.Message = "Email Sent!"; return(View()); }
// GET: tb_ItemRepair public ActionResult Index() { // get active repairs for current location Trello t = new Trello(); var cards = new List <Trello.Card>(); cards = t.GetCards(SessionVariables.CurrentLocation.ToString()); // populate a view model by inserting cards List <RepairStatusView> view = new List <RepairStatusView>(); // compile list of cards with active due date, sort by date due foreach (var card in cards) { if (card.due != null && card.dueComplete == false) { RepairStatusView repair = new RepairStatusView(); repair.ItemUpc = card.name; var checklists = t.GetChecklists(card.id); //repair.Checklist = checklists.First().checkItems; var checklist = checklists.Last().checkItems; repair.Checklist = new List <Models.Trello.CheckItemView>(); foreach (var checkitem in checklist) { Trello.CheckItemView civ = new Models.Trello.CheckItemView(); civ.id = checkitem.id; civ.name = checkitem.name; civ.nameData = checkitem.nameData; civ.pos = checkitem.pos; civ.idChecklist = checkitem.idChecklist; if (checkitem.state == "complete") { civ.state = true; } else { civ.state = false; } repair.Checklist.Add(civ); } repair.RequestDate = checklists.Last().name; repair.DueDate = Convert.ToDateTime(card.due).Date; foreach (var b in t.GetBoards()) { if (b.id == card.idBoard) { repair.ItemLocation = b.name; } } var comments = t.GetCardComments(card.id); if (repair.Comments == null) { repair.Comments = new List <Models.Trello.Comment>(); } foreach (var comment in comments) { if (Convert.ToDateTime(repair.RequestDate) <= Convert.ToDateTime(comment.date) && !comment.text.StartsWith("CLOSED")) { repair.Comments.Add(comment); } } view.Add(repair); } } if (TempData["message"] != null) { ViewBag.Message = TempData["message"]; } return(View(view)); }