public JsonResult <StationRespObj> AuthorizeStationAccess(StationRegObj appRegObj)
        {
            var resp = new StationRespObj
            {
                ResponseStatus = new ResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new ResponseMessage
                    {
                        FriendlyMessage  = "Unable to process your registration. Please try later",
                        TechnicalMessage = "Invalid / Empty Registration Object"
                    }
                }
            };

            try
            {
                if (appRegObj == null)
                {
                    return(Json(resp));
                }

                resp = ServiceProvider.Instance().GetClientStationServices().RegisterStation(appRegObj);
                return(Json(resp));
            }
            catch (Exception ex)
            {
                resp.ResponseStatus.Message.FriendlyMessage  = "Unable to process your registration. Please try later";
                resp.ResponseStatus.Message.TechnicalMessage = "Error: " + ex.Message;
                return(Json(resp));
            }
        }
Example #2
0
 public StationRespObj RegisterStation(StationRegObj corporateInfo)
 {
     try
     {
         return(_clientStationRepository.RegisterStation(corporateInfo));
     }
     catch (Exception ex)
     {
         BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
         return(new StationRespObj
         {
             ResponseStatus = new ResponseStatus
             {
                 IsSuccessful = false,
                 Message = new ResponseMessage
                 {
                     FriendlyMessage = "Unable to complete your request! Please try again later",
                     TechnicalMessage = "Unable to complete your request! Please try again later"
                 },
             }
         });
     }
 }
Example #3
0
        public StationRespObj RegisterStation(StationRegObj corporateInfo)
        {
            var response = new StationRespObj
            {
                ResponseStatus = new ResponseStatus
                {
                    Message      = new ResponseMessage(),
                    IsSuccessful = false,
                }
            };

            try
            {
                List <ValidationResult> valResults;
                if (!EntityValidatorHelper.Validate(corporateInfo, out valResults))
                {
                    var errorDetail = new StringBuilder();
                    if (!valResults.IsNullOrEmpty())
                    {
                        errorDetail.AppendLine("Following error occurred:");
                        valResults.ForEachx(m => errorDetail.AppendLine(m.ErrorMessage));
                    }
                    else
                    {
                        errorDetail.AppendLine("Validation error occurred! Please check all supplied parameters and try again");
                    }
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = errorDetail.ToString();
                    return(response);
                }

                var station = GetStation(corporateInfo.StationId);
                if (station == null || string.IsNullOrEmpty(station.StationName) || station.ClientStationId < 1)
                {
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Invalid Station Key";
                    return(response);
                }

                //if (string.Compare(station.StationName.Trim(), corporateInfo.StationName.Trim(), StringComparison.CurrentCultureIgnoreCase) != 0)
                //{
                //    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Incorrect Station Name";
                //    return response;
                //}

                if (string.Compare(station.StationId.Trim(), corporateInfo.StationId.Trim(), StringComparison.CurrentCultureIgnoreCase) != 0)
                {
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Incorrect Station ID";
                    return(response);
                }

                string msg;
                var    opRegId = GenerateSIN(out msg, station.StationId, station.OrganizationId);
                if (string.IsNullOrEmpty(opRegId))
                {
                    response.ResponseStatus.Message.FriendlyMessage  = "Unable to generate Operator ID";
                    response.ResponseStatus.Message.TechnicalMessage = "Unable to generate Operator ID";
                    return(response);
                }


                if (IsDuplicate(station.OrganizationId, corporateInfo.UserName, corporateInfo.Email, opRegId, corporateInfo.MobileNumber, out msg))
                {
                    response.ResponseStatus.Message.FriendlyMessage  = msg;
                    response.ResponseStatus.Message.TechnicalMessage = msg;
                    response.ResponseStatus.IsSuccessful             = false;
                    return(response);
                }

                var helper = new Enroller
                {
                    EnrollerRegId = opRegId,
                    //OrganizationId = station.OrganizationId,
                    ClientStationId     = station.ClientStationId,
                    DeviceIP            = corporateInfo.DeviceIP,
                    DeviceId            = corporateInfo.DeviceId,
                    FirstName           = corporateInfo.FirstName,
                    Surname             = corporateInfo.Surname,
                    UserName            = corporateInfo.UserName,
                    Email               = corporateInfo.Email,
                    MobileNumber        = corporateInfo.MobileNumber,
                    Status              = 1,
                    RegisteredByUserId  = 1,
                    TimeStampRegistered = DateTime.Now
                };

                //if (station.Status == 2)
                //{
                //    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "This Station is already configured and used";
                //    return response;
                //}

                //station.DeviceId = corporateInfo.DeviceId;
                //station.DeviceIP = corporateInfo.DeviceIP;
                //station.Status = 2;

                //var processedClientEnrollerStation = _enrollerRepository.Add(helper);
                var retId = new EnrollerRepository().AddEnroller(helper, out msg);
                _uoWork.SaveChanges();

                if (retId < 1)
                {
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Process Failed! Unable to process hosting information";
                    return(response);
                }


                response.APIAccessKey    = station.APIAccessKey;
                response.ClientStationId = station.ClientStationId;
                response.DeviceId        = corporateInfo.DeviceId;
                response.Surname         = corporateInfo.Surname;
                response.FirstName       = corporateInfo.FirstName;
                response.Email           = corporateInfo.Email;
                response.MobileNumber    = corporateInfo.MobileNumber;
                //response.OrganizationId = station.OrganizationId;
                response.EnrollerRegId = opRegId;
                response.EnrollerId    = retId;
                response.StationId     = station.StationId;
                response.StationName   = station.StationName;
                response.UserName      = corporateInfo.UserName;
                response.ResponseStatus.IsSuccessful = true;
                response.ResponseStatus.ReturnedId   = retId;
                return(response);


                //public string APIAccessKey;
                //public string DeviceId;
                //public string StationId;
                //public long ClientStationId;
                //public long EnrollerId;
                //public long OrganizationId;
                //public string EnrollerRegId;
                //public string Surname;
                //public string FirstName;
                //public string UserName;
                //public string MobileNumber;
                //public string Email;
            }
            catch (Exception ex)
            {
                response.ResponseStatus.Message.FriendlyMessage  = "Processing Error Occurred! Please try again later " + ex.Message;
                response.ResponseStatus.Message.TechnicalMessage = ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(response);
            }
        }