Ejemplo n.º 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();
            }
        }
 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);
     }
 }
Ejemplo n.º 3
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();
            }
        }