Ejemplo n.º 1
0
        public void DeleteBot(int BotID)
        {
            Bot item;

            LogEnter();

            Log(LogLevels.Information, $"Trying to get bot");
            item = Try(() => botModule.GetBot(BotID)).OrThrow <PIOInternalErrorException>("Failed to get Bot");
            if (item == null)
            {
                Log(LogLevels.Warning, $"Bot doesn't exist (BotID={BotID})");
                throw new PIONotFoundException($"Bot doesn't exist (BotID={BotID})", null, ID, ModuleName, "DeleteBot");
            }

            Remove((int id) => id == BotID);

            #region clear bot assignment
            Log(LogLevels.Information, $"Clearing bot assignment (BotID={BotID})");
            Try(() => orderManager.UnassignAll(BotID)).OrThrow <PIOInternalErrorException>($"Failed to clear bot assignment");

            Log(LogLevels.Information, $"Deleting bot (BotID={BotID})");
            Try(() => botModule.DeleteBot(BotID)).OrThrow <PIOInternalErrorException>($"Failed to delete bot");

            #endregion
        }
Ejemplo n.º 2
0
 public Bot GetBot(int BotID)
 {
     LogEnter();
     return(Try(() => botModule.GetBot(BotID)).OrThrow(GenerateFaultException));
 }