/// <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);
            }
        }
Example #2
0
    HttpResponseMessage ImportBlogML()
    {
        HttpPostedFile file = HttpContext.Current.Request.Files[0];
        if (file != null && file.ContentLength > 0)
        {
            var reader = new BlogReader();
            var rdr = new StreamReader(file.InputStream);
            reader.XmlData = rdr.ReadToEnd();

            if (reader.Import())
            {
                return Request.CreateResponse(HttpStatusCode.OK);
            }
        }
        return Request.CreateResponse(HttpStatusCode.InternalServerError);
    }
    HttpResponseMessage ImportBlogML()
    {
        try
        {
            HttpPostedFile file = HttpContext.Current.Request.Files[0];
            if (file != null && file.ContentLength > 0)
            {
                var reader = new BlogReader();
                var rdr = new StreamReader(file.InputStream);
                reader.XmlData = rdr.ReadToEnd();

                if (reader.Import())
                {
                    return Request.CreateResponse(HttpStatusCode.OK);
                }
            }
        }
        catch (Exception exception)
        {
            RDN.Library.Classes.Error.ErrorDatabaseManager.AddException(exception, exception.GetType());
        }
        return Request.CreateResponse(HttpStatusCode.InternalServerError);
    }