コード例 #1
0
        public static Int32 Save(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, USER_ROLES objSave)
        {
            Int32        objReturn = 0;
            USER_ROLESDB objDB     = new USER_ROLESDB();

            objReturn = objDB.Save(CURRENT_USER, CURRENT_REGISTRY_ID, objSave);

            return(objReturn);
        }
コード例 #2
0
        public static USER_ROLES GetItem(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, Int32 USER_ROLE_ID)
        {
            USER_ROLES   objReturn = null;
            USER_ROLESDB objDB     = new USER_ROLESDB();

            objReturn = objDB.GetItem(CURRENT_USER, CURRENT_REGISTRY_ID, USER_ROLE_ID);

            return(objReturn);
        }
コード例 #3
0
        public static USER_ROLES GetItemByUserRole(string Username, string RoleName)
        {
            USER_ROLES   objReturn = null;
            USER_ROLESDB objDB     = new USER_ROLESDB();

            objReturn = objDB.GetItemByUserRole(Username, RoleName);

            return(objReturn);
        }
コード例 #4
0
        public USER_ROLES ParseReaderComplete(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, DataRow row)
        {
            USER_ROLES objReturn = ParseReaderCustom(row);

            if (objReturn != null)
            {
                STD_ROLEDB sTD_ROLEDB = new STD_ROLEDB();
                objReturn.STD_ROLE = sTD_ROLEDB.ParseReaderCustom(row);
            }

            return(objReturn);
        }
コード例 #5
0
        public USER_ROLES ParseReaderCustom(DataRow row)
        {
            USER_ROLES objReturn = new USER_ROLES
            {
                CREATED       = (DateTime)GetNullableObject(row.Field <object>("USER_ROLES_CREATED")),
                CREATEDBY     = (string)GetNullableObject(row.Field <object>("USER_ROLES_CREATEDBY")),
                INACTIVE_DATE = (DateTime?)GetNullableObject(row.Field <object>("USER_ROLES_INACTIVE_DATE")),
                INACTIVE_FLAG = (bool)GetNullableObject(row.Field <object>("USER_ROLES_INACTIVE_FLAG")),
                STD_ROLE_ID   = (Int32)GetNullableObject(row.Field <object>("USER_ROLES_STD_ROLE_ID")),
                UPDATED       = (DateTime)GetNullableObject(row.Field <object>("USER_ROLES_UPDATED")),
                UPDATEDBY     = (string)GetNullableObject(row.Field <object>("USER_ROLES_UPDATEDBY")),
                USER_ID       = (Int32)GetNullableObject(row.Field <object>("USER_ROLES_USER_ID")),
                USER_ROLE_ID  = (Int32)GetNullableObject(row.Field <object>("USER_ROLES_USER_ROLE_ID"))
            };

            return(objReturn);
        }
コード例 #6
0
        public USERS ParseReaderComplete(DataRow row)
        {
            USERS user = ParseReaderCustom(row);

            if (user != null)
            {
                USER_ROLESDB uSER_ROLESDB = new USER_ROLESDB();
                USER_ROLES   userRole     = uSER_ROLESDB.ParseReaderCustom(row);
                if (userRole != null)
                {
                    STD_ROLEDB sTD_ROLEDB = new STD_ROLEDB();
                    userRole.STD_ROLE = sTD_ROLEDB.ParseReaderCustom(row);
                }
                user.USER_ROLES = new List <USER_ROLES>();
                user.USER_ROLES.Add(userRole);
            }

            return(user);
        }
コード例 #7
0
        public RESPONSE_MODEL UpdateUserRole(int employee_id, int application_id, List <int> role_id)
        {
            try
            {
                var allRole = ctx.ROLE.Where(o => o.APP_ID == application_id).Select(o => o.ROLE_ID).ToList();
                if (role_id != null)
                {
                    var deleteOld = ctx.USER_ROLES.Where(o => allRole.Contains(o.ROLE_ID) && o.EMPLOYEE_ID == employee_id).ToList();
                    ctx.USER_ROLES.RemoveRange(deleteOld);

                    var allowedRole = allRole.Where(o => role_id.Contains(o)).ToList();
                    foreach (var item in allowedRole)
                    {
                        USER_ROLES role = new USER_ROLES();
                        role.ROLE_ID           = item;
                        role.EMPLOYEE_ID       = employee_id;
                        role.USER_ROLE_ALLOWED = "Y";
                        ctx.USER_ROLES.Add(role);
                    }
                    var notAllowedRole = allRole.Where(o => !role_id.Contains(o)).ToList();
                    foreach (var item in notAllowedRole)
                    {
                        USER_ROLES role = new USER_ROLES();
                        role.ROLE_ID           = item;
                        role.EMPLOYEE_ID       = employee_id;
                        role.USER_ROLE_ALLOWED = "N";
                        ctx.USER_ROLES.Add(role);
                    }
                }
                else
                {
                    var deleteOld = ctx.USER_ROLES.Where(o => allRole.Contains(o.ROLE_ID) && o.EMPLOYEE_ID == employee_id).ToList();
                    ctx.USER_ROLES.RemoveRange(deleteOld);
                }
                ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                resp = ErrorCollection(ex);
            }
            return(resp);
        }
