public List <EAccount> ListAllAIUser() { List <EAccount> allaiuser = DBBase.Query <EAccount>("IsAI=1"); if (allaiuser.Count == 0) { List <EAccount> maxidlist = DBBase.QueryCustom <EAccount>("SELECT MAX(ID) as ID from account"); int maxid = 1; if (maxidlist.Count > 0) { EAccount maxAccount = maxidlist.FirstOrDefault(); maxid = maxAccount.ID + 1; } StringBuilder createBuilder = new StringBuilder(); for (int i = 0; i < 1000; i++) { createBuilder.Append(string.Format("INSERT INTO `account` VALUES('{0}', null, null, '{1}', '{2}', '{3}', null, '2017-06-29 09:31:47', '2017-07-06 10:28:28', '0', '9728', '9820', '0', 'WindowsPlayer', 'QQ', '106.522762', '29.505817', '重庆市九龙坡区杨家坪直港大道天鹅堡别墅旁', '0', '', '', '', '0', '2017-06-29 09:31:47', 1,0,'2017-06-29 09:31:47','2017-06-29 09:31:47','');", maxid++, AIUserRandomAttr.getRandomName(), AIUserRandomAttr.GetRandomFace(), "aiopenid" + i)); } DBBase.ExcuteCustom(createBuilder.ToString()); allaiuser = DBBase.Query <EAccount>("IsAI=1"); } return(allaiuser); }
static void SendRemind(object sender, System.Timers.ElapsedEventArgs e) { List <ETask> taskList = DBBase.QueryCustom <ETask>("select * from task where IsReminded=0 and Remind<>'' and Remind is not null"); foreach (var t in taskList) { try { DateTime remindTime = t.BeginTime.Date.AddHours(int.Parse(t.Remind)); if (DateTime.Now > remindTime) { t.IsReminded = true; DBBase.Change(t); EUser excuteuser = DBBase.Get <EUser>(t.ExecutorID); List <string> ulist = new List <string>(); ulist.Add(excuteuser.PushClientID); PushMessageToList.PushToList("你有一个任务需要办理", t.Title, ulist, true); } } catch (Exception ex) { Console.WriteLine(t.Title + " 任务提醒出错" + ex.StackTrace); } } }
public MyResult ListMyHomeTask(int par0, int par1, int par2, TaskPriority?par3) { List <ETask> plist = null; if (par0 != 0) { plist = DBBase.QueryCustom <ETask>("select t.*,h.`Name`as TaskHeadName,h.Face as TaskHeadFace,e.`Name` as ExecutorName,e.Face as ExecutorFace,s.Name as StepName from task t LEFT JOIN `user` h ON t.TaskHeadID=h.ID LEFT JOIN `user` e ON t.ExecutorID=e.ID LEFT JOIN projecttaskstep s ON s.ProjectID=t.ProjectID and s.`Value`=t.State where t.ProjectID=" + par0 + " and t.ExecutorID=" + MySession.UserID); } else { plist = DBBase.QueryCustom <ETask>("select t.*,h.`Name`as TaskHeadName,h.Face as TaskHeadFace,e.`Name` as ExecutorName,e.Face as ExecutorFace,s.Name as StepName from task t LEFT JOIN `user` h ON t.TaskHeadID=h.ID LEFT JOIN `user` e ON t.ExecutorID=e.ID LEFT JOIN projecttaskstep s ON s.ProjectID=t.ProjectID and s.`Value`=t.State where t.ExecutorID=" + MySession.UserID); } if (par1 != 0) { plist = plist.Where(c => c.PlanID == par1).ToList(); } if (par2 > 0) { plist = plist.Where(c => c.State == par2).ToList(); } if (par3.HasValue) { plist = plist.Where(c => c.Priority == par3.Value).ToList(); } return(ServiceResult(plist)); }
public List <EFriends> ListFriends(int accountid) { return(DBBase.QueryCustom <EFriends>(@"select f.*,a.NickName as FriendNickName,a.Face as FriendIconUrl,a.WinTimes as FriendWinTimes from friends f LEFT JOIN account a on f.FriendID = a.Id where AccountID = " + accountid)); }
public MyResult ListByPlanID(int par0, int par1) { List <ETask> plist = DBBase.QueryCustom <ETask>("select t.*,h.`Name`as TaskHeadName,h.Face as TaskHeadFace,e.`Name` as ExecutorName,e.Face as ExecutorFace,s.Name as StepName from task t LEFT JOIN `user` h ON t.TaskHeadID=h.ID LEFT JOIN `user` e ON t.ExecutorID=e.ID LEFT JOIN projecttaskstep s ON s.ProjectID=t.ProjectID and s.`Value`=t.State where t.PlanID=" + par0); if (par1 > 0) { plist = plist.Where(c => c.TaskHeadID == par1).ToList(); } return(ServiceResult(plist)); }
public EBattleRecord GetBattleRecord(int id) { try { string sql = @"SELECT r.*,a2.NickName as Sider2Name,a3.NickName as Sider3Name,a4.NickName as Sider4Name from battlerecord r LEFT JOIN account a2 on r.Sider2ID=a2.ID LEFT JOIN account a3 on r.Sider3ID=a3.ID LEFT JOIN account a4 on r.Sider4ID=a4.ID where r.ID=" + id; List <EBattleRecord> recordList = DBBase.QueryCustom <EBattleRecord>(sql); //string js = JsonConvert.SerializeObject(recordList); //Console.Write(js); return(recordList.FirstOrDefault()); } catch (Exception ex) { Console.Write(ex.Message + " " + ex.StackTrace); return(null); } }
public List <EBattleRecord> BattleRecord(int accountID) { try { string sql = @"SELECT r.ID,r.BattleCode,r.GameNum,r.BeginTime,r.EndTime,r.Sider1ID,r.Sider1Score,r.Sider2ID,r.Sider2Score,r.Sider3ID,r.Sider3Score,r.Sider4ID,r.Sider4Score,r.IsFinished,a2.NickName as Sider2Name,a3.NickName as Sider3Name,a4.NickName as Sider4Name from battlerecord r LEFT JOIN account a2 on r.Sider2ID=a2.ID LEFT JOIN account a3 on r.Sider3ID=a3.ID LEFT JOIN account a4 on r.Sider4ID=a4.ID where r.Sider1ID={0} or r.Sider2ID={0} or r.Sider3ID={0} or r.Sider4ID={0} order by r.BeginTime desc limit 50"; sql = String.Format(sql, accountID); List <EBattleRecord> recordList = DBBase.QueryCustom <EBattleRecord>(sql); //string js = JsonConvert.SerializeObject(recordList); //Console.Write(js); return(recordList); } catch (Exception ex) { Console.Write(ex.Message + " " + ex.StackTrace); return(null); } }
public MyResult SendMessage(string par0) { Type type = typeof(EMessage); object obj = JsonConvert.DeserializeObject(par0, type); EMessage newObj = DBBase.Create(obj) as EMessage; //发送推送 EUser myuser = DBBase.Get <EUser>(newObj.SenderID); if (newObj.Type == MessageType.OneToOne) { //接收者加个提示 ENewTips tips = new ENewTips() { UserID = newObj.ReceiverID, Type = newObj.Type, OwnerID = newObj.SenderID }; DBBase.Create(tips); //推送给接收者 EUser excuteuser = DBBase.Get <EUser>(newObj.ReceiverID); List <string> ulist = new List <string>(); ulist.Add(excuteuser.PushClientID); PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, false); PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, true); } else if (newObj.Type == MessageType.Project) { List <EUser> teamUsers = DBBase.QueryCustom <EUser>("select * from user where ID in(select UserID from projectteam where ProjectID=" + newObj.ReceiverID + ")"); List <string> ulist = new List <string>(); foreach (var u in teamUsers) { ulist.Add(u.PushClientID); //每个人加个提示 ENewTips tips = new ENewTips() { UserID = u.ID, Type = newObj.Type, OwnerID = newObj.ReceiverID }; DBBase.Create(tips); } //推送给所有接收者 PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, false); PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, true); } return(ServiceResult("ok")); }
public MyResult ListByTargetID(MessageType par0, int par1) { List <EMessage> plist = null; if (par0 == MessageType.System) { plist = DBBase.QueryCustom <EMessage>("select m.*,u.`Name`as SenderName,u.Face as SenderFace from message m LEFT JOIN `user` u ON m.SenderID=u.ID where (ReceiverID=" + MySession.UserID + " or ReceiverID= -100) and Type=" + (int)par0 + " order by m.ID desc limit 20"); } else if (par0 == MessageType.Project) { plist = DBBase.QueryCustom <EMessage>("select m.*,u.`Name`as SenderName,u.Face as SenderFace from message m LEFT JOIN `user` u ON m.SenderID=u.ID where ReceiverID=" + par1 + " and Type=" + (int)par0 + " order by m.ID desc limit 20"); } else { plist = DBBase.QueryCustom <EMessage>("select m.*,u.`Name`as SenderName,u.Face as SenderFace from message m LEFT JOIN `user` u ON m.SenderID=u.ID where ((SenderID=" + par1 + " and ReceiverID=" + MySession.UserID + ") or (ReceiverID=" + par1 + " and SenderID=" + MySession.UserID + ")) and Type=" + (int)par0 + " order by m.ID desc limit 20"); } return(ServiceResult(plist)); }
public MyResult ListByProjectID(int par0) { List <EProjectTeam> team = DBBase.QueryCustom <EProjectTeam>("select p.*,u.`Name`as UserName,u.Face as UserFace from projectteam p LEFT JOIN `user` u ON p.UserID=u.ID where p.ProjectID=" + par0); return(ServiceResult(team)); }
public MyResult GetByProjectID(int par0, int par1) { EProjectTeam teamOne = DBBase.QueryCustom <EProjectTeam>("select p.*,u.`Name`as UserName,u.Face as UserFace from projectteam p LEFT JOIN `user` u ON p.UserID=u.ID where p.UserID=" + par0 + " and p.ProjectID=" + par1).FirstOrDefault(); return(ServiceResult(teamOne)); }
public MyResult Get(int par0) { ETask newObj = DBBase.QueryCustom <ETask>("select t.*,h.`Name`as TaskHeadName,h.Face as TaskHeadFace,e.`Name` as ExecutorName,e.Face as ExecutorFace,s.Name as StepName from task t LEFT JOIN `user` h ON t.TaskHeadID=h.ID LEFT JOIN `user` e ON t.ExecutorID=e.ID LEFT JOIN projecttaskstep s ON s.ProjectID=t.ProjectID and s.`Value`=t.State where t.ID=" + par0).FirstOrDefault(); return(ServiceResult(newObj)); }
public MyResult ListByTaskID(int par0) { List <ETaskTransfer> plist = DBBase.QueryCustom <ETaskTransfer>("select t.*,h.`Name`as AppointName,h.Face as AppointFace,e.`Name` as AssignedName,e.Face as AssignedFace,s.Name as StepName from tasktransfer t LEFT JOIN `user` h ON t.AppointPersonID=h.ID LEFT JOIN `user` e ON t.AssignedPersonID=e.ID LEFT JOIN task k ON t.TaskID=k.ID LEFT JOIN projecttaskstep s ON s.ProjectID=k.ProjectID and s.`Value`=t.ToState where t.TaskID=" + par0 + " order by t.CreateTime desc"); return(ServiceResult(plist)); }
public MyResult ListByUserID(int par0, int par1, int par2) { List <ETaskTransfer> plist = DBBase.QueryCustom <ETaskTransfer>(String.Format("select t.*,k.Title as TaskName,h.`Name`as AppointName,h.Face as AppointFace,e.`Name` as AssignedName,e.Face as AssignedFace,s.Name as StepName from tasktransfer t LEFT JOIN `user` h ON t.AppointPersonID=h.ID LEFT JOIN `user` e ON t.AssignedPersonID=e.ID LEFT JOIN task k ON t.TaskID=k.ID LEFT JOIN projecttaskstep s ON s.ProjectID=k.ProjectID and s.`Value`=t.ToState and s.`Value`=t.ToState where t.AppointPersonID={0} order by t.CreateTime desc limit {1},{2}", par0, par1 * par2, par2)); return(ServiceResult(plist)); }
public MyResult ListMyPeople() { List <EPeople> plist = DBBase.QueryCustom <EPeople>(@"select p.*,u.`Name`as PeopleName,u.Face as PeopleFace from people p LEFT JOIN `user` u ON p.PeopleID=u.ID where UserID=" + MySession.UserID); return(ServiceResult(plist)); }
public MyResult GetMyOnePeople(int par0) { EPeople people = DBBase.QueryCustom <EPeople>("select p.*,u.`Name`as PeopleName,u.Face as PeopleFace from people p LEFT JOIN `user` u ON p.PeopleID=u.ID where p.UserID=" + MySession.UserID + " and p.PeopleID=" + par0).FirstOrDefault(); return(ServiceResult(people)); }
public MyResult GetByID(int par0) { List <EUserSearch> plist = DBBase.QueryCustom <EUserSearch>("select s.*,j.`Name` as ProjectName,p.`Name` as PlanName,t.Name as StepName from usersearch s LEFT JOIN project j on s.ProjectID=j.ID LEFT JOIN plan p on s.PlanID=p.ID LEFT JOIN projecttaskstep t ON t.ProjectID=s.ProjectID and t.`Value`=s.TaskState where s.ID=" + par0); return(ServiceResult(plist.FirstOrDefault())); }
public MyResult ListMy() { List <EUserSearch> plist = DBBase.QueryCustom <EUserSearch>("select s.*,j.`Name` as ProjectName,p.`Name` as PlanName,t.Name as StepName from usersearch s LEFT JOIN project j on s.ProjectID=j.ID LEFT JOIN plan p on s.PlanID=p.ID LEFT JOIN projecttaskstep t ON t.ProjectID=s.ProjectID and t.`Value`=s.TaskState where s.UserID=" + MySession.UserID); return(ServiceResult(plist)); }