} // method TradeSkillsGetAll public static Skill SkillGetById(long objectID) { string cacheKey = "Skill_" + objectID; Skill returnObject = HttpContext.Current.Cache[cacheKey] as Skill; if (returnObject == null) { using (RepopdataEntities myEntities = new RepopdataEntities()) { returnObject = (from skill in myEntities.Skills where skill.skillID == objectID select skill).FirstOrDefault(); AppCaching.AddToCache(cacheKey, returnObject); } // using } // if (currentSkill == null) return returnObject; } // method SkillGetById
} // method PowerSourceInfoGetByItemID public static Item_Stores_Power PowerStorageInfoGetByItemID(long objectID) { string cacheKey = "ItemPowerStorageInfoByItemID_" + objectID; Item_Stores_Power returnObject = HttpContext.Current.Cache[cacheKey] as Item_Stores_Power; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { returnObject = (from item in myEntities.Item_Stores_Power where item.itemID == objectID select item).FirstOrDefault(); if (returnObject == null) { return null; } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method PowerStorageInfoGetByItemID
} // DetermineItemGroupByItemID public static Item_Value ValueGetByItemID(long objectID) { string cacheKey = "ItemValueByItemID_" + objectID; Item_Value returnObject = HttpContext.Current.Cache[cacheKey] as Item_Value; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { returnObject = (from item in myEntities.Item_Value where item.itemID == objectID select item).FirstOrDefault(); if (returnObject == null) { return null; } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // ValueGetByItemID
} // method GetAllFittings public static List<BlueprintBase> GetAllBlueprints() { string cacheKey = "AllBlueprints"; List<BlueprintBase> returnObject = HttpContext.Current.Cache[cacheKey] as List<BlueprintBase>; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Structures select item).Distinct().OrderBy(x => x.displayName); if (result == null) { return null; } returnObject = new List<BlueprintBase>(); foreach (Structure item in result.ToList()) { returnObject.Add(new BlueprintBase(item.structureID)); } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method GetAllBlueprints
} // method RecipesGetBySkillID // This method is used by the constructor for CraftingRecipe public static Recipe RecipeGetById(long objectID) { string cacheKey = "Recipe_" + objectID; Recipe returnObject = HttpContext.Current.Cache[cacheKey] as Recipe; if (returnObject == null) { using (RepopdataEntities myEntities = new RepopdataEntities()) { returnObject = (from recipe in myEntities.Recipes where recipe.recipeID == objectID select recipe).FirstOrDefault(); if (returnObject == null) { return null; } AppCaching.AddToCache(cacheKey, returnObject); } // using } // if (currentRecipe == null) return returnObject; } // method RecipeGetById
public static List<CraftingFilter> GetAllCraftingFilters() { string cacheKey = "AllCraftingFilters"; List<CraftingFilter> returnObject = HttpContext.Current.Cache[cacheKey] as List<CraftingFilter>; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Crafting_Filters select item).Distinct().OrderBy(x => x.displayName); if (result == null) { return null; } returnObject = new List<CraftingFilter>(); foreach (Crafting_Filters item in result.ToList()) { returnObject.Add(new CraftingFilter(item)); } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method GetAllBlueprints
} // method GetAllComponents public static Crafting_Components CraftingComponentGetByComponentID(long objectID) { string cacheKey = "CraftingComponentByComponentID_" + objectID; Crafting_Components returnObject = HttpContext.Current.Cache[cacheKey] as Crafting_Components; if (returnObject == null) { using (RepopdataEntities myEntities = new RepopdataEntities()) { returnObject = (from item in myEntities.Crafting_Components where item.componentID == objectID select item).FirstOrDefault(); if (returnObject == null) { return null; } AppCaching.AddToCache(cacheKey, returnObject); } // using }// if return returnObject; } // method CraftingComponentGetByComponentID
public static List<SpeciesInfo> GetAllSpecies() { string cacheKey = "AllSpecies"; List<SpeciesInfo> returnObject = HttpContext.Current.Cache[cacheKey] as List<SpeciesInfo>; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Species select item).Distinct().OrderBy(x => x.displayName); if (result == null) { return null; } returnObject = new List<SpeciesInfo>(); foreach (Species item in result.ToList()) { returnObject.Add(new SpeciesInfo(item)); } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method GetAllSpecies
} // method BlueprintGetByID public static RecipeBook BookGetByRecipeID(long objectID) { string cacheKey = "BookByRecipeID_" + objectID; RecipeBook returnObject = HttpContext.Current.Cache[cacheKey] as RecipeBook; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Recipe_Books where item.recipeID == objectID select item).FirstOrDefault(); if (result == null) { return null; } returnObject = new RecipeBook(result.itemID); AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method BookGetByRecipeID
} // method GetAllSpecies public static SpeciesInfo SpeciesInfoGetBySpeciesID(long objectID) { string cacheKey = "AllSpeciesBySpeciesID_" + objectID; SpeciesInfo returnObject = HttpContext.Current.Cache[cacheKey] as SpeciesInfo; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Species where item.speciesID == objectID select item).FirstOrDefault(); if (result == null) { return null; } returnObject = new SpeciesInfo(result); AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method SpeciesInfoGetBySpeciesID
} // method GetFilterByItemID public static CraftingFilter CraftingFilterGetByFilterID(long objectID) { string cacheKey = "CraftingFilterByFilterID_" + objectID; CraftingFilter returnObject = HttpContext.Current.Cache[cacheKey] as CraftingFilter; if (returnObject == null) { using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Crafting_Filters where item.filterID == objectID select item).FirstOrDefault(); if (result == null) { return null; } returnObject = new CraftingFilter(result); AppCaching.AddToCache(cacheKey, returnObject); } // using }// if return returnObject; } // method CraftingFilterGetByFilterID
} // method FittingGetByID // This method is used by the BlueprintBase constructor public static Structure BlueprintGetByID(long objectID) { string cacheKey = "Blueprint_" + objectID; Structure returnObject = HttpContext.Current.Cache[cacheKey] as Structure; if (returnObject == null) { using (RepopdataEntities myEntities = new RepopdataEntities()) { returnObject = (from item in myEntities.Structures where item.structureID == objectID select item).FirstOrDefault(); if (returnObject == null) { return null; } AppCaching.AddToCache(cacheKey, returnObject); } // using } // if (returnObject == null) return returnObject; } // method BlueprintGetByID
} // method ItemGetByID // This method is used by the FittingBase constructor public static Fitting FittingGetByID(long objectID) { string cacheKey = "Fitting_" + objectID; Fitting returnObject = HttpContext.Current.Cache[cacheKey] as Fitting; if (returnObject == null) { using (RepopdataEntities myEntities = new RepopdataEntities()) { returnObject = (from item in myEntities.Fittings where item.fittingID == objectID select item).FirstOrDefault(); if (returnObject == null) { return null; } AppCaching.AddToCache(cacheKey, returnObject); } // using } // if (returnObject == null) return returnObject; } // method FittingGetByID
} // method AllSpeciesInfoForItem public static List<SpeciesResult> AllSpeciesResultsBySpeciesID(long objectID) { string cacheKey = "AllSpeciesResultsForItem_" + objectID; List<SpeciesResult> returnObject = HttpContext.Current.Cache[cacheKey] as List<SpeciesResult>; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Species_Results where item.speciesID == objectID select item).OrderBy(x => x.speciesID); if (result == null) { return null; } returnObject = new List<SpeciesResult>(); foreach (Species_Results item in result.ToList()) { returnObject.Add(new SpeciesResult(item)); } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method AllSpeciesResultsBySpeciesID
public static List<CharacterTradeSkill> TradeSkillsGetAll() { string cacheKey = "TradeSkillList"; List<CharacterTradeSkill> returnObject = HttpContext.Current.Cache[cacheKey] as List<CharacterTradeSkill>; if (returnObject == null) { using (RepopdataEntities myEntities = new RepopdataEntities()) { var tradeSkills = (from skill in myEntities.Skills join recipe in myEntities.Recipes on skill.skillID equals recipe.skillID select skill).Distinct().OrderBy(x => x.displayName); returnObject = new List<CharacterTradeSkill>(); foreach (Skill skill in tradeSkills.ToList()) { returnObject.Add(new CharacterTradeSkill(skill.skillID)); } AppCaching.AddToCache(cacheKey, returnObject); } // using } // if (skillList == null) return returnObject; } // method TradeSkillsGetAll
} // method IngredientsGetByRecipeID public static List<CraftingRecipeAgent> AgentsGetByRecipeID(long objectID) { string cacheKey = "RecipeAgentsByRecipeID_" + objectID; List<CraftingRecipeAgent> returnObject = HttpContext.Current.Cache[cacheKey] as List<CraftingRecipeAgent>; if (returnObject == null) { using (RepopdataEntities myEntities = new RepopdataEntities()) { var results = (from item in myEntities.Recipe_Agents where item.recipeID == objectID select item); if (results == null) { return null; } returnObject = new List<CraftingRecipeAgent>(); foreach (Recipe_Agents item in results.ToList()) { returnObject.Add(new CraftingRecipeAgent(item)); } AppCaching.AddToCache(cacheKey, returnObject); } // using }// if return returnObject; } // method AgentsGetByRecipeID
} // method BookGetByRecipeID public static List<ItemBase> ItemsGetByComponentID(long objectID) { string cacheKey = "ItemsByComponentID_" + objectID; List<ItemBase> returnObject = HttpContext.Current.Cache[cacheKey] as List<ItemBase>; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Items join components in myEntities.Item_Crafting_Components on item.itemID equals components.itemID where components.componentID == objectID select item).OrderBy(x => x.displayName); if (result == null) { return null; } returnObject = new List<ItemBase>(); foreach (Item item in result.ToList()) { returnObject.Add(new ItemBase(item.itemID)); } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // GetCraftingComponentsByComponentID
public static List<CraftingRecipe> RecipesGetBySkillID(long objectID) { string cacheKey = "RecipesInSkill_" + objectID; List<CraftingRecipe> returnObject = HttpContext.Current.Cache[cacheKey] as List<CraftingRecipe>; if (returnObject == null) { using (RepopdataEntities myEntitities = new RepopdataEntities()) { var results = (from recipe in myEntitities.Recipes where recipe.skillID == objectID select recipe).OrderBy(x => x.displayName); if (results == null) { return null; } returnObject = new List<CraftingRecipe>(); foreach (Recipe recipe in results.ToList()) { returnObject.Add(new CraftingRecipe(recipe.recipeID)); } AppCaching.AddToCache(cacheKey, returnObject); } // using } // if (returnList == null) return returnObject; } // method RecipesGetBySkillID
} // method CraftingComponentGetByComponentID public static List<CraftingComponent> ComponentsGetByItemID(long objectID) { string cacheKey = "ComponentsByItemID_" + objectID; List<CraftingComponent> returnObject = HttpContext.Current.Cache[cacheKey] as List<CraftingComponent>; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Crafting_Components join itemComponents in myEntities.Item_Crafting_Components on item.componentID equals itemComponents.componentID where itemComponents.itemID == objectID select item).Distinct().OrderBy(x => x.displayName); if (result == null) { return null; } returnObject = new List<CraftingComponent>(); foreach (Crafting_Components item in result.ToList()) { returnObject.Add(new CraftingComponent(item.componentID)); } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method GetAllComponents
} // method RecipesGetAllThatUseComponentAsIngredient public static List<CraftingRecipe> RecipesGetAllThatUseComponentAsAgent(long objectID) { string cacheKey = "AllRecipesThatUseComponentAsAgent_" + objectID; List<CraftingRecipe> returnObject = HttpContext.Current.Cache[cacheKey] as List<CraftingRecipe>; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Recipes join agents in myEntities.Recipe_Agents on item.recipeID equals agents.recipeID where agents.componentID == objectID select item); if (result == null) { return null; } returnObject = new List<CraftingRecipe>(); foreach (Recipe item in result.ToList()) { returnObject.Add(new CraftingRecipe(item.recipeID)); } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method RecipesGetAllThatUseComponentAsAgent
} // method RecipeGetById public static List<CraftingRecipeSkillRange> SkillRangeGetByRecipeID(long objectID) { string cacheKey = "SkillRangeByRecipeID_" + objectID; List<CraftingRecipeSkillRange> returnObject = HttpContext.Current.Cache[cacheKey] as List<CraftingRecipeSkillRange>; if (returnObject == null) { using (RepopdataEntities myEntities = new RepopdataEntities()) { var results = (from item in myEntities.Recipe_Skill_Range where item.recipeID == objectID select item).OrderBy(x => x.level); if (results == null) { return null; } returnObject = new List<CraftingRecipeSkillRange>(); foreach (Recipe_Skill_Range item in results.ToList()) { returnObject.Add(new CraftingRecipeSkillRange(item)); } AppCaching.AddToCache(cacheKey, returnObject); } // using } // if return returnObject; } // method GetSkillRangByRecipeID
} // method GetAllBlueprintsCreatedByTradeskillID public static ItemGroupEnum DetermineItemGroupByItemID(long objectID) { string cacheKey = "ItemGroupByItemID_" + objectID; ItemGroupEnum returnObject; if (HttpContext.Current.Cache[cacheKey] == null) { returnObject = ItemGroupEnum.Unknown; } else { returnObject = (ItemGroupEnum)HttpContext.Current.Cache[cacheKey]; } if (returnObject == ItemGroupEnum.Unknown) using (RepopdataEntities myEntities = new RepopdataEntities()) { // There's no easy way to determine the item "group" (recipe book, crafting component, etc.) // This method definitely needs refactoring var recipeResult = RecipeGateway.RecipesGrantedByRecipeBookID(objectID); if (recipeResult.Count > 0) { returnObject = ItemGroupEnum.RecipeBook; AppCaching.AddToCache(cacheKey, returnObject); return returnObject; } var rawMatResult = SpeciesGateway.AllSpeciesInfoForItem(objectID); if (rawMatResult.Count > 0) { returnObject = ItemGroupEnum.RawMaterial; AppCaching.AddToCache(cacheKey, returnObject); return returnObject; } var componentResult = ComponentGateway.ComponentsGetByItemID(objectID); if (componentResult.Count > 0) { returnObject = ItemGroupEnum.CraftingComponent; AppCaching.AddToCache(cacheKey, returnObject); return returnObject; } } // using return returnObject; } // DetermineItemGroupByItemID
} // method RecipesThatCreateBlueprint public static List<CraftingRecipe> RecipesGrantedByRecipeBookID(long objectID) { string cacheKey = "AllRecipesGrantedByRecipeBookID_" + objectID; List<CraftingRecipe> returnObject = HttpContext.Current.Cache[cacheKey] as List<CraftingRecipe>; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Recipes join recipeBooks in myEntities.Recipe_Books on item.recipeID equals recipeBooks.recipeID join items in myEntities.Items on recipeBooks.itemID equals items.itemID where items.itemID == objectID select item); if (result == null) { return null; } returnObject = new List<CraftingRecipe>(); foreach (Recipe recipe in result.ToList()) { returnObject.Add(new CraftingRecipe(recipe.recipeID)); } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method RecipesGrantedByRecipeBookID
} // method GetAllBlueprints public static CraftingFilter CraftingFilterGetByItemID(long objectID) { // Currently, there can only be 1 crafting filter per item string cacheKey = "CraftingFiltersByItemID_" + objectID; CraftingFilter returnObject = HttpContext.Current.Cache[cacheKey] as CraftingFilter; if (returnObject == null) { using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Crafting_Filters join itemCraftingFilter in myEntities.Item_Crafting_Filters on item.filterID equals itemCraftingFilter.filterID where itemCraftingFilter.itemID == objectID select item).FirstOrDefault(); if (result == null) { return null; } returnObject = new CraftingFilter(result); AppCaching.AddToCache(cacheKey, returnObject); } // using } // if (currentSkill == null) return returnObject; } // method GetFilterByItemID
} // method RecipesGetAllThatUseItemAsAgent // All of this logic needs to be completely re-written from scratch due to the refactoring //public static List<CraftingRecipe> RecipesGetAllThatUseItemAsIngredient(long objectID) //{ // string cacheKey = "AllRecipesThatUseItemAsIngredient_" + objectID; // List<CraftingRecipe> returnObject = HttpContext.Current.Cache[cacheKey] as List<CraftingRecipe>; // if (returnObject == null) // using (RepopdataEntities myEntities = new RepopdataEntities()) // { // returnObject = new List<CraftingRecipe>(); // var recipeList = (from item in myEntities.Recipes // join ingredients in myEntities.Recipe_Ingredients on item.recipeID equals ingredients.recipeID // join itemCraftingComponents in myEntities.Item_Crafting_Components on ingredients.componentID equals itemCraftingComponents.componentID // join actualItems in myEntities.Items on itemCraftingComponents.itemID equals actualItems.itemID // where actualItems.itemID == objectID // select item).OrderBy(x => x.skillID); // if (recipeList == null) { return null; } // foreach (Recipe recipe in recipeList) // { // List<CraftingRecipeResult> recipeResults = RecipeResultsGetByRecipeID(recipe.recipeID); // // We only need the Recipe_Ingredients for the current recipe that use one of the item components // List<CraftingRecipeIngredient> componentIngredients = (from item in IngredientsGetByRecipeID(recipe.recipeID) // join components in ComponentGateway.ComponentsGetByItemID(objectID) on item.CraftingComponent.ID equals components.ID // select item).ToList(); // // This is a terrible hack to make this work while I refactor. It needs to be taken out back and buried // CraftingFilter itemFilter = FilterGateway.CraftingFilterGetByItemID(objectID); // if (itemFilter == null) { itemFilter = new CraftingFilter(null); } // foreach (CraftingRecipeIngredient recipeIngredient in componentIngredients) // { // switch (recipeIngredient.Slot) // { // case 1: // foreach (CraftingRecipeResult recipeResult in recipeResults) // { // if ((recipeResult.Filters[0].Ingredient.ID == 0 || recipeResult.filter1ID == itemFilter.ID) && !returnObject.Contains(new CraftingRecipe(recipe.recipeID))) // { returnObject.Add(new CraftingRecipe(recipe.recipeID)); break; } // Don't need to continue if it matches // } // foreach (Recipe_Results recipeResult in recipeResults) // break; // case 2: // foreach (CraftingRecipeResult recipeResult in recipeResults) // { // if ((recipeResult.Filters[1].Ingredient.ID == 0 || recipeResult.filter2ID == itemFilter.ID) && !returnObject.Contains(new CraftingRecipe(recipe.recipeID))) // { returnObject.Add(new CraftingRecipe(recipe.recipeID)); break; } // Don't need to continue if it matches // } // foreach (Recipe_Results recipeResult in recipeResults) // break; // case 3: // foreach (CraftingRecipeResult recipeResult in recipeResults) // { // if ((recipeResult.Filters[2].Ingredient.ID == 0 || recipeResult.filter3ID == itemFilter.ID) && !returnObject.Contains(new CraftingRecipe(recipe.recipeID))) // { returnObject.Add(new CraftingRecipe(recipe.recipeID)); break; } // Don't need to continue if it matches // } // foreach (Recipe_Results recipeResult in recipeResults) // break; // case 4: // foreach (CraftingRecipeResult recipeResult in recipeResults) // { // if ((recipeResult.Filters[3].Ingredient.ID == 0 || recipeResult.filter4ID == itemFilter.ID) && !returnObject.Contains(new CraftingRecipe(recipe.recipeID))) // { returnObject.Add(new CraftingRecipe(recipe.recipeID)); break; } // Don't need to continue if it matches // } // foreach (Recipe_Results recipeResult in recipeResults) // break; // } // switch (recipeIngredient.ingSlot) // } // foreach (Recipe_Ingredients recipeIngredient in componentIngredients) // } // foreach (Recipe recipe in recipeList) // if (returnObject == null) { return null; } // AppCaching.AddToCache(cacheKey, returnObject); // } // using // return returnObject; //} // method RecipesGetAllThatUseItemAsIngredient public static List<CraftingRecipe> RecipesGetAllThatUseFilter(long objectID) { string cacheKey = "AllRecipesThatUseFilter_" + objectID; List<CraftingRecipe> returnObject = HttpContext.Current.Cache[cacheKey] as List<CraftingRecipe>; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Recipes join results in myEntities.Recipe_Results on item.recipeID equals results.recipeID where results.filter1ID == objectID || results.filter2ID == objectID || results.filter3ID == objectID || results.filter4ID == objectID select item).OrderBy(x => x.skillID).Distinct(); if (result == null) { return null; } returnObject = new List<CraftingRecipe>(); foreach (Recipe item in result.ToList()) { returnObject.Add(new CraftingRecipe(item.recipeID)); } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method RecipesGetAllThatUseFilter
} // method FittingsGetAllCreatedByTradeskillID public static List<BlueprintBase> BlueprintsGetAllCreatedByTradeskillID(long objectID) { string cacheKey = "AllBlueprintsCreatedByTradeskillID_" + objectID; List<BlueprintBase> returnObject = HttpContext.Current.Cache[cacheKey] as List<BlueprintBase>; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Structures join recipeResults in myEntities.Recipe_Results on item.structureID equals recipeResults.resultID join recipesinSkill in myEntities.Recipes on recipeResults.recipeID equals recipesinSkill.recipeID where recipeResults.type == (long)ItemTypeEnum.Blueprint && recipesinSkill.skillID == objectID select item).Distinct().OrderBy(x => x.displayName); if (result == null) { return null; } returnObject = new List<BlueprintBase>(); foreach (Structure item in result.ToList()) { returnObject.Add(new BlueprintBase(item.structureID)); } AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method GetAllBlueprintsCreatedByTradeskillID