private void SaveToDB(qCom_TempBulkEmailLog t_log, int email_item_id, string email)
        {
            int curr_log_id = 0;
            int i           = 0;

            if ((email == null) || (email.Trim().Length == 0))
            {
                return;
            }

            var logs = qCom_EmailLog.GetEmailLogsByEmailItemIDANDEmail(email_item_id, email);

            if (logs != null)
            {
                foreach (var l in logs)
                {
                    if (i == 0)
                    {
                        curr_log_id = l.EmailLogID;
                    }
                    i++;
                }
            }
            else
            {
                // log doesn't exist so create one
                qCom_EmailItem email_sent = new qCom_EmailItem(email_item_id);
                qCom_EmailLog  log        = new qCom_EmailLog();
                log.ScopeID      = 1;
                log.EmailItemID  = email_item_id;
                log.UserID       = 0;
                log.EmailAddress = email;
                log.Subject      = email_sent.Subject;
                log.Timestamp    = t_log.Timestamp;
                log.Insert();

                curr_log_id = log.EmailLogID;
            }

            if (curr_log_id > 0)
            {
                qCom_EmailLog e_log = new qCom_EmailLog(curr_log_id);
                if (e_log.EmailLogID > 0)
                {
                    e_log.ReadTime = DateTime.Now;
                    e_log.Update();
                }
            }
        }
示例#2
0
        public static qCom_EmailLog CheckForEmailSentLastDay(string email_address)
        {
            qCom_EmailLog log = new qCom_EmailLog();

            log.container.Select(new DbQuery
            {
                Top     = "Top(1)",
                Where   = string.Format("DateDiff(DAY, Timestamp, GETDATE()) = 0 AND EmailAddress LIKE '%" + email_address + "%'"),
                OrderBy = "Timestamp DESC"
            });

            if (log.EmailLogID > 0)
            {
                return(log);
            }
            else
            {
                return(null);
            }
        }
        //Add log for successful transmission
        private static int AddTransmissionLog(int scopeID, string strTo, int userID, string emailType, string emailSubject, int emailID, int campaign_id, string from_email)
        {
            int email_log_id = 0;

            qCom_EmailLog log = new qCom_EmailLog();

            log.ScopeID      = scopeID;
            log.EmailItemID  = emailID;
            log.UserID       = userID;
            log.EmailFrom    = from_email;
            log.EmailAddress = strTo;
            log.EmailType    = emailType;
            log.Subject      = emailSubject;
            log.Timestamp    = DateTime.Now;
            log.CampaignID   = campaign_id;
            log.Insert();

            email_log_id = log.EmailLogID;

            return(email_log_id);
        }
        public static qCom_EmailLog CheckForEmailSentLastDay(string email_address)
        {
            qCom_EmailLog log = new qCom_EmailLog();

            log.container.Select(new DbQuery
            {
                Top = "Top(1)",
                Where = string.Format("DateDiff(DAY, Timestamp, GETDATE()) = 0 AND EmailAddress LIKE '%" + email_address + "%'"),
                OrderBy = "Timestamp DESC"
            });

            if (log.EmailLogID > 0) return log;
            else return null;
        }
        private void SaveToDB(qCom_TempBulkEmailLog t_log, int email_item_id, string email)
        {
            int curr_log_id = 0;
            int i = 0;
            if( ( email==null) || ( email.Trim().Length == 0 ) )
                return;

            var logs = qCom_EmailLog.GetEmailLogsByEmailItemIDANDEmail(email_item_id, email);

            if (logs != null)
            {
                foreach (var l in logs)
                {
                    if (i == 0)
                        curr_log_id = l.EmailLogID;
                    i++;
                }
            }
            else
            {
                // log doesn't exist so create one
                qCom_EmailItem email_sent = new qCom_EmailItem(email_item_id);
                qCom_EmailLog log = new qCom_EmailLog();
                log.ScopeID = 1;
                log.EmailItemID = email_item_id;
                log.UserID = 0;
                log.EmailAddress = email;
                log.Subject = email_sent.Subject;
                log.Timestamp = t_log.Timestamp;
                log.Insert();

                curr_log_id = log.EmailLogID;

            }

            if (curr_log_id > 0)
            {
                qCom_EmailLog e_log = new qCom_EmailLog(curr_log_id);
                if (e_log.EmailLogID > 0)
                {
                    e_log.ReadTime = DateTime.Now;
                    e_log.Update();
                }
            }
        }
        //Add log for successful transmission
        private static int AddTransmissionLog(int scopeID, string strTo, int userID, string emailType, string emailSubject, int emailID, int campaign_id, string from_email)
        {
            int email_log_id = 0;

            qCom_EmailLog log = new qCom_EmailLog();

            log.ScopeID = scopeID;
            log.EmailItemID = emailID;
            log.UserID = userID;
            log.EmailFrom = from_email;
            log.EmailAddress = strTo;
            log.EmailType = emailType;
            log.Subject = emailSubject;
            log.Timestamp = DateTime.Now;
            log.CampaignID = campaign_id;
            log.Insert();

            email_log_id = log.EmailLogID;

            return email_log_id;
        }