Exemple #1
0
 /// <summary>
 /// Sets control values from a communication record.
 /// </summary>
 /// <param name="communication">The communication.</param>
 public override void SetFromCommunication(CommunicationDetails communication)
 {
     EnsureChildControls();
     tbTitle.Text    = communication.PushTitle;
     tbMessage.Text  = communication.PushMessage;
     cbSound.Checked = communication.PushSound.IsNotNullOrWhiteSpace();
 }
Exemple #2
0
 /// <summary>
 /// Updates the a communication record from control values.
 /// </summary>
 /// <param name="communication">The communication.</param>
 public override void UpdateCommunication(CommunicationDetails communication)
 {
     EnsureChildControls();
     communication.PushTitle   = tbTitle.Text;
     communication.PushMessage = tbMessage.Text;
     communication.PushSound   = cbSound.Checked ? "default" : string.Empty;
 }
Exemple #3
0
        /// <summary>
        /// Updates the a communication record from control values.
        /// </summary>
        /// <param name="communication">The communication.</param>
        public override void UpdateCommunication(CommunicationDetails communication)
        {
            EnsureChildControls();
            communication.PushTitle             = tbTitle.Text;
            communication.PushMessage           = tbMessage.Text;
            communication.PushImageBinaryFileId = iupPushImage.BinaryFileId;
            communication.PushOpenAction        = GetSelectedOpenActionOrDefault();

            var pushData = new PushData();

            if (communication.PushOpenAction == PushOpenAction.ShowDetails)
            {
                communication.PushOpenMessage = htmlAdditionalDetails.Text;
                pushData.MobileApplicationId  = ddlMobileApplications.SelectedValue.AsIntegerOrNull();
            }

            if (communication.PushOpenAction == PushOpenAction.LinkToMobilePage)
            {
                pushData.MobilePageQueryString = kvlQuerystring.Value.AsDictionaryOrNull();
                pushData.MobilePageId          = ppMobilePage.SelectedValue.AsIntegerOrNull();
                pushData.MobileApplicationId   = pushData.MobilePageId.HasValue ? PageCache.Get(pushData.MobilePageId.Value)?.SiteId : null;
            }

            if (communication.PushOpenAction == PushOpenAction.LinkToUrl)
            {
                pushData.Url = urlLink.Text;
            }

            communication.PushData = pushData.ToJson();
        }
        /// <summary>
        /// Gets parent schema.
        /// </summary>
        /// <param name="schema"><see cref="EntitySchema"/>schema.</param>
        /// <returns>Parent schema if schema is a detail.</returns>
        protected override string GetParentSchemaName(EntitySchema schema)
        {
            string schemaName = schema.Name;

            return(CommunicationDetails.GetValueOrDefault(schemaName, default(string))
                   ?? SimpleDetails.GetValueOrDefault(schemaName, default(string)));
        }
        /// <summary>
        /// Gets key value pair detail by detail name.
        /// </summary>
        /// <param name="detailNameWithSuffix">Detail name with suffix.</param>
        /// <returns>Custom or simple detail.</returns>
        private KeyValuePair <string, string> GetDetailByName(string detailNameWithSuffix)
        {
            var simpleDetail        = SimpleDetails.FirstOrDefault(d => detailNameWithSuffix == d.Key);
            var communicationDetail = CommunicationDetails.FirstOrDefault(d => detailNameWithSuffix.StartsWith(d.Key));

            return(simpleDetail.Equals(default(KeyValuePair <string, string>)) ? communicationDetail : simpleDetail);
        }
        /// <summary>
        /// Sets up a communication model with the user-entered values
        /// </summary>
        /// <returns>The communication for this session.</returns>
        private Rock.Model.Communication SetupCommunication()
        {
            var communication = new Rock.Model.Communication
            {
                Status                = CommunicationStatus.Approved,
                ReviewedDateTime      = RockDateTime.Now,
                ReviewerPersonAliasId = CurrentPersonAliasId,
                SenderPersonAliasId   = CurrentPersonAliasId,
                CommunicationType     = CommunicationType.PushNotification
            };

            communication.EnabledLavaCommands     = GetAttributeValue(AttributeKey.EnabledLavaCommands);
            communication.CommunicationTemplateId = hfSelectedCommunicationTemplateId.Value.AsIntegerOrNull();

            var communicationData       = new CommunicationDetails();
            var pushNotificationControl = phPushControl.Controls[0] as PushNotification;

            if (pushNotificationControl != null)
            {
                pushNotificationControl.UpdateCommunication(communicationData);
            }

            CommunicationDetails.Copy(communicationData, communication);

            return(communication);
        }
Exemple #7
0
 /// <summary>
 /// Sets control values from a communication record.
 /// </summary>
 /// <param name="communication">The communication.</param>
 public override void SetFromCommunication(CommunicationDetails communication)
 {
     EnsureChildControls();
     tbFromName.Text       = communication.FromName;
     ebFromAddress.Text    = communication.FromEmail;
     ebReplyToAddress.Text = communication.ReplyToEmail;
     ebCcAddress.Text      = communication.CCEmails;
     ebBccAddress.Text     = communication.BCCEmails;
     tbSubject.Text        = communication.Subject;
     htmlMessage.Text      = communication.Message;
     hfAttachments.Value   = communication.EmailAttachmentBinaryFileIds != null?communication.EmailAttachmentBinaryFileIds.ToList().AsDelimited(",") : string.Empty;
 }
Exemple #8
0
 /// <summary>
 /// Updates the a communication record from control values.
 /// </summary>
 /// <param name="communication">The communication.</param>
 public override void UpdateCommunication(CommunicationDetails communication)
 {
     EnsureChildControls();
     communication.FromName     = tbFromName.Text;
     communication.FromEmail    = ebFromAddress.Text;
     communication.ReplyToEmail = ebReplyToAddress.Text;
     communication.Subject      = tbSubject.Text;
     communication.Message      = htmlMessage.Text;
     communication.EmailAttachmentBinaryFileIds = hfAttachments.Value.SplitDelimitedValues().AsIntegerList();
     communication.CCEmails  = ebCcAddress.Text;
     communication.BCCEmails = ebBccAddress.Text;
 }
