public Task ExecuteCommand(MediatorSerializedObject mediatorSerializedObject)
        {
            var type = GetType(mediatorSerializedObject);

            if (type != null)
            {
                dynamic req = JsonConvert.DeserializeObject(mediatorSerializedObject.Data, type);

                return(mediator.Send(req as IRequest));
            }

            return(null);
        }
        private System.Type GetType(MediatorSerializedObject mediatorSerializedObject)
        {
            if (mediatorSerializedObject?.AssemblyName == null)
            {
                return(null);
            }

            var assemblies = GetAssemblies().ToList()
                             .Where(x => x.GetName().Name.EndsWith(mediatorSerializedObject.AssemblyName))
                             .Select(x => x.GetName().FullName)
                             .ToList();

            var type = assemblies.SelectMany(x => Assembly.Load(x)
                                             .GetTypes()
                                             .Where(t => t.FullName == mediatorSerializedObject.FullTypeName)
                                             .ToList()).First();

            return(type);
        }
Exemple #3
0
 public void ScheduleRecurring(MediatorSerializedObject mediatorSerializedObject, string name, string cronExpression, string description = null)
 {
     RecurringJob.AddOrUpdate(name, () => _commandsExecutor.ExecuteCommand(mediatorSerializedObject), cronExpression, TimeZoneInfo.Local);
 }
Exemple #4
0
        public void Schedule(MediatorSerializedObject mediatorSerializedObject, TimeSpan delay, string description = null)
        {
            var newTime = DateTime.Now + delay;

            BackgroundJob.Schedule(() => _commandsExecutor.ExecuteCommand(mediatorSerializedObject), newTime);
        }
Exemple #5
0
 public void Schedule(MediatorSerializedObject mediatorSerializedObject, DateTimeOffset scheduleAt, string description = null)
 {
     BackgroundJob.Schedule(() => _commandsExecutor.ExecuteCommand(mediatorSerializedObject), scheduleAt);
 }
Exemple #6
0
 public string Enqueue(MediatorSerializedObject mediatorSerializedObject, string parentJobId, JobContinuationOptions continuationOption, string description = null)
 {
     return(BackgroundJob.ContinueJobWith(parentJobId, () => _commandsExecutor.ExecuteCommand(mediatorSerializedObject), continuationOption));
 }
Exemple #7
0
 public string Enqueue(MediatorSerializedObject mediatorSerializedObject)
 {
     return(BackgroundJob.Enqueue(() => _commandsExecutor.ExecuteCommand(mediatorSerializedObject)));
 }
        public Task ExecuteCommand(string reuest)
        {
            MediatorSerializedObject mediatorSerializedObject = JsonConvert.DeserializeObject <MediatorSerializedObject>(reuest);

            return(ExecuteCommand(mediatorSerializedObject));
        }