Exemplo n.º 1
0
        public void SaveRegionConfig(string[] name, int rolepkid)
        {
            Session session = new Session();

            try
            {
                session.BeginTransaction();
                BusinessObjectCollection regioncollection = new BusinessObjectCollection("RoleDataPermission");
                regioncollection.SessionInstance = session;
                BusinessFilter filter = new BusinessFilter("RoleDataPermission");
                filter.AddFilterItem("FK_Role", rolepkid.ToString(), Operation.Equal, FilterType.NumberType, AndOr.AND);
                filter.AddFilterItem("Type", Convert.ToString((int)DictionaryType.Region), Operation.Equal, FilterType.NumberType, AndOr.AND);
                regioncollection.AddFilter(filter);
                regioncollection.DeleteFilter();

                for (int index = 0; index < name.Length; index++)
                {
                    BusinessMapping.RoleDataPermission regionright = new RoleDataPermission();
                    regionright.SessionInstance     = session;
                    regionright.FK_Role.Value       = rolepkid;
                    regionright.Type.Value          = 1;
                    regionright.FK_Dictionary.Value = int.Parse(name[index].ToString());
                    regionright.CreateUser.Value    = SystemContext.GetContext().UserID;
                    regionright.ModifyUser.Value    = SystemContext.GetContext().UserID;
                    regionright.CreateTime.Value    = regionright.ModifyTime.Value = DateTime.Now;
                    regionright.Insert();
                }
                session.Commit();

                OperationLog opLog = new OperationLog();
                opLog.WriteOperationLog("数据权限管理", "配置数据权限");
            }
            catch
            {
                session.Rollback();
            }
        }