Пример #1
0
        public int Delete(string classcode)
        {
            //删功能,删菜单,删分配
            //删除WFDistribution
            string[] funcIDAry = Dal.From <FunctionInfo>().Where(FunctionInfo._.ClassCode.StartsWith(classcode)).Select(FunctionInfo._.ID).ToSinglePropertyArray();

            ParameterInfoDataAccess paraClient = new ParameterInfoDataAccess();
            ParameterInfo           version    = paraClient.GetEntity("41585e05-7246-44d1-ada2-92112d0cda61");//功能版本

            version.Value = (int.Parse(version.Value) + 1).ToString();

            SessionFactory dal;
            IDbTransaction tr = Dal.BeginTransaction(out dal);

            try
            {
                dal.BeginBatch(50, tr);
                dal.SubmitNew(tr, ref dal, version);
                dal.Delete <FunctionInfo>(FunctionInfo._.ClassCode.StartsWith(classcode), tr);
                dal.Delete <MenuInfo>(MenuInfo._.FuntionID.In(funcIDAry), tr);
                dal.Delete <Permission>(Permission._.FunID.In(funcIDAry), tr);
                dal.FromCustomSql("delete WFDistribution where EXISTS (select 1 from FunctionInfo where FunctionInfo.id=WFDistribution.FuncId and  ClassCode like @classCode+'%'   )", tr)
                .AddInputParameter("classCode", classcode).ExecuteNonQuery();
                dal.EndBatch(tr);
                dal.CommitTransaction(tr);
                return(1);
            }
            catch (Exception)
            {
                dal.RollbackTransaction(tr);

                throw;
                return(0);
            }
        }
Пример #2
0
        public int Delete(string id, ref string error)
        {
            if (Dal.Exists <RoleAndUserRalation>(RoleAndUserRalation._.RoleId == id))
            {
                error = "当前角色已被使用,不能删除";
                return(-1);
            }
            ParameterInfoDataAccess paraClient = new ParameterInfoDataAccess();
            ParameterInfo           version    = paraClient.GetEntity("478d3892-df2d-4f2b-b1f7-43d4398fcafc");//权限版本

            version.Value = (int.Parse(version.Value) + 1).ToString();
            SessionFactory dal;
            IDbTransaction tr = Dal.BeginTransaction(out dal);
            int            i  = 0;

            try
            {
                dal.SubmitNew(tr, ref dal, version);
                dal.Delete <Role>(tr, id);
                i = dal.Delete <Permission>(Permission._.RoleID == id, tr);
                dal.CommitTransaction(tr);
                return(i);
            }
            catch (Exception ex)
            {
                dal.RollbackTransaction(tr);
                error = ex.Message;
                return(-1);

                throw;
            }
        }
Пример #3
0
        public int Delete(string classcode)
        {
            ParameterInfoDataAccess paraClient = new ParameterInfoDataAccess();
            ParameterInfo           version    = paraClient.GetEntity("3eb2fb3d-061b-4c18-b37f-3f84360380f7");//菜单版本

            version.Value = (int.Parse(version.Value) + 1).ToString();
            // 删菜单,删分配
            string[] menuIDAry = Dal.From <MenuInfo>().Where(MenuInfo._.ClassCode.StartsWith(classcode)).Select(MenuInfo._.ID).ToSinglePropertyArray();

            SessionFactory dal;
            IDbTransaction tr = Dal.BeginTransaction(out dal);

            try
            {
                dal.BeginBatch(50, tr);
                dal.SubmitNew(tr, ref dal, version);
                dal.Delete <MenuInfo>(MenuInfo._.ClassCode.StartsWith(classcode), tr);
                dal.Delete <Permission>(Permission._.MenuID.In(menuIDAry), tr);
                dal.EndBatch(tr);
                dal.CommitTransaction(tr);
                return(1);
            }
            catch (Exception)
            {
                dal.RollbackTransaction(tr);
                throw;
            }
        }
Пример #4
0
        public int Save(List <FunctionInfo> list)
        {
            ParameterInfoDataAccess paraClient = new ParameterInfoDataAccess();
            ParameterInfo           version    = paraClient.GetEntity("41585e05-7246-44d1-ada2-92112d0cda61");//功能版本

            version.Value = (int.Parse(version.Value) + 1).ToString();
            List <BaseEntity> listnew = new List <BaseEntity>();

            listnew.Add(version);
            listnew.AddRange(list);
            return(Dal.Submit(listnew));
        }
Пример #5
0
        public int Save(AuthorityEntity.Role item)
        {
            ParameterInfoDataAccess paraClient = new ParameterInfoDataAccess();
            ParameterInfo           version    = paraClient.GetEntity("478d3892-df2d-4f2b-b1f7-43d4398fcafc");//权限版本

            if (string.IsNullOrEmpty(version.Value))
            {
                version.Value = "0";
            }
            version.Value = (int.Parse(version.Value) + 1).ToString();

            return(Dal.Submit(item, version));
        }