コード例 #8
0
        public override bool IsUserInRole(string username, string roleName)
        {
            USER_ROLES ur = null;

            //if (!string.IsNullOrEmpty(ApplicationName))
            //{
            //    urr = Users_In_Registries_In_RolesManager.GetItem(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId,username, roleName, ApplicationName);
            //}
            //else
            //{
            ur = ServiceInterfaceManager.USER_ROLES_GET_BY_USER_ROLE(username, roleName);
            //}

            if (ur != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #9
0
        public USER_ROLES GetItem(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, Int32 USER_ROLE_ID)
        {
            USER_ROLES objReturn = null;

            SqlConnection  sConn    = null;
            SqlCommand     sCmd     = null;
            SqlDataAdapter sAdapter = null;
            DataSet        objTemp  = null;

            try
            {
                sConn = new SqlConnection(SqlConnectionString);

                sConn.Open();

                sCmd = new SqlCommand("CRS.usp_USER_ROLES_getitem", sConn);
                sCmd.CommandTimeout = SqlCommandTimeout;
                sCmd.CommandType    = CommandType.StoredProcedure;
                sCmd.Parameters.AddWithValue("@CURRENT_USER", CURRENT_USER);
                sCmd.Parameters.AddWithValue("@CURRENT_REGISTRY_ID", CURRENT_REGISTRY_ID);
                sCmd.Parameters.AddWithValue("@USER_ROLE_ID", USER_ROLE_ID);

                objTemp  = new DataSet();
                sAdapter = new SqlDataAdapter(sCmd);

                LogDetails logDetails = new LogDetails(String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                sAdapter.Fill(objTemp);
                LogManager.LogTiming(logDetails);
                CheckDataSet(objTemp);

                if (objTemp != null && objTemp.Tables.Count > 0 && objTemp.Tables[0].Rows.Count > 0)
                {
                    objReturn = ParseReader(objTemp.Tables[0].Rows[0]);
                }

                sConn.Close();
            }
            catch (Exception ex)
            {
                LogManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                throw ex;
            }
            finally
            {
                if (sAdapter != null)
                {
                    sAdapter.Dispose();
                    sAdapter = null;
                }
                if (sCmd != null)
                {
                    sCmd.Dispose();
                    sCmd = null;
                }
                if (sConn != null)
                {
                    if (sConn.State != ConnectionState.Closed)
                    {
                        sConn.Close();
                    }
                    sConn.Dispose();
                    sConn = null;
                }
            }

            return(objReturn);
        }
コード例 #10
0
        public Int32 Save(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, USER_ROLES objSave)
        {
            Int32 objReturn = 0;

            SqlConnection sConn = null;
            SqlCommand    sCmd  = null;
            SqlParameter  p     = null;

            try
            {
                sConn = new SqlConnection(SqlConnectionString);

                sConn.Open();

                sCmd = new SqlCommand("CRS.usp_USER_ROLES_save", sConn);
                sCmd.CommandTimeout = SqlCommandTimeout;
                sCmd.CommandType    = CommandType.StoredProcedure;
                sCmd.Parameters.AddWithValue("@CURRENT_USER", CURRENT_USER);
                sCmd.Parameters.AddWithValue("@CURRENT_REGISTRY_ID", CURRENT_REGISTRY_ID);

                p           = new SqlParameter("@CREATED", SqlDbType.DateTime, 8);
                p.Precision = 23;
                p.Scale     = 3;
                AddParameter(ref sCmd, ref p, objSave.CREATED);
                p           = new SqlParameter("@CREATEDBY", SqlDbType.VarChar, 30);
                p.Precision = 0;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.CREATEDBY);
                p           = new SqlParameter("@INACTIVE_DATE", SqlDbType.DateTime, 8);
                p.Precision = 23;
                p.Scale     = 3;
                AddParameter(ref sCmd, ref p, objSave.INACTIVE_DATE);
                p           = new SqlParameter("@INACTIVE_FLAG", SqlDbType.Bit, 1);
                p.Precision = 1;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.INACTIVE_FLAG);
                p           = new SqlParameter("@STD_ROLE_ID", SqlDbType.Int, 4);
                p.Precision = 10;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.STD_ROLE_ID);
                p           = new SqlParameter("@UPDATED", SqlDbType.DateTime, 8);
                p.Precision = 23;
                p.Scale     = 3;
                AddParameter(ref sCmd, ref p, objSave.UPDATED);
                p           = new SqlParameter("@UPDATEDBY", SqlDbType.VarChar, 30);
                p.Precision = 0;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.UPDATEDBY);
                p           = new SqlParameter("@USER_ID", SqlDbType.Int, 4);
                p.Precision = 10;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.USER_ID);
                p           = new SqlParameter("@USER_ROLE_ID", SqlDbType.Int, 4);
                p.Direction = ParameterDirection.InputOutput;
                p.Precision = 10;
                p.Scale     = 0;
                AddParameter(ref sCmd, ref p, objSave.USER_ROLE_ID);

                LogDetails logDetails = new LogDetails(String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                int        cnt        = sCmd.ExecuteNonQuery();
                LogManager.LogTiming(logDetails);

                objReturn = (Int32)sCmd.Parameters["@USER_ROLE_ID"].Value;

                sConn.Close();
            }
            catch (Exception ex)
            {
                LogManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                throw ex;
            }
            finally
            {
                if (sCmd != null)
                {
                    sCmd.Dispose();
                    sCmd = null;
                }
                if (sConn != null)
                {
                    if (sConn.State != ConnectionState.Closed)
                    {
                        sConn.Close();
                    }
                    sConn.Dispose();
                    sConn = null;
                }
            }

            return(objReturn);
        }