Exemple #9
0
        /// <summary>
        /// Sets control values from a communication record.
        /// </summary>
        /// <param name="communication">The communication.</param>
        public override void SetFromCommunication(CommunicationDetails communication)
        {
            EnsureChildControls();
            var valueItem = dvpFrom.Items.FindByValue(communication.SMSFromDefinedValueId.ToString());

            if (valueItem == null && communication.SMSFromDefinedValueId != null)
            {
                var lookupDefinedValue = DefinedValueCache.Get(communication.SMSFromDefinedValueId.GetValueOrDefault());
                dvpFrom.Items.Add(new ListItem(lookupDefinedValue.Description, lookupDefinedValue.Id.ToString()));
            }
            dvpFrom.SetValue(communication.SMSFromDefinedValueId);
            tbMessage.Text = communication.SMSMessage;
        }
        private static CommunicationDetails CreateCommunication(MicrosoftSupportClient client, string ticketName, string subject, string body)
        {
            var createCommunicationParameters = new CommunicationDetails
            {
                Subject = subject,
                Body    = body
            };

            var communicationName = TestUtilities.GenerateName("Communication");

            Console.WriteLine($"Creating communication with name: {communicationName} for ticket {ticketName}");

            var communicationDetails = client.Communications.Create(ticketName, communicationName, createCommunicationParameters);

            return(communicationDetails);
        }
Exemple #11
0
        /// <summary>
        /// Sets control values from a communication record.
        /// </summary>
        /// <param name="communication">The communication.</param>
        public override void SetFromCommunication(CommunicationDetails communication)
        {
            EnsureChildControls();
            tbTitle.Text   = communication.PushTitle;
            tbMessage.Text = communication.PushMessage;

            iupPushImage.BinaryFileId = communication.PushImageBinaryFileId;
            if (communication.PushOpenAction != null)
            {
                rbOpenAction.SelectedValue = communication.PushOpenAction.ConvertToInt().ToString();
            }

            var pushData = new PushData();

            if (communication.PushData.IsNotNullOrWhiteSpace())
            {
                pushData = Newtonsoft.Json.JsonConvert.DeserializeObject <PushData>(communication.PushData);
            }

            ddlMobileApplications.SelectedValue = null;
            htmlAdditionalDetails.Text          = null;
            if (communication.PushOpenAction == PushOpenAction.ShowDetails)
            {
                ddlMobileApplications.SelectedValue = pushData.MobileApplicationId.ToStringSafe();
                htmlAdditionalDetails.Text          = communication.PushOpenMessage;
            }

            kvlQuerystring.Value = null;
            if (communication.PushOpenAction == PushOpenAction.LinkToMobilePage)
            {
                ppMobilePage.SetValue(pushData.MobilePageId);

                if (pushData.MobilePageQueryString != null)
                {
                    kvlQuerystring.Value = pushData.MobilePageQueryString.Select(a => string.Format("{0}^{1}", a.Key, a.Value)).ToList().AsDelimited("|");
                }
            }

            urlLink.Text = null;
            if (communication.PushOpenAction == PushOpenAction.LinkToUrl)
            {
                urlLink.Text = pushData.Url;
            }
        }
Exemple #12
0
        public static PSSupportTicketCommunication ToPSSupportTicketCommunication(this CommunicationDetails sdkCommunication)
        {
            if (sdkCommunication == null)
            {
                return(null);
            }

            return(new PSSupportTicketCommunication
            {
                Id = sdkCommunication.Id,
                Name = sdkCommunication.Name,
                Type = sdkCommunication.Type,
                Subject = sdkCommunication.Subject,
                Body = sdkCommunication.Body,
                Sender = sdkCommunication.Sender,
                CommunicationDirection = sdkCommunication.CommunicationDirection,
                CommunicationType = sdkCommunication.CommunicationType,
                CreatedDate = sdkCommunication.CreatedDate
            });
        }
Exemple #13
0
        public override void ExecuteCmdlet()
        {
            try
            {
                if (this.IsParameterBound(c => c.SupportTicketObject))
                {
                    this.SupportTicketName = this.SupportTicketObject.Name;
                }

                var checkNameAvailabilityInput = new CheckNameAvailabilityInput
                {
                    Name = this.Name,
                    Type = Management.Support.Models.Type.MicrosoftSupportCommunications
                };

                var checkNameResult = this.SupportClient.Communications.CheckNameAvailability(this.SupportTicketName, checkNameAvailabilityInput);

                if (checkNameResult.NameAvailable.HasValue && !checkNameResult.NameAvailable.Value)
                {
                    throw new PSArgumentException(string.Format("A Communication with name '{0}' for SupportTicket '{1}' already exists.", this.Name, this.SupportTicketName));
                }

                var communicationDetails = new CommunicationDetails
                {
                    Subject = this.Subject,
                    Body    = this.Body,
                    Sender  = this.Sender
                };

                if (this.ShouldProcess(this.Name, string.Format("Creating a new Communication for SupportTicket '{0}' with name '{1}'.", this.SupportTicketName, this.Name)))
                {
                    var result = this.SupportClient.Communications.Create(this.SupportTicketName, this.Name, communicationDetails);
                    this.WriteObject(result.ToPSSupportTicketCommunication());
                }
            }
            catch (ExceptionResponseException ex)
            {
                throw new PSArgumentException(string.Format("Error response received. Error Message: '{0}'",
                                                            ex.Response.Content));
            }
        }
