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 }); }
/// <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."); } }
/// <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; }
/// <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)); }
/// <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)); }
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); }
public static Command CreateServerCommand(Condition condition, ServerCommand serverCommand, ExecutionFrequency frequency) { return(new Command(condition, null, serverCommand, null, CommandType.Server, null, DataTransferOptions.None, frequency)); }
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); }
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)); }
public static Command CreateLocalCommand(Condition condition, ClientCommand clientCommand, ExecutionFrequency frequency) { return(new Command(condition, clientCommand, null, null, CommandType.Local, null, DataTransferOptions.None, frequency)); }
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)); }
public static Command CreateLocalCommand(Condition condition, ClientCommand clientCommand, ExecutionFrequency frequency) { return new Command(condition, clientCommand, null, null, CommandType.Local, null, DataTransferOptions.None, frequency); }
public static Command CreateServerCommand(ServerCommand serverCommand, ExecutionFrequency frequency) { return CreateServerCommand(null, serverCommand, frequency); }
public static Command CreateServerCommand(Condition condition, ServerCommand serverCommand, ExecutionFrequency frequency) { return new Command(condition, null, serverCommand, null, CommandType.Server, null, DataTransferOptions.None, frequency); }
public static Command CreateLocalCommand(ClientCommand clientCommand, ExecutionFrequency frequency) { return CreateLocalCommand(null, clientCommand, frequency); }
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 }); }
/// <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)); }
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)); }
public override string ToString() { string lastRun = LastStarted == DateTime.MinValue ? "never" : LastStarted.ToString(); return($"{Type} (Freq: {ExecutionFrequency.ToHumanReadableString()} Last run: {lastRun})"); }
public static Command CreateLocalCommand(ClientCommand clientCommand, ExecutionFrequency frequency) { return(CreateLocalCommand(null, clientCommand, frequency)); }
public static Command CreateServerCommand(ServerCommand serverCommand, ExecutionFrequency frequency) { return(CreateServerCommand(null, serverCommand, frequency)); }
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); }