Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            SEC_OTN otn = new SEC_OTN();

            otn.DBConnect();
            var file = otn.getOnTimeData().ToFileWrite(path);   //ToFileWrite() path parameter input

            otn.DBdisconnet();

            #region FTP UPLoad
            ExportFile previousFile = ExportFile.GetFile("PCBINFOR_A0ND" + DateTime.Now.ToString("yyyyMMddHH"), "ff", previousPath);

            FtpServer ftp = new FtpServer()
            {
                Host = "stftp.simmtech.com", UserName = "******", Password = "******", Path = "/ymsoy"
            };
            ftp.ProgressChanged += Ftp_ProgressChanged;
            ftp.Upload(previousFile);

            //FtpServer ftp = new FtpServer() { Host = "stftp.simmtech.com", UserName = "******", Password = "******", Path = "/ymsoy" };
            //ftp.ProgressChanged += Ftp_ProgressChanged;
            //ftp.Upload(file);
            #endregion

            #region e-Mail Send
            SmtpServer smtp = new SmtpServer()
            {
                Host = "systemmail.simmtech.com", Port = 25, UserName = "******", Password = ""
            };
            smtp.Attatchments.Add(file.FullName);
            smtp.Attatchments.Add(logfile.FullName);
            smtp.From = smtp.UserName;

            smtp.To.Add("*****@*****.**");   //권정수 팀장
            smtp.To.Add("*****@*****.**");   //박진희 차장
            smtp.To.Add("*****@*****.**"); //이규호 주임
            smtp.To.Add("*****@*****.**");   //김화영 주임
            smtp.CC.Add("*****@*****.**");
            smtp.CC.Add("jipark @simmtech.com");
            smtp.CC.Add("*****@*****.**");
            smtp.CC.Add("*****@*****.**");
            //smtp.To.Add("*****@*****.**");
            smtp.Subject = "[SEC OTN] - " + file.Name + " 첨부 건.";
            smtp.Body.Append("ATTACH SEC OTN DATA FILE AND LOG FILE.");
            smtp.Send();
            #endregion
        }
        public static ExportFile ToFileWrite(this List <SEC_OTN_DATA> otn, string path)
        {
            ExportFile file = ExportFile.GetFile("PCBINFOR_A0ND" + DateTime.Now.AddDays(1).ToString("yyyyMMddHH"), "ff", path);

            List <string> fileheader = new List <string>()
            {
                "Vendor_Code", "Material_Code", "Diagram_No", "Lot_ID",
                "AOI_Start_Time", "AOI_End_Time",
                "AOI_In_Qty", "AOI_Out_Qty", "AOI_YLD",
                "AOI_Open_Qty", "AOI_Open_YLD",
                "AOI_Short_Qty", "AOI_Short_YLD",
                "BBT_Start_Time", "BBT_End_Time",
                "BBT_In_Qty", "BBT_Out_Qty", "BBT_YLD",
                "BBT_Open_Qty", "BBT_Open_YLD",
                "BBT_Short_Qty", "BBT_Short_YLD"
            };

            try
            {
                using (StreamWriter writer = new StreamWriter(file.FullName, false, new UTF8Encoding(false)))
                {
                    writer.WriteLine(String.Join(",", fileheader));

                    foreach (var lotdata in otn)
                    {
                        writer.WriteLine(lotdata.ToString());
                    }
                }

                //StreamWriter writer = File.CreateText(file.FullName);
                //writer.WriteLine(String.Join(",", fileheader));

                //foreach (var v in otn)
                //{
                //    writer.WriteLine(v.ToString());
                //}
                //writer.Dispose();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return(file);
        }