191 lines
8.2 KiB
C#
191 lines
8.2 KiB
C#
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region MailSenderErrorListDA
|
|
|
|
internal class MailSenderErrorListDA
|
|
{
|
|
#region Constructor
|
|
|
|
private MailSenderErrorListDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
internal static void Insert(TransactionContext tc, MailSenderErrorList item)
|
|
{
|
|
string sql = SQLParser.MakeSQL(
|
|
"INSERT INTO MailSenderErrorList(MailSenderErrorListID,BatchNo,ToEmpID, ReceiveTime," +
|
|
"SendTime, IsSuccessfull, Reason, MailTo, CC, Subject, MailBody, MailFrom )" +
|
|
" VALUES(%n, %n, %n, %D, %D, %b, %s, %s, %s, %s, %s, %s)", item.ID,
|
|
DataReader.GetNullValue(item.BatchNo), DataReader.GetNullValue(item.ToEmpID), item.ReceiveTime,
|
|
item.SendTime, item.IsSuccessfull, item.Reason, item.To, item.CC, item.Subject, item.Body, item.From);
|
|
tc.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
//internal static void Insert(OracleCommand command, MailSenderErrorList item)
|
|
//{
|
|
// string sql = SQLParser.MakeSQL("INSERT INTO MailSenderErrorList(MailSenderErrorListID,BatchNo,ToEmpID, ReceiveTime," +
|
|
// "SendTime, IsSuccessfull, Reason, MailTo, CC, Subject, Attachments, MailFrom, MailBody)" +
|
|
// " VALUES(%n, %n, %n, %D, %D, %b, %s, %s, %s, %s, %s, %s, :MailBody)", item.ID, DataReader.GetNullValue(item.BatchNo), DataReader.GetNullValue(item.ToEmpID), item.ReceiveTime,
|
|
// item.SendTime, item.IsSuccessfull, item.Reason, item.To, item.CC, item.Subject, item.Attachments, item.From);
|
|
|
|
// OracleParameter parameter = new OracleParameter();
|
|
// parameter.OracleType = OracleType.LongRaw;
|
|
// parameter.ParameterName = "MailBody";
|
|
// parameter.Value = item.Body;
|
|
|
|
// command.Parameters.Add(parameter);
|
|
// command.CommandText = sql;
|
|
// command.ExecuteNonQuery();
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, MailSenderErrorList item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"UPDATE MailSenderErrorList SET BatchNo=%n,ToEmpID=%n, MailFrom=%s, ReceiveTime=%D, SendTime=%D, IsSuccessfull=%b, Reason=%s, MailTo=%s, CC=%s, Subject=%s, MailBody=%s" +
|
|
"WHERE MailSenderErrorListID=%n", DataReader.GetNullValue(item.BatchNo),
|
|
DataReader.GetNullValue(item.ToEmpID), item.From, item.ReceiveTime, item.SendTime, item.IsSuccessfull,
|
|
item.Reason, item.To, item.CC, item.Subject, item.Body, item.ID);
|
|
}
|
|
|
|
//internal static void Update(OracleCommand command, MailSenderErrorList item)
|
|
//{
|
|
// string sql = SQLParser.MakeSQL("UPDATE MailSenderErrorList SET BatchNo=%n,ToEmpID=%n, MailFrom=%s, ReceiveTime=%D," +
|
|
// "SendTime=%D, IsSuccessfull=%b, Reason=%s, MailTo=%s, CC=%s, Subject=%s,Attachments=%s " +
|
|
// "WHERE MailSenderErrorListID=%n;", DataReader.GetNullValue(item.BatchNo),
|
|
// DataReader.GetNullValue(item.ToEmpID), item.From, item.ReceiveTime, item.SendTime, item.IsSuccessfull,
|
|
// item.Reason, item.To, item.CC, item.Subject, item.Attachments, item.ID);
|
|
|
|
// command.CommandText = sql;
|
|
// command.ExecuteNonQuery();
|
|
//}
|
|
internal static void UpdateSendStatus(TransactionContext tc, int nID, bool bStatus)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE MailSenderErrorList SET IsSuccessfull=%b" +
|
|
"WHERE MailSenderErrorListID=%n", bStatus, nID);
|
|
}
|
|
//public static void UpdateBody(OracleConnection connection, int id, byte[] body)
|
|
//{
|
|
// OracleCommand command = new OracleCommand("UPDATE MailSenderErrorList SET " + "Body=@BODY WHERE MailSenderErrorListID=@ID ", connection);
|
|
|
|
// command.Parameters.Add("@ID", OracleType.Number).Value = id;
|
|
// command.Parameters.Add("@BODY", OracleType.LongRaw, body.Length).Value = body;
|
|
// connection.Open();
|
|
// command.ExecuteNonQuery();
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM MailSenderErrorList Order By MailSenderErrorListID");
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int nID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM MailSenderErrorList Where MailSenderErrorListID=%n", nID);
|
|
}
|
|
|
|
//internal static IDataReader Get(OracleCommand command, int nID)
|
|
//{
|
|
// string sql = SQLParser.MakeSQL("SELECT * FROM MailSenderErrorList Where MailSenderErrorListID=%n", nID);
|
|
// command.CommandText = sql;
|
|
// return command.ExecuteReader();
|
|
//}
|
|
|
|
internal static DataTable GetMailHistory(TransactionContext tc, bool status, EnumSchedularType Type, DateTime fromDate, DateTime toDate)
|
|
{
|
|
string sql = SQLParser.MakeSQL(@"SELECT M.* FROM MailNotificationHistory M
|
|
WHERE M.STATUS = %n AND M.NOTIFICATIONTYPE = %n
|
|
AND M.CreationDate BETWEEN %d AND %d order By M.CreationDate Desc
|
|
", status, Type, fromDate, toDate);
|
|
return tc.ExecuteDataSet(sql).Tables[0];
|
|
}
|
|
|
|
internal static DataTable GetBatchNoWiseErrorList(TransactionContext tc)
|
|
{
|
|
string sql = SQLParser.MakeSQL(@"SELECT ms.BatchNo,ms.Subject,ms.SendTime,COUNT(*) MailCount
|
|
FROM MailSenderErrorList ms
|
|
WHERE ms.IsSuccessfull=0
|
|
GROUP BY BatchNo,ms.SendTime,ms.Subject
|
|
ORDER BY ms.BatchNo");
|
|
return tc.ExecuteDataSet(sql).Tables[0];
|
|
}
|
|
|
|
public static IDataReader GetByBatch(TransactionContext tc, int batchNo)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM MailSenderErrorList ms WHERE ms.IsSuccessfull=0 AND BatchNo=%n",
|
|
batchNo);
|
|
}
|
|
|
|
//public static SqlDataReader GetBody(SqlConnection connection, int nMailID)
|
|
//{
|
|
// SqlCommand command = new SqlCommand("SELECT Body FROM MailSenderErrorList WHERE MailSenderErrorListID=@ID", connection);
|
|
// command.Parameters.Add("@ID", SqlDbType.Int).Value = nMailID;
|
|
// SqlDataReader reader = command.ExecuteReader(CommandBehavior.SequentialAccess);
|
|
// return reader;
|
|
//}
|
|
//public static OracleDataReader GetBody(OracleCommand command, int nMailID)
|
|
//{
|
|
// string sql = SQLParser.MakeSQL("SELECT MailBody FROM MailSenderErrorList WHERE MailSenderErrorListID=%n", nMailID);
|
|
// return command.ExecuteReader(CommandBehavior.SequentialAccess);
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void Delete(TransactionContext tc, int nID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM MailSenderErrorList Where MailSenderErrorListID=%n", nID);
|
|
}
|
|
|
|
internal static void DeleteByBatchNo(TransactionContext tc, int batchNo)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM MailSenderErrorList Where BatchNo = %n", batchNo);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetNewID
|
|
|
|
//public static int GetNewID(OracleCommand command, string tableName, string columnName)
|
|
//{
|
|
// string sql = SQLParser.MakeSQL("SELECT MAX(%q) FROM %q", columnName, tableName);
|
|
// command.CommandText = sql;
|
|
// object maxID = command.ExecuteScalar();
|
|
|
|
// if (maxID == null || maxID == DBNull.Value)
|
|
// {
|
|
// maxID = 1;
|
|
// }
|
|
// else
|
|
// {
|
|
// maxID = Convert.ToInt32(maxID) + 1;
|
|
// if ((int)maxID <= 0)
|
|
// maxID = 1;
|
|
// }
|
|
|
|
// return Convert.ToInt32(maxID);
|
|
//}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
} |