123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using Sugar.Enties;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using WebAPIBase.Utils;
- using System.IO;
- public class DocumentRule : DbContext<SafeQualityCheck>
- {
- public AttachmentSaveMode _SaveMode;
- public static AttachmentSavePathMode _SavePathMode;
- private string _Path;
- public void Init()
- {
- var manager = new ConfigItemValueManager();
- string itemLower = manager.GetConfigItemValue("基础模块-附件存储设置-存储模式");
- _Path = manager.GetConfigItemValue("基础模块-附件存储设置-文件存储目录");
- if (itemLower != null && itemLower.ToLower() == "file")
- {
- _SaveMode = AttachmentSaveMode.file;
- if (_Path == null || _Path == "")
- {
- throw new Exception("未定义文档存储目录,请检查附件存储路径参数配置");
- }
- try
- {
- if (!Directory.Exists(_Path))
- {
- Directory.CreateDirectory(_Path);
- }
- }
- catch
- {
- throw new Exception("文档存储目录有误,请检查附件存储路径参数配置");
- }
- }
- else
- {
- _SaveMode = AttachmentSaveMode.database;
- }
- string itemLower2 = manager.GetConfigItemValue("基础模块-附件存储设置-文件目录模式");
- try
- {
- _SavePathMode = (AttachmentSavePathMode)Enum.Parse(typeof(AttachmentSavePathMode), itemLower2.ToUpper());
- }
- catch
- {
- _SavePathMode = AttachmentSavePathMode.ROOT;
- }
- }
- }
|