public static EmailPost GetNextWaiting(LoginUser loginUser, string processID) { EmailPosts emails = new EmailPosts(loginUser); using (SqlCommand command = new SqlCommand()) { command.CommandText = @" UPDATE EmailPosts SET LockProcessID = @ProcessID OUTPUT Inserted.* WHERE EmailPostID IN ( SELECT TOP 1 EmailPostID FROM EmailPosts WHERE LockProcessID IS NULL AND CreatorID <> -5 AND DATEADD(SECOND, HoldTime, DateCreated) < GETUTCDATE() ORDER BY DateCreated ) "; command.CommandType = CommandType.Text; command.Parameters.AddWithValue("@ProcessID", processID); emails.Fill(command); } if (emails.IsEmpty) { return(null); } else { return(emails[0]); } }
public static void UnlockAll(LoginUser loginUser) { EmailPosts emailPosts = new EmailPosts(loginUser); using (SqlCommand command = new SqlCommand()) { command.CommandText = "UPDATE EmailPosts SET LockProcessID = NULL"; command.CommandType = CommandType.Text; emailPosts.ExecuteNonQuery(command); } }
public static void DeleteImportEmails(LoginUser loginUser) { EmailPosts emailPosts = new EmailPosts(loginUser); using (SqlCommand command = new SqlCommand()) { command.CommandText = "DELETE FROM EmailPosts WHERE CreatorID = -5"; command.CommandType = CommandType.Text; emailPosts.ExecuteNonQuery(command, "EmailPosts"); } }
public static void UnlockThread(LoginUser loginUser, int thread) { EmailPosts emailPosts = new EmailPosts(loginUser); using (SqlCommand command = new SqlCommand()) { command.CommandText = "UPDATE EmailPosts SET LockProcessID = NULL WHERE LockProcessID = @id"; command.CommandType = CommandType.Text; command.Parameters.AddWithValue("id", thread); emailPosts.ExecuteNonQuery(command); } }
public static EmailPost GetEmailPost(LoginUser loginUser, int emailPostID) { EmailPosts emailPosts = new EmailPosts(loginUser); emailPosts.LoadByEmailPostID(emailPostID); if (emailPosts.IsEmpty) { return(null); } else { return(emailPosts[0]); } }
private static void PostEmail(LoginUser loginUser, EmailPostType emailPostType, int holdTime, string param1, string param2, string param3, string param4, string param5, string text1, string text2, string text3) { EmailPosts emailPosts = new EmailPosts(loginUser); EmailPost emailPost = emailPosts.AddNewEmailPost(); emailPost.DateCreated = DateTime.UtcNow; emailPost.CreatorID = loginUser.UserID; emailPost.EmailPostType = emailPostType; emailPost.HoldTime = holdTime; emailPost.Param1 = param1; emailPost.Param2 = param2; emailPost.Param3 = param3; emailPost.Param4 = param4; emailPost.Param5 = param5; emailPost.Text1 = text1; emailPost.Text2 = text2; emailPost.Text3 = text3; emailPosts.Save(); }
public static EmailPost GetDebugNextWaiting(LoginUser loginUser, string processID, int orgID) { EmailPosts emails = new EmailPosts(loginUser); using (SqlCommand command = new SqlCommand()) { command.CommandText = @" UPDATE EmailPosts SET LockProcessID = @ProcessID OUTPUT Inserted.* WHERE EmailPostID IN ( SELECT TOP 1 ep.EmailPostID FROM EmailPosts AS ep LEFT JOIN Tickets t ON t.TicketID = CAST(ep.Param1 AS INT) LEFT JOIN Users u ON u.UserID = ep.CreatorID WHERE ep.LockProcessID IS NULL AND DATEADD(SECOND, 15, ep.DateCreated) < GETUTCDATE() AND (u.OrganizationID = @OrganizationID OR t.OrganizationID = @OrganizationID) ORDER BY ep.DateCreated ) "; command.CommandType = CommandType.Text; command.Parameters.AddWithValue("@ProcessID", processID); command.Parameters.AddWithValue("@OrganizationID", orgID); emails.Fill(command); } if (emails.IsEmpty) { return(null); } else { return(emails[0]); } }
public EmailPost(DataRow row, EmailPosts emailPosts) : base(row, emailPosts) { _emailPosts = emailPosts; }