public ProduceOrder CreateProduceOrder(int PlanetID, int BuildingID) { ProduceOrder[] existingOrders; ProduceOrder produceOrder; 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, "CreateProduceOrder"); } Log(LogLevels.Information, $"Checking if order already exists (BuildingID={BuildingID})"); existingOrders = Try(() => produceOrderModule.GetProduceOrders(BuildingID)).OrThrow <PIOInternalErrorException>("Failed to get ProduceOrder"); if ((existingOrders != null) && (existingOrders.Length > 0)) { Log(LogLevels.Warning, $"Produce order already exists for building (BuildingID={BuildingID})"); throw new PIOInvalidOperationException($"Produce order already exists for building (BuildingID={BuildingID})", null, ID, ModuleName, "CreateProduceOrder"); } Log(LogLevels.Information, $"Creating ProduceOrder"); produceOrder = Try(() => produceOrderModule.CreateProduceOrder(PlanetID, BuildingID)).OrThrow <PIOInternalErrorException>("Failed to create ProduceOrder"); return(produceOrder); }
public ProduceOrder[] GetProduceOrders(int PlanetID) { LogEnter(); return(Try(() => produceOrderModule.GetProduceOrders(PlanetID)).OrThrow(GenerateFaultException)); }