public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data) { var kbp = new KanbanItemProperty { Name = property.Name }; SetColor(kbp, setting.Color); JObject jObj = JObject.FromObject(task); string uid = JTokenHelper.GetPropertyValue <string>(jObj, property.Key); if (!string.IsNullOrEmpty(uid)) { var avatar = AvatarHelper.GetAvatar(uid, AvatarSize.X40); if (property.RawKey == "assignee") { kanban.Due = avatar; } else { kbp.Value = avatar.DisplayName; kanban.Properties.Add(kbp); } } }
public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data) { JObject jObj = JObject.FromObject(task); string[] files = JTokenHelper.GetPropertyValue <string[]>(jObj, property.Key); kanban.AttachmentCount = files.Length; }
public string GetKanban(string channelName) { var mappings = RallyBackgroundData.Instance.RallySlackMappings; var map = mappings.Find(o => o.Channels.Contains(channelName.ToLower())); if (map == null) { throw new ObjectNotFoundException("Cannot found channel name mapping for " + channelName); } var result = _rallyService.GetKanban(map); var list = result; if (list == null) { return(null); } //requestFields = new List<string>() //{ // "Name", // "ObjectID", // "FormattedID", // "Description", // "ScheduleState", // "Owner" //}; var kanbanGroup = list.Select(o => KanbanItem.ConvertFrom(o, map.KanbanSortColumn)).Cast <KanbanItem>().GroupBy(k => k.KanbanState).ToDictionary(k => k.Key, o => o.OrderBy(t => t.AssignedTo).ToList()); Image img = _graphicService.DrawWholeKanban(500, 20, 20, 20, 100, kanbanGroup); var uploaded = _azureService.Upload(img, string.Format("{0}-kanban", channelName)); return(uploaded); }
public async Task <IActionResult> UpdateItem(int itemId, [Bind("Id,Title,KanbanColumnId")] KanbanItem kanbanItem) { if (itemId != kanbanItem.Id) { return(NotFound()); } if (ModelState.IsValid) { try { await _repos.UpdateItem(kanbanItem); } catch (DbUpdateConcurrencyException) { if (!KanbanItemExists(kanbanItem.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(kanbanItem)); }
public ActionResult DeleteConfirmed(int id) { KanbanItem kanbanItem = db.KanbanItems.Find(id); db.KanbanItems.Remove(kanbanItem); db.SaveChanges(); return(RedirectToAction("Index")); }
public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data) { kanban.State = new Models.TaskState { Name = state.Name, Foreground = WtColorHelper.GetNewColor(state.Color), BoldGlyph = WtIconHelper.GetBoldGlyph(state.Type) }; }
public IActionResult DeleteItem(int itemId) { KanbanItem kanbanItem = _context.KanbanItems.Find(itemId); if (kanbanItem == null) { return(NotFound()); } return(View(kanbanItem)); }
public IActionResult AddItem(KanbanItem item) { if (ModelState.IsValid) { _repos.AddItem(item); return(RedirectToAction(nameof(Index))); } return(RedirectToAction(nameof(AddItem))); }
public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data) { JObject jObj = JObject.FromObject(task); var value = JTokenHelper.GetPropertyValue <string>(jObj, property.Key); if (value != null) { var priority = data.Data.References.Lookups.Priorities.Single(p => p.Id == value); kanban.Priority = WtColorHelper.GetNewBrush(priority.Color); } }
public ActionResult Edit([Bind(Include = "ID,Description,DateCreated,ColumnID,Critical,BoardID")] KanbanItem kanbanItem) { if (ModelState.IsValid) { db.Entry(kanbanItem).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BoardID = new SelectList(db.KanbanBoards, "ID", "Description", kanbanItem.BoardID); return(View(kanbanItem)); }
public async Task <int> UpdateItem(KanbanItem item) { _context.Update(item); if (item.KanbanColumnId == (int)Column.Done) { var teamMembers = await FetchTeamMembersAsync(); List <string> emails = teamMembers.Select(user => user.Email).ToList(); SendEmails(emails, item); } return(await _context.SaveChangesAsync()); }
public async Task AddItemAsync(int boardId, string name, int columnId) { var newItem = new KanbanItem { Name = name, Index = GetNextItemIndex(columnId), ColumnID = columnId, }; _dbContext.KanbanItems.Add(newItem); await _dbContext.SaveChangesAsync(); }
public void DrawKanbanItemFrameNonBlockedTest() { GraphicService service = new GraphicService(); KanbanItem item = new KanbanItem("C1", "US4321", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxddsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas"); var rec = service.GetKanbanItemSize(new Point(0, 0), 400, 20, 20, item); Image image = new Bitmap(rec.Width, rec.Height); using (var g = Graphics.FromImage(image)) { service.DrawOneKanbanItem(g, new Point(0, 0), 400, 20, 20, item); image.Save(@"c:\temp\pngTempNonBlocked.png", ImageFormat.Png); } }
// GET: KanbanItems/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } KanbanItem kanbanItem = db.KanbanItems.Find(id); if (kanbanItem == null) { return(HttpNotFound()); } return(View(kanbanItem)); }
// GET: KanbanItems/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } KanbanItem kanbanItem = db.KanbanItems.Find(id); if (kanbanItem == null) { return(HttpNotFound()); } ViewBag.BoardID = new SelectList(db.KanbanBoards, "ID", "Description", kanbanItem.BoardID); return(View(kanbanItem)); }
public ActionResult Create([Bind(Include = "ID,Description,DateCreated,ColumnID,Critical,BoardID")] KanbanItem kanbanItem) { var dateTimeNow = DateTime.Now; kanbanItem.DateCreated = dateTimeNow.Date; if (ModelState.IsValid) { db.KanbanItems.Add(kanbanItem); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BoardID = new SelectList(db.KanbanBoards, "ID", "Description", kanbanItem.BoardID); return(View(kanbanItem)); }
public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data) { var kbp = new KanbanItemProperty { Name = "实际工时" }; SetColor(kbp, setting.Color); JObject jObj = JObject.FromObject(task); var workload = JTokenHelper.GetPropertyValue <WorkloadValue>(jObj, property.Key); if (workload.Actual != 0) { kbp.Value = workload.Actual.ToString(); kanban.Properties.Add(kbp); } }
public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data) { JObject jObj = JObject.FromObject(task); string[] tagIds = JTokenHelper.GetPropertyValue <string[]>(jObj, property.Key); if (tagIds.Length > 0) { foreach (var id in tagIds) { var tag = data.Data.References.Lookups.Tags.Single(t => t.Id == id); var kbp = new KanbanItemProperty { Value = tag.Name, Foreground = new SolidColorBrush(Colors.White), Background = WtColorHelper.GetNewBrush(tag.Color) }; kanban.Properties.Add(kbp); } } }
public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data) { var kbp = new KanbanItemProperty { Name = property.Name }; SetColor(kbp, setting.Color); JObject jObj = JObject.FromObject(task); var span = JTokenHelper.GetPropertyValue <DateSpan>(jObj, property.Key); if (span.Begin.Date.HasValue && span.End.Date.HasValue) { kbp.Value = WtDateTimeHelper.ToWtKanbanDate(span.Begin.Date.Value) + " ~ " + WtDateTimeHelper.ToWtKanbanDate(span.End.Date.Value); kanban.Properties.Add(kbp); } }
public bool DeleteItem(int itemId) { try { KanbanItem itemToDelete = _context.KanbanItems.Find(itemId); if (itemToDelete is null) { return(false); } _context.KanbanItems.Remove(itemToDelete); _context.SaveChanges(); } catch (Exception e) { _logger.LogError($"{e.Source}: {e.Message}"); Console.WriteLine("Error in DeleteItem: " + e.Message); return(false); } return(true); }
public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data) { if (property.RawKey == "title") { kanban.Title = task.Title; } else { JObject jObj = JObject.FromObject(task); string value = JTokenHelper.GetPropertyValue <string>(jObj, property.Key); if (value != null) { var kbp = new KanbanItemProperty { Name = property.Name, Value = value }; SetColor(kbp, setting.Color); kanban.Properties.Add(kbp); } } }
public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data) { var kbp = new KanbanItemProperty { Name = property.Name }; SetColor(kbp, setting.Color); JObject jObj = JObject.FromObject(task); string value = JTokenHelper.GetPropertyValue <string>(jObj, property.Key); if (value != null) { if (property.Lookup == null) { kbp.Value = value; } else { JObject lookup = JObject.FromObject(data.Data.References.Lookups); var jItem = lookup[property.Lookup].Single(item => item["_id"].Value <string>() == value); if (jItem is JObject obj) { if (obj.ContainsKey("name")) { kbp.Value = jItem["name"].Value <string>(); kanban.Properties.Add(kbp); } else if (obj.ContainsKey("text")) { kbp.Value = jItem["text"].Value <string>(); kanban.Properties.Add(kbp); } } } } }
public void DrawOneKanbanColumnTest() { GraphicService service = new GraphicService(); KanbanItem item0 = new KanbanItem("C1", "US4321", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxddsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas"); KanbanItem item1 = new KanbanItem("C1", "US4321", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxddsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas", "BLOCKED BLOCKED BLOCKED BBBBBBBB"); //KanbanItem item2 = new KanbanItem("US4321", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxddsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas"); //KanbanItem item3 = new KanbanItem("US4321", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxddsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas"); //KanbanItem item4 = new KanbanItem("US4321", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxddsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas"); //KanbanItem item5 = new KanbanItem("US4321", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxddsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas"); //KanbanItem item6 = new KanbanItem("US4321", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxddsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas"); List <KanbanItem> items = new List <KanbanItem>() { item0, item1 }; var rec = service.GetOneKanbanColumnSize(new Point(0, 0), 400, 20, 50, 20, 100, items); Image image = new Bitmap(rec.Width, rec.Height); using (var g = Graphics.FromImage(image)) { service.DrawOneKanbanColumn(g, new Point(0, 0), 400, 20, 50, 20, "Development", 100, items); image.Save(@"c:\temp\pngTempOneColumn.png", ImageFormat.Png); } }
public override void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data) { var kbp = new KanbanItemProperty { Name = property.Name }; SetColor(kbp, setting.Color); JObject jObj = JObject.FromObject(task); WtDate date = null; if (property.Key.Count(k => k == '.') > 0) { date = JTokenHelper.GetPropertyValue <WtDate>(jObj, property.Key); } else { date = new WtDate(); string timestamp = jObj[property.Key].Value <string>(); if (timestamp != null) { date.Date = WtDateTimeHelper.GetDateTime(timestamp); } } if (date.Date.HasValue) { kbp.Value = date.Date.Value.ToWtKanbanDate(); if (property.RawKey == "due" && date.Date.Value < DateTime.Now) { kbp.Foreground = WtColorHelper.DangerColor; kbp.Background = WtColorHelper.DangerColor1A; } kanban.Properties.Add(kbp); } }
public void DrawWholeKanbanTest() { GraphicService service = new GraphicService(); KanbanItem item0 = new KanbanItem("C1", "US1234", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxddsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas"); KanbanItem item1 = new KanbanItem("C1", "DE4321", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxddsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas", "BLOCKED BLOCKED BLOCKED BBBBBBBB"); KanbanItem item2 = new KanbanItem("C2", "US4321", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxddsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas"); KanbanItem item3 = new KanbanItem("C2", "US4321", "Cheng Huang", "aabbccddxxxxxxxxxxxefadsfasefaefasdfsdfsafas"); KanbanItem item4 = new KanbanItem("C3", "US22221", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxdsdfgsdfgsfgsdsssseeqqzxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas"); KanbanItem item5 = new KanbanItem("C4", "US4321", "Cheng Huang", "aabbccddxxxxxxxxxxxxxxxxxxxxxxxxxbbbbdeevsdfaefefadsfasefaefasdfsdfsafas"); KanbanItem item6 = new KanbanItem("C4", "US4321", "Cheng Huang", "aabbccfaefasdfsdfsafas", "abeedde"); List <KanbanItem> itemg1 = new List <KanbanItem>() { item0, item1 }; List <KanbanItem> itemg2 = new List <KanbanItem>() { item2, item3, item0, item5 }; List <KanbanItem> itemg3 = new List <KanbanItem>() { item4 }; List <KanbanItem> itemg4 = new List <KanbanItem>() { item5, item6 }; Dictionary <string, List <KanbanItem> > dict = new Dictionary <string, List <KanbanItem> >(); dict.Add("C1", itemg1); dict.Add("C2", itemg2); dict.Add("C3", itemg3); dict.Add("C4", itemg4); Image img = service.DrawWholeKanban(400, 20, 50, 20, 100, dict); img.Save(@"c:\temp\pngTempWholeKanban.png", ImageFormat.Png); }
public Rectangle GetKanbanItemSize(Point startPoint, int recWidth, int headerHeight, int textMargin, KanbanItem item) { Image img = new Bitmap(1, 1); using (var g = Graphics.FromImage(img)) { float currentHeight = 0; var halfMargin = textMargin / 2; Rectangle headerRec = new Rectangle(new Point(startPoint.X, startPoint.Y), new Size(recWidth + 1, headerHeight)); Font font = new Font("Segoe UI", 20, FontStyle.Regular); currentHeight += headerRec.Bottom + halfMargin; var formattedIdSize = g.MeasureString(item.FormattedId, font); var assignedToSize = g.MeasureString(item.AssignedTo, font); var descriptionSize = g.MeasureString(item.StoryDescription, font, headerRec.Width - 2 * textMargin); RectangleF recDescription = new RectangleF(new PointF(headerRec.Left + textMargin, currentHeight + textMargin), descriptionSize); currentHeight += formattedIdSize.Height + textMargin; currentHeight += assignedToSize.Height + textMargin; currentHeight += recDescription.Height + textMargin; if (item.IsBlocked) { Image blockedIcon = Resources.blocked; var blockedReasonSize = g.MeasureString(item.BlockedReason, font, headerRec.Width - 2 * textMargin - blockedIcon.Width - halfMargin); SizeF blockedReasonBackgroundSize = new SizeF(headerRec.Width - 2 * textMargin, blockedReasonSize.Height); currentHeight += blockedReasonBackgroundSize.Height + textMargin; } currentHeight += halfMargin; //currentBottom += halfMargin; //Frame, wire frame rectangle Rectangle recFrame = new Rectangle(startPoint, new Size(recWidth, (int)currentHeight)); return(recFrame); } }
public Rectangle DrawOneKanbanItem(Graphics g, Point startPoint, int recWidth, int headerHeight, int textMargin, KanbanItem item) { float currentHeight = 0; var halfMargin = textMargin / 2; //Header, solid rectangle Brush headerBrush = new SolidBrush(Color.DarkOrange); Rectangle headerRec = new Rectangle(new Point(startPoint.X, startPoint.Y), new Size(recWidth + 1, headerHeight)); Font font = new Font("Segoe UI", 20, FontStyle.Regular); Debug.WriteLine("Draw:currentHeight0:" + currentHeight); currentHeight = headerRec.Bottom + halfMargin; Debug.WriteLine("Draw:currentHeight1:" + currentHeight); //FormattedId Brush formattedIdBrush = new SolidBrush(Color.DeepSkyBlue); var formattedIdSize = g.MeasureString(item.FormattedId, font); g.DrawString(item.FormattedId, font, formattedIdBrush, headerRec.Left + textMargin, currentHeight); currentHeight += formattedIdSize.Height + textMargin; Debug.WriteLine("Draw:currentHeight2:" + currentHeight); //AssignedToId Brush assignedToBrush = new SolidBrush(Color.Black); var assignedToSize = g.MeasureString(item.AssignedTo, font); g.DrawString(item.AssignedTo, font, assignedToBrush, headerRec.Left + textMargin, currentHeight); currentHeight += assignedToSize.Height + textMargin; Debug.WriteLine("Draw:currentHeight3:" + currentHeight); //Description Brush descriptionBrush = new SolidBrush(Color.Black); var descriptionSize = g.MeasureString(item.StoryDescription, font, headerRec.Width - 2 * textMargin); RectangleF recDescription = new RectangleF(new PointF(headerRec.Left + textMargin, currentHeight), descriptionSize); g.DrawString(item.StoryDescription, font, descriptionBrush, recDescription); currentHeight += recDescription.Height + textMargin; Debug.WriteLine("Draw:currentHeight4:" + currentHeight); if (item.IsBlocked) { Image blockedIcon = Resources.blocked; var blockedReasonSize = g.MeasureString(item.BlockedReason, font, headerRec.Width - 2 * textMargin - blockedIcon.Width - halfMargin); SizeF blockedReasonBackgroundSize = new SizeF(headerRec.Width - 2 * textMargin, blockedReasonSize.Height); Brush blockedReasonBackgroundBrush = new SolidBrush(Color.LightGray); g.FillRectangle(blockedReasonBackgroundBrush, new RectangleF(new PointF(headerRec.Left + textMargin, currentHeight), blockedReasonBackgroundSize)); Brush blockedReasonBrush = new SolidBrush(Color.Black); RectangleF recBlockedReason = new RectangleF(new PointF(headerRec.Left + blockedIcon.Width + textMargin + halfMargin, currentHeight), blockedReasonSize); g.DrawString(item.BlockedReason, font, blockedReasonBrush, recBlockedReason); RectangleF recBlockedIconSmall = new RectangleF(headerRec.Left + textMargin + halfMargin, currentHeight + recBlockedReason.Height / 2 - blockedIcon.Height / 2, blockedIcon.Width, blockedIcon.Height); g.DrawImage(blockedIcon, recBlockedIconSmall); currentHeight += blockedReasonBackgroundSize.Height + textMargin; } currentHeight += halfMargin; //Frame, wire frame rectangle Pen framePen = item.IsBlocked ? new Pen(Color.DarkRed, 2) : new Pen(Color.Gray, 2); //g.Clear(Color.White); Rectangle recFrame = new Rectangle(startPoint, new Size(recWidth, (int)currentHeight - startPoint.Y)); g.DrawRectangle(framePen, recFrame); g.FillRectangle(headerBrush, headerRec); return(recFrame); }
public abstract void Read(KanbanItem kanban, WtTaskProperty property, ValueElement task, TaskState state, ShowSetting setting, ApiMissionVnextKanbanContent data);
/// <summary> /// Sends emails to all users with the team or admin role. /// Used when a KanbanItem is moved to the Done column. /// </summary> /// <param name="emails">A list of all the recipents' email addresses.</param> /// <param name="item">The updated kanbanitem.</param> private void SendEmails(List <string> emails, KanbanItem item) { Task.Run(() => _emailSender.SendMailToMultipleAsync(emails, "KanbanItem moved to Done", $"{item.Title} was moved to done column.")); }
public int AddItem(KanbanItem item) { _context.Add(item); return(_context.SaveChanges()); }