/// <summary> /// 清除icons /// </summary> /// <param name="messageAddress"></param> private void ResetIocn(MessageAddress messageAddress) { Transform jt = trans_c_icon_jpg; int iconCountsJ = jt.childCount; if (iconCountsJ > 0) { for (int i = 0; i < iconCountsJ; i++) { Destroy(jt.GetChild(i).gameObject); } } Transform gt = trans_c_icon_gif; //gif数量 for (int i = 0; i < 3; i++) { int gtCount = gt.GetChild(i).childCount; Transform gificon = gt.GetChild(i); for (int j = 0; j < gtCount; j++) { Destroy(gificon.GetChild(j).gameObject); } } }
public static MessageAddress ParseAddress(String address) { MessageAddress lAddress = new MessageAddress(); lAddress.FromString(address); return(lAddress); }
public IHttpActionResult InsertGUID(ForgotPasswordAppTokenAddRequest model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ItemResponse <string> response = new ItemResponse <string> { Item = _appTokenService.InsertGUID(model) }; if (response.Item != null) { Email eml = new Email(); MessageAddress msgAdd = new MessageAddress { Email = model.Email //,Name = model.Email }; List <MessageAddress> list = new List <MessageAddress> { msgAdd }; eml.To = list; eml.FromAddress = "*****@*****.**"; eml.FromName = "Eleveight"; eml.Subject = "Reset your password"; eml.HtmlBody = _emailTemplateService.CreateForgotPassword(new EmailTemplateInput { Name = msgAdd.Name, Token = response.Item }); _emailMessenger.SendMail(eml); } return(Ok(response)); } catch (Exception ex) { int currentUser = _userService.GetCurrentUserId(); _appLogService.Insert(new AppLogAddRequest { AppLogTypeId = 1, Message = ex.Message, StackTrace = ex.StackTrace, Title = "Error in " + GetType().Name + " " + System.Reflection.MethodBase.GetCurrentMethod().Name, UserBaseId = currentUser }); return(BadRequest(ex.Message)); } }
public MessageAddress Add(String address) { MessageAddress item = new MessageAddress(); item.FromString(address); fData.Add(item); return(item); }
public virtual MessageAddress GetAddress(string addressName) { var config = MessagingConfig.CurrentMessageQueues; var queueConfig = config.Queues.SingleOrDefault(x => x.Name == addressName); var queueAddress = queueConfig?.Address ?? addressName; var messageAddress = new MessageAddress(queueAddress); return(messageAddress); }
public MessageAddress Add(String name, String address) { MessageAddress item = new MessageAddress(); item.Name = name; item.Address = address; fData.Add(item); return(item); }
public static MessageAddresses ParseAddresses(ISequence <String> addresses) { MessageAddresses lAddresses = new MessageAddresses(); foreach (String address in addresses) { lAddresses.Add(MessageAddress.ParseAddress(address)); } return(lAddresses); }
public void MailboxInfo_MessageInfoTests() { MailboxInfo oInfo = null; try { oInfo = new MailboxInfo(_connectionServer, _tempUser.ObjectId); } catch (Exception ex) { Assert.Fail("Failed creating new MailboxInfo object:" + ex); } Console.WriteLine(oInfo.DumpAllProps()); Console.WriteLine(oInfo.ToString()); int iInboxCount, iDeletedCount, iSentCount; //check counts WebCallResult res = oInfo.GetFolderMessageCounts(out iInboxCount, out iDeletedCount, out iSentCount); Assert.IsTrue(res.Success, "Failed to fetch message folder counts off empty mailbox:" + res); Assert.IsTrue(iInboxCount == 0, "New mailbox reporting more than 0 inbox messages"); Assert.IsTrue(oInfo.CurrentSizeInBytes == 0, "Newly created mailbox reporting non empty mailbox"); Assert.IsTrue(oInfo.IsMailboxMounted, "Newly created mailbox reporting it's not mounted"); Assert.IsTrue(oInfo.IsPrimary, "Newly created mailbox is not reproting itself as primary"); Assert.IsFalse(oInfo.IsReceiveQuotaExceeded, "Newly created mailbox is reporting over quota"); //leave message MessageAddress oRecipient = new MessageAddress(); oRecipient.AddressType = MessageAddressType.TO; oRecipient.SmtpAddress = _tempUser.SmtpAddress; res = UserMessage.CreateMessageLocalWav(_connectionServer, _tempUser.ObjectId, "test subject", "dummy.wav", false, SensitivityType.Normal , false, false, false, false, new CallerId { CallerNumber = "1234" }, true, oRecipient); Assert.IsTrue(res.Success, "Failed to create new message from WAV file:" + res); //wait for message to be delivered Thread.Sleep(10000); //refetch mailbox info res = oInfo.RefetchMailboxData(); Assert.IsTrue(res.Success, "Failed to refetch mailbox data:" + res); //recheck counts res = oInfo.GetFolderMessageCounts(out iInboxCount, out iDeletedCount, out iSentCount); Assert.IsTrue(res.Success, "Failed to fetch message folder counts off mailbox with one message:" + res); Assert.IsTrue(iInboxCount == 1, "Mailbox reporting with single message not reporting correct inbox count:" + iInboxCount); }
public IHttpActionResult Post(ContactUsAddRequest model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); Email eml = new Email(); MessageAddress msgAdd = new MessageAddress { Email = AppSettingDictionary.Instance.appSettings["gmailAccount"], Name = model.FirstName }; List <MessageAddress> list = new List <MessageAddress> { msgAdd }; string subject = ""; if (model.SubjectId == "0") { subject = "Student"; } else if (model.SubjectId == "1") { subject = "School"; } else { subject = "Other"; } eml.To = list; eml.FromAddress = model.Email; eml.FromName = model.FirstName + " " + model.LastName; eml.Subject = subject; eml.PlainTextBody = model.Message; _emailMessenger.SendMail(eml); return(Ok(response)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public bool Equals(ProtocolInformation other) { if (ReferenceEquals(this, other)) { return(true); } // Check if other is a null reference by using ReferenceEquals because // we overload the == operator. If other isn't actually null then // we get an infinite loop where we're constantly trying to compare to null. return(!ReferenceEquals(other, null) && Version.Equals(other.Version) && MessageAddress.Equals(other.MessageAddress)); }
public void CreateMessageLocalWav_EmptySubject_Failure() { MessageAddress oRecipient = new MessageAddress(); oRecipient.AddressType = MessageAddressType.BCC; MessageAddress oRecipient2 = new MessageAddress(); oRecipient2.AddressType = MessageAddressType.TO; MessageAddress oRecipient3 = new MessageAddress(); oRecipient3.AddressType = MessageAddressType.CC; var res = UserMessage.CreateMessageLocalWav(_mockServer, "userobjectID", "", "dummy.wav", false, SensitivityType.Normal, false, false, false, false, null, false, oRecipient, oRecipient2, oRecipient3); Assert.IsFalse(res.Success, "Call to CreateMessageLocalWav with empty subject did not fail."); }
public void CreateMessageLocalWav_InvalidWavPath_Failure() { MessageAddress oRecipient = new MessageAddress(); oRecipient.AddressType = MessageAddressType.BCC; MessageAddress oRecipient2 = new MessageAddress(); oRecipient2.AddressType = MessageAddressType.TO; MessageAddress oRecipient3 = new MessageAddress(); oRecipient3.AddressType = MessageAddressType.CC; var res = UserMessage.CreateMessageLocalWav(_mockServer, "userobjectID", "subject", "bogus.wav", false, SensitivityType.Normal, false, false, false, false, null, false, oRecipient, oRecipient2, oRecipient3); Assert.IsFalse(res.Success, "Call to CreateMessageLocalWav with invalid WAV path did not fail."); }
public void CreateMessageResourceId_InvalidResourceId_Failure() { MessageAddress oRecipient = new MessageAddress(); oRecipient.AddressType = MessageAddressType.BCC; MessageAddress oRecipient2 = new MessageAddress(); oRecipient2.AddressType = MessageAddressType.TO; MessageAddress oRecipient3 = new MessageAddress(); oRecipient3.AddressType = MessageAddressType.CC; var res = UserMessage.CreateMessageResourceId(_connectionServer, "userobjectId", "subject", "resourceId", true, SensitivityType.Private, true, true, true, true, new CallerId(), oRecipient, oRecipient2, oRecipient3); Assert.IsFalse(res.Success, "Call to CreateMessageResourceId with invalid resourceId did not fail."); }
public void CreateMessageLocalWav_InvalidObjectIds_Failure() { MessageAddress oRecipient = new MessageAddress(); oRecipient.AddressType = MessageAddressType.BCC; MessageAddress oRecipient2 = new MessageAddress(); oRecipient2.AddressType = MessageAddressType.TO; MessageAddress oRecipient3 = new MessageAddress(); oRecipient3.AddressType = MessageAddressType.CC; var res = UserMessage.CreateMessageLocalWav(_connectionServer, "userobjectID", "subject", "dummy.wav", false, SensitivityType.Normal, false, false, false, false, null, true, oRecipient, oRecipient2, oRecipient3); Assert.IsFalse(res.Success, "Call to CreateMessageLocalWav with invalid UserObjectId did not fail."); }
public void CreateMessageLocalWav_NullConnectionServer_Failure() { MessageAddress oRecipient = new MessageAddress(); oRecipient.AddressType = MessageAddressType.BCC; MessageAddress oRecipient2 = new MessageAddress(); oRecipient2.AddressType = MessageAddressType.TO; MessageAddress oRecipient3 = new MessageAddress(); oRecipient3.AddressType = MessageAddressType.CC; WebCallResult res = UserMessage.CreateMessageLocalWav(null, "userobjectID", "subject", "dummy.wav", false, SensitivityType.Normal, false, false, false, false, null, false, oRecipient, oRecipient2, oRecipient3); Assert.IsFalse(res.Success, "Call to CreateMessageLocalWav with null ConnectionServerRest did not fail."); }
public void CreateMessageResourceId_EmptyRecipientsList_Failure() { MessageAddress oRecipient = new MessageAddress(); oRecipient.AddressType = MessageAddressType.BCC; MessageAddress oRecipient2 = new MessageAddress(); oRecipient2.AddressType = MessageAddressType.TO; MessageAddress oRecipient3 = new MessageAddress(); oRecipient3.AddressType = MessageAddressType.CC; var res = UserMessage.CreateMessageResourceId(_mockServer, "userobjectId", "subject", "resourceId", false, SensitivityType.Normal, false, false, false, false, null); Assert.IsFalse(res.Success, "Call to CreateMessageResourceId with empty recipients list did not fail."); }
private async void OnLoad(MessageAddress item) { if (item.Message != null && item.User != null && item.Message.User != null && item.Message.User != GuiEnvironment.User && item.User == GuiEnvironment.User) { if (item.UpdateState == DBUpdateState.Default && item.DateRead == null)// && (md == null || !md.Visible)) { item.DateRead = DateTime.Now; await item.Save(GuiEnvironment.User); if (GuiService.Main != null) { GuiService.Main.SetStatus(new StateInfo("Messanger", "New Message from " + item.Message.User.ToString(), item.Message.Data as string, StatusType.Information, item)); } ShowDialog(item.Message.User); } } }
public void CreateMessageResourceId_NullConnectionServer_Failure() { MessageAddress oRecipient = new MessageAddress(); oRecipient.AddressType = MessageAddressType.BCC; MessageAddress oRecipient2 = new MessageAddress(); oRecipient2.AddressType = MessageAddressType.TO; MessageAddress oRecipient3 = new MessageAddress(); oRecipient3.AddressType = MessageAddressType.CC; var res = UserMessage.CreateMessageResourceId(null, "userobjectId", "subject", "resourceId", false, SensitivityType.Normal, false, false, false, false, null, oRecipient, oRecipient2, oRecipient3); Assert.IsFalse(res.Success, "Call to CreateMessageResourceId with null ConnectionServerRest did not fail."); }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode() { // As obtained from the Jon Skeet answer to: // http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode // And adapted towards the Modified Bernstein (shown here: http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx) // // Overflow is fine, just wrap unchecked { // Pick a random prime number int hash = 17; // Mash the hash together with yet another random prime number hash = (hash * 23) ^ Version.GetHashCode(); hash = (hash * 23) ^ MessageAddress.GetHashCode(); return(hash); } }
public void UserMessage_Test() { MessageAddress oRecipient = new MessageAddress(); oRecipient.AddressType = MessageAddressType.TO; oRecipient.SmtpAddress = _tempUser.SmtpAddress; var res = UserMessage.CreateMessageLocalWav(_connectionServer, _tempUser.ObjectId, "test", "Dummy.wav", false, SensitivityType.Normal, false, false, false, false, null, true, oRecipient); Assert.IsTrue(res.Success, "Failed leaving test message"); Thread.Sleep(1000); _errorString = ""; List <UserMessage> oMessages; res = UserMessage.GetMessages(_connectionServer, _tempUser.ObjectId, out oMessages, 1, 2); Assert.IsTrue(res.Success, "Failed to fetch UserBase:" + res); Assert.IsTrue(string.IsNullOrEmpty(_errorString), _errorString); }
public IHttpActionResult Post(OrgMemRegAddRequest model) { string temppw = Membership.GeneratePassword(8, 1); temppw = Regex.Replace(temppw, @"[^a-zA-Z0-9]", m => "9"); model.TemporaryPassword = temppw; model.UserBaseId = _userService.GetCurrentUserId(); //setting model.UserBaseId with the current LoggedinUserBase from this function System.Diagnostics.Debug.WriteLine(model); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ItemResponse <string> response = new ItemResponse <string> { Item = _orgMemRegService.Insert(model) }; if (response.Item != "") //if there is a GUID,execute this { Email eml = new Email(); MessageAddress msgAdd = new MessageAddress { Email = model.Email, Name = model.FirstName }; List <MessageAddress> list = new List <MessageAddress> { msgAdd }; eml.To = list; eml.FromAddress = "*****@*****.**"; eml.FromName = "Eleveight"; eml.Subject = "Confirm your account..."; eml.HtmlBody = _emailTemplateService.CreateConfirmEmail(new EmailTemplateInput { Name = msgAdd.Name, Token = response.Item, ExtraInfo = "Here is your temporary password: "******"<br>Please login and change the password.</br>" }); _emailMessenger.SendMail(eml); } return(Ok(response)); } catch (Exception ex) { int currentUser = _userService.GetCurrentUserId(); _appLogService.Insert(new AppLogAddRequest { AppLogTypeId = 1, Message = ex.Message, StackTrace = ex.StackTrace, Title = "Error in " + GetType().Name + " " + System.Reflection.MethodBase.GetCurrentMethod().Name, UserBaseId = currentUser }); return(BadRequest(ex.Message)); } }
public void UserMessageTests() { List <UserMessage> oMessages; WebCallResult res = UserMessage.GetMessages(_connectionServer, _tempUser.ObjectId, out oMessages, 1, 2); Assert.IsTrue(res.Success, "Failed fetching messages on new user:"******"Test user account is reporting more than 0 messages"); //create a new message MessageAddress oRecipient = new MessageAddress(); oRecipient.AddressType = MessageAddressType.TO; oRecipient.SmtpAddress = _tempUser.SmtpAddress; res = UserMessage.CreateMessageLocalWav(_connectionServer, _tempUser.ObjectId, "test subject", "dummy.wav", false, SensitivityType.Normal, false, false, false, false, new CallerId { CallerNumber = "1234" }, true, oRecipient); Assert.IsTrue(res.Success, "Failed to create new message from WAV file:" + res); UserMessage oMessage = new UserMessage(_connectionServer, _tempUser.ObjectId); Console.WriteLine(oMessage.ToString()); Console.WriteLine(oMessage.DumpAllProps()); res = UserMessage.GetMessages(_connectionServer, _tempUser.ObjectId, out oMessages, 1, 10, MessageSortOrder.OLDEST_FIRST, MessageFilter.None, MailboxFolder.deletedItems); Assert.IsTrue(res.Success, "Failed fetching deleted messages on new user"); res = UserMessage.GetMessages(_connectionServer, _tempUser.ObjectId, out oMessages, 1, 10, MessageSortOrder.OLDEST_FIRST, MessageFilter.None, MailboxFolder.sentItems); Assert.IsTrue(res.Success, "Failed fetching send messages on new user"); try { UserMessage oNewMessage = new UserMessage(null, _tempUser.ObjectId); Assert.Fail("Creating new UserMessage object with null Connection server did not fail:" + oNewMessage); } catch { } try { UserMessage oNewMessage = new UserMessage(_connectionServer, ""); Assert.Fail("Creating new UserMessage object with and empty user ObjectID did not fail:" + oNewMessage); } catch { } //give the message time to be delivered Thread.Sleep(5000); //fetch res = UserMessage.GetMessages(_connectionServer, _tempUser.ObjectId, out oMessages); Assert.IsTrue(res.Success, "Failed to fetch messages:" + res); Assert.IsTrue(oMessages.Count > 0, "No messages found for temp user after leaving a new message"); oMessage = oMessages[0]; //some static helper methods Console.WriteLine(UserMessage.ConvertFromTimeDateToMilliseconds(DateTime.Now)); Console.WriteLine(UserMessage.ConvertFromTimeDateToMilliseconds(DateTime.Now, false)); //update failure res = oMessage.Update(); Assert.IsFalse(res.Success, "Calling update on message with no pending changes did not fail"); //update it oMessage.Subject = "New test subject"; oMessage.Read = true; res = oMessage.Update(); Assert.IsTrue(res.Success, "Message update failed"); //get attachment count int iCount; res = UserMessage.GetMessageAttachmentCount(_connectionServer, oMessage.MsgId, _tempUser.ObjectId, out iCount); Assert.IsTrue(res.Success, "Failed calling GetMessageAttachmentCount:" + res); Assert.IsTrue(iCount > 0, "Attachment count not valid"); res = UserMessage.GetMessageAttachmentCount(null, oMessage.MsgId, _tempUser.ObjectId, out iCount); Assert.IsFalse(res.Success, "Calling GetMessageAttachmentAccount with null Connection server did not fail."); //get attachments Assert.IsTrue(oMessage.Attachments.Count > 0, "Message fetched has no attachments"); string filename = "c:\\" + Guid.NewGuid().ToString() + ".wav"; res = oMessage.GetMessageAttachment(filename, 0); Assert.IsTrue(res.Success, "Failed to fetch attachment"); try { File.Delete(filename); } catch (Exception ex) { Console.WriteLine("Failed to delete temporary wav file:" + filename + ", error=" + ex); } //forward it to mailbox res = oMessage.ForwardMessageLocalWav("FW:" + oMessage.Subject, true, SensitivityType.Private, true, true, true, "dummy.wav", true, oRecipient); Assert.IsTrue(res.Success, "Failed to forward message"); //Forward failures res = oMessage.ForwardMessageLocalWav("FW:" + oMessage.Subject, true, SensitivityType.Private, true, false, false, "dummy.wav", true); Assert.IsFalse(res.Success, "Forwarding with wav with no address did not fail"); res = oMessage.ForwardMessageLocalWav("FW:" + oMessage.Subject, true, SensitivityType.Private, true, false, false, "bogus.wav", true, oRecipient); Assert.IsFalse(res.Success, "Forwarding with wav with invalid WAV file did not fail"); res = oMessage.ForwardMessageResourceId("FW:" + oMessage.Subject, true, SensitivityType.Private, true, false, false, "", oRecipient); Assert.IsFalse(res.Success, "Forwarding with empty resource Id did not fail"); res = oMessage.ForwardMessageResourceId("FW:" + oMessage.Subject, true, SensitivityType.Private, true, false, false, "bogus"); Assert.IsFalse(res.Success, "Forwarding resourceId with no addresses did not fail"); res = oMessage.ForwardMessageResourceId("FW:" + oMessage.Subject, true, SensitivityType.Private, true, false, false, "bogus", oRecipient); Assert.IsFalse(res.Success, "Forwarding resourceId with invalid resource Id did not fail"); //reply res = oMessage.ReplyWithLocalWav("RE:" + oMessage.Subject, true, SensitivityType.Private, true, false, false, "dummy.wav", true); Assert.IsTrue(res.Success, "Failed to reply"); //reply to all res = oMessage.ReplyWithLocalWav("RE:" + oMessage.Subject, true, SensitivityType.Private, true, false, false, "dummy.wav", true, true); Assert.IsTrue(res.Success, "Failed to reply to all"); //reply failures res = oMessage.ReplyWithResourceId("RE:" + oMessage.Subject, "", true, SensitivityType.Private, true, false, false, true); Assert.IsFalse(res.Success, "Reply with empty resource ID did not fail"); res = oMessage.ReplyWithResourceId("RE:" + oMessage.Subject, "bogus", true, SensitivityType.Private, true, false, false, true); Assert.IsFalse(res.Success, "Reply to all with bogus resource ID did not fail"); res = oMessage.ReplyWithResourceId("RE:" + oMessage.Subject, "bogus", true, SensitivityType.Private, true, false, false); Assert.IsFalse(res.Success, "Reply with bogus resource ID did not fail"); //delete it res = oMessage.Delete(true); Assert.IsTrue(res.Success, "Failed to delete messages:" + res); //clear deleted items folder res = UserMessage.ClearDeletedItemsFolder(_connectionServer, _tempUser.ObjectId); Assert.IsTrue(res.Success, "Failed to clear deleted items folder"); //failure res = UserMessage.ClearDeletedItemsFolder(null, _tempUser.ObjectId); Assert.IsFalse(res.Success, "Calling ClearDeletedItemsFolder with null ConnectionServerRest did not fail"); res = UserMessage.RecallMessage(null, _tempUser.ObjectId, "bugus"); Assert.IsFalse(res.Success, "Calling RecallMessage with null Connection server did not fail"); res = UserMessage.RecallMessage(_connectionServer, _tempUser.ObjectId, "bugus"); Assert.IsFalse(res.Success, "Calling RecallMessage with invalid message ID did not fail"); res = UserMessage.RestoreDeletedMessage(null, _tempUser.ObjectId, "bugus"); Assert.IsFalse(res.Success, "Calling RestoreDeletedMessage with null ConnectionServerRest did not fail"); res = UserMessage.RestoreDeletedMessage(_connectionServer, _tempUser.ObjectId, "bugus"); Assert.IsFalse(res.Success, "Calling RestoreDeletedMessage with invalid messae Id did not fail"); }
public void UserMessageSendFetchCompare() { List <UserMessage> oMessages; var res = UserMessage.GetMessages(_connectionServer, _tempUser.ObjectId, out oMessages); Assert.IsTrue(res.Success, "Failed fetching messages on new user:"******"Failed deleting messages from test inbox:" + res); } } //create a new message MessageAddress oRecipient = new MessageAddress(); oRecipient.AddressType = MessageAddressType.TO; oRecipient.SmtpAddress = _tempUser.SmtpAddress; //send urgent, secure, private res = UserMessage.CreateMessageLocalWav(_connectionServer, _tempUser.ObjectId, "test subject", "dummy.wav", true, SensitivityType.Private, true, false, false, false, new CallerId { CallerNumber = "1234" }, true, oRecipient); Assert.IsTrue(res.Success, "Failed to create new message from WAV file:" + res); Thread.Sleep(1000); //fetch the message res = UserMessage.GetMessages(_connectionServer, _tempUser.ObjectId, out oMessages); Assert.IsTrue(res.Success, "Failed fetching messages on new user"); Assert.IsTrue(oMessages.Count == 1, "1 message should be fetched from store, instead messages returned =" + oMessages.Count); //compare UserMessage oMessage = oMessages[0]; Assert.IsTrue(oMessage.Sensitivity == SensitivityType.Private, "Message is not flagged as private and it should be"); Assert.IsTrue(oMessage.Priority == PriorityType.Urgent, "Message not marked urgent and it should be"); Assert.IsTrue(oMessage.Secure, "Message not marked secure and it should be"); //delete res = oMessage.Delete(true); Assert.IsTrue(res.Success, "Failed deleting messages from test inbox:" + res); //send NOT secure, private, urgent res = UserMessage.CreateMessageLocalWav(_connectionServer, _tempUser.ObjectId, "test subject", "dummy.wav", false, SensitivityType.Normal, false, false, false, false, new CallerId { CallerNumber = "3456" }, true, oRecipient); Assert.IsTrue(res.Success, "Failed to create new message from WAV file:" + res); Thread.Sleep(1000); //fetch the message res = UserMessage.GetMessages(_connectionServer, _tempUser.ObjectId, out oMessages); Assert.IsTrue(res.Success, "Failed fetching messages on new user"); Assert.IsTrue(oMessages.Count == 1, "1 message should be fetched from store, instead messages returned =" + oMessages.Count); //compare oMessage = oMessages[0]; Assert.IsTrue(oMessage.Sensitivity == SensitivityType.Normal, "Message is not flagged as not private and it should be"); Assert.IsTrue(oMessage.Priority == PriorityType.Normal, "Message not marked normal priority and it should be"); Assert.IsTrue(!oMessage.Secure, "Message marked secure and it should not be"); //delete res = oMessage.Delete(true); Assert.IsTrue(res.Success, "Failed deleting messages from test inbox:" + res); }
/// <summary> /// Adds a single Addressee to the TOAddress collection /// </summary> public void AddAddressee(MessageAddressBuilder.Addressee addressee) { MessageAddress.AddAddressee(addressee); m_ToAddress = MessageAddress.ToString(); }
/// <summary> /// Parses a single header and sets member variables according to it. /// </summary> /// <param name="headerName">The name of the header</param> /// <param name="headerValue">The value of the header in unfolded state (only one line)</param> /// <exception cref="ArgumentNullException">If <paramref name="headerName"/> or <paramref name="headerValue"/> is <see langword="null"/></exception> public void ParseHeader(String headerName, String headerValue) { if (headerName == null) { throw new ArgumentNullException("headerName"); } if (headerValue == null) { throw new ArgumentNullException("headerValue"); } HeaderValueChanged(headerName, headerValue); switch (headerName.ToUpperInvariant()) { // See http://tools.ietf.org/html/rfc5322#section-3.6.3 case "TO": this.To = MessageHeader.ParseAddresses(headerValue); break; // See http://tools.ietf.org/html/rfc5322#section-3.6.3 case "CC": this.Cc = MessageHeader.ParseAddresses(headerValue); break; // See http://tools.ietf.org/html/rfc5322#section-3.6.3 case "BCC": this.Bcc = MessageHeader.ParseAddresses(headerValue); break; // See http://tools.ietf.org/html/rfc5322#section-3.6.2 case "FROM": // There is only one MailAddress in the from field this.From = MessageAddress.ParseAddress(headerValue); break; // http://tools.ietf.org/html/rfc5322#section-3.6.2 // The implementation here might be wrong case "REPLY-TO": // This field may actually be a list of addresses, but no // such case has been encountered this.ReplyTo = MessageAddress.ParseAddress(headerValue); break; // http://tools.ietf.org/html/rfc5322#section-3.6.2 case "SENDER": this.Sender = MessageAddress.ParseAddress(headerValue); break; // See http://tools.ietf.org/html/rfc5322#section-3.6.5 // RFC 5322: // The "Keywords:" field contains a comma-separated list of one or more // words or quoted-strings. // The field are intended to have only human-readable content // with information about the message case "KEYWORDS": var keywordsTemp = headerValue.Split(","); foreach (String keyword in keywordsTemp) { // Remove the quotes if there is any Keywords.Add(Utility.RemoveQuotesIfAny(keyword.Trim())); } break; // See http://tools.ietf.org/html/rfc5322#section-3.6.7 case "RECEIVED": // Simply add the value to the list Received.Add(headerValue.Trim()); break; case "IMPORTANCE": Importance = HeaderFieldParser.ParseImportance(headerValue.Trim()); break; // See http://tools.ietf.org/html/rfc3798#section-2.1 case "DISPOSITION-NOTIFICATION-TO": this.DispositionNotificationTo = MessageHeader.ParseAddresses(headerValue); break; case "MIME-VERSION": MimeVersion = headerValue.Trim(); break; // See http://tools.ietf.org/html/rfc5322#section-3.6.5 case "SUBJECT": case "THREAD-TOPIC": Subject = EncodedWord.Decode(headerValue); break; // See http://tools.ietf.org/html/rfc5322#section-3.6.7 case "RETURN-PATH": // Return-paths does not include a username, but we // may still use the address parser this.ReturnPath = MessageAddress.ParseAddress(headerValue); break; // See http://tools.ietf.org/html/rfc5322#section-3.6.4 // Example Message-ID // <*****@*****.**> case "MESSAGE-ID": MessageId = HeaderFieldParser.ParseId(headerValue); break; // See http://tools.ietf.org/html/rfc5322#section-3.6.4 case "IN-REPLY-TO": InReplyTo = HeaderFieldParser.ParseMultipleIDs(headerValue); break; // See http://tools.ietf.org/html/rfc5322#section-3.6.4 case "REFERENCES": References = HeaderFieldParser.ParseMultipleIDs(headerValue); break; // See http://tools.ietf.org/html/rfc5322#section-3.6.1)) case "DATE": Date = headerValue.Trim(); DateSent = Rfc2822DateTime.StringToDate(headerValue); break; // See http://tools.ietf.org/html/rfc2045#section-6 // See ContentTransferEncoding class for more details case "CONTENT-TRANSFER-ENCODING": ContentTransferEncoding = HeaderFieldParser.ParseContentTransferEncoding(headerValue.Trim()); break; // See http://tools.ietf.org/html/rfc2045#section-8 case "CONTENT-DESCRIPTION": // Human description of for example a file. Can be encoded ContentDescription = EncodedWord.Decode(headerValue.Trim()); break; // See http://tools.ietf.org/html/rfc2045#section-5.1 // Example: Content-type: text/plain; charset="us-ascii" case "CONTENT-TYPE": ContentType = HeaderFieldParser.ParseContentType(headerValue); break; // See http://tools.ietf.org/html/rfc2183 case "CONTENT-DISPOSITION": ContentDisposition = HeaderFieldParser.ParseContentDisposition(headerValue); break; // See http://tools.ietf.org/html/rfc2045#section-7 // Example: <foo4*[email protected]> case "CONTENT-ID": ContentId = HeaderFieldParser.ParseId(headerValue); break; case "_REQUEST-LINE_": // header could contain request-line that could not be parsed as simple key value pair, so store entire line // Example: POST /odata/$batch HTTP/1.1 RequestLine = headerValue; break; default: // This is an unknown header // Custom headers are allowed. That means headers // that are not mentionen in the RFC. // Such headers start with the letter "X" // We do not have any special parsing of such // Add it to unknown headers UnknownHeaders.Add(headerName, headerValue); break; } }
public IHttpActionResult GetEmailInfo(int id, int jobId) { try { int userId = _userService.GetCurrentUserId(); var resp = new ItemsResponse<ApplyJobEmail>(); resp.Items = _jobPostingsService.GetEmailInfo(id, jobId); var eml = new Email(); var msgAdd = new MessageAddress { Email = resp.Items[0].ContactEmail, Name = "Dev Job Employer" }; var list = new List<MessageAddress> { msgAdd }; eml.To = list; eml.FromAddress = "*****@*****.**"; eml.FromName = resp.Items[0].Firstname + " " + resp.Items[0].LastName; eml.Subject = "Job Interest"; eml.PlainTextBody = "Hello, this is a message from Dev. "+ (eml.FromName) + " is interested in the "+(resp.Items[0].JobTitle)+" position that you have posted. " + "To get back to "+(eml.FromName)+" about this position you can email "+(resp.Items[0].Firstname)+" at " +(resp.Items[0].Email)+"."; _emailMessenger.SendMail(eml); var emlConfirmation = new Email(); var msgAddConfirmation = new MessageAddress { Email = resp.Items[0].Email, Name = "Dev" }; var listConfiramtion = new List<MessageAddress> { msgAddConfirmation }; emlConfirmation.To = listConfiramtion; emlConfirmation.FromAddress = "*****@*****.**"; emlConfirmation.FromName = resp.Items[0].Firstname + " " + resp.Items[0].LastName; emlConfirmation.Subject = "Job Interest Confirmation"; emlConfirmation.PlainTextBody = "Hello " + (emlConfirmation.FromName) + ", this is a message from Dev. You have succesfully contacted the employer regarding the position of " + (resp.Items[0].JobTitle) + ". " + "The employer will contact you by email. DO NOT contact Dev regarding this position."; _emailMessenger.SendMail(emlConfirmation); return Ok(resp); } catch (Exception ex) { int currentUser = _userService.GetCurrentUserId(); _appLogService.Insert(new AppLogAddRequest { AppLogTypeId = 1, Message = ex.Message, StackTrace = ex.StackTrace, Title = "Error in " + GetType().Name + " " + System.Reflection.MethodBase.GetCurrentMethod().Name, UserBaseId = currentUser }); return BadRequest(ex.Message); }; }
/// <summary> /// 更新icon的素材,供外部调用 /// </summary> /// <param name="messageAddress"></param> private void UpdateIcons(MessageAddress messageAddress) { CheckAndCreateIconBtn(messageAddress.Parameters as Texture2D[]); RegisterIcon(); }
public MessageAddress Add(MessageAddress address) { fData.Add(address); return(address); }
//CHARGE EXISTING CUSTOMERS public List <ChargeExistingUser> GetUsersToCharge() { List <ChargeExistingUser> existingUserList = null; DataProvider.ExecuteCmd("dbo.UserSubscriptions_SelectCustomersToBill", inputParamMapper: null, singleRecordMapper: (IDataReader reader, short resultSet) => { if (existingUserList == null) { existingUserList = new List <ChargeExistingUser>(); } existingUserList.Add(DataMapper <ChargeExistingUser> .Instance.MapToObject(reader)); }); if (existingUserList != null) { ChargeExistingUser model = null; foreach (ChargeExistingUser existingUser in existingUserList.ToList()) { try { model = existingUser; TransactionsAddRequest transaction = ChargeExistingCustomer(existingUser); InsertTransaction(transaction); DateTime _newBillDate = existingUser.NextBillingDate.AddMonths(existingUser.DurationMonths); existingUser.NextBillingDate = _newBillDate; } catch (Exception ex) { TransactionFailAddRequest failedTransaction = new TransactionFailAddRequest { UserBaseId = model.UserBaseId, CustomerId = model.CustomerId, Amount = model.Price, Currency = model.Currency, Name = model.CustomerName, Email = model.CustomerEmail, PlanId = model.PlanId, DurationTypeId = model.DurationTypeId, DiscountPercent = model.DiscountPercent, ErrorMessage = ex.Message }; //will lock UserBaseId when transaction failure is inserted this.InsertTransactionFail(failedTransaction); //will deactivate user once transaction fails //this.UpdateUserIsActive(failedTransaction); //create Token/GUID on AppToken table with the UserBaseId ItemResponse <string> Token = new ItemResponse <string> { Item = this.CreateTokenForFailedTransactions(failedTransaction) }; Email eml = new Email(); MessageAddress msgAdd = new MessageAddress { Email = "*****@*****.**", Name = model.CustomerName }; List <MessageAddress> list = new List <MessageAddress> { msgAdd }; eml.To = list; eml.FromAddress = "*****@*****.**"; eml.FromName = "Eleveight"; eml.Subject = "Subscription Charge Failure"; eml.HtmlBody = _emailTemplateService.CreateFailedPayments(new EmailPaymentFailTemplateInput { CustomerName = msgAdd.Name, Token = Token.Item, ExtraInfo = "Your subscription has been deactivated due to failed recurring charges. " + "Please call Eleveight customer service to reactivate your subscription" }); _emailMessenger.SendMail(eml); //remove from list if transaction failed existingUserList.Remove(existingUser); } } if (existingUserList.Count != 0) { UpdateMultipleCustomerSubscription(existingUserList); } } return(existingUserList); }