Exemplo n.º 1
0
        public void Update(string functionId, string administratorId, IList <string> tableColumnIds)
        {
            using (var dal = new BaseDal())
            {
                var list = dal.TableColumnAndAdmin.Where(o => ((o.FunctionId == functionId) && (o.AdministratorId == administratorId)));

                var tableColumnList = dal.TableColumn.Where(o => o.FunctionId == functionId);

                dal.TableColumnAndAdmin.RemoveRange(list);
                foreach (var p in tableColumnIds)
                {
                    var tableColumn = tableColumnList.SingleOrDefault(o => o.TableColumnId == p);
                    if (tableColumn == null)
                    {
                        continue;
                    }

                    dal.TableColumnAndAdmin.Add(new TableColumnAndAdminDefinition()
                    {
                        TableColumnId   = p,
                        FunctionId      = functionId,
                        AdministratorId = administratorId,
                    });
                }
                dal.SaveChanges();
            }
        }
Exemplo n.º 2
0
 public IList <FunctionDefinition> QueryParentOrderByName()
 {
     using (var dal = new BaseDal())
     {
         return(dal.Function.Where(o => o.ParentId == "0").OrderBy(o => o.Name).ToList());
     }
 }
Exemplo n.º 3
0
 public IList <FunctionDefinition> QueryByParentId(string id)
 {
     using (var dal = new BaseDal())
     {
         return((from o in dal.Function where o.ParentId == id select o).ToArray());
     }
 }
Exemplo n.º 4
0
 public IList <LogDefinition> QueryNearN(int n)
 {
     using (var dal = new BaseDal())
     {
         return(dal.Log.OrderByDescending(o => o.UpdateDateTime).Take(n).ToList());
     }
 }
Exemplo n.º 5
0
 public FunctionDefinition FindByPage(string page)
 {
     using (var dal = new BaseDal())
     {
         return(dal.Function.Single(o => o.Page == page));
     }
 }
Exemplo n.º 6
0
        public string GetValue(string configName, string defaultValue)
        {
            if (string.IsNullOrEmpty(defaultValue))
            {
                throw new Exception(string.Format("配置项{0}不能为空", configName));
            }

            using (var dal = new BaseDal())
            {
                var p = dal.Config.Find(configName);
                if (p == null)
                {
                    dal.Config.Add(new ConfigDefinition()
                    {
                        Name = configName, Value = defaultValue, Comment = ""
                    });
                    dal.SaveChanges();
                    return(defaultValue);
                }
                else
                {
                    if (string.IsNullOrEmpty(p.Value))
                    {
                        throw new Exception(string.Format("配置项{0}不能为空", p.Name));
                    }
                    return(p.Value);
                }
            }
        }
Exemplo n.º 7
0
 public bool HasByFunctionId(string functionId)
 {
     using (var dal = new BaseDal())
     {
         return(dal.TableColumn.Any(o => o.FunctionId == functionId));
     }
 }
Exemplo n.º 8
0
 public IList <TableColumnDefinition> QueryByFunctionIdAndVisible(string functionId)
 {
     using (var dal = new BaseDal())
     {
         return(dal.TableColumn.Where(o => (o.FunctionId == functionId) && (o.Visible)).OrderBy(o => o.Index).ToList());
     }
 }
Exemplo n.º 9
0
 public TableColumnDefinition FindByFunctionIdTableColumnId(string functionId, string tableColumnId)
 {
     using (var dal = new BaseDal())
     {
         return(dal.TableColumn.SingleOrDefault(o => o.FunctionId == functionId && (o.TableColumnId == tableColumnId)));
     }
 }
Exemplo n.º 10
0
 public IList <CommandDefinition> QueryByFunctionId(string functionId)
 {
     using (var dal = new BaseDal())
     {
         return(dal.Command.Where(o => o.FunctionId == functionId).OrderBy(o => o.Index).ToList());
     }
 }
