예제 #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("添加成功"));
        }
예제 #2
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"));
        }
예제 #4
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"));
        }
예제 #5
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"));
        }