// bLink = true <- Link, false <- Unlink. private bool ChangeLinkToMyApp(linkMethod lnkMethod, string id) { bool bSuccess = false; // Scroll through our Object and change state to Linked foreach (EikonApp myApp in EIKONAPP) { DebugOutput("myApp ID : " + myApp.INSTANCEID); if (string.Equals(myApp.INSTANCEID, id)) { // Found our instance, change status to Linked DebugOutput("FOUND OUR LINKED APP with Instance ID :" + myApp.INSTANCEID); if (lnkMethod == linkMethod.RECEIVED) { myApp.RECEIVEDFROM = true; } else if (lnkMethod == linkMethod.STOPRECEIVED) { myApp.RECEIVEDFROM = false; } bSuccess = true; } } return(bSuccess); }
public string BroadcastApp(linkMethod lnkMethod, EikonApp myApp, out string stroutPostData) { string strResponse = ""; JsonLinkApp jLinkApp = new JsonLinkApp(); if (lnkMethod == linkMethod.BROADCAST) { jLinkApp.command = "link"; } else if (lnkMethod == linkMethod.STOPBROADCAST) { jLinkApp.command = "unlink"; } else { jLinkApp.command = ""; } jLinkApp.sessionToken = SESSIONTOKEN; jLinkApp.targetInstanceId = myApp.INSTANCEID; // Serialize JSonLaunchApp object to create JSON data for POST Request string strPostData = JsonConvert.SerializeObject(jLinkApp, Formatting.Indented); stroutPostData = strPostData; DebugOutput(strPostData); strResponse = restClient.PostRequest(strPostData); // Using Newtonsoft.Json library to do JSON Deserialization Object from Web Response try { // Beautify Json response strResponse = JValue.Parse(strResponse).ToString(Formatting.Indented); var myObject = JsonConvert.DeserializeObject <dynamic>(strResponse); if (myObject.isSuccess == true) { //Link/Unlink process Successfull, update our islinked state if (lnkMethod == linkMethod.BROADCAST) { myApp.BROADCASTTO = true; DebugOutput("Set Broadcast To Success instanceID: " + myApp.INSTANCEID); } else if (lnkMethod == linkMethod.STOPBROADCAST) { myApp.BROADCASTTO = false; DebugOutput("Stop Broadcast Success instanceID: " + myApp.INSTANCEID); } } else { DebugOutput("ERROR in Linking/Unlinkg APP"); } } catch (Exception) { //strResponse = ex.Message.ToString(); } return(strResponse); }