Exemplo n.º 11
0
 public void Update(string roleId, IList <string> functionIds, IList <string> commandIds)
 {
     using (var dal = new BaseDal())
     {
         var oldRoleAndFunction = dal.RoleAndFunction.Where(o => o.RoleId == roleId);
         dal.RoleAndFunction.RemoveRange(oldRoleAndFunction);
         var oldRoleAndCommand = dal.RoleAndCommand.Where(o => o.RoleId == roleId);
         dal.RoleAndCommand.RemoveRange(oldRoleAndCommand);
         foreach (var p in functionIds)
         {
             dal.RoleAndFunction.Add(new RoleAndFunctionDefinition()
             {
                 RoleId = roleId, FunctionId = p
             });
         }
         foreach (var p in commandIds)
         {
             dal.RoleAndCommand.Add(new RoleAndCommandDefinition()
             {
                 RoleId = roleId, CommandId = p
             });
         }
         dal.SaveChanges();
     }
 }
Exemplo n.º 12
0
 public IList <GrainDefinition> QueryByGrainTypeId(int grainTypeId)
 {
     using (var dal = new BaseDal())
     {
         return(dal.Grain.Where(o => o.GrainTypeId == grainTypeId).ToList());
     }
 }
Exemplo n.º 13
0
 public IList <string> QueryTableColumnIdByAdministratorIdFunctionId(string administratorId, string functionId)
 {
     using (var dal = new BaseDal())
     {
         return(dal.TableColumnAndAdmin.Where(o => ((o.AdministratorId == administratorId) && (o.FunctionId == functionId))).Select(o => o.TableColumnId).ToList());
     }
 }
Exemplo n.º 14
0
 public IList <FunctionDefinition> QueryDisplay()
 {
     using (var dal = new BaseDal())
     {
         return(dal.Function.Where(o => o.Display).OrderBy(o => o.Postion).ToList());
     }
 }
Exemplo n.º 15
0
 public virtual IList <T> Query()
 {
     using (var bll = new BaseDal())
     {
         return((from o in bll.Set <T>() select o).AsNoTracking().ToList());
     }
 }
Exemplo n.º 16
0
 public AdministratorDefinition FindByAccounts(string accounts)
 {
     using (var dal = new BaseDal())
     {
         return(dal.Administrator.SingleOrDefault(o => o.Accounts == accounts));
     }
 }
Exemplo n.º 17
0
 public T Find(params object[] p)
 {
     using (var bll = new BaseDal())
     {
         return(bll.Set <T>().Find(p));
     }
 }
Exemplo n.º 18
0
 public IList <RoleAndFunctionDefinition> QueryByRoleId(string roleId)
 {
     using (var dal = new BaseDal())
     {
         return(dal.RoleAndFunction.Where(o => o.RoleId == roleId).ToList());
     }
 }
Exemplo n.º 19
0
 public virtual void Add(T p)
 {
     using (var bll = new BaseDal())
     {
         bll.Set <T>().Add(p);
         bll.SaveChanges();
     }
 }
Exemplo n.º 20
0
 public virtual void Update(T p)
 {
     using (var bll = new BaseDal())
     {
         bll.Entry(p).State = EntityState.Modified;
         bll.SaveChanges();
     }
 }
Exemplo n.º 21
0
 public virtual void Remove(T p)
 {
     using (var bll = new BaseDal())
     {
         bll.Set <T>().Attach(p);
         bll.Set <T>().Remove(p);
         bll.SaveChanges();
     }
 }
Exemplo n.º 22
0
        //public void ExecuteNonQuery(string sql)
        //{
        //    using (var dal = new BaseDal())
        //    {
        //        dal.Database.ExecuteNonQuery(sql);
        //    }
        //}

        public void Clear()
        {
            using (var dal = new BaseDal())
            {
                var list = (from o in dal.Set <T>() select o).ToList();
                dal.Set <T>().RemoveRange(list);
                dal.SaveChanges();
            }
        }
