| | |
| | | |
| | | namespace LFServer.cs |
| | | { |
| | | public class ExportUtil |
| | | public static class ExportUtil |
| | | { |
| | | /// <summary> |
| | | /// 基目录 |
| | | /// </summary> |
| | | public static readonly string BaseDir = AppDomain.CurrentDomain.BaseDirectory; |
| | | |
| | | private static string py; |
| | | |
| | | public string GetPy |
| | | { |
| | | get |
| | | { |
| | | if (py == null) py = Path.Combine(BaseDir, "Sources\\render.py"); |
| | | |
| | | return py; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 最大文件数 |
| | | /// </summary> |
| | | public const int MaxFileCount = 2000; |
| | | |
| | | private static string sourcesPath; |
| | | |
| | | public string GetSourcesPath |
| | | /// <summary> |
| | | /// 获取资源目录 |
| | | /// </summary> |
| | | public static string SourcesPath |
| | | { |
| | | get |
| | | { |
| | |
| | | |
| | | return sourcesPath; |
| | | } |
| | | } |
| | | |
| | | private static string pyFile; |
| | | |
| | | /// <summary> |
| | | /// 获取Python文件 |
| | | /// </summary> |
| | | public static string PyFile |
| | | { |
| | | get |
| | | { |
| | | if (string.IsNullOrWhiteSpace(pyFile)) |
| | | { |
| | | pyFile = Path.Combine(SourcesPath, "render.py"); |
| | | } |
| | | |
| | | return pyFile; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取上期字符串 |
| | | /// </summary> |
| | | public static string DateStr |
| | | { |
| | | get |
| | | { |
| | | return DateTime.Now.ToString("yyyyMMddHHmmss"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取出图目录 |
| | | /// </summary> |
| | | public static string ExportFolder |
| | | { |
| | | get |
| | | { |
| | | return ConfigurationManager.AppSettings["exportFolder"]; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取出图子目录 |
| | | /// </summary> |
| | | public static string GetExportSubFolder() |
| | | { |
| | | string root = ExportFolder; |
| | | if (!Directory.Exists(root)) |
| | | { |
| | | Directory.CreateDirectory(root); |
| | | } |
| | | |
| | | int i = 1; |
| | | while (true) |
| | | { |
| | | string subFolder = Path.Combine(root, i.ToString()); |
| | | if (!Directory.Exists(subFolder)) |
| | | { |
| | | Directory.CreateDirectory(subFolder); |
| | | break; |
| | | } |
| | | |
| | | DirectoryInfo dir = new DirectoryInfo(subFolder); |
| | | FileInfo[] files = dir.GetFiles(); |
| | | if (files == null || files.Length < MaxFileCount) |
| | | { |
| | | break; |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | return i.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | } |
| | | } |
| | | |
| | | public static void Generate() |
| | | { |
| | | string date = DateStr; |
| | | |
| | | |
| | | } |
| | | } |
| | | } |