//using System; //using System.Collections.Generic; //using System.Data; //using System.Diagnostics; //using System.Drawing; //using System.IO; //using System.Linq; //using System.Management; //using System.Net; //using System.Net.NetworkInformation; //using System.Runtime.Serialization.Formatters.Binary; //using System.Text; //using System.Windows.Forms; //namespace Project //{ // public static partial class UTIL // { // //public static Boolean SendMail(string title, string body, string from, string[] tolist, string file = "") // //{ // // //메일을 전송하고 나간다 // // Chilkat.MailMan mailman = new Chilkat.MailMan(); // // bool success = mailman.UnlockComponent("BLUPRT.CBX012020_rzDFf7pQAsCS"); // // if (success != true) // // { // // UTIL.MsgE("메일 전송이 실패되었습니다\n잠시 후 다시 시도하세요", true); // // return false; // // } // // else // // { // // mailman.SmtpHost = "10.101.10.6"; // // mailman.SmtpPort = 25; // // Chilkat.Email email = new Chilkat.Email(); // // email.Subject = title; // // //email.Body = this.textBox1.Text; // // email.SetHtmlBody(body.Replace("\r", "").Replace("\n", "
")); // // email.From = from; // // foreach (var to in tolist) // // email.AddTo(to.Substring(0, to.IndexOf('@')), to); // // if (System.IO.File.Exists(file)) // // email.AddFileAttachment(file); // // success = mailman.SendEmail(email); // // if (success != true) // // { // // UTIL.MsgE("발송 실패", true); // // return false; // // } // // success = mailman.CloseSmtpConnection(); // // if (success != true) // // { // // UTIL.MsgE("Connection to SMTP server not closed cleanly.", true); // // return false; // // } // // } // // return true; // //} // //public static string JobListToFile(Class.CHistoryJOB data, string jobdate, string jobseq, out int cnt) // //{ // // cnt = 0; // // if (string.IsNullOrEmpty(jobdate)) return string.Empty; // // //이미저장된 목록을 가져오고 중복된것은 피한다 // // var preSavedFile = System.IO.Path.Combine(COMM.SETTING.Data.Path_Data, "JobData", jobdate.Substring(0, 6), jobdate + "-" + jobseq + ".txt"); // // List preList = new List(); // // if (System.IO.File.Exists(preSavedFile)) preList.AddRange(System.IO.File.ReadAllLines(preSavedFile, System.Text.Encoding.UTF8)); // // //Temp // // var fiName = System.IO.Path.Combine(COMM.SETTING.Data.Path_Data, "UploadTemp", jobdate + "_" + jobseq + ".tab"); // // var fi = new System.IO.FileInfo(fiName); // // if (fi.Directory.Exists == false) fi.Directory.Create(); // // var sb = new System.Text.StringBuilder(); // // sb.AppendLine("#Time\tSID\tRID\tRAW"); // // var oklist = data.Items.Where(t => t.VisionData.RID.isEmpty() == false).ToArray(); // // foreach (var item in oklist) // // { // // //기존에 전송한 목록에 없어야 한다 // // if (item.error == Class.JobData.ErrorCode.None && item.VisionData.RID.isEmpty() == false) // // { // // sb.AppendLine(string.Format("{0}\t{1}\t{2}\t{3}", // // item.JobStart.ToString("yyyy-MM-dd HH:mm:sss"), item.VisionData.SID, item.VisionData.RID, item.VisionData.QROutRaw)); // // cnt += 1; // // } // // } // // try // // { // // System.IO.File.WriteAllText(fi.FullName, sb.ToString(), System.Text.Encoding.UTF8); // // return fi.FullName; // // } // // catch (Exception ex) // // { // // PUB.log.AddE("JobListToFile:" + ex.Message); // // return string.Empty; // // } // //} // //public static bool SendMail(string seqdate, string seqno) // //{ // // Chilkat.MailMan mailman = new Chilkat.MailMan(); // // bool success = mailman.UnlockComponent("BLUPRT.CBX012020_rzDFf7pQAsCS"); // // if (success != true) // // { // // Debug.WriteLine(mailman.LastErrorText); // // return false; // // } // // mailman.SmtpHost = "10.101.10.6"; // // mailman.SmtpPort = 25; // // // Create a new email object // // Chilkat.Email email = new Chilkat.Email(); // // var mailform = PUB.mailForm.FirstOrDefault(); // // if (mailform == null) // // return false; // // var subject = mailform.subject.Trim(); // // subject = subject.Replace("{seqdate}", seqdate); // // subject = subject.Replace("{seqno}", seqno); // // var buffer = System.IO.File.ReadAllText(UTIL.CurrentPath + "\\Mailform.html"); // // //시드별집계데이터생성 // // System.Text.StringBuilder sbFileSID = new StringBuilder(); // // System.Text.StringBuilder sbFileREEL = new StringBuilder(); // // sbFileSID.AppendLine(string.Format("NO,SID,작업수량,예정수량,UNIT")); // // sbFileREEL.AppendLine(string.Format("NO,SID,REEL,QTY,TIME")); // // // int cntrid = 1; // // System.IO.File.WriteAllText(UTIL.CurrentPath + "\\result_sidsummary.csv", sbFileSID.ToString(), System.Text.Encoding.Default); // // System.IO.File.WriteAllText(UTIL.CurrentPath + "\\result_reelist.csv", sbFileREEL.ToString(), System.Text.Encoding.Default); // // //메일본문의 내용 치환 // // var contents = buffer.Trim(); // // contents = contents.Replace("{seqdate}", seqdate); // // contents = contents.Replace("{seqno}", seqno); // // email.Subject = subject; // // email.SetHtmlBody(contents); // // email.From = "ReelSorter"; // // email.AddFileAttachment(UTIL.CurrentPath + "\\result_sidsummary.csv"); // // email.AddFileAttachment(UTIL.CurrentPath + "\\result_reelist.csv"); // // System.Text.StringBuilder maillist = new StringBuilder(); // // foreach (DataSet1.MailRecipientRow r in PUB.mailList.Rows) // // { // // success = email.AddTo(r.Name, r.Address); // // maillist.Append(string.Format("{0}({1})", r.Name, r.Address)); // // } // // success = mailman.SendEmail(email); // // if (success != true) // // { // // Debug.WriteLine(mailman.LastErrorText); // // return false; // // } // // success = mailman.CloseSmtpConnection(); // // if (success != true) // // { // // Debug.WriteLine("Connection to SMTP server not closed cleanly."); // // PUB.log.AddE("메일 발송 실패(" + maillist.ToString() + ")"); // // } // // PUB.log.AddI("메일 발송 완료(" + maillist.ToString() + ")"); // // return true; // //} // } //}