Example #1
0
        public ActionResult CallMicroService(string url)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                url = "http://10.25.232.179:8001/PracticeList";
            }

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var    returnResult    = string.Empty;
            object convertedResult = null;
            int    totalBytes      = 0;

            using (var wc = new WebClient())
            {
                returnResult    = wc.DownloadString(url);
                convertedResult = JsonConvert.DeserializeObject(returnResult);
                totalBytes      = (returnResult.Length * sizeof(Char));
            }

            stopWatch.Stop();

            var returnObj = new MicroserviceResponseModel
            {
                TimeElapsedMs = stopWatch.Elapsed.Milliseconds,
                Data          = convertedResult,
                TotalBytes    = totalBytes
            };

            return(Content(JsonConvert.SerializeObject(returnObj), "application/json"));
        }
Example #2
0
        public ActionResult DecryptServiceResponse(string data)
        {
            if (string.IsNullOrWhiteSpace(data))
            {
                throw new Exception("No encrypted data provided.");
            }

            var crypto = new Cryptography();

            var decryptedResults = crypto.Decrypt(data);

            var returnObj = new MicroserviceResponseModel
            {
                TimeElapsedMs = 0,
                Data          = JsonConvert.DeserializeObject(decryptedResults),
                TotalBytes    = ((decryptedResults.Length) * sizeof(Char))
            };

            return(Content(JsonConvert.SerializeObject(returnObj), "application/json"));
        }