[ResponseHeaderAddition] //Response header addition profile public object Post(PeriodicalTaskGet taskGetRequest) { PeriodicalTaskGetResponse tasksList = new PeriodicalTaskGetResponse { }; tasksList.periodicalTasks = new List <PeriodicalTaskGetResponse.PeriodicalTask>(); //Check if the response status code is correct to store info in DB and send back response if (Response.StatusCode == 200) { string smartBoxSN = Request.Headers[ApiCustomHttpHeaders.DeviceId]; //----Perform query in DB for smartbox tasks, return list with tasks IDs------ //CODE HERE //------------------------------------------------------------------------ //----TEST CODE---- //List of all tasks for SmartBox List <PeriodicalTaskGetResponse.PeriodicalTask> allTasksList = CreatePeriodicalTasksDUMMY(); //Get all requested tasks from the list for (int i = 0; i < allTasksList.Count; i++) { if (taskGetRequest.periodicalTasksRequested.IndexOf(allTasksList[i].periodicalTaskID) != -1) { tasksList.periodicalTasks.Add(allTasksList[i]); } } //----------------- } return(tasksList); }
private void button4_Click(object sender, EventArgs e) { //Try to Query periodical task from server try { //TEST INFO---Tasks that are already in SmartBox List <int> tasksInSmartBox = new List <int>(); tasksInSmartBox.Add(0); tasksInSmartBox.Add(2); //---------------------------------------------- //Query for all periodical tasks for the smartbox var queryRes = client.Get <PeriodicalTaskQueryResponse>("/periodicaltaskquery"); //Check for new tasks List <int> newTasksIDs = new List <int>(); foreach (int taskID in queryRes.periodicalTasksID) { if (tasksInSmartBox.IndexOf(taskID) == -1) { newTasksIDs.Add(taskID); } } //Try to Get new tasks from server PeriodicalTaskGet newTasksToGet = new PeriodicalTaskGet(); newTasksToGet.periodicalTasksRequested = newTasksIDs; try { var getRes = client.Post <PeriodicalTaskGetResponse>("/periodicaltaskget", newTasksToGet); label1.Text = getRes.periodicalTasks[0].description; } catch (WebServiceException webEx) { //Get error Message label1.Text = webEx.GetStatus().ToString() + ": " + webEx.StatusDescription; } } catch (WebServiceException webEx) { //Get error Message label1.Text = webEx.GetStatus().ToString() + ": " + webEx.StatusDescription; } }