public async Task AutoUpdateRandDynamicData(int id) { //generate random eta Random rndETA1 = new Random(); int etaint1 = rndETA1.Next(1, 60); // creates a number between 1 and 60 string eta1 = etaint1.ToString() + "min"; Random rndETA2 = new Random(); int etaint2 = rndETA2.Next(1, 60); // creates a number between 1 and 60 string eta2 = etaint2.ToString() + "min"; //call traveltimeService to update the values into postgresql database traveltimeService.updateTravelTime(id, "1", "mvalley", "Mid Valley", DateTime.Now.ToString(), eta1); traveltimeService.updateTravelTime(id, "1", "tsquare", "Times Square", DateTime.Now.ToString(), eta2); //call parkingService to update the values into postgresql database //-------- //call weatherService to update the values into postgresql database /*Random rand1 = new Random(); * int diceNum1 = rand1.Next(0, 2); * Random rand2 = new Random(); * int diceNum2 = rand2.Next(0, 2); * Random rand3 = new Random(); * int diceNum3 = rand3.Next(0, 2); * string[] weatherStatus = new string[] { "rain", "no rain", "thunderstorm" }; * * string morning = weatherStatus[diceNum1]; * string afternoon = weatherStatus[diceNum2]; * string night = weatherStatus[diceNum3]; * * weatherService.updateWeather(id, "Selayang", morning, afternoon, * night, DateTime.Now.ToString());*/ //delete tempfoldersingle, recreate tempfilersingle, copy from board folder var folderPath = UploadsFolder.GetUploadsSubPath(UploadsFolder.TempFolderSingle); if (Directory.Exists(folderPath)) { Directory.Delete(folderPath, true); //delete old folder } if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); //create new folder } var sourcePathToCopy = UploadsFolder.GetUploadsSubPath(id.ToString()); if (Directory.Exists(sourcePathToCopy)) { _fileManagement.CopyFiles(sourcePathToCopy, folderPath); //make a copy from board folder } //call createvsn to re-create the vsn file _createVsnService.createVSN(id, false); //update physical board await _colorlightServices.SendProgramAsync(id, false); }
public async Task <ActionResult> UpdateTravelTimeAsync([FromBody] TravelTimeUpdateRequest request) { //call traveltimeService to update the values into postgresql database traveltimeService.updateTravelTime(request.id, request.eventType, request.sname, request.name, request.datetime, request.eta); //call createvsn to create the vsn file _createVsnService.createVSN(request.id, false); //update physical board await _colorlightServices.SendProgramAsync(request.id, false); return(Ok()); }
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"); } }