Ejemplo n.º 1
0
 public static DocumentRule Instance()
 {
     if (!inited)
     {
         inited = true;
         string text = ConfigurationSettings.AppSettings["AttachMentSaveMode"];
         if ((text != null) && (text.ToLower() == "file"))
         {
             _SaveMode = AttachmentSaveMode.file;
             _Path     = ConfigurationSettings.AppSettings["AttachMentSavePath"];
             if (_Path == null)
             {
                 throw new Exception("未定义文档存储目录");
             }
             try
             {
                 if (!Directory.Exists(_Path))
                 {
                     Directory.CreateDirectory(_Path);
                 }
             }
             catch
             {
                 throw new Exception("不能创建文档存储目录");
             }
         }
         else
         {
             _SaveMode = AttachmentSaveMode.database;
         }
         string text2 = ConfigurationSettings.AppSettings["AttachMentSavePathMode"];
         try
         {
             _SavePathMode = (AttachmentSavePathMode)Enum.Parse(typeof(AttachmentSavePathMode), text2.ToUpper());
         }
         catch
         {
             _SavePathMode = AttachmentSavePathMode.ROOT;
         }
     }
     return(new DocumentRule());
 }
Ejemplo n.º 2
0
    public void init()
    {
        string mode = System.Configuration.ConfigurationSettings.AppSettings["AttachMentSaveMode"];

        if (mode != null && mode.ToLower() == "file")
        {
            _SaveMode = AttachmentSaveMode.file;
            _Path     = System.Configuration.ConfigurationSettings.AppSettings["AttachMentSavePath"];
            if (_Path == null)
            {
                throw (new Exception("未定义文档存储目录"));
            }
            try
            {
                if (!Directory.Exists(_Path))
                {
                    Directory.CreateDirectory(_Path);
                }
            }
            catch
            {
                throw (new Exception("不能创建文档存储目录"));
            }
        }
        else
        {
            _SaveMode = AttachmentSaveMode.database;
        }

        string pathmode = System.Configuration.ConfigurationSettings.AppSettings["AttachMentSavePathMode"];

        try
        {
            _SavePathMode = (AttachmentSavePathMode)System.Enum.Parse(typeof(AttachmentSavePathMode), pathmode.ToUpper());
        }
        catch { _SavePathMode = AttachmentSavePathMode.ROOT; }
    }