Exemple #1
0
        public ActionResult PostPublish(PublishModels model, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View("Publish", model));
            }

            //图片不超过20M
            if (file == null && file.ContentLength > 1024 * 1024 * 20)
            {
                ModelState.AddModelError("", "请上传规定大小的图片");
                return(View("Publish", model));
            }

            //验证通过后
            Activity act = new Activity
            {
                ActID      = Guid.NewGuid(),
                OrgID      = new Guid(Session["OrgID"].ToString()),
                ActName    = model.ActName,
                Place      = model.Place,
                Class1     = model.Class1,
                Class2     = model.Class2,
                BeginTime  = model.BeginTime,
                EndTime    = model.EndTime,
                ActIntro   = model.ActIntro,
                MoneyState = model.Money.Equals("yes") ? 1 : 0,
                ScoreState = model.Score.Equals("yes") ? 1 : 0,
                AwardState = model.Award.Equals("yes") ? 1 : 0,
                VoteState  = model.Vote.Equals("yes") ? 1 : 0
            };
            string absolutePath = "E:\\web\\Firewood\\";// SiteConfig.SitePath;
            string path         = GetPath("Act");
            string fullPath     = absolutePath + path;
            string url          = path + act.ActID.ToString() + ".png";

            using (var stream = file.InputStream)
            {
                Image img = Image.FromStream(stream);
                var   bmp = ResizeImg(img);
                if (!System.IO.Directory.Exists(fullPath))
                {
                    System.IO.Directory.CreateDirectory(fullPath);
                }
                bmp.Save(absolutePath + url, ImageFormat.Png);
            }
            act.ActPic = url;

            if (actService.Publish(act))
            {
                return(Content("<script>alert('发布成功~');window.location.href='Index'</script>"));
            }
            else
            {
                ModelState.AddModelError("", "注册异常");
                return(View("Publish", model));
            }
        }
Exemple #2
0
        public IActionResult PublishToFB(PublishModels models)
        {
            _ubfPublish.UpdateStatusBeforePublishing(models.id, models.time);
            var jobId = BackgroundJob.Schedule(
                () => _context.PublishToWP(models.id),
                models.time);

            return(Accepted());
        }
Exemple #3
0
        public ActionResult PostPublish(PublishModels model, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid) return View("Publish", model);

            //图片不超过20M
            if (file == null && file.ContentLength > 1024 * 1024 * 20)
            {
                ModelState.AddModelError("", "请上传规定大小的图片");
                return View("Publish", model);
            }

            //验证通过后
            Activity act = new Activity
            {
                ActID = Guid.NewGuid(),
                OrgID = new Guid(Session["OrgID"].ToString()),
                ActName = model.ActName,
                Place = model.Place,
                Class1 = model.Class1,
                Class2 = model.Class2,
                BeginTime = model.BeginTime,
                EndTime = model.EndTime,
                ActIntro = model.ActIntro,
                MoneyState = model.Money.Equals("yes") ? 1 : 0,
                ScoreState = model.Score.Equals("yes") ? 1 : 0,
                AwardState = model.Award.Equals("yes") ? 1 : 0,
                VoteState = model.Vote.Equals("yes") ? 1 : 0
            };
            string absolutePath = "E:\\web\\Firewood\\";// SiteConfig.SitePath;
            string path = GetPath("Act");
            string fullPath = absolutePath + path;
            string url = path + act.ActID.ToString() + ".png";
            using (var stream = file.InputStream)
            {
                Image img = Image.FromStream(stream);
                var bmp = ResizeImg(img);
                if (!System.IO.Directory.Exists(fullPath))
                    System.IO.Directory.CreateDirectory(fullPath);
                bmp.Save(absolutePath + url, ImageFormat.Png);
            }
            act.ActPic = url;

            if (actService.Publish(act))
            {
                return Content("<script>alert('发布成功~');window.location.href='Index'</script>");
            }
            else
            {
                ModelState.AddModelError("", "注册异常");
                return View("Publish", model);
            }
        }