/// <summary> /// Gets the medium data. /// </summary> private void GetMediumData() { if (phContent.Controls.Count == 1) { var mediumControl = phContent.Controls[0] as MediumControl; if (mediumControl != null) { // If using simple mode, the control should be re-initialized from sender since sender fields // are not presented for editing and user shouldn't be able to change them if (!_fullMode && CurrentPerson != null) { mediumControl.InitializeFromSender(CurrentPerson); } foreach (var dataItem in mediumControl.MediumData) { if (MediumData.ContainsKey(dataItem.Key)) { MediumData[dataItem.Key] = dataItem.Value; } else { MediumData.Add(dataItem.Key, dataItem.Value); } } } } }
private void GetTemplateData(int templateId, bool loadControl = true) { var template = new CommunicationTemplateService(new RockContext()).Get(templateId); if (template != null) { var mediumData = template.MediumData; if (!mediumData.ContainsKey("Subject")) { mediumData.Add("Subject", template.Subject); } foreach (var dataItem in mediumData) { if (!string.IsNullOrWhiteSpace(dataItem.Value)) { if (MediumData.ContainsKey(dataItem.Key)) { MediumData[dataItem.Key] = dataItem.Value; } else { MediumData.Add(dataItem.Key, dataItem.Value); } } } if (loadControl) { LoadMediumControl(true); } } }
public void SetMediumDataValue(string key, string value) { if (MediumData.ContainsKey(key)) { MediumData[key] = value; } else { MediumData.Add(key, value); } }
/// <summary> /// Shows the detail. /// </summary> /// <param name="communication">The communication.</param> private void ShowDetail(Rock.Model.Communication communication) { Recipients.Clear(); if (communication != null) { this.AdditionalMergeFields = communication.AdditionalMergeFields.ToList(); lTitle.Text = (communication.Subject ?? "New Communication").FormatAsHtmlTitle(); foreach (var recipient in new CommunicationRecipientService(new RockContext()) .Queryable("PersonAlias.Person.PhoneNumbers") .Where(r => r.CommunicationId == communication.Id)) { Recipients.Add(new Recipient(recipient.PersonAlias.Person, recipient.Status, recipient.StatusNote, recipient.OpenedClient, recipient.OpenedDateTime)); } } else { communication = new Rock.Model.Communication() { Status = CommunicationStatus.Transient }; lTitle.Text = "New Communication".FormatAsHtmlTitle(); int?personId = PageParameter("Person").AsIntegerOrNull(); if (personId.HasValue) { communication.IsBulkCommunication = false; var person = new PersonService(new RockContext()).Get(personId.Value); if (person != null) { Recipients.Add(new Recipient(person, CommunicationRecipientStatus.Pending, string.Empty, string.Empty, null)); } } } CommunicationId = communication.Id; MediumEntityTypeId = communication.MediumEntityTypeId; BindMediums(); MediumData = communication.MediumData; MediumData.Add("Subject", communication.Subject); if (communication.Status == CommunicationStatus.Transient && !string.IsNullOrWhiteSpace(GetAttributeValue("DefaultTemplate"))) { var template = new CommunicationTemplateService(new RockContext()).Get(GetAttributeValue("DefaultTemplate").AsGuid()); // If a template guid was passed in, it overrides any default template. string templateGuid = PageParameter("templateGuid"); if (!string.IsNullOrEmpty(templateGuid)) { var guid = new Guid(templateGuid); template = new CommunicationTemplateService(new RockContext()).Queryable().Where(t => t.Guid == guid).FirstOrDefault(); } if (template != null && template.MediumEntityTypeId == MediumEntityTypeId) { foreach (ListItem item in ddlTemplate.Items) { if (item.Value == template.Id.ToString()) { item.Selected = true; GetTemplateData(template.Id, false); } else { item.Selected = false; } } } } cbBulk.Checked = communication.IsBulkCommunication; MediumControl control = LoadMediumControl(true); if (control != null && CurrentPerson != null) { control.InitializeFromSender(CurrentPerson); } dtpFutureSend.SelectedDateTime = communication.FutureSendDateTime; ShowStatus(communication); ShowActions(communication); }