Exemplo n.º 1
0
        protected override void OnStart(string[] args)
        {
            string outputDirectory       = Settings.Default.outputDirectory;
            string sqlConnectionString   = Settings.Default.sqlConnectionString;
            int    sendMessageCount      = Settings.Default.sendMessageCount;
            int    sendDelayInHour       = Settings.Default.sendDelayInHour;
            int    checkIntervalInSecond = Settings.Default.checkIntervalInSecond;
            string logPath        = Settings.Default.logPath;
            int    maxLogSizeInKb = Settings.Default.maxLogSizeInKb;

            var log = new FileInfo(logPath);

            if (log.Exists && log.Length > maxLogSizeInKb)
            {
                File.Delete(logPath);
            }

            _timer.Interval = checkIntervalInSecond * 100;
            _timer.Start();

            _timer.Elapsed += (sender, eventArgs) =>
            {
                try
                {
                    MT103.Send(sqlConnectionString, new DirectoryInfo(outputDirectory), sendMessageCount, sendDelayInHour);
                }
                catch (Exception e)
                {
                    File.AppendAllText(logPath, DateTime.Now + "    " + e.ToString() + "\n\n");
                }
            };
        }
Exemplo n.º 2
0
 public void SendTestSingle()
 {
     try
     {
         MT103.Send(CONNECTION_STRING, new DirectoryInfo(OUTPUT_DIRECTORY), "ССС140118000001");
         Assert.IsTrue(true);
     }
     catch (Exception e)
     {
         Assert.Fail(e.ToString());
     }
 }
Exemplo n.º 3
0
        public void SendTestMany()
        {
            try
            {
                //for (int i = 0; i < 100; i++)
                //{
                //Thread.Sleep(new TimeSpan(0, 0, 0));
                MT103.Send(CONNECTION_STRING, new DirectoryInfo(OUTPUT_DIRECTORY), 1000, 1);
                //}

                Assert.IsTrue(true);
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
        }