// Creacion de cliente // Nuevo creador de clientes public ClientData CreateClient(ClientIdType type, string id, int port, string name, string appPath, string logPath, int timeout, bool mail, bool logAttach, int queueSize) { // Validacion de parametros // Claves if (type == ClientIdType.KeyByIdString) { // Clave ID if (string.IsNullOrEmpty(id)) { throw new ArgumentException("El valor no puede ser nulo.", "id"); } if (ContainsId(id)) { throw new ArgumentException("El valor ya está registrado.", "id"); } // Si el puerto NO es clave, puede ser cero. Si es distinto de cero, debe // estar en el rango libre if (port != 0 && (port < 1024 || port > 65535)) { throw new ArgumentOutOfRangeException("port", "El valor debe estar entre 1024 y 65535."); } } else { // Clave Puerto if (port == 0) { throw new ArgumentException("El valor no puede ser cero.", "port"); } if (port < 1024 || port > 65535) { throw new ArgumentOutOfRangeException("port", "El valor debe estar entre 1024 y 65535."); } if (ContainsPort(port)) { throw new ArgumentException("El valor ya está registrado.", "port"); } } // name if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name", "El valor no puede ser nulo."); } if (ContainsName(name)) { throw new ArgumentException("El valor ya está registrado.", "name"); } // Resto de los campos // appPath if (string.IsNullOrEmpty(appPath)) { throw new ArgumentNullException("appPath", "El valor no puede ser nulo."); } // logPath if (string.IsNullOrEmpty(logPath)) { throw new ArgumentNullException("logPath", "El valor no puede ser nulo."); } // timeout if (timeout == 0) { throw new ArgumentException("El valor no puede ser cero.", "timeout"); } // queueSize if (queueSize == 0) { throw new ArgumentException("El valor no puede ser cero.", "queueSize"); } // Creacion del objeto ClientData newClt = new ClientData(); newClt.IdType = type; newClt.Id = id; newClt.Port = port; newClt.Name = name; newClt.AppFilePath = appPath; newClt.LogFilePath = logPath; newClt.Timeout = timeout; newClt.MailEnabled = mail; newClt.LogAttachEnabled = logAttach; newClt.QueueSize = queueSize; Add(newClt); return(newClt); }
public RequestSendEmail(EMessageAction action, DateTime date, ClientData client) { Action = action; Date = date; Client = client; }