private static string GetTransmissionName(TransmissionEvent transmissionEvent)
        {
            if (transmissionEvent is ImmediatelyTransmissionEvent)
            {
                return((string)Application.Current.Resources["Immediately"]);
            }
            if (transmissionEvent is DateTimeTransmissionEvent)
            {
                return((string)Application.Current.Resources["DateAndTime"] +
                       $" ({((DateTimeTransmissionEvent) transmissionEvent).DateTime.ToLocalTime()})");
            }
            if (transmissionEvent is OnJoinTransmissionEvent)
            {
                return((string)Application.Current.Resources["OnJoin"]);
            }
            if (transmissionEvent is RepeatingTransmissionEvent)
            {
                return((string)Application.Current.Resources["Repeating"] +
                       $" ({((int) ((RepeatingTransmissionEvent) transmissionEvent).TimeSpan.TotalHours):00}:{((RepeatingTransmissionEvent) transmissionEvent).TimeSpan.Minutes:00}:{((RepeatingTransmissionEvent) transmissionEvent).TimeSpan.Seconds:00})");
            }
            if (transmissionEvent is EveryClientOnceTransmissionEvent)
            {
                return((string)Application.Current.Resources["EveryClientOnce"]);
            }

            return(null);
        }
Ejemplo n.º 2
0
        public async Task <bool> ExecuteCommand(StaticCommand staticCommand, TransmissionEvent transmissionEvent,
                                                ExecutionEvent executionEvent, StopEvent stopEvent, List <Condition> conditions, CommandTarget target)
        {
            if (conditions != null && conditions.Count == 0)
            {
                conditions = null;
            }

            var plugin = StaticCommands[staticCommand.GetType()];

            if (plugin != null)
            {
                if (!await UploadPluginToServer(plugin))
                {
                    return(false);
                }
            }

            _connectionManager.SendCommand(new DynamicCommand
            {
                CommandId         = staticCommand.CommandId,
                Target            = target,
                Conditions        = conditions,
                TransmissionEvent = transmissionEvent,
                ExecutionEvent    = executionEvent,
                CommandParameter  = staticCommand.GetCommandParameter().Data,
                PluginHash        = plugin?.PluginHash,
                StopEvent         = stopEvent
            });

            return(true);
        }
Ejemplo n.º 3
0
        public void OkButtonClick(CommandTarget commandTarget, TransmissionEvent transmissionEvent,
                                  ExecutionEvent executionEvent, StopEvent stopEvent)
        {
            CommandTarget     = commandTarget;
            TransmissionEvent = transmissionEvent;
            ExecutionEvent    = executionEvent;
            StopEvent         = stopEvent;

            DialogResult = true;
        }
Ejemplo n.º 4
0
        public void ExecuteCommand(StaticCommand staticCommand, TransmissionEvent transmissionEvent, ExecutionEvent executionEvent,
                                   List <Condition> conditions, CommandTarget target)
        {
            if (conditions != null && conditions.Count == 0)
            {
                conditions = null;
            }

            _serverConnection.SendCommand(new DynamicCommand
            {
                CommandId         = staticCommand.CommandId,
                Target            = target,
                Conditions        = conditions,
                TransmissionEvent = transmissionEvent,
                ExecutionEvent    = executionEvent,
                CommandParameter  = staticCommand.GetCommandParameter().Data,
                PluginHash        = null
            });
        }
Ejemplo n.º 5
0
        private DateTime GetNextTime(TransmissionEvent transmissionEvent)
        {
            var dateTimeEvent = transmissionEvent as DateTimeTransmissionEvent;

            if (dateTimeEvent != null)
            {
                return(dateTimeEvent.DateTime);
            }

            var repeatingEvent = transmissionEvent as RepeatingTransmissionEvent;

            if (repeatingEvent != null)
            {
                return
                    (repeatingEvent.DayZero.AddMilliseconds(repeatingEvent.TimeSpan.TotalMilliseconds *
                                                            Math.Ceiling(
                                                                (DateTime.UtcNow - repeatingEvent.DayZero).TotalMilliseconds /
                                                                repeatingEvent.TimeSpan.TotalMilliseconds)));
            }

            throw new InvalidOperationException(nameof(transmissionEvent));
        }
Ejemplo n.º 6
0
 public Task <bool> ExecuteCommand(StaticCommand staticCommand, TransmissionEvent transmissionEvent, ExecutionEvent executionEvent,
                                   StopEvent stopEvent, List <Condition> conditions, CommandTarget target)
 {
     return(Task.FromResult(true));
 }