public IHttpActionResult ProcessRequest(RequestData request)
        {
            //HttpClient client = new HttpClient();
            //Request.Headers.Authorization

            JObject obj = new JObject();

            try
            {
                JObject jsonObj = request.Json;
                var     newObj  = new JObject
                {
                    ["Json"] = jsonObj,
                };

                string newJsonString = Convert.ToString(newObj);


                dynamic inputObject = new ExpandoObject();

                var expConverter = new ExpandoObjectConverter();
                inputObject = JsonConvert.DeserializeObject <ExpandoObject>(newJsonString, expConverter);
                string customApi = "";
                string processServicesConfiguartionURL = ServiceConfigurationDataAccessManager.GetServicesConfiguartionURL(inputObject.Json.ServicesAction);
                // Convert json string to custom .Net object
                JObject ObjProcessServicesConfiguartionURL = (JObject)JsonConvert.DeserializeObject(processServicesConfiguartionURL);
                customApi = ObjProcessServicesConfiguartionURL["Json"]["ServicesURL"].ToString();


                //customApi = _cacheManager.GetServiceConfiguartionUrlFromCache(inputObject.Json.ServicesAction);
                LogData("ProcessRequest customApi" + customApi);


                if (!string.IsNullOrEmpty(customApi))
                {
                    //create the constructor with post type and few data
                    GRClientRequest myRequest = new GRClientRequest(customApi, "POST", newJsonString);
                    //show the response string on the console screen.
                    string outputResponse = myRequest.GetResponse();
                    LogData("outputResponse customApi" + outputResponse);
                    if (outputResponse != null)
                    {
                        obj = (JObject)JsonConvert.DeserializeObject(outputResponse);
                    }
                }
            }
            catch (Exception ex)
            {
                LogData("ProcessRequest Error" + ex.Message);
            }

            return(Ok(obj));
        }
        public HttpResponseMessage ProcessRequestForExcelExport(RequestData request)
        {
            HttpResponseMessage result = new HttpResponseMessage();

            try
            {
                JObject jsonObj = request.Json;

                var newObj = new JObject
                {
                    ["Json"] = jsonObj,
                };
                string newJsonString = Convert.ToString(newObj);

                string customApi = LoadServicesConfigDetails(JObject.Parse(newJsonString));

                JObject obj = new JObject();
                if (!string.IsNullOrEmpty(customApi))
                {
                    //create the constructor with post type and few data
                    GRClientRequest myRequest = new GRClientRequest(customApi, "POST", newJsonString);
                    //show the response string on the console screen.

                    string outputResponse = myRequest.GetResponse();

                    if (outputResponse != null)
                    {
                        obj = (JObject)JsonConvert.DeserializeObject(outputResponse);
                        string jsonstring = obj["Json"]["OrderList"].ToString();

                        DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsonstring, (typeof(DataTable)));
                        result = ExportReportDownloading(dt);
                    }
                }
            }
            catch (Exception e)
            {
            }

            return(result);
        }
        public HttpResponseMessage ProcessRequestForBuffer(RequestData request)
        {
            JObject jsonObj = request.Json;

            HttpResponseMessage result = new HttpResponseMessage();

            var newObj = new JObject
            {
                ["Json"] = jsonObj,
            };
            string newJsonString = Convert.ToString(newObj);

            string customApi = LoadServicesConfigDetails(JObject.Parse(newJsonString));

            JObject obj = new JObject();

            if (!string.IsNullOrEmpty(customApi))
            {
                //create the constructor with post type and few data
                GRClientRequest myRequest = new GRClientRequest(customApi, "POST", newJsonString);
                //show the response string on the console screen.

                string outputResponse = myRequest.GetResponse();

                if (!string.IsNullOrEmpty(outputResponse) && outputResponse != "{}")
                {
                    JObject        response  = (JObject)JsonConvert.DeserializeObject(outputResponse);
                    List <dynamic> orderList = new List <dynamic>();

                    string blob         = "";
                    string documenttype = "";

                    if (!string.IsNullOrEmpty(Convert.ToString(response["Json"]["OrderDocumentList"])))
                    {
                        orderList = ((JArray)response["Json"]["OrderDocumentList"]).ToObject <List <dynamic> >();

                        foreach (dynamic order in orderList)
                        {
                            blob         = order.DocumentBlob;
                            documenttype = order.DocumentFormat;
                        }
                    }
                    else if (!string.IsNullOrEmpty(Convert.ToString(response["Json"]["TransportVehicleList"])))
                    {
                        orderList = ((JArray)response["Json"]["TransportVehicleList"]).ToObject <List <dynamic> >();

                        foreach (dynamic order in orderList)
                        {
                            blob         = order.DocumentBlob;
                            documenttype = order.DocumentFormat;
                        }
                    }
                    else
                    {
                        blob         = Convert.ToString(response["Json"]["DocumentBlob"]);
                        documenttype = Convert.ToString(response["Json"]["DocumentFormat"]);
                    }

                    byte[] byt = Convert.FromBase64String(blob);

                    if (byt == null)
                    {
                        result = Request.CreateResponse(HttpStatusCode.Gone);
                    }
                    else
                    {
                        result.Content = new ByteArrayContent(byt);
                        result.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
                        result.Content.Headers.ContentDisposition.FileName = "OrderPickSlip." + documenttype;
                        result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/" + documenttype);
                    }
                }
                else
                {
                }
            }

            return(result);
        }
        protected bool ValidateLicense(LoginDTO loginDto)
        {
            bool IsValid = false;

            try
            {
                JObject jsonObj = new JObject();

                var newObj = new JObject
                {
                    ["Json"] = jsonObj,
                };
                string newJsonString = Convert.ToString(newObj);
                LogWsData("newJsonString: " + newJsonString);
                string servicesAction = "GetLicenseInfoList";
                string servicesURL    = ServiceConfigurationDataAccessManager.GetServicesConfiguartionURL(servicesAction);
                LogWsData("servicesURL: " + servicesURL);
                // Convert json string to custom .Net object
                JObject jObjectServicesConfiguartionURL = (JObject)JsonConvert.DeserializeObject(servicesURL);
                string  customApi = jObjectServicesConfiguartionURL["Json"]["ServicesURL"].ToString();
                LogWsData("customApi: " + customApi);
                GRClientRequest myRequest = new GRClientRequest(customApi, "POST", newJsonString);
                LogWsData("myRequest: " + myRequest);
                string outputResponse = myRequest.GetResponse();
                LogWsData("outputResponse: " + outputResponse);
                if (!string.IsNullOrEmpty(outputResponse))
                {
                    JObject obj  = new JObject();
                    JObject obj1 = new JObject();

                    obj = (JObject)JsonConvert.DeserializeObject(outputResponse);

                    // Create a dynamic output object
                    dynamic output = new ExpandoObject();

                    output.LicenseInfoList = obj["LicenseInfo"]["LicenseInfoList"];
                    output.UserTypeCode    = loginDto.UserTypeCode;
                    output.UserName        = loginDto.UserName;
                    output.ActivationCode  = loginDto.ActivationCode;

                    dynamic orderJson = new ExpandoObject();
                    orderJson.Json = output;

                    // Serialize the dynamic output object to a string
                    string outputJson = JsonConvert.SerializeObject(orderJson);

                    // Convert json object to JOSN string format
                    string jsonData = JsonConvert.SerializeObject(obj1);

                    string servicesAction1 = "ValidateLicense";
                    string servicesURL1    = ServiceConfigurationDataAccessManager.GetServicesConfiguartionURL(servicesAction1);

                    // Convert json string to custom .Net object
                    JObject jObjectServicesConfiguartionURL1 = (JObject)JsonConvert.DeserializeObject(servicesURL1);
                    string  customApi1 = jObjectServicesConfiguartionURL1["Json"]["ServicesURL"].ToString();

                    GRClientRequest myRequest1 = new GRClientRequest(customApi1, "POST", outputJson);

                    string outputResponse1 = myRequest1.GetResponse();

                    if (!string.IsNullOrEmpty(outputResponse1))
                    {
                        JObject objoutputResponse = new JObject();

                        objoutputResponse = (JObject)JsonConvert.DeserializeObject(outputResponse1);
                        IsValid           = Convert.ToBoolean(objoutputResponse["Json"]["IsLicenseValid"]);
                    }
                }
            }
            catch (Exception ex)
            {
                LogWsData("ValidateLicense: " + ex);
                LogWsData("ValidateLicenseMessage: " + ex.Message);
                LogWsData("ValidateLicenseInnerException: " + ex.InnerException);
            }

            return(IsValid);
        }