Ejemplo n.º 1
0
        public HttpResponseMessage GetRouteUsers([FromBody] GetRouteUserRequest GetRouteUserRequest)
        {
            Logger.Debug("Inside UM Controller- GetRouteUsers ");
            Logger.Debug("Request: " + new JavaScriptSerializer().Serialize(GetRouteUserRequest));
            GetRouteUserResponse lResponse = new GetRouteUserResponse();
            ErrorResponse        error     = new ErrorResponse();
            var response = new Dictionary <string, object>();

            try
            {
                string SessionID = Guid.Empty.ToString();
                if (Request.Headers != null)
                {
                    SessionID = Request.Headers.LastOrDefault().Value.First();
                    Logger.Debug("SessionID: " + SessionID.ToString());
                    if (_IUMServer.ValidateUser(SessionID))
                    {
                        lResponse = _IUMServer.GetRouteUsers(GetRouteUserRequest);
                        if (lResponse != null)
                        {
                            Logger.Debug("Response: " + new JavaScriptSerializer().Serialize(lResponse));
                            return(Request.CreateResponse(HttpStatusCode.OK, lResponse));
                        }
                        else
                        {
                            error.ErrorCode    = HttpStatusCode.InternalServerError;
                            error.ErrorMessage = "Failure";
                            response.Add("ErrorResponse", error);
                            return(Request.CreateResponse(HttpStatusCode.InternalServerError, response));
                        }
                    }
                    else
                    {
                        error.ErrorCode    = HttpStatusCode.Forbidden;
                        error.ErrorMessage = "Session has expired, please login again";
                        response.Add("ErrorResponse", error);
                        return(Request.CreateResponse(HttpStatusCode.Forbidden, response));
                    }
                }
                else
                {
                    error.ErrorCode    = HttpStatusCode.BadRequest;
                    error.ErrorMessage = "Failure";
                    response.Add("ErrorResponse", error);
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, response));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                error.ErrorCode    = HttpStatusCode.InternalServerError;
                error.ErrorMessage = "Failure";
                response.Add("ErrorResponse", error);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, response));
            }
        }
