Esempio n. 1
0
 protected void NewFolder(object sender, EventArgs e)
 {
     if (!CurrentUser.OperateFiles)
     {
         Response.StatusCode = 401;
         return;
     }
     FileHelper.CreateDirectory(FileHelper.Combine(RelativePath, Hidden.Value.UrlDecode()));
     Response.Redirect(Request.RawUrl);
 }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
            Response.ContentType = "application/xml";
            var result = new XElement("result");
            var path   = RouteData.GetRelativePath();

            try
            {
                switch (RouteData.GetRouteString("Action").ToLower())
                {
                case "list":
                    if (!Request.GetUser().Browse)
                    {
                        Response.StatusCode = 401;
                        return;
                    }
                    List(path, result);
                    break;

                case "createdirectory":
                    if (!Request.GetUser().OperateFiles)
                    {
                        Response.StatusCode = 401;
                        return;
                    }
                    FileHelper.CreateDirectory(path);
                    break;

                case "copy":
                    if (!Request.GetUser().OperateFiles)
                    {
                        Response.StatusCode = 401;
                        return;
                    }
                    FileHelper.Copy(path, Request.QueryString["Target"].UrlDecode());
                    break;

                case "move":
                    if (!Request.GetUser().OperateFiles)
                    {
                        Response.StatusCode = 401;
                        return;
                    }
                    FileHelper.Move(path, Request.QueryString["Target"].UrlDecode());
                    break;

                case "delete":
                    if (!Request.GetUser().OperateFiles)
                    {
                        Response.StatusCode = 401;
                        return;
                    }
                    FileHelper.Delete(path);
                    break;

                case "details":
                    if (!Request.GetUser().Browse)
                    {
                        Response.StatusCode = 401;
                        return;
                    }
                    Details(path, result);
                    break;

                case "niguan":
                    NiGuan(path, result);
                    Response.Write(result.ToString());
                    return;

                case "codecs":
                    Codecs(result);
                    break;

                default:
                    throw new FormatException("无法识别的 Action!");
                }
                result.SetAttributeValue("status", "ok");
            }
            catch (Exception exc)
            {
                result.SetAttributeValue("status", "error");
                result.SetAttributeValue("message", exc.GetMessage());
            }
            Response.Write(result.ToString());
        }