예제 #1
0
 /// <summary>
 /// Method To show the All Record Status
 /// </summary>
 public ObservableCollection <string> GetRecordStatus()
 {
     try
     {
         CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
         FindUserProp objFindUserProp = new FindUserProp();
         string[]     lst             = _serviceInstance.RecordList();
         RecordStatus = new ObservableCollection <string>(lst);
         RecordStatus.Insert(0, "All");
         SelectedStatus = "All";
     }
     catch (Exception ex)
     {
         LogHelper.LogErrorToDb(ex);
         bool displayErrorOnUI = false;
         CommonSettings.logger.LogError(this.GetType(), ex);
         if (displayErrorOnUI)
         {
             throw;
         }
     }
     finally
     {
         CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
     }
     return(RecordStatus);
 }
예제 #2
0
 /// <summary>
 /// Method To show the All Roles
 /// </summary>
 public void GetAllRoles(int userID)
 {
     try
     {
         CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
         FindUserProp objFindUserProp = new FindUserProp();
         var          lst             = _serviceInstance.GetRolesSelection(0);
         if (lst.Count() > 0)
         {
             RoleList = null;
             RoleList = lst.ToList();
             RoleList.Insert(0, new RoleList {
                 RoleName = "All"
             });
             RoleName = "All";
         }
     }
     catch (Exception ex)
     {
         LogHelper.LogErrorToDb(ex);
         bool displayErrorOnUI = false;
         CommonSettings.logger.LogError(this.GetType(), ex);
         if (displayErrorOnUI)
         {
             throw;
         }
     }
     finally
     {
         CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
     }
 }
