Esempio n. 1
0
        public static CustomList <RuleDetails> GetAllSecurityRule_ObjectWithApplicationID(string applicationID)
        {
            ConnectionManager        conManager = new ConnectionManager(ConnectionName.SysMan);
            CustomList <RuleDetails> SecurityRule_ObjectCollection = new CustomList <RuleDetails>();
            IDataReader reader = null;
            String      sql    = "Select * from RuleDetails where ApplicationID='" + applicationID + "'";

            try
            {
                conManager.OpenDataReader(sql, out reader);
                while (reader.Read())
                {
                    RuleDetails newSecurityRule_Object = new RuleDetails();
                    newSecurityRule_Object.SetData(reader);
                    SecurityRule_ObjectCollection.Add(newSecurityRule_Object);
                }
                return(SecurityRule_ObjectCollection);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
Esempio n. 2
0
        private void ProManSys_Checked()
        {
            try
            {
                String refSourceString = String.Empty;
                CustomList<RuleDetails> SecurityRuleDetailList = new CustomList<RuleDetails>();
                CustomList<SECURITY.DAO.Menu> MenuList = (CustomList<SECURITY.DAO.Menu>)HttpContext.Current.Session["SecurityRule_MenuList"];
                CustomList<TempRuleDetails> TempSecurityRuleDetailList = (CustomList<TempRuleDetails>)HttpContext.Current.Session["SecurityRule_TempSecurityRuleDetailList"];
                string hfApplicationID = (string)HttpContext.Current.Session["ApplicationID"];
                string PersonName = (string)HttpContext.Current.Session["PersonName"];
                string CompanyID = (string)HttpContext.Current.Session["CompanyID"];
                CustomList<SECURITY.DAO.Menu> SelectedMenuList = MenuList.FindAll(f => f.IsModified);
                foreach (SECURITY.DAO.Menu M in SelectedMenuList)
                {
                    if (M.CanInsert || M.CanSelect || M.CanUpdate || M.CanDelete)
                    {
                        RuleDetails objNewSRO = new RuleDetails();
                        objNewSRO.ApplicationID = M.ApplicationID;
                        objNewSRO.ObjectID = M.MenuID;
                        objNewSRO.ObjectType = "Menu";
                        objNewSRO.CanInsert = M.CanInsert;
                        objNewSRO.CanSelect = M.CanSelect;
                        objNewSRO.CanUpdate = M.CanUpdate;
                        objNewSRO.CanDelete = M.CanDelete;
                        SecurityRuleDetailList.Add(objNewSRO);
                    }
                }

                CustomList<Application> ApplicationList = (CustomList<Application>)HttpContext.Current.Session["SecurityRule_ApplicationList"];
                foreach (Application a in ApplicationList)
                {
                    CustomList<RuleDetails> upDate = SecurityRuleDetailList.FindAll(f => f.ApplicationID == a.ApplicationID);
                    CustomList<RuleDetails> newUpdate = new CustomList<RuleDetails>();
                    newUpdate = upDate.FindAll(f => f.CanInsert == true || f.CanSelect == true || f.CanUpdate == true || f.CanDelete == true);
                    if (newUpdate.Count != 0)
                        a.IsSaved = true;
                    else
                        a.IsSaved = false;
                }

                HttpContext.Current.Session["SecurityRule_MenuList"] = MenuList;
                HttpContext.Current.Session["SecurityRule_SecurityRuleDetailList"] = SecurityRuleDetailList;
                HttpContext.Current.Session["SecurityRule_TempSecurityRuleDetailList"] = TempSecurityRuleDetailList;
                HttpContext.Current.Session["SecurityRule_ApplicationList"] = ApplicationList;

                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.ContentType = "text/plain";
                HttpContext.Current.Response.Write(refSourceString);
                HttpContext.Current.Response.Flush();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
 public static CustomList<RuleDetails> GetAllSecurityRule_ObjectWithSecurityRule(string securityRuleCode)
 {
     ConnectionManager conManager = new ConnectionManager(ConnectionName.SysMan);
     CustomList<RuleDetails> SecurityRule_ObjectCollection = new CustomList<RuleDetails>();
     IDataReader reader = null;
     String sql = "Select * from RuleDetails where SecurityRuleCode='" + securityRuleCode + "'";
     try
     {
         conManager.OpenDataReader(sql, out reader);
         while (reader.Read())
         {
             RuleDetails newSecurityRule_Object = new RuleDetails();
             newSecurityRule_Object.SetData(reader);
             SecurityRule_ObjectCollection.Add(newSecurityRule_Object);
         }
         return SecurityRule_ObjectCollection;
     }
     catch (Exception ex)
     {
         throw (ex);
     }
     finally
     {
         if (reader != null && !reader.IsClosed)
             reader.Close();
     }
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                CustomList<SECURITY.DAO.SecurityRule> lstSecurityRule = SecurityRuleList;
                if (lstSecurityRule.Count == 0)
                {
                    SECURITY.DAO.SecurityRule newSecurityRule = new SECURITY.DAO.SecurityRule();
                    lstSecurityRule.Add(newSecurityRule);
                }

                SetDataControlsToSecurityRuleObject(ref lstSecurityRule);
                CustomList<SECURITY.DAO.Menu> AllMenu = (CustomList<SECURITY.DAO.Menu>)Session["SecurityRule_MenuList"];
                CustomList<SECURITY.DAO.Menu> selectedMenu = AllMenu.FindAll(f => f.CanSelect || f.CanInsert || f.CanUpdate || f.CanDelete);
                objSecurityRuleDetailList = new CustomList<RuleDetails>();
                foreach (SECURITY.DAO.Menu m in selectedMenu)
                {
                    RuleDetails obj = new RuleDetails();
                    obj.ApplicationID = m.ApplicationID;
                    obj.ObjectID = m.MenuID;
                    obj.ObjectType = "menu";
                    obj.CanSelect = m.CanSelect;
                    obj.CanInsert = m.CanInsert;
                    obj.CanUpdate = m.CanUpdate;
                    obj.CanDelete = m.CanDelete;
                    objSecurityRuleDetailList.Add(obj);
                }
                //objSecurityRuleDetailList = SecurityRuleDetailList;
                if (!CheckUserAuthentication(lstSecurityRule, objSecurityRuleDetailList)) return;
                if (lstSecurityRule.IsNotNull())
                {
                    #region Delete
                    CustomList<RuleDetails> securityRuleObject = manager.GetAllSecurityRule_ObjectWithSecurityRule(lstSecurityRule[0].SecurityRuleCode);
                    if (securityRuleObject.Count != 0)
                    {
                        foreach (RuleDetails obj in securityRuleObject)
                        {
                            obj.Delete();
                        }
                        manager.TempSecurityRule_ObjectDelete(ref securityRuleObject);
                    }
                    #endregion

                    manager.SaveSecurityRule(ref lstSecurityRule, ref objSecurityRuleDetailList);
                    txtSecurityRuleCode.Text = manager.SecurityRuleInfoID;
                    this.SuccessMessage = (StaticInfo.SavedSuccessfullyMsg);
                }
            }
            catch (SqlException ex)
            {
                this.ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex));
            }
            catch (Exception ex)
            {
                this.ErrorMessage = (ExceptionHelper.getExceptionMessage(ex));
            }
        }