Beispiel #1
0
        //生成项目字典
        public void PublishDictionary()
        {
            NameValueCollection Params = HttpContext.Request.Form; //参数
            string projectCode         = Params["projectCode"];    //项目编码
            string fileName            = Params["projectName"];    //项目名称
            string path      = Server.MapPath(string.Format("~/Content/Pack/{0}", User.Identity.Name));
            string directory = Server.MapPath(string.Format("~/Content/Html/{0}/{1}", User.Identity.Name, fileName));

            try
            {
                path = GenerateHtml(projectCode, fileName, path, directory);
                do
                {
                    DZips.ZipFileDirectory(directory, path);
                } while (DZips.ValidZipFile(path));
                Response.Write("{HasError:false,msg:'项目字典生成成功!'}");
            }catch (Exception ex) {
                NHibernateHelper.WriteErrorLog("生成项目字典", ex);
                Response.Write("{HasError:true,msg:'项目字典生成失败!'}");
            }
            Response.End();
        }
Beispiel #2
0
        //打包项目字典
        public void UnpackDictionary()
        {
            NameValueCollection Params = HttpContext.Request.Form; //参数
            string   projectCode       = Params["projectCode"];    //项目编码
            string   fileName          = Params["projectName"];    //项目名称
            string   path      = Server.MapPath(string.Format("~/Content/Pack/{0}/{1}.zip", User.Identity.Name, fileName));
            string   directory = Server.MapPath(string.Format("~/Content/Html/{0}/{1}", User.Identity.Name, fileName));
            FileInfo fi        = new FileInfo(path);

            if (fi.Exists)//输出压缩包
            {
                WriteZip(fi);
            }
            else//压缩项目字典
            {
                do
                {
                    DZips.ZipFileDirectory(directory, path);
                } while (DZips.ValidZipFile(path));
                fi = new FileInfo(path);
                WriteZip(fi);
            }
        }