Exemplo n.º 1
0
 internal Enroller GetLastEnrollerRegistered(long clientStationId)
 {
     try
     {
         //var myItems = _enrollerRepository.GetAll(x => x.OrganizationId == organizationId && x.ClientStationId == clientStationId).OrderByDescending(o => o.EnrollerId).ToList();
         var myItems =
             _enrollerRepository.GetAll(
                 x => x.ClientStationId == clientStationId)
             .OrderByDescending(o => o.EnrollerId)
             .ToList();
         if (!myItems.Any())
         {
             return(new Enroller());
         }
         return(myItems[0]);
     }
     catch (Exception ex)
     {
         BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
         return(new Enroller());
     }
 }
Exemplo n.º 2
0
        public static List <State> GetStates()
        {
            try
            {
                var connection = ConfigurationManager.ConnectionStrings["DataKioskEntities"].ConnectionString;
                if (string.IsNullOrEmpty(connection))
                {
                    return(new List <State>());
                }

                using (var sqlConnection = new SqlConnection(connection))
                {
                    sqlConnection.Open();
                    var sqlBuilder = new StringBuilder();

                    sqlBuilder.AppendFormat("SELECT * FROM \"EnrollKiosk\".\"State\" ");
                    string sql     = sqlBuilder.ToString();
                    var    command = new SqlCommand(sql, sqlConnection);
                    var    dr      = command.ExecuteReader();
                    var    items   = new List <State>();
                    while (dr.Read())
                    {
                        var item = new State();
                        {
                            item.StateId = dr.GetInt32(dr.GetOrdinal("StateId"));
                            item.Name    = dr.GetString(dr.GetOrdinal("Name"));
                        };
                        items.Add(item);
                    }
                    sqlConnection.Close();
                    return(items);
                }
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(new List <State>());
            }
        }
Exemplo n.º 3
0
        public static UserProfileInfo GetUserProfile(long userId, out string msg)
        {
            try
            {
                var user = PortalUser.GetUser(userId);
                if (user == null || user.UserId < 1)
                {
                    msg = "User information not found!";
                    return(null);
                }

                msg = "";
                var myProfileDetail = new UserProfileInfo
                {
                    BBPin              = "",
                    DateOfBirth        = "",
                    FirstName          = user.FirstName,
                    FaceBookId         = "",
                    Email              = user.Email,
                    GooglePlusId       = "",
                    LandPhone          = "",
                    LastName           = user.Surname,
                    MaritalStatus      = MaritalStatus.None,
                    MobileNo           = user.MobileNumber,
                    ResidentialAddress = "",
                    TwitterId          = "",
                    SexId              = user.SexId,
                    UserId             = userId,
                };
                return(myProfileDetail);
            }
            catch (Exception ex)
            {
                msg = "Error: " + ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }
Exemplo n.º 4
0
        public bool ValidateEnroller(Enroller thisUser, string password, out string msg)
        {
            try
            {
                if (thisUser == null)
                {
                    msg = "Invalid / Empty Enroller Information";
                    return(false);
                }

                var flag = Crypto.VerifyHashedPassword(thisUser.UserCode, password);
                //RecordLoginEvent(thisUser.UserProfileId, flag && thisUser.IsApproved);
                if (!flag)
                {
                    msg = "Invalid Username, Password or both";
                    return(false);
                }

                //if (!thisUser.IsApproved)
                //{
                //    if (thisUser.IsLockedOut)
                //    {
                //        msg = "This user is currently locked out due to several wrong passwords";
                //        return false;
                //    }
                //    msg = "This user is currently disabled by the admin";
                //    return false;
                //}
                msg = "";
                return(true);
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                msg = "Unable to validate user";
                return(false);
            }
        }
Exemplo n.º 5
0
        public ActionResult GetStationByOrganizationId(int orgId)
        {
            try
            {
                var add   = new KeyContent(0, "Select a Station");
                var items = CustomManager.GetStationByOrganizationId(orgId);

                if (!items.Any())
                {
                    return(Json(new List <KeyContent> {
                        add
                    }, JsonRequestBehavior.AllowGet));
                }
                var jsonitem = items.Select(o => new KeyContent(o.ClientStationId, o.StationName)).ToList();
                jsonitem.Insert(0, add);
                return(Json(jsonitem, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <KeyContent>(), JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 6
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"
                 },
             }
         });
     }
 }
Exemplo n.º 7
0
        public bool IsInRole(string role)
        {
            try
            {
                if (string.IsNullOrEmpty(role))
                {
                    throw new Exception("Role Name is empty or invalid");
                }
                //if (role == "*") { return true; }
                if (_roles != null && _roles.Length > 0)
                {
                    var check = _roles.Contains(role);
                    return(check);
                }

                return(true);    //return new RoleRepository().IsUserInRole(Identity.Name, role.Trim());
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                throw new Exception("Unknown Error Occured");
            }
        }
Exemplo n.º 8
0
 public StationRespObj RemoteLogin(RemoteStationLoginObj loginObj)
 {
     try
     {
         return(_enrollerRepository.RemoteLogin(loginObj));
     }
     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"
                 },
             }
         });
     }
 }
Exemplo n.º 9
0
 private void ProcessLookUpFromFiles(DataKioskEntities context)
 {
     try
     {
         var basePath = GetBasePath();
         if (string.IsNullOrEmpty(basePath))
         {
             return;
         }
         if (!context.LocalAreas.Any())
         {
             var stateLgas = GetFromResources(basePath + "\\SqlFiles\\lga_lookups2.sql");
             if (!string.IsNullOrEmpty(stateLgas))
             {
                 context.Database.ExecuteSqlCommand(stateLgas);
             }
         }
     }
     catch (Exception ex)
     {
         BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
     }
 }
