예제 #1
0
        public CardsAggregationModel Aggregate(BoardList doneList, BoardList additionalDoneList = null)
        {
            if (additionalDoneList != null && !string.Equals(doneList.BoardId, additionalDoneList.BoardId))
            {
                throw new ArgumentException($"Both lists should be from single board! Observed boards ids: {doneList.BoardId}, {additionalDoneList.BoardId}.");
            }

            var additionalDoneListId = additionalDoneList?.Id;
            var cardIds = taskManagerClient.GetBoardLists(doneList.BoardId).Where(x => x.Id.Equals(doneList.Id) || (additionalDoneListId != null && x.Id.Equals(additionalDoneListId)))
                          .Select(l => l.Cards.Select(c => c.Id))
                          .SelectMany(i => i)
                          .ToArray();

            return(CardsAggregationModel.Create(cardIds.Select(cardId => cardStatsBuilder.Build(cardId)).ToArray()));
        }
예제 #2
0
        /// <summary>
        /// Creates a new board with BoardName and BoardNotes. Adds
        /// it to the database and collection
        /// </summary>
        public void CreateBoard()
        {
            BoardViewModel newBoard = new BoardViewModel
            {
                BoardName  = BoardName,
                BoardNotes = BoardNotes
            };

            // Add board to db and collection
            int newBoardId = DataProvider.AddBoard(BoardName, BoardNotes);

            newBoard.BoardId = newBoardId.ToString();
            newBoard.Tasks   = new ObservableCollection <CustomKanbanModel>();
            BoardList.Add(newBoard);
        }
        public BoardList ListBoard()
        {
            var model = new BoardList();

            foreach (var board in _dbContext.Boards)
            {
                model.Boards.Add(new BoardList.Board
                {
                    Id   = board.Id,
                    Name = string.IsNullOrEmpty(board.Name) ? string.Empty : board.Name
                });
            }

            return(model);
        }
예제 #4
0
        public BoardList GetListBoards()
        {
            var boardList = new BoardList();

            foreach (var dbBoard in _dbContext.Boards)
            {
                boardList.Boards.Add(new Board()
                {
                    Id    = dbBoard.Id,
                    Title = dbBoard.Title
                });
            }

            return(boardList);
        }
예제 #5
0
        public BoardList ListBoard()
        {
            var model = new BoardList();

            foreach (var board in _dbContext.Boards)
            {
                model.Boards.Add(new BoardList.Board
                {
                    Id    = board.Id,
                    Title = board.Title
                });
            }

            return(model);
        }
예제 #6
0
        public IActionResult Index()
        {
            var model = new BoardList();

            var board = new BoardList.Board();

            board.Title = "Jon's Board";
            model.Boards.Add(board);

            var anotherBoard = new BoardList.Board();

            anotherBoard.Title = "Another Board";
            model.Boards.Add(anotherBoard);

            return(View(model));
        }
예제 #7
0
        public BoardList ListBoards()
        {
            var boardVMs = boardContext.Boards.Select(b => new BoardList.Board()
            {
                Title = b.Title,
                Id    = b.Id
            }).ToList();


            var boardList = new BoardList()
            {
                Boards = boardVMs
            };

            return(boardList);
        }
예제 #8
0
        public async Task CreateList(string boardId, List list)
        {
            await context.Lists.InsertOneAsync(list);

            var boardList = new BoardList()
            {
                ListId       = list.ListId,
                ListTitle    = list.ListTitle,
                ListPosition = list.ListPosition,
                CreationDate = list.CreationDate
            };
            // var filter = Builders<Board>.Filter.Eq(c => c.BoardId, list.BoardId);
            // var update = Builders<Board>.Update.Push(c => c.BoardLists, boardList);
            //var updateBoard = context.Boards.FindOneAndUpdateAsync(filter, update);
            //await updateBoard;
        }
예제 #9
0
 private void OnItemInvoked(WinUI.NavigationView sender, WinUI.NavigationViewItemInvokedEventArgs args)
 {
     if (args.IsSettingsInvoked)
     {
         SelectedBoard = null;
         NavigationService.Navigate(typeof(SettingsPage));
     }
     else
     {
         // For some reason if the Board is already selected and select it again the InvokedItem is null.
         if (args.InvokedItem != null)
         {
             // Get the selected Board in the BoardList and then send it over to the BoardPage for display
             SelectedBoard = BoardList.Where(b => b.BoardName == (string)args.InvokedItem).FirstOrDefault();
             NavigationService.Navigate(typeof(BoardPage), SelectedBoard.TaskList);
         }
     }
 }
