Exemple #1
0
        public virtual ActionResult AddSystemTemplate(string c, string v, string t)
        {
            if (string.IsNullOrEmpty(c) || string.IsNullOrEmpty(v))
            {
                return(Content("Error"));
            }
            if (!c.Contains("<%@"))
            {
                c = "<%@ Control Language=\"C#\" AutoEventWireup=\"true\" Inherits=\"System.Web.Mvc.ViewUserControl\" %>" + c;
            }
            var li = new SelectListItem
            {
                Text  = t,
                Value = v
            };
            var x = ConfigSerializer.Load <List <SelectListItem> >("SystemTemplate");

            if (x.Where(q => q.Value == li.Value).Count() != 1)
            {
                x.Add(li);
                ConfigSerializer.Save(x, "SystemTemplate");
                ConfigSerializer.ClearCache("SystemTemplate");
                //	CHSNS.File.SaveAllText(Path.EventSystemTemplatePath(li.Value), c);
            }
            else
            {
                return(Content("Error"));
            }
            return(Content("添加成功"));
        }
Exemple #2
0
        public virtual ActionResult SystemTemplate()
        {
            var x = ConfigSerializer.Load <List <SelectListItem> >("SystemTemplate");

            ViewData["source"] = x;
            return(View("Admin/SystemTemplate"));
        }
Exemple #3
0
        public virtual ActionResult Manage(int?p)
        {
            InitPage(ref p);
            Title = "应用程序管理";
            var ais = ConfigSerializer.Load <SystemApplicationConfig>("SystemApplication");
            var li  = new PagedList <ApplicationItem>(ais.Items, p.Value, 10);

            return(View(li));
        }
Exemple #4
0
        public ActionResult UploadImage(HttpPostedFileBase file1, bool isSaveSource)
        {
            var uploadPath = WebContext.Path.UploadPath(WebUser.UserId);

            if (string.IsNullOrEmpty(uploadPath) || file1 == null)
            {
                return(Content("error:路径有错误"));
            }
            IOFactory.Folder.Create(uploadPath);
            if (file1.ContentLength > 2004800)
            {
                return(Content("error:文件请小于2M"));
            }
            var fileExtension = System.IO.Path.GetExtension(file1.FileName).ToLower();

            if (!ConfigSerializer.Load <List <string> >("AllowImageExt").Contains(fileExtension))
            {
                return(Content("error:您上传的文件扩展名不正确"));
            }
            var fileName = WebContext.Path.NewPhoto(WebUser.UserId, fileExtension);
            var photourl = System.IO.Path.Combine(uploadPath, fileName);

            if (isSaveSource)
            {
                IOFactory.StoreFile.Save(file1.InputStream, photourl);
            }
            //按比例生成缩略图
            using (var imgSrc = Image.FromStream(file1.InputStream))
            {
                foreach (var keyvalue in ConfigSerializer.Load <List <ThumbnailPair> >("ThumbnailSize"))
                {
                    Thumbnail.CreateThumbnail(
                        imgSrc,
                        WebContext.Path.ThumbPhoto(fileName, keyvalue.ImageType),
                        keyvalue.Size.Width,
                        keyvalue.Size.Height
                        );
                }
            }
            //SetStarLevel(CHUser.UserId); //更新
            Photo.Add(new Photo
            {
                Title   = "头像" + DateTime.Now.ToString("yyyyMMddhhmm"),
                UserId  = WebUser.UserId,
                Summary = "",
                Domain  = WebContext.Site.Upload.Domain,
                Url     = photourl
            });
            UserInfo.ChangeFace(WebUser.UserId, System.IO.Path.Combine(WebContext.Site.Upload.Domain, photourl));
            //更新头像地址
            //将新头像地址存入相册
            return
                (Content(WebContext.Path.ThumbUrl(photourl, ThumbType.Big, WebContext)));
        }
