93 lines
2.8 KiB
C#
93 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Unity;
|
|
using Cowain.Bake.Model;
|
|
using Cowain.Bake.Common.Enums;
|
|
using System.Collections.Concurrent;
|
|
|
|
namespace Cowain.Bake.BLL
|
|
{
|
|
public class SysSetupService : ServiceBase
|
|
{
|
|
public ConcurrentDictionary<string, string> ParaDic = new ConcurrentDictionary<string, string>();
|
|
public SysSetupService(IUnityContainer unityContainer) : base(unityContainer)
|
|
{
|
|
GetAllPara();
|
|
}
|
|
|
|
public List<TSysSetup> GetAll()
|
|
{
|
|
using (var Context = new BakingEntities())
|
|
{
|
|
return Context.Set<TSysSetup>().OrderBy(item => item.Id).ToList();
|
|
}
|
|
}
|
|
|
|
public void GetAllPara()
|
|
{
|
|
ParaDic.Clear();
|
|
using (var Context = new BakingEntities())
|
|
{
|
|
var list = Context.Set<TSysSetup>().OrderBy(item => item.Id).ToList();
|
|
foreach (var item in list)
|
|
{
|
|
ParaDic.TryAdd(item.ParamCode, item.ParamValue);
|
|
}
|
|
}
|
|
}
|
|
|
|
public string GetValueByParaID(string paraID)
|
|
{
|
|
return ParaDic[paraID];
|
|
}
|
|
|
|
public string GetValueByID(long ID)
|
|
{
|
|
using (var Context = new BakingEntities())
|
|
{
|
|
var pi = (from ts in Context.Set<TSysSetup>()
|
|
where ts.Id == ID
|
|
select ts).FirstOrDefault();
|
|
return pi.ParamValue;
|
|
}
|
|
}
|
|
public bool UpdateValue(long ID, string value)
|
|
{
|
|
using (var Context = new BakingEntities())
|
|
{
|
|
var pi = (from ts in Context.Set<TSysSetup>()
|
|
where ts.Id == ID
|
|
select ts).FirstOrDefault();
|
|
pi.ParamValue = value;
|
|
var result = Context.SaveChanges() != 0;
|
|
GetAllPara();
|
|
return result;
|
|
}
|
|
}
|
|
public bool UpdateValue(string paramCode, string value)
|
|
{
|
|
using (var Context = new BakingEntities())
|
|
{
|
|
var pi = (from ts in Context.Set<TSysSetup>()
|
|
where ts.ParamCode == paramCode
|
|
select ts).FirstOrDefault();
|
|
pi.ParamValue = value;
|
|
var result = Context.SaveChanges() != 0;
|
|
GetAllPara();
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public List<TSysSetup> GetShowParam()
|
|
{
|
|
using (var Context = new BakingEntities())
|
|
{
|
|
return Context.Set<TSysSetup>().Where(x=>x.Type == (int)EParamType.Sys).OrderBy(item => item.Id).ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|