Esempio n. 1
0
        public CornetTransactionRegistrationReply RegisterCornetTransaction(CornetTransaction cornetTransaction)
        {
            Console.WriteLine("In RegisterCornetTransaction");
            CornetTransactionRegistrationReply cornetregreply = new CornetTransactionRegistrationReply();

            CornetTransactionRegistration.getInstance().Add(cornetTransaction);
            cornetregreply.ResponseMessage = "Success";
            cornetregreply.ResponseCode    = "1";

            return(cornetregreply);
        }
        public CornetTransactionRegistrationReply RegisterCornetTransaction(CornetTransaction cornetTransaction)
        {
            Console.WriteLine(DateTime.Now + " In RegisterCornetTransaction");
            CornetTransactionRegistrationReply cornetregreply = new CornetTransactionRegistrationReply();

            CornetTransactionRegistration.getInstance().Add(cornetTransaction);
            Console.WriteLine(DateTime.Now + " Received data from Cornet");

            var t = Task.Run(() => CallDynamicsWithCornetData(_configuration, cornetTransaction));

            t.Wait();
            Console.WriteLine(DateTime.Now + " Sent data to Dynamics");

            if (t.Result.Contains("Cornet Notification "))
            {
                cornetregreply.ResponseCode    = "200";
                cornetregreply.ResponseMessage = "Success";
                Console.WriteLine(DateTime.Now + " Response Success");
            }
            else
            {
                //JObject tempJson = JObject.Parse(t.Result);
                //CornetDynamicsReply replyJson = new CornetDynamicsReply();

                //if (t.IsCompletedSuccessfully == true)
                //{
                //    cornetregreply.ResponseMessage = "Success";
                //    cornetregreply.ResponseCode = null;// t.Result;
                //    Console.WriteLine(DateTime.Now + " Response Success");
                //}
                //else
                //{
                cornetregreply.ResponseMessage = "Failure";
                cornetregreply.ResponseCode    = t.Result;
                Console.WriteLine(DateTime.Now + " Response Fail");
                //}
            }

            // Responses as follows:
            // 200 - Status OK - Automatically Done
            // 400 - Bad Request (Malformed JSON) - Automatically Done
            // 500 - Internal Server Error (Something wrong on our end)
            // 201 - If anything is being created on our end based on the notification sent
            // This next line is just a sample of how to do it:
            //this.HttpContext.Response.StatusCode = 444;

            Console.WriteLine(DateTime.Now + " Exit RegisterCornetTransaction");
            return(cornetregreply);
        }
Esempio n. 3
0
        public IActionResult InsertCornetTransaction(CornetTransaction cornetTransaction)
        {
            try
            {
                Console.WriteLine("In InsertCornetTransaction");
                CornetTransactionRegistrationReply casregreply = new CornetTransactionRegistrationReply();
                CornetTransactionRegistration.getInstance().Add(cornetTransaction);
                casregreply.ResponseMessage = "Success";

                return(Ok(casregreply));
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in InsertCornetTransaction. " + e.ToString());
                return(StatusCode(e.HResult));
            }
        }