123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Data;
- using MySystem.Models.Main;
- using Library;
- using LitJson;
- namespace MySystem.Service.Main
- {
- public class TeamConfigService
- {
- string _conn = "";
- public TeamConfigService()
- {
- _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
- }
-
-
-
-
-
-
-
-
-
- public List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, out int count, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
- {
- List<string> fields = new List<string>();
- fields.Add("Id");
- fields.Add("CreateDate");
- fields.Add("Status");
- fields.Add("LimitBuddyNo");
- fields.Add("MinUserNum");
- fields.Add("MaxUserNum");
- fields.Add("MinCycleNum");
- fields.Add("MaxCycleNum");
- fields.Add("MinStartDayLimit");
- fields.Add("MaxStartDayLimit");
- fields.Add("OverlineStatus");
- fields.Add("BlacklistCycle");
- fields.Add("EnterEndMin");
- fields.Add("Remark");
- Dictionary<string, object> obj = new DbService(AppConfig.Base.dbTables, _conn).IndexData("TeamConfig", relationData, orderBy, page, limit, condition, fields);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- count = int.Parse(obj["count"].ToString());
- return diclist;
- }
- public List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
- {
- List<string> fields = new List<string>();
- fields.Add("Id");
- fields.Add("CreateDate");
- fields.Add("Status");
- fields.Add("LimitBuddyNo");
- fields.Add("MinUserNum");
- fields.Add("MaxUserNum");
- fields.Add("MinCycleNum");
- fields.Add("MaxCycleNum");
- fields.Add("MinStartDayLimit");
- fields.Add("MaxStartDayLimit");
- fields.Add("OverlineStatus");
- fields.Add("BlacklistCycle");
- fields.Add("EnterEndMin");
- fields.Add("Remark");
- Dictionary<string, object> obj = new DbService(AppConfig.Base.dbTables, _conn).IndexData("TeamConfig", relationData, orderBy, page, limit, condition, fields);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- return diclist;
- }
-
-
-
-
-
- public TeamConfig Query(int Id)
- {
- WebCMSEntities db = new WebCMSEntities();
- TeamConfig editData = db.TeamConfig.FirstOrDefault(m => m.Id == Id) ?? new TeamConfig();
- db.Dispose();
- return editData;
- }
-
-
-
-
-
- public int Count(string condition = "")
- {
- int result = 0;
- DataTable dt = CustomerSqlConn.dtable("select count(Id) from TeamConfig where 1=1" + condition, _conn);
- if(dt.Rows.Count > 0)
- {
- result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString()));
- }
- return result;
- }
-
-
-
-
-
- public bool Exist(int Id)
- {
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.TeamConfig.Any(m => m.Id == Id);
- db.Dispose();
- return check;
- }
-
-
-
-
-
- public AppResultJson Add(Dictionary<string, object> fields, bool check = true)
- {
- if(check)
- {
- if (string.IsNullOrEmpty(fields["MinUserNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最小队伍人数" };
- }
- if (!function.IsInt(fields["MinUserNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最小队伍人数" };
- }
- if (string.IsNullOrEmpty(fields["MaxUserNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最大队伍人数" };
- }
- if (!function.IsInt(fields["MaxUserNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最大队伍人数" };
- }
- if (string.IsNullOrEmpty(fields["MinCycleNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最小周期天数" };
- }
- if (!function.IsInt(fields["MinCycleNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最小周期天数" };
- }
- if (string.IsNullOrEmpty(fields["MaxCycleNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最大周期天数" };
- }
- if (!function.IsInt(fields["MaxCycleNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最大周期天数" };
- }
- if (string.IsNullOrEmpty(fields["MinStartDayLimit"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最小间隔天数" };
- }
- if (!function.IsInt(fields["MinStartDayLimit"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最小间隔天数" };
- }
- if (string.IsNullOrEmpty(fields["MaxStartDayLimit"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最大间隔天数" };
- }
- if (!function.IsInt(fields["MaxStartDayLimit"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最大间隔天数" };
- }
- if (string.IsNullOrEmpty(fields["BlacklistCycle"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写黑名单周期" };
- }
- if (!function.IsInt(fields["BlacklistCycle"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的黑名单周期" };
- }
- if (string.IsNullOrEmpty(fields["EnterEndMin"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写活动时间差" };
- }
- if (!function.IsInt(fields["EnterEndMin"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的活动时间差" };
- }
- }
- int Id = new DbService(AppConfig.Base.dbTables, _conn).Add("TeamConfig", fields, 0);
- return new AppResultJson(){ Status = "1", Data = Id };
- }
-
-
-
-
-
- public AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
- {
- if(check)
- {
- if (string.IsNullOrEmpty(fields["MinUserNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最小队伍人数" };
- }
- if (!function.IsInt(fields["MinUserNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最小队伍人数" };
- }
- if (string.IsNullOrEmpty(fields["MaxUserNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最大队伍人数" };
- }
- if (!function.IsInt(fields["MaxUserNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最大队伍人数" };
- }
- if (string.IsNullOrEmpty(fields["MinCycleNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最小周期天数" };
- }
- if (!function.IsInt(fields["MinCycleNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最小周期天数" };
- }
- if (string.IsNullOrEmpty(fields["MaxCycleNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最大周期天数" };
- }
- if (!function.IsInt(fields["MaxCycleNum"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最大周期天数" };
- }
- if (string.IsNullOrEmpty(fields["MinStartDayLimit"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最小间隔天数" };
- }
- if (!function.IsInt(fields["MinStartDayLimit"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最小间隔天数" };
- }
- if (string.IsNullOrEmpty(fields["MaxStartDayLimit"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最大间隔天数" };
- }
- if (!function.IsInt(fields["MaxStartDayLimit"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的最大间隔天数" };
- }
- if (string.IsNullOrEmpty(fields["BlacklistCycle"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写黑名单周期" };
- }
- if (!function.IsInt(fields["BlacklistCycle"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的黑名单周期" };
- }
- if (string.IsNullOrEmpty(fields["EnterEndMin"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写活动时间差" };
- }
- if (!function.IsInt(fields["EnterEndMin"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的活动时间差" };
- }
- }
- new DbService(AppConfig.Base.dbTables, _conn).Edit("TeamConfig", fields, Id);
- return new AppResultJson(){ Status = "1", Data = Id };
- }
-
-
-
-
- public void Remove(int Id)
- {
- Dictionary<string, object> fields = new Dictionary<string, object>();
- fields.Add("Status", -1);
- new DbService(AppConfig.Base.dbTables, _conn).Edit("TeamConfig", fields, Id);
- }
-
-
-
-
- public void Delete(int Id)
- {
- new DbService(AppConfig.Base.dbTables, _conn).Delete("TeamConfig", Id);
- }
-
-
-
-
-
- public void Sort(int Id, int Sort)
- {
- new DbService(AppConfig.Base.dbTables, _conn).Sort("TeamConfig", Sort, Id);
- }
-
-
-
-
- public void Import(string ExcelData)
- {
- WebCMSEntities db = new WebCMSEntities();
- JsonData list = JsonMapper.ToObject(ExcelData);
- for (int i = 1; i < list.Count;i++ )
- {
- JsonData dr = list[i];
-
- db.TeamConfig.Add(new TeamConfig()
- {
- CreateDate = DateTime.Now,
- UpdateDate = DateTime.Now,
-
- });
- db.SaveChanges();
- }
- db.Dispose();
- }
-
-
-
-
-
-
-
-
-
-
- }
- }
|