コード例 #1
0
        public HttpResponseMessage Login([FromBody]LoginRequest pLoginRequest)
        {

            Logger.Debug("Inside UMController- Login");
            //Logger.Debug("Request: " + new JavaScriptSerializer().Serialize(pLoginRequest));
            LoginResponse LoginResponse = new LoginResponse();
            ErrorResponse error = new ErrorResponse();
            var response = new Dictionary<string, object>();

            //error.ErrorCode = HttpStatusCode.OK;
            //// error.ErrorMessage = "Unable to Get User Details";
            //error.ErrorMessage = "Checking Prabhu.";
            //response.Add("ErrorResponse", error);
            //return Request.CreateResponse(HttpStatusCode.OK, response);
            try
            {
                //int b = 0;
                //int a = 1 / b;
                //pLoginRequest.Cred.UserName = Encoding.UTF8.GetString(Convert.FromBase64String(pLoginRequest.Cred.UserName));
                //pLoginRequest.Cred.Password = Encoding.UTF8.GetString(Convert.FromBase64String(pLoginRequest.Cred.Password));
                string[] lCred = Encoding.UTF8.GetString(Convert.FromBase64String(pLoginRequest.Cred)).Split(':');
                if (lCred.Count() > 1)
                {
                    pLoginRequest.UserName = lCred[0];
                    pLoginRequest.Password = lCred[1];
                }
                pLoginRequest.LoginType = eLoginType.DeviceLogin;
                LoginResponse = _IUMServer.Login(pLoginRequest);
                if (LoginResponse != null)
                {
                    Logger.Debug("Response: " + new JavaScriptSerializer().Serialize(LoginResponse));
                    response.Add("LoginResponse", LoginResponse);
                    return Request.CreateResponse(HttpStatusCode.OK, response);
                }
                else
                {
                    error.ErrorCode = HttpStatusCode.PreconditionFailed;
                    // error.ErrorMessage = "Unable to Get User Details";
                    error.ErrorMessage = "Invalid Username and Password." + pLoginRequest.UserName + ":" + pLoginRequest.Password;
                    response.Add("ErrorResponse", error);
                    return Request.CreateResponse(HttpStatusCode.PreconditionFailed, 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);
            }
        }
コード例 #2
0
        public LoginResponse Login(LoginRequest pLoginRequest)
        {
            LoginResponse loginResponse = new LoginResponse();
            IUserRepository _IUserRepository;
            _IUserRepository = new UserRepository(new WorkersInMotionDB());

            //UserRepository lUserRepository = new UserRepository();


            // MasterLogin lMasterLogin = _IUserRepository.UserLogin(pLoginRequest.UserName, pLoginRequest.Password, pLoginRequest.IpAddress, pLoginRequest.Phone, pLoginRequest.DeviceID);
            //if (lMasterLogin != null && lMasterLogin.UserGUID != null && lMasterLogin.UserGUID != Guid.Empty)
            //{
            //    loginResponse.MasterLogin = lMasterLogin;
            //}
            return loginResponse;
        }
コード例 #3
0
 public HttpResponseMessage Login([FromBody]LoginRequest pLoginRequest)
 {
     log4net.Config.XmlConfigurator.Configure();
     ILog log = LogManager.GetLogger("Inside Login Controller- Login");
     LoginResponse loginResponse = new LoginResponse();
     try
     {
         loginResponse = _ILoginServer.Login(pLoginRequest);
         return Request.CreateResponse(HttpStatusCode.OK, loginResponse);
     }
     catch (Exception ex)
     {
         log.Debug(ex.Message);
         ErrorResponse error = new ErrorResponse();
         error.ErrorCode = HttpStatusCode.InternalServerError;
         error.ErrorMessage = "Failure";
         return Request.CreateResponse(HttpStatusCode.InternalServerError, error);
     }
 }