private void SetMailList(OdbcDataReader reader, List <ObjMailElement> list) { string sLUid; int nLUid; string sName; Boolean bFlag; int max, idx; ObjMailElement ome; sLUid = GetReaderString(reader, 0); nLUid = m_libCmn.StrToInt(sLUid); sName = GetReaderString(reader, 1); bFlag = false; max = list.Count; for (idx = 0; idx < max; idx++) { if (nLUid == list[idx].m_nLUid) { list[idx].m_sCName = sName; bFlag = true; } } if (bFlag == false) { ome = new ObjMailElement(); ome.m_nLUid = nLUid; ome.m_sCName = sName; list.Add(ome); } }
private void SetLogInfo(ObjMailElement ome, int nLMode) { string sMsg; string sInfo; sInfo = "[MD][○○時○○分]"; sInfo = AnlizeString(ome, sInfo); if (nLMode == 1) { sMsg = sInfo + "に" + ome.m_sCName + "さん到着"; } else if (nLMode == 2) { sMsg = sInfo + "に" + ome.m_sCName + "さん帰宅"; } else { sMsg = sInfo + "に" + ome.m_sCName + "さん認証"; } if (m_objCrt != null) { Type type = m_objCrt.GetType(); if (type == typeof(C100SendMailControl)) { m_objSMC = (C100SendMailControl)m_objCrt; m_objSMC.AddLstLog(sMsg); } } DoDispatch(); }
private string AnlizeString(ObjMailElement ome, String sSrcStr) { string retStr; string cmdStr; string[] aryVal; int max, i; Boolean flag; flag = false; cmdStr = ""; retStr = ""; max = sSrcStr.Length; for (i = 0; i < max; i++) { if (sSrcStr[i] == '[') { flag = true; cmdStr = ""; } else if (sSrcStr[i] == ']') { if (flag == true) { retStr = retStr + AnlizeCommand(ome, cmdStr); } flag = false; } else { if (flag == true) { cmdStr = cmdStr + sSrcStr[i]; } else { retStr = retStr + sSrcStr[i]; } } } return(retStr); }
private List <ObjMailElement> GetDataGrid() { List <ObjMailElement> list; int max, idx; DataRow drItem; ObjMailElement ome; string sId; list = new List <ObjMailElement>(); max = m_dt.Rows.Count; for (idx = 0; idx < max; idx++) { drItem = m_dt.Rows[idx]; ome = new ObjMailElement(); sId = drItem["col_uid"] as string; ome.m_nLUid = m_libCmn.StrToInt(sId); ome.m_sCName = drItem["col_uname"] as string; ome.m_sSendName = drItem["col_sendname"] as string; ome.m_sSendMail = drItem["col_sendmail"] as string; list.Add(ome); } return(list); }
private List <ObjMailElement> LoadMailElement(string sLoadFileName) { List <ObjMailElement> lst; string sData; string[] aryLine; int max, idx; string[] aryClm; ObjMailElement ome; sData = m_libCmn.LoadFileSJIS(sLoadFileName); if (sData == "") { return(null); } sData = sData.Replace("\r\n", "\n"); aryLine = sData.Split('\n'); lst = new List <ObjMailElement>(); max = aryLine.Length; for (idx = 0; idx < max; idx++) { if (aryLine[idx] == "") { break; } aryClm = aryLine[idx].Split(','); ome = new ObjMailElement(); ome.m_nLUid = m_libCmn.StrToInt(aryClm[0]); ome.m_sCName = aryClm[1]; ome.m_sSendName = aryClm[2]; ome.m_sSendMail = aryClm[3]; lst.Add(ome); } return(lst); }
private void SendMail(ObjMailElement ome, int nLMode) { string sMsg; string sFromMail; string sFromName; string sFromPassWord; string sToMail; string sToName; string sSubject; string sBody; DoDispatch(); if (nLMode == 1) { sSubject = GetArrivalSubject(); sSubject = AnlizeString(ome, sSubject); sBody = GetArrivalBody(); sBody = AnlizeString(ome, sBody); } else if (nLMode == 2) { sSubject = GetRetHomeSubject(); sSubject = AnlizeString(ome, sSubject); sBody = GetRetHomeBody(); sBody = AnlizeString(ome, sBody); } else // ファンクションが押されていないときのメール(nLMode = 0) { sSubject = "[受信者名]様へ認証のご案内"; sSubject = AnlizeString(ome, sSubject); sBody = "[受信者名]様へ\n[ユーザ名]さんは[西暦年月日]に認証されました"; sBody = AnlizeString(ome, sBody); } sFromName = GetServerName(); sFromMail = GetServerMail(); sFromPassWord = GetServerPassWord(); sToMail = ome.m_sSendMail; sToName = ome.m_sSendName + "様"; string url; //url = "http://www.unismail.net/sendmail.php"; url = "http://www.hurrymulti.com/unis/sendmail.php"; HttpClient httpClient = new HttpClient(); var aryPair = new Dictionary <string, string>(); aryPair["tomail"] = sToMail; aryPair["toname"] = sToName; aryPair["frommail"] = sFromMail; aryPair["fromname"] = sFromName; aryPair["subject"] = sSubject; aryPair["body"] = sBody; var content = new FormUrlEncodedContent(aryPair); Task <HttpResponseMessage> response = httpClient.PostAsync(url, content); response.Wait(); String sRet = response.Result.Content.ReadAsStringAsync().Result; String[] sAry = sRet.Split(','); if (sAry[0] == "0") { sMsg = sSubject + "メール送信失敗(" + sToName + ")"; if (m_objCrt != null) { Type type = m_objCrt.GetType(); if (type == typeof(C100SendMailControl)) { m_objSMC = (C100SendMailControl)m_objCrt; m_objSMC.AddLstLog(sMsg); } } } }
// メールを送信 public void SendMailLoop(ObjRecordElement record) { int nLUid; int nLTid; string sTName; string sCName; string sCDate; string sCTime; int nLUserType; string sCUnique; int nLMode; string sMsg; List <ObjMailElement> listOME; List <ObjAdminElement> listOAE; int max, idx; ObjMailElement ome; nLTid = record.m_nLTid; sTName = record.m_sTName; nLUid = record.m_nLUid; sCName = record.m_sCName; sCDate = record.m_sCDate; sCTime = record.m_sCTime; nLUserType = record.m_nLUserType; sCUnique = record.m_sCUnique; nLMode = record.m_nLMode; if (m_sBFDate == sCDate && m_sBFTime == sCTime && m_nBFId == nLUid) { return; } m_sBFDate = sCDate; m_sBFTime = sCTime; m_nBFId = nLUid; if (nLUid == -1) { sMsg = sCDate.Substring(4, 2) + "月" + sCDate.Substring(6, 2) + "日 "; sMsg = sMsg + sCTime.Substring(0, 2) + "時" + sCTime.Substring(2, 2) + "分"; sMsg = sMsg + " 認証失敗"; if (m_objCrt != null) { Type type = m_objCrt.GetType(); if (type == typeof(C100SendMailControl)) { m_objSMC = (C100SendMailControl)m_objCrt; m_objSMC.AddLstLog(sMsg); } } return; } ome = new ObjMailElement(); ome.m_sCName = sCName; ome.m_sCDateTime = sCDate + sCTime; ome.m_nLTid = nLTid; ome.m_sTName = sTName; SetLogInfo(ome, nLMode); if (nLMode == 1 || nLMode == 2 || nLMode == 3) { if (nLMode == 3) { nLMode = m_nDefLMode; } else { m_nDefLMode = nLMode; } listOME = GetMailElementList(); max = listOME.Count; for (idx = 0; idx < max; idx++) { if (listOME[idx].m_nLUid == nLUid) { listOME[idx].m_sCDateTime = sCDate + sCTime; listOME[idx].m_nLTid = nLTid; listOME[idx].m_sTName = sTName; try { SendMail(listOME[idx], nLMode); } catch (Exception ex) { } } } if (GetAdminSend() == true) { if (GetAdminSend() == true) { listOAE = GetAdminElementList(); max = listOAE.Count; for (idx = 0; idx < max; idx++) { ome.m_sSendName = listOAE[idx].m_sName; ome.m_sSendMail = listOAE[idx].m_sMail; try { SendMail(ome, nLMode); } catch (Exception ex) { } } } } } }
private string AnlizeCommand(ObjMailElement ome, String sCommand) { string sYear; string sMonth; string sDay; string sHour; string sMinute; string sSecond; string sGG; sYear = ome.m_sCDateTime.Substring(0, 4); sMonth = ome.m_sCDateTime.Substring(4, 2); sDay = ome.m_sCDateTime.Substring(6, 2); sHour = ome.m_sCDateTime.Substring(8, 2); sMinute = ome.m_sCDateTime.Substring(10, 2); sSecond = ome.m_sCDateTime.Substring(12, 2); if (sCommand == "ターミナルID") { return(ome.m_nLTid.ToString()); } else if (sCommand == "ターミナル名") { return(ome.m_sTName); } if (sCommand == "ユーザID") { return(ome.m_nLUid.ToString()); } else if (sCommand == "ユーザ名") { return(ome.m_sCName); } else if (sCommand == "受信者名") { return(ome.m_sSendName); } else if (sCommand == "受信者メール") { return(ome.m_sSendMail); } else if (sCommand == "西暦年月日") { return(sYear + "年" + sMonth + "月" + sDay + "日"); } else if (sCommand == "和暦年月日") { sGG = AnlizeNengou(sYear); return(sGG + "年" + sMonth + "月" + sDay + "日"); } else if (sCommand == "MD") { return(sMonth + "月" + sDay + "日"); } else if (sCommand == "○○時○○分") { return(sHour + "時" + sMinute + "分"); } else if (sCommand == "○○:○○") { return(sHour + ":" + sMinute); } else if (sCommand == "hhmmss") { return(sHour + ":" + sMinute + ":" + sSecond); } return(""); }