예제 #1
0
        private BusinessEntities.Entities.Common.GenericResponse GetCongestionFactorByLinkIds(BusinessEntities.Entities.HERE_TrafficAnalyticsRequests.CongestionFactorByLinkIds congestionFactorByLinkIds)
        {
            ///log message
            ///
            Startup._iLog.WriteDebug("============================================= GetCongestionFactorByLinkIds =============================================");
            //Startup._iLog.WriteDebug(string.Format("To Speed Data LinkIds: {0}", string.Join(",", toSpeedDataByLinkIds.LinkIds.ToArray())));
            //Startup._iLog.WriteDebug(string.Format("Congestion Factor Params : {0}", Newtonsoft.Json.JsonConvert.SerializeObject(congestionFactorByLinkIds)));

            BusinessEntities.Entities.Common.GenericResponse genericResponse = null;
            try
            {
                if (
                    congestionFactorByLinkIds == null
                    ||
                    string.IsNullOrEmpty(congestionFactorByLinkIds.LinkIds)
                    ||
                    string.IsNullOrEmpty(congestionFactorByLinkIds.TimePattern)
                    ||
                    string.IsNullOrEmpty(congestionFactorByLinkIds.Direction)
                    )
                {
                    genericResponse = new BusinessEntities.Entities.Common.GenericResponse()
                    {
                        ResponseCode    = ((int)HttpStatusCode.OK).ToString(),
                        ResponseMessage = ("all request parameters are required."),
                        ResponseData    = string.Empty
                    };
                }
                else
                {
                    genericResponse = new BusinessEntities.Entities.Common.GenericResponse()
                    {
                        ResponseCode    = ((int)HttpStatusCode.OK).ToString(),
                        ResponseMessage = ("WaliedCheetos : Hollla"),
                        ResponseData    = BusinessLogic.Operations.HERE_TrafficAnalytics._fx_GetCongestionFactorByLinkIds(congestionFactorByLinkIds, Startup._iLog, string.Empty)
                    };
                }
            }
            catch (Exception exception)
            {
                ///log message
                ///
                Startup._iLog.WriteError(string.Format("Exception: {0}", exception.ToString()));

                genericResponse = new BusinessEntities.Entities.Common.GenericResponse()
                {
                    ResponseCode    = ((int)HttpStatusCode.InternalServerError).ToString(),
                    ResponseMessage = (exception.ToString()),
                    ResponseData    = string.Empty
                };
            }
            finally
            {
            }
            return(genericResponse);
        }
예제 #2
0
        public BusinessEntities.Entities.Common.GenericResponse GenericJSONRequest([Microsoft.AspNetCore.Mvc.FromBody] Newtonsoft.Json.Linq.JToken GenericJSONRequest)
        {
            //HttpResponseMessage httpResponseMessage = null;
            BusinessEntities.Entities.Common.GenericResponse genericResponse = null;
            string methodName = string.Empty;

            ///log message
            ///
            Startup._iLog.WriteDebug("============================================= GenericJSONRequest =============================================");

            try
            {
                if (GenericJSONRequest != null)
                {
                    ///log message
                    ///
                    //N.B. memory intentsive operation.
                    Startup._iLog.WriteDebug(string.Format("Request: {0}", GenericJSONRequest.ToString()));

                    RequestParams requestParams = Newtonsoft.Json.JsonConvert.DeserializeObject <RequestParams>(GenericJSONRequest.ToString());
                    genericResponse = this.InBoundRequest(requestParams);
                }
                else
                {
                    ///log message
                    ///
                    Startup._iLog.WriteError(string.Format("Error: {0}", "GenericJSONRequest: Null value passed in parameter _jToken_GenericJSONRequest. No action taken."));
                }
            }
            catch (Exception exception)
            {
                ///log message
                ///
                Startup._iLog.WriteError(string.Format("Exception: {0}", exception.ToString()));

                genericResponse = new BusinessEntities.Entities.Common.GenericResponse()
                {
                    ResponseCode    = ((int)HttpStatusCode.InternalServerError).ToString(),
                    ResponseMessage = (exception.ToString()),
                    ResponseData    = string.Empty
                };
            }
            finally
            {
                ///log message
                ///
                //N.B. memory intentsive operation.
                Startup._iLog.WriteDebug(string.Format("Response: {0}", (Newtonsoft.Json.JsonConvert.SerializeObject(genericResponse))));
            }
            return(genericResponse);
        }
예제 #3
0
        public BusinessEntities.Entities.Common.GenericResponse InBoundRequest(RequestParams requestParams)
        {
            BusinessEntities.Entities.Common.GenericResponse genericResponse = null;
            try
            {
                if (requestParams != null && !string.IsNullOrEmpty(requestParams.Method))
                {
                    if (ValidateRequestUser(requestParams.User, requestParams.Token, string.Empty))
                    {
                        //JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

                        switch (requestParams.Method.ToUpper())
                        {
                        case "GETTOSPEEDDATABYLINKID":

                            BusinessEntities.Entities.HERE_TrafficAnalyticsRequests.ToSpeedDataByLinkIds toSpeedDataByLinkIds = Newtonsoft.Json.JsonConvert.DeserializeObject <BusinessEntities.Entities.HERE_TrafficAnalyticsRequests.ToSpeedDataByLinkIds>(requestParams.Data.ToString());
                            genericResponse = this.GetToSpeedDataByLinkId(toSpeedDataByLinkIds);
                            break;

                        case "GETCONGESTIONFACTORBYLINKIDS":

                            BusinessEntities.Entities.HERE_TrafficAnalyticsRequests.CongestionFactorByLinkIds congestionFactorByLinkIds = Newtonsoft.Json.JsonConvert.DeserializeObject <BusinessEntities.Entities.HERE_TrafficAnalyticsRequests.CongestionFactorByLinkIds>(requestParams.Data.ToString());
                            genericResponse = this.GetCongestionFactorByLinkIds(congestionFactorByLinkIds);
                            break;

                        case "GETCONGESTIONFACTORSBYLINKIDS":

                            BusinessEntities.Entities.HERE_TrafficAnalyticsRequests.CongestionFactorsByLinkIds congestionFactorsByLinkIds = Newtonsoft.Json.JsonConvert.DeserializeObject <BusinessEntities.Entities.HERE_TrafficAnalyticsRequests.CongestionFactorsByLinkIds>(requestParams.Data.ToString());
                            genericResponse = this.GetCongestionFactorsByLinkIds(congestionFactorsByLinkIds);
                            break;

                        default:
                            genericResponse = new BusinessEntities.Entities.Common.GenericResponse()
                            {
                                ResponseCode    = ((int)HttpStatusCode.NotImplemented).ToString(),
                                ResponseMessage = ("Method is not implemented"),
                                ResponseData    = string.Empty
                            };
                            break;
                        }
                    }
                    else
                    {
                        genericResponse = new BusinessEntities.Entities.Common.GenericResponse()
                        {
                            ResponseCode    = ((int)HttpStatusCode.Unauthorized).ToString(),
                            ResponseMessage = ("Unauthorized access"),
                            ResponseData    = string.Empty
                        };
                    }
                }
            }
            catch (Exception exception)
            {
                ///log message
                ///
                Startup._iLog.WriteError(string.Format("Exception: {0}", exception.ToString()));

                genericResponse = new BusinessEntities.Entities.Common.GenericResponse()
                {
                    ResponseCode    = ((int)HttpStatusCode.InternalServerError).ToString(),
                    ResponseMessage = (exception.ToString()),
                    ResponseData    = string.Empty
                };
            }
            finally { }

            return(genericResponse);
        }