Exemple #5
0
        public virtual ActionResult Delete(string id)
        {
            HttpContext.Application.Lock();
            var ais  = ConfigSerializer.Load <SystemApplicationConfig>("SystemApplication", false);
            var item = ais.Items.Where(c => c.ID == id.Trim()).FirstOrDefault();

            ais.Items.Remove(item);
            ConfigSerializer.Save(ais, "SystemApplication");
            HttpContext.Application.UnLock();
            return(this.RedirectToReferrer());
        }
        private static UnityConfigurationSection SerializeAndLoadSection(string filename, Action <UnityConfigurationSection> sectionInitializer)
        {
            var serializer = new ConfigSerializer(filename);
            var section    = new UnityConfigurationSection();

            sectionInitializer(section);
            serializer.Save("unity", section);

            var loadedConfiguration = serializer.Load();

            return((UnityConfigurationSection)loadedConfiguration.GetSection("unity"));
        }
Exemple #7
0
        public ActionResult Submit(string id)
        {
            Title = "Submit your code";
            var li = ConfigSerializer.Load <List <Compiler> >("Compiler");

            ViewData["Compiler"] = new SelectList(li, "Guid", "Name");
            if (!id.IsNullOrEmpty())
            {
                ViewData["QuestionId"] = id;
            }
            return(View());
        }
Exemple #8
0
        public ActionResult Submit(long?id)
        {
            List <Compiler> li = ConfigSerializer.Load <List <Compiler> >("Compiler");

            ViewData["Compiler"] = new SelectList(li, "Guid", "Name");
            if (id.HasValue)
            {
                ViewData["QuestionId"] = id.Value;
            }
            ViewData["Username"] = User.Identity.Name;
            return(View());
        }
Exemple #9
0
        public virtual ActionResult Edit(ApplicationItem app)
        {
            Title          = app.FullName;
            app.AddTime    = DateTime.Now;
            app.UpdateTime = DateTime.Now;
            app.UserCount  = 0;
            app.IsTrue     = true;
            var ais = ConfigSerializer.Load <SystemApplicationConfig>("SystemApplication", false);

            ais.Items.Add(app);
            ConfigSerializer.Save(ais, "SystemApplication");
            return(RedirectToAction("Manage"));
        }
Exemple #10
0
 ActionResult ManageResult(Group g)
 {
     if (g == null)
     {
         return(HttpNotFound("group not found"));
     }
     Title = g.Name + "管理";
     ViewData["group.ShowLevel"] = new SelectList(
         ConfigSerializer.Load <List <SelectListItem> >("Group/ShowLevel"),
         "Value", "Text", g.ShowLevel);
     ViewData["group.JoinLevel"] = new SelectList(
         ConfigSerializer.Load <List <SelectListItem> >("Group/JoinLevel"),
         "Value", "Text", g.JoinLevel);
     ViewData["group"] = g;
     return(View());
 }
Exemple #11
0
        protected UnityConfigurationSection SerializeAndLoadConfig(string filename, Action <ContainerElement> containerInitializer)
        {
            var serializer = new ConfigSerializer(filename);
            var section    = new UnityConfigurationSection();

            section.SectionExtensions.Add(new SectionExtensionElement()
            {
                TypeName = typeof(InterceptionConfigurationExtension).AssemblyQualifiedName
            });

            var container = new ContainerElement();

            section.Containers.Add(container);

            containerInitializer(container);

            serializer.Save("unity", section);

            return((UnityConfigurationSection)serializer.Load().GetSection("unity"));
        }
Exemple #12
0
        public virtual ActionResult UploadPhoto(string name, long id, HttpPostedFileBase file)
        {
            var al = Album.GetCountChange(id, 1);

            if (al == null)
            {
                return(HttpNotFound("album not found"));
            }
            var p = new Photo {
                Title = name, AlbumId = id, AddTime = DateTime.Now, UserId = WebUser.UserId
            };
            var f = new ImageUpload(file,
                                    WebContext,
                                    ConfigSerializer.Load <List <string> >("AllowImageExt")
                                    , p.AddTime,
                                    ConfigSerializer.Load <List <ThumbnailPair> >("ThumbnailSize")
                                    );

            f.Upload();
            p.Summary = f.Ext;
            Photo.Add(p);
            return(RedirectToAction("details", new{ id }));
        }