예제 #10
0
        public async Task <IActionResult> Index()
        {
            string id = _accessor.HttpContext.Session.GetString("id");

            var model = await _boardService.GetBoardsByAppUserId(Convert.ToInt32(id));

            List <BoardList> boardList = new List <BoardList>();

            foreach (var item in model)
            {
                BoardList board = new BoardList {
                    Id    = item.Id,
                    Title = item.Title
                };
                boardList.Add(board);
            }
            return(View(boardList));
        }
예제 #11
0
파일: Model.cs 프로젝트: omgohmygod/MVC
        // load
        public void LoadData()
        {
            for (int i = 0; i < BUTTON; i++)
            {
                Board         _newBoard         = new Board(BOARD_NAME + (i + 1), COUNT + (i + 1) + TYPE + BOARD_NAME, (i + 1) * COST * TWO);
                Core          _newCpu           = new Core(CORE_NAME + (i + 1), COUNT + (i + 1) + TYPE + CORE_NAME, (i + 1) * COST * THREE);
                Disk          _newDisk          = new Disk(DISK_NAME + (i + 1), COUNT + (i + 1) + TYPE + DISK_NAME, (i + 1) * COST);
                Memory        _newMemory        = new Memory(MEMORY_NAME + (i + 1), COUNT + (i + 1) + TYPE + MEMORY_NAME, (i + 1) * COST);
                DisplayCard   _newDisplayCard   = new DisplayCard(CARD_NAME + (i + 1), COUNT + (i + 1) + TYPE + CARD_NAME, (i + 1) * COST * FOUR);
                ComboComputer _newComboComputer = new ComboComputer(COMPUTER_NAME + (i + 1), COUNT + (i + 1) + TYPE + COMPUTER_NAME, (i + 1) * COST * FIVE);

                BoardList.Add(_newBoard);
                CoreList.Add(_newCpu);
                DiskList.Add(_newDisk);
                MemoryList.Add(_newMemory);
                DisplayCardList.Add(_newDisplayCard);
                ComboComputerList.Add(_newComboComputer);
            }
        }
예제 #12
0
        private async Task <IEnumerable <Board> > GetMyBoards(uint startIndex, int page)
        {
            if (isLoadingBoards || this.Context.User == null)
            {
                return(new List <Board>());
            }

            try
            {
                isLoadingBoards = true;
                string urlname = !string.IsNullOrEmpty(this.Context.User.urlname) ? this.Context.User.urlname : this.Context.User.user_id;

                var query = "?limit=20";
                var max   = GetMaxKeyId();
                if (max > 0)
                {
                    query += $"&max={max}";
                }

                var collection = await httpHelper.GetAsync <BoardCollection>($"{urlname}/boards/{query}");

                var result = collection.Boards;

                if (result.Count() == 0)
                {
                    BoardList.NoMore();
                }
                else
                {
                    BoardList.HasMore();
                }

                return(result);
            }
            catch { }
            finally
            {
                isLoadingBoards = false;
            }
            return(null);
        }
예제 #13
0
        /// <summary>
        /// LIST호출
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public ActionResult List(int page = 1)
        {
            //받을 객체생성
            BoardList list = new BoardList();

            //객체 JSON받아오기
            try
            {
                HttpWebRequest  objWRequest  = (HttpWebRequest)System.Net.WebRequest.Create("http://exerciseCrud.com/Exercise/List/" + page);
                HttpWebResponse objWResponse = (HttpWebResponse)objWRequest.GetResponse();
                Stream          stream       = objWResponse.GetResponseStream();
                StreamReader    reader       = new StreamReader(stream);
                string          result       = reader.ReadToEnd();
                stream.Close();
                objWResponse.Close();
                //역직렬화
                list = JsonConvert.DeserializeObject <BoardList>(result);
            }
            catch (Exception) {}
            ViewBag.page = page;
            return(View(list));
        }