Exemplo n.º 23
0
 public void RemoveById(string functionId)
 {
     using (var dal = new BaseDal())
     {
         var p = dal.Function.Find(functionId);
         dal.Function.Remove(p);
         dal.SaveChanges();
     }
 }
Exemplo n.º 24
0
 public IList <ZkGetOrderDefinition> QueryByParam(QueryByParamIn param)
 {
     using (var dal = new BaseDal())
     {
         var list = from o in dal.ZkGetOrder where (true)select o;
         param.Total = list.Count();
         list        = from o in list orderby o.ManufacturingDate select o;
         list        = list.Skip((param.Page - 1) * param.Rows).Take(param.Rows);
         return((list).ToList());
     }
 }
Exemplo n.º 25
0
 public void SetValue(string configName, string value)
 {
     GetValue(configName, value);
     using (var dal = new BaseDal())
     {
         var p = dal.Config.Find(configName);
         p.Value            = value;
         dal.Entry(p).State = EntityState.Modified;
         dal.SaveChanges();
     }
 }
Exemplo n.º 26
0
 public IList <TableColumnDefinition> QueryByAdministratorIdFunctionIdAndVisible(string administratorId, string functionId)
 {
     using (var dal = new BaseDal())
     {
         var list = from tableColumn in dal.TableColumn
                    from tableColumnAndAdmin in dal.TableColumnAndAdmin
                    where ((tableColumn.FunctionId == tableColumnAndAdmin.FunctionId) && (tableColumn.TableColumnId == tableColumnAndAdmin.TableColumnId) && (tableColumnAndAdmin.AdministratorId == administratorId) && (tableColumnAndAdmin.FunctionId == functionId) && (tableColumn.Visible))
                    select tableColumn;
         return(list.ToList().OrderBy(o => o.Index).ToList());
     }
 }
Exemplo n.º 27
0
 public void DeleteByFunctionId(string functionId)
 {
     using (var dal = new BaseDal())
     {
         var list = dal.TableColumnAndAdmin.Where(o => o.FunctionId == functionId).ToList();
         if (list.Count() > 0)
         {
             dal.TableColumnAndAdmin.RemoveRange(list);
             dal.SaveChanges();
         }
     }
 }
Exemplo n.º 28
0
        public IList <FunctionDefinition> QueryDisplayByRoleId(string roleId)
        {
            using (var dal = new BaseDal())
            {
                var tree = from item in dal.Function
                           join roleAndFunction in dal.RoleAndFunction on item.FunctionId equals roleAndFunction.FunctionId
                           where ((item.Display) && (item.FunctionId == roleAndFunction.FunctionId) &&
                                  (roleAndFunction.RoleId == roleId))
                           select item;

                return((tree).ToList());
            }
        }
Exemplo n.º 29
0
 public IList <GranariesDefinition> QueryByParam1(QueryByParam1In param)
 {
     //param.BeginDateTime = param.BeginDateTime.Date;
     //param.EndDateTime = param.EndDateTime.AddDays(1);
     using (var dal = new BaseDal())
     {
         var list = from o in dal.Granaries where (true)select o;
         param.Total = list.Count();
         list        = from o in list orderby o.GranariesName select o;
         list        = list.Skip((param.Page - 1) * param.Rows).Take(param.Rows);
         return((list).ToList());
     }
 }
Exemplo n.º 30
0
 public IList <LogDefinition> QueryByParam1(QueryByParam1In param)
 {
     param.BeginDateTime = param.BeginDateTime.Date;
     param.EndDateTime   = param.EndDateTime.AddDays(1);
     using (var dal = new BaseDal())
     {
         var list = from o in dal.Log where ((o.UpdateDateTime >= param.BeginDateTime) && (o.UpdateDateTime < param.EndDateTime))  select o;
         param.Total = list.Count();
         list        = from o in list orderby o.UpdateDateTime select o;
         list        = list.Skip((param.Page - 1) * param.Rows).Take(param.Rows);
         return((list).ToList());
     }
 }