Exemplo n.º 1
0
        public void SendEmailControlled(string doc_type_short, string group_code, int run_no, byte rev_no,
                                        string receiver)
        {
            if (!string.IsNullOrEmpty(receiver))
            {
                string   mailto    = "";
                char[]   delimiter = new char[] { ',' };
                string[] email     = receiver.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
                int      max_email = 47;
                if (email.Length > max_email)//Max send email = 50
                {
                    for (int i = 0; i < max_email; i++)
                    {
                        mailto += "," + email[i];
                    }
                    mailto = mailto.Substring(1);
                }
                else
                {
                    mailto = receiver;
                }

                var get_doc = (from a in dbDC.V_Transaction
                               where a.doc_type_short == doc_type_short && a.group_code == group_code &&
                               a.run_no == run_no && a.rev_no == rev_no
                               select a).FirstOrDefault();

                if (get_doc != null)
                {
                    TNCUtility tnc_util = new TNCUtility();
                    string     subject  = "";
                    string     body     = "";//For Real
                    //string body = "Mail :" + mailto + "<br />";//For Test
                    string int_link = "http://webExternal/DocControl";
                    string ext_link = "http://webexternal.nok.co.th/DocControl";
                    string Param    = "/Home/ShowDocDetail?dt=" + get_doc.doc_type_short + "&gc=" + get_doc.group_code +
                                      "&rn=" + get_doc.run_no + "&rv=" + get_doc.rev_no;

                    subject = "Controlled (" + get_doc.doc_no + ")";
                    body    = "Dear. All Concern,<br /><br />" +
                              "<b>Document No. : </b>" + get_doc.doc_no + "<br />" +
                              "<b>Document Name : </b>" + get_doc.doc_name + "<br />" +
                              "<b>Effective Date : </b>" + get_doc.eff_date.Date.ToString("dd-MM-yyyy") + "<br />" +
                              "<b>You can see document at link ---> </b><a href='" + int_link + get_doc.attach_file.Substring(1) + "'>View</a><br />" +
                              "<b>Link : </b><a href='" + int_link + "/Home/Controlled'>Internal</a> | <a href='" + ext_link + "/Home/Controlled'>External</a><br />" +
                              "<br /><b>*This message is automatic sending from Document Control, please do not reply*</b>";

                    //tnc_util.SendMail(16, "*****@*****.**", mailto, subject, body);//For Real
                    tnc_util.SendMail(16, "*****@*****.**", "*****@*****.**", subject, body);//For Test
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            PackingChangeEntities db = new PackingChangeEntities();

            try
            {
                var query = from a in db.td_transaction
                            where a.act_id == null && a.status_id < 100
                            //orderby a.lv_id, a.org_id ascending
                            select a;

                //int i = 1;
                foreach (var q in query)
                {
                    GetEmail gm = new GetEmail();

                    string mailto = gm.ByOrg(q.org_id, q.lv_id);

                    if (!string.IsNullOrEmpty(mailto))
                    {
                        TNCUtility tnc_util = new TNCUtility();

                        string pkc = "PKC-" + q.gpcode + "-" + q.year + "-" + q.runno.ToString("000");

                        string int_link = "http://webExternal/PKC/Home";
                        string subject  = "[Remind] Packing Change waiting for process (" + pkc + ")";
                        string body     = //"Mail To : " + mailto + "<br />Dear. All Concern,<br /><br />" +
                                          "You have Packing Change No. <b>" + pkc +
                                          "</b> waiting for Process at State : " + q.tm_status.status_name + "<br />" +
                                          "<br /><a href='" + int_link + "/MainPCO?id=" + pkc + "'>Packing Change Online</a><br />" +
                                          "<br /><b>Best Regard.<br />" + "From Packing Change-Admin</b>";

                        tnc_util.SendMail(31, "*****@*****.**", mailto, subject, body);//For Real
                        //tnc_util.SendMail(31, "*****@*****.**", "*****@*****.**", subject, body);//For Test

                        //Console.WriteLine(i + ". " + pkc);
                        //i++;
                    }
                    //break;
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error PKC E-mail Remind");
                Console.ReadLine();
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            PackingChangeEntities db = new PackingChangeEntities();

            try
            {
                string email_test = "[email protected],[email protected]";//,[email protected]";
                string int_link   = "http://webExternal/PKC/Home/MainPCO?id=";

                var sale = from a in db.v_pack_std_qa_sale
                           where a.status == "Pending"
                           group a by a.sale into g
                           select new { sales = g.Key, list = g };

                foreach (var g in sale)
                {
                    GetEmail gm     = new GetEmail();
                    string   mailto = gm.ByOrg(g.sales.Value);

                    TNCUtility tnc_util = new TNCUtility();

                    string subject = "[Remind] Please Follow up Packing Standard";
                    string body    = "<style> table { border-collapse: collapse; } table, td, th { border: 1px solid black; } td, th { padding: 4px; }</style>";
                    //body += "Mail To : " + mailto + "<br />"; //For Test
                    body += "Dear. All Concern,<br /><br />";
                    body += "<table><tr><td>Control No.</td><td>Change Detail</td></tr>";

                    foreach (var l in g.list)
                    {
                        var pkc = "PKC-" + l.gpcode + "-" + l.year + "-" + l.runno.ToString("000");
                        body += "<tr><td><a href='" + int_link + pkc + "'>" + pkc + "</a></td><td>" + l.change_detail + "</td></tr>";
                    }

                    body += "</table><br />Packing Change Online";

                    //Console.WriteLine(body);
                    tnc_util.SendMail(31, "*****@*****.**", mailto, subject, body, bcc: email_test);//For Real
                    //tnc_util.SendMail(31, "*****@*****.**", "*****@*****.**", subject, body);//For Test
                }

                //--------------------------------------------//

                var qa = from a in db.v_pack_std_qa_sale
                         where a.status == null
                         group a by a.qa into g
                         select new { qa = g.Key, list = g };

                foreach (var g in qa)
                {
                    GetEmail gm     = new GetEmail();
                    string   mailto = gm.ByOrg(g.qa);

                    TNCUtility tnc_util = new TNCUtility();

                    string subject = "[Remind] Please Add Packing Standard";
                    string body    = "<style> table { border-collapse: collapse; } table, td, th { border: 1px solid black; } td, th { padding: 4px; }</style>";//"Dear. All Concern,<br /><br />";
                    //body += "Mail To : " + mailto;
                    body += "Dear. All Concern,<br /><br />";
                    body += "<table><tr><td>Control No.</td><td>Change Detail</td></tr>";//For Test

                    foreach (var l in g.list)
                    {
                        var pkc = "PKC-" + l.gpcode + "-" + l.year + "-" + l.runno.ToString("000");
                        body += "<tr><td><a href='" + int_link + pkc + "'>" + pkc + "</a></td><td>" + l.change_detail + "</td></tr>";
                    }

                    body += "</table><br />Packing Change Online";

                    //Console.WriteLine(body);
                    tnc_util.SendMail(31, "*****@*****.**", mailto, subject, body, bcc: "*****@*****.**");//For Real
                    //tnc_util.SendMail(31, "*****@*****.**", "*****@*****.**", subject, body, flag: 0);//For Test
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error PKC E-mail Remind QA, Sales");
                Console.ReadLine();
            }
        }
Exemplo n.º 4
0
        //Program Email Reminder for Review Document
        static void Main(string[] args)
        {
            //Program pgm = new Program();

            try
            {
                MailCenterEntities      dbMail = new MailCenterEntities();
                DocumentControlEntities dbDoc  = new DocumentControlEntities();
                TNC_ADMINEntities       dbTNC  = new TNC_ADMINEntities();

                DateTime dtNow   = DateTime.Now.Date;
                DateTime dtCheck = DateTime.Now.AddMonths(1).Date;//Before one month
                //DateTime dtTest = new DateTime(2015, 6, 6);//for Test

                //Review every 2 years and send email before due date 1 month.
                var query = from a in dbDoc.V_Max_Transaction
                            where a.check_date <= dtCheck && a.status_id == 100//100 = Controlled
                            select a;

                //var count_query = 0;
                //var count_send = 0;
                foreach (var q in query)
                {
                    GetEmail gm = new GetEmail();

                    string email = gm.GetEmailbyOrg(q.org_id, 0);//Get email Mgr. down

                    var get_mail = (from a in dbTNC.View_Organization
                                    where a.group_id == q.org_id
                                    select a).FirstOrDefault();

                    string cc = null;
                    if (get_mail != null)
                    {
                        cc += !string.IsNullOrEmpty(get_mail.DeptMgr_email) ? "," + get_mail.DeptMgr_email : "";
                        cc += !string.IsNullOrEmpty(get_mail.PlantMgr_email) ? "," + get_mail.PlantMgr_email : "";
                    }

                    cc = !string.IsNullOrEmpty(cc) ? cc.Substring(1) : null;

                    //Console.WriteLine("doc no:" + q.doc_no);//Comment for Real

                    if (!string.IsNullOrEmpty(email))
                    {
                        TNCUtility tnc_util = new TNCUtility();

                        string int_link = "http://webExternal/DocControl";
                        string ext_link = "http://webexternal.nok.co.th/DocControl";
                        string subject  = "Pls. review document no. " + q.doc_no;
                        string body     = "Dear. Document Owner,<br /><br />" +
                                          "<b>This document / format need to review period 2 years</b><br />" +
                                          "<b>Document No. : </b>" + q.doc_no + "<br />" +
                                          "<b>Document Name : </b>" + q.doc_name + "<br />" +
                                          "<b>You can see document at link ---> </b><a href='" + int_link + q.attach_file.Substring(1) + "'>View</a><br />" +
                                          "<b>Link : </b><a href='" + int_link + "/Home/OverDueReview'>Internal</a> | <a href='" + ext_link + "/Home/OverDueReview'>External</a><br />" +
                                          "<br /><b>*This message is automatic sending from Document Control, please do not reply*</b>";

                        tnc_util.SendMail(16, "*****@*****.**", email, subject, body, cc);//For Real
                        //tnc_util.SendMail(16, "*****@*****.**", "*****@*****.**", subject, body);//For Test
                        //count_send++;
                    }
                    //else
                    //{
                    //    Console.WriteLine("NO EMAIL:" + q.doc_no);
                    //}
                    //count_query++;
                }
                //Console.WriteLine("total : " + count_query + ", count send : " + count_send);
            }
            catch (Exception)
            {
                Console.WriteLine("Error E-mail Remind");
                Console.ReadLine();
            }
        }