protected static void SaveMessageRecipients(int messageID, int[] telephoneIDs) { ///Collect all receipents number from the telephone number table IList <TelephoneNumber> recipients = new List <TelephoneNumber>(); recipients = (from P in _DataContext.TelephoneNumbers where (from I in telephoneIDs select I).Contains(P.ID) select P).ToList(); if (recipients != null && recipients.Count > 0) { foreach (TelephoneNumber receipient in recipients) { Message_Recipient msgRecipient = new Message_Recipient(); msgRecipient.Message_ID = messageID; msgRecipient.Recipient_ID = receipient.ID; msgRecipient.Recipient_Name = String.Format("{0} {1}", receipient.Contact.FirstNames, receipient.Contact.LastName); msgRecipient.Destination = receipient.Number; msgRecipient.Try_Order = 1; ///TODO: I think we have to review the Following line of code. msgRecipient.Is_Phone_Number = true; msgRecipient.Status_ID = 1; msgRecipient.Updated_On = DateTime.Now; _DataContext.Message_Recipients.InsertOnSubmit(msgRecipient); _DataContext.SubmitChanges(); } } }
protected static String SendMessage(int[] telephoneIDs, Message message) { //Get Int array from the receipients list //int[] ids = WebUtil.GetIntArray(receiPients); int lastRecipientID = 0; //collect all receipents number from the telephone number table //OMMDataContext dataContext = new OMMDataContext(); IList <TelephoneNumber> recipients = new List <TelephoneNumber>(); IList <TelephoneNumber> filteredRecipients = new List <TelephoneNumber>(); Message_Recipient msgRecipient = new Message_Recipient(); recipients = (from P in _DataContext.TelephoneNumbers where (from I in telephoneIDs select I).Contains(P.ID) select P).ToList(); if (recipients != null && recipients.Count > 0) { foreach (TelephoneNumber receipient in recipients) { if (lastRecipientID != receipient.ID) { //// RULES //// Number not sent -> Send and go to next contact //// Number sent and failed -> Go to next number //// Number sent but not delivered -> Go to next contact //// Number sent and delivered -> Go to next contact filteredRecipients.Add(receipient); } lastRecipientID = receipient.ID; } ///TODO: Send Messages to the Filtered Receipients if (filteredRecipients.Count > 0) { SendFinalMessage(message, filteredRecipients); System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < filteredRecipients.Count; i++) { TelephoneNumber cell = filteredRecipients[i]; if (i > 0) { sb.Append(", "); } sb.Append(cell.Number); } return(sb.ToString()); } } return(String.Empty); }
private void detach_Message_Recipients(Message_Recipient entity) { this.SendPropertyChanging(); entity.Message_Statuse = null; }
partial void DeleteMessage_Recipient(Message_Recipient instance);
partial void UpdateMessage_Recipient(Message_Recipient instance);
partial void InsertMessage_Recipient(Message_Recipient instance);
private void attach_Message_Recipients(Message_Recipient entity) { this.SendPropertyChanging(); entity.Message = this; }