Exemple #1
0
        public string DoLaunchApp(string appName, List <string> context, out string stroutPostData)
        {
            string strResponse = string.Empty;

            restClient.httpMethod = httpMethod.POST;
            restClient.URI        = URL_SXS;

            JsonLaunchApp jLaunchApp = new JsonLaunchApp();

            jLaunchApp.appId        = appName;
            jLaunchApp.sessionToken = SESSIONTOKEN;


            // Add RIC (context) to our JSon object
            foreach (string str in context)
            {
                jLaunchApp.context.entities.Add(new JsonEntities(str));
            }


            // Serialize JSonLaunchApp object to create JSON data for POST Request
            string strPostData = JsonConvert.SerializeObject(jLaunchApp, 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)
                {
                    DebugOutput("instanceID: " + myObject.instanceId);
                    EIKONAPP.Add(new EikonApp(myObject.instanceId.ToString(), jLaunchApp));
                }
                else
                {
                    DebugOutput("ERROR LAUNCHING APP");
                }
            }
            catch (Exception)
            {
                //strResponse = ex.Message.ToString();
            }

            return(strResponse);
        }
Exemple #2
0
        public string DoLaunchApp(string appName)
        {
            string strResponse = string.Empty;

            restClient.httpMethod = httpMethod.POST;
            restClient.URI        = URL_SXS;

            //JsonLaunchAppSimple jLaunchApp = new JsonLaunchAppSimple();
            JsonLaunchApp jLaunchApp = new JsonLaunchApp();

            jLaunchApp.appId        = appName;
            jLaunchApp.sessionToken = SESSIONTOKEN;
            jLaunchApp.context.entities.Add(new JsonEntities("TRI.N"));
            jLaunchApp.context.entities.Add(new JsonEntities("MSFT.O"));

            string strPostData = JsonConvert.SerializeObject(jLaunchApp);

            DebugOutput(strPostData);

            strResponse = restClient.PostRequest(strPostData);

            // Using Newtonsoft.Json library to do JSON Deserialization Object
            try
            {
                var myObject = JsonConvert.DeserializeObject <dynamic>(strResponse);

                if (myObject.isSuccess == true)
                {
                    DebugOutput("instanceID: " + myObject.instanceId);
                    EIKONAPP.Add(new EikonApp(myObject.instanceId.ToString(), jLaunchApp));
                }
                else
                {
                    DebugOutput("ERROR LAUNCHING APP");
                }
            }
            catch (Exception ex)
            {
                strResponse = ex.Message.ToString();
            }

            return(strResponse);
        }