Example #1
0
        public async Task Save(Level avatar)
        {
            ucsdbEntities context = new ucsdbEntities(m_vConnectionString);
            {
                context.Configuration.AutoDetectChangesEnabled = false;
                context.Configuration.ValidateOnSaveEnabled    = false;
                player p = await context.player.FindAsync(avatar.GetPlayerAvatar().GetId());

                if (p != null)
                {
                    p.LastUpdateTime       = avatar.GetTime();
                    p.AccountStatus        = avatar.GetAccountStatus();
                    p.AccountPrivileges    = avatar.GetAccountPrivileges();
                    p.IPAddress            = avatar.GetIPAddress();
                    p.Avatar               = avatar.GetPlayerAvatar().SaveToJSON();
                    p.GameObjects          = avatar.SaveToJSON();
                    context.Entry(p).State = EntityState.Modified;
                }
                else
                {
                    context.player.Add(
                        new player
                    {
                        PlayerId          = avatar.GetPlayerAvatar().GetId(),
                        AccountStatus     = avatar.GetAccountStatus(),
                        AccountPrivileges = avatar.GetAccountPrivileges(),
                        LastUpdateTime    = avatar.GetTime(),
                        IPAddress         = avatar.GetIPAddress(),
                        Avatar            = avatar.GetPlayerAvatar().SaveToJSON(),
                        GameObjects       = avatar.SaveToJSON()
                    });
                }
                await context.SaveChangesAsync();
            }
        }
Example #2
0
        public async Task Save(Alliance alliance)
        {
            using (ucsdbEntities context = new ucsdbEntities(m_vConnectionString))
            {
                context.Configuration.AutoDetectChangesEnabled = false;
                context.Configuration.ValidateOnSaveEnabled    = false;
                clan c = await context.clan.FindAsync((int)alliance.GetAllianceId());

                if (c != null)
                {
                    c.LastUpdateTime       = DateTime.Now;
                    c.Data                 = alliance.SaveToJSON();
                    context.Entry(c).State = EntityState.Modified;
                }
                else
                {
                    context.clan.Add(
                        new clan
                    {
                        ClanId         = alliance.GetAllianceId(),
                        LastUpdateTime = DateTime.Now,
                        Data           = alliance.SaveToJSON()
                    });
                }
                await context.SaveChangesAsync();
            }
        }
        public async Task Save(Alliance alliance)
        {
            using (ucsdbEntities ctx = new ucsdbEntities(m_vConnectionString))
            {
                ctx.Configuration.AutoDetectChangesEnabled = false;
                ctx.Configuration.ValidateOnSaveEnabled    = false;
                clan c = await ctx.clan.FindAsync((int)alliance.GetAllianceId());

                if (c != null)
                {
                    c.LastUpdateTime   = DateTime.Now;
                    c.Data             = alliance.SaveToJson();
                    ctx.Entry(c).State = EntityState.Modified;
                }
                //else
                //{
                //    context.clan.Add(
                //        new clan
                //        {
                //            ClanId = alliance.GetAllianceId(),
                //            LastUpdateTime = DateTime.Now,
                //            Data = alliance.SaveToJSON()
                //        });
                //}
                await ctx.SaveChangesAsync();
            }
        }
Example #4
0
 public async Task Save(List <Level> avatars)
 {
     try
     {
         using (ucsdbEntities context = new ucsdbEntities(m_vConnectionString))
         {
             context.Configuration.AutoDetectChangesEnabled = false;
             context.Configuration.ValidateOnSaveEnabled    = false;
             foreach (Level pl in avatars)
             {
                 lock (pl)
                 {
                     player p = context.player.Find(pl.GetPlayerAvatar().GetId());
                     if (p != null)
                     {
                         p.LastUpdateTime       = pl.GetTime();
                         p.AccountStatus        = pl.GetAccountStatus();
                         p.AccountPrivileges    = pl.GetAccountPrivileges();
                         p.IPAddress            = pl.GetIPAddress();
                         p.Avatar               = pl.GetPlayerAvatar().SaveToJSON();
                         p.GameObjects          = pl.SaveToJSON();
                         context.Entry(p).State = EntityState.Modified;
                     }
                     else
                     {
                         context.player.Add(
                             new player
                         {
                             PlayerId          = pl.GetPlayerAvatar().GetId(),
                             AccountStatus     = pl.GetAccountStatus(),
                             AccountPrivileges = pl.GetAccountPrivileges(),
                             LastUpdateTime    = pl.GetTime(),
                             IPAddress         = pl.GetIPAddress(),
                             Avatar            = pl.GetPlayerAvatar().SaveToJSON(),
                             GameObjects       = pl.SaveToJSON()
                         });
                     }
                 }
             }
             await context.SaveChangesAsync();
         }
     }
     catch
     {
     }
 }
 public async Task Save(List <Level> levels)
 {
     try
     {
         using (var ctx = new ucsdbEntities(m_vConnectionString))
         {
             ctx.Configuration.AutoDetectChangesEnabled = false;
             ctx.Configuration.ValidateOnSaveEnabled    = false;
             foreach (Level pl in levels)
             {
                 lock (pl)
                 {
                     player p = ctx.player.Find(pl.GetPlayerAvatar().GetId());
                     if (p != null)
                     {
                         p.LastUpdateTime    = pl.GetTime();
                         p.AccountStatus     = pl.GetAccountStatus();
                         p.AccountPrivileges = pl.GetAccountPrivileges();
                         p.IPAddress         = pl.GetIPAddress();
                         p.Avatar            = pl.GetPlayerAvatar().SaveToJson();
                         p.GameObjects       = pl.SaveToJson();
                         ctx.Entry(p).State  = EntityState.Modified;
                     }
                     //else
                     //    context.player.Add(
                     //        new player
                     //        {
                     //            PlayerId = pl.GetPlayerAvatar().GetId(),
                     //            AccountStatus = pl.GetAccountStatus(),
                     //            AccountPrivileges = pl.GetAccountPrivileges(),
                     //            LastUpdateTime = pl.GetTime(),
                     //            IPAddress = pl.GetIPAddress(),
                     //            Avatar = pl.GetPlayerAvatar().SaveToJSON(),
                     //            GameObjects = pl.SaveToJSON()
                     //        });
                 }
             }
             await ctx.SaveChangesAsync();
         }
     }
     catch
     {
         // 0 Actual f***s given.
     }
 }
        public async Task Save(List <Alliance> alliances)
        {
            try
            {
                using (ucsdbEntities ctx = new ucsdbEntities(m_vConnectionString))
                {
                    ctx.Configuration.AutoDetectChangesEnabled = false;
                    ctx.Configuration.ValidateOnSaveEnabled    = false;
                    foreach (Alliance alliance in alliances)
                    {
                        lock (alliance)
                        {
                            clan c = ctx.clan.Find((int)alliance.GetAllianceId());
                            if (c != null)
                            {
                                c.LastUpdateTime   = DateTime.Now;
                                c.Data             = alliance.SaveToJson();
                                ctx.Entry(c).State = EntityState.Modified;
                            }
                            //else
                            //{
                            //    context.clan.Add(
                            //        new clan
                            //        {
                            //            ClanId = alliance.GetAllianceId(),
                            //            LastUpdateTime = DateTime.Now,
                            //            Data = alliance.SaveToJSON(),

                            //        });
                            //}
                        }
                    }
                    await ctx.SaveChangesAsync();
                }
            }
            catch
            {
                // 0 Actual f***s given.
            }
        }