Exemple #14
0
        public async Task <CommunicationDetails> AppendMessageToCommunication(string submitedSubscription, string supportTicketId, string trackingId, string body)
        {
            if (string.IsNullOrWhiteSpace(submitedSubscription))
            {
                throw new ArgumentException($"'{nameof(submitedSubscription)}' cannot be null or whitespace.", nameof(submitedSubscription));
            }
            if (string.IsNullOrWhiteSpace(supportTicketId))
            {
                throw new ArgumentException($"'{nameof(supportTicketId)}' cannot be null or whitespace.", nameof(supportTicketId));
            }
            if (string.IsNullOrWhiteSpace(body))
            {
                throw new ArgumentException($"'{nameof(body)}' cannot be null or whitespace.", nameof(body));
            }

            try
            {
                var coms = await GetMsSupportTicketsCommunication(submitedSubscription, supportTicketId, trackingId);

                var subject = coms?.Select(a => a.Subject).FirstOrDefault();
                if (subject.IsNullOrEmptyExt())
                {
                    throw new ApplicationException(nameof(AppendMessageToCommunication) + "-" + nameof(GetMsSupportTicketsCommunication) + ", no subject found");
                }
                CommunicationDetails added = null;
                try
                {
                    added = await AddMessageToCommunication(submitedSubscription, supportTicketId, subject, body);
                }
                catch (Exception ex)
                {
                    //retry with trackingId
                    added = await AddMessageToCommunication(submitedSubscription, trackingId, subject, body);
                }
                return(added);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #15
0
        /// <summary>
        /// Gets the communication.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="peopleIds">The people ids.</param>
        /// <returns></returns>
        private Rock.Model.Communication GetCommunication(RockContext rockContext, List <int> peopleIds)
        {
            var communicationService = new CommunicationService(rockContext);
            var recipientService     = new CommunicationRecipientService(rockContext);

            if (GetTemplateData())
            {
                Rock.Model.Communication communication = new Rock.Model.Communication();
                communication.Status = CommunicationStatus.Transient;
                communication.SenderPersonAliasId = CurrentPersonAliasId;
                communicationService.Add(communication);
                communication.IsBulkCommunication = true;
                communication.CommunicationType   = CommunicationType.Email;
                communication.FutureSendDateTime  = null;

                // add each person as a recipient to the communication
                if (peopleIds != null)
                {
                    var emailMediumTypeId = EntityTypeCache.Get(Rock.SystemGuid.EntityType.COMMUNICATION_MEDIUM_EMAIL.AsGuid()).Id;

                    foreach (var personId in peopleIds)
                    {
                        if (!communication.Recipients.Any(r => r.PersonAlias.PersonId == personId))
                        {
                            var communicationRecipient = new CommunicationRecipient();
                            communicationRecipient.PersonAlias        = new PersonAliasService(rockContext).GetPrimaryAlias(personId);
                            communicationRecipient.MediumEntityTypeId = emailMediumTypeId;
                            communication.Recipients.Add(communicationRecipient);
                        }
                    }
                }

                CommunicationDetails.Copy(CommunicationData, communication);

                return(communication);
            }

            return(null);
        }
        /// <summary>
        /// Initializes the fields from communication template.
        /// </summary>
        /// <param name="communicationTemplateId">The communication template identifier.</param>
        private void InitializeFieldsFromCommunicationTemplate(int communicationTemplateId)
        {
            hfSelectedCommunicationTemplateId.Value = communicationTemplateId.ToString();
            var communicationTemplate = new CommunicationTemplateService(new RockContext()).Get(hfSelectedCommunicationTemplateId.Value.AsInteger());

            var pushCommunication = new CommunicationDetails
            {
                PushData = communicationTemplate.PushData,
                PushImageBinaryFileId = communicationTemplate.PushImageBinaryFileId,
                PushMessage           = communicationTemplate.PushMessage,
                PushTitle             = communicationTemplate.PushTitle,
                PushOpenMessage       = communicationTemplate.PushOpenMessage,
                PushOpenAction        = communicationTemplate.PushOpenAction
            };

            var pushNotificationControl = phPushControl.Controls[0] as PushNotification;

            if (pushNotificationControl != null)
            {
                pushNotificationControl.SetFromCommunication(pushCommunication);
            }
        }
Exemple #17
0
        /// <summary>
        /// Gets the template data.
        /// </summary>
        /// <exception cref="System.Exception">Missing communication template configuration.</exception>
        private bool GetTemplateData()
        {
            if (string.IsNullOrWhiteSpace(GetAttributeValue("PhotoRequestTemplate")))
            {
                nbError.Title   = "Configuration Error";
                nbError.Text    = "Missing communication template configuration.";
                nbError.Visible = true;
                return(false);
            }

            var template = new CommunicationTemplateService(new RockContext()).Get(GetAttributeValue("PhotoRequestTemplate").AsGuid());

            if (template == null)
            {
                nbError.Title   = "Configuration Error";
                nbError.Text    = "The communication template appears to be missing.";
                nbError.Visible = true;
                return(false);
            }

            CommunicationDetails.Copy(template, CommunicationData);

            return(true);
        }
 private static void CreateSupportTicketCommunication(string supportTicketName, string communicationName, CommunicationDetails createCommunicationPayload)
 {
     try
     {
         var rsp = supportClient.Communications.Create(supportTicketName, communicationName, createCommunicationPayload);
         Console.WriteLine(JsonConvert.SerializeObject(rsp, Formatting.Indented));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ERRORMSG);
         Console.WriteLine(JsonConvert.SerializeObject(ex, Formatting.Indented));
     }
 }
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="emailTemplateId">The email template id.</param>
        protected void ShowEdit(int emailTemplateId)
        {
            var globalAttributes = GlobalAttributesCache.Get();

            string globalFromName = globalAttributes.GetValue("OrganizationName");

            tbFromName.Help = string.Format("If a From Name value is not entered the 'Organization Name' Global Attribute value of '{0}' will be used when this template is sent. <small><span class='tip tip-lava'></span></small>", globalFromName);

            string globalFrom = globalAttributes.GetValue("OrganizationEmail");

            tbFrom.Help = string.Format("If a From Address value is not entered the 'Organization Email' Global Attribute value of '{0}' will be used when this template is sent. <small><span class='tip tip-lava'></span></small>", globalFrom);

            tbTo.Help = "You can specify multiple email addresses by separating them with a comma.";

            SystemCommunicationService emailTemplateService = new SystemCommunicationService(new RockContext());
            SystemCommunication        emailTemplate        = emailTemplateService.Get(emailTemplateId);

            bool showMessagePreview = false;

            var pushCommunication = new CommunicationDetails();

            if (emailTemplate != null)
            {
                pdAuditDetails.Visible = true;
                pdAuditDetails.SetEntity(emailTemplate, ResolveRockUrl("~"));

                lActionTitle.Text       = ActionTitle.Edit(SystemCommunication.FriendlyTypeName).FormatAsHtmlTitle();
                hfEmailTemplateId.Value = emailTemplate.Id.ToString();

                cbIsActive.Checked = emailTemplate.IsActive.GetValueOrDefault();
                cpCategory.SetValue(emailTemplate.CategoryId);
                tbTitle.Text         = emailTemplate.Title;
                tbFromName.Text      = emailTemplate.FromName;
                tbFrom.Text          = emailTemplate.From;
                tbTo.Text            = emailTemplate.To;
                tbCc.Text            = emailTemplate.Cc;
                tbBcc.Text           = emailTemplate.Bcc;
                tbSubject.Text       = emailTemplate.Subject;
                ceEmailTemplate.Text = emailTemplate.Body;

                pushCommunication = new CommunicationDetails
                {
                    PushData = emailTemplate.PushData,
                    PushImageBinaryFileId = emailTemplate.PushImageBinaryFileId,
                    PushMessage           = emailTemplate.PushMessage,
                    PushTitle             = emailTemplate.PushTitle,
                    PushOpenMessage       = emailTemplate.PushOpenMessage,
                    PushOpenAction        = emailTemplate.PushOpenAction
                };

                nbTemplateHelp.InnerHtml = CommunicationTemplateHelper.GetTemplateHelp(false);

                kvlMergeFields.Value = emailTemplate.LavaFields.Select(a => string.Format("{0}^{1}", a.Key, a.Value)).ToList().AsDelimited("|");

                hfShowAdditionalFields.Value = (!string.IsNullOrEmpty(emailTemplate.Cc) || !string.IsNullOrEmpty(emailTemplate.Bcc)).ToTrueFalse().ToLower();

                cbCssInliningEnabled.Checked = emailTemplate.CssInliningEnabled;

                showMessagePreview = true;
            }
            else
            {
                pdAuditDetails.Visible  = false;
                lActionTitle.Text       = ActionTitle.Add(SystemCommunication.FriendlyTypeName).FormatAsHtmlTitle();
                hfEmailTemplateId.Value = 0.ToString();

                cbIsActive.Checked = true;
                cpCategory.SetValue(( int? )null);
                tbTitle.Text         = string.Empty;
                tbFromName.Text      = string.Empty;
                tbFrom.Text          = string.Empty;
                tbTo.Text            = string.Empty;
                tbCc.Text            = string.Empty;
                tbBcc.Text           = string.Empty;
                tbSubject.Text       = string.Empty;
                ceEmailTemplate.Text = string.Empty;
            }

            var pushNotificationControl = phPushNotification.Controls[0] as PushNotification;

            if (pushNotificationControl != null)
            {
                pushNotificationControl.SetFromCommunication(pushCommunication);
            }

            SetEmailMessagePreviewModeEnabled(showMessagePreview);

            LoadDropDowns();

            // SMS Fields
            mfpSMSMessage.MergeFields.Clear();
            mfpSMSMessage.MergeFields.Add("GlobalAttribute");
            mfpSMSMessage.MergeFields.Add("Rock.Model.Person");

            if (emailTemplate != null)
            {
                dvpSMSFrom.SetValue(emailTemplate.SMSFromDefinedValueId);
                tbSMSTextMessage.Text = emailTemplate.SMSMessage;
            }
        }
Exemple #20
0
 /// <summary>
 /// Updates the a communication record from control values.
 /// </summary>
 /// <param name="communication">The communication.</param>
 public override void UpdateCommunication(CommunicationDetails communication)
 {
     EnsureChildControls();
     communication.SMSFromDefinedValueId = dvpFrom.SelectedValueAsId();
     communication.SMSMessage            = tbMessage.Text;
 }
Exemple #21
0
        /// <summary>
        /// Adds a new customer communication to an Azure support ticket.
        /// </summary>
        /// <param name='supportTicketName'>
        /// Support ticket name.
        /// </param>
        /// <param name='communicationName'>
        /// Communication name.
        /// </param>
        /// <param name='createCommunicationParameters'>
        /// Communication object.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        public async Task <AzureOperationResponse <CommunicationDetails> > CreateWithHttpMessagesAsync(string supportTicketName, string communicationName, CommunicationDetails createCommunicationParameters, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            // Send Request
            AzureOperationResponse <CommunicationDetails> _response = await BeginCreateWithHttpMessagesAsync(supportTicketName, communicationName, createCommunicationParameters, customHeaders, cancellationToken).ConfigureAwait(false);

            return(await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false));
        }
