/// <summary> /// Loads the response listing. /// </summary> private void LoadResponseListing(int?personId) { // NOTE: The FromPersonAliasId is the person who sent a text from a mobile device to Rock. // This person is also referred to as the Recipient because they are responding to a // communication from Rock. Restated the response is from the recipient of a communication. // This is the person lava field, we want to clear it because reloading this list will deselect the user. litSelectedRecipientDescription.Text = string.Empty; hfSelectedRecipientPersonAliasId.Value = string.Empty; hfSelectedMessageKey.Value = string.Empty; tbNewMessage.Visible = false; btnSend.Visible = false; btnEditNote.Visible = false; lbShowImagePicker.Visible = false; noteEditor.Visible = false; int?smsPhoneDefinedValueId = hfSmsNumber.ValueAsInt(); if (smsPhoneDefinedValueId == default(int)) { return; } using (var rockContext = new RockContext()) { var communicationResponseService = new CommunicationResponseService(rockContext); int months = GetAttributeValue(AttributeKey.ShowConversationsFromMonthsAgo).AsInteger(); var startDateTime = RockDateTime.Now.AddMonths(-months); bool showRead = tglShowRead.Checked; var maxConversations = this.GetAttributeValue(AttributeKey.MaxConversations).AsIntegerOrNull() ?? 1000; var responseListItems = communicationResponseService.GetCommunicationResponseRecipients(smsPhoneDefinedValueId.Value, startDateTime, showRead, maxConversations, personId); // don't display conversations if we're rebinding the recipient list rptConversation.Visible = false; gRecipients.DataSource = responseListItems; gRecipients.DataBind(); } }
/// <summary> /// Loads the response listing. /// </summary> private void LoadResponseListing(int?personId) { // NOTE: The FromPersonAliasId is the person who sent a text from a mobile device to Rock. // This person is also referred to as the Recipient because they are responding to a // communication from Rock. Restated the response is from the recipient of a communication. // This is the person lava field, we want to clear it because reloading this list will deselect the user. litSelectedRecipientDescription.Text = string.Empty; hfSelectedRecipientPersonAliasId.Value = string.Empty; hfSelectedMessageKey.Value = string.Empty; tbNewMessage.Visible = false; btnSend.Visible = false; btnEditNote.Visible = false; lbShowImagePicker.Visible = false; noteEditor.Visible = false; int?smsPhoneDefinedValueId = hfSmsNumber.ValueAsInt(); if (smsPhoneDefinedValueId == default(int)) { return; } try { using (var rockContext = new RockContext()) { rockContext.Database.CommandTimeout = GetAttributeValue(AttributeKey.DatabaseTimeoutSeconds).AsIntegerOrNull() ?? 180; var communicationResponseService = new CommunicationResponseService(rockContext); int months = GetAttributeValue(AttributeKey.ShowConversationsFromMonthsAgo).AsInteger(); var startDateTime = RockDateTime.Now.AddMonths(-months); bool showRead = tglShowRead.Checked; var maxConversations = this.GetAttributeValue(AttributeKey.MaxConversations).AsIntegerOrNull() ?? 1000; var responseListItems = communicationResponseService.GetCommunicationResponseRecipients(smsPhoneDefinedValueId.Value, startDateTime, showRead, maxConversations, personId); // don't display conversations if we're rebinding the recipient list rptConversation.Visible = false; gRecipients.DataSource = responseListItems; gRecipients.DataBind(); } } catch (Exception ex) { this.LogException(ex); var sqlTimeoutException = ReportingHelper.FindSqlTimeoutException(ex); if (sqlTimeoutException != null) { nbError.NotificationBoxType = NotificationBoxType.Warning; nbError.Text = "Unable to load SMS responses in a timely manner. You can try again or adjust the timeout setting of this block."; nbError.Visible = true; return; } else { nbError.NotificationBoxType = NotificationBoxType.Danger; nbError.Text = "An error occurred when loading SMS responses"; nbError.Details = ex.Message; nbError.Visible = true; return; } } }