protected override void OnStart(string[] args) { timer1 = new Timer(); // every 30 secs // this.timer1.Interval = 30000; // every 1 min this.timer1.Interval = 5 * 60 * 1000; this.timer1.Elapsed += new ElapsedEventHandler(this.timer1_Tick); timer1.Enabled = true; SendSMSToParents.WriteErrorLog("Test Window Service Started"); }
//public string SendSms222(DBSite site, string mobileNos, string msg, UserBLL.User usr, HttpResponse res, bool isUnicode) //{ // //smsIndiaHub // string sUser = "******"; // string spwd = "pantnagar"; // string sNumber = mobileNos; // string sMessage = msg; // string sSenderID = usr.SenderId ; // string MessageData = msg; // //string sURL = "http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=" + sNumber + "&sid=" + sSenderID + "&msg=" + msg + "&fl=0&gwid=2"; // // unicode // // http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user=yourUserID&password=yourPassword&msisdn=919898xxxxxx&sid=SenderId&msg=परीक्षण संदेश &fl=0&dc=8&gwid=2 // string sURL = "http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=" + sNumber + "&sid=" + sSenderID + "&msg=" + msg + "&fl=0&dc=8&gwid=2"; // string sResponse = GetResponse(sURL); // //res.Write(sResponse); // return sResponse; //} //public string SendSms(DBSite site, string mobileNos, string msg, UserBLL.User usr, HttpResponse res, bool isUnicode) //{ // //smsIndiaHub // string sUser = "******"; // string spwd = "pantnagar"; // //string spwd = "Pantnagar@123"; // string sNumber = mobileNos; // string sMessage = msg; // string sSenderID = usr.SenderId; // string MessageData = msg; // string sURL = ""; // isUnicode = ContainsUnicodeCharacter(msg); // if (isUnicode) // { // //sURL = "http://trans.smsleads.in/sendsms.jsp?user="******"&password="******"&mobiles=" + sNumber + "&sms=" + msg + "&senderid=" + sSenderID + "&verion=3&unicode=1"; // //sURL = "http://websms.itfisms.com/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=" + sNumber + "&sid=" + sSenderID + "&msg=" + msg + "&fl=0&dc=8&gwid=2"; // sURL = "http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=" + sNumber + "&sid=" + sSenderID + "&msg=" + msg + "&fl=0&dc=8&gwid=2"; // //sURL = "http://login.blesssms.com/api/mt/SendSMS?" // //sURL = "http://184.171.171.74/api/mt/SendSMS?" // //+ "user=Sandeep99" // //+ "&password=pantnagar" // // + "&senderid=" + sSenderID // // + "&channel=Trans" // // + "&DCS=8" // // + "&flashsms=0" // //+ "&text=" + msg // // + "&route=4" // //+ "&number=" + mobileNos; // //Gujrat // // sURL = "http://sms.hspsms.com/sendSMS?username="******"&password=2314&message=" + sMessage + "&sendername=" + sSenderID + "&smstype=TRANS&numbers=" + sNumber + "&apikey=d6a74a66-e6b8-430a-9121-52aa758c34fa"; // } // else // { // //sURL = "http://trans.smsleads.in/sendsms.jsp?user="******"&password="******"&mobiles=" + sNumber + "&sms=" + msg + "&senderid=" + sSenderID + "&verion=3&unicode=0"; // //sURL = "http://websms.itfisms.com/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=" + sNumber + "&sid=" + sSenderID + "&msg=" + msg + "&fl=0&gwid=2"; // sURL = "http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=" + sNumber + "&sid=" + sSenderID + "&msg=" + msg + "&fl=0&gwid=2"; // //sURL = "http://184.171.171.74/api/mt/SendSMS?" // //+ "user=Sandeep99" // //+ "&password=pantnagar" // // + "&senderid=" + sSenderID // // + "&channel=Trans" // // + "&DCS=0" // // + "&flashsms=0" // //+ "&text=" + msg // //+ "&route=4" // //+ "&number=" + mobileNos; // // sURL = "http://sms.hspsms.com/sendSMS?username=admin&message=" + sMessage + "&sendername=INFORM&smstype=TRANS&numbers=9219484030&apikey=d0002689-c347-4b82-af90-9d3188ad6c6e"; // //Gujrat // // sURL = "http://sms.hspsms.com/sendSMS?username="******"&password=2314&message="+sMessage+"&sendername="+sSenderID+"&smstype=TRANS&numbers="+sNumber+"&apikey=d6a74a66-e6b8-430a-9121-52aa758c34fa"; // } // string sResponse = GetResponse(sURL); // //res.Write(sResponse); // return sResponse; //} // 7777 public string SendSms(string mobileNos, string msg, int userID, string senderID, bool isUnicode) { //smsIndiaHub string sUser = "******"; string spwd = "pantnagar2314"; string sNumber = mobileNos; string sMessage = msg; string sSenderID = senderID; string MessageData = msg; string sURL = ""; isUnicode = ContainsUnicodeCharacter(msg); if (isUnicode) { sURL = "http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=" + sNumber + "&sid=" + sSenderID + "&msg=" + msg + "&fl=0&dc=8&gwid=2"; } else { sURL = "http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=" + sNumber + "&sid=" + sSenderID + "&msg=" + msg + "&fl=0&gwid=2"; } //SendSMSToParents.WriteErrorLog("SMS Sent the Url " + sURL); string sResponse = GetResponse(sURL); SendSMSToParents.WriteErrorLog("SMS SENT 22 the Url 2222 " + sResponse); return(sResponse); }
private void timer1_Tick(object sender, ElapsedEventArgs e) { // witer code to do some job as per ur need // send sms for Abentee to be sent on 9:15 AM Util_BLL util = new Util_BLL(); AttendanceBll aBLL = new AttendanceBll(); //aBLL.ProcessMachineAttendance(site, util.CheckNullInt(DateTime.Now.Year), util.CheckNullInt(DateTime.Now.Month), util.CheckNullInt(DateTime.Now.Day), 0); // Check if attendance table has students per day if not then add aBLL.AddStudentDataInAttdencance(site, util.CheckNullInt(DateTime.Now.Year), util.CheckNullInt(DateTime.Now.Month), util.CheckNullInt(DateTime.Now.Day), 0); List <AttendanceBll.AttendanceEntity> absentees = new List <AttendanceBll.AttendanceEntity>(); absentees = aBLL.GetAttendance(site, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, -1, false); foreach (AttendanceBll.AttendanceEntity abs in absentees) { string logdate = ""; // Update InTime if (abs.Status == 0 && abs.IdcardNo.Length > 1) { // get logdate logdate = aBLL.GetlogDate(site, util.CheckNullInt(DateTime.Now.Year), util.CheckNullInt(DateTime.Now.Month), util.CheckNullInt(DateTime.Now.Day), abs.AttendanceId, abs.IdcardNo, "INTIME"); if (logdate.Length > 0) { aBLL.UpDateInTime_OutTime(site, logdate, abs.AttendanceId, 1, "INTIME"); //SendSMSToParents.WriteErrorLog("UPDATE INTIME " + abs.IdcardNo); } } // OUTTIME if (abs.Status >= 0 && abs.IdcardNo.Length > 1 && abs.IsSMSSent == 1) { logdate = aBLL.GetlogDate(site, util.CheckNullInt(DateTime.Now.Year), util.CheckNullInt(DateTime.Now.Month), util.CheckNullInt(DateTime.Now.Day), abs.AttendanceId, abs.IdcardNo, "OUTTIME"); if (logdate.Length > 0) { aBLL.UpDateInTime_OutTime(site, logdate, abs.AttendanceId, 1, "OUTTIME"); //SendSMSToParents.WriteErrorLog("UPDATE OUTTIME " + abs.IdcardNo); } } } // get students again after updating List <AttendanceBll.AttendanceEntity> absentees2 = new List <AttendanceBll.AttendanceEntity>(); absentees2 = aBLL.GetAttendance(site, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, -1, false); string msg_str = ""; foreach (AttendanceBll.AttendanceEntity absente in absentees2) { if (absente.Status > 0) { if (absente.Status == 1 && absente.IsSMSSent == 0 && absente.InTime.Length > 0) { msg_str = "Dear Parents, Your child " + absente.StudentName + " has arrived in school on " + absente.InTime + "."; util.SendSms(absente.MobileNo, msg_str, 1, "WHSLMC", false); util.SaveSentSMSToDB(site, absente.MobileNo, msg_str, false, 36); aBLL.PostSMS(site, absente.StudentId, 1); SendSMSToParents.WriteErrorLog("set isSMSSent to 1 " + absente.StudentName); } // Exit if (absente.Status == 1 && absente.IsSMSSent == 1 && absente.OutTime.Length > 0) { msg_str = "Dear Parents, Your child " + absente.StudentName + " has left the school on " + absente.OutTime + "."; util.SendSms(absente.MobileNo, msg_str, 1, "WHSLMC", false); util.SaveSentSMSToDB(site, absente.MobileNo, msg_str, false, 36); aBLL.PostSMS(site, absente.StudentId, 2); SendSMSToParents.WriteErrorLog("set isSMSSent to 2 " + absente.StudentName); } } } SendSMSToParents.WriteErrorLog("Timer ticked and some job has been done sucessesfully"); }
protected override void OnStop() { timer1.Enabled = false; SendSMSToParents.WriteErrorLog("Test Window Service is stopped"); }
public List <AttendanceEntity> GetAttendance2MAy19(DBSite site, int yearNo, int theMonth, int theDay, int clasId, bool onlyAbsentees) { List <AttendanceEntity> adList = new List <AttendanceEntity>(); AttendanceEntity da = null; string qry = ""; qry = "SELECT AttendanceId, YearNo, MonthNo, DayNo, HolidayID " + ", a.StudentMasterID, StudentName, s.classID, MobileF , ClassName, s.SectionId, sc.SectionName, s.IdCardNo " + " , (SELECT MIN(InTime) FROM tblAttendance " + Util_BLL.GetUserWhereCondition("a") + " AND YearNo = " + yearNo + " AND MonthNo = " + theMonth + " AND DayNo = " + theDay + " AND studentmasterid=s.studentMasterID " + " GROUP BY StudentMasterID, YearNo, monthno, dayno, userId, FYear )InTime " + " , OutTime, Status " + ", IsPosted " + " , (select MAX(IsSMSSent) FROM tblAttendance where dayNo=" + theDay + " AND STUDENTMASTERID = s.studentMasterID GROUP BY StudentMasterID) IsSmsSent " + " FROM tblAttendance a " + " LEFT OUTER JOIN tblStudentMaster s ON s.StudentMasterID = a.StudentMasterID " + " LEFT OUTER JOIN tblClassMaster C ON c.classMasterID = s.classID " + " LEFT OUTER JOIN tblSectionMaster sc ON sc.SectionMasterID = s.SectionId " + Util_BLL.GetUserWhereCondition("a") + " AND YearNo = " + yearNo + " AND MonthNo = " + theMonth + " AND DayNo = " + theDay; if (onlyAbsentees) { qry += " AND status = 0 "; } if (clasId != -1) { qry += " AND c.classMasterID = " + clasId; } qry += " AND AttendanceID In (select MAx(AttendanceID) " + " FROM tblAttendance b" + Util_BLL.GetUserWhereCondition("b") + " GROUP BY StudentMasterID, YearNo, monthno, dayno, userId, FYear ) " + " ORDER BY ClassOrder,sectionName, StudentName "; SendSMSToParents.WriteErrorLog("GetAttendance qry " + qry); DataTable dt = site.ExecuteSelect(qry); foreach (DataRow dr in dt.Rows) { da = new AttendanceEntity(); da.AttendanceId = util.CheckNullInt(dr["AttendanceId"]); da.YearNo = util.CheckNullInt(dr["YearNo"]); da.MonthNo = util.CheckNullInt(dr["MonthNo"]); da.DayNo = util.CheckNullInt(dr["DayNo"]); da.HolidayId = util.CheckNullInt(dr["HolidayID"]); da.StudentId = util.CheckNullInt(dr["StudentMasterID"]); da.StudentName = util.CheckNull(dr["StudentName"]); da.MobileNo = util.CheckNull(dr["MobileF"]); da.ClassId = util.CheckNullInt(dr["ClassID"]); da.ClassName = util.CheckNull(dr["ClassName"]); da.SectionId = util.CheckNullInt(dr["SectionID"]); da.SectionName = util.CheckNull(dr["SectionName"]); da.IdcardNo = util.CheckNull(dr["IdCardNo"]); da.InTime = util.CheckNull(dr["InTime"]); da.OutTime = util.CheckNull(dr["OutTime"]); da.IsPosted = util.CheckNullInt(dr["IsPosted"]); da.IsSMSSent = util.CheckNullInt(dr["IsSMSSent"]); da.Status = util.CheckNullInt(dr["status"]); //if (da.IsPosted==0) // da.Status = 1; adList.Add(da); } return(adList); }