Ejemplo n.º 2
0
        public GetRouteUserResponse GetRouteUsers(GetRouteUserRequest GetRouteUserRequest)
        {
            GetRouteUserResponse lresponse = new GetRouteUserResponse();
            IJobRepository       _IJobRepository;

            _IJobRepository = new JobRepository(new WorkersInMotionDB());
            //lresponse = _IJobRepository.GetRouteUsers(GetRouteUserRequest);
            //return lresponse;
            try
            {
                GetRouteUserResponse lResponse = new GetRouteUserResponse();

                SqlParameter[] Param = new SqlParameter[12];
                Param[11]           = new SqlParameter("@pOrganizationGUID", SqlDbType.UniqueIdentifier);
                Param[11].Value     = DBNull.Value;
                Param[0]            = new SqlParameter("@pDate", SqlDbType.Date);
                Param[0].Value      = DateTime.UtcNow;
                Param[1]            = new SqlParameter("@pStartTime", SqlDbType.Time);
                Param[1].Value      = DateTime.UtcNow.TimeOfDay;
                Param[2]            = new SqlParameter("@pEndTime", SqlDbType.Time);
                Param[2].Value      = DateTime.UtcNow.TimeOfDay;
                Param[3]            = new SqlParameter("@pDuration", SqlDbType.Float);
                Param[3].Value      = 230;
                Param[4]            = new SqlParameter("@pRegionGUID", SqlDbType.UniqueIdentifier);
                Param[4].Value      = DBNull.Value;
                Param[5]            = new SqlParameter("@pTerritoryGUID", SqlDbType.UniqueIdentifier);
                Param[5].Value      = DBNull.Value;
                Param[6]            = new SqlParameter("@pLatitude", SqlDbType.Float);
                Param[6].Value      = 0;
                Param[7]            = new SqlParameter("@pLongitude", SqlDbType.Float);
                Param[7].Value      = 0;
                Param[8]            = new SqlParameter("@pSearchWithinZoneArea", SqlDbType.Bit);
                Param[8].Value      = 0;
                Param[9]            = new SqlParameter("@pSearch", SqlDbType.Bit);
                Param[9].Value      = 0;
                Param[10]           = new SqlParameter("@pErrorCode", SqlDbType.NVarChar, 200);
                Param[10].Value     = "";
                Param[10].Direction = ParameterDirection.Output;

                // var result1 = contextWIM.Database.SqlQuery<dynamic>("p_GetUsersLocationForADate @pOrganizationGUID,@pDate,@pStartTime, @pEndTime, @pDuration,@pRegionGUID,@pTerritoryGUID,@pLatitude,@pLongitude,@pSearchWithinZoneArea,@pSearch,@pErrorCode", Param).ToList();

                SqlParameter[] sqlParam = new SqlParameter[12];
                sqlParam[0]            = new SqlParameter("@pSkill", SqlDbType.NVarChar);
                sqlParam[0].Value      = "";
                sqlParam[1]            = new SqlParameter("@pDate", SqlDbType.Date);
                sqlParam[1].Value      = DateTime.UtcNow;
                sqlParam[2]            = new SqlParameter("@pStartTime", SqlDbType.Time);
                sqlParam[2].Value      = DateTime.UtcNow.TimeOfDay;
                sqlParam[3]            = new SqlParameter("@pEndTime", SqlDbType.Time);
                sqlParam[3].Value      = DateTime.UtcNow.TimeOfDay;
                sqlParam[4]            = new SqlParameter("@pDuration", SqlDbType.Float);
                sqlParam[4].Value      = 230;
                sqlParam[5]            = new SqlParameter("@pRegionGUID", SqlDbType.UniqueIdentifier);
                sqlParam[5].Value      = DBNull.Value;
                sqlParam[6]            = new SqlParameter("@pTerritoryGUID", SqlDbType.UniqueIdentifier);
                sqlParam[6].Value      = DBNull.Value;
                sqlParam[7]            = new SqlParameter("@pLatitude", SqlDbType.Float);
                sqlParam[7].Value      = 0;
                sqlParam[8]            = new SqlParameter("@pLongitude", SqlDbType.Float);
                sqlParam[8].Value      = 0;
                sqlParam[9]            = new SqlParameter("@pSearchWithinZoneArea", SqlDbType.Bit);
                sqlParam[9].Value      = 0;
                sqlParam[10]           = new SqlParameter("@pSearch", SqlDbType.Bit);
                sqlParam[10].Value     = 0;
                sqlParam[11]           = new SqlParameter("@pErrorCode", SqlDbType.NVarChar, 200);
                sqlParam[11].Value     = "";
                sqlParam[11].Direction = ParameterDirection.Output;

                // var result = contextWIM.Database.SqlQuery<dynamic>("p_GetUsersAvailability @pSkill,@pDate,@pStartTime, @pEndTime, @pDuration,@pRegionGUID,@pTerritoryGUID,@pLatitude,@pLongitude,@pSearchWithinZoneArea,@pSearch,@pErrorCode", sqlParam).ToList();
                lresponse = _IJobRepository.GetRouteUsers(sqlParam, Param);
                return(lResponse);
            }
            catch (Exception exception)
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        public GetRouteUserResponse GetRouteUsers(GetRouteUserRequest GetRouteUserRequest)
        {
            GetRouteUserResponse lresponse = new GetRouteUserResponse();
            IJobRepository _IJobRepository;
            _IJobRepository = new JobRepository(new WorkersInMotionDB());
            //lresponse = _IJobRepository.GetRouteUsers(GetRouteUserRequest);
            //return lresponse;
            try
            {
                GetRouteUserResponse lResponse = new GetRouteUserResponse();

                SqlParameter[] Param = new SqlParameter[12];
                Param[11] = new SqlParameter("@pOrganizationGUID", SqlDbType.UniqueIdentifier);
                Param[11].Value = DBNull.Value;
                Param[0] = new SqlParameter("@pDate", SqlDbType.Date);
                Param[0].Value = DateTime.UtcNow;
                Param[1] = new SqlParameter("@pStartTime", SqlDbType.Time);
                Param[1].Value = DateTime.UtcNow.TimeOfDay;
                Param[2] = new SqlParameter("@pEndTime", SqlDbType.Time);
                Param[2].Value = DateTime.UtcNow.TimeOfDay;
                Param[3] = new SqlParameter("@pDuration", SqlDbType.Float);
                Param[3].Value = 230;
                Param[4] = new SqlParameter("@pRegionGUID", SqlDbType.UniqueIdentifier);
                Param[4].Value = DBNull.Value;
                Param[5] = new SqlParameter("@pTerritoryGUID", SqlDbType.UniqueIdentifier);
                Param[5].Value = DBNull.Value;
                Param[6] = new SqlParameter("@pLatitude", SqlDbType.Float);
                Param[6].Value = 0;
                Param[7] = new SqlParameter("@pLongitude", SqlDbType.Float);
                Param[7].Value = 0;
                Param[8] = new SqlParameter("@pSearchWithinZoneArea", SqlDbType.Bit);
                Param[8].Value = 0;
                Param[9] = new SqlParameter("@pSearch", SqlDbType.Bit);
                Param[9].Value = 0;
                Param[10] = new SqlParameter("@pErrorCode", SqlDbType.NVarChar, 200);
                Param[10].Value = "";
                Param[10].Direction = ParameterDirection.Output;

                // var result1 = contextWIM.Database.SqlQuery<dynamic>("p_GetUsersLocationForADate @pOrganizationGUID,@pDate,@pStartTime, @pEndTime, @pDuration,@pRegionGUID,@pTerritoryGUID,@pLatitude,@pLongitude,@pSearchWithinZoneArea,@pSearch,@pErrorCode", Param).ToList();

                SqlParameter[] sqlParam = new SqlParameter[12];
                sqlParam[0] = new SqlParameter("@pSkill", SqlDbType.NVarChar);
                sqlParam[0].Value = "";
                sqlParam[1] = new SqlParameter("@pDate", SqlDbType.Date);
                sqlParam[1].Value = DateTime.UtcNow;
                sqlParam[2] = new SqlParameter("@pStartTime", SqlDbType.Time);
                sqlParam[2].Value = DateTime.UtcNow.TimeOfDay;
                sqlParam[3] = new SqlParameter("@pEndTime", SqlDbType.Time);
                sqlParam[3].Value = DateTime.UtcNow.TimeOfDay;
                sqlParam[4] = new SqlParameter("@pDuration", SqlDbType.Float);
                sqlParam[4].Value = 230;
                sqlParam[5] = new SqlParameter("@pRegionGUID", SqlDbType.UniqueIdentifier);
                sqlParam[5].Value = DBNull.Value;
                sqlParam[6] = new SqlParameter("@pTerritoryGUID", SqlDbType.UniqueIdentifier);
                sqlParam[6].Value = DBNull.Value;
                sqlParam[7] = new SqlParameter("@pLatitude", SqlDbType.Float);
                sqlParam[7].Value = 0;
                sqlParam[8] = new SqlParameter("@pLongitude", SqlDbType.Float);
                sqlParam[8].Value = 0;
                sqlParam[9] = new SqlParameter("@pSearchWithinZoneArea", SqlDbType.Bit);
                sqlParam[9].Value = 0;
                sqlParam[10] = new SqlParameter("@pSearch", SqlDbType.Bit);
                sqlParam[10].Value = 0;
                sqlParam[11] = new SqlParameter("@pErrorCode", SqlDbType.NVarChar, 200);
                sqlParam[11].Value = "";
                sqlParam[11].Direction = ParameterDirection.Output;

                // var result = contextWIM.Database.SqlQuery<dynamic>("p_GetUsersAvailability @pSkill,@pDate,@pStartTime, @pEndTime, @pDuration,@pRegionGUID,@pTerritoryGUID,@pLatitude,@pLongitude,@pSearchWithinZoneArea,@pSearch,@pErrorCode", sqlParam).ToList();
                lresponse = _IJobRepository.GetRouteUsers(sqlParam, Param);
                return lResponse;
            }
            catch (Exception exception)
            {
                return null;
            }
        }