コード例 #11
0
        private void UpdateRoles(int registryId, int roleId)
        {
            List <USER_ROLES> userRoles = UserRoles;

            int userId = 0;

            int.TryParse(hideUserId.Value, out userId);

            if (registryId > 0)
            {
                bool foundRegistry = false;

                if (userRoles != null)
                {
                    for (int i = 0; i < userRoles.Count; i++)
                    {
                        if (userRoles[i].STD_ROLE == null)
                        {
                            userRoles[i].STD_ROLE = ServiceInterfaceManager.STD_ROLE_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, userRoles[i].STD_ROLE_ID);
                        }

                        if (userRoles[i].STD_ROLE != null && userRoles[i].STD_ROLE.STD_REGISTRY_ID == registryId)
                        {
                            foundRegistry = true;

                            userRoles[i].UPDATED   = DateTime.Now;
                            userRoles[i].UPDATEDBY = HttpContext.Current.User.Identity.Name;

                            if (roleId > 0)
                            {
                                userRoles[i].INACTIVE_FLAG = false;
                                userRoles[i].INACTIVE_DATE = null;

                                if (userRoles[i].STD_ROLE_ID != roleId)
                                {
                                    userRoles[i].STD_ROLE = ServiceInterfaceManager.STD_ROLE_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, roleId);
                                }

                                userRoles[i].STD_ROLE_ID = roleId;
                            }
                            else
                            {
                                userRoles[i].INACTIVE_FLAG = true;
                                userRoles[i].INACTIVE_DATE = DateTime.Now;
                                //userRoles[i].STD_ROLE_ID = roleId;
                            }
                        }
                    }
                }

                if (!foundRegistry && roleId > 0)
                {
                    if (userRoles == null)
                    {
                        userRoles = new List <USER_ROLES>();
                    }

                    USER_ROLES userRole = new USER_ROLES();

                    userRole.CREATED       = userRole.UPDATED = DateTime.Now;
                    userRole.CREATEDBY     = userRole.UPDATEDBY = HttpContext.Current.User.Identity.Name;
                    userRole.INACTIVE_FLAG = false;
                    userRole.INACTIVE_DATE = null;
                    userRole.USER_ID       = userId;

                    STD_ROLE stdRole = ServiceInterfaceManager.STD_ROLE_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, roleId);
                    if (stdRole != null)
                    {
                        userRole.STD_ROLE_ID = stdRole.ID;
                        userRole.STD_ROLE    = stdRole;
                        userRoles.Add(userRole);
                    }
                }
            }

            if (userRoles != null && userRoles.Count > 0)
            {
                UserRoles = userRoles;
            }
        }
コード例 #12
0
 public static Boolean Delete(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, USER_ROLES objDelete)
 {
     return(Delete(CURRENT_USER, CURRENT_REGISTRY_ID, objDelete.USER_ROLE_ID));
 }