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); }
public Bot GetBotForWorker(int WorkerID) { LogEnter(); return(Try(() => botModule.GetBotForWorker(WorkerID)).OrThrow(GenerateFaultException)); }