Esempio n. 1
0
File: Ml.cs Progetto: jsakamoto/bjd5
        public Ml(Kernel kernel, Logger logger, MailSave mailSave, MlOption mlOption,string mlName,List<string>domainList)
        {
            Status = false;

            _kernel = kernel;
            _logger = logger;
            _mlName = mlName;
            //_mlOption = mlOption;

            _mlMailDb = new MlMailDb(logger, mlOption.ManageDir, mlName);
            if (!_mlMailDb.Status) {
                return;//初期化中断
            }

            _mlAddr = new MlAddr(mlName, domainList);
            _mlUserList = new MlUserList(mlOption.MemberList);
            _mlSender = new MlSender(mailSave, logger);
            var mlSubject = new MlSubject(mlOption.TitleKind, mlName);
            _mlDevivery = new MlDelivery(mailSave, logger,_mlUserList, _mlAddr, _mlMailDb, mlSubject, mlOption.Docs,mlOption.MaxGet);
            _mlCreator2 = new MlCreator(_mlAddr,mlOption.Docs);
            _autoRegistration = mlOption.AutoRegistration;
            const double effectiveMsec = 120 * 1000; //有効時間120秒
            _mlSubscribeDb = new MlSubscribeDb(mlOption.ManageDir, mlName, effectiveMsec);//confirm文字列データベース
            if (!_mlMailDb.Status) {
                return;//初期化中断
            }
            Status = true;//ステータス
        }
Esempio n. 2
0
        public Mail Summary(MlMailDb mlDb, MlSubject mlSubject, int start, int end)
        {
            //ライブラリからの取得
            Encoding      encoding = null;
            StringBuilder sb       = new StringBuilder();

            for (int i = start; i <= end; i++)
            {
                var mail = mlDb.Read(i);
                if (mail == null)
                {
                    sb.Append(mlSubject.Get(i) + " library no't found.\r\n");
                }
                else
                {
                    string str = mail.GetHeader("subject");
                    if (str != null)
                    {
                        str = Subject.Decode(ref encoding, str);
                        sb.Append(string.Format("{0}\r\n", str));
                    }
                    else
                    {
                        sb.Append(mlSubject.Get(i) + " subject no't found.\r\n");
                    }
                }
            }
            string subject = string.Format("result for summary [{0}-{1}] ({2} ML)", start, end, mlAddr.Name);

            return(Create(ContentTyep.Sjis, subject, sb.ToString()));
        }
Esempio n. 3
0
File: Ml.cs Progetto: schifflee/bjd5
        public Ml(Kernel kernel, Logger logger, MailSave mailSave, MlOption mlOption, string mlName, List <string> domainList)
        {
            Status = false;

            _kernel = kernel;
            _logger = logger;
            _mlName = mlName;
            //_mlOption = mlOption;

            _mlMailDb = new MlMailDb(logger, mlOption.ManageDir, mlName);
            if (!_mlMailDb.Status)
            {
                return;//初期化中断
            }

            _mlAddr     = new MlAddr(mlName, domainList);
            _mlUserList = new MlUserList(mlOption.MemberList);
            _mlSender   = new MlSender(mailSave, logger);
            var mlSubject = new MlSubject(mlOption.TitleKind, mlName);

            _mlDevivery       = new MlDelivery(mailSave, logger, _mlUserList, _mlAddr, _mlMailDb, mlSubject, mlOption.Docs, mlOption.MaxGet);
            _mlCreator2       = new MlCreator(_mlAddr, mlOption.Docs);
            _autoRegistration = mlOption.AutoRegistration;
            const double effectiveMsec = 120 * 1000;                                       //有効時間120秒

            _mlSubscribeDb = new MlSubscribeDb(mlOption.ManageDir, mlName, effectiveMsec); //confirm文字列データベース
            if (!_mlMailDb.Status)
            {
                return;    //初期化中断
            }
            Status = true; //ステータス
        }
Esempio n. 4
0
 public MlDelivery(MailSave mailSave, Logger logger, MlUserList mlUserList, MlAddr mlAddr, MlMailDb mlDb, MlSubject mlSubject, List <string> docs, int maxGet)
 {
     _mlUserList = mlUserList;
     _mlAddr     = mlAddr;
     _logger     = logger;
     _mlDb       = mlDb;
     _mlSubject  = mlSubject;
     _docs       = docs;
     _maxGet     = maxGet;
     _mlSender   = new MlSender(mailSave, logger);
 }
Esempio n. 5
0
 public MlDelivery(MailSave mailSave, Logger logger, MlUserList mlUserList, MlAddr mlAddr, MlMailDb mlDb, MlSubject mlSubject,List<string>docs,int maxGet)
 {
     _mlUserList = mlUserList;
     _mlAddr = mlAddr;
     _logger = logger;
     _mlDb = mlDb;
     _mlSubject = mlSubject;
     _docs = docs;
     _maxGet = maxGet;
     _mlSender = new MlSender(mailSave, logger);
 }
