public void Modify(ExecutionFrequency executionFrequency, int executionHours, int executionMinutes, DayOfWeek?executionDayOfWeek = null)
        {
            Validate(executionFrequency, executionHours, executionMinutes, executionDayOfWeek);

            ExecutionFrequency = executionFrequency;
            ExecutionHours     = executionHours;
            ExecutionMinutes   = executionMinutes;
            ExecutionDayOfWeek = executionDayOfWeek;
        }
        public static SchedulerSettings Insert(ExecutionFrequency executionFrequency, int executionHours, int executionMinutes, DayOfWeek?executionDayOfWeek = null)
        {
            Validate(executionFrequency, executionHours, executionMinutes, executionDayOfWeek);

            return(new SchedulerSettings
            {
                ExecutionFrequency = executionFrequency,
                ExecutionHours = executionHours,
                ExecutionMinutes = executionMinutes,
                ExecutionDayOfWeek = executionDayOfWeek
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new Command instance
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="clientExecution">The method that will be executed</param>
        /// <param name="serverExecution"></param>
        /// <param name="applyServerResult"></param>
        /// <param name="comandType">The CommandType of this Command</param>
        /// <param name="networkValueType">The type of the value that is returned by the Execution delegate, if the command doesn't returns a value, you can set this to null to limit network data transfer</param>
        /// <param name="dataTransferOptions">Defines options for network packet transmission</param>
        /// <param name="frequency">Defines the frequency at which the current command will be processed</param>
        public Command(Condition condition, ClientCommand clientExecution, ServerCommand serverExecution,
                         ApplyServerCommand applyServerResult, CommandType comandType, Type networkValueType,
                         DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
        {
            if (networkValueType != null && !networkValueType.IsValueType && networkValueType != typeof(string) && networkValueType != typeof(byte[]))
                throw new CoreException("DataType must be a ValueType.");

            LocalId = _count++;
            Condition = condition;
            ClientExecution = clientExecution;
            ServerExecution = serverExecution;
            ApplyServerResult = applyServerResult;
            Type = comandType;
            NetworkValueType = networkValueType;
            TransferOptions = dataTransferOptions;
            Frequency = frequency;
        }
        private static void Validate(ExecutionFrequency executionFrequency, int executionHours, int executionMinutes, DayOfWeek?executionDayOfWeek)
        {
            if (executionFrequency == ExecutionFrequency.Weekly && executionDayOfWeek == null)
            {
                throw new Exception("ExecutionDayOfWeek cannot be null if ExecutionFrequency is ExecutionFrequency.Weekly.");
            }

            if (executionHours > 23 || executionHours < 0)
            {
                throw new Exception("Wrong value. Hours value should be from 0 to 23.");
            }

            if (executionMinutes > 59 || executionMinutes < 0)
            {
                throw new Exception("Wrong value. Minutes value should be from 0 to 59.");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new Command instance
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="clientExecution">The method that will be executed</param>
        /// <param name="serverExecution"></param>
        /// <param name="applyServerResult"></param>
        /// <param name="comandType">The CommandType of this Command</param>
        /// <param name="networkValueType">The type of the value that is returned by the Execution delegate, if the command doesn't returns a value, you can set this to null to limit network data transfer</param>
        /// <param name="dataTransferOptions">Defines options for network packet transmission</param>
        /// <param name="frequency">Defines the frequency at which the current command will be processed</param>
        public Command(Condition condition, ClientCommand clientExecution, ServerCommand serverExecution,
                       ApplyServerCommand applyServerResult, CommandType comandType, Type networkValueType,
                       DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
        {
            if (networkValueType != null && !networkValueType.IsValueType && networkValueType != typeof(string) && networkValueType != typeof(byte[]))
            {
                throw new CoreException("DataType must be a ValueType.");
            }

            LocalId           = _count++;
            Condition         = condition;
            ClientExecution   = clientExecution;
            ServerExecution   = serverExecution;
            ApplyServerResult = applyServerResult;
            Type             = comandType;
            NetworkValueType = networkValueType;
            TransferOptions  = dataTransferOptions;
            Frequency        = frequency;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Adds a Command to this behavior that will be executed solely on the client
 /// </summary>
 /// <param name="clientCommand">The delegate to the code that will be executed by the client</param>
 /// <param name="condition"></param>
 /// <param name="frequency"></param>
 protected void AddLocalCommand(Condition condition, Command.ClientCommand clientCommand, ExecutionFrequency frequency)
 {
     AddCommand(Command.CreateLocalCommand(condition, clientCommand, frequency));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Adds a Command to this behavior that will be executed solely on the server and returned to all clients in the session
 /// </summary>
 /// <param name="condition"></param>
 /// <param name="serverExecution">The delegate to the code that will be executed by the server</param>
 /// <param name="applyServerResult">The delegate to the code that will be executed by all clients in the session when server returns</param>
 /// <param name="dataType">The Type of the data exchanged between the clients and server</param>
 /// <param name="dataTransferOptions">Tells how the command orders are transfered throught the network</param>
 /// <param name="frequency"></param>
 protected void AddServerCommand(Condition condition, Command.ServerCommand serverExecution,
                              Command.ApplyServerCommand applyServerResult, Type dataType,
                              DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
 {
     AddCommand(Command.CreateServerCommand(condition, serverExecution, applyServerResult, dataType, dataTransferOptions, frequency));
 }
Exemplo n.º 8
0
 public static Command CreateLocalAndServerCommand(ClientCommand clientCommand, ServerCommand serverCommand, ApplyServerCommand applyServerResult, Type typeOfDataExchanged, DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
 {
     return CreateLocalAndServerCommand(null, clientCommand, serverCommand, applyServerResult, typeOfDataExchanged, dataTransferOptions, frequency);
 }
Exemplo n.º 9
0
 public static Command CreateServerCommand(Condition condition, ServerCommand serverCommand, ExecutionFrequency frequency)
 {
     return(new Command(condition, null, serverCommand, null, CommandType.Server, null, DataTransferOptions.None, frequency));
 }
Exemplo n.º 10
0
 public static Command CreateLocalAndServerCommand(Condition condition, ClientCommand clientCommand, ServerCommand serverCommand, Type typeOfDataExchanged, DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
 {
     return new Command(condition, clientCommand, serverCommand, null, CommandType.LocalAndServer, typeOfDataExchanged, dataTransferOptions, frequency);
 }
Exemplo n.º 11
0
 public static Command CreateLocalAndServerCommand(ClientCommand clientCommand, ServerCommand serverCommand, ApplyServerCommand applyServerResult, Type typeOfDataExchanged, DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
 {
     return(CreateLocalAndServerCommand(null, clientCommand, serverCommand, applyServerResult, typeOfDataExchanged, dataTransferOptions, frequency));
 }
Exemplo n.º 12
0
 public static Command CreateLocalCommand(Condition condition, ClientCommand clientCommand, ExecutionFrequency frequency)
 {
     return(new Command(condition, clientCommand, null, null, CommandType.Local, null, DataTransferOptions.None, frequency));
 }
Exemplo n.º 13
0
 public static Command CreateServerCommand(Condition condition, ServerCommand serverCommand, ApplyServerCommand applyServerResult, Type typeOfDataExchanged, DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
 {
     return(new Command(condition, null, serverCommand, applyServerResult, CommandType.Server, typeOfDataExchanged, dataTransferOptions, frequency));
 }
Exemplo n.º 14
0
 public static Command CreateLocalCommand(Condition condition, ClientCommand clientCommand, ExecutionFrequency frequency)
 {
     return new Command(condition, clientCommand, null, null, CommandType.Local, null, DataTransferOptions.None, frequency);
 }
Exemplo n.º 15
0
 public static Command CreateServerCommand(ServerCommand serverCommand, ExecutionFrequency frequency)
 {
     return CreateServerCommand(null, serverCommand, frequency);
 }
Exemplo n.º 16
0
 public static Command CreateServerCommand(Condition condition, ServerCommand serverCommand, ExecutionFrequency frequency)
 {
     return new Command(condition, null, serverCommand, null, CommandType.Server, null, DataTransferOptions.None, frequency);
 }
Exemplo n.º 17
0
 public static Command CreateLocalCommand(ClientCommand clientCommand, ExecutionFrequency frequency)
 {
     return CreateLocalCommand(null, clientCommand, frequency);
 }
Exemplo n.º 18
0
        public static SchedulerItem Insert(string name, string messageSubject, string messageBody, ExecutionFrequency executionFrequency, int executionHours, int executionMinutes, DayOfWeek?executionDayOfWeek = null)
        {
            Validate(name);

            var schedulerMessage  = SchedulerMessage.Insert(messageSubject, messageBody);
            var schedulerSettings = SchedulerSettings.Insert(executionFrequency, executionHours, executionMinutes, executionDayOfWeek);

            return(new SchedulerItem
            {
                Name = name,
                IsActive = false,
                IsDeleted = false,
                Settings = schedulerSettings,
                Message = schedulerMessage
            });
        }
Exemplo n.º 19
0
 /// <summary>
 /// Adds a Command to this behavior that will be executed solely on the server and returned to all clients in the session
 /// </summary>
 /// <param name="condition"></param>
 /// <param name="serverExecution">The delegate to the code that will be executed by the server</param>
 /// <param name="frequency"></param>
 protected void AddServerCommand(Condition condition, Command.ServerCommand serverExecution, ExecutionFrequency frequency)
 {
     AddCommand(Command.CreateServerCommand(condition, serverExecution, frequency));
 }
Exemplo n.º 20
0
 public static Command CreateLocalAndServerCommand(Condition condition, ClientCommand clientCommand, ServerCommand serverCommand, Type typeOfDataExchanged, DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
 {
     return(new Command(condition, clientCommand, serverCommand, null, CommandType.LocalAndServer, typeOfDataExchanged, dataTransferOptions, frequency));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Adds a Command to this behavior that will be executed solely on the server and returned to all clients in the session
 /// </summary>
 /// <param name="condition"></param>
 /// <param name="serverExecution">The delegate to the code that will be executed by the server</param>
 /// <param name="applyServerResult">The delegate to the code that will be executed by all clients in the session when server returns</param>
 /// <param name="dataType">The Type of the data exchanged between the clients and server</param>
 /// <param name="dataTransferOptions">Tells how the command orders are transfered throught the network</param>
 /// <param name="frequency"></param>
 protected void AddServerCommand(Condition condition, Command.ServerCommand serverExecution,
                                 Command.ApplyServerCommand applyServerResult, Type dataType,
                                 DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
 {
     AddCommand(Command.CreateServerCommand(condition, serverExecution, applyServerResult, dataType, dataTransferOptions, frequency));
 }
Exemplo n.º 22
0
        public override string ToString()
        {
            string lastRun = LastStarted == DateTime.MinValue ? "never" : LastStarted.ToString();

            return($"{Type} (Freq: {ExecutionFrequency.ToHumanReadableString()} Last run: {lastRun})");
        }
Exemplo n.º 23
0
 /// <summary>
 /// Adds a Command to this behavior that will be executed solely on the client
 /// </summary>
 /// <param name="clientCommand">The delegate to the code that will be executed by the client</param>
 /// <param name="condition"></param>
 /// <param name="frequency"></param>
 protected void AddLocalCommand(Condition condition, Command.ClientCommand clientCommand, ExecutionFrequency frequency)
 {
     AddCommand(Command.CreateLocalCommand(condition, clientCommand, frequency));
 }
Exemplo n.º 24
0
 public static Command CreateLocalCommand(ClientCommand clientCommand, ExecutionFrequency frequency)
 {
     return(CreateLocalCommand(null, clientCommand, frequency));
 }
Exemplo n.º 25
0
 /// <summary>
 /// Adds a Command to this behavior that will be executed solely on the server and returned to all clients in the session
 /// </summary>
 /// <param name="condition"></param>
 /// <param name="serverExecution">The delegate to the code that will be executed by the server</param>
 /// <param name="frequency"></param>
 protected void AddServerCommand(Condition condition, Command.ServerCommand serverExecution, ExecutionFrequency frequency)
 {
     AddCommand(Command.CreateServerCommand(condition, serverExecution, frequency));
 }
Exemplo n.º 26
0
 public static Command CreateServerCommand(ServerCommand serverCommand, ExecutionFrequency frequency)
 {
     return(CreateServerCommand(null, serverCommand, frequency));
 }
Exemplo n.º 27
0
 public static Command CreateServerCommand(Condition condition, ServerCommand serverCommand, ApplyServerCommand applyServerResult, Type typeOfDataExchanged, DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
 {
     return new Command(condition, null, serverCommand, applyServerResult, CommandType.Server, typeOfDataExchanged, dataTransferOptions, frequency);
 }