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"); } }; }
public void SendTestSingle() { try { MT103.Send(CONNECTION_STRING, new DirectoryInfo(OUTPUT_DIRECTORY), "ССС140118000001"); Assert.IsTrue(true); } catch (Exception e) { Assert.Fail(e.ToString()); } }
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()); } }