public HarvestOrder CreateHarvestOrder(int PlanetID, int BuildingID) { HarvestOrder[] existingOrders; HarvestOrder harvestOrder; Building building; LogEnter(); Log(LogLevels.Information, $"Checking if building is on planet (PlanetID={PlanetID}, BuildingID={BuildingID})"); building = AssertExists(() => client.GetBuilding(BuildingID), $"BuildingID=({BuildingID})"); if (building.PlanetID != PlanetID) { Log(LogLevels.Warning, $"Building is not in the same planet (BuildingID={BuildingID})"); throw new PIOInvalidOperationException($"Building is not in the same planet (BuildingID={BuildingID})", null, ID, ModuleName, "CreateHarvestOrder"); } Log(LogLevels.Information, $"Checking if order already exists (BuildingID={BuildingID})"); existingOrders = Try(() => harvestOrderModule.GetHarvestOrders(BuildingID)).OrThrow <PIOInternalErrorException>("Failed to get HarvestOrder"); if ((existingOrders != null) && (existingOrders.Length > 0)) { Log(LogLevels.Warning, $"Harvest order already exists for building (BuildingID={BuildingID})"); throw new PIOInvalidOperationException($"Harvest order already exists for building (BuildingID={BuildingID})", null, ID, ModuleName, "CreateHarvestOrder"); } Log(LogLevels.Information, $"Creating HarvestOrder"); harvestOrder = Try(() => harvestOrderModule.CreateHarvestOrder(PlanetID, BuildingID)).OrThrow <PIOInternalErrorException>("Failed to create HarvestOrder"); return(harvestOrder); }
public HarvestOrder[] GetHarvestOrders(int PlanetID) { LogEnter(); return(Try(() => harvestOrderModule.GetHarvestOrders(PlanetID)).OrThrow(GenerateFaultException)); }