Exemplo n.º 10
0
        public ClientStation ValidateClientAccess(string stationId, string stationName, string accessKey, out string msg)
        {
            try
            {
                var stationInfo = GetStation(stationId);
                if (stationInfo == null || stationInfo.ClientStationId < 1)
                {
                    msg = "Unregistered / Invalid Authorization Access";
                    return(null);
                }
                if (
                    string.Compare(stationInfo.APIAccessKey.Trim(), accessKey.Trim(),
                                   StringComparison.CurrentCultureIgnoreCase) != 0 ||
                    string.Compare(stationInfo.StationId.Trim(), stationId.Trim(),
                                   StringComparison.CurrentCultureIgnoreCase) != 0 ||
                    string.Compare(stationInfo.StationName.Trim(), stationName.Trim(),
                                   StringComparison.CurrentCultureIgnoreCase) != 0)
                {
                    msg = "Unregistered / Invalid Authorization Access";
                    return(null);
                }
                if (stationInfo.Status != 2)
                {
                    msg = "Unauthorized Access!";
                    return(null);
                }

                msg = "";
                return(stationInfo);
            }
            catch (Exception ex)
            {
                msg = "Unable to validate Station Access";
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }
Exemplo n.º 11
0
        public ActionResult GetLocalAreaByStateId(int stateId)
        {
            try
            {
                var add   = new KeyContent(0, "Select a Local Government");
                var items = CustomManager.GetLocalAreaByStateId(stateId);

                //var items = new List<LocalArea>
                //{
                //    new LocalArea
                //    {
                //        LocalAreaId = 1,
                //        Name = "Ogba/Egbema/Ndoni"
                //    },
                //    new LocalArea
                //    {
                //        LocalAreaId = 2,
                //        Name = "Omumma"
                //    },
                //};

                if (!items.Any())
                {
                    return(Json(new List <KeyContent> {
                        add
                    }, JsonRequestBehavior.AllowGet));
                }
                var jsonitem = items.Select(o => new KeyContent(o.LocalAreaId, o.Name)).ToList();
                jsonitem.Insert(0, add);
                return(Json(jsonitem, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <KeyContent>(), JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 12
0
        public BulkBeneficiaryRegResponseObj AddBulkBeneficiary(BulkBeneficiaryRegObj beneficiaryRegObjs, UploadClientStation station)
        {
            var response = new BulkBeneficiaryRegResponseObj
            {
                MainStatus = new ResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new ResponseMessage()
                },
                BeneficiaryRegResponses = new List <BeneficiaryRegResponseObj>()
            };

            try
            {
                return(_beneficiaryRepository.AddBulkBeneficiary(beneficiaryRegObjs, station));
            }
            catch (Exception ex)
            {
                response.MainStatus.Message.FriendlyMessage  = "Processing Error Occurred! Please try again later";
                response.MainStatus.Message.TechnicalMessage = "Error: " + ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(response);
            }
        }
Exemplo n.º 13
0
        //
        // GET: /PortalUser/
        //[EppSecurity_Authorize]
        public ActionResult Index()
        {
            ViewBag.Reply    = Session["Reply"] as string;
            ViewBag.Error    = Session["Error"] as string;
            Session["Reply"] = "";
            Session["Error"] = "";

            try
            {
                var items = PortalUser.GetUserList() ?? new List <RegisteredUserReportObj>();
                if (!items.Any())
                {
                    ViewBag.Error = "No Registered User Info Found!";
                    return(View(new List <RegisteredUserReportObj>()));
                }
                if (!User.IsInRole("Super Admin"))
                {
                    items = items.FindAll(m => m.RoleId != 1);
                    if (!items.Any())
                    {
                        ViewBag.Error = "No User Info Found!";
                        return(View(new List <RegisteredUserReportObj>()));
                    }
                }
                var users = items.Where(item => !item.MyRole.Contains("Super Admin")).ToList();

                Session["_portalUsersInfos"] = users;
                return(View(users));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(View(new List <RegisteredUserReportObj>()));
            }
        }
Exemplo n.º 14
0
 internal bool RoleExists(string roleName, out string msg)
 {
     try
     {
         msg = "";
         return
             (GetRoles().Count(
                  m =>
                  string.Compare(m.Name.Trim(), roleName.Trim(), StringComparison.CurrentCultureIgnoreCase) ==
                  0) > 0);
     }
     catch (DbEntityValidationException ex)
     {
         BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
         msg = ex.Message;
         return(false);
     }
     catch (Exception ex)
     {
         BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
         msg = ex.Message;
         return(false);
     }
 }
Exemplo n.º 15
0
 internal string[] GetUsersInRole(string rolename, string usernameToMatch, out string msg)
 {
     try
     {
         msg = "";
         var userIds = new UserRoleRepository().GetUserRolesByRoleId(GetRoles().Where(p => String.Compare(p.Name.Trim(), rolename.Trim(), StringComparison.CurrentCultureIgnoreCase) == 0).ToList()[0].RoleId).Select(m => m.UserId).ToList();
         if (!userIds.Any())
         {
             return(null);
         }
         return(new UserRepository().GetUsers().Where(m => userIds.Contains(m.UserId) && m.Username.Contains(usernameToMatch.Trim())).Select(q => q.Username).ToArray());
     }
     catch (DbEntityValidationException ex)
     {
         msg = ex.Message;
         BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
         return(null);
     }
     catch (Exception ex)
     {
         msg = ex.Message;
         return(null);
     }
 }
Exemplo n.º 16
0
        private bool IsDuplicate(string roleName, out string msg)
        {
            try
            {
                var sql1 =
                    String.Format(
                        "Select * FROM \"EnrollKiosk\".\"Role\"  WHERE lower(\"Name\") = lower('{0}')", roleName.Replace("'", "''"));

                var check = _repository.RepositoryContext().Database.SqlQuery <Role>(sql1).ToList();
                msg = "";
                if (check.IsNullOrEmpty())
                {
                    return(false);
                }
                msg = "Duplicate Error! Item already exist";
                return(true);
            }
            catch (Exception ex)
            {
                msg = "Error: " + ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(true);
            }
        }
Exemplo n.º 17
0
        public static string PrepareImagePath(string org, string stationId, string enrollerId, out string msg)
        {
            try
            {
                var year     = DateTime.Now.Year.ToString(CultureInfo.InvariantCulture);
                var imgName  = DateTime.Now.Ticks;
                var fileName = imgName + ".jpeg";

                #region Folder Structure For Storage

                #region Local

                //var stationKey = (ServiceProvider.Instance().GetStationInfoService().GetStationInfos() ?? new List<StationInfo>())[0].StationKey;
                //var username = Utils.CurrentUser.UserName;

                //var fileName = imgName;
                ////TODO:Resourse path
                //string folderPath = "/Station-" + stationKey + "/" + username + "/" + year + "/" + "/Image/";
                //var imageResPath = folderPath + fileName;
                //var dir = InternetCon.GetBasePath() + ConfigurationManager.AppSettings["BioResource"];
                //var imagePath = Path.GetFullPath(dir + imageResPath);
                //if (!Directory.Exists(@dir + @folderPath))
                //{
                //    try
                //    {
                //        Directory.CreateDirectory(@dir + @folderPath);
                //    }
                //    catch (Exception ex)
                //    {
                //        ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                //        msg = ex.Message;
                //        return;
                //    }
                //}
                //while (File.Exists(imagePath))
                //{
                //    fileName = DateTime.Now.Ticks + ".jpeg";
                //    imageResPath = folderPath + fileName;
                //    imagePath = Path.GetFullPath(dir + imageResPath);
                //}


                #endregion


                #region Remote

                org        = org.Replace(" ", "_");
                stationId  = stationId.Replace(" ", "_");
                enrollerId = enrollerId.Replace(" ", "_");
                string resPath      = "~/KioskResources/";
                string folderPath   = org + "/" + stationId + "/" + enrollerId + "/" + year + "/" + "/Image/";
                var    imageResPath = folderPath + fileName;

                //var imagePath = Path.GetFullPath(resPath + imageResPath);
                //var dir = InternetCon.GetBasePath() + ConfigurationManager.AppSettings["BioResource"];

                var dirPath   = HostingEnvironment.MapPath(resPath + folderPath);
                var imagePath = HostingEnvironment.MapPath(resPath + imageResPath);
                if (@dirPath != null && !Directory.Exists(@dirPath))
                {
                    try
                    {
                        Directory.CreateDirectory(@dirPath);
                    }
                    catch (Exception ex)
                    {
                        BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                        msg = ex.Message;
                        return(null);
                    }
                }
                while (File.Exists(imagePath))
                {
                    fileName     = DateTime.Now.Ticks + ".jpeg";
                    imageResPath = folderPath + fileName;
                    imagePath    = HostingEnvironment.MapPath(resPath + imageResPath);
                    //imagePath = Path.GetFullPath(@dirPath + imageResPath);
                }


                //if (dirPath == null || !Directory.Exists(dirPath))
                //{
                //    var newDirPath = Directory.CreateDirectory(resPath);
                //    logoPath = newDirPath.ToString();
                //}

                #endregion


                #endregion

                if (imagePath == null)
                {
                    msg = "Path not exist";
                    return(null);
                }

                //image.Save(imagePath, ImageFormat.Jpeg);
                msg = "";
                return(imagePath);
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                msg = ex.Message;
                return(null);
            }
        }
Exemplo n.º 18
0
        public ActionResult ModifyUser(string id)
        {
            ViewBag.Errors        = Session["EditErrors"] as List <string>;
            ViewBag.Error         = Session["EditError"] as string;
            Session["EditErrors"] = null;
            Session["EditError"]  = null;

            try
            {
                long userId;
                Int64.TryParse(id, out userId);

                if (userId < 1)
                {
                    Session["Error"] = "Invalid selection";
                    //ViewBag.Error = "Invalid selection";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                if (Session["_portalUsersInfos"] == null)
                {
                    Session["Error"] = "Your session has expired! Please try again later";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }
                var users = Session["_portalUsersInfos"] as List <RegisteredUserReportObj>;
                if (users == null || !users.Any())
                {
                    //ViewBag.Error = "Your session has expired! Please try again later";
                    Session["Error"] = "Your session has expired! Please try again later";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                var user = users.Find(m => m.UserId == userId);
                if (user == null || user.UserId < 1)
                {
                    //ViewBag.Error = "Your session has expired! Please try again later";
                    Session["Error"] = "Your session has expired! Please try again later";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                var helper = new AuthPortalUser
                {
                    ConfirmPassword             = "",
                    Email                       = user.Email,
                    FailedPasswordCount         = user.FailedPasswordCount,
                    FirstName                   = user.FirstName,
                    IsApproved                  = user.IsApproved,
                    IsLockedOut                 = user.IsLockedOut,
                    LastName                    = user.Surname,
                    LastLockedOutTimeStamp      = user.LastLockedOutTimeStamp,
                    LastLoginTimeStamp          = user.LastLoginTimeStamp,
                    LastPasswordChangeTimeStamp = user.PasswordChangeTimeStamp,
                    MobileNo                    = user.MobileNumber,
                    //MyRoleIds = user.MyRoleIds,
                    //MyRoles = portalUser.MyRoles,
                    OrganizationId = user.OrganizationId,
                    UserTypeId     = user.UserTypeId,
                    RoleId         = user.RoleId,
                    UserName       = user.Username,
                    Password       = user.Password,
                    //SelectedRoles = user.SelectedRoles,
                    SexId = user.SexId,
                    TimeStampRegistered = user.TimeStampRegistered,
                    UserId = user.UserId,
                    //Roles = portalUser.MyRoleIds.ToList(),

                    Action = "ModifyUser"
                };

                Session["_selectedPortalUser"] = user;
                return(View("AddUser", helper));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }
Exemplo n.º 19
0
        void Application_AuthenticateRequest()
        {
            var myCookie     = FormsAuthentication.FormsCookieName;
            var myAuthCookie = Context.Request.Cookies[myCookie];

            if (null == myAuthCookie)
            {
                return;
            }

            FormsAuthenticationTicket myAuthTicket;

            try
            {
                myAuthTicket = FormsAuthentication.Decrypt(myAuthCookie.Value);
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return;
            }

            if (null == myAuthTicket)
            {
                return;
            }


            var userDataSplit = myAuthTicket.UserData.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            var size          = userDataSplit.Length;

            //if (!userDataSplit.Any() || userDataSplit.Length != 3)
            //if (!userDataSplit.Any())
            //{
            //    if ((size != 3 || size != 4))
            //    {
            //        return;
            //    }
            //}


            if (!userDataSplit.Any() || userDataSplit.Length != 3)
            {
                return;
            }

            if (!DataCheck.IsNumeric(userDataSplit[0].Trim()))
            {
                return;
            }

            //switch (size)
            //{
            //    case 3:
            //        var roles = userDataSplit[2].Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            //        var id = new FormsIdentity(myAuthTicket);
            //        //IPrincipal principal = new StcPrincipal(id, roles);
            //        //Context.User = principal;
            //        break;

            //    case 4:
            //        var clientRoles = userDataSplit[3].Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            //        var clientId = new FormsIdentity(myAuthTicket);
            //        //IPrincipal clientPrincipal = new StcPrincipal(clientId, clientRoles);
            //        //Context.User = clientPrincipal;
            //        break;
            //}

            var roles = userDataSplit[2].Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            //var role = userDataSplit[2];

            var        id        = new FormsIdentity(myAuthTicket);
            IPrincipal principal = new StcPrincipal(id, roles);

            Context.User = principal;
        }
Exemplo n.º 20
0
        public ActionResult ModifyOrganization(string id, OrganizationRegObj model)
        {
            try
            {
                long organizationId;
                Int64.TryParse(id, out organizationId);

                if (organizationId < 1)
                {
                    ViewBag.Error = "Invalid selection";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                if (model == null)
                {
                    Session["Error"] = "Your session has expired! Please, re-login";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                if (Session["_selectedOrganization"] == null)
                {
                    Session["Error"] = "Your session has expired! Please, re-login";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                var thisOrganization = Session["_selectedOrganization"] as RegisteredOrganizationReportObj;
                if (thisOrganization == null || thisOrganization.OrganizationId < 1)
                {
                    Session["Error"] = "Your session has expired! Please, re-login";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                ModelState.Clear();
                if (!ModelState.IsValid)
                {
                    ViewBag.Error = "Please fill all required fields";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                var helper = new Organization
                {
                    OrganizationId     = thisOrganization.OrganizationId,
                    Name               = model.Name,
                    PhoneNumber        = model.PhoneNumber,
                    Email              = model.Email,
                    Address            = model.Address,
                    RegisteredByUserId = thisOrganization.RegisteredByUserId,
                    Status             = model.Status
                };

                var retId = ServiceProvider.Instance().GetOrganizationServices().UpdateOrganization(helper);
                if (retId == null)
                {
                    Session["EditError"] = "Unable to update this organization";
                    return(Redirect(Url.RouteUrl(new { action = "ModifyOrganization" })));
                }

                if (!retId.IsSuccessful)
                {
                    Session["EditError"] = string.IsNullOrEmpty(retId.Message.FriendlyMessage) ? "Unable to update this organization" : retId.Message.FriendlyMessage;
                    return(Redirect(Url.RouteUrl(new { action = "ModifyOrganization" })));

                    //Session["Error"] = string.IsNullOrEmpty(retId.Message.FriendlyMessage) ? "Unable to update this organization" : retId.Message.FriendlyMessage;
                    //return Redirect(Url.RouteUrl(new { action = "Index" }));
                }

                Session["_selectedOrganization"] = null;
                Session["Reply"] = "Organization information was updated successfully";
                return(Redirect(Url.RouteUrl(new { action = "Index" })));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }
Exemplo n.º 21
0
        public ActionResult ModifyUser(string id, AuthPortalUser model)
        {
            try
            {
                long userId;
                Int64.TryParse(id, out userId);

                if (userId < 1)
                {
                    ViewBag.Error = "Invalid selection";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                if (model == null)
                {
                    Session["Error"] = "Your session has expired! Please, re-login";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                if (Session["_selectedPortalUser"] == null)
                {
                    Session["Error"] = "Your session has expired! Please, re-login";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                var thisUser = Session["_selectedPortalUser"] as RegisteredUserReportObj;
                if (thisUser == null || thisUser.UserId < 1)
                {
                    Session["Error"] = "Your session has expired! Please, re-login";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                ModelState.Clear();
                if (!ModelState.IsValid)
                {
                    ViewBag.Error = "Please fill all required fields";
                    return(Redirect(Url.RouteUrl(new { action = "Index" })));
                }

                var helper = new UserRegistrationObj
                {
                    Password        = "******",
                    ConfirmPassword = "******",
                    Email           = model.Email,
                    FirstName       = model.FirstName,
                    Surname         = model.LastName,
                    MobileNumber    = model.MobileNo,
                    RoleId          = model.RoleId,
                    UserTypeId      = model.UserTypeId,
                    OrganizationId  = model.OrganizationId,
                    //MyRoleIds = model.MyRoleIds,
                    //MyRoles = selRoles.ToArray(),
                    Username = model.UserName,
                    //SelectedRoles = string.Join(";", selRoles),
                    Sex    = model.SexId,
                    UserId = thisUser.UserId,
                    //IsActive = model.IsApproved
                };

                var retId = PortalUser.UpdateUser(helper);
                if (retId == null)
                {
                    Session["EditError"] = "Unable to update this user";
                    return(Redirect(Url.RouteUrl(new { action = "ModifyUser" })));
                }

                if (!retId.IsSuccessful)
                {
                    Session["EditError"] = string.IsNullOrEmpty(retId.Message.FriendlyMessage) ? "Unable to update this user" : retId.Message.FriendlyMessage;
                    return(Redirect(Url.RouteUrl(new { action = "ModifyUser" })));

                    //Session["Error"] = string.IsNullOrEmpty(retId.Message.FriendlyMessage) ? "Unable to update this organization" : retId.Message.FriendlyMessage;
                    //return Redirect(Url.RouteUrl(new { action = "Index" }));
                }

                //if (retId == null)
                //{
                //    Session["Error"] = "Unable to complete your request! Please try again later";
                //    return Redirect(Url.RouteUrl(new { action = "Index" }));
                //}

                //if (!retId.IsSuccessful)
                //{
                //    Session["Error"] = string.IsNullOrEmpty(retId.Message.FriendlyMessage) ? "Unable to update this user" : retId.Message.FriendlyMessage;
                //    return Redirect(Url.RouteUrl(new { action = "Index" }));
                //}

                Session["_selectedPortalUser"] = null;
                Session["Reply"] = "User information was updated successfully";
                return(Redirect(Url.RouteUrl(new { action = "Index" })));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }
Exemplo n.º 22
0
        private bool doesBeneficiaryInfoExist(int surnameHashed, int dobHashed, int mobileHashed, int othernameHashed, int firstnameHashed, int sex, int calType, out string msg)
        {
            try
            {
                var sql = new StringBuilder();
                sql.Append(string.Format("SELECT * FROM \"EnrollKiosk\".\"Beneficiary\" WHERE 1 = 1"));

                if (Math.Abs(surnameHashed) > 0)
                {
                    sql.Append(string.Format(" AND \"SurnameHashed\" = {0}", surnameHashed));
                }

                if (Math.Abs(dobHashed) > 0)
                {
                    sql.Append(string.Format(" AND \"DateOfBirthHashed\" = {0}", dobHashed));
                }

                if (Math.Abs(mobileHashed) > 0)
                {
                    sql.Append(string.Format(" AND \"MobileNoHashed\" = {0}", mobileHashed));
                }

                if (Math.Abs(firstnameHashed) > 0)
                {
                    sql.Append(string.Format(" AND \"FirstNameHashed\" = {0}", firstnameHashed));
                }

                if (Math.Abs(othernameHashed) > 0)
                {
                    sql.Append(string.Format(" AND \"OtherNameHashed\" = {0}", othernameHashed));
                }

                if (sex > 0 && sex < 3)
                {
                    sql.Append(string.Format(" AND \"Sex\" = {0}", sex));
                }

                var retVal = _repository.RepositoryContext()
                             .Database.SqlQuery <Beneficiary>(sql.ToString()).ToList();
                if (retVal.IsNullOrEmpty())
                {
                    msg = "";
                    return(false);
                }
                if (calType == 2)
                {
                    if (retVal.Count == 1)
                    {
                        msg = "";
                        return(false);
                    }
                }
                msg = "";
                return(true);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(true);
            }
        }
Exemplo n.º 23
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);
            }
        }
Exemplo n.º 24
0
        public BulkBeneficiaryRegResponseObj AddBulkBeneficiary(BulkBeneficiaryRegObj beneficiaryRegObjs, UploadClientStation station)
        {
            var response = new BulkBeneficiaryRegResponseObj
            {
                MainStatus = new ResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new ResponseMessage
                    {
                        FriendlyMessage  = "",
                        TechnicalMessage = ""
                    }
                },
                BeneficiaryRegResponses = new List <BeneficiaryRegResponseObj>()
            };

            try
            {
                List <ValidationResult> valResults;
                if (!EntityValidatorHelper.Validate(beneficiaryRegObjs, 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.MainStatus.Message.FriendlyMessage = response.MainStatus.Message.TechnicalMessage = errorDetail.ToString();
                    return(response);
                }

                if (beneficiaryRegObjs.BeneficiaryRegObjs.IsNullOrEmpty())
                {
                    response.MainStatus.Message.FriendlyMessage  = "Data List is empty!";
                    response.MainStatus.Message.TechnicalMessage = "Data List is empty!";
                    return(response);
                }

                //var valSettings = new DataValidationSettingRepository().GetDataValidationSettings();
                //if (valSettings.IsNullOrEmpty())
                //{
                //    response.MainStatus.Message.FriendlyMessage = "Invalid Data Validation Setting";
                //    response.MainStatus.Message.TechnicalMessage = "Unable to retrieve Data Validation Parameters";
                //    return null;
                //}

                foreach (var item in beneficiaryRegObjs.BeneficiaryRegObjs)
                {
                    var thisResponse = new BeneficiaryRegResponseObj
                    {
                        Status = new ResponseStatus
                        {
                            IsSuccessful = false,
                            Message      = new ResponseMessage
                            {
                                FriendlyMessage  = "",
                                TechnicalMessage = ""
                            }
                        },
                        BeneficiaryId = item.BeneficiaryId,
                        MobileNumber  = item.MobileNumber,
                    };

                    try
                    {
                        valResults = new List <ValidationResult>();
                        if (!EntityValidatorHelper.Validate(item, 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");
                            }

                            thisResponse.Status.Message.FriendlyMessage = thisResponse.Status.Message.TechnicalMessage = errorDetail.ToString();
                            response.BeneficiaryRegResponses.Add(thisResponse);
                            continue;
                        }

                        var regStatus = (RegStatus)Enum.Parse(typeof(RegStatus), item.Status.ToString(CultureInfo.InvariantCulture));

                        #region Delete

                        //try
                        //{
                        //    if (regStatus == RegStatus.Deleted)
                        //    {

                        //        if (!valSettings.Find(m => (string.Compare(m.Name.Trim(), "Can_Delete_Record", StringComparison.CurrentCultureIgnoreCase) == 0)).ValidationValue)
                        //        {
                        //            thisResponse.Status.Message.FriendlyMessage = thisResponse.Status.Message.TechnicalMessage = "Data Deleting Feature is currently turned off! Unable to delete this record on the remote server";
                        //            response.BusinessRegResponses.Add(thisResponse);
                        //            continue;
                        //        }

                        //        if (item.BusinessInfoRemoteId < 1)
                        //        {
                        //            thisResponse.Status.Message.FriendlyMessage = thisResponse.Status.Message.TechnicalMessage = "Invalid Remote Record Id! Unable to complete operation on this record";
                        //            response.BusinessRegResponses.Add(thisResponse);
                        //            continue;
                        //        }

                        //        var buzInfo = GetBusinessInfoItem(item.BusinessInfoRemoteId);
                        //        if (buzInfo == null)
                        //        {
                        //            thisResponse.Status.Message.FriendlyMessage = thisResponse.Status.Message.TechnicalMessage = "No Remote Record Found! The specified Remote Id did not return any record";
                        //            response.BusinessRegResponses.Add(thisResponse);
                        //            continue;
                        //        }
                        //        buzInfo.Status = RegStatus.Deleted;
                        //    }
                        //}
                        //catch (Exception ex)
                        //{
                        //    thisResponse.Status.Message.FriendlyMessage = "Unable to process this record due to error";
                        //    thisResponse.Status.Message.TechnicalMessage = "Error: " + ex.Message;
                        //    BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                        //    response.BeneficiaryRegResponses.Add(thisResponse);
                        //    continue;
                        //}

                        #endregion
                        #region Edit
                        //try
                        //{
                        //    if (regStatus == RegStatus.Edited)
                        //    {



                        //        if (!valSettings.Find(m => (string.Compare(m.Name.Trim(), "Can_Edit_Record", StringComparison.CurrentCultureIgnoreCase) == 0)).ValidationValue)
                        //        {
                        //            thisResponse.Status.Message.FriendlyMessage = thisResponse.Status.Message.TechnicalMessage = "Data Editing Feature is currently turned off! Unable to update this record on the remote server";
                        //            response.BusinessRegResponses.Add(thisResponse);
                        //            continue;
                        //        }

                        //        if (item.BusinessInfoRemoteId < 1)
                        //        {
                        //            thisResponse.Status.Message.FriendlyMessage = thisResponse.Status.Message.TechnicalMessage = "Invalid Remote Record Id! Unable to complete operation on this record";
                        //            response.BusinessRegResponses.Add(thisResponse);
                        //            continue;
                        //        }

                        //        var bizInfo = loadBusinessInfo(item, businessRegObjs.LocalAreaId, valSettings, ref thisResponse.Status);
                        //        if (bizInfo == null)
                        //        {
                        //            response.BusinessRegResponses.Add(thisResponse);
                        //            continue;
                        //        }

                        //        if (!doValidation(bizInfo, 2, valSettings, ref thisResponse.Status))
                        //        {
                        //            response.BusinessRegResponses.Add(thisResponse);
                        //            continue;
                        //        }

                        //        using (var db = _uoWork.BeginTransaction())
                        //        {
                        //            var processedBusinessInfo = _repository.Update(bizInfo);
                        //            _uoWork.SaveChanges();
                        //            if (processedBusinessInfo.BusinessInfoId < 1)
                        //            {
                        //                db.Rollback();
                        //                thisResponse.Status.Message.FriendlyMessage = thisResponse.Status.Message.TechnicalMessage = "Update process failed!";
                        //                response.BusinessRegResponses.Add(thisResponse);
                        //                continue;
                        //            }

                        //            var ownerInfo = bizInfo.BusinessOwnerInfo;
                        //            var ownerRet = _ownerRepository.Update(ownerInfo);
                        //            _uoWork.SaveChanges();

                        //            if (ownerRet.BusinessOwnerInfoId < 1)
                        //            {
                        //                db.Rollback();
                        //                thisResponse.Status.Message.FriendlyMessage = thisResponse.Status.Message.TechnicalMessage = "Processing Failed! Please try again later";
                        //                response.BusinessRegResponses.Add(thisResponse);
                        //                continue;
                        //            }

                        //            db.Commit();
                        //            thisResponse.Status.IsSuccessful = true;
                        //            thisResponse.BusinessInfoRemoteId = bizInfo.BusinessInfoId;
                        //            thisResponse.BusinessOwnerInfoRemoteId = ownerInfo.BusinessOwnerInfoId;
                        //            response.BusinessRegResponses.Add(thisResponse);
                        //        }
                        //        continue;
                        //    }
                        //}
                        //catch (Exception ex)
                        //{
                        //    thisResponse.Status.Message.FriendlyMessage = "Unable to process this record due to error";
                        //    thisResponse.Status.Message.TechnicalMessage = "Error: " + ex.Message;
                        //    ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                        //    response.BusinessRegResponses.Add(thisResponse);
                        //    continue;
                        //}

                        #endregion
                        #region New Record


                        #region Saving Image

                        string msg;
                        var    org           = station.OrganizationName;
                        var    stationId     = station.StationId;
                        var    enrollerRegId = station.EnrollerRegId;
                        //var image = Utils.BeneficiaryRegObj.Image;

                        var imgResPath = EnrollHelper.PrepareImagePath(org, stationId, enrollerRegId, out msg);
                        if (imgResPath.IsNullOrEmpty() || !msg.IsNullOrEmpty())
                        {
                            thisResponse.Status.Message.FriendlyMessage = thisResponse.Status.Message.TechnicalMessage = msg;
                            response.BeneficiaryRegResponses.Add(thisResponse);
                            continue;
                        }

                        var bytes = Convert.FromBase64String(item.ImageByteString);
                        File.WriteAllBytes(@imgResPath, bytes);
                        var imgFileName = Path.GetFileName(imgResPath);

                        #region Biometric

                        //var listOfArrays = new List<byte[]>();
                        //var array = listOfArrays
                        //                .SelectMany(a => a)
                        //                .ToArray();


                        var fingerPrintByteArray = item.FingerPrintTemplate
                                                   .SelectMany(a => a)
                                                   .ToArray();

                        //var bio = new BiometricData
                        //{
                        //    FingerPrintTemplates = item.FingerPrintTemplate,
                        //    ImageFileName = Path.GetFileName(imgResPath),
                        //    ImagePath = "~/" + imgResPath
                        //};
                        //string _bio = JsonConvert.SerializeObject(bio);


                        #endregion

                        #endregion

                        var ben = new Beneficiary
                        {
                            Surname              = item.Surname,
                            FirstName            = item.FirstName,
                            Othernames           = item.Othernames,
                            Sex                  = item.Sex,
                            MaritalStatus        = item.MaritalStatus,
                            OccupationId         = item.OccupationId,
                            DateOfBirth          = item.DateOfBirth,
                            ResidentialAddress   = item.ResidentialAddress,
                            OfficeAddress        = item.OfficeAddress,
                            LocalAreaId          = item.LocalAreaId,
                            StateId              = item.StateId,
                            ImageFileName        = imgFileName,
                            ImagePath            = "~/" + imgResPath,
                            RemoteImageFileName  = item.ImageFileName,
                            BeneficiaryRemoteId  = item.BeneficiaryId,
                            FingerPrintTemplates = fingerPrintByteArray,
                            //Biometric = _bio,

                            SurnameHashed     = UniqueHashing.GetStandardHash(item.Surname.Trim().Replace(" ", "").ToLower()),
                            FirstNameHashed   = UniqueHashing.GetStandardHash(item.FirstName.Trim().Replace(" ", "").ToLower()),
                            OtherNameHashed   = UniqueHashing.GetStandardHash(item.Othernames.Trim().Replace(" ", "").ToLower()),
                            MobileNoHashed    = UniqueHashing.GetStandardHash(item.MobileNumber.Trim().Replace(" ", "").ToLower()),
                            DateOfBirthHashed = UniqueHashing.GetStandardHash(item.DateOfBirth.Trim().Replace(" ", "").ToLower()),

                            Status              = regStatus,
                            EnrollerId          = station.EnrollerId,
                            ClientStationId     = station.ClientStationId,
                            TimeStampRegistered = DateTime.Now,
                        };

                        if (!doValidation(ben, 1, ref thisResponse.Status))
                        {
                            response.BeneficiaryRegResponses.Add(thisResponse);
                            continue;
                        }

                        var retVal = _repository.Add(ben);
                        _uoWork.SaveChanges();
                        if (retVal.BeneficiaryId < 1)
                        {
                            thisResponse.Status.Message.FriendlyMessage = thisResponse.Status.Message.TechnicalMessage = "Processing Failed! Please try again later";
                            response.BeneficiaryRegResponses.Add(thisResponse);
                            continue;
                        }

                        thisResponse.Status.IsSuccessful = true;
                        thisResponse.BeneficiaryRemoteId = retVal.BeneficiaryId;
                        response.BeneficiaryRegResponses.Add(thisResponse);
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        thisResponse.Status.Message.FriendlyMessage  = "Processing Error Occurred! Please try again later";
                        thisResponse.Status.Message.TechnicalMessage = "Error: " + ex.Message;
                        BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                        response.BeneficiaryRegResponses.Add(thisResponse);
                    }
                }


                response.MainStatus.IsSuccessful = true;
                return(response);
            }
            catch (Exception ex)
            {
                response.MainStatus.Message.FriendlyMessage  = "Processing Error Occurred! Please try again later";
                response.MainStatus.Message.TechnicalMessage = "Error: " + ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(response);
            }
        }
Exemplo n.º 25
0
        private void ProcessStateLookUps(DataKioskEntities context)
        {
            try
            {
                if (!context.States.Any())
                {
                    var state = new State {
                        Name = "Abia"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Adamawa"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Anambra"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Akwa Ibom"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Bauchi"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Bayelsa"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Benue"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Borno"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Cross River"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Delta"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Ebonyi"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Enugu"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Edo"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Ekiti"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Gombe"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Imo"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Jigawa"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Kaduna"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Kano"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Katsina"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Kebbi"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Kogi"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Kwara"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Lagos"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Nasarawa"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Niger"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Ogun"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Ondo"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Osun"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Oyo"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Plateau"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Rivers"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Sokoto"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Taraba"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "Yobe"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();

                    state = new State {
                        Name = "FCT Abuja"
                    };
                    context.States.AddOrUpdate(m => m.Name, state);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
            }
        }
Exemplo n.º 26
0
        internal int RemoveUsersFromRoles(string[] usernames, string[] roleNames, out string msg)
        {
            try
            {
                var names = String.Join("), lower(", usernames);
                var roles = String.Join("), lower(", roleNames);
                if (names.StartsWith("), lower("))
                {
                    names = names.Substring(2);
                }
                names = names + ")";

                if (roles.StartsWith("), lower("))
                {
                    roles = roles.Substring(2);
                }
                roles = roles + ")";

                var sql1 =
                    String.Format(
                        "Select \"UserId\" FROM   \"EnrollKiosk\".\"User\"  WHERE \"UserName\" in ({0});", names);
                var sql2 =
                    String.Format(
                        "Select \"RoleId\" FROM   \"EnrollKiosk\".\"Role\"  WHERE \"Name\" in ({0});", roles);


                var userIds = _repository.RepositoryContext().Database.SqlQuery <int>(sql1).ToList();
                var roleIds = _repository.RepositoryContext().Database.SqlQuery <int>(sql2).ToList();

                if (!userIds.Any() || roleIds.Any())
                {
                    msg = "Process Failed! Either User list is empty or Role list is empty";
                    return(-1);
                }

                var counter = 0;
                foreach (var item in userIds)
                {
                    foreach (var roleitem in roleIds)
                    {
                        sql1 =
                            String.Format(
                                "Delete From \"EnrollKiosk\".\"UserRole\"  WHERE \"UserId\" = {0} And \"RoleId\" = {1};", item, roleitem);
                        var retId = _repository.RepositoryContext().Database.ExecuteSqlCommand(sql1);
                        if (retId > 0)
                        {
                            counter++;
                        }
                    }
                }

                msg = "";
                return(counter);
            }
            catch (DbEntityValidationException ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                msg = ex.Message;
                return(0);
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                msg = ex.Message;
                return(0);
            }
        }
Exemplo n.º 27
0
        internal ResponseStatus UpdateOrganization(Organization organizationRegObj)
        {
            var response = new ResponseStatus
            {
                IsSuccessful = false,
                Message      = new ResponseMessage(),
                ReturnedId   = 0
            };

            try
            {
                #region Null Validation

                if (organizationRegObj.Equals(null))
                {
                    response.Message.FriendlyMessage = response.Message.TechnicalMessage = "Error Occurred! Unable to proceed with your registration";
                    return(response);
                }

                List <ValidationResult> valResults;
                if (!EntityValidatorHelper.Validate(organizationRegObj, 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.Message.FriendlyMessage = response.Message.TechnicalMessage = errorDetail.ToString();
                    return(response);
                }

                #endregion

                #region Get This Organization
                var thisOrganization = GetOrganization(organizationRegObj.OrganizationId);
                if (thisOrganization == null || thisOrganization.OrganizationId < 1)
                {
                    response.Message.FriendlyMessage = response.Message.TechnicalMessage = "Invalid Organization Information";
                    return(response);
                }
                #endregion

                string msg;
                if (IsDuplicate2(organizationRegObj, out msg, 1))
                {
                    response.Message.FriendlyMessage = response.Message.TechnicalMessage = msg;
                    return(response);
                }

                thisOrganization.Name        = organizationRegObj.Name;
                thisOrganization.Email       = organizationRegObj.Email;
                thisOrganization.Address     = organizationRegObj.Address;
                thisOrganization.PhoneNumber = organizationRegObj.PhoneNumber;
                thisOrganization.Status      = organizationRegObj.Status;

                var processedOrganization = _repository.Update(thisOrganization);
                _uoWork.SaveChanges();
                if (processedOrganization.OrganizationId < 1)
                {
                    response.Message.FriendlyMessage = response.Message.TechnicalMessage = "Process Failed! Please try again later";
                    return(response);
                }

                response.IsSuccessful = true;
                return(response);
            }
            catch (Exception ex)
            {
                response.Message.FriendlyMessage =
                    "Unable to complete your request due to error! Please try again later";
                response.Message.TechnicalMessage = "Error" + ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(response);
            }
        }
Exemplo n.º 28
0
        public JsonResult <BulkBeneficiaryRegResponseObj> BulkBeneficiaryRegistration(BulkBeneficiaryRegObj appRegObj)
        {
            var response = new BulkBeneficiaryRegResponseObj
            {
                MainStatus = new ResponseStatus()
            };

            try
            {
                object authResponse;
                if (!Request.Properties.TryGetValue("AuthResponse", out authResponse))
                {
                    response = new BulkBeneficiaryRegResponseObj
                    {
                        MainStatus = new ResponseStatus
                        {
                            IsSuccessful = false,
                            Message      = new ResponseMessage
                            {
                                FriendlyMessage  = "Process Error Occurred! Check parameters and try again later",
                                TechnicalMessage = "Unable to perform authentication on the server"
                            }
                        }
                    };
                    return(Json(response));
                }
                var auth = authResponse as ApiObj;
                if (auth == null)
                {
                    response = new BulkBeneficiaryRegResponseObj
                    {
                        MainStatus = new ResponseStatus
                        {
                            IsSuccessful = false,
                            Message      = new ResponseMessage
                            {
                                FriendlyMessage  = "Process Error Occurred! Check parameters and try again later",
                                TechnicalMessage = "Unable to perform authentication on the server"
                            }
                        }
                    };
                    return(Json(response));
                }

                if (auth.IsSuccessful)
                {
                    response = ServiceProvider.Instance().GetBeneficiaryServices().AddBulkBeneficiary(appRegObj, auth.StationInfo);
                    return(Json(response));
                }

                response = new BulkBeneficiaryRegResponseObj
                {
                    MainStatus = new ResponseStatus
                    {
                        IsSuccessful = auth.IsSuccessful,
                        Message      = new ResponseMessage
                        {
                            FriendlyMessage  = auth.ErrorMessage,
                            TechnicalMessage = auth.TechErrorMessage
                        }
                    }
                };
                return(Json(response));
            }
            catch (Exception ex)
            {
                response.MainStatus.IsSuccessful             = false;
                response.MainStatus.Message.FriendlyMessage  = "An unexpected error occurred";
                response.MainStatus.Message.TechnicalMessage = ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(Json(response));
            }
        }
Exemplo n.º 29
0
        private bool IsDuplicate(long clientStationId, string username, string email, string sin, string phoneNo, out string msg)
        {
            try
            {
                #region Latest Duplicate

                // Check Duplicate Phone Number & SIN
                var check  = IsUsernameExist(username);
                var check1 = IsPhoneNumberExist(clientStationId, phoneNo);
                var check2 = IsSINExist(clientStationId, sin);
                var check3 = IsEmailExist(clientStationId, email);

                if ((!check.Any() || check.Count == 0) && (!check1.Any() || check1.Count == 0) && (!check2.Any() || check2.Count == 0) && (!check3.Any() || check3.Count == 0))
                {
                    msg = "";
                    return(false);
                }

                if (check != null)
                {
                    if (check.Count > 0)
                    {
                        msg = "Duplicate Error! Username already exist under";
                        return(true);
                    }
                }

                if (check1 != null && check1.Count > 0)
                {
                    msg = "Duplicate Error! Phone Number already been used by another operator";
                    return(true);
                }

                if (check2 != null)
                {
                    if (check2.Count > 0)
                    {
                        msg = "Duplicate Error! Operator Reg. No already exist under this station's organization";
                        return(true);
                    }
                }

                if (check3 != null && check3.Count > 0)
                {
                    msg = "Duplicate Error! Email already been used by another operator";
                    return(true);
                }

                #endregion

                msg = "";
                return(false);

                //msg = "Unable to check duplicate! Please try again later";
                //return true;
            }
            catch (Exception ex)
            {
                msg = "Error: " + ex.Message;
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(true);
            }
        }
Exemplo n.º 30
0
        public StationRespObj RemoteLogin(RemoteStationLoginObj loginObj)
        {
            var response = new StationRespObj
            {
                ResponseStatus = new ResponseStatus
                {
                    Message      = new ResponseMessage(),
                    IsSuccessful = false,
                }
            };

            try
            {
                #region Null Validation

                List <ValidationResult> valResults;
                if (!EntityValidatorHelper.Validate(loginObj, 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);
                }

                #endregion

                string msg;
                var    enroller = LoginEnroller(loginObj.UserName, loginObj.Password, out msg);
                if (enroller == null || string.IsNullOrEmpty(enroller.EnrollerRegId) || enroller.EnrollerId < 1)
                {
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Invalid Station Operator Info";
                    return(response);
                }

                var station = new ClientStationRepository().GetStation(enroller.ClientStationId);
                if (station == null || station.ClientStationId < 1)
                {
                    response.ResponseStatus.Message.FriendlyMessage = response.ResponseStatus.Message.TechnicalMessage = "Invalid Station Info";
                    return(response);
                }

                enroller.DeviceId            = loginObj.DeviceId;
                enroller.DeviceIP            = loginObj.DeviceIP;
                enroller.Status              = 2;
                enroller.TimeStampAuthorized = DateTime.Now;
                var processedClientStationEnroller = _repository.Update(enroller);
                _uoWork.SaveChanges();

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

                response.ResponseStatus.IsSuccessful = true;
                response.APIAccessKey       = station.APIAccessKey;
                response.ClientStationId    = enroller.ClientStationId;
                response.ResidentialAddress = enroller.Address;
                response.Surname            = enroller.Surname;
                response.FirstName          = enroller.FirstName;
                response.Othernames         = enroller.OtherNames;
                response.Sex          = enroller.Sex;
                response.Email        = enroller.Email;
                response.MobileNumber = enroller.MobileNumber;
                //response.OrganizationId = enroller.OrganizationId;
                response.EnrollerRegId = enroller.EnrollerRegId;
                response.EnrollerId    = enroller.EnrollerId;
                response.StationId     = station.StationId;
                response.StationName   = station.StationName;
                //response.UserName = corporateInfo.UserName;
                response.ResponseStatus.ReturnedId   = enroller.EnrollerId;
                response.ResponseStatus.IsSuccessful = true;
                response.StationStatus  = station.Status;
                response.EnrollerStatus = enroller.Status;
                //response.ResponseStatus.ReturnedValue = retId;
                //response.DeviceId = station.DeviceId;
                return(response);
            }
            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);
            }
        }