Esempio n. 6
0
        public void SaveReadTest()
        {
            var tmpDir = TestUtil.GetTmpDir("$tmp");
            var logger = new Logger();

            var mail = new Mail();
            const string mlName = "1ban";
            var mlMailDb = new MlMailDb(logger, tmpDir, mlName);
            mlMailDb.Remove();//もし、以前のメールが残っていたらTESTが誤動作するので、ここで消しておく

            Assert.AreEqual(mlMailDb.Count(), 0);

            const int max = 10; //試験件数10件
            //保存と、
            for (int i = 0; i < max; i++) {
                var b = mlMailDb.Save( mail);
                Assert.AreEqual(b,true);//保存が成功しているか
                Assert.AreEqual(mlMailDb.Count(), i+1);//連番がインクリメントしているか
            }
            //範囲外のメール取得でnullが返るか
            //no==1..10が取得可能
            var m = mlMailDb.Read(0);//範囲外
            Assert.IsNull(m);
            //範囲内
            for (int no = 1; no <= max; no++) {
                //m = mlMailDb.Read(no);
                mlMailDb.Read(no);
                Assert.NotNull(mlMailDb.Read(no));
            }
            //範囲外
            m = mlMailDb.Read(11);
            Assert.IsNull(m);

            //TearDown
            mlMailDb.Remove();
            mlMailDb.Dispose();
            Directory.Delete(tmpDir,true);
        }
Esempio n. 7
0
        public void CtorTest(string folder, bool exists,bool status)
        {
            //Testプロジェクトの下に、TEST用フォルダを作成する

            var dir = string.Format("{0}\\{1}", Directory.GetCurrentDirectory(), folder);

            if (!exists){//存在しないフォルダをTESTする場合は、フォルダをあらかじめ削除してお
                if (Directory.Exists(dir)) {
                    Directory.Delete(dir,true);
                }
            }
            const string mlName = "2ban";
            var mlMailDb = new MlMailDb(null, dir,mlName);//コンストラクタ
            Assert.AreEqual(mlMailDb.Status, status);//初期化成功
            mlMailDb.Remove();

            if (!exists) {//存在しないフォルダをTESTする場合は、最後にフォルダを削除しておく
                if (Directory.Exists(dir)) {
                    Directory.Delete(dir, true);
                }
            }
            mlMailDb.Dispose();
        }
Esempio n. 8
0
        public Mail Get(MlMailDb mlDb, int start, int end)
        {
            string boundaryStr = "BJD-Boundary";

            byte[] buf = new byte[0];
            //ライブラリからの取得
            for (int i = start; i <= end; i++)
            {
                var mail = mlDb.Read(i);
                if (mail != null)
                {
                    buf = Bytes.Create(buf, Encoding.ASCII.GetBytes(string.Format("--{0}\r\n", boundaryStr)));
                    buf = Bytes.Create(buf, Encoding.ASCII.GetBytes("Content-Type: message/rfc822\r\n\r\n"));
                    buf = Bytes.Create(buf, mail.GetBytes());
                }
            }
            buf = Bytes.Create(buf, Encoding.ASCII.GetBytes(string.Format("--{0}--\r\n", boundaryStr)));

            var subject     = string.Format("result for get [{0}-{1} MIME/multipart] ({2} ML)", start, end, mlAddr.Name);
            var contentType = string.Format("multipart/mixed;\r\n boundary=\"{0}\"\r\n", boundaryStr);

            return(Create(subject, contentType, buf));
        }
Esempio n. 9
0
        public Mail Get(MlMailDb mlDb, int start, int end)
        {
            string boundaryStr = "BJD-Boundary";
            byte[] buf = new byte[0];
            //ライブラリからの取得
            for (int i = start; i <= end; i++) {
                var mail = mlDb.Read(i);
                if (mail != null) {
                    buf = Bytes.Create(buf, Encoding.ASCII.GetBytes(string.Format("--{0}\r\n", boundaryStr)));
                    buf = Bytes.Create(buf, Encoding.ASCII.GetBytes("Content-Type: message/rfc822\r\n\r\n"));
                    buf = Bytes.Create(buf, mail.GetBytes());
                }
            }
            buf = Bytes.Create(buf, Encoding.ASCII.GetBytes(string.Format("--{0}--\r\n", boundaryStr)));

            var subject = string.Format("result for get [{0}-{1} MIME/multipart] ({2} ML)", start, end, mlAddr.Name);
            var contentType = string.Format("multipart/mixed;\r\n boundary=\"{0}\"\r\n", boundaryStr);

            return Create(subject, contentType, buf);
        }
Esempio n. 10
0
 public Mail Summary(MlMailDb mlDb, MlSubject mlSubject, int start, int end)
 {
     //ライブラリからの取得
     Encoding encoding = null;
     StringBuilder sb = new StringBuilder();
     for (int i = start; i <= end; i++) {
         var mail = mlDb.Read(i);
         if (mail == null) {
             sb.Append(mlSubject.Get(i) + " library no't found.\r\n");
         } else {
             string str = mail.GetHeader("subject");
             if (str != null) {
                 str = Subject.Decode(ref encoding, str);
                 sb.Append(string.Format("{0}\r\n", str));
             } else {
                 sb.Append(mlSubject.Get(i) + " subject no't found.\r\n");
             }
         }
     }
     string subject = string.Format("result for summary [{0}-{1}] ({2} ML)", start, end, mlAddr.Name);
     return Create(ContentTyep.Sjis, subject, sb.ToString());
 }