xusc 4 weeks ago
parent
commit
6764fbd104
  1. BIN
      .vs/ICSSoft.FromERP/v16/.suo
  2. 1
      ICSSoft.FromERP/App.config
  3. 193
      ICSSoft.FromERP/AutoSendMail_KBS.cs
  4. 1
      ICSSoft.FromERP/ICSSoft.FromERP.csproj

BIN
.vs/ICSSoft.FromERP/v16/.suo

Binary file not shown.

1
ICSSoft.FromERP/App.config

@ -38,6 +38,7 @@
<connectionStrings>
<!--<add name="SysConnectionString" connectionString="Data Source=119.3.29.177;Database=ICSMESBase;Uid=gitea;Pwd=aA123456;"/>-->
<add name="SysConnectionString" connectionString="server=192.168.93.135; Database=ICSMESBase_RuiTeng; User ID=sa; Password=rhyt0n***;MultipleActiveResultSets=True;Connect Timeout=300;"/>
<!--<add name="SysConnectionString" connectionString="server=172.66.9.13; Database=ICSWMS_KBS; User ID=sa; Password=Drcoffee201609;MultipleActiveResultSets=True;Connect Timeout=300;"/>-->
<!--<add name="SysConnectionString" connectionString="server=192.168.93.135; Database=ICSMESBase_RuiTengZS; User ID=sa; Password=rhyt0n***;MultipleActiveResultSets=True;Connect Timeout=300;"/>-->
<!--<add name="SysConnectionString" connectionString="server=192.168.1.155; Database=ICSMESBase_WeiMas; User ID=sa; Password=aA123456;MultipleActiveResultSets=True;Connect Timeout=300;"/>-->
<!--<add name="SysConnectionString" connectionString="server=172.16.12.201; Database=ICSJYMES; User ID=sa; Password=aA123456;MultipleActiveResultSets=True;Connect Timeout=300;"/>-->

193
ICSSoft.FromERP/AutoSendMail_KBS.cs

