示例#1
0
        public CategoryTree(FwkCategory pFwkCategory)
        {
            //Rules = new List<CategoryTree>();
            this.FwkCategory = pFwkCategory;
            this.Id          = pFwkCategory.CategoryId.ToString();

            this.Name = pFwkCategory.Name;
            if (pFwkCategory.ParentId.HasValue)
            {
                ParentId = pFwkCategory.ParentId.Value.ToString();
            }
            else
            {
                ParentId = "0";
            }

            //if (pFwkCategory.FwkRulesInCategoryList != null)
            //{

            //    CategoryTree rule = null;
            //    foreach (FwkAuthorizationRule r in pFwkCategory.FwkRulesInCategoryList)
            //    {
            //        rule = new CategoryTree();
            //        rule.Name = r.Name.Trim();
            //        rule.ParentId = this.Id;
            //        rule.Id = string.Concat(this.Id, "_", r.Name.Trim());
            //        rule.IsCategory = false;
            //        this.Rules.Add(rule);
            //    }
            //}
        }
示例#2
0
        private void treeList1_Click(object sender, EventArgs e)
        {
            if (treeList1.FocusedNode != null)
            {
                _SelectedCategory = (FwkCategory)treeList1.GetDataRecordByNode(treeList1.FocusedNode);

                bindingSourceRules.DataSource = _SelectedCategory.FwkRulesInCategoryList;

                grdRulesByCategory.RefreshDataSource();
            }
        }
示例#3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pFwkCategory"></param>
        /// <param name="connectionStringName">Nombre de cadena de coneccion del archivo de configuracion.-</param>
        /// <param name="applicationName">Nombre de la aplicacion. Coincide con CompanyId en la arquitectura</param>
        public static void CreateCategory(FwkCategory pFwkCategory, string applicationName, string connectionStringName)
        {
            Database wDataBase = null;
            DbCommand wCmd = null;


            try
            {
                Guid wApplicationId = GetApplication(applicationName, connectionStringName);

                wDataBase = DatabaseFactory.CreateDatabase(connectionStringName);
                StringBuilder str = new StringBuilder(FwkMembershipScripts.Category_i);


                str.Replace("[ApplicationId]", wApplicationId.ToString());
                if (pFwkCategory.ParentId == null) pFwkCategory.ParentId = 0;
                str.Replace("[ParentCategoryId]", pFwkCategory.ParentId.ToString());
                str.Replace("[CategoryName]", pFwkCategory.Name.ToLower());

                wCmd = wDataBase.GetSqlStringCommand(str.ToString());
                wCmd.CommandType = CommandType.Text;

                pFwkCategory.CategoryId = Convert.ToInt32(wDataBase.ExecuteScalar(wCmd));

                if (pFwkCategory.FwkRulesInCategoryList != null)
                    if (pFwkCategory.FwkRulesInCategoryList.Count != 0)
                        CreateRuleInCategory(pFwkCategory, applicationName.ToLower(), connectionStringName);



            }
            catch (TechnicalException tx)
            { throw tx; }
            catch (Exception ex)
            {
                TechnicalException te = new TechnicalException(Fwk.Security.Properties.Resource.MembershipSecurityGenericError, ex);
                ExceptionHelper.SetTechnicalException<FwkMembership>(te);
                te.ErrorId = "4000";
                throw te;
            }
        }
示例#4
0
        void Create_Categoty(string name)
        {
            FwkCategory wFwkCategory = new FwkCategory();

            wFwkCategory.Name = name;
            if (_CurrentCategory != null)
            {
                wFwkCategory.ParentId = Convert.ToInt32(_CurrentCategory.Id);
            }
            else
            {
                wFwkCategory.ParentId = 0;
            }

            try
            {
                FwkMembership.CreateCategory(wFwkCategory, frmAdmin.Provider.Name);
                MessageViewInfo.Show("Category was successfully created");
                PopulateAsync();
            }
            catch (Exception ex)
            { throw ex; }
        }
示例#5
0
        /// <summary>
        /// Obtiene las Categorias de una determinada aplicacion. Recibe el Nombre de cadena de coneccion del archivo de configuracion.-
        /// </summary>
        /// <param name="applicationName">Nombre de la aplicacion. Coincide con CompanyId en la arquitectura</param>
        /// <param name="connectionStringName">Nombre de cadena de coneccion del archivo de configuracion.-</param>
        /// <returns></returns>
        public static FwkCategoryList GetAllCategories(string applicationName, string connectionStringName)
        {

            FwkCategory wCategory;
            FwkCategoryList wCategoryList = null;
            try
            {
                Guid wApplicationId = GetApplication(applicationName, connectionStringName);
                using (Fwk.Security.RuleProviderDataContext dc = new Fwk.Security.RuleProviderDataContext(System.Configuration.ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString))
                {
                    var rulesinCat = from s in dc.aspnet_RulesCategories where s.ApplicationId == wApplicationId select s;

                    wCategoryList = new FwkCategoryList();
                    foreach (aspnet_RulesCategory aspnet_cat in rulesinCat.ToList<aspnet_RulesCategory>())
                    {
                        wCategory = new FwkCategory();
                        wCategory.CategoryId = aspnet_cat.CategoryId;
                        if (aspnet_cat.ParentCategoryId != null)
                            wCategory.ParentId = aspnet_cat.ParentCategoryId;
                        wCategory.Name = aspnet_cat.Name;
                        wCategoryList.Add(wCategory);
                    }

                }

                foreach (FwkCategory category in wCategoryList)
                {
                    category.FwkRulesInCategoryList = GetFwkRules_By_Category(category.CategoryId, connectionStringName);
                }


                return wCategoryList;
            }
            catch (TechnicalException tx)
            { throw tx; }
            catch (Exception ex)
            {

                TechnicalException te = new TechnicalException(Fwk.Security.Properties.Resource.MembershipSecurityGenericError, ex);
                ExceptionHelper.SetTechnicalException<FwkMembership>(te);
                te.ErrorId = "4000";
                throw te;
            }
        }
