Ejemplo n.º 1
0
        /// <summary>
        /// Save Nexmo Settings and MailChimp Settings in settings.xml
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                if (ValidateFields())
                {
                    XmlDocument doc = new XmlDocument();

                    XmlElement settings = doc.CreateElement(string.Empty, "settings", string.Empty);
                    doc.AppendChild(settings);

                    XmlElement nexmo = doc.CreateElement(string.Empty, "nexmo", string.Empty);
                    settings.AppendChild(nexmo);

                    XmlElement api      = doc.CreateElement(string.Empty, "api", string.Empty);
                    XmlText    nexmoApi = doc.CreateTextNode(txtNexmoAPI.Text.Trim().ToString());
                    api.AppendChild(nexmoApi);
                    nexmo.AppendChild(api);

                    XmlElement secretKey = doc.CreateElement(string.Empty, "secret-key", string.Empty);
                    XmlText    key       = doc.CreateTextNode(txtNexmoSecretKey.Text.Trim().ToString());
                    secretKey.AppendChild(key);
                    nexmo.AppendChild(secretKey);

                    XmlElement fromNumber = doc.CreateElement(string.Empty, "from-number", string.Empty);
                    XmlText    number     = doc.CreateTextNode(FromNumber.Trim().ToString());
                    fromNumber.AppendChild(number);
                    nexmo.AppendChild(fromNumber);


                    //--MailChimp
                    XmlElement mailchimp = doc.CreateElement(string.Empty, "mailchimp", string.Empty);
                    settings.AppendChild(mailchimp);

                    XmlElement mailchimpAPI = doc.CreateElement(string.Empty, "api", string.Empty);
                    XmlText    apitext      = doc.CreateTextNode(txtMailChimpAPI.Text.Trim().ToString());
                    mailchimpAPI.AppendChild(apitext);
                    mailchimp.AppendChild(mailchimpAPI);

                    doc.Save(FileName);

                    System.Security.AccessControl.FileSecurity fsec = System.IO.File.GetAccessControl(FileName);
                    fsec.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule("Everyone", System.Security.AccessControl.FileSystemRights.Modify, System.Security.AccessControl.AccessControlType.Allow));
                    System.IO.File.SetAccessControl(FileName, fsec);
                    MailChimpCampaign nexmoForm = new MailChimpCampaign();
                    nexmoForm.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Open MailChimpCampaign form
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnCancel_Click(object sender, EventArgs e)
 {
     if (!ValidateXMLSettings())
     {
         this.Close();
     }
     else
     {
         Cursor.Current = Cursors.WaitCursor;
         try
         {
             MailChimpCampaign nexmoForm = new MailChimpCampaign();
             nexmoForm.ShowDialog();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             Cursor.Current = Cursors.Default;
         }
     }
 }
        /// <summary>
        /// Save Nexmo Settings and MailChimp Settings in settings.xml
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                if (ValidateFields())
                {
                    XmlDocument doc = new XmlDocument();

                    XmlElement settings = doc.CreateElement(string.Empty, "settings", string.Empty);
                    doc.AppendChild(settings);

                    XmlElement nexmo = doc.CreateElement(string.Empty, "nexmo", string.Empty);
                    settings.AppendChild(nexmo);

                    XmlElement api = doc.CreateElement(string.Empty, "api", string.Empty);
                    XmlText nexmoApi = doc.CreateTextNode(txtNexmoAPI.Text.Trim().ToString());
                    api.AppendChild(nexmoApi);
                    nexmo.AppendChild(api);

                    XmlElement secretKey = doc.CreateElement(string.Empty, "secret-key", string.Empty);
                    XmlText key = doc.CreateTextNode(txtNexmoSecretKey.Text.Trim().ToString());
                    secretKey.AppendChild(key);
                    nexmo.AppendChild(secretKey);

                    XmlElement fromNumber = doc.CreateElement(string.Empty, "from-number", string.Empty);
                    XmlText number = doc.CreateTextNode(FromNumber.Trim().ToString());
                    fromNumber.AppendChild(number);
                    nexmo.AppendChild(fromNumber);


                    //--MailChimp
                    XmlElement mailchimp = doc.CreateElement(string.Empty, "mailchimp", string.Empty);
                    settings.AppendChild(mailchimp);

                    XmlElement mailchimpAPI = doc.CreateElement(string.Empty, "api", string.Empty);
                    XmlText apitext = doc.CreateTextNode(txtMailChimpAPI.Text.Trim().ToString());
                    mailchimpAPI.AppendChild(apitext);
                    mailchimp.AppendChild(mailchimpAPI);

                    doc.Save(FileName);

                    System.Security.AccessControl.FileSecurity fsec = System.IO.File.GetAccessControl(FileName);
                    fsec.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule("Everyone", System.Security.AccessControl.FileSystemRights.Modify, System.Security.AccessControl.AccessControlType.Allow));
                    System.IO.File.SetAccessControl(FileName, fsec);
                    MailChimpCampaign nexmoForm = new MailChimpCampaign();
                    nexmoForm.ShowDialog();

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;

            }
        }
        /// <summary>
        /// Open MailChimpCampaign form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            if (!ValidateXMLSettings())
            {
                this.Close();
            }
            else
            {
                Cursor.Current = Cursors.WaitCursor;
                try
                {
                    MailChimpCampaign nexmoForm = new MailChimpCampaign();
                    nexmoForm.ShowDialog();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }

        }