protected void Page_Load(object sender, EventArgs e) { var sp1 = new StaticPage(); var cache = new CacheManager<StaticPage>("PigeonCms.StaticPage", this.CacheDuration); if (cache.IsEmpty(this.PageName)) { if (!StaticPagesManager.ExistPage(this.PageName)) this.PageName = StaticPagesManager.DEFAULT_PAGE_NAME; sp1 = new StaticPagesManager().GetStaticPageByName(this.PageName); cache.Insert(this.PageName, sp1); } else { sp1 = cache.GetValue(this.PageName); } if (sp1.ShowPageTitle) LitPageTitle.Text = sp1.PageTitle + "<br />"; LitPageContent.Text = ""; if (!sp1.IsPageContentTranslated) { //LitPageContent.Text += "<span class='textNote'>" + Resources.PublicLabels.LblTextNotTranslated + "</span><br />"; } LitPageContent.Text += sp1.PageContentParsed; }
private bool saveForm() { bool res = false; LblErr.Text = ""; LblOk.Text = ""; try { StaticPage p1 = new StaticPage(); if (TxtId.Text == string.Empty) { form2obj(p1); p1 = new StaticPagesManager().Insert(p1); } else { p1 = new StaticPagesManager().GetStaticPageByName(TxtPageName.Text);//precarico i campi esistenti e nn gestiti dal form form2obj(p1); new StaticPagesManager().Update(p1); } new CacheManager<StaticPage>("PigeonCms.StaticPage").Remove(p1.PageName); Grid1.DataBind(); LblOk.Text = RenderSuccess(Utility.GetLabel("RECORD_SAVED_MSG")); res = true; } catch (Exception e1) { LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString()); } finally { } return res; }
private void editPage(string pageName) { LblOk.Text = ""; LblErr.Text = ""; TxtPageName.Text = pageName; TxtPageName.Enabled = true; TxtId.Text = ""; ChkShowPageTitle.Checked = true; foreach (KeyValuePair<string, string> item in Config.CultureList) { TextBox t1 = new TextBox(); t1 = (TextBox)PanelPageTitle.FindControl("TxtPageTitle" + item.Value); t1.Text = ""; var html1 = new Controls_ContentEditorControl(); html1 = Utility.FindControlRecursive<Controls_ContentEditorControl>(this, "HtmlText" + item.Value); html1.Text = ""; } if (pageName != "") { TxtId.Text = "1"; TxtPageName.Enabled = false; StaticPage currPage = new StaticPage(); currPage = new StaticPagesManager().GetStaticPageByName(pageName); obj2form(currPage); } MultiView1.ActiveViewIndex = 1; }
private void sendNotificationEmail(string username, string pwd, string toEmail, string userEmail) { var emailPage = new StaticPage(); if (string.IsNullOrEmpty(base.NotificationEmailPageName)) return; try { emailPage = new StaticPagesManager().GetStaticPageByName(base.NotificationEmailPageName); if (string.IsNullOrEmpty(emailPage.PageName)) throw new ArgumentException("invalid NotificationEmailPageName"); var smtp = new SmtpClient(AppSettingsManager.GetValue("SmtpServer")); using (smtp as IDisposable) { smtp.EnableSsl = false; if (!string.IsNullOrEmpty(AppSettingsManager.GetValue("SmtpUseSSL"))) { bool useSsl = false; bool.TryParse(AppSettingsManager.GetValue("SmtpUseSSL"), out useSsl); smtp.EnableSsl = useSsl; } if (!string.IsNullOrEmpty(AppSettingsManager.GetValue("SmtpPort"))) { int port = 25; int.TryParse(AppSettingsManager.GetValue("SmtpPort"), out port); smtp.Port = port; } if (!string.IsNullOrEmpty(AppSettingsManager.GetValue("SmtpUser"))) { smtp.Credentials = new NetworkCredential( AppSettingsManager.GetValue("SmtpUser"), AppSettingsManager.GetValue("SmtpPassword")); } MailMessage mail1 = new MailMessage(); mail1.From = new MailAddress(AppSettingsManager.GetValue("EmailSender")); mail1.To.Add(toEmail); //mail1.Bcc = this.EmailAddressBcc; //debug controllo formato email mail1.Subject = emailPage.PageTitle; mail1.IsBodyHtml = true; //available placeholders [[NewUsername]],[[NewUserPassword]],[[NewUserEmail]] mail1.Body = emailPage.PageContent .Replace("[[NewUsername]]", username) .Replace("[[NewUserPassword]]", pwd) .Replace("[[NewUserEmail]]", userEmail); smtp.Send(mail1); } } catch (Exception e1) { LogProvider.Write(this.BaseModule, "sendNotificationEmail("+ username +",,"+ toEmail +","+ userEmail +") failed: " +e1.ToString(), TracerItemType.Error); Tracer.Log("sendNotificationEmail() failed " + e1.ToString(), TracerItemType.Error); } }