Beispiel #1
0
        /// <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);
            }
        }
    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));
    }
Beispiel #3
0
        public ActionResult Index()
        {
            var blogUrl       = new Uri(ConfigurationManager.AppSettings["blogRssUrl"]);
            var accessLogPath = ConfigurationManager.AppSettings["accessLog"];
            var teamCityUrl   = ConfigurationManager.AppSettings["teamCityUrl"];

            var blogReader      = new BlogReader(blogUrl);
            var accessLogReader = new AccessLogReader(accessLogPath);
            var buildMonitor    = new TeamCityBuildMonitor(teamCityUrl);

            var viewModel = new HomeViewModel
            {
                BlogItems      = blogReader.GetSummaryOfLatest(5),
                LatestVisitors = accessLogReader.GetLastVisitors(5),
                BuildStatus    = buildMonitor.GetSummary()
            };

            return(View(viewModel));
        }