Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        protected void Get(HttpContext context)
        {
            var u     = new AuthedUser();
            var root  = u.InitTree(u.Root.Element("node"));
            var roles = u.Root.Element("roles").Elements("add").Select(a => a.Attribute("name").Value).ToList();


            var jw = new JsonTextWriter(context.Response.Output);

            jw.WriteStartArray();
            JWRPT(root, roles, jw);
            jw.WriteEndArray();


            jw.Close();
        }
Пример #2
0
        protected override void Render(HtmlTextWriter writer)
        {
            writer.WriteBeginTag("div");
            writer.WriteAttribute("id", this.ClientID);
            writer.WriteAttribute("class", this.CssClass);
            writer.Write(">");
            writer.WriteEndTag("div");
            //RenderTable(writer);

            writer.WriteBeginTag("form");
            writer.WriteAttribute("id", this.ClientID + "_form");
            writer.WriteAttribute("method", "post");
            writer.WriteAttribute("action", this.ClientID + ".NavConfig");
            writer.Write(">");

            var cs = Page.ClientScript;

            writer.WriteBeginTag("script");
            writer.WriteAttribute("src", cs.GetWebResourceUrl(this.GetType(), "HY.Auth.NavConfigControl.js"));
            writer.Write(">");
            writer.WriteEndTag("script");

            //配置信息
            writer.WriteBeginTag("script");
            writer.Write(">");
            var u   = new AuthedUser();
            var cfg = new
            {
                id  = this.ClientID,
                key = "authcfg",
                //tree = u.InitTree(u.Root.Element("node")),
                roles = u.Root.Element("roles").Elements("add").Select(a => a.Attribute("name").Value).ToList()
            };

            writer.Write("NavConfig=");
            writer.Write(ObjectExtensions.ToJson(cfg));
            writer.Write(";");


            writer.WriteEndTag("script");

            writer.Write("<input type=\"hidden\" id=\"{0}\" name=\"{1}\" />", cfg.id + "_hd", cfg.key);

            writer.WriteEndTag("form");
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        protected void Post(HttpContext context)
        {
            var u   = new AuthedUser();
            var rep = context.Response;

            try
            {
                var bytes = new byte[context.Request.InputStream.Length];
                context.Request.InputStream.Read(bytes, 0, bytes.Length);
                u.UpdateNodes(System.Text.Encoding.UTF8.GetString(bytes));
                var obj = new HY.Frame.Core.ResResult();
                rep.Write(ObjectExtensions.ToJson(obj));
            }
            catch (Exception e)
            {
                this.Log4().Error("保存出错", e);
                rep.StatusCode = 500;
                var obj = new HY.Frame.Core.ResResult {
                    error = true, msg = e.Message
                };
                rep.Write(ObjectExtensions.ToJson(obj));
            }
        }