|
- using Learun.Application.Base.SystemModule;
- using System;
- using System.IO;
- using System.Web;
- using System.Web.Mvc;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
-
- namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers
- {
- public class LogoImgController : MvcControllerBaseNoLogin
- {
- DatabaseLinkIBLL databaseLinkIbll = new DatabaseLinkBLL();
- private DgreeIBLL dgreeIBLL = new DgreeBLL();
- LR_Base_LogoIBLL baseLogoIbll = new LR_Base_LogoBLL();
-
- // GET: LR_SystemModule/LogoImg
- public ActionResult AppIndex()
- {
- return View();
- }
-
- public ActionResult UploadFile(string code)
- {
-
- HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
- //没有文件上传,直接返回
- if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName))
- {
- return HttpNotFound();
- }
- DgreeEntity dgreeEntity = new DgreeEntity();
- dgreeEntity.ModuleID = "2fdc1fdb-50f4-4e9c-97c7-0d53b161f9da";
- dgreeEntity.Status = "1";
- dgreeIBLL.SaveEntity("", dgreeEntity);
- string fExtension = Path.GetExtension(files[0].FileName);
- string rootPath = Server.MapPath("/");
- try
- {
- string filepath = rootPath + "/Content/images/logo/" + DateTime.Now.ToString("yyyyMMdd");
- if (System.IO.Directory.Exists(filepath) == false)//如果不存在就创建file文件夹
- {
- System.IO.Directory.CreateDirectory(filepath);
- }
- files[0].SaveAs(filepath + "/" + code + ".png");
- LR_Base_LogoEntity logoEntity = baseLogoIbll.GetLR_Base_LogoEntityByCode(code);
- if (logoEntity == null)
- {
- logoEntity = new LR_Base_LogoEntity();
- logoEntity.Create();
- logoEntity.F_Code = code;
- logoEntity.F_FileName = filepath + "/" + code + ".png";
- baseLogoIbll.SaveEntity(null, logoEntity);
- }
- else
- {
- logoEntity.F_FileName = filepath + "/" + code + ".png";
- baseLogoIbll.SaveEntity(logoEntity.F_LId, logoEntity);
- }
- //switch (code)
- //{
- // case "default":
- // {
- // logoEntity.F_Code = code;
- // logoEntity.F_FileName = filepath + "/"+ code + ".png";
- // files[0].SaveAs(filepath + "/"+ code + ".png");
- // }
- // break;
- // case "accordion":
- // files[0].SaveAs(rootPath + "/Content/images/logo/accordion.png");
- // break;
- // case "windows":
- // files[0].SaveAs(rootPath + "/Content/images/logo/windows.png");
- // break;
- // case "top":
- // files[0].SaveAs(rootPath + "/Content/images/logo/top.png");
- // break;
- // case "applogo":
- // files[0].SaveAs(rootPath + "/Content/images/logo/applogo.png");
- // break;
-
- //}
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- throw;
- }
-
-
- return Success("保存成功!");
- }
-
- public ActionResult GetImg(string code)
- {
- string rootPath = Server.MapPath("/");
- string midPath = "Content/images/logo";
- try
- {
- LR_Base_LogoEntity logoEntity = baseLogoIbll.GetLR_Base_LogoEntityByCode(code);
- if (logoEntity != null)
- {
- var bytesdefault = System.IO.File.ReadAllBytes(logoEntity.F_FileName);
- return File(bytesdefault, "image/jpeg");
- }
- else
- {
- switch (code)
- {
- case "default":
- var bytesdefault = System.IO.File.ReadAllBytes(Path.Combine(rootPath, midPath, "default.png"));
- return File(bytesdefault, "image/jpeg");
- case "accordion":
- var bytesaccordion = System.IO.File.ReadAllBytes(Path.Combine(rootPath, midPath, "accordion.png"));
- return File(bytesaccordion, "image/jpeg");
- case "windows":
- var byteswindows = System.IO.File.ReadAllBytes(Path.Combine(rootPath, midPath, "windows.png"));
- return File(byteswindows, "image/jpeg");
- case "top":
- var bytestop = System.IO.File.ReadAllBytes(Path.Combine(rootPath, midPath, "top.png"));
- return File(bytestop, "image/jpeg");
- case "applogo":
- var byteapplogo = System.IO.File.ReadAllBytes(Path.Combine(rootPath, midPath, "applogo.png"));
- return File(byteapplogo, "image/jpeg");
- }
- }
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- }
- return null;
- }
-
- public ActionResult PCIndex()
- {
- return View();
- }
- }
- }
|