private void Check() { lock (_sync) { DataBaseRetriever db = new DataBaseRetriever(ConfigManager.ConnectionString); DateTime d = DateTime.Today.AddDays(1); DateTime FromDate = d + new TimeSpan(0, 0, 0);; DateTime ToDate = d + new TimeSpan(23, 59, 0); var sql = @"SELECT top 100 A.FromDate,A.ToDate,B.Email,B.tel,U.Name as [ActivityName], B.Name as [CustomerName],Us.BizName as [userName],Us.Email as [UserMail],A.id as QueId,B.Id As CustId FROM Que A INNER JOIN Customer B on A.CustomerId = B.Id JOIN UsersActivitiesTypes U ON U.Id = A.QueType JOIN Users Us On Us.Id = A.UserId WHERE (A.IsMessageSent=0 Or A.IsMessageSent=Null) And A.FromDate>=@FromDate And A.ToDate<=@ToDate ORDER BY A.FromDate asc"; SecureData sec = new SecureData(); try { IEnumerable <QueDataMessage> QueDataRows = db.QueryData <QueDataMessage>(sql, 1, new { FromDate = FromDate, ToDate = ToDate }); foreach (QueDataMessage que in QueDataRows) { string subject = "הודעה מ" + que.userName; string content = "שלום" + "<BR><BR>" + "מחר יש לך תור ל" + que.ActivityName + " בתאריך " + que.FromDate.ToShortDateString() + " בשעה " + que.FromDate.ToShortTimeString() + " עד " + que.ToDate.ToShortTimeString(); content += "<BR><BR>"; string encriptedQueId = sec.EncryptTextWithNoSpecialCharecters(que.QueId.ToString(), "shalomHa!@"); content += "לאישור הגעתך אנא " + " <a href='" + baseUerl + "/Que/Approve/" + encriptedQueId + "'>לחץ כאן לאישור</a>"; content += "<BR><BR>"; content += "לביטול התור" + " <a href='" + baseUerl + "/Que/Cancel/" + encriptedQueId + "'>לחץ כאן לביטול</a>"; string[] arr = new string[1]; arr[0] = que.Email; bool isSent = MailSender.sendMail(subject, content, arr, que.UserMail); if (isSent) { Task.Run(() => { updateMessageStatus(que.QueId); }); } } } catch (Exception ex) { Logger.Write(ex); } } }
public string DeleteQue(string decryptedQueId) { try { SecureData sec = new SecureData(); string queId = sec.DecryptTextWithNoSpecialCharecters(decryptedQueId, "shalomHa!@"); //IsApproved field string sqlUpdate = "Delete FROM Que where [id]=@QueId;"; DataBaseRetriever db = new DataBaseRetriever(ConfigManager.ConnectionString); var affectedRows = db.Execute(sqlUpdate, 1, new { QueId = queId }); } catch (Exception ex) { Logger.Write(ex); return("ארעה שגיאה"); } return(""); }