コード例 #1
0
        public RespawnDTO LoadById(long respawnId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    RespawnDTO dto = new RespawnDTO();
                    if (Mapper.Mapper.Instance.RespawnMapper.ToRespawnDTO(context.Respawn.FirstOrDefault(s => s.RespawnId.Equals(respawnId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #2
0
 public void Insert(List <ShopItemDTO> items)
 {
     try
     {
         using (OpenNosContext context = DataAccessHelper.CreateContext())
         {
             context.Configuration.AutoDetectChangesEnabled = false;
             foreach (ShopItemDTO Item in items)
             {
                 ShopItem entity = _mapper.Map <ShopItem>(Item);
                 context.ShopItem.Add(entity);
             }
             context.Configuration.AutoDetectChangesEnabled = true;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }
コード例 #3
0
 public void Insert(List <NpcMonsterDTO> npcs)
 {
     try
     {
         using (var context = DataAccessHelper.CreateContext())
         {
             context.Configuration.AutoDetectChangesEnabled = false;
             foreach (NpcMonsterDTO Item in npcs)
             {
                 NpcMonster entity = _mapper.Map <NpcMonster>(Item);
                 context.NpcMonster.Add(entity);
             }
             context.Configuration.AutoDetectChangesEnabled = true;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }
コード例 #4
0
        public ShopDTO LoadByNpc(int mapNpcId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    ShopDTO dto = new ShopDTO();
                    if (Mapper.Mappers.ShopMapper.ToShopDTO(context.Shop.FirstOrDefault(s => s.MapNpcId.Equals(mapNpcId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #5
0
        public PenaltyLogDTO LoadById(int penaltyLogId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    PenaltyLogDTO dto = new PenaltyLogDTO();
                    if (Mapper.Mappers.PenaltyLogMapper.ToPenaltyLogDTO(context.PenaltyLog.AsNoTracking().FirstOrDefault(s => s.PenaltyLogId.Equals(penaltyLogId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #6
0
        public RecipeItemDTO LoadById(short recipeItemId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    RecipeItemDTO dto = new RecipeItemDTO();
                    if (Mapper.Mappers.RecipeItemMapper.ToRecipeItemDTO(context.RecipeItem.AsNoTracking().FirstOrDefault(s => s.RecipeItemId.Equals(recipeItemId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #7
0
ファイル: QuestLogDAO.cs プロジェクト: tolgatr61/nostormv2
        public QuestLogDTO LoadById(long id)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    QuestLogDTO dto = new QuestLogDTO();
                    if (Mapper.Mappers.QuestLogMapper.ToQuestLogDTO(context.QuestLog.FirstOrDefault(i => i.Id.Equals(id)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #8
0
ファイル: ItemCardDAO.cs プロジェクト: LumiereZ/OpenNos-1
 public void Insert(List <ItemCardDTO> itemCards)
 {
     try
     {
         using (var context = DataAccessHelper.CreateContext())
         {
             context.Configuration.AutoDetectChangesEnabled = false;
             foreach (ItemCardDTO itemCard in itemCards)
             {
                 ItemCard entity = _mapper.Map <ItemCard>(itemCard);
                 context.ItemCard.Add(entity);
             }
             context.Configuration.AutoDetectChangesEnabled = true;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }
コード例 #9
0
        public MapTypeMapDTO LoadByMapAndMapType(short mapId, short maptypeId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    MapTypeMapDTO dto = new MapTypeMapDTO();
                    if (Mapper.Mappers.MapTypeMapMapper.ToMapTypeMapDTO(context.MapTypeMap.FirstOrDefault(i => i.MapId.Equals(mapId) && i.MapTypeId.Equals(maptypeId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #10
0
ファイル: ComboDAO.cs プロジェクト: tolgatr61/nostormv2
        public ComboDTO LoadById(short comboId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    ComboDTO dto = new ComboDTO();
                    if (Mapper.Mappers.ComboMapper.ToComboDTO(context.Combo.FirstOrDefault(s => s.SkillVNum.Equals(comboId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #11
0
ファイル: BCardDAO.cs プロジェクト: Vorlent/OpenNos
 public void Insert(List <BCardDTO> cards)
 {
     try
     {
         using (OpenNosContext context = DataAccessHelper.CreateContext())
         {
             context.Configuration.AutoDetectChangesEnabled = false;
             foreach (BCardDTO card in cards)
             {
                 BCard entity = _mapper.Map <BCard>(card);
                 context.BCard.Add(entity);
             }
             context.Configuration.AutoDetectChangesEnabled = true;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }
コード例 #12
0
        public WarpPointDTO LoadById(short warppointID)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    WarpPointDTO dto = new WarpPointDTO();
                    if (Mapper.Mappers.WarpPointMapper.ToWarpPointDTO(context.WarpPoint.FirstOrDefault(i => i.WarpPointID.Equals(warppointID)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #13
0
ファイル: ActPartDAO.cs プロジェクト: tolgatr61/nostormv2
 public void Insert(List <ActPartDTO> actParts)
 {
     try
     {
         using (OpenNosContext context = DataAccessHelper.CreateContext())
         {
             context.Configuration.AutoDetectChangesEnabled = false;
             foreach (ActPartDTO actPart in actParts)
             {
                 ActPart entity = new ActPart();
                 context.ActPart.Add(entity);
             }
             context.Configuration.AutoDetectChangesEnabled = true;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }
コード例 #14
0
        public MaintenanceLogDTO LoadFirst()
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    MaintenanceLogDTO dto = new MaintenanceLogDTO();
                    if (Mapper.Mapper.Instance.MaintenanceLogMapper.ToMaintenanceLogDTO(context.MaintenanceLog.FirstOrDefault(m => m.DateEnd > DateTime.Now), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #15
0
 public void Insert(List <ShopSkillDTO> skills)
 {
     try
     {
         using (OpenNosContext context = DataAccessHelper.CreateContext())
         {
             context.Configuration.AutoDetectChangesEnabled = false;
             foreach (ShopSkillDTO Skill in skills)
             {
                 ShopSkill entity = _mapper.Map <ShopSkill>(Skill);
                 context.ShopSkill.Add(entity);
             }
             context.Configuration.AutoDetectChangesEnabled = true;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }
コード例 #16
0
ファイル: MapDAO.cs プロジェクト: McIks/OpenNos-master
 public void Insert(List <MapDTO> maps)
 {
     try
     {
         using (var context = DataAccessHelper.CreateContext())
         {
             context.Configuration.AutoDetectChangesEnabled = false;
             foreach (MapDTO Item in maps)
             {
                 Map entity = _mapper.Map <Map>(Item);
                 context.Map.Add(entity);
             }
             context.Configuration.AutoDetectChangesEnabled = true;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }
コード例 #17
0
ファイル: CardDAO.cs プロジェクト: joaoderocha/Kint-Sources
        public CardDTO LoadById(short cardId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    CardDTO dto = new CardDTO();
                    if (Mapper.Mapper.Instance.CardMapper.ToCardDTO(context.Card.FirstOrDefault(s => s.CardId.Equals(cardId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #18
0
        public MultiAccountExceptionDTO LoadByAccount(long accountId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    MultiAccountExceptionDTO dto = new MultiAccountExceptionDTO();
                    if (Mapper.Mappers.MultiAccountExceptionMapper.ToMultiAccountExceptionDTO(context.MultiAccountException.AsNoTracking().FirstOrDefault(s => s.AccountId.Equals(accountId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #19
0
        public MapMonsterDTO LoadById(int mapMonsterId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    MapMonsterDTO dto = new MapMonsterDTO();
                    if (Mapper.Mapper.Instance.MapMonsterMapper.ToMapMonsterDTO(context.MapMonster.FirstOrDefault(i => i.MapMonsterId == mapMonsterId), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #20
0
        public IEnumerable <TDTO> InsertOrUpdate(IEnumerable <TDTO> dtos)
        {
            try
            {
                IList <TDTO> results = new List <TDTO>();
                using (var context = DataAccessHelper.CreateContext())
                {
                    foreach (TDTO dto in dtos)
                    {
                        results.Add(InsertOrUpdate(context, dto));
                    }
                }

                return(results);
            }
            catch (Exception e)
            {
                Logger.Log.Error(String.Format(Language.Instance.GetMessageFromKey("UPDATE_ERROR"), e.Message), e);
                return(Enumerable.Empty <TDTO>());
            }
        }
コード例 #21
0
        public MapDTO LoadById(short mapId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    MapDTO dto = new MapDTO();
                    if (Mapper.Mapper.Instance.MapMapper.ToMapDTO(context.Map.FirstOrDefault(c => c.MapId.Equals(mapId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #22
0
        public QuestDTO InsertOrUpdate(QuestDTO quest)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    Quest entity = context.Quest.Find(quest.QuestId);

                    if (entity == null)
                    {
                        return(insert(quest, context));
                    }
                    return(update(entity, quest, context));
                }
            }
            catch (Exception e)
            {
                Logger.Error(string.Format(Language.Instance.GetMessageFromKey("INSERT_ERROR"), quest, e.Message), e);
                return(quest);
            }
        }
コード例 #23
0
ファイル: RecipeDAO.cs プロジェクト: tolgatr61/nostormv2
        public RecipeDTO LoadByItemVNum(short itemVNum)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    RecipeDTO dto = new RecipeDTO();
                    if (Mapper.Mappers.RecipeMapper.ToRecipeDTO(context.Recipe.SingleOrDefault(s => s.ItemVNum.Equals(itemVNum)), dto))
                    {
                        return dto;
                    }

                    return null;
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return null;
            }
        }
コード例 #24
0
 public DeleteResult Delete(long characterId, long questId)
 {
     try
     {
         using (OpenNosContext context = DataAccessHelper.CreateContext())
         {
             CharacterQuest charQuest = context.CharacterQuest.FirstOrDefault(i => i.CharacterId == characterId && i.QuestId == questId);
             if (charQuest != null)
             {
                 context.CharacterQuest.Remove(charQuest);
                 context.SaveChanges();
             }
             return(DeleteResult.Deleted);
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
         return(DeleteResult.Error);
     }
 }
コード例 #25
0
 public DeleteResult Delete(long characterId, short skillVNum)
 {
     try
     {
         using (var context = DataAccessHelper.CreateContext())
         {
             CharacterSkill invItem = context.CharacterSkill.FirstOrDefault(i => i.CharacterId == characterId && i.SkillVNum == skillVNum);
             if (invItem != null)
             {
                 context.CharacterSkill.Remove(invItem);
                 context.SaveChanges();
             }
             return(DeleteResult.Deleted);
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
         return(DeleteResult.Error);
     }
 }
コード例 #26
0
        public NpcMonsterDTO LoadByVNum(short npcMonsterVNum)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    NpcMonsterDTO dto = new NpcMonsterDTO();
                    if (Mapper.Mappers.NpcMonsterMapper.ToNpcMonsterDTO(context.NpcMonster.FirstOrDefault(i => i.NpcMonsterVNum.Equals(npcMonsterVNum)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #27
0
        public MapNpcDTO LoadById(int mapNpcId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    MapNpcDTO dto = new MapNpcDTO();
                    if (Mapper.Mappers.MapNpcMapper.ToMapNpcDTO(context.MapNpc.FirstOrDefault(i => i.MapNpcId.Equals(mapNpcId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #28
0
        public TeleporterDTO LoadById(short teleporterId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    TeleporterDTO dto = new TeleporterDTO();
                    if (Mapper.Mappers.TeleporterMapper.ToTeleporterDTO(context.Teleporter.AsNoTracking().FirstOrDefault(i => i.TeleporterId.Equals(teleporterId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
コード例 #29
0
 public void Insert(List <ComboDTO> combos)
 {
     try
     {
         using (OpenNosContext context = DataAccessHelper.CreateContext())
         {
             context.Configuration.AutoDetectChangesEnabled = false;
             foreach (ComboDTO combo in combos)
             {
                 Combo entity = _mapper.Map <Combo>(combo);
                 context.Combo.Add(entity);
             }
             context.Configuration.AutoDetectChangesEnabled = true;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }
コード例 #30
0
        public ShopItemDTO LoadById(int itemId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    ShopItemDTO dto = new ShopItemDTO();
                    if (Mapper.Mappers.ShopItemMapper.ToShopItemDTO(context.ShopItem.FirstOrDefault(i => i.ShopItemId.Equals(itemId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }