public string Create(int boardId, int listId, string name, string description = "", DateTime?dateDue = null, string colors = "") { if (!User.CheckSecurity(boardId)) { return(AccessDenied()); } Query.Models.Card card; try { card = Common.Platform.Cards.Create(boardId, listId, name, description, dateDue, colors); }catch (ServiceErrorException ex) { return(Error(ex.Message)); } //load Card html try { var boards = new Query.Boards(); var board = boards.GetDetails(boardId); card.boardType = board.type; return(GetCard(boardId, card)); } catch (ServiceErrorException ex) { return(Error(ex.Message)); } }
public static string Details(int boardId) { Server Server = Server.Instance; var query = new Query.Boards(); try { var board = query.GetDetails(boardId); return(Serializer.WriteObjectToString( new Dictionary <string, Dictionary <string, string> >() { { "board", new Dictionary <string, string>() { { "name", board.name }, { "color", "#" + board.color }, { "teamId", board.teamId.ToString() } } } } )); } catch (Exception) { throw new ServiceErrorException("Error displaying board details"); } }
public static void Update(Datasilk.Request request, int boardId, string name, string color, int teamId) { Server Server = Server.Instance; var query = new Query.Boards(); //check if user has access to board if (!query.MemberExists(request.User.userId, boardId)) { throw new ServiceDeniedException(); } //finally, update board try { query.UpdateBoard(new Query.Models.Board() { name = name, boardId = boardId, color = color, teamId = teamId }); } catch (Exception) { throw new ServiceErrorException("Error updating existing board"); } }
public static int Create(Datasilk.Request request, string name, string color, int teamId) { Server Server = Server.Instance; var query = new Query.Boards(); try { var id = query.CreateBoard(new Query.Models.Board() { name = name, security = 1, color = color, teamId = teamId }, request.User.userId); //add board Id to user's permissions for boards request.User.boards.Add(id); request.User.Save(true); return(id); }catch (Exception) { throw new ServiceErrorException("Error creating new board"); } }
public string Create(int boardId, string name, int sort = 0) { //check security if (!User.CheckSecurity(boardId)) { return(AccessDenied()); } var boards = new Query.Boards(); var board = boards.GetDetails(boardId); int id; try { id = Common.Platform.Lists.Create(boardId, name, sort); }catch (ServiceErrorException ex) { return(Error(ex.Message)); } switch (board.type) { case 0: //Kanban; return(Common.Platform.List.Kanban.RenderList( new Query.Models.List() { boardId = boardId, name = name, sort = sort, listId = id }, new List <Query.Models.Card>() )); } return(Error()); }
public override string Render(string[] path, string body = "", object metadata = null) { if (User.userId == 0) { //load login page var page = new Login(context); return(page.Render(path)); } //load boards list var scaffold = new Scaffold("/Views/Boards/boards.html", Server.Scaffold); var query = new Query.Boards(); var boards = query.GetList(User.userId); var html = new StringBuilder(); var item = new Scaffold("/Views/Boards/list-item.html", Server.Scaffold); boards.ForEach((Query.Models.Board b) => { item.Data["favorite"] = b.favorite ? "1" : ""; item.Data["name"] = b.name; item.Data["color"] = "#" + b.color; item.Data["extra"] = b.favorite ? "fav" : ""; item.Data["id"] = b.boardId.ToString(); item.Data["type"] = b.type.ToString(); item.Data["url"] = Uri.EscapeUriString("/board/" + b.boardId + "/" + b.name.Replace(" ", "-").ToLower()); html.Append(item.Render()); }); scaffold.Data["list"] = html.ToString(); //load teams list var queryTeams = new Query.Teams(); var teams = queryTeams.GetList(User.userId); html = new StringBuilder(); teams.ForEach((Query.Models.Team t) => { html.Append("<option value=\"" + t.teamId + "\">" + t.name + "</option>\n"); }); scaffold.Data["team-options"] = html.ToString(); //load page resources AddScript("/js/dashboard.js"); AddCSS("/css/dashboard.css"); //load header LoadHeader(ref scaffold, false); //render page return(base.Render(path, scaffold.Render())); }
public override string Render(string[] path, string body = "", object metadata = null) { if (!CheckSecurity()) { return(AccessDenied()); } //check security if (context.Request.QueryString.Value.Contains("?upload")) { //uploaded json file var files = context.Request.Form.Files; if (files.Count > 0) { Models.Trello.Board board = null; try { var ms = new MemoryStream(); files[0].CopyTo(ms); ms.Position = 0; var sr = new StreamReader(ms); var txt = sr.ReadToEnd(); board = (Models.Trello.Board)Serializer.ReadObject(txt.ToString(), typeof(Models.Trello.Board)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (board != null) { //show success page in iframe var scaffold = new Scaffold("/Views/Import/Trello/success.html", Server.Scaffold); scaffold.Data["name"] = board.name; //import board var boards = new Query.Boards(); var lists = new Query.Lists(); var cards = new Query.Cards(); var merge = context.Request.QueryString.Value.Contains("merge"); var boardType = context.Request.Query.ContainsKey("type") ? int.Parse(context.Request.Query["type"]) : 0; var sort = 0; var sortCard = 0; var bgColor = board.prefs.backgroundColor != null ? board.prefs.backgroundColor : board.prefs.backgroundBottomColor; if (bgColor == null) { bgColor = board.prefs.backgroundTopColor; } var boardId = boards.Import(new Query.Models.Board() { name = board.name, archived = board.closed, color = bgColor, datecreated = board.actions.Last().date, lastmodified = board.dateLastActivity, ownerId = User.userId, favorite = board.pinned, security = (short)(board.prefs.permissionLevel == "private" ? 1 : 0), type = (Query.Models.Board.BoardType)boardType }, User.userId, merge); if (!Utility.Objects.IsEmpty(boardId)) { //import each list sort = 0; board.lists.ForEach((list) => { if (list.closed == false) { var listId = lists.Import(new Query.Models.List() { boardId = boardId, name = list.name, sort = sort }, merge); //import cards for each list sortCard = 0; board.cards.FindAll((c) => c.idList == list.id).ForEach((card) => { if (card.closed == false) { var cardDate = board.actions.FindLast((a) => a.data != null ? (a.data.card != null ? (a.data.card.id != null ? a.data.card.id == card.id : false) : false) : false); cards.Import(new Query.Models.Card() { boardId = boardId, archived = card.closed, colors = string.Join(",", card.labels.Select((a) => a.color).ToArray()), datecreated = cardDate != null ? cardDate.date : DateTime.Now, datedue = card.due, description = card.desc, listId = listId, name = card.name, sort = sortCard, type = 0 }, merge); //import checklists for each card sortCard++; } }); sort++; } }); } return(scaffold.Render()); } else { return("Could not parse json file correctly"); } } //show upload form in iframe return(Server.LoadFileFromCache("/Views/Import/Trello/trello.html")); } else { //show upload form in iframe return(Server.LoadFileFromCache("/Views/Import/Trello/trello.html")); } }
public static string RenderBoardsMenu(Datasilk.Request request) { Server Server = Server.Instance; var html = new StringBuilder(); var htm = new StringBuilder(); var section = new Scaffold("/Views/Boards/menu-section.html", Server.Scaffold); var item = new Scaffold("/Views/Boards/menu-item.html", Server.Scaffold); var query = new Query.Boards(); var boards = query.GetList(request.User.userId); var favs = boards.Where((a) => { return(a.favorite); }); var teams = boards.OrderBy((a) => { return(a.datecreated); }).Reverse().OrderBy((a) => { return(a.ownerId == request.User.userId); }); // Favorite Boards ////////////////////////////////////////// if (favs.Count() > 0) { section.Data["title"] = "Starred Boards"; section.Data["id"] = "favs"; section.Data["icon"] = "star-border-sm"; htm = new StringBuilder(); foreach (var fav in favs) { item.Data["id"] = fav.boardId.ToString(); item.Data["url"] = "/board/" + fav.boardId + "/" + fav.name.Replace(" ", "-").ToLower(); item.Data["color"] = "#" + fav.color; item.Data["title"] = fav.name; item.Data["owner"] = fav.ownerName; item.Data["star"] = fav.favorite ? "star" : "star-border"; htm.Append(item.Render()); } section.Data["items"] = htm.ToString(); html.Append(section.Render()); } // Team Boards ////////////////////////////////////////// if (teams.Count() > 0) { var teamId = 0; var isnewTeam = true; htm = new StringBuilder(); foreach (var team in teams) { if (team.teamId != teamId) { if (teamId > 0) { section.Data["items"] = htm.ToString(); html.Append(section.Render()); } isnewTeam = true; teamId = team.teamId; } if (isnewTeam == true) { section.Data["title"] = team.teamName; section.Data["id"] = "team" + team.teamId.ToString(); section.Data["icon"] = "user"; } item.Data["id"] = team.boardId.ToString(); item.Data["url"] = "/board/" + team.boardId + "/" + team.name.Replace(" ", "-").ToLower(); item.Data["color"] = "#" + team.color; item.Data["title"] = team.name; item.Data["owner"] = team.ownerName; item.Data["star"] = team.favorite ? "star" : "star-border"; htm.Append(item.Render()); } section.Data["items"] = htm.ToString(); html.Append(section.Render()); } // Team Boards (sort by user owned, then by date created) ///////// return(html.ToString()); }
public override string Render(string[] path, string body = "", object metadata = null) { //check security if (path.Length < 2) { return(Error()); } var boardId = int.Parse(path[1]); if (User.userId == 0) { return(AccessDenied(true, new Login(context))); } if (!User.CheckSecurity(boardId)) { return(AccessDenied(true, new Login(context))); } //add client-side dependencies AddScript("/js/views/board/board.js"); AddScript("/js/dashboard.js"); AddCSS("/css/dashboard.css"); var scaffold = new Scaffold("/Views/Board/board.html", Server.Scaffold); var query = new Query.Boards(); //load board details var colors = new Utility.Colors(); var board = query.GetBoardAndLists(boardId); BoardPage page; //add custom javascript for User Settings & Board info scripts.Append("<script language=\"javascript\">" + "S.board.id=" + board.boardId + ";" + (User.allColor ? "S.head.allColor();" : "") + "</script>"); //choose which Lists Type to render switch (board.type) { default: case Query.Models.Board.BoardType.kanban: //kanban page = new Kanban(context); break; } //dependancy injection page.board = board; //set background color of board scaffold.Data["color"] = "#" + board.color; scaffold.Data["color-dark"] = colors.ChangeHexBrightness(board.color, (float)-0.3); //transfer resources from page scripts.Append(page.scripts.ToString()); headCss.Append(page.headCss.ToString()); //render board lists scaffold.Data["content"] = page.Render(path); //load header LoadHeader(ref scaffold); return(base.Render(path, scaffold.Render())); }