Exemplo n.º 1
0
        DateTime _dt = new DateTime(0); //最終処理時間

        #endregion Fields

        #region Constructors

        public OneFetchJob(Kernel kernel, MailSave mailSave,String domainName,OneFetch oneFetch, int timeout, int sizeLimit)
        {
            _kernel = kernel;
            _mailSave = mailSave;
            _domainName = domainName;
            _oneFetch = oneFetch;
            _timeout = timeout;
            _sizeLimit = sizeLimit;
        }
Exemplo n.º 2
0
 public OneFetchJob(Kernel kernel, MailSave mailSave, String domainName, OneFetch oneFetch, int timeout, int sizeLimit)
 {
     _kernel     = kernel;
     _mailSave   = mailSave;
     _domainName = domainName;
     _oneFetch   = oneFetch;
     _timeout    = timeout;
     _sizeLimit  = sizeLimit;
 }
Exemplo n.º 3
0
            public ListFetchJob(Kernel kernel, MailSave mailSave, String domainName, Logger logger, IEnumerable <OneDat> fetchList, int timeout, int sizeLimit)
            {
                if (fetchList != null)
                {
                    foreach (var o in fetchList)
                    {
                        if (o.Enable)
                        {
                            var interval  = Convert.ToInt32(o.StrList[0]); //受信間隔
                            var host      = o.StrList[1];                  //サーバ
                            var port      = Convert.ToInt32(o.StrList[2]); //ポート
                            var user      = o.StrList[3];                  //ユーザ
                            var pass      = Crypt.Decrypt(o.StrList[4]);   //パスワード
                            var localUser = o.StrList[5];                  //ローカルユーザ


                            //Ver5.2.7 旧バージョン(5.2以前)との互換のため
                            int synchronize;
                            try {
                                synchronize = Convert.ToInt32(o.StrList[6]); //同期
                            } catch {
                                var s = o.StrList[6];
                                if (s == "サーバに残す" || s == "An email of a server does not eliminate it")
                                {
                                    synchronize = 0;
                                }
                                else if (s == "メールボックスと同期する" || s == "Synchronize it with a mailbox")
                                {
                                    synchronize = 1;
                                }
                                else if (s == "サーバから削除する" || s == "An email of a server eliminates it")
                                {
                                    synchronize = 2;
                                }
                                else
                                {
                                    continue; //コンバート失敗したので設定データは無効
                                }
                            }
                            var keepTime = Convert.ToInt32(o.StrList[7]); //サーバに残す時間
                            var oneFetch = new OneFetch(interval, host, port, user, pass, localUser, synchronize, keepTime);
                            if (oneFetch.Ip == null)
                            {
                                logger.Set(LogKind.Error, null, 0, string.Format("host={0}", host));
                            }
                            Ar.Add(new OneFetchJob(kernel, mailSave, domainName, oneFetch, timeout, sizeLimit));
                        }
                    }
                }
            }
Exemplo n.º 4
0
 public void ホスト名の解決に失敗している時_処理はキャンセルされる()
 {
     //setUp
     MailSave mailSave = null;
     var domainName = "";
     var interval = 10;//10分
     var synchronize = 0;
     var keepTime = 100;//100分
     //不正ホスト名 xxxxx
     var oneFetch = new OneFetch(interval, "xxxxx", 9110, "user1", "user1", "localuser", synchronize, keepTime);
     var sut = new OneFetchJob(new Kernel(), mailSave, domainName, oneFetch, 3, 1000);
     var expected = false;
     //exercise
     var actual = sut.Job(new Logger(), DateTime.Now, this);
     //verify
     Assert.That(actual, Is.EqualTo(expected));
     //tearDown
     sut.Dispose();
 }
Exemplo n.º 5
0
 public void インターバルが10分の時_5分後の処理はキャンセルされる()
 {
     //setUp
     MailSave mailSave = null;
     var domainName = "";
     var interval = 10;//10分
     var synchronize = 0;
     var keepTime = 100;//100分
     var oneFetch = new OneFetch(interval,"127.0.0.1",9110,"user1","user1","localuser",synchronize,keepTime);
     var sut = new OneFetchJob(new Kernel(), mailSave, domainName, oneFetch, 3, 1000);
     var expected = false;
     //exercise
     //1回目の接続
     sut.Job(new Logger(), DateTime.Now, this);
     //2回目(5分後)の接続
     var actual = sut.Job(new Logger(), DateTime.Now.AddMinutes(5), this);
     //verify
     Assert.That(actual, Is.EqualTo(expected));
     //tearDown
     sut.Dispose();
 }
Exemplo n.º 6
0
 public void 動作確認()
 {
     //setUp
     MailSave mailSave = null;
     var domainName = "";
     var interval = 10;//10分
     var synchronize = 0;
     var keepTime = 100;//100分
     var oneFetch = new OneFetch(interval, "127.0.0.1", 9110, "user2", "user2", "localuser", synchronize, keepTime);
     var sut = new OneFetchJob(new Kernel(), mailSave, domainName, oneFetch, 3, 1000);
     var expected = true;
     //exercise
     var actual = sut.Job(new Logger(), DateTime.Now, this);
     //verify
     Assert.That(actual, Is.EqualTo(expected));
     //tearDown
     sut.Dispose();
 }