..
This commit is contained in:
@@ -1,100 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace JobReportMailService
|
||||
{
|
||||
partial class Program
|
||||
static class Program
|
||||
{
|
||||
static CSetting setting = new CSetting();
|
||||
static DateTime ChkAutoDate = DateTime.Now.AddDays(-1);
|
||||
static string vGcode = "EET1P";
|
||||
static bool cn = false;
|
||||
static DateTime LastUpdateTime = DateTime.Now.AddHours(-1);
|
||||
static DateTime ConsoleTime = DateTime.Now.AddDays(-1);
|
||||
|
||||
|
||||
static void Main(string[] args)
|
||||
/// <summary>
|
||||
/// 해당 애플리케이션의 주 진입점입니다.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
setting = new CSetting();
|
||||
setting.Load();
|
||||
if (setting.Xml.Exist() == false)
|
||||
{
|
||||
Console.WriteLine("new setting file make");
|
||||
setting.Save();
|
||||
}
|
||||
|
||||
|
||||
while (true)
|
||||
{
|
||||
//등록된 날짜를 확인하여, 해당 일자가 일반 평일 이라면 8시간 체크해서 메일을 보낸다.
|
||||
//등록된 날짜가 토,일은 제외한다.
|
||||
|
||||
var ts = DateTime.Now - LastUpdateTime;
|
||||
if (ts.TotalMinutes <= 15)
|
||||
{
|
||||
//15분 미만이면 동작하지 않는다
|
||||
if ((DateTime.Now - ConsoleTime).TotalHours >= 1.0)
|
||||
{
|
||||
Console.WriteLine("15분 미만이라 동작하지 않습니다");
|
||||
ConsoleTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
else if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday || DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
|
||||
{
|
||||
//토,일요일에는 동작하지 않는다
|
||||
if ((DateTime.Now - ConsoleTime).TotalHours >= 1.0)
|
||||
{
|
||||
Console.WriteLine("토/일에는 동작하지 않습니다");
|
||||
ConsoleTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
else if (DateTime.Now.Hour < 9)
|
||||
{
|
||||
if ((DateTime.Now - ConsoleTime).TotalHours >= 1.0)
|
||||
{
|
||||
Console.WriteLine("9시 이전에는 동작하지 않습니다");
|
||||
ConsoleTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastUpdateTime = DateTime.Now;
|
||||
try
|
||||
{
|
||||
WorkDay();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("일간업무알림 실패: " + ex.Message);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
WorkWeek();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("주간업무알림 실패: " +ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
System.Threading.Thread.Sleep(60000); //1분단위로 체크한다
|
||||
}
|
||||
}
|
||||
|
||||
static string MailSort(string addr, string except)
|
||||
{
|
||||
if (string.IsNullOrEmpty(except)) return addr;
|
||||
var alist = addr.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
var elist = except.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
foreach (var item in elist)
|
||||
alist.Remove(item);
|
||||
if (alist.Count < 1) return string.Empty;
|
||||
return string.Join(";", alist);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MDIParent1());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user