예제 #14
0
        public ActionResult BoardWrite(BoardList doc, int?idx, int?cate)
        {
            if (idx != null)
            {
                //수정모드
                doc = db.BoardList.Find(idx);

                var _list = (from a in db.BoardFile where a.Md_id == doc.fileId && a.use_yn != "N" select a).OrderByDescending(p => p.id).ToList();

                ViewBag.이미지리스트    = _list;
                ViewBag.이미지리스트카운트 = _list.Count();
            }
            else
            {
                ViewBag.이미지리스트    = "";
                ViewBag.이미지리스트카운트 = 0;
            }

            BoardAuth(idx, cate);

            return(View(doc));
        }
예제 #15
0
        public MainViewModel()
        {
            // Instantiate the collection object
            BoardList = DataProvider.GetBoards();

            if (BoardList.Count == 0)
            {
                // Create board
                BoardViewModel newBoard = new BoardViewModel
                {
                    BoardName = "New Board"
                };

                // Add to collection and db
                int newBoardId = DataProvider.AddBoard("New Board", "");
                newBoard.BoardId = newBoardId.ToString();
                newBoard.Tasks   = new ObservableCollection <CustomKanbanModel>();
                BoardList.Add(newBoard);
                Current = newBoard;
            }
            else
            {
                allTasks = new ObservableCollection <CustomKanbanModel>();
                allTasks = DataProvider.GetData();
                foreach (var board in BoardList)
                {
                    foreach (var task in allTasks)
                    {
                        if (task.BoardId == board.BoardId)
                        {
                            board.Tasks.Add(task);
                        }
                    }
                }

                Current = BoardList[0];
            }
        }
예제 #16
0
        public ActionResult del_set_check(BoardList doc, int file_idx)
        {
            BoardList _updateContent =
                (from a in db.BoardList where a.idx == doc.idx select a).Single();

            _updateContent.title    = doc.title;
            _updateContent.content  = doc.content;
            _updateContent.editDate = DateTime.Now;

            db.SaveChanges(); // 실제로 저장

            #region 삭제

            BoardFile _update =
                (from a in db.BoardFile where a.id == file_idx select a).Single();
            _update.use_yn = "N";

            db.SaveChanges(); // 실제로 저장

            #endregion

            return(Redirect("/board/BoardWrite?cate=" + doc.BM_idx + "&idx=" + doc.idx));
        }
예제 #17
0
        public void CreateBoard()
        {
            // Create board
            BoardViewModel newBoard = new BoardViewModel
            {
                BoardName  = BoardName,
                BoardNotes = BoardNotes
            };

            // Add board to db and collection
            int newBoardId = DataProvider.AddBoard(BoardName, BoardNotes);

            newBoard.BoardId = newBoardId.ToString();
            newBoard.Tasks   = new ObservableCollection <CustomKanbanModel>();
            foreach (var task in allTasks)
            {
                if (task.BoardId == newBoardId.ToString())
                {
                    newBoard.Tasks.Add(task);
                }
            }
            BoardList.Add(newBoard);
        }
        public BoardList ListBoard(double latitude, double langitude)
        {
            var model = new BoardList();

            foreach (var board in _dbContext.Boards)
            {
                var    sCoord = new GeoCoordinate(latitude, langitude);
                var    eCoord = new GeoCoordinate(Convert.ToDouble(board.Latitude), Convert.ToDouble(board.Longitude));
                double result = sCoord.GetDistanceTo(eCoord) / 1000;
                if (result < distance)
                {
                    model.Boards.Add(new BoardList.Board
                    {
                        Id        = board.Id,
                        Title     = string.IsNullOrEmpty(board.Title) ? string.Empty : board.Title,
                        Name      = string.IsNullOrEmpty(board.Name) ? string.Empty : board.Name,
                        Latitude  = board.Latitude == null ? 0 : board.Latitude,
                        Longitude = board.Longitude == null ? 0 : board.Longitude
                    });
                }
            }

            return(model);
        }
예제 #19
0
 public async Task ClearAndReload()
 {
     await BoardList.ClearAndReload();
 }