Exemple #22
0
 /// <summary>
 /// Sets control values from a communication record.
 /// </summary>
 /// <param name="communication">The communication.</param>
 public abstract void SetFromCommunication(CommunicationDetails communication);
Exemple #23
0
 /// <summary>
 /// Updates the a communication record from control values.
 /// </summary>
 /// <param name="communication">The communication.</param>
 public abstract void UpdateCommunication(CommunicationDetails communication);
Exemple #24
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            var rockContext = new RockContext();

            var communicationTemplateService           = new CommunicationTemplateService(rockContext);
            var communicationTemplateAttachmentService = new CommunicationTemplateAttachmentService(rockContext);
            var binaryFileService = new BinaryFileService(rockContext);

            CommunicationTemplate communicationTemplate = null;
            var communicationTemplateId = hfCommunicationTemplateId.Value.AsIntegerOrNull();

            if (communicationTemplateId.HasValue)
            {
                communicationTemplate = communicationTemplateService.Get(communicationTemplateId.Value);
            }

            var newTemplate = false;

            if (communicationTemplate == null)
            {
                newTemplate           = true;
                communicationTemplate = new CommunicationTemplate();
                communicationTemplateService.Add(communicationTemplate);
            }

            communicationTemplate.Name        = tbName.Text;
            communicationTemplate.IsActive    = cbIsActive.Checked;
            communicationTemplate.Description = tbDescription.Text;

            if (communicationTemplate.ImageFileId != imgTemplatePreview.BinaryFileId)
            {
                var oldImageTemplatePreview = binaryFileService.Get(communicationTemplate.ImageFileId ?? 0);
                if (oldImageTemplatePreview != null)
                {
                    // the old image template preview won't be needed anymore, so make it IsTemporary and have it get cleaned up later
                    oldImageTemplatePreview.IsTemporary = true;
                }
            }

            communicationTemplate.ImageFileId = imgTemplatePreview.BinaryFileId;

            // Ensure that the ImagePreview is not set as IsTemporary=True
            if (communicationTemplate.ImageFileId.HasValue)
            {
                var imageTemplatePreview = binaryFileService.Get(communicationTemplate.ImageFileId.Value);
                if (imageTemplatePreview != null && imageTemplatePreview.IsTemporary)
                {
                    imageTemplatePreview.IsTemporary = false;
                }
            }

            // Note: If the Logo has changed, we can't get rid of it since existing communications might use it
            communicationTemplate.LogoBinaryFileId = imgTemplateLogo.BinaryFileId;

            // Ensure that the ImagePreview is not set as IsTemporary=True
            if (communicationTemplate.LogoBinaryFileId.HasValue)
            {
                var newImageTemplateLogo = binaryFileService.Get(communicationTemplate.LogoBinaryFileId.Value);
                if (newImageTemplateLogo != null && newImageTemplateLogo.IsTemporary)
                {
                    newImageTemplateLogo.IsTemporary = false;
                }
            }

            communicationTemplate.FromName           = tbFromName.Text;
            communicationTemplate.FromEmail          = tbFromAddress.Text;
            communicationTemplate.ReplyToEmail       = tbReplyToAddress.Text;
            communicationTemplate.CCEmails           = tbCCList.Text;
            communicationTemplate.BCCEmails          = tbBCCList.Text;
            communicationTemplate.LavaFields         = kvlMergeFields.Value.AsDictionaryOrNull();
            communicationTemplate.CssInliningEnabled = cbCssInliningEnabled.Checked;

            var binaryFileIds = hfAttachedBinaryFileIds.Value.SplitDelimitedValues().AsIntegerList();

            // delete any attachments that are no longer included
            foreach (var attachment in communicationTemplate.Attachments
                     .Where(a => !binaryFileIds.Contains(a.BinaryFileId)).ToList())
            {
                communicationTemplate.Attachments.Remove(attachment);
                communicationTemplateAttachmentService.Delete(attachment);
            }

            // add any new attachments that were added
            foreach (var attachmentBinaryFileId in binaryFileIds.Where(a => communicationTemplate.Attachments.All(x => x.BinaryFileId != a)))
            {
                communicationTemplate.Attachments.Add(new CommunicationTemplateAttachment {
                    BinaryFileId = attachmentBinaryFileId, CommunicationType = CommunicationType.Email
                });
            }

            communicationTemplate.Subject = tbEmailSubject.Text;
            communicationTemplate.Message = ceEmailTemplate.Text;

            communicationTemplate.SMSFromDefinedValueId = dvpSMSFrom.SelectedValue.AsIntegerOrNull();
            communicationTemplate.SMSMessage            = tbSMSTextMessage.Text;

            communicationTemplate.CategoryId = cpCategory.SelectedValueAsInt();

            var pushCommunication       = new CommunicationDetails();
            var pushNotificationControl = phPushNotification.Controls[0] as PushNotification;

            if (pushNotificationControl != null)
            {
                pushNotificationControl.UpdateCommunication(pushCommunication);
            }

            communicationTemplate.PushData = pushCommunication.PushData;
            communicationTemplate.PushImageBinaryFileId = pushCommunication.PushImageBinaryFileId;
            communicationTemplate.PushMessage           = pushCommunication.PushMessage;
            communicationTemplate.PushOpenAction        = pushCommunication.PushOpenAction;
            communicationTemplate.PushOpenMessage       = pushCommunication.PushOpenMessage;
            communicationTemplate.PushTitle             = pushCommunication.PushTitle;

            rockContext.SaveChanges();

            var personalView = GetAttributeValue(AttributeKey.PersonalTemplatesView).AsBoolean();

            if (newTemplate)
            {
                communicationTemplate = communicationTemplateService.Get(communicationTemplate.Id);
                if (communicationTemplate != null)
                {
                    if (personalView)
                    {
                        // If editing personal templates, make the new template is private/personal to current user
                        communicationTemplate.MakePrivate(Authorization.VIEW, CurrentPerson);
                        communicationTemplate.MakePrivate(Authorization.EDIT, CurrentPerson);
                        communicationTemplate.MakePrivate(Authorization.ADMINISTRATE, CurrentPerson);
                    }
                    else
                    {
                        // Otherwise, make sure user can view and edit the new template.
                        if (!communicationTemplate.IsAuthorized(Authorization.VIEW, CurrentPerson))
                        {
                            communicationTemplate.AllowPerson(Authorization.VIEW, CurrentPerson);
                        }

                        // Make sure user can edit the new template.
                        if (!communicationTemplate.IsAuthorized(Authorization.EDIT, CurrentPerson))
                        {
                            communicationTemplate.AllowPerson(Authorization.EDIT, CurrentPerson);
                        }
                    }

                    // Always make sure RSR-Admin and Communication Admin can see
                    var groupService = new GroupService(rockContext);
                    var communicationAdministrators = groupService.Get(Rock.SystemGuid.Group.GROUP_COMMUNICATION_ADMINISTRATORS.AsGuid());
                    if (communicationAdministrators != null)
                    {
                        communicationTemplate.AllowSecurityRole(Authorization.VIEW, communicationAdministrators, rockContext);
                        communicationTemplate.AllowSecurityRole(Authorization.EDIT, communicationAdministrators, rockContext);
                        communicationTemplate.AllowSecurityRole(Authorization.ADMINISTRATE, communicationAdministrators, rockContext);
                    }

                    var rockAdministrators = groupService.Get(Rock.SystemGuid.Group.GROUP_ADMINISTRATORS.AsGuid());
                    if (rockAdministrators != null)
                    {
                        communicationTemplate.AllowSecurityRole(Authorization.VIEW, rockAdministrators, rockContext);
                        communicationTemplate.AllowSecurityRole(Authorization.EDIT, rockAdministrators, rockContext);
                        communicationTemplate.AllowSecurityRole(Authorization.ADMINISTRATE, rockAdministrators, rockContext);
                    }
                }
            }

            NavigateToParentPage();
        }
