/BlogEngine/BlogEngine.NET/admin/Settings/Import.aspx.cs
# · C# · 50 lines · 37 code · 7 blank · 6 comment · 2 complexity · 7f43da74015bc81a67f50a963c0e5cbb MD5 · raw file
- namespace admin.Settings
- {
- using System;
- using System.IO;
- using BlogEngine.Core.API.BlogML;
- using App_Code;
-
- public partial class Import : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- WebUtils.CheckRightsForAdminSettingsPage(false);
- }
-
- /// <summary>
- /// Handles the Click event of the btnBlogMLImport control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
- protected void BtnBlogMlImportClick(object sender, EventArgs e)
- {
- var fileName = txtUploadFile.FileName;
-
- if (string.IsNullOrEmpty(fileName))
- {
- //this.Master.SetStatus("warning", "File name is required");
- }
- else
- {
- var reader = new BlogReader();
-
- var stm = txtUploadFile.FileContent;
- var rdr = new StreamReader(stm);
- reader.XmlData = rdr.ReadToEnd();
-
- string tmpl = "<script language=\"JavaScript\">ShowStatus('{0}', '{1}');</script>";
-
- if(reader.Import())
- {
- tmpl = string.Format(tmpl, "success", reader.Message);
- }else
- {
- tmpl = string.Format(tmpl, "warning", reader.Message.Replace("'", "`").Replace("\"", "`").Replace(Environment.NewLine, " "));
- }
-
- ClientScript.RegisterStartupScript(this.GetType(), "ImportDone", tmpl);
- }
- }
- }
- }