コード例 #1
0
        protected override void DataOperation()
        {
            using (var db = new UniSpyContext())
            {
                var result = from p in db.Pstorages
                             where p.ProfileId == _request.ProfileId &&
                             p.Dindex == _request.DataIndex &&
                             p.Ptype == (int)_request.StorageType
                             select p;

                Pstorage ps;
                if (result.Count() == 0)
                {
                    //insert a new record in database
                    ps           = new Pstorage();
                    ps.Dindex    = _request.DataIndex;
                    ps.ProfileId = _request.ProfileId;
                    ps.Ptype     = (int)_request.StorageType;
                    ps.Data      = _request.KeyValues;
                    db.Pstorages.Add(ps);
                }
                else if (result.Count() == 1)
                {
                    //update an existed record in database
                    ps      = result.First();
                    ps.Data = _request.KeyValues;
                }

                db.SaveChanges();
            }
        }
コード例 #2
0
        private void P2PGroupRoomList()
        {
            // Game name is unique in redis database
            var groupInfo = _peerGroupRedisClient.Context.FirstOrDefault(x => x.GameName == _request.GameName);

            if (groupInfo is null)
            {
                // search gamename in database
                using (var db = new UniSpyContext())
                {
                    var result = from g in db.Games
                                 join gl in db.Grouplists on g.Gameid equals gl.Gameid
                                 where g.Gamename == _request.GameName
                                 select gl;
                    if (result.Count() == 0)
                    {
                        throw new SBException($"can not find peer group info in redis and database, please check game name:{_request.GameName}");
                    }
                    else
                    {
                        groupInfo = new PeerGroupInfo()
                        {
                            GameName  = _request.GameName,
                            GameID    = result.First().Gameid,
                            PeerRooms = result.Select(x => new PeerRoomInfo(x)).ToList()
                        };
                    }
                }
            }
            ((P2PGroupRoomListResult)_result).PeerGroupInfo = groupInfo;
        }
コード例 #3
0
 protected override void DataOperation()
 {
     using (var db = new UniSpyContext())
     {
         var result = from p in db.Profiles
                      join u in db.Users on p.Userid equals u.UserId
                      join sp in db.Subprofiles on p.ProfileId equals sp.ProfileId
                      where sp.Uniquenick == _request.Uniquenick &&
                      sp.Cdkeyenc == _request.CDKey &&
                      sp.PartnerId == _request.PartnerCode &&
                      sp.NamespaceId == _request.NamespaceId &&
                      u.Email == _request.Email
                      // we do not care about game id now
                      select new { u, p, sp };
         if (result.Count() != 1)
         {
             throw new AuthException("No account exists with the provided email address.");
         }
         var data = result.First();
         _result.UserId    = data.u.UserId;
         _result.ProfileId = data.p.ProfileId;
         _result.CdKeyHash = data.sp.Cdkeyenc;
         // currently we set this to uniquenick
         _result.ProfileNick = data.sp.Uniquenick;
     }
 }
コード例 #4
0
        public static string GetSecretKey(string gameName)
        {
            using (var db = new UniSpyContext())
            {
                var result = from p in db.Games
                             where p.Gamename == gameName
                             select new { p.Secretkey };

                return(result.First().Secretkey);
            }
        }