예제 #20
0
        public async Task <IActionResult> Board_action(BoardList doc, int?idx, int cate, string mode_type, List <IFormFile> files)
        {
            string file_id = "";
            string user_id = User.Identity.Name;
            string msg     = "";

            if (idx == null)
            {
                msg     = "입력";
                file_id = DateTime.Now.ToShortDateString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString();

                #region 저장
                doc.fileId    = file_id;
                doc.useable   = "Y";
                doc.writeDate = DateTime.Now;
                doc.editDate  = DateTime.Now;
                db.BoardList.Add(doc);
                db.SaveChanges(); // 실제로 저장


                #endregion
            }
            else
            {
                int _idx = Convert.ToInt32(idx);

                if (mode_type == "D")
                {
                    #region 삭제

                    msg = "삭제";
                    BoardList _update =
                        (from a in db.BoardList where a.idx == idx select a).Single();

                    _update.useable = "N";
                    _update.delDate = DateTime.Now;

                    db.SaveChanges(); // 실제로 저장

                    #endregion
                }
                else
                {
                    #region 수정
                    msg = "수정";
                    #region  일 아이디
                    file_id = doc.fileId;

                    if (string.IsNullOrEmpty(file_id))
                    {
                        file_id = user_id + DateTime.Now.ToShortDateString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString();

                        doc.fileId = file_id;
                    }
                    #endregion


                    doc.editDate        = DateTime.Now;
                    doc.writeDate       = DateTime.Now;
                    db.Entry(doc).State = EntityState.Modified;

                    //idx 제외 업데이트=================================
                    db.Entry(doc).Property("idx").IsModified = false;
                    //==================================================
                    db.SaveChanges();



                    #endregion
                }
            }

            #region  일 올리기


            var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
            Configuration = builder.Build();
            string Models_photo = Configuration["user_app:file_list_url"];
            string company_id   = UserData.user_get(user_id, "company_id");


            int s = 1;
            foreach (var formFile in files)
            {
                double file_size = formFile.Length;
                if (file_size < _fileSizeLimit)
                {
                    var formFileContent =
                        await FileHelpers
                        .ProcessFormFile <IFormFile>(
                            formFile, ModelState, _permittedExtensions,
                            _fileSizeLimit);



                    #region 변수
                    // 변수 =========================================================================================================================
                    string only = user_id + DateTime.Today.ToShortDateString().Replace("-", "") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString();
                    //  var trustedFileNameForFileStorage = Path.GetRandomFileName();   //랜덤이름

                    string file_ex = ""; // 확장자

                    try { file_ex = Path.GetFileName(formFile.FileName).Split('.').Last(); }
                    catch
                    {
                    }
                    var _fileName = only + "." + file_ex;     // 신규 파일 이름



                    var    _local_path      = _targetFilePath + company_id + "/";   // 신규 파일 경로
                    var    filePath         = Path.Combine(_local_path, _fileName); // 전체 경로
                    string desiredThumbPath = _local_path + "s/";                   // 작은 이미지 전체 경로

                    string ore_fileName = Path.GetFileName(formFile.FileName);
                    #endregion



                    //경로에 폴더가 없으면 만들어준다.=============================================
                    var dInfo   = new DirectoryInfo(_local_path);
                    var dInfo_s = new DirectoryInfo(desiredThumbPath);
                    if (!dInfo.Exists)
                    {
                        dInfo.Create();
                    }
                    if (!dInfo_s.Exists)
                    {
                        dInfo_s.Create();
                    }
                    //=================================================================================



                    using (var fileStream = System.IO.File.Create(filePath))
                    {
                        await fileStream.WriteAsync(formFileContent);
                    }

                    if (get_word.img_check(file_ex) == "img")
                    {
                        // 세로 기준
                        ResizeImage(desiredThumbPath, formFile, _fileName, 300, 0);
                    }



                    var _insert = new BoardFile()
                    {
                        Md_id      = file_id,
                        ImagePath  = Models_photo + company_id + "/" + _fileName,
                        fileName   = ore_fileName,
                        use_yn     = "Y",
                        file_ex    = file_ex,
                        file_size  = file_size,
                        r_date     = DateTime.Now,
                        write_id   = user_id,
                        sImagePath = Models_photo + company_id + "/s/" + _fileName,
                    };

                    db.BoardFile.Add(_insert);
                    db.SaveChanges();
                }

                s++;
            }


            #endregion

            //===============================================================================
            UserData history = new UserData();
            history.History_write(User.Identity.Name, "/board/boardwrite/cate=" + cate, msg);
            //==============================================================================

            string returnUrl = "/board/board_list?cate=" + cate;

            return(Redirect(returnUrl));
        }
