예제 #1
0
        static void Main(string[] args)
        {
            logger.Info($"TaskProcessor Started...");
            var databaseName = ConfigurationManager.AppSettings["databaseName"];
            var client       = new MongoClient();
            var mongoDB      = client.GetDatabase(databaseName);

            logger.Info($"Connected to {databaseName}");

            var tasksRepo           = new ServerTasksRepository(mongoDB);
            List <ServerTask> tasks = tasksRepo.GetEntitiesByExpression(t => t.Status != ServerTask.TaskStatus.Completed).ToList();

            logger.Info($"Retrived {tasks.Count} to process");
            foreach (var task in tasks)
            {
                try
                {
                    logger.Info($"Process\n{task}");
                    ITaskProcessor processor = TaskProcessorFactory.GetTaskProcessor(task.Type, mongoDB);
                    processor.ProcessTask(task);
                }
                catch (Exception e)
                {
                    logger.Error($"{e}");
                }
            }
            logger.Info($"TaskProcessor Finished...");
        }
예제 #2
0
        private void CloseTask(ServerTask task)
        {
            var taskRepo = new ServerTasksRepository(DataBase);

            task.Status = ServerTask.TaskStatus.Completed;
            taskRepo.Update(task);
            logger.Info($"Task Completed successfully!");
        }
예제 #3
0
        public ChatService(string databaseName)
        {
            var client = new MongoClient();

            mongoDB            = client.GetDatabase(databaseName);
            MessagesRepository = new MessagesRepository(mongoDB);
            AccountRepository  = new AccountsRepository(mongoDB);
            GroupsRepository   = new GroupsRepository(mongoDB);
            TasksRepository    = new ServerTasksRepository(mongoDB);
        }