示例#6
0
        /// <summary>
        /// Obtiene las subcategorias de una categoria.-
        /// </summary>
        /// <param name="pCategoryId"></param>
        /// <param name="applicationName">Nombre de la aplicacion de membership</param>
        /// <param name="connectionStringName">Nombre de cadena de coneccion</param>
        /// <returns></returns>
        static List<FwkCategory> GetSubCategoriesByCategoryId(int pCategoryId, string applicationName, string connectionStringName)
        {

            IEnumerable<FwkCategory> wCategories = null;
            FwkCategory wFwkCategory = new FwkCategory();
            try
            {
                Guid wApplicationId = GetApplication(applicationName, connectionStringName);
                using (Fwk.Security.RuleProviderDataContext dc = new Fwk.Security.RuleProviderDataContext(System.Configuration.ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString))
                {
                    wCategories = from s in dc.aspnet_RulesCategories
                                  where (s.ParentCategoryId == pCategoryId
                        && s.ApplicationId == wApplicationId)
                                  select new FwkCategory { CategoryId = s.CategoryId, ParentId = s.ParentCategoryId, Name = s.Name };

                    //var wRulesCategories = from s in dc.aspnet_RulesCategories
                    //                       where (s.ParentCategoryId == pCategoryId
                    //                       && s.ApplicationId == wApplicationId)
                    //                       select s;

                    //foreach(aspnet_RulesCategory rule in wRulesCategories.ToList<aspnet_RulesCategory>())
                    //{
                    //    wFwkCategory = new FwkCategory ();
                    //    wFwkCategory.CategoryId = pCategoryId;
                    //    wFwkCategory.Name = rule.Name;
                    //    wFwkCategory.ParentId = rule.ParentCategoryId;

                    //wCategories.Add(wFwkCategory);
                    //}
                    return wCategories.ToList<FwkCategory>();
                }

            }
            catch (TechnicalException tx)
            { throw tx; }
            catch (Exception ex)
            {

                TechnicalException te = new TechnicalException(Fwk.Security.Properties.Resource.MembershipSecurityGenericError, ex);
                ExceptionHelper.SetTechnicalException<FwkMembership>(te);
                te.ErrorId = "4000";
                throw te;
            }

        }
示例#7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="pFwkCategory"></param>
 /// <param name="providerName">Nombre del proveedor de membership</param>
 public static void CreateCategory(FwkCategory pFwkCategory, string providerName)
 {
     SqlMembershipProvider wProvider = GetSqlMembershipProvider(providerName);
     CreateCategory(pFwkCategory, wProvider.ApplicationName, GetProvider_ConnectionStringName(wProvider.Name));
 }
示例#8
0
        /// <summary>
        /// Elimina todas las filas de RuleInCategory y las agrega nuevamente.- 
        /// Las que agrega son las que se mofificaron desde el front end u otro origen.-
        /// </summary>
        /// <param name="pFwkCategory"></param>
        /// <param name="applicationName">Nombre de la aplicacion. Coincide con CompanyId en la arquitectura</param>
        /// <param name="connectionStringName">Nombre de cadena de coneccion del archivo de configuracion.-</param>
        static void CreateRuleInCategory(FwkCategory pFwkCategory, string applicationName, string connectionStringName)
        {
            Database wDataBase = null;
            DbCommand wCmd = null;
            Guid id = GetApplication(applicationName, connectionStringName);

            try
            {
                wDataBase = DatabaseFactory.CreateDatabase(connectionStringName);
                StringBuilder str = new StringBuilder(FwkMembershipScripts.RulesInCategory_d);

                foreach (FwkAuthorizationRule rule in pFwkCategory.FwkRulesInCategoryList)
                {
                    str.Append(FwkMembershipScripts.RuleInCategory_i);
                    str.Replace("[RuleId]", rule.Id.ToString());
                }
                str.Replace("[CategoryId]", pFwkCategory.CategoryId.ToString());
                str.Replace("[ApplicationId]", id.ToString());
                wCmd = wDataBase.GetSqlStringCommand(str.ToString());
                wCmd.CommandType = CommandType.Text;

                wDataBase.ExecuteNonQuery(wCmd);
            }
            catch (Exception ex)
            {
                TechnicalException te = new TechnicalException(Fwk.Security.Properties.Resource.MembershipSecurityGenericError, ex);
                ExceptionHelper.SetTechnicalException<FwkMembership>(te);
                te.ErrorId = "4000";
                throw te;
            }
        }
示例#9
0
        void Create_Categoty(string name)
        {
            FwkCategory wFwkCategory = new FwkCategory();

            wFwkCategory.Name = name;
            if (_CurrentCategory != null)
                wFwkCategory.ParentId = Convert.ToInt32(_CurrentCategory.Id);
            else
                wFwkCategory.ParentId = 0;

            try
            {
                FwkMembership.CreateCategory(wFwkCategory, frmAdmin.Provider.Name);
                MessageViewInfo.Show("Category was successfully created");
                PopulateAsync();
            }
            catch (Exception ex)
            { throw ex; }

        }