/////////////////////////////////////// public void setup() { String id = getVal("id"); String zone = getVal("zone"); String eventType = getVal("eventType"); String eventDate = getVal("eventDate"); if (recipient == "") { recipient = getVal("recipient"); } if (sendVia == "") { sendVia = getVal("sendVia"); } //get the name of the item NoxCore.cId i = new NoxCore.cId(); String name = i.getName(id); try { Boolean bSend = false; String verb = ""; //convert time to ints for comparison DateTime dEvent = Convert.ToDateTime(eventDate); String resKey = ""; //arrival if(m_inTimeWindow(dEvent, arriveBeginHour, arriveBeginMinute, arriveEndHour, arriveEndMinute)) { verb = "entered"; resKey = verb + "." + dEvent.Month.ToString() + "." + dEvent.Day.ToString(); if (m_getLastMovement(id) != resKey) { m_setLastMovement(id, resKey); bSend = true; } } //exit if (m_inTimeWindow(dEvent, exitBeginHour, exitBeginMinute, exitEndHour, exitEndMinute)) { verb = "exited"; resKey = verb + "." + dEvent.Month.ToString() + "." + dEvent.Day.ToString(); if (m_getLastMovement(id) != resKey) { m_setLastMovement(id, resKey); bSend = true; } } //transmission if (bSend) { //format the message String message = ""; message = name + " has " + verb + " " + zone + " at " + dEvent.ToShortTimeString(); if (sendVia.ToLower() == "smtp") { m_sendSMTP(recipient, message); } if (sendVia.ToLower() == "sms") { m_sendSMS(recipient, message); } } if (debug) { NoxCore.cLog log = new NoxCore.cLog(); log.write("timeClock.aspx.cs.setup() debug id:" + id + " send:" + bSend.ToString() + " sendVia:" + sendVia + " verb:" + verb + " eventDate:" + dEvent.ToString() + " resKey:" + resKey + " dbKey:" + m_getLastMovement(id)); } } catch(Exception e) { NoxCore.cLog log = new NoxCore.cLog(); log.write("timeClock.aspx.cs.setup() " + e.Message); } }
///////////////////////////////////////// public void m_sendSMS(String recipient, String message) { NoxComm.cHTTP http = new NoxComm.cHTTP(); //http://bulkpush.mytoday.com/BulkSms/SingleMsgApi?feedid=1879&username=9967025255&password=hello&To=919967025255&Text=Hellocheck2350&time=200812110950&senderid=testSenderID //1) Channel Name : GYAANTECH_API //Resource Id : 337457 //Log in id - 9820033441 //Password - awtpw //NDNC check : ON //*URL for checking API: http://bulkpush.mytoday.com/BulkSms/ try { // netCore wants spaces replaced with + message = message.Replace(" ", "+"); http.serverName = "bulkpush.mytoday.com"; http.page = "BulkSms/SingleMsgApi"; http.addData("feedid", feedId); http.addData("username", userName); http.addData("password", password); http.addData("To", recipient); http.addData("Text", message); http.addData("senderid", senderId); // transmit the request output = http.get(); } catch (Exception e) { NoxCore.cLog log = new NoxCore.cLog(); log.write("timeClock.aspx.cs.sendSMS(): " + e.Message); } //debug logging if (debug) { NoxCore.cLog log = new NoxCore.cLog(); log.write("timeClock.aspx.cs.sendSMS() URL " + http.URL); log.write("timeClock.aspx.cs.sendSMS() output " + output); } }
///////////////////////////////////////// public void m_sendSMTP(String recipient, String message) { NoxComm.cSMTP mail = new NoxComm.cSMTP(); String body = ""; String subject = ""; //standard settings mail.server = NoxCore.cConfig.smtpServer; mail.port = NoxCore.cConfig.smtpPort; mail.username = NoxCore.cConfig.smtpUserName; mail.password = NoxCore.cConfig.smtpPassword; mail.TLS = NoxCore.cConfig.smtpTLS; mail.from = NoxCore.cConfig.smtpFrom; mail.to = recipient; mail.subject = message; mail.body = message; String response = mail.send(); //debug logging if (debug) { NoxCore.cLog log = new NoxCore.cLog(); log.write("timeClock.aspx.cs.sendSMTP() " + response + " server: " + mail.server); } }