예제 #3
0
        /// <summary>
        /// To Remove the Record of existing User
        /// </summary>
        /// <param name="AdminUserProp"></param>
        /// <returns>int</returns>
        /// <createdBy></createdBy>
        /// <createdOn>Apr-29,2016</createdOn>
        public int RemoveUserDetails(FindUserProp objFindUserProp)
        {
            int value = 0;

            try
            {
                int userID = Convert.ToInt32(objFindUserProp.UserID);
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                // creating the object of PortStorageEntities Database
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    string userName = (from tblUser in objAppWorksEntities.Users where tblUser.UserID == userID select tblUser.UserCode).FirstOrDefault();
                    string password = (from tblUser in objAppWorksEntities.Users where tblUser.UserID == userID select tblUser.Password).FirstOrDefault();

                    if (userID != 0)
                    {
                        var  userRecord = (from tblUser in objAppWorksEntities.Users where tblUser.UserID == userID && tblUser.Password == password && tblUser.UserCode == userName select tblUser).FirstOrDefault();
                        User user       = objAppWorksEntities.Users.Where(U => U.UserID == userID).FirstOrDefault();
                        user.RecordStatus = objFindUserProp.RecordStatus;
                        objAppWorksEntities.Users.Remove(userRecord);
                        objAppWorksEntities.SaveChanges();
                        value = objAppWorksEntities.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
            return(value);
        }
예제 #4
0
        /// <summary>
        /// Function to Delete record for user.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>void</returns>
        /// <createdBy></createdBy>

        public void DeleteRecord(object obj)
        {
            try
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                MessageBoxResult messageBoxResult = MessageBox.Show(Resources.MsgDeleteConfirm, Resources.msgTitleMessageBoxDelete, MessageBoxButton.YesNo);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    string       errMsg          = string.Empty;
                    FindUserProp objFindUserProp = new FindUserProp();
                    objFindUserProp.UserID       = obj.GetType().GetProperty("UdUserID").GetValue(obj).ToString();
                    objFindUserProp.RecordStatus = "Inactive";
                    objFindUserProp.FirstName    = obj.GetType().GetProperty("UdUserFirstName").GetValue(obj).ToString();;
                    objFindUserProp.LastName     = obj.GetType().GetProperty("UdUserLastName").GetValue(obj).ToString();;
                    objFindUserProp.UserCode     = obj.GetType().GetProperty("UdUserCode").GetValue(obj).ToString();;
                    objFindUserProp.SelectedRole = SelectedRole;
                    string currentUserName = Application.Current.Properties["LoggedInUserName"].ToString().ToUpper();
                    string deleteUserName  = objFindUserProp.UserCode.ToUpper();
                    if (deleteUserName != currentUserName)
                    {
                        int value = _serviceInstance.RemoveUserDetails(objFindUserProp);
                        if (SelectedStatus != null && !SelectedStatus.Equals("All"))
                        {
                            objFindUserProp.selectedStatusRole = SelectedStatus;
                        }
                        if (obj.GetType().GetProperty("UdUserStatus").GetValue(obj) != null && !obj.GetType().GetProperty("UdUserStatus").GetValue(obj).ToString().Equals("All"))
                        {
                            objFindUserProp.selectedStatusRole = obj.GetType().GetProperty("UdUserStatus").GetValue(obj).ToString();;
                        }
                        FindUserDeligate.SetValueMethodCmdReferesh(string.Empty);
                        MessageBox.Show(Resources.msgDeleteSuccessfully);
                        UsersRecordList(null);
                    }
                    else
                    {
                        MessageBox.Show(Resources.WarnDeleteCurrentUser);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }
            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }
예제 #5
0
 /// <summary>
 /// Function To Get The Users Infoemation.
 /// </summary>
 /// <param name="objFindUserProp"></param>
 /// <returns>List</returns>
 /// <createdBy></createdBy>
 /// <createdOn>Apr-25,2016</createdOn>
 public void UsersList(FindUserProp objFindUserProp)
 {
     // creating the object of PortStorageEntities Database
     using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
     {
         CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
         try
         {
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Function To Get The Users Lists.
        /// </summary>
        /// <param name="objFindUserProp"></param>
        /// <returns>List</returns>
        /// <createdBy></createdBy>
        /// <createdOn>Apr-26,2016</createdOn>
        public List <FindUserDetails> GetUserRecord(FindUserProp objFindUserProp)
        {
            List <FindUserDetails> objFindUserDetails = new List <FindUserDetails>();

            try
            {
                FindUserDAL objFindUserDAL = new FindUserDAL();
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                objFindUserDetails = objFindUserDAL.GetUserRecord(objFindUserProp);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End4 {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
            return(objFindUserDetails);
        }
예제 #7
0
        /// <summary>
        /// Function To Remove the User Details
        /// </summary>
        /// <param name="objFindUserProp"></param>
        /// <returns>
        /// Int</returns>
        /// <createdBy></createdBy>
        /// <createdOn>Apr-29,2016</createdOn>
        public int RemoveUserDetails(FindUserProp objFindUserProp)
        {
            int value = 0;

            try
            {
                FindUserDAL objFindUserDAL = new FindUserDAL();
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                value = objFindUserDAL.RemoveUserDetails(objFindUserProp);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
            return(value);
        }
예제 #8
0
        /// <summary>
        /// Method To Show All Record
        /// </summary>
        public void UsersRecordList(object obj)
        {
            try
            {
                Count = 0;
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                if (obj == null)
                {
                    CurrentPageIndex = 0;
                }
                if (CurrentPageIndex == 0)
                {
                    Application.Current.Properties["FindUserGridLastScrollOffset"] = 0;
                    Application.Current.Properties["FindUserGridCurrentPageIndex"] = 0;
                }

                FindUserProp objFindUserProp = new FindUserProp();
                objFindUserProp.CurrentPageIndex = CurrentPageIndex;
                objFindUserProp.PageSize         = CurrentPageIndex > 0 ? _GridPageSizeOnScroll : _GridPageSize;;
                objFindUserProp.DefaultPageSize  = _GridPageSize;
                objFindUserProp.FirstName        = FirstName;
                objFindUserProp.LastName         = LastName;
                objFindUserProp.UserCode         = UserCode;
                objFindUserProp.SelectedRole     = RoleName;

                if (SelectedStatus != null && !SelectedStatus.Equals("All"))
                {
                    objFindUserProp.selectedStatusRole = SelectedStatus;
                }

                var list = _serviceInstance.GetUserRecord(objFindUserProp).Select(d => new UserDetails
                {
                    UdUserCode      = d.UserCode,
                    UdUserFirstName = d.FirstName,
                    UdUserLastName  = d.LastName,
                    UdUserStatus    = d.UserStatus,
                    UdUserID        = d.UserID,
                    TotalPageCount  = d.TotalPageCount
                });

                if (CurrentPageIndex == 0)
                {
                    UserDetailList = null;
                    UserDetailList = new ObservableCollection <UserDetails>(list);
                }
                else
                {
                    if (UserDetailList != null && UserDetailList.Count > 0)
                    {
                        foreach (UserDetails ud in new ObservableCollection <UserDetails>(list))
                        {
                            UserDetailList.Add(ud);
                        }
                    }
                }
                Count = userDetailList.ToList().Where(x => x.TotalPageCount > 0).FirstOrDefault().TotalPageCount;
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }
            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                if (_searchTimer != null)
                {
                    _searchTimer.Dispose();
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Function To Get The Record of Users.
        /// </summary>
        /// <param></param>
        /// <returns>List</returns>
        /// <createdBy></createdBy>
        /// <createdOn>Apr-26,2016</createdOn>
        public List <FindUserDetails> GetUserRecord(FindUserProp objFindUserProp)
        {
            List <FindUserDetails> objFindUserDetails = new List <FindUserDetails>();

            try
            {
                PortStorageEntities objAppWorksEntities = new PortStorageEntities();

                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                var query = (from tblUsers in objAppWorksEntities.Users
                             join tblUserRole in objAppWorksEntities.UserRoles on tblUsers.UserID equals tblUserRole.UserID
                             orderby tblUsers.UserID
                             select new FindUserDetails
                {
                    UserCode = tblUsers.UserCode,
                    FirstName = tblUsers.FirstName,
                    LastName = tblUsers.LastName,
                    UserID = tblUsers.UserID,
                    UserRole = tblUserRole.RoleName,
                    UserStatus = tblUsers.RecordStatus,
                }).AsQueryable().Distinct();
                //objFindUserDetails = list.ToList();
                if ((objFindUserProp.UserCode != null) && (objFindUserProp.UserCode.Length > 0))
                {
                    query = query.Where(cnd => cnd.UserCode.Contains(objFindUserProp.UserCode) || cnd.FirstName.Contains(objFindUserProp.UserCode) || cnd.LastName.Contains(objFindUserProp.UserCode));
                }
                if ((objFindUserProp.FirstName != null) && (objFindUserProp.FirstName.Length > 0))
                {
                    query = query.Where(cnd => cnd.FirstName.Contains(objFindUserProp.FirstName));
                }
                if ((objFindUserProp.LastName != null) && (objFindUserProp.LastName.Length > 0))
                {
                    query = query.Where(cnd => cnd.LastName.Contains(objFindUserProp.LastName));
                }
                if ((objFindUserProp.SelectedRole != null) && (objFindUserProp.SelectedRole.Length > 0) && (objFindUserProp.SelectedRole != "All"))
                {
                    query = query.Where(cnd => cnd.UserRole == objFindUserProp.SelectedRole);
                }
                if ((objFindUserProp.selectedStatusRole != null) && (objFindUserProp.selectedStatusRole.Length > 0) && (objFindUserProp.selectedStatusRole != "All"))
                {
                    query = query.Where(cnd => cnd.UserStatus == objFindUserProp.selectedStatusRole);
                }

                //objFindUserDetails = query.ToList();
                objFindUserDetails = (from DistVal in query.AsEnumerable()
                                      select new FindUserDetails
                {
                    UserCode = DistVal.UserCode,
                    FirstName = DistVal.FirstName,
                    LastName = DistVal.LastName,
                    UserID = DistVal.UserID,
                    UserRole = DistVal.UserRole,
                    UserStatus = DistVal.UserStatus,
                }).DistinctBy(x => x.UserID).ToList();

                var pageCount = objFindUserDetails.ToList().Count;
                if (objFindUserProp.CurrentPageIndex == 0)
                {
                    var queryResult = objFindUserDetails.ToList().Skip(objFindUserProp.CurrentPageIndex * objFindUserProp.PageSize).Take(objFindUserProp.PageSize).ToList();
                    //var queryResult = query.ToList().Skip(objFindUserProp.CurrentPageIndex * objFindUserProp.PageSize).Take(objFindUserProp.PageSize).ToList();
                    if (queryResult != null && queryResult.Count > 0)
                    {
                        queryResult.FirstOrDefault().TotalPageCount = pageCount;
                    }
                    return(queryResult.Distinct().ToList());
                }
                else
                {
                    var queryResult = objFindUserDetails.ToList().Skip((objFindUserProp.CurrentPageIndex * objFindUserProp.PageSize) + (objFindUserProp.DefaultPageSize - objFindUserProp.PageSize)).Take(objFindUserProp.PageSize).ToList();
                    //var queryResult = query.ToList().Skip(objFindUserProp.CurrentPageIndex * objFindUserProp.PageSize).Take(objFindUserProp.PageSize).ToList();
                    if (queryResult != null && queryResult.Count > 0)
                    {
                        queryResult.FirstOrDefault().TotalPageCount = pageCount;
                    }
                    return(queryResult.Distinct().ToList());
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }