Ejemplo n.º 1
0
        /// <summary>
        /// Handles the ItemDataBound event of the rptConversation control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void rptConversation_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            CommunicationRecipientResponse communicationRecipientResponse = e.Item.DataItem as CommunicationRecipientResponse;

            if (communicationRecipientResponse != null)
            {
                var hfCommunicationRecipientId = ( HiddenFieldWithClass )e.Item.FindControl("hfCommunicationRecipientId");
                hfCommunicationRecipientId.Value = communicationRecipientResponse.RecipientPersonAliasId.ToString();

                var hfCommunicationMessageKey = ( HiddenFieldWithClass )e.Item.FindControl("hfCommunicationMessageKey");
                hfCommunicationMessageKey.Value = communicationRecipientResponse.MessageKey;

                var lSMSMessage = ( Literal )e.Item.FindControl("lSMSMessage");
                lSMSMessage.Text = communicationRecipientResponse.SMSMessage;

                var lSenderName = ( Literal )e.Item.FindControl("lSenderName");
                lSenderName.Text = communicationRecipientResponse.FullName;

                var lblMessageDateTime = ( Label )e.Item.FindControl("lblMessageDateTime");
                lblMessageDateTime.ToolTip = communicationRecipientResponse.CreatedDateTime.ToString();
                lblMessageDateTime.Text    = communicationRecipientResponse.HumanizedCreatedDateTime.ToString();
                var divCommunication = ( HtmlGenericControl )e.Item.FindControl("divCommunication");

                if (communicationRecipientResponse.IsOutbound)
                {
                    divCommunication.RemoveCssClass("inbound");
                    divCommunication.AddCssClass("outbound");
                }
                else
                {
                    divCommunication.RemoveCssClass("outbound");
                    divCommunication.AddCssClass("inbound");
                }
            }
        }
        /// <summary>
        /// Handles the ItemDataBound event of the rptConversation control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void rptConversation_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            CommunicationRecipientResponse communicationRecipientResponse = e.Item.DataItem as CommunicationRecipientResponse;

            if (communicationRecipientResponse != null)
            {
                var hfCommunicationRecipientId = ( HiddenFieldWithClass )e.Item.FindControl("hfCommunicationRecipientId");
                hfCommunicationRecipientId.Value = communicationRecipientResponse.RecipientPersonAliasId.ToString();

                var hfCommunicationMessageKey = ( HiddenFieldWithClass )e.Item.FindControl("hfCommunicationMessageKey");
                hfCommunicationMessageKey.Value = communicationRecipientResponse.MessageKey;

                var lSMSMessage = ( Literal )e.Item.FindControl("lSMSMessage");
                if (communicationRecipientResponse.SMSMessage.IsNullOrWhiteSpace())
                {
                    var divCommunicationBody = ( HtmlControl )e.Item.FindControl("divCommunicationBody");
                    divCommunicationBody.Visible = false;
                }
                else
                {
                    lSMSMessage.Text = communicationRecipientResponse.SMSMessage;
                }

                if (communicationRecipientResponse.BinaryFileGuids != null)
                {
                    var    lSMSAttachments = ( Literal )e.Item.FindControl("lSMSAttachments");
                    string applicationRoot = GlobalAttributesCache.Value("PublicApplicationRoot");

                    foreach (var binaryFileGuid in communicationRecipientResponse.BinaryFileGuids)
                    {
                        // Show the image thumbnail by appending the html to lSMSMessage.Text
                        string imageElement = $"<a href='{applicationRoot}GetImage.ashx?guid={binaryFileGuid}' target='_blank' rel='noopener noreferrer'><img src='{applicationRoot}GetImage.ashx?guid={binaryFileGuid}&width=200' class='img-responsive sms-image'></a>";

                        // If there is a text portion or previous image then drop down a line before appending the image element
                        lSMSAttachments.Text += imageElement;
                    }
                }

                var lSenderName = ( Literal )e.Item.FindControl("lSenderName");
                lSenderName.Text = communicationRecipientResponse.FullName;

                var lblMessageDateTime = ( Label )e.Item.FindControl("lblMessageDateTime");
                lblMessageDateTime.ToolTip = communicationRecipientResponse.CreatedDateTime.ToString();
                lblMessageDateTime.Text    = communicationRecipientResponse.HumanizedCreatedDateTime.ToString();

                if (communicationRecipientResponse.MessageStatus == CommunicationRecipientStatus.Pending)
                {
                    lblMessageDateTime.Text += " (Pending)";
                }

                var divCommunication = ( HtmlGenericControl )e.Item.FindControl("divCommunication");

                if (communicationRecipientResponse.IsOutbound)
                {
                    divCommunication.RemoveCssClass("inbound");
                    divCommunication.AddCssClass("outbound");
                }
                else
                {
                    divCommunication.RemoveCssClass("outbound");
                    divCommunication.AddCssClass("inbound");
                }
            }
        }