Example #1
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());
        }
Example #2
0
        public ApiResult ExportOne(RequestVisitRecordQDTO request)
        {
            List <string> files = new List <string>();

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

            File.WriteAllBytes(filePath, Encoding.UTF8.GetBytes(recordService.ExportQuery(request)));
            files.Add(filePath);

            var ret = recordService.GetDetail(request);

            if (ret != null)
            {
                foreach (var file in ret.SJWLFiles)
                {
                    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.LBWLFiles)
                {
                    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.NBGLFiles)
                {
                    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.HYXGFiles)
                {
                    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.NewsFiles)
                {
                    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());
        }