Exemple #25
0
        /// <summary>
        /// Adds a new customer communication to an Azure support ticket.
        /// </summary>
        /// <param name='supportTicketName'>
        /// Support ticket name.
        /// </param>
        /// <param name='communicationName'>
        /// Communication name.
        /// </param>
        /// <param name='createCommunicationParameters'>
        /// Communication object.
        /// </param>
        /// <param name='customHeaders'>
        /// Headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ExceptionResponseException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <return>
        /// A response object containing the response body and response headers.
        /// </return>
        public async Task <AzureOperationResponse <CommunicationDetails> > BeginCreateWithHttpMessagesAsync(string supportTicketName, string communicationName, CommunicationDetails createCommunicationParameters, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (supportTicketName == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "supportTicketName");
            }
            if (communicationName == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "communicationName");
            }
            if (createCommunicationParameters == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "createCommunicationParameters");
            }
            if (createCommunicationParameters != null)
            {
                createCommunicationParameters.Validate();
            }
            if (Client.SubscriptionId == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
            }
            if (Client.ApiVersion == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
            }
            // Tracing
            bool   _shouldTrace  = ServiceClientTracing.IsEnabled;
            string _invocationId = null;

            if (_shouldTrace)
            {
                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("supportTicketName", supportTicketName);
                tracingParameters.Add("communicationName", communicationName);
                tracingParameters.Add("createCommunicationParameters", createCommunicationParameters);
                tracingParameters.Add("cancellationToken", cancellationToken);
                ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters);
            }
            // Construct URL
            var _baseUrl = Client.BaseUri.AbsoluteUri;
            var _url     = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications/{communicationName}").ToString();

            _url = _url.Replace("{supportTicketName}", System.Uri.EscapeDataString(supportTicketName));
            _url = _url.Replace("{communicationName}", System.Uri.EscapeDataString(communicationName));
            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
            List <string> _queryParameters = new List <string>();

            if (Client.ApiVersion != null)
            {
                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
            }
            if (_queryParameters.Count > 0)
            {
                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
            }
            // Create HTTP transport objects
            var _httpRequest = new HttpRequestMessage();
            HttpResponseMessage _httpResponse = null;

            _httpRequest.Method     = new HttpMethod("PUT");
            _httpRequest.RequestUri = new System.Uri(_url);
            // Set Headers
            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
            {
                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
            }
            if (Client.AcceptLanguage != null)
            {
                if (_httpRequest.Headers.Contains("accept-language"))
                {
                    _httpRequest.Headers.Remove("accept-language");
                }
                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
            }


            if (customHeaders != null)
            {
                foreach (var _header in customHeaders)
                {
                    if (_httpRequest.Headers.Contains(_header.Key))
                    {
                        _httpRequest.Headers.Remove(_header.Key);
                    }
                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
                }
            }

            // Serialize Request
            string _requestContent = null;

            if (createCommunicationParameters != null)
            {
                _requestContent      = Rest.Serialization.SafeJsonConvert.SerializeObject(createCommunicationParameters, Client.SerializationSettings);
                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
                _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
            }
            // Set Credentials
            if (Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
            }
            // Send Request
            if (_shouldTrace)
            {
                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);

            if (_shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
            }
            HttpStatusCode _statusCode = _httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string _responseContent = null;

            if ((int)_statusCode != 200 && (int)_statusCode != 202)
            {
                var ex = new ExceptionResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
                try
                {
                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                    ExceptionResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject <ExceptionResponse>(_responseContent, Client.DeserializationSettings);
                    if (_errorBody != null)
                    {
                        ex.Body = _errorBody;
                    }
                }
                catch (JsonException)
                {
                    // Ignore the exception
                }
                ex.Request  = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
                if (_shouldTrace)
                {
                    ServiceClientTracing.Error(_invocationId, ex);
                }
                _httpRequest.Dispose();
                if (_httpResponse != null)
                {
                    _httpResponse.Dispose();
                }
                throw ex;
            }
            // Create Result
            var _result = new AzureOperationResponse <CommunicationDetails>();

            _result.Request  = _httpRequest;
            _result.Response = _httpResponse;
            if (_httpResponse.Headers.Contains("x-ms-request-id"))
            {
                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
            }
            // Deserialize Response
            if ((int)_statusCode == 200)
            {
                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                try
                {
                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <CommunicationDetails>(_responseContent, Client.DeserializationSettings);
                }
                catch (JsonException ex)
                {
                    _httpRequest.Dispose();
                    if (_httpResponse != null)
                    {
                        _httpResponse.Dispose();
                    }
                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
                }
            }
            if (_shouldTrace)
            {
                ServiceClientTracing.Exit(_invocationId, _result);
            }
            return(_result);
        }
