private void bindPulledData(string state) { try { if (objDataSet == null) { objDataSet = new DataSet(); } Reply objRes = new Reply(); using (WebClient client = new WebClient()) { client.Headers[HttpRequestHeader.ContentType] = "text/json"; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string JsonString = JsonConvert.SerializeObject(state); EncRequest objEncRequest = new EncRequest(); objEncRequest.RequestData = AesGcm256.Encrypt(JsonString); string dataEncrypted = JsonConvert.SerializeObject(objEncRequest); string result = client.UploadString(URL + "/GetPulledData", "POST", dataEncrypted); EncResponse objResponse = JsonConvert.DeserializeObject <EncResponse>(result); objResponse.ResponseData = AesGcm256.Decrypt(objResponse.ResponseData); //objRes = JsonConvert.DeserializeObject<Reply>(objResponse.ResponseData); //DataContractJsonSerializer objDCS = new DataContractJsonSerializer(typeof(Reply)); //MemoryStream objMS = new MemoryStream(Encoding.UTF8.GetBytes(objResponse.ResponseData)); //objRes = (Reply)objDCS.ReadObject(objMS); Newtonsoft.Json.JsonSerializer json = new Newtonsoft.Json.JsonSerializer(); json.NullValueHandling = NullValueHandling.Ignore; StringReader sr = new StringReader(objResponse.ResponseData); Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr); objRes = json.Deserialize <Reply>(reader); if (objRes.res == true && objRes.DS.Tables[0].Rows.Count > 0) { GV_Pulled_data.DataSource = objRes.DS.Tables[0]; GV_Pulled_data.DataBind(); } else { GV_Pulled_data.DataSource = null; GV_Pulled_data.DataBind(); } } } catch (Exception ex) { var page = HttpContext.Current.CurrentHandler as Page; ScriptManager.RegisterStartupScript(page, page.GetType(), "alert", "errorDisplay('catch error : " + ex.Message + "');", true); } }
public void bindKioskHealth(string state) { try { if (objDataSet == null) { objDataSet = new DataSet(); } Reply objRes = new Reply(); using (WebClient client = new WebClient()) { client.Headers[HttpRequestHeader.ContentType] = "text/json"; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string JsonString = JsonConvert.SerializeObject(state); EncRequest objEncRequest = new EncRequest(); objEncRequest.RequestData = AesGcm256.Encrypt(JsonString); string dataEncrypted = JsonConvert.SerializeObject(objEncRequest); string result = client.UploadString(URL + "/CommandsMachineList", "POST", dataEncrypted); EncResponse objResponse = JsonConvert.DeserializeObject <EncResponse>(result); objResponse.ResponseData = AesGcm256.Decrypt(objResponse.ResponseData); //objRes = JsonConvert.DeserializeObject<Reply>(objResponse.ResponseData); //DataContractJsonSerializer objDCS = new DataContractJsonSerializer(typeof(Reply)); //MemoryStream objMS = new MemoryStream(Encoding.UTF8.GetBytes(objResponse.ResponseData)); //objRes = (Reply)objDCS.ReadObject(objMS); Newtonsoft.Json.JsonSerializer json = new Newtonsoft.Json.JsonSerializer(); json.NullValueHandling = NullValueHandling.Ignore; StringReader sr = new StringReader(objResponse.ResponseData); Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr); objRes = json.Deserialize <Reply>(reader); if (objRes.res == true) { if (objRes.DS.Tables[1].Rows.Count > 0) { GV_Pulled_data.DataSource = objRes.DS.Tables[1]; GV_Pulled_data.DataBind(); } else { GV_Pulled_data.DataSource = null; GV_Pulled_data.DataBind(); } for (int iStateIndex = 0; iStateIndex < objRes.DS.Tables[0].Rows.Count; iStateIndex++) { State_List_with_IP += "<tr>" + "<td class=''>" + " <label class='option block mn'>" + " <input type = 'checkbox' name= 'inputname' value= 'FR'> " + " <span class='checkbox mn'></span> " + " </label> " + " </td> " + " <td class=''>" + objRes.DS.Tables[0].Rows[iStateIndex][0].ToString() + "</td> " + " <td class=''>" + objRes.DS.Tables[0].Rows[iStateIndex][1].ToString() + "</td> " + " <td class=''>" + objRes.DS.Tables[0].Rows[iStateIndex][2].ToString() + "</td> " + " <td > " + " <span>" + objRes.DS.Tables[0].Rows[iStateIndex][3].ToString() + "</span> " + " </td> " + " <td class=''>" + objRes.DS.Tables[0].Rows[iStateIndex][4].ToString() + "</td> " + " <td class=''>" + objRes.DS.Tables[0].Rows[iStateIndex][5].ToString() + "</td> " + " </tr>"; } errorlabel.Style["display"] = "none"; kiosklist.Style["display"] = "block"; srch.Value = ""; kiosk_data.Text = State_List_with_IP; } else { var page = HttpContext.Current.CurrentHandler as Page; ScriptManager.RegisterStartupScript(page, page.GetType(), "alert", "errorDisplay('" + objRes.strError + "');", true); } } } catch (Exception ex) { var page = HttpContext.Current.CurrentHandler as Page; ScriptManager.RegisterStartupScript(page, page.GetType(), "alert", "errorDisplay('catch error : " + ex.Message + "');", true); } }