예제 #21
0
        public ActionResult BoardView(int idx, int?cate)
        {
            if (idx == 0)
            {
                //0번 게시글은 임시글로써, DB에 존재하지 않는 글임
                return(NotFound());
            }

            //권한 시작==============================================================================================
            BoardAuth(idx, cate);
            //권한 끝================================================================================================

            BoardList data = db.BoardList.Find(idx);

            #region  일 가져오기
            //파일 가져오기=====================================================================================================================

            var _list = (from a in db.BoardFile where a.Md_id == data.fileId && a.use_yn != "N" select a).OrderByDescending(p => p.id).ToList();

            ViewBag.이미지리스트    = _list;
            ViewBag.이미지리스트카운트 = _list.Count();

            //파일 끝============================================================================================================================
            #endregion

            #region 조회수 증가

            data.hit = data.hit + 1;;

            db.SaveChanges(); // 실제로 저장


            #endregion

            #region 읽은 사용자 저장

            int _readCount = (from a in db.BoardRread where a.board_idx == idx && a.user_id == User.Identity.Name select a.idx).Count();

            if (_readCount == 0)
            {
                var _insert = new BoardRread
                {
                    user_id   = User.Identity.Name,
                    user_name = (from a in db.user where a.user_id == User.Identity.Name select a.user_name).FirstOrDefault(),
                    read_date = DateTime.Now,
                    board_idx = idx
                };

                db.BoardRread.Add(_insert);
                db.SaveChanges(); // 실제로 저장
            }


            var _read = (from a in db.BoardRread where a.board_idx == idx select a).ToList();

            ViewBag.읽은사람 = _read;

            #endregion

            #region 코멘트 가져오기

            IQueryable <BoardComment> _listComent = Enumerable.Empty <BoardComment>().AsQueryable();

            _listComent = db.BoardComment.Where(p => p.BD_idx == idx && p.use_yn == "Y").OrderByDescending(o => o.idx);

            ViewBag.댓글  = _listComent;
            ViewBag.댓글수 = _listComent.Count();
            #endregion

            return(View(data));
        }
예제 #22
0
 static public void ResetBoardManager()
 {
     boardList = new BoardList();
     boardInfo = new BoardInfo();
 }
예제 #23
0
        public IActionResult Index()
        {
            BoardList model = boardService.ListBoard();

            return(View(model));
        }
예제 #24
0
 /// <summary>
 /// Clears tasks collection and removes board from list.
 /// Then deletes the board and its tasks from the database
 /// </summary>
 /// <param name="currentBoard"></param>
 /// <returns>If deletion was successful</returns>
 internal bool DeleteBoard(BoardViewModel currentBoard)
 {
     currentBoard.Tasks.Clear();
     BoardList.Remove(currentBoard);
     return(DataProvider.DeleteBoard(currentBoard.BoardId));
 }
