Exemplo n.º 1
0
        /// <summary>
        /// This method uses to get all visibility data
        /// </summary>
        /// <returns>DataSet</returns>
        /// <Author> Hung LA, Dec 13, 2004</Author>

        public DataSet GetVisibilityData()
        {
            const string METHOD_NAME = THIS + "GetVisibilityData()";

            // TODO : Remove after constant approved
            const int CANNOT_GET_VISIBILITY_DATA = -1;

            DataSet dstData = new DataSet();

            try
            {
                Sys_VisibilityGroupDS dsVisibilityGroup = new Sys_VisibilityGroupDS();
                dstData.Merge(dsVisibilityGroup.List().Tables[0]);
                Sys_VisibilityItemDS dsVisibilityItem = new Sys_VisibilityItemDS();
                dstData.Merge(dsVisibilityItem.List().Tables[0]);
                Sys_VisibilityGroup_RoleDS dsVisibilityGroup_Role = new Sys_VisibilityGroup_RoleDS();
                dstData.Merge(dsVisibilityGroup_Role.List().Tables[0]);
                Sys_RoleDS dsRole = new Sys_RoleDS();
                dstData.Merge(dsRole.ListAll().Tables[0]);
            }
            catch (PCSDBException ex)
            {
                throw new PCSBOException(CANNOT_GET_VISIBILITY_DATA, METHOD_NAME, ex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(dstData);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update Dataset of table Sys_Role after deleting related rights
        /// </summary>
        /// <param name="dstData"></param>
        /// <Author>Duong NA, Oct-10-2005 </Author>

        public void UpdateDataSetAndDelete(DataSet dstData, string pstrDeletedRoleIDs)
        {
            const char CHR_SEPARATOR = ',';
            //const int DEFAULT_PERMISSION = 1;
            string strAddedRole = string.Empty;

            //Begin edit by duongna 10-10-2005 to add default menus to new role and delete all menus assigned to role
            //mark added role

            foreach (DataRow drRole in dstData.Tables[0].Rows)
            {
                if (drRole.RowState == DataRowState.Added)
                {
                    strAddedRole += "'" + drRole[Sys_RoleTable.NAME_FLD].ToString().Replace("'", "''") + "' ,";
                }
            }

            if (strAddedRole.EndsWith(CHR_SEPARATOR.ToString()))
            {
                strAddedRole = strAddedRole.Substring(0, strAddedRole.Length - 1);
            }

            //Delete all menu entries assigned to this role

            Sys_RightDS objRightDS = new Sys_RightDS();

            if (pstrDeletedRoleIDs.Length > 0)
            {
                pstrDeletedRoleIDs = pstrDeletedRoleIDs.Replace(';', ',');
                objRightDS.DeleteRightsOfRole(pstrDeletedRoleIDs);
            }

            //End edit by duongna 10-10-2005

            //Init the DS object
            Sys_RoleDS objSysRoleDs = new Sys_RoleDS();

            objSysRoleDs.UpdateDataSet(dstData);

            //
            if (strAddedRole.Length > 0)
            {
                Sys_VisibilityGroup_RoleDS dsVisibility = new Sys_VisibilityGroup_RoleDS();
                dsVisibility.InsertDefaultVisibility(strAddedRole);
                objRightDS.InsertDefaultMenu(strAddedRole);
            }
            //Begin edit by duongna 10-10-2005

            #region             // HACK: DEL SonHT 2005-12-09

            //Add default menus for added role
//			foreach (string strIndex in strAddedRole.Split(CHR_SEPARATOR))
//			{
//				try
//				{
//					nIndex = Convert.ToInt32(strIndex);
//				}
//				catch
//				{
//					continue;
//				}
//				if (dstData.Tables[0].Rows[nIndex].RowState == DataRowState.Unchanged)
//				{
//					//Get all default menu entry
//					Sys_Menu_EntryDS objSysMenuDS = new Sys_Menu_EntryDS();
//					Sys_RightDS objSysRight = new Sys_RightDS();
//					ArrayList arrDefaultMenus = objSysMenuDS.GetAllDefaultMenus();
//					//Do add default rights here
//					foreach (int nMenuID in arrDefaultMenus)
//					{
//						Sys_RightVO voRight = new Sys_RightVO();
//						voRight.Menu_EntryID = nMenuID;
//						voRight.Permission = DEFAULT_PERMISSION;
//						try
//						{
//							voRight.RoleID = Convert.ToInt32(dstData.Tables[0].Rows[nIndex][Sys_RoleTable.ROLEID_FLD]);
//						}
//						catch
//						{
//							continue;
//						}
//						objSysRight.Add(voRight);
//					}
//				}
//			}
            //End edit by duongna
            #endregion             // END: DEL SonHT 2005-12-09
        }