Esempio n. 1
0
        public ApiResult GetDetail([FromBody] RequestOrgQDTO request)
        {
            OrgService orgService = new OrgService();
            var        ret        = orgService.GetDetail(request);

            if (ret == null)
            {
                return(new ApiResult()
                {
                    Status = EnumApiStatus.BizError, Msg = "数据不存在,或没有权限"
                });
            }
            else
            {
                return(ret.ToApiResult());
            }
        }
Esempio n. 2
0
        public ApiResult ExportOne(RequestOrgQDTO request)
        {
            OrgService    orgService = new OrgService();
            List <string> files      = new List <string>();

            var rootpath = ConfigurationManager.AppSettings["rootpath"].ToString();
            var fileid   = "org_" + request.OrgID;
            var filename = fileid + ".xls";
            var filePath = System.IO.Path.Combine(rootpath, filename);

            File.WriteAllBytes(filePath, Encoding.UTF8.GetBytes(orgService.Export(request)));
            files.Add(filePath);

            var ret = orgService.GetDetail(request);

            if (ret != null)
            {
                foreach (var file in ret.BJFiles)
                {
                    if (File.Exists(System.IO.Path.Combine(rootpath, file.FileUrl)))
                    {
                        File.Copy(System.IO.Path.Combine(rootpath, file.FileUrl), System.IO.Path.Combine(rootpath, file.FileName), true);
                        files.Add(System.IO.Path.Combine(rootpath, file.FileName));
                    }
                }

                foreach (var file in ret.OtherFiles)
                {
                    if (File.Exists(System.IO.Path.Combine(rootpath, file.FileUrl)))
                    {
                        File.Copy(System.IO.Path.Combine(rootpath, file.FileUrl), System.IO.Path.Combine(rootpath, file.FileName), true);
                        files.Add(System.IO.Path.Combine(rootpath, file.FileName));
                    }
                }
            }
            CommonService.CompressFiles(files, System.IO.Path.Combine(rootpath, fileid + ".zip"));

            return(fileid.ToApiResult());
        }