예제 #25
0
        private void Pack_recursive(PartList parts, BoardList boards, PartList TemporarySolution, double tempSolutionArea)
        {
            // loop through remaining parts
            for (PartNode iPart = parts.Tail; iPart != null; iPart = iPart.Prev)
            {
                #region // check if the part is a viable candidate ...
                // if this part has bigger area than the largest board segment available, go to next part
                if (iPart.Area > boards.Tail.Area)
                {
                    continue;
                }
                // if the previous part was the same size, pass this one - we already completed this iteration
                if (iPart != parts.Tail && iPart.Length == iPart.Next.Length && iPart.Width == iPart.Next.Width)
                {
                    continue;
                }
                #endregion

                #region // Find first board that will fit the part ...
                // find first board that will accomodate the part
                BoardNode iBoard = boards.Head;

                // if even the last (bigest) board had a smaller area than the part, non of the rest will fit
                while (iPart.Area > iBoard.Area)
                {
                    iBoard = iBoard.Next;
                }
                while (iBoard != null && (iPart.Length > iBoard.Length || iPart.Width > iBoard.Width))
                {
                    iBoard = iBoard.Next;
                }
                if (iBoard == null)
                {
                    continue; // if this part cannot fit any board, continue to next part
                }
                #endregion

                #region // place the part ...
                double newPackedPartsArea = tempSolutionArea + iPart.Area;
                //append the part to the list of packed parts
                TemporarySolution.Append(new PartNode(iPart)
                {
                    Container = iBoard.ID,
                    dWidth    = iBoard.dWidth,
                    dLength   = iBoard.dLength
                });
                #endregion

                #region // store best solution ...
                //if this is a better solution than the current best one ... replace the current best one
                if (newPackedPartsArea > currentSolutionArea)
                {
                    currentSolutionArea = newPackedPartsArea;
                    currentSolution     = new PartList(TemporarySolution);
                }
                #endregion

                // if there are no more parts, break out of the loop
                if (parts.Count == 1)
                {
                    break;
                }

                #region // Break association and adjust associate if a board is used that is associated with another to prevent overlapping placements ...
                BoardNode iAssocBoard = iBoard.AssociatedBoard;
                double    oAssocLength = 0, oAssocWidth = 0;
                // if the board section used has a buddy from a previous placement, adjust the buddy and break the association
                if (iAssocBoard != null)
                {
                    oAssocLength = iAssocBoard.Length;
                    oAssocWidth  = iAssocBoard.Width;;

                    //we have to adjust the buddy, so as not to place another part on the overlapping area
                    if (iBoard.dWidth < iAssocBoard.dWidth)
                    {
                        //if this is Rem1
                        //if the part is wider than the left portion of Rem1
                        if (iBoard.dWidth + iPart.Width + sawkerf > iAssocBoard.dWidth)
                        {
                            iAssocBoard.Length -= (iBoard.Length + sawkerf);
                        }
                        else
                        {
                            iBoard.Width -= (iAssocBoard.Width + sawkerf);
                        }
                    }
                    else
                    {
                        //if this is Rem2
                        if (iBoard.dLength + iPart.Length + sawkerf > iAssocBoard.dLength)
                        {
                            iAssocBoard.Width -= (iBoard.Width + sawkerf);
                        }
                        else
                        {
                            iBoard.Length -= (iAssocBoard.Length + sawkerf);
                        }
                    }

                    //then break the pair
                    iAssocBoard.AssociatedBoard = null;
                    iBoard.AssociatedBoard      = null;
                }
                #endregion

                #region // remove the current part from the parts list ...
                parts.Remove(iPart);
                #endregion

                #region // replace the used board with 2 overlapping remainder pieces after subtracting the part ...
                // divide the board into two overlapping remainder sections
                boards.Remove(iBoard);
                BoardNode boardSection1 = null;
                double    l             = iBoard.Length - iPart.Length - sawkerf;
                if (l * iBoard.Width >= parts.Head.Area)
                {
                    boardSection1 = new BoardNode(iBoard.ID, l, iBoard.Width, iBoard.dLength + iPart.Length + sawkerf, iBoard.dWidth);
                    boards.InsertItemSortedbyAreaAsc(boardSection1);
                }
                BoardNode boardSection2 = null;
                double    w             = iBoard.Width - iPart.Width - sawkerf;
                if (w * iBoard.Length >= parts.Head.Area)
                {
                    boardSection2 = new BoardNode(iBoard.ID, iBoard.Length, w, iBoard.dLength, iBoard.dWidth + iPart.Width + sawkerf);
                    boards.InsertItemSortedbyAreaAsc(boardSection2);
                    boardSection2.AssociatedBoard = boardSection1;
                    if (boardSection1 != null)
                    {
                        boardSection1.AssociatedBoard = boardSection2;
                    }
                }
                #endregion

                if (boards.Count > 0)
                {
                    #region // pack the remaining parts on the remaining boards ...
                    // pack the remaining parts on the remaining boards
                    Pack_recursive(parts, boards, TemporarySolution, newPackedPartsArea);
                    #endregion
                }

                #region // undo the placement so we can iterate to the next part and test with it ...
                // place the current part back in its exact place ...
                parts.Return(iPart);

                // remove the remainder board sections we added...
                if (boardSection1 != null)
                {
                    boards.Remove(boardSection1);
                }
                if (boardSection2 != null)
                {
                    boards.Remove(boardSection2);
                }

                // restore associations, and the original associated board's size
                if (iAssocBoard != null)
                {
                    iBoard.AssociatedBoard      = iAssocBoard;
                    iAssocBoard.AssociatedBoard = iBoard;
                    iAssocBoard.Length          = oAssocLength;
                    iAssocBoard.Width           = oAssocWidth;
                }

                // place the board back
                if (iBoard.Prev == null)
                {
                    boards.Head = iBoard;
                }
                else
                {
                    iBoard.Prev.Next = iBoard;
                }
                if (iBoard.Next == null)
                {
                    boards.Tail = iBoard;
                }
                else
                {
                    iBoard.Next.Prev = iBoard;
                }
                boards.Count++;

                // remove the part from the temporary solution
                TemporarySolution.Tail = TemporarySolution.Tail.Prev;
                if (TemporarySolution.Tail != null)
                {
                    TemporarySolution.Tail.Next = null;
                }
                else
                {
                    TemporarySolution.Head = null;
                }
                TemporarySolution.Count--;

                #endregion
            }
        }