@ -0,0 +1,193 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Quartz;
using System.Data;
//using NFine.Data.Extensions;
using System.Configuration;
using ICSSoft.FromERP;
//using ICSSoft.SendMail;
using System.Data.SqlClient;
using System.Net;
using System.Net.Mail;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
namespace ICSSoft.FromERP
{
/// <summary>
/// 发送SQE人员复判
/// </summary>
public class AutoSendMail_KBS : IJob
{
private static object key = new object();
private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public void Execute(IJobExecutionContext context)
{
try
{
lock (key)
{
log.Info("开始……………………………………………………………………");
Execute();
log.Info("结束……………………………………………………………………");
}
}
catch (Exception ex)
{
log.Error(ex.ToString());
}
}
private void Execute()
{
string erpName = ICSHelper.GetConfigString()["ERPDB"];
string conStr = ICSHelper.GetConnectString();
string Namespace = this.GetType().Namespace;
//string Class = this.GetType().Name;
DataTable dt = ICSHelper.GetOldERPDB(conStr);
foreach (DataRow dr1 in dt.Rows)
{
string WorkPoint = dr1["WorkPointCode"].ToString();
string Class = this.GetType().Name + WorkPoint;
string sql = @"select
a.*
from IcsMatCheckResult a with(nolock)
where 1=1
and a.WorkPoint='KC47'
and a.CheckNo='CR202410290034'
--and a.IsCheckComplete='是'
--and a.AsnCode='DNA08S000072400088'
--and a.InvCode='8S11332'
--and a.InvBatcgNo=''
order by a.Mtime desc
";
DataTable dtInInfo = ICSHelper.ExecuteTable(conStr, sql);
if (dtInInfo == null || dtInInfo.Rows.Count == 0)
{
return;
}
string MailOpen = ICSHelper.GetConfigString("MailOpen");
if (MailOpen != "true")
{
return;
}
string SendHost = ICSHelper.GetConfigString("SendHost");
string StrSendPort = ICSHelper.GetConfigString("SendPort");
int SendPort = 25;
if (!string.IsNullOrEmpty(StrSendPort))
SendPort = Convert.ToInt32(ICSHelper.GetConfigString("SendPort"));
string SendDisplayName = ICSHelper.GetConfigString("SendDisplayName");
string SendAddress = ICSHelper.GetConfigString("SendAddress");
string SendPassword = ICSHelper.GetConfigString("SendPassword");
string sqls = @" select *
from V_QuerySysEnumItem a
where a.F_EnCode = 'SQESendMail'";
DataTable dts = ICSHelper.ExecuteTable(conStr, sqls);
string Email = string.Empty;
foreach (DataRow drs in dts.Rows)
{
Email += drs["Ext1"].ToString() + ",";
}
foreach (DataRow dr in dtInInfo.Rows)
{
string TOAddress = Email.TrimEnd(',');
string CCAddress = "";
string Subject = "SQE复判提醒";
bool isBodyHtml = true;
//string VenName = dr["VENDORNAME"].ToString();
//string STNO = dr["STNO"].ToString();
string NowDate = DateTime.Now.GetDateTimeFormats('D')[0].ToString();
string body = "SQE复判" + ":";
body += "\r\n";
body += " 您好!有一个来料复判的检验单,单号为:" + dr["CheckNo"].ToString() + " 的检验单已经超过48小时没有复判,请及时处理 !";
body += "\r\n";
body += " 苏州咖博士咖啡系统科技有限公司";
body += "\r\n";
body += " " + NowDate;
//string StrConn = ConfigurationManager.ConnectionStrings["connstr"].ConnectionString;
SendEmail(conStr, SendHost, SendPort, SendDisplayName, SendAddress, SendPassword, TOAddress, CCAddress, Subject, isBodyHtml, body);
}
}
}
public void SendEmail(string ConnectionString, string SendHost, int SendPort, string SendDisplayName, string SendAddress, string SendPassword, string TOAddress, string CCAddress, string Subject, bool IsBodyHtml, string Body)
{
try
{
SmtpClient smtpClient = new SmtpClient
{
//EnableSsl = false,
UseDefaultCredentials = false,
Host = SendHost,
Port = SendPort,
Credentials = new NetworkCredential(SendAddress, SendPassword)
};
MailMessage mailMessage = new MailMessage
{
Subject = Subject,
SubjectEncoding = Encoding.GetEncoding("utf-8"),
BodyEncoding = Encoding.GetEncoding("utf-8"),
From = new MailAddress(SendAddress, SendDisplayName),
IsBodyHtml = IsBodyHtml,
Body = Body
};
string[] array = TOAddress.Split(new char[]
{
','
});
string[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
string text = array2[i];
if (!string.IsNullOrEmpty(text))
{
mailMessage.To.Add(text);
}
}
string[] array3 = CCAddress.Split(new char[]
{
','
});
array2 = array3;
for (int i = 0; i < array2.Length; i++)
{
string text2 = array2[i];
if (!string.IsNullOrEmpty(text2))
{
mailMessage.CC.Add(text2);
}
}
ServicePointManager.ServerCertificateValidationCallback = ((object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => true);
smtpClient.Send(mailMessage);
//InsertData(ConnectionString, SendHost, SendPort, SendDisplayName, SendAddress, SendPassword, TOAddress, CCAddress, Subject, IsBodyHtml, Body, "1", null);
}
catch (Exception ex)
{
//InsertData(ConnectionString, SendHost, SendPort, SendDisplayName, SendAddress, SendPassword, TOAddress, CCAddress, Subject, IsBodyHtml, Body, "2", ex.Message);
throw ex;
}
}
}
}

1
ICSSoft.FromERP/ICSSoft.FromERP.csproj

@ -86,6 +86,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AutoSendMail_KBS.cs" />
<Compile Include="Extension\ConvertExt.cs" />
<Compile Include="Helper\DBHelper.cs" />
<Compile Include="Extension\CommonExt.cs" />

Loading…
Cancel
Save