Exemple #26
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="templateId">The template identifier.</param>
        private void ShowDetail(int templateId)
        {
            CommunicationTemplate communicationTemplate = null;
            var newTemplate       = false;
            var pushCommunication = new CommunicationDetails();

            if (!templateId.Equals(0))
            {
                communicationTemplate = new CommunicationTemplateService(new RockContext()).Get(templateId);
                if (communicationTemplate != null)
                {
                    lTitle.Text = communicationTemplate.Name.FormatAsHtmlTitle();
                    pdAuditDetails.SetEntity(communicationTemplate, ResolveRockUrl("~"));
                }

                pushCommunication = new CommunicationDetails
                {
                    PushData = communicationTemplate.PushData,
                    PushImageBinaryFileId = communicationTemplate.PushImageBinaryFileId,
                    PushMessage           = communicationTemplate.PushMessage,
                    PushTitle             = communicationTemplate.PushTitle,
                    PushOpenMessage       = communicationTemplate.PushOpenMessage,
                    PushOpenAction        = communicationTemplate.PushOpenAction
                };
            }

            if (communicationTemplate == null)
            {
                RockPage.PageTitle    = "New Communication Template";
                lTitle.Text           = "New Communication Template".FormatAsHtmlTitle();
                communicationTemplate = new CommunicationTemplate();
                newTemplate           = true;
            }

            LoadDropDowns();

            mfpSMSMessage.MergeFields.Clear();
            mfpSMSMessage.MergeFields.Add("GlobalAttribute");
            mfpSMSMessage.MergeFields.Add("Rock.Model.Person");

            hfCommunicationTemplateId.Value = templateId.ToString();

            tbName.Text        = communicationTemplate.Name;
            cbIsActive.Checked = communicationTemplate.IsActive;
            tbDescription.Text = communicationTemplate.Description;
            cpCategory.SetValue(communicationTemplate.CategoryId);

            imgTemplatePreview.BinaryFileId = communicationTemplate.ImageFileId;
            imgTemplateLogo.BinaryFileId    = communicationTemplate.LogoBinaryFileId;

            // Email Fields
            tbFromName.Text    = communicationTemplate.FromName;
            tbFromAddress.Text = communicationTemplate.FromEmail;

            tbReplyToAddress.Text        = communicationTemplate.ReplyToEmail;
            tbCCList.Text                = communicationTemplate.CCEmails;
            tbBCCList.Text               = communicationTemplate.BCCEmails;
            cbCssInliningEnabled.Checked = communicationTemplate.CssInliningEnabled;
            kvlMergeFields.Value         = communicationTemplate.LavaFields.Select(a => string.Format("{0}^{1}", a.Key, a.Value)).ToList().AsDelimited("|");

            hfShowAdditionalFields.Value = (!string.IsNullOrEmpty(communicationTemplate.ReplyToEmail) || !string.IsNullOrEmpty(communicationTemplate.CCEmails) || !string.IsNullOrEmpty(communicationTemplate.BCCEmails)).ToTrueFalse().ToLower();

            tbEmailSubject.Text = communicationTemplate.Subject;

            nbTemplateHelp.InnerHtml = CommunicationTemplateHelper.GetTemplateHelp(true);
            ceEmailTemplate.Text     = communicationTemplate.Message;

            hfAttachedBinaryFileIds.Value = communicationTemplate.Attachments.Select(a => a.BinaryFileId).ToList().AsDelimited(",");
            UpdateAttachedFiles(false);

            // SMS Fields
            dvpSMSFrom.SetValue(communicationTemplate.SMSFromDefinedValueId);
            tbSMSTextMessage.Text = communicationTemplate.SMSMessage;

            // render UI based on Authorized and IsSystem
            var readOnly       = false;
            var restrictedEdit = false;

            if (!newTemplate && !communicationTemplate.IsAuthorized(Authorization.EDIT, CurrentPerson))
            {
                restrictedEdit            = true;
                readOnly                  = true;
                nbEditModeMessage.Text    = EditModeMessage.NotAuthorizedToEdit(CommunicationTemplate.FriendlyTypeName);
                nbEditModeMessage.Visible = true;
            }

            if (communicationTemplate.IsSystem)
            {
                restrictedEdit            = true;
                nbEditModeMessage.Text    = EditModeMessage.System(CommunicationTemplate.FriendlyTypeName);
                nbEditModeMessage.Visible = true;
            }

            tbName.ReadOnly    = restrictedEdit;
            cbIsActive.Enabled = !restrictedEdit;

            tbFromName.ReadOnly               = restrictedEdit;
            tbName.ReadOnly                   = restrictedEdit;
            tbFromAddress.ReadOnly            = restrictedEdit;
            tbReplyToAddress.ReadOnly         = restrictedEdit;
            tbCCList.ReadOnly                 = restrictedEdit;
            tbBCCList.ReadOnly                = restrictedEdit;
            tbEmailSubject.ReadOnly           = restrictedEdit;
            fupAttachments.Visible            = !restrictedEdit;
            fupAttachments.BinaryFileTypeGuid = this.GetAttributeValue(AttributeKey.AttachmentBinaryFileType).AsGuidOrNull() ?? Rock.SystemGuid.BinaryFiletype.DEFAULT.AsGuid();
            // Allow these to be Editable if they are IsSystem, but not if they don't have EDIT Auth
            tbDescription.ReadOnly     = readOnly;
            imgTemplatePreview.Enabled = !readOnly;
            ceEmailTemplate.ReadOnly   = readOnly;

            mfpSMSMessage.Visible     = !restrictedEdit;
            dvpSMSFrom.Enabled        = !restrictedEdit;
            tbSMSTextMessage.ReadOnly = restrictedEdit;
            ceEmailTemplate.ReadOnly  = restrictedEdit;

            btnSave.Enabled = !readOnly;

            tglPreviewAdvanced.Checked = true;

            var pushNotificationControl = phPushNotification.Controls[0] as PushNotification;

            if (pushNotificationControl != null)
            {
                pushNotificationControl.SetFromCommunication(pushCommunication);
            }

            SetEmailMessagePreviewModeEnabled(tglPreviewAdvanced.Checked);
        }