예제 #26
0
        public IActionResult Index()
        {
            BoardList model = _boardService.GetListBoards();

            return(base.View(model));
        }
예제 #27
0
        static public PartList Pack(PartList parts, BoardList boards, double sawkerf = 4, double boardMarginLength = 0, double boardMarginWidth = 0, double partPaddingLength = 0, double partPaddingWidth = 0)
        {
            // order the parts by Area, Ascending
            var orderredParts = parts.OrderredByArea();
            var oderredBoards = boards.OrderredByArea();

            // add padding to parts
            orderredParts.InflateAll(partPaddingWidth, partPaddingLength);

            // init the bag for the solution
            PartList completeSolution = new PartList();

            // repeat until all parts are placed, or boards used up
            int iteration = 0;

            while (orderredParts.Count > 0 && oderredBoards.Count > 0)
            {
                // for this iteration, prepare to hold the best board's packing solution
                PartList bestsolution         = null;
                double   bestsolutioncoverage = 0;

                // we will pack each board in its own thread, so we need to track the threads
                List <Task> threads = new List <Task>();

                // loop through the available board sections
                for (BoardNode iBoard = oderredBoards.Head; iBoard != null; iBoard = iBoard.Next)
                {
                    threads.Add(
                        Task.Factory.StartNew((o) =>
                    {
                        Thread.CurrentThread.Priority = ThreadPriority.Highest;
                        // for every board
                        BoardNode tiBoard = new BoardNode((BoardNode)o);
                        // subtract the margin from the board
                        tiBoard.Inflate(-boardMarginWidth, -boardMarginLength);

                        // init a packer object
                        Packer iPacker = new Packer()
                        {
                            boardArea = tiBoard.Area,
                            sawkerf   = sawkerf
                        };

                        // pack the board recursively, starting at the first part and an empty solution
                        iPacker.Pack_recursive(new PartList(orderredParts), new BoardList(tiBoard), new PartList(), 0);

                        //Trace.WriteLine($"......in iteration {iteration+1}: Board {iPacker.currentSolution.Head.Container} packed to {iPacker.currentSolutionArea/iPacker.boardArea:0 %} :\r\n{iPacker.currentSolution.ToString()}");

                        // replace the best solution if this one is better
                        lock (lck)
                            if (iPacker.currentSolutionArea / iPacker.boardArea > bestsolutioncoverage)
                            {
                                bestsolutioncoverage = iPacker.currentSolutionArea / iPacker.boardArea;
                                bestsolution         = iPacker.currentSolution;
                            }
                    }, iBoard));
                }
                Task.WaitAll(threads.ToArray());

                // if no board could be packed, stop
                if (bestsolutioncoverage == 0)
                {
                    Trace.WriteLine("STOPPING: Non of the parts left to place would fit any of the available boards...");
                    break;
                }

                boards[bestsolution.Head.Container].Solution = new PartList(bestsolution);
                // report the best packking for this iteration
                Trace.WriteLine($"Best solution for iteration {++iteration}: Board {bestsolution.Head.Container} packed to {bestsolutioncoverage:0 %} :\r\n{bestsolution.ToString()}");

                // remove best packed board from the list of available boards
                oderredBoards.Remove(bestsolution.Head.Container);

                // remove the parts packed from the list of required parts
                for (PartNode iPart = bestsolution.Head; iPart != null; iPart = iPart.Next)
                {
                    orderredParts.Remove(iPart.ID);
                }

                // add this partial solution to the complete solution...
                completeSolution.Append(bestsolution);
            }

            // return the solution
            return(completeSolution);
        }
예제 #28
0
 public override void Dispose()
 {
     BoardList.Clear();
     base.Dispose();
 }
 public override Task FinishGetSavedAsync()
 {
     LoadControls();
     _model !.GameBoard1 !.PileList = SaveRoot !.BoardList.ToCustomBasicList();
     return(base.FinishGetSavedAsync());
 }