/// <summary> /// Create an instance of the OCPI HTTP API for Charge Point Operators /// using a newly created HTTP server. /// </summary> public CPOAPI(RoamingNetwork RoamingNetwork, String HTTPServerName = DefaultHTTPServerName, IPPort HTTPServerPort = null, String URIPrefix = "", String ServiceName = DefaultHTTPServerName, EMailAddress APIEMailAddress = null, PgpSecretKeyRing APISecretKeyRing = null, String APIPassphrase = null, EMailAddressList APIAdminEMail = null, SMTPClient APISMTPClient = null, DNSClient DNSClient = null, String LogfileName = DefaultLogfileName) : base(RoamingNetwork, HTTPServerName, HTTPServerPort != null ? HTTPServerPort : DefaultHTTPServerPort, URIPrefix, ResourceName => typeof(CPOAPI).Assembly.GetManifestResourceStream("org.GraphDefined.WWCP.OCPIv2_1.HTTPAPI.CPOAPI.HTTPRoot." + ResourceName), ServiceName, APIEMailAddress, null,//OpenPGP.ReadPublicKeyRing(typeof(CPOAPI).Assembly.GetManifestResourceStream("org.GraphDefined.WWCP.OCPIv2_1.HTTPAPI.GenericAPI.HTTPRoot.robot@offenes-jena_pubring.gpg")), APISecretKeyRing, APIPassphrase, APIAdminEMail, APISMTPClient, DNSClient, LogfileName) { RegisterCPOURITemplates(); }
public async Task <IActionResult> Edit(int id, [Bind("ID,PersonID,Address")] EMailAddress eMailAddress) { if (id != eMailAddress.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(eMailAddress); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EMailAddressExists(eMailAddress.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PersonID"] = new SelectList(_context.People, "ID", "ID", eMailAddress.PersonID); return(View(eMailAddress)); }
private EMailAddress ParseEmailAddress(string emailAddressTag) { EMailAddress result = null; string[] parts = new string[2]; if (EMailAddress.ValidateAddress(emailAddressTag)) { parts[0] = emailAddressTag; parts[1] = string.Empty; } else { Regex regEx = new Regex(@"<.*>$"); Match match = regEx.Match(emailAddressTag); if (match.Success) { parts[0] = match.Value; parts[0] = parts[0].Substring(1, parts[0].Length - 2); parts[1] = emailAddressTag.Remove(match.Index).Trim(); } else { parts[0] = parts[1] = emailAddressTag; } } result = new EMailAddress(parts[0], parts[1]); return(result); }
public void MailFail5() { string adresse = "*****@*****.**"; EMailAddress adress = new EMailAddress(adresse); Assert.IsFalse(adress.verifyEmailAddress(adresse)); }
public void MailFail2() { string adresse = "[email protected]@gmail.net"; EMailAddress adress = new EMailAddress(adresse); Assert.IsFalse(adress.verifyEmailAddress(adresse)); }
public void MailGood1() { string adresse = "*****@*****.**"; EMailAddress adress = new EMailAddress(adresse); Assert.IsTrue(adress.verifyEmailAddress(adresse)); }
public void MailFail1() { string adresse = "[email protected]@.gmail.com"; EMailAddress adress = new EMailAddress(adresse); Assert.IsFalse(adress.verifyEmailAddress(adresse)); }
public void MailFail4() { string adresse = "[email protected]"; EMailAddress adress = new EMailAddress(adresse); Assert.IsFalse(adress.verifyEmailAddress(adresse)); }
public void MailFail12() { string adresse = "manuel.krammer@"; EMailAddress adress = new EMailAddress(adresse); Assert.IsFalse(adress.verifyEmailAddress(adresse)); }
public void MailFail6() { string adresse = "[email protected]."; EMailAddress adress = new EMailAddress(adresse); Assert.IsFalse(adress.verifyEmailAddress(adresse)); }
public void MailFail8() { string adresse = null; EMailAddress adress = new EMailAddress(adresse); Assert.IsFalse(adress.verifyEmailAddress(adresse)); }
public override JObject ToJSON(Boolean Embedded = false) => JSONObject.Create( !Embedded ? new JProperty("@context", JSONLDContext.ToString()) : null, new JProperty("email", EMailAddress.ToJSON(Embedded: true)), Subject.IsNotNullOrEmpty() ? new JProperty("subject", Subject) : null, SubjectPrefix.IsNotNullOrEmpty() ? new JProperty("subjectPrefix", SubjectPrefix) : null, ListId.IsNotNullOrEmpty() ? new JProperty("listId", ListId) : null, NotificationMessageTypes.SafeAny() ? new JProperty("messageTypes", new JArray(NotificationMessageTypes.Select(msgType => msgType.ToString()))) : null, Description.IsNotNullOrEmpty() ? new JProperty("description", Description) : null );
public void MailFail7() { string adresse = "*****@*****.**"; EMailAddress adress = new EMailAddress(adresse); Assert.IsFalse(adress.verifyEmailAddress(adresse)); }
/// <summary> /// Initialize the OCPI HTTP server using IPAddress.Any, http port 8080 and maybe start the server. /// </summary> internal GenericAPI(RoamingNetwork RoamingNetwork, HTTPServer HTTPServer, String URIPrefix = "/ext/OCPI", Func <String, Stream> GetRessources = null, String ServiceName = DefaultHTTPServerName, EMailAddress APIEMailAddress = null, PgpPublicKeyRing APIPublicKeyRing = null, PgpSecretKeyRing APISecretKeyRing = null, String APIPassphrase = null, EMailAddressList APIAdminEMail = null, SMTPClient APISMTPClient = null, String LogfileName = DefaultLogfileName) { #region Initial checks if (RoamingNetwork == null) { throw new ArgumentNullException("RoamingNetwork", "The given parameter must not be null!"); } if (HTTPServer == null) { throw new ArgumentNullException("HTTPServer", "The given parameter must not be null!"); } if (URIPrefix.IsNullOrEmpty()) { throw new ArgumentNullException("URIPrefix", "The given parameter must not be null or empty!"); } if (!URIPrefix.StartsWith("/")) { URIPrefix = "/" + URIPrefix; } #endregion #region Init data this._HTTPServer = HTTPServer; this._GetRessources = GetRessources; this._URIPrefix = URIPrefix; this._ServiceName = ServiceName; this._APIEMailAddress = APIEMailAddress; this._APIPublicKeyRing = APIPublicKeyRing; this._APISecretKeyRing = APISecretKeyRing; this._APIPassphrase = APIPassphrase; this._APIAdminEMail = APIAdminEMail; this._APISMTPClient = APISMTPClient; this._DNSClient = HTTPServer.DNSClient; #endregion RegisterURITemplates(); }
internal GenericAPI(RoamingNetwork RoamingNetwork, String HTTPServerName = DefaultHTTPServerName, IPPort HTTPServerPort = null, String URIPrefix = "", Func <String, Stream> GetRessources = null, String ServiceName = DefaultHTTPServerName, EMailAddress APIEMailAddress = null, PgpPublicKeyRing APIPublicKeyRing = null, PgpSecretKeyRing APISecretKeyRing = null, String APIPassphrase = null, EMailAddressList APIAdminEMail = null, SMTPClient APISMTPClient = null, DNSClient DNSClient = null, String LogfileName = DefaultLogfileName) : this(RoamingNetwork, new HTTPServer(DefaultServerName : DefaultHTTPServerName).AttachTCPPorts(HTTPServerPort != null ? HTTPServerPort : DefaultHTTPServerPort), URIPrefix, GetRessources, ServiceName, APIEMailAddress, APIPublicKeyRing, APISecretKeyRing, APIPassphrase, APIAdminEMail, APISMTPClient, LogfileName) { }
public void MailFail3() { string adresse = "*****@*****.**"; EMailAddress adress = new EMailAddress(adresse); Assert.IsFalse(adress.verifyEmailAddress(adresse)); }
public void MailGood0() { string adresse = "*****@*****.**"; EMailAddress adress = new EMailAddress(adresse); Assert.IsTrue(adress.verifyEmailAddress(adresse)); }
private static EMailAddress CreateAddress(string address) { MailAddress test = new MailAddress(address); EMailAddress result = new EMailAddress(); result.Address = address; return(result); }
public static EMail CreateForAssociate(int emailId, EMailAddress emailAddress, bool isPrimary, int associateId) { return(new EMail { Id = emailId, EMailAddress = emailAddress, IsPrimary = isPrimary, AssociateId = associateId }); }
public Boolean OptionalEquals(EMailNotification other) => EMailAddress.Equals(other.EMailAddress) && String.Equals(Subject, other.Subject) && String.Equals(SubjectPrefix, other.SubjectPrefix) && String.Equals(ListId, other.ListId) && String.Equals(Description, other.Description) && _NotificationMessageTypes.SetEquals(other._NotificationMessageTypes);
// TO DO: Do we need both user id and contact id? public static EMail CreateForContact(int emailId, EMailAddress emailAddress, bool isPrimary, int contactId) { return(new EMail { Id = emailId, EMailAddress = emailAddress, IsPrimary = isPrimary, ContactId = contactId }); }
public async Task <IActionResult> Create([Bind("ID,PersonID,Address")] EMailAddress eMailAddress) { if (ModelState.IsValid) { _context.Add(eMailAddress); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PersonID"] = new SelectList(_context.People, "ID", "ID", eMailAddress.PersonID); return(View(eMailAddress)); }
private static EMailMessage CreateMessage(EMailAddress from, EMailAddress recipient, string subject, string message) { EMailMessage result = new EMailMessage(); result.Subject = subject; result.From = from; result.To = new EMailAddress[1]; result.To[0] = recipient; result.Body = new EMailBodyAlternateView(); result.Body.ContentStream = message; return(result); }
private EMailRM CreateEMailForAssociate(Commands.V1.Associate.EMail.CreateForAssociate cmd) { EMail email = EMail.CreateForAssociate(_emails++, EMailAddress.Create(cmd.EMailAddress), cmd.IsPrimary, cmd.AssociateId); if (_repository.EMailExistsForAssociate(email, cmd.AssociateId)) { throw new InvalidOperationException($"EMail already exists for Associate {cmd.AssociateId}"); } _repository.AddEMailForAssociate(email, cmd.AssociateId); return(Conversions.GetEMailRM(email)); }
private void SetUpEMail() { EMailAddress newSender = new EMailAddress(accountId); message.Subject = string.Concat(GetNewSubject(), XEMailMessagesHandler.GetUTF8DecodedText(this.message.Subject)); message.Body.ContentStream = string.Concat(GetBodyHeader(), XEMailMessagesHandler.GetTextOnlyBodyView(message)); if (action != MessageActions.Forward && action != MessageActions.Compose) { message.Attachments = new EMailAttachment[0]; List <EMailAddress> recipients = new List <EMailAddress>(); if (message.ReplyTo.Address == "@") { recipients.Add(message.From); } else { recipients.Add(message.ReplyTo); } if (action == MessageActions.ReplyAll) { foreach (EMailAddress recipient in message.To) { if (recipient.Address == accountId) { continue; } recipients.Add(recipient); } foreach (EMailAddress recipient in message.CC) { if (recipient.Address == accountId) { continue; } recipients.Add(recipient); } } message.To = recipients.ToArray(); } else { message.To = new EMailAddress[0]; } message.From = newSender; }
public static Task AddEMailNotification(this UsersAPI UsersAPI, User User, IEnumerable <NotificationMessageType> NotificationMessageTypes, EMailAddress EMailAddress = null, String Subject = null, String SubjectPrefix = null, EventTracking_Id EventTrackingId = null, User_Id?CurrentUserId = null) => UsersAPI.AddNotification(User, new EMailNotification(EMailAddress ?? User.EMail, Subject, SubjectPrefix), NotificationMessageTypes, EventTrackingId, CurrentUserId);
private EMailAddress[] ParseEmailAddressTag(string emailHeaderTag) { EMailAddress[] result; char[] sepatators = ",;".ToCharArray(); string[] emails = emailHeaderTag.Split(sepatators); ArrayList list = new ArrayList(); foreach (string emailTag in emails) { EMailAddress address = ParseEmailAddress(emailTag.Trim()); if (address.DisplayName != null && address.Host != null) { list.Add(address); } } result = new EMailAddress[list.Count]; list.CopyTo(result); return(result); }
/// <summary> /// Create a new e-mail notification. /// </summary> /// <param name="EMailAddress">The e-mail address of the receiver of this notification.</param> /// <param name="Subject">An optional customer-specific subject of all e-mails to send.</param> /// <param name="SubjectPrefix">An optional prefix added to the standard subject of all e-mails to send.</param> /// <param name="ListId">An optional 'List-Id" e-mail header within all e-mails to send.</param> /// <param name="NotificationMessageTypes">An optional enumeration of notification message types.</param> /// <param name="Description">Some description to remember why this notification was created.</param> public EMailNotification(EMailAddress EMailAddress, String Subject = null, String SubjectPrefix = null, String ListId = null, IEnumerable <NotificationMessageType> NotificationMessageTypes = null, String Description = null) : base(NotificationMessageTypes, Description, String.Concat(nameof(EMailNotification), EMailAddress, Subject, SubjectPrefix, ListId)) { this.EMailAddress = EMailAddress; this.Subject = Subject; this.SubjectPrefix = SubjectPrefix; this.ListId = ListId; }
public string GetEMailAddressTag(EMailAddress Address) { string result = string.Empty; if (string.IsNullOrEmpty(Address.DisplayName) && !string.IsNullOrEmpty(Address.Address)) { result = Address.Address; } else { if (string.IsNullOrEmpty(Address.Address)) { result = Address.DisplayName; } else { result = string.Format("{0} <{1}>", Address.DisplayName, Address.Address); } } return(result); }
public static Boolean TryParse(JObject JSON, out EMailNotification Notification) { if (JSON["@context"]?.Value <String>() == JSONLDContext && JSON["email"] is JObject EMailJSON && EMailAddress.TryParseJSON(EMailJSON, out EMailAddress EMail, out String ErrorResponse, true)) { Notification = new EMailNotification(EMail, JSON["subject"]?.Value <String>(), JSON["subjectPrefix"]?.Value <String>(), JSON["listId"]?.Value <String>(), (JSON["messageTypes"] as JArray)?.SafeSelect(element => NotificationMessageType.Parse(element.Value <String>())), JSON["description"]?.Value <String>()); return(true); } Notification = null; return(false); }