protected void BackGrup_Click(object sender, EventArgs e)
        {
            ZipClass zip        = new ZipClass();
            string   dir        = TemplateDir + Request["Dir"];//文件夹
            string   dir1       = TemplateDir.Substring(TemplateDir.LastIndexOf("/") + 1);
            int      index      = dir.LastIndexOf("/");
            string   fielname   = dir.Substring(index + 1);
            string   LjFile     = Request.PhysicalApplicationPath.ToString() + dir;
            string   FileToZip  = LjFile.Replace("/", @"\");
            string   zipdirName = DateTime.Now.ToString("yyyyMMdd") + "_" + dir1 + "_" + fielname;
            string   ZipedFile  = FileToZip + @"\" + zipdirName + "模板集备份" + ".rar";
            string   path1      = ZipedFile;
            string   sPath      = Request.PhysicalApplicationPath.ToString() + @"temp\";

            if (Directory.Exists(sPath))//判断是否存在这个目录
            {
            }
            else
            {
                Directory.CreateDirectory(sPath);//不存在则创建这个目录
            }
            string path2 = sPath + zipdirName + "模板集备份" + ".rar";

            if (zip.Zip(FileToZip, ZipedFile, ""))
            {
                function.WriteSuccessMsg("模版方案(" + fielname + ")备份失败!", "../Template/TemplateManage.aspx");
            }
            else
            {
                File.Delete(path2);      //如果不删除则会出现文件已存在,无法创建该文件的错误。
                File.Move(path1, path2); //因为生成的ZIP文件名和文件的存放位置一样,所以要在生成以后移动到temp目录下面(temp目录是用来存放备份文件的)
                function.WriteSuccessMsg("模版方案(" + fielname + ")备份成功!", "../Template/TemplateManage.aspx");
            }
        }
示例#2
0
        /// <summary>
        /// Processes the given settings and modifies the <see cref="ProcessArgumentBuilder"/>
        /// </summary>
        /// <param name="args"></param>
        /// <param name="environment"></param>
        internal void Evaluate(ProcessArgumentBuilder args, ICakeEnvironment environment)
        {
            if (Version)
            {
                args.Append("--version");
            }

            if (Verbose)
            {
                args.Append("--verbose");
            }

            if (TimingsMode)
            {
                args.Append("--timings");
            }

            if (!string.IsNullOrEmpty(TemplateEngine))
            {
                args.Append("--template-engine " + TemplateEngine);
            }

            if (TemplateDir != null)
            {
                args.Append("--template-dir " + TemplateDir.MakeAbsolute(environment).FullPath.Quote());
            }

            if (SectionNumbers)
            {
                args.Append("--section-numbers");
            }

            if (SafeMode.HasValue)
            {
                args.Append("--safe-mode " + Enum.GetName(typeof(SafeMode), SafeMode.Value).ToLower(CultureInfo.InvariantCulture));
            }

            if (Require)
            {
                args.Append("--require");
            }

            if (Quiet)
            {
                args.Append("--quiet");
            }

            if (Output != null)
            {
                args.Append("--out-file " + Output.MakeAbsolute(environment).FullPath.Quote());
            }

            if (SuppressHeaderAndFooter)
            {
                args.Append("--no-header-footer");
            }

            foreach (var p in LoadPath)
            {
                args.Append("--load-path " + p.MakeAbsolute(environment).FullPath.Quote());
            }

            if (ERuby.HasValue)
            {
                { args.Append("--eruby " + Enum.GetName(typeof(ERuby), ERuby.Value).ToLower(CultureInfo.InvariantCulture)); }
            }

            if (DocType.HasValue)
            {
                { args.Append("--doctype " + Enum.GetName(typeof(DocType), DocType.Value).ToLower(CultureInfo.InvariantCulture)); }
            }

            if (DestinationDir != null)
            {
                args.Append("--destination-dir " + DestinationDir.MakeAbsolute(environment).FullPath.Quote());
            }

            if (Compact)
            {
                args.Append("--compact");
            }

            foreach (var p in ClassPath)
            {
                args.Append("--classpath " + p.MakeAbsolute(environment).FullPath.Quote());
            }

            if (BaseDir != null)
            {
                args.Append("--base-dir " + BaseDir.MakeAbsolute(environment).FullPath.Quote());
            }

            if (!string.IsNullOrEmpty(Backend))
            {
                args.Append("--backend " + Backend);
            }

            foreach (var kvp in Attributes)
            {
                args.Append($"--attribute {kvp.Key}={kvp.Value}");
            }

            // input is last!
            foreach (var f in InputFiles)
            {
                args.Append(f.MakeAbsolute(environment).FullPath.Quote());
            }
        }