Exemple #27
0
 /// <summary>
 /// Sets control values from a communication record.
 /// </summary>
 /// <param name="communication">The communication.</param>
 public override void SetFromCommunication(CommunicationDetails communication)
 {
     EnsureChildControls();
     ddlFrom.SetValue(communication.SMSFromDefinedValueId);
     tbMessage.Text = communication.SMSMessage;
 }
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var rockContext = new RockContext();

            SystemCommunicationService emailTemplateService = new SystemCommunicationService(rockContext);
            SystemCommunication        emailTemplate;

            int emailTemplateId = int.Parse(hfEmailTemplateId.Value);

            if (emailTemplateId == 0)
            {
                emailTemplate = new SystemCommunication();
                emailTemplateService.Add(emailTemplate);
            }
            else
            {
                emailTemplate = emailTemplateService.Get(emailTemplateId);
            }

            emailTemplate.IsActive           = cbIsActive.Checked;
            emailTemplate.CategoryId         = cpCategory.SelectedValueAsInt();
            emailTemplate.Title              = tbTitle.Text;
            emailTemplate.FromName           = tbFromName.Text;
            emailTemplate.From               = tbFrom.Text;
            emailTemplate.To                 = tbTo.Text;
            emailTemplate.Cc                 = tbCc.Text;
            emailTemplate.Bcc                = tbBcc.Text;
            emailTemplate.Subject            = tbSubject.Text;
            emailTemplate.Body               = ceEmailTemplate.Text;
            emailTemplate.LavaFields         = kvlMergeFields.Value.AsDictionaryOrNull();
            emailTemplate.CssInliningEnabled = cbCssInliningEnabled.Checked;

            emailTemplate.SMSFromDefinedValueId = dvpSMSFrom.SelectedValue.AsIntegerOrNull();
            emailTemplate.SMSMessage            = tbSMSTextMessage.Text;

            var pushCommunication       = new CommunicationDetails();
            var pushNotificationControl = phPushNotification.Controls[0] as PushNotification;

            if (pushNotificationControl != null)
            {
                pushNotificationControl.UpdateCommunication(pushCommunication);
            }

            emailTemplate.PushData = pushCommunication.PushData;
            emailTemplate.PushImageBinaryFileId = pushCommunication.PushImageBinaryFileId;
            emailTemplate.PushMessage           = pushCommunication.PushMessage;
            emailTemplate.PushOpenAction        = pushCommunication.PushOpenAction;
            emailTemplate.PushOpenMessage       = pushCommunication.PushOpenMessage;
            emailTemplate.PushTitle             = pushCommunication.PushTitle;

            if (!emailTemplate.IsValid)
            {
                // If CodeEditor is hidden, we need to manually add the Required error message or it will not be shown.
                if (string.IsNullOrWhiteSpace(ceEmailTemplate.Text) && !ceEmailTemplate.Visible)
                {
                    var customValidator = new CustomValidator();

                    customValidator.ValidationGroup   = ceEmailTemplate.ValidationGroup;
                    customValidator.ControlToValidate = ceEmailTemplate.ID;
                    customValidator.ErrorMessage      = "Email Message Body is required.";
                    customValidator.IsValid           = false;

                    Page.Validators.Add(customValidator);
                }

                // Controls will render the error messages
                return;
            }

            rockContext.SaveChanges();

            NavigateToParentPage();
        }
 /// <summary>
 /// Adds a new customer communication to an Azure support ticket. Adding
 /// attachments are not currently supported via the API. &lt;br/&gt;To add a
 /// file to a support ticket, visit the &lt;a target='_blank'
 /// href='https://portal.azure.com/#blade/Microsoft_Azure_Support/HelpAndSupportBlade/managesupportrequest'&gt;Manage
 /// support ticket&lt;/a&gt; page in the Azure portal, select the support
 /// ticket, and use the file upload control to add a new file.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='supportTicketName'>
 /// Support ticket name
 /// </param>
 /// <param name='communicationName'>
 /// Communication name
 /// </param>
 /// <param name='createCommunicationParameters'>
 /// Communication object
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <CommunicationDetails> BeginCreateAsync(this ICommunicationsOperations operations, string supportTicketName, string communicationName, CommunicationDetails createCommunicationParameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateWithHttpMessagesAsync(supportTicketName, communicationName, createCommunicationParameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Adds a new customer communication to an Azure support ticket. Adding
 /// attachments are not currently supported via the API. &lt;br/&gt;To add a
 /// file to a support ticket, visit the &lt;a target='_blank'
 /// href='https://portal.azure.com/#blade/Microsoft_Azure_Support/HelpAndSupportBlade/managesupportrequest'&gt;Manage
 /// support ticket&lt;/a&gt; page in the Azure portal, select the support
 /// ticket, and use the file upload control to add a new file.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='supportTicketName'>
 /// Support ticket name
 /// </param>
 /// <param name='communicationName'>
 /// Communication name
 /// </param>
 /// <param name='createCommunicationParameters'>
 /// Communication object
 /// </param>
 public static CommunicationDetails BeginCreate(this ICommunicationsOperations operations, string supportTicketName, string communicationName, CommunicationDetails createCommunicationParameters)
 {
     return(operations.BeginCreateAsync(supportTicketName, communicationName, createCommunicationParameters).GetAwaiter().GetResult());
 }