Ejemplo n.º 1
0
        public Bot CreateBot(int WorkerID)
        {
            Bot item;

            LogEnter();
            Log(LogLevels.Information, $"Checking if bot exists");
            item = Try(() => botModule.GetBotForWorker(WorkerID)).OrThrow <PIOInvalidOperationException>("Failed to get Bot");
            if (item != null)
            {
                Log(LogLevels.Warning, $"Bot already exists (WorkerID={WorkerID})");
                throw new PIOInvalidOperationException($"Bot already exists (WorkerID={WorkerID})", null, ID, ModuleName, "CreateBot");
            }

            Log(LogLevels.Information, $"Trying to create bot");
            item = Try(() => botModule.CreateBot(WorkerID)).OrThrow <PIOInternalErrorException>("Failed to create Bot");
            Add(DateTime.Now, item.BotID);

            return(item);
        }
Ejemplo n.º 2
0
 public Bot GetBotForWorker(int WorkerID)
 {
     LogEnter();
     return(Try(() => botModule.GetBotForWorker(WorkerID)).OrThrow(GenerateFaultException));
 }