コード例 #1
0
        public async Task LongProcess(int boardId, bool isMultiple, List <int> selectedMessages)
        {
            await _dotnetHubInvoker.UpdateProgress(0, "Start..."); //START

            // *** *** ** WRITE CODE HERE TO CHECK CONNECTION AS A PRIMARY STEP **** *** ***

            /*
             *
             *
             *
             *
             */

            string vsnCreated = _createVsnService.createVSN(boardId, isMultiple);
            await _dotnetHubInvoker.UpdateProgress(10, "New program file created. Attempt to delete old program. Please wait...");

            if (await _colorlightServices.GetActiveProgramAsync(boardId) == vsnCreated)
            {
                await _colorlightServices.DeleteProgramAsync(boardId);
            }
            await _dotnetHubInvoker.UpdateProgress(30, "Attempt to upload and display new program. Please wait...");

            bool IsSuccessful = await _colorlightServices.SendProgramAsync(boardId, isMultiple); //Send from TempFolder

            UploadTime = DateTime.Now.ToString("ddMMMMyyyy, h:mmtt");
            await _dotnetHubInvoker.UpdateProgress(70, "Checking status. Please wait...");

            //Delay for board to play new program
            await Task.Delay(3000);

            await _dotnetHubInvoker.UpdateProgress(80, "Please wait...");

            string boardName = _context.Boards.Where(b => b.ID == boardId).Select(b => b.Name).FirstOrDefault();

            if (IsSuccessful)
            { //successfully send program
                Upload_OK.Add(boardName);
                await _dotnetHubInvoker.GenaralBroadcast(boardName + " - Upload OK");

                if (await _colorlightServices.GetActiveProgramAsync(boardId) == vsnCreated)
                { //successfully play on display
                    await _dotnetHubInvoker.GenaralBroadcast(boardName + " - Display OK");

                    if (isMultiple)
                    {
                        _fileManagement.CopyFromTempFolderMultiple(boardId);
                    }
                    else
                    {
                        _fileManagement.CopyFromTempFolderSingle(boardId);
                    }
                    await _dotnetHubInvoker.UpdateProgress(85, "");
                    await UpdateMessageAssignment(boardId, selectedMessages);

                    await _dotnetHubInvoker.UpdateProgress(90, "");
                    await UpdateHistory(boardId);

                    //---------------HERE HERE HERE-----------------------------'
                    await CombineHistory(boardId);

                    await _dotnetHubInvoker.UpdateProgress(100, ""); //END

                    Display_OK.Add(boardName);
                }
                else
                {
                    Display_NOTOK.Add(boardName);
                    await _dotnetHubInvoker.GenaralBroadcast(boardName + " - Display NOT OK");
                }
            }
            else
            {
                Upload_NOTOK.Add(boardName);
                await _dotnetHubInvoker.GenaralBroadcast(boardName + " - Upload NOT OK");
            }
        }