示例#1
0
        public static string ReplaceCandidateWildCards(this string rtf, Candidate candidate, bool blEncodeRtf)
        {
            CrossThreadUtility.InvokeControlAction <RichTextBox>(m_rtb, t =>
            {
                if (blEncodeRtf)
                {
                    t.Clear();

                    m_rtb.Rtf = rtf;

                    ReplaceWildCard(@"{FIRSTNAME}", candidate.FirstName);
                    ReplaceWildCard(@"{LASTNAME}", candidate.LastName);
                    ReplaceWildCard(@"{EMAIL}", candidate.EMailAddress);
                    ReplaceWildCard(@"{MOBILE}", candidate.Mobile);
                    ReplaceWildCard(@"{PHONE}", candidate.Phone);
                    ReplaceWildCard(@"{CANDIDATENUMBER}", candidate.CandidateNumber.Value.ToString());


                    rtf = m_rtb.Rtf;
                }
                else
                {
                    rtf = Regex.Replace(rtf, @"(\{)(FIRSTNAME)(\})", candidate.FirstName ?? string.Empty);
                    rtf = Regex.Replace(rtf, @"(\{)(LASTNAME)(\})", candidate.LastName ?? string.Empty);
                    rtf = Regex.Replace(rtf, @"(\{)(EMAIL)(\})", candidate.EMailAddress ?? string.Empty);
                    rtf = Regex.Replace(rtf, @"(\{)(MOBILE)(\})", candidate.Mobile ?? string.Empty);
                    rtf = Regex.Replace(rtf, @"(\{)(PHONE)(\})", candidate.Phone ?? string.Empty);
                    rtf = Regex.Replace(rtf, @"(\{)(CANDIDATENUMBER)(\})", candidate.CandidateNumber.Value.ToString());
                }
            });

            return(rtf);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            panelWait.Visible = true;
            button1.Enabled   = false;
            button2.Enabled   = false;

            var insertWorker = new BackgroundWorker();

            short index = 0;

            //fix index
            foreach (MailTemplate tmpl in m_bindingList)
            {
                index++;
                tmpl.TemplateIndex = index;
            }

            insertWorker.RunWorkerCompleted += (senders, es) =>
            {
                CrossThreadUtility.InvokeControlAction <Panel>(panelWait, panel => panel.Visible = false);
            };

            insertWorker.DoWork += (senders, es) =>
            {
                try
                {
                    if (!es.Cancel)
                    {
                        ServiceHelper.Add(listBox1.DataSource as IEnumerable <MailTemplate>);

                        CrossThreadUtility.InvokeControlAction <Form>(this, f => f.Close());

                        //add new template
                        m_mainRegion.MailTemplates = new List <MailTemplate>(listBox1.DataSource as IEnumerable <MailTemplate>);
                    }
                }
                finally
                {
                }
            };

            insertWorker.RunWorkerAsync();
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            panelWait.Visible = true;
            button1.Enabled   = false;
            button2.Enabled   = false;

            Properties.Settings.Default.PageSize         = Convert.ToInt32(udPageSize.Value);
            Properties.Settings.Default.UseProxy         = cbUseProxy.Checked;
            Properties.Settings.Default.ProxyAddress     = tbProxyAddress.Text;
            Properties.Settings.Default.ProxyPort        = int.Parse(tbProxyPort.Text);
            Properties.Settings.Default.AddMSCompanyLogo = cbAddMSCompanyLogo.Checked;
            Properties.Settings.Default.MSLogoFilePath   = tbMSLogoFilePath.Text;

            Properties.Settings.Default.Save();

            string xml = populateSettingsXml();

            var saveWorker = new BackgroundWorker();

            saveWorker.RunWorkerCompleted += (senders, es) =>
            {
                CrossThreadUtility.InvokeControlAction <Form>(this, f => f.Close());
            };

            saveWorker.DoWork += (senders, es) =>
            {
                try
                {
                    if (!es.Cancel)
                    {
                        ServiceHelper.Update(new Settings
                        {
                            Xml = xml
                        });
                    }
                }
                finally
                {
                }
            };

            saveWorker.RunWorkerAsync();
        }