示例#1
0
 public void UpdateMenu(sys_menu dto, string funcs)
 {
     if (!string.IsNullOrEmpty(dto.menu_url))
     {
         dto.menu_type = 1;
     }
     if (dto.parent_id == 0)
     {
         dto.menu_level = 1;
     }
     else
     {
         dto.menu_level = Sqldb.Queryable <sys_menu>().Where(s => s.id == dto.parent_id).Select(s => s.menu_level).First() + 1;
     }
     Sqldb.Updateable(dto).IgnoreColumns(s => new { s.create_time, s.create_person }).ExecuteCommand();
     Sqldb.Deleteable <sys_menu_ref_operate>().Where(s => s.menu_id == dto.id).ExecuteCommand();
     if (!string.IsNullOrEmpty(funcs))
     {
         var funcArray = funcs.Split(',');
         if (funcArray.Length > 0)
         {
             var list = new List <sys_menu_ref_operate>();
             foreach (var func in funcArray)
             {
                 var funcModel = new sys_menu_ref_operate();
                 funcModel.menu_id    = dto.id;
                 funcModel.operate_id = func.ToInt64();
                 list.Add(funcModel);
             }
             Sqldb.Insertable(list).ExecuteCommand();
         }
     }
 }
示例#2
0
 public void SaveRoleAuth(string roleId, string ids)
 {
     Sqldb.Deleteable <sys_role_authorize>().Where(s => s.role_id == SqlFunc.ToInt64(roleId)).ExecuteCommand();
     if (!string.IsNullOrEmpty(ids))
     {
         var list    = new List <sys_role_authorize>();
         var menuIds = ids.ToObject <List <ZtreeDto> >();
         foreach (var mid in menuIds)
         {
             mid.pId = mid.pId ?? "0";
             var model = new sys_role_authorize();
             model.id            = IdWorkerHelper.NewId();
             model.role_id       = roleId.ToInt64();
             model.menu_id       = mid.id.ToInt64();
             model.menu_pid      = mid.pId.ToInt64();
             model.create_time   = DateTime.Now;
             model.create_person = UserCookie.AccountName;
             list.Add(model);
         }
         if (list.Any())
         {
             Sqldb.Insertable(list).ExecuteCommand();
         }
     }
 }
示例#3
0
        public string[] DeleteTask(string ids)
        {
            var idsArry = ids.Split(',');

            Sqldb.Deleteable <hangfire_jobs>().Where(s => idsArry.Contains(s.id)).ExecuteCommand();
            return(idsArry);
        }
示例#4
0
 public void DelByIds(string ids)
 {
     if (!string.IsNullOrEmpty(ids))
     {
         var idsArray = ids.Split(',');
         Sqldb.Deleteable <sys_area>().In(idsArray).ExecuteCommand();
     }
 }
示例#5
0
 public void DelRoleByIds(string ids)
 {
     if (!string.IsNullOrEmpty(ids))
     {
         var idsArray = ids.Split(',').StrToLongArray();
         Sqldb.Deleteable <sys_role>().In(idsArray).ExecuteCommand();
         Sqldb.Deleteable <sys_role_authorize>().Where(s => idsArray.Contains(s.role_id)).ExecuteCommand();
     }
 }
示例#6
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="dto"></param>
        public void UpdateMenu(sys_menu dto, string funcs)
        {
            if (!string.IsNullOrEmpty(dto.menu_url))
            {
                dto.menu_type = 1;
            }
            if (dto.parent_id == 0)
            {
                dto.menu_level = 1;
            }
            else
            {
                dto.menu_level = Sqldb.Queryable <sys_menu>().Where(s => s.id == dto.parent_id).Select(s => s.menu_level)
                                 .First() + 1;
            }
            Sqldb.Updateable(dto).IgnoreColumns(s => new { s.create_time, s.create_person }).ExecuteCommand();

            //设置菜单下按钮
            Sqldb.Deleteable <sys_operate>().Where(s => s.menu_id == dto.id).ExecuteCommand();
            if (dto.menu_type == 1 && !string.IsNullOrEmpty(funcs))
            {
                var funcArray = funcs.ToObject <List <SysFuncDto> >();
                var list      = new List <sys_operate>();
                foreach (var func in funcArray)
                {
                    var funcModel = new sys_operate();
                    funcModel.menu_id    = dto.id;
                    funcModel.func_cname = func.title;
                    funcModel.func_name  = func.funcname;
                    funcModel.func_icon  = func.icon;
                    funcModel.func_url   = func.url;
                    funcModel.in_table   = func.intable;
                    funcModel.func_sort  = func.funcSort;
                    funcModel.id         = func.id > 0 ? func.id : IdWorkerHelper.NewId();
                    list.Add(funcModel);
                }
                Sqldb.Insertable(list).ExecuteCommand();
            }
        }
示例#7
0
 public void DelByIds(string ids)
 {
     try
     {
         if (!string.IsNullOrEmpty(ids))
         {
             var    idsArray = ids.Split(',');
             long[] arri     = idsArray.StrToLongArray();
             Sqldb.Ado.BeginTran();
             Sqldb.Deleteable <sys_operate>().In(idsArray).ExecuteCommand();
             Sqldb.Deleteable <sys_menu_ref_operate>().Where(s => arri.Contains(s.operate_id)).ExecuteCommand();
             Sqldb.Deleteable <sys_role_authorize>()
             .Where(s => arri.Contains(s.menu_id)).ExecuteCommand();
             Sqldb.Ado.CommitTran();
         }
     }
     catch (Exception ex)
     {
         Sqldb.Ado.RollbackTran();
         throw ex;
     }
 }
示例#8
0
 /// <summary>
 /// 删除操作
 /// </summary>
 /// <param name="funcId"></param>
 public void Delfunc(long funcId)
 {
     Sqldb.Deleteable <sys_operate>().Where(s => s.id == funcId).ExecuteCommand();
     Sqldb.Deleteable <sys_role_authorize>().Where(s => s.menu_id == funcId).ExecuteCommand();
 }