コード例 #5
0
 protected override void DataOperation()
 {
     try
     {
         using (var db = new UniSpyContext())
         {
             db.Subprofiles.FirstOrDefault(s => s.SubProfileId == _client.Info.SubProfileInfo.SubProfileId).Uniquenick = _request.UniqueNick;
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw new GPDatabaseException(e.Message);
     }
 }
コード例 #6
0
        protected override void DataOperation()
        {
            using (var db = new UniSpyContext())
            {
                var result = db.Subprofiles.Where(s => s.ProfileId == _client.Info.ProfileInfo.ProfileId &&
                                                  s.NamespaceId == _client.Info.SubProfileInfo.NamespaceId);
                //&& s.Productid == _client.Info.ProductID);

                if (result.Count() == 0 || result.Count() > 1)
                {
                    throw new GPDatabaseException("No user infomation found in database.");
                }

                db.Subprofiles.FirstOrDefault(s => s.SubProfileId == _client.Info.SubProfileInfo.SubProfileId).Cdkeyenc = _request.CDKeyEnc;

                db.SaveChanges();
            }
        }
コード例 #7
0
 protected override void DataOperation()
 {
     using (var db = new UniSpyContext())
     {
         if (db.Blockeds.Where(b => b.Targetid == _request.ProfileId &&
                               b.Namespaceid == _client.Info.SubProfileInfo.NamespaceId &&
                               b.ProfileId == _client.Info.ProfileInfo.ProfileId).Count() == 0)
         {
             Blocked blocked = new Blocked
             {
                 ProfileId   = (int)_client.Info.ProfileInfo.ProfileId,
                 Targetid    = _request.ProfileId,
                 Namespaceid = (int)_client.Info.SubProfileInfo.NamespaceId
             };
             db.Blockeds.Update(blocked);
         }
     }
 }
コード例 #8
0
        protected override void DataOperation()
        {
            using (var db = new UniSpyContext())
            {
                var result = from friend in db.Friends
                             where friend.ProfileId == _request.DeleteProfileID &&
                             friend.Namespaceid == _client.Info.SubProfileInfo.NamespaceId
                             select friend;
                if (result.Count() == 0)
                {
                    throw new GPDatabaseException("No buddy found in database.");
                }
                else if (result.Count() > 1)
                {
                    throw new GPDatabaseException("More than one buddy found in database, please check database.");
                }

                db.Friends.Remove(result.First());
            }
        }
コード例 #9
0
        protected override void DataOperation()
        {
            using (var db = new UniSpyContext())
            {
                var result = from p in db.Profiles
                             join u in db.Users on p.Userid equals u.UserId
                             join sp in db.Subprofiles on p.ProfileId equals sp.ProfileId
                             where sp.Authtoken == _request.AuthToken &&
                             sp.PartnerId == _request.GameId
                             select new { u, p, sp };
                if (result.Count() != 1)
                {
                    throw new System.Exception("No account exists with the provided email address.");
                }

                var data = result.First();
                _result.UserId    = data.u.UserId;
                _result.ProfileId = data.p.ProfileId;
                _result.CdKeyHash = data.sp.Cdkeyenc;
                // currently we set this to uniquenick
                _result.ProfileNick = data.sp.Uniquenick;
                _result.UniqueNick  = data.sp.Uniquenick;
            }
        }
コード例 #10
0
        protected override void DataOperation()
        {
            using (var db = new UniSpyContext())
            {
                var profile = db.Profiles.Where(
                    p => p.Userid == _client.Info.UserInfo.UserId &&
                    p.ProfileId == _client.Info.ProfileInfo.ProfileId &&
                    p.Nick == p.Nick).First();

                var user = db.Users.Where(
                    u => u.UserId == _client.Info.UserInfo.UserId).First();

                var subprofile = db.Subprofiles.Where(
                    s => s.ProfileId == _client.Info.ProfileInfo.ProfileId &&
                    s.NamespaceId == _client.Info.SubProfileInfo.NamespaceId &&
                    s.Uniquenick == _client.Info.SubProfileInfo.Uniquenick).First();

                if (_request.HasPublicMaskFlag)
                {
                    profile.Publicmask = (int)_request.PublicMask;
                }
                if (_request.HasFirstNameFlag)
                {
                    profile.Firstname = _request.FirstName;
                }
                if (_request.HasLastNameFlag)
                {
                    profile.Lastname = _request.LastName;
                }
                if (_request.HasICQFlag)
                {
                    profile.Icquin = _request.ICQUIN;
                }
                if (_request.HasHomePageFlag)
                {
                    profile.Homepage = _request.HomePage;
                }
                if (_request.HasBirthdayFlag)
                {
                    profile.Birthday   = _request.BirthDay;
                    profile.Birthmonth = _request.BirthMonth;
                    profile.Birthyear  = _request.BirthYear;
                }
                if (_request.HasSexFlag)
                {
                    profile.Sex = _request.Sex;
                }

                if (_request.HasZipCode)
                {
                    profile.Zipcode = _request.ZipCode;
                }
                if (_request.HasCountryCode)
                {
                    profile.Countrycode = _request.CountryCode;
                }

                db.Update(profile);
                // we update the profile in our memory
                _client.Info.ProfileInfo = profile;
            }
        }