Exemple #1
0
        public MyResult Change(string par0, string par1)
        {
            ServiceReturn ret    = new ServiceReturn();
            Assembly      asmb   = Assembly.GetAssembly(typeof(ServiceReturn));
            Type          type   = asmb.GetType(par0);
            object        obj    = JsonConvert.DeserializeObject(par1, type);
            object        newObj = DBBase.Change(obj);

            return(ServiceResult(newObj));
        }
Exemple #2
0
        public int WinGold(int accountid, int goldnum)
        {
            EAccount user = DBBase.Get <EAccount>(accountid);

            if (user == null)
            {
                return(-1);
            }
            user.Gold += goldnum;
            DBBase.Change(user);
            return(0);
        }
Exemple #3
0
        public int SetInviteCode(int accountid, int inviteCode)
        {
            EAccount account = DBBase.Get <EAccount>(accountid);

            if (account == null)
            {
                return(-1);
            }
            account.ReferrerID = inviteCode;
            DBBase.Change(account);
            return(0);
        }
Exemple #4
0
 public void ClearBattleSidesState(Battle battle)
 {
     foreach (var s in battle.Sides)
     {
         EAccount user = DBBase.Get <EAccount>(Convert.ToInt32(s.AccountID));
         if (user != null)
         {
             user.BattleCode = "";
             user.BattleIP   = "";
             user.BattlePort = "";
             DBBase.Change(user);
         }
     }
 }
Exemple #5
0
        public EAccount Day5Sign(int accountid)
        {
            EAccount aoount = DBBase.Get <EAccount>(accountid);

            if (aoount == null)
            {
                return(null);
            }
            int todayNum = (int)(System.DateTime.Now.Date - aoount.FirstSignTime.Date).TotalDays + 1;

            if (aoount.FirstSignTime.Year == 1)
            {
                todayNum = 1;
            }

            if (string.IsNullOrEmpty(aoount.SignRecord))
            {
                aoount.SignRecord = todayNum.ToString();
            }
            else
            {
                if (aoount.SignRecord.Split('|').Contains(todayNum.ToString()))
                {
                    return(null);
                }
                aoount.SignRecord += "|" + todayNum;
            }
            if (todayNum == 1)
            {
                if (aoount.Vip < 1)
                {
                    aoount.Vip          = 1;
                    aoount.VipBeginTime = DateTime.Now;
                }
                aoount.FirstSignTime = DateTime.Now;
            }
            if (todayNum == 2 || todayNum == 3 || todayNum == 4 || todayNum == 5 || todayNum == 6)
            {
                aoount.Gold += 1000;
            }
            if (todayNum == 7)
            {
                aoount.Diamond += 20;
            }
            DBBase.Change(aoount);
            return(aoount);
        }
Exemple #6
0
        public EAccount Login(string userName, string password, string pushClientID)
        {
            EAccount user = DBBase.Query <EAccount>("UserName='******'").FirstOrDefault();

            if (user == null)
            {
                throw new Exception("用户名或密码不正确");
            }
            if (user.Password != password)
            {
                throw new Exception("用户名或密码不正确");
            }
            //修改客户端推送ID
            user.PushClientID = pushClientID;
            DBBase.Change(user);
            return(user);
        }
        public MyResult SetDefault(int par0)
        {
            List <EUserSearch> plist = DBBase.Query <EUserSearch>("UserID=" + MySession.UserID);

            foreach (var s in plist)
            {
                if (s.ID == par0)
                {
                    s.IsDefault = true;
                }
                else
                {
                    s.IsDefault = false;
                }
                DBBase.Change(s);
            }
            return(ServiceResult("ok"));
        }
Exemple #8
0
 public void ClearBattleOneSideState(Battle battle, string uid)
 {
     foreach (var s in battle.Sides)
     {
         if (s.AccountID != uid)
         {
             continue;
         }
         LogHelper.DebugLog("clear:" + uid);
         EAccount user = DBBase.Get <EAccount>(Convert.ToInt32(s.AccountID));
         if (user != null)
         {
             user.BattleCode = "";
             user.BattleIP   = "";
             user.BattlePort = "";
             DBBase.Change(user);
         }
     }
 }
Exemple #9
0
        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));
        }
Exemple #10
0
        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));
        }
Exemple #11
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="par0">账号</param>
        /// <param name="par1">密码</param>
        /// <returns></returns>
        public MyResult Login(string par0, string par1, string par2)
        {
            EUser user = DBBase.Query <EUser>("Phone='" + par0 + "'").FirstOrDefault();

            if (user == null)
            {
                return(ServiceErrorResult("用户名或密码不正确"));
            }
            else
            {
                if (user.Password != par1)
                {
                    return(ServiceErrorResult("用户名或密码不正确"));
                }
                else
                {
                    //修改客户端推送ID
                    user.PushClientID = par2;
                    DBBase.Change(user);

                    return(ServiceResult(user));
                }
            }
        }
Exemple #12
0
        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);
        }
Exemple #13
0
        public void FinishedBattle(Battle battle)
        {
            int takeDiamon = 0;

            if (battle.WhoTakeMoney == 1)
            {
                if (battle.GameNum == 8)
                {
                    takeDiamon = -10;
                }
                else if (battle.GameNum == 16)
                {
                    takeDiamon = -20;
                }
            }
            foreach (var s in battle.Sides)
            {
                //结算
                EAccount user = DBBase.Get <EAccount>(Convert.ToInt32(s.AccountID));
                if (user != null)
                {
                    if (battle.BattleType == BattleType.Gold900)
                    {
                        s.GetMoney = s.TotalScore * 900;
                        user.Gold += s.GetMoney;
                    }
                    else if (battle.BattleType == BattleType.Gold2300)
                    {
                        s.GetMoney = s.TotalScore * 2300;
                        user.Gold += s.GetMoney;
                    }
                    else if (battle.BattleType == BattleType.Gold5300)
                    {
                        s.GetMoney = s.TotalScore * 5300;
                        user.Gold += s.GetMoney;
                    }
                    else if (battle.BattleType == BattleType.Diamon10)
                    {
                        s.GetMoney    = s.TotalScore * 10;
                        user.Diamond += s.GetMoney;
                    }
                    else if (battle.BattleType == BattleType.Diamon50)
                    {
                        s.GetMoney    = s.TotalScore * 50;
                        user.Diamond += takeDiamon + s.GetMoney;
                    }
                    else if (battle.BattleType == BattleType.Diamon100)
                    {
                        s.GetMoney    = s.TotalScore * 100;
                        user.Diamond += takeDiamon + s.GetMoney;
                    }
                    if (user.Gold < 0)
                    {
                        user.Gold = 0;
                    }
                    if (user.Diamond < 0)
                    {
                        user.Diamond = 0;
                    }
                    if (!user.IsAI)
                    {
                        DBBase.Change(user);
                    }
                }
            }
        }