Пример #6
0
        public int Save(FunctionInfo item)
        {
            ParameterInfoDataAccess paraClient = new ParameterInfoDataAccess();
            ParameterInfo           version    = paraClient.GetEntity("41585e05-7246-44d1-ada2-92112d0cda61");//功能版本

            if (string.IsNullOrEmpty(version.Value))
            {
                version.Value = "0";
            }
            version.Value = (int.Parse(version.Value) + 1).ToString();
            List <FunctionInfo> parentList = new List <FunctionInfo>();

            if (item.IsMust)
            {
                //必备功能,则将其父功能不处理,
                //其子功能及其菜单,如果有不是必备的,则改为在权限设置里显示
                item.IsMustNot = true;
                if (item.RecordStatus != StatusType.add)
                {
                    if (Dal.Exists <FunctionInfo>(FunctionInfo._.ClassCode.StartsWith(item.ClassCode + ";") && FunctionInfo._.IsMust == false))
                    {
                        item.IsMustNot = false;
                    }

                    if (item.IsMustNot)
                    {
                        if (Dal.Exists <MenuInfo>(MenuInfo._.FuntionID == item.ID && MenuInfo._.IsMust == false && MenuInfo._.Name != "菜单" && MenuInfo._.Name != "工具栏" && MenuInfo._.Name != "右键菜单" && MenuInfo._.Name != "控件"))
                        {
                            item.IsMustNot = false;
                        }
                    }
                }
            }
            else
            {
                if (!item.IsMustNot)
                {
                    //不是必备功能,则将其父功能都显示
                    string classcode = item.ClassCode;
                    while (classcode.Length > 37)
                    {
                        classcode = classcode.Substring(0, classcode.Length - 37);
                        FunctionInfo parent = new FunctionInfo();
                        parent.RecordStatus = StatusType.update;
                        parent.Where        = FunctionInfo._.ClassCode == classcode;
                        parent.IsMustNot    = false;
                        parentList.Add(parent);
                    }
                }
            }
            Sharp.Data.SessionFactory dal;
            IDbTransaction            tr = Dal.BeginTransaction(out dal);

            try
            {
                dal.SubmitNew(ref dal, item, version);
                dal.SubmitNew(tr, ref dal, parentList);
                dal.CommitTransaction(tr);
                return(1);
            }
            catch (Exception)
            {
                dal.RollbackTransaction(tr);
                return(-1);
            }
        }
Пример #7
0
        public int Save(List <MenuInfo> list)
        {
            ParameterInfoDataAccess paraClient = new ParameterInfoDataAccess();
            ParameterInfo           version    = paraClient.GetEntity("3eb2fb3d-061b-4c18-b37f-3f84360380f7");//菜单版本

            if (string.IsNullOrEmpty(version.Value))
            {
                version.Value = "0";
            }
            version.Value = (int.Parse(version.Value) + 1).ToString();
            List <FunctionInfo> fucList    = new List <FunctionInfo>();
            List <MenuInfo>     parentList = new List <MenuInfo>();

            foreach (var item in list)
            {
                if (item.Name != "菜单" && item.Name != "工具栏" && item.Name != "右键菜单" && item.Name != "控件")
                {
                    if (item.IsMust)
                    {
                        //必备功能,则将其父菜单不处理,
                        //其子菜单,如果有不是必备的,则改为在权限设置里显示
                        item.IsMustNot = true;

                        if (item.RecordStatus != StatusType.add)
                        {
                            if (Dal.Exists <MenuInfo>(MenuInfo._.ClassCode.StartsWith(item.ClassCode + ";") && MenuInfo._.IsMust == false))
                            {
                                item.IsMustNot = false;
                            }
                        }
                    }
                    else
                    {
                        //不是必备功能,则将其功能显示
                        if (!item.IsMustNot)
                        {
                            FunctionInfo parent = new FunctionInfo();
                            parent.RecordStatus = StatusType.update;
                            parent.Where        = FunctionInfo._.ID == item.FuntionID;
                            parent.IsMustNot    = false;
                            fucList.Add(parent);

                            //不是必备功能,则将其父菜单都显示

                            string classcode = item.ClassCode;
                            while (classcode.Length > 37)
                            {
                                classcode = classcode.Substring(0, classcode.Length - 37);
                                MenuInfo parentmenu = new MenuInfo();
                                parentmenu.RecordStatus = StatusType.update;
                                parentmenu.Where        = MenuInfo._.ClassCode == classcode && MenuInfo._.Name != "菜单" && MenuInfo._.Name != "工具栏" && MenuInfo._.Name != "右键菜单" && MenuInfo._.Name != "控件";
                                parentmenu.IsMustNot    = false;
                                parentList.Add(parentmenu);
                            }
                        }
                    }
                }
            }
            Sharp.Data.SessionFactory dal;
            IDbTransaction            tr = Dal.BeginTransaction(out dal);

            try
            {
                dal.BeginBatch(20, tr);
                dal.SubmitNew(tr, ref dal, version);
                dal.SubmitNew(tr, ref dal, list);
                dal.SubmitNew(tr, ref dal, fucList);
                dal.SubmitNew(tr, ref dal, parentList);
                dal.EndBatch(tr);
                dal.CommitTransaction(tr);
                return(0);
            }
            catch (Exception ex)
            {
                dal.RollbackTransaction(tr);
                //LogDataAccess.LogDal.Write(ex);
                return(-1);

                throw;
            }
        }