public MyResult Create(string par0, string par1) { Assembly asmb = Assembly.GetAssembly(typeof(ServiceReturn)); Type type = asmb.GetType(par0); object obj = JsonConvert.DeserializeObject(par1, type); object newObj = DBBase.Create(obj); if (type == typeof(ETask)) { ETask task = (ETask)obj; if (MySession.UserID != task.ExecutorID && task.ExecutorID != 0) { EUser myuser = DBBase.Get <EUser>(MySession.UserID); EUser excuteuser = DBBase.Get <EUser>(task.ExecutorID); List <string> ulist = new List <string>(); ulist.Add(excuteuser.PushClientID); PushMessageToList.PushToList(task.Title, "指派人" + myuser.Name, ulist, true); } } else if (type == typeof(EPlan)) { EPlan plan = (EPlan)obj; EProject project = DBBase.Get <EProject>(plan.ProjectID); EUserSearch userSearch = new EUserSearch() { IsDefault = false, Name = project.Name + "-" + plan.Name, UserID = MySession.UserID, ProjectID = plan.ProjectID, PlanID = plan.ID }; DBBase.Create(userSearch); } return(ServiceResult(newObj)); }
public EAccount DeliverGoods(int accountid, int goodsid) { EAccount account = DBBase.Get <EAccount>(accountid); EStore goods = DBBase.Get <EStore>(goodsid); if (goods.Type != "Bag" && goods.Type != "Gold") { return(null); } int getGold = Convert.ToInt32(goods.Name); if (account.Diamond < goods.Price) { return(null); } account.Diamond -= goods.Price; account.Gold += getGold; DBBase.Change(account); EBuyRecord record = new EBuyRecord() { BuyerID = accountid, BuyTime = DateTime.Now, GoodsID = goodsid, Num = 1, NowDiamond = account.Diamond, NowGold = account.Gold, CostDiamond = -goods.Price, CostGold = getGold }; DBBase.Create(record); return(account); }
public MyResult TaskProcess(int par0, int par1, int par2, string par3) { ETask task = DBBase.Get <ETask>(par0); task.ExecutorID = par1; task.State = par2; ETaskTransfer taskTransfer = new ETaskTransfer() { TaskID = task.ID, AppointPersonID = MySession.UserID, AssignedPersonID = par1, CreateTime = System.DateTime.Now, ToState = task.State, Note = par3 }; DBBase.Change(task); DBBase.Create(taskTransfer); if (MySession.UserID != task.ExecutorID && task.ExecutorID != 0) { EUser myuser = DBBase.Get <EUser>(MySession.UserID); EUser excuteuser = DBBase.Get <EUser>(task.ExecutorID); List <string> ulist = new List <string>(); ulist.Add(excuteuser.PushClientID); PushMessageToList.PushToList(task.Title, "指派人" + myuser.Name, ulist, true); } return(ServiceResult(task.ID)); }
public MyResult Create(string par0) { EPeople p = JsonConvert.DeserializeObject <EPeople>(par0); DBBase.Create(p); List <EUser> alluser = DBBase.Query <EUser>(); return(ServiceResult(alluser)); }
public string PayNotice() { log4net.ILog log = log4net.LogManager.GetLogger(this.GetType());//获取一个日志记录器 try { ResponseBean responseBean = new ResponseBean(this.Request); var sign = GetSign(responseBean); if (responseBean.p4_status == "1" && sign.Equals(responseBean.p10_sign)) { string[] data = responseBean.p11_remark.Split('|'); log.Info(DateTime.Now.ToString() + ": pay info:uid>" + data[0] + " goodsid>" + data[1]); int uid = Convert.ToInt32(data[0]); int goodsid = Convert.ToInt32(data[1]); EAccount account = DBBase.Get <EAccount>(uid); EStore goods = DBBase.Get <EStore>(goodsid); int oldDiamon = account.Diamond; if (goods.Type == "Damion") { account.Diamond += Convert.ToInt32(goods.Name); } else if (goods.Type == "Vip") { account.Vip = Convert.ToInt32(goods.Name); account.VipBeginTime = DateTime.Now; } DBBase.Change(account); EBuyRecord record = new EBuyRecord() { BuyerID = account.ID, BuyTime = DateTime.Now, GoodsID = goodsid, Num = 1, NowDiamond = account.Diamond, NowGold = account.Gold, CostDiamond = account.Diamond - oldDiamon, CostGold = 0 }; DBBase.Create(record); log.Info(DateTime.Now.ToString() + ": pay success:uid>" + uid + " goodsid>" + goodsid);//写入一条新log //服务器操作 return("success"); } else { log.Info(DateTime.Now.ToString() + ": pay error: status>" + responseBean.p4_status);//写入一条新log return("error"); } } catch (Exception ex) { log.Error(DateTime.Now.ToString() + ": pay error: " + ex.Message + " " + ex.StackTrace);//写入一条新log return("error"); } }
public void JoinBattle(string ip, string port, int accountID, int curGameNum, string battleCode, int takeGold, int taleDiamon) { try { EAccount account = DBBase.Get <EAccount>(accountID); account.BattleIP = ip; account.BattlePort = port; account.BattleCode = battleCode.ToString(); if (curGameNum == 1) { account.Gold += takeGold; account.Diamond += taleDiamon; } DBBase.Change(account); EBattleRecord record = DBBase.Query <EBattleRecord>("BattleCode='" + battleCode + "' and GameNum=" + curGameNum).FirstOrDefault(); if (record == null) { //创建记录 record = new EBattleRecord() { BeginTime = DateTime.Now, EndTime = DateTime.Now, BattleCode = battleCode, Sider1ID = accountID, IsFinished = false, GameNum = curGameNum }; DBBase.Create(record); } else { if (record.Sider1ID == 0) { record.Sider1ID = accountID; } else if (record.Sider2ID == 0) { record.Sider2ID = accountID; } else if (record.Sider3ID == 0) { record.Sider3ID = accountID; } else if (record.Sider4ID == 0) { record.Sider4ID = accountID; } DBBase.Change(record); } } catch (Exception ex) { Console.Write(ex.Message + " " + ex.StackTrace); } }
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 AskConnect(int par0) { EPeople people = new EPeople(); people.UserID = par0; people.PeopleID = MySession.UserID; people.State = Lemon.Team.Entity.Enum.PeopleState.NeedConfirm; EPeople people2 = new EPeople(); people2.UserID = MySession.UserID; people2.PeopleID = par0; people2.State = Lemon.Team.Entity.Enum.PeopleState.Request; DBBase.Create(people); DBBase.Create(people2); return(ServiceResult("ok")); }
public MyResult SetComplated(int par0) { ETask task = DBBase.Get <ETask>(par0); task.IsComplated = true; ETaskTransfer taskTransfer = new ETaskTransfer() { TaskID = task.ID, AppointPersonID = MySession.UserID, AssignedPersonID = 0, CreateTime = System.DateTime.Now, ToState = task.State, Note = "设置为已完成" }; DBBase.Change(task); DBBase.Create(taskTransfer); return(ServiceResult(task.ID)); }
public MyResult PlatformLogin(string par0, string par1, string par2, string par3) { EUser user = DBBase.Query <EUser>("OpenID='" + par0 + "'").FirstOrDefault(); if (user == null) { user = new EUser() { OpenID = par0, Name = par1, Face = par2, PushClientID = par3 }; user = (EUser)DBBase.Create(user); InitUser(user); } else { //修改客户端推送ID user.PushClientID = par3; DBBase.Change(user); } return(ServiceResult(user)); }
public int AddFriends(int accountid, int friendid) { EAccount friendAoount = DBBase.Get <EAccount>(friendid); if (friendAoount == null) { return(-1); } List <EFriends> oldFriends = DBBase.Query <EFriends>(string.Format("AccountID={0} and FriendID={1}", accountid, friendid)); if (oldFriends.Count > 0) { return(-1); } EFriends friend = new EFriends() { AccountID = accountid, FriendID = friendid }; DBBase.Create(friend); return(0); }
private void InitUser(EUser user) { EProject defaultProject = new EProject() { Name = "默认项目", CreateTime = DateTime.Now, CreaterID = user.ID }; defaultProject = ProjectController.CreateProject(defaultProject, user.ID); EPlan defaultPlan = new EPlan() { ProjectID = defaultProject.ID, Name = "默认计划", BeginTime = DateTime.Now, EndTime = DateTime.Now }; defaultPlan = (EPlan)DBBase.Create(defaultPlan); EUserSearch userSearch = new EUserSearch() { IsDefault = true, Name = "默认项目计划", UserID = user.ID, ProjectID = defaultPlan.ProjectID, PlanID = defaultPlan.ID }; DBBase.Create(userSearch); }
public MyResult Regist(string par0) { EUser obj = JsonConvert.DeserializeObject(par0, typeof(EUser)) as EUser; if (string.IsNullOrEmpty(obj.Phone) || string.IsNullOrEmpty(obj.Password)) { return(ServiceErrorResult("账号密码不能为空")); } else { EUser olduser = DBBase.Query <EUser>("Phone='" + obj.Phone + "'").FirstOrDefault(); if (olduser != null) { return(ServiceErrorResult("账号已存在")); } else { EUser newObj = DBBase.Create(obj) as EUser; InitUser(newObj); return(ServiceResult(newObj.ID)); } } }
public static EProject CreateProject(EProject obj, int userid) { EProject newObj = DBBase.Create(obj) as EProject; EProjectTeam projectTeam = new EProjectTeam() { UserID = userid, ProjectID = newObj.ID }; DBBase.Create(projectTeam); EProjectTaskStep projectStep1 = new EProjectTaskStep() { ProjectID = newObj.ID, Name = "新任务", Value = 1 }; DBBase.Create(projectStep1); EProjectTaskStep projectStep2 = new EProjectTaskStep() { ProjectID = newObj.ID, Name = "已完成", Value = 2 }; DBBase.Create(projectStep2); return(newObj); }
public EAccount PlatformLogin(string userInfo) { LogHelper.DebugLog("PlatformLogin:"******"\p{Cs}", ""); string iconUrl = pars[3]; string longitude = pars[4]; string latitude = pars[5]; string address = pars[6]; string systemName = pars[7]; if (platform == "WX" && !iconUrl.Contains("http:")) { string json = HttpService.Get(WXHelper.getCodeRequestUrl(iconUrl)); TokenAndOpenID tokenAndOpenID = JsonConvert.DeserializeObject <TokenAndOpenID>(json); if (tokenAndOpenID != null) { openID = tokenAndOpenID.openid; string json2 = HttpService.Get(WXHelper.getUserInfoUrl(tokenAndOpenID.access_token, tokenAndOpenID.openid)); UserInfo userinfo = JsonConvert.DeserializeObject <UserInfo>(json2); if (userinfo != null) { nickName = userinfo.nickname; iconUrl = userinfo.headimgurl; } } } EAccount user = DBBase.Query <EAccount>("OpenID='" + openID + "'").FirstOrDefault(); if (user == null) { user = new EAccount() { OpenID = openID, NickName = nickName, Face = iconUrl, Longitude = longitude, Latitude = latitude, Address = address, PlatformName = platform, CreateTime = DateTime.Now, LastLoginTime = DateTime.Now, SystemName = systemName, LastGetGoldTime = DateTime.Now, Gold = 1000, Diamond = 0 }; user = (EAccount)DBBase.Create(user); } else { //修改客户端推送ID user.Longitude = longitude; user.Latitude = latitude; user.Address = address; user.SystemName = systemName; user.LastLoginTime = DateTime.Now; double dayNum = (DateTime.Now - user.LastGetGoldTime).TotalDays; user.Gold += user.Vip * (int)dayNum * 10; user.LastGetGoldTime = DateTime.Now; DBBase.Change(user); } //创建登录记录 ELoginRecord loginRecord = new ELoginRecord() { AccountID = user.ID, LoginTime = DateTime.Now }; DBBase.Create(loginRecord); int referrerCount = DBBase.Query <EAccount>("ReferrerID=" + user.ID + "").Count(); if (referrerCount > user.TaskProcess) { user.TaskProcess = referrerCount; int taskGetDiamon = 0; if (user.TaskProcess == 1) { taskGetDiamon = 10; } else if (user.TaskProcess == 10) { taskGetDiamon = 100; } else if (user.TaskProcess == 20) { taskGetDiamon = 200; } else if (user.TaskProcess == 50) { taskGetDiamon = 500; } user.Diamond += taskGetDiamon; DBBase.Change(user); } List <EBattleServers> serverList = DBBase.Query <EBattleServers>(); EBattleServers server = serverList.FirstOrDefault(c => c.ID == 1); user.CurBattleIP = server.IP; user.CurBattlePort = server.Port; user.CurTaskProcess = referrerCount; return(user); }