static public void Save(RemoveMail objRemoveMail, Database db, DbTransaction trans, bool CommitTrans)
 {
     try
     {
         if (objRemoveMail.IsModified == true)
         {
             if (objRemoveMail.ID == 0)
             {
                 Insert(objRemoveMail, db, trans);
             }
             else
             {
                 Update(objRemoveMail, db, trans);
             }
         }
         if (CommitTrans == true)
         {
             trans.Commit();
         }
     }
     catch (Exception e)
     {
         if (CommitTrans == true)
         {
             //we were hoping to commit the transaction which means we're at the end so
             //Roll back the transaction. Otherwise just rethrow the error and let the next
             //higher level catch it and rollback
             trans.Rollback();
         }
         //and then rethrow the error
         throw (e);
     }
 }
        static public void Delete(RemoveMail objRemoveMail)
        {
            Database db = DatabaseFactory.CreateDatabase("BRGCaseMail");

            System.Data.Common.DbCommand dbCommand = db.GetStoredProcCommand("p_RemoveMailDelete");
            db.AddInParameter(dbCommand, "ID", DbType.Int32, objRemoveMail.ID);
            db.ExecuteNonQuery(dbCommand);
        }
 static public void Save(RemoveMail objRemoveMail)
 {
     if (objRemoveMail.IsModified == true)
     {
         if (objRemoveMail.ID == 0)
         {
             Insert(objRemoveMail);
         }
         else
         {
             Update(objRemoveMail);
         }
     }
 }
Esempio n. 4
0
        public RemoveMail Copy()
        {
            RemoveMail _removeMail = new RemoveMail();

            _removeMail.ID = _iD;
            _removeMail.IndexOnMailServer = _indexOnMailServer;
            _removeMail.MsgDateTime       = _msgDateTime;
            _removeMail.ToAddress         = _toAddress;
            _removeMail.FromAddress       = _fromAddress;
            _removeMail.Subject           = _subject;
            _removeMail.Body            = _body;
            _removeMail.Processed       = _processed;
            _removeMail.FoundAndRemoved = _foundAndRemoved;
            return(_removeMail);
        }
        static public List <RemoveMail> GetSince(DateTime _date)
        {
            List <RemoveMail> objRemoveMails = new List <RemoveMail>();
            Database          db             = DatabaseFactory.CreateDatabase("BRGCaseMail");

            using (IDataReader reader = db.ExecuteReader(CommandType.Text, _selectViewSQL + " Where MsgDateTime > '" + _date.ToShortDateString() + "' order by MsgDateTime desc "))
            {
                while (reader.Read())
                {
                    RemoveMail objRemoveMail = new RemoveMail();
                    LoadRemoveMail(objRemoveMail, reader);
                    objRemoveMail.IsModified = false;
                    objRemoveMails.Add(objRemoveMail);
                }
                // always call Close when done reading.
                reader.Close();
                return(objRemoveMails);
            }
        }
 static private void LoadRemoveMail(RemoveMail objRemoveMail, IDataReader _reader)
 {
     if (_reader.IsDBNull(0) != true)
     {
         objRemoveMail.ID = _reader.GetInt32(0);
     }
     if (_reader.IsDBNull(1) != true)
     {
         objRemoveMail.IndexOnMailServer = _reader.GetInt32(1);
     }
     if (_reader.IsDBNull(2) != true)
     {
         objRemoveMail.MsgDateTime = _reader.GetDateTime(2);
     }
     if (_reader.IsDBNull(3) != true)
     {
         objRemoveMail.ToAddress = _reader.GetString(3);
     }
     if (_reader.IsDBNull(4) != true)
     {
         objRemoveMail.FromAddress = _reader.GetString(4);
     }
     if (_reader.IsDBNull(5) != true)
     {
         objRemoveMail.Subject = _reader.GetString(5);
     }
     if (_reader.IsDBNull(6) != true)
     {
         objRemoveMail.Body = _reader.GetString(6);
     }
     if (_reader.IsDBNull(7) != true)
     {
         objRemoveMail.Processed = _reader.GetBoolean(7);
     }
     if (_reader.IsDBNull(8) != true)
     {
         objRemoveMail.FoundAndRemoved = _reader.GetBoolean(8);
     }
 }
        static public RemoveMail GetByID(int ID)
        {
            RemoveMail objRemoveMail = new RemoveMail();
            string     query         = _selectViewSQL + " where ID = " + ID;
            Database   db            = DatabaseFactory.CreateDatabase("BRGCaseMail");

            using (IDataReader reader = db.ExecuteReader(CommandType.Text, query))
            {
                if (reader.Read())
                {
                    LoadRemoveMail(objRemoveMail, reader);
                    // always call Close when done reading.
                    reader.Close();
                    objRemoveMail.IsModified = false;
                    return(objRemoveMail);
                }
                else
                {
                    return(null);
                }
            }
        }
 static private void Update(RemoveMail objRemoveMail, Database db, DbTransaction trans)
 {
     //Database db = DatabaseFactory.CreateDatabase("BRGCaseMail");
     System.Data.Common.DbCommand dbCommand = db.GetStoredProcCommand("p_RemoveMailUpdate");
     db.AddInParameter(dbCommand, "ID", DbType.Int32, objRemoveMail.ID);
     db.AddInParameter(dbCommand, "IndexOnMailServer", DbType.Int32, objRemoveMail.IndexOnMailServer);
     if (objRemoveMail.MsgDateTime > DateTime.MinValue)
     {
         db.AddInParameter(dbCommand, "MsgDateTime", DbType.DateTime, objRemoveMail.MsgDateTime);
     }
     else
     {
         db.AddInParameter(dbCommand, "MsgDateTime", DbType.DateTime, Convert.DBNull);
     }
     db.AddInParameter(dbCommand, "ToAddress", DbType.String, objRemoveMail.ToAddress);
     db.AddInParameter(dbCommand, "FromAddress", DbType.String, objRemoveMail.FromAddress);
     db.AddInParameter(dbCommand, "Subject", DbType.String, objRemoveMail.Subject);
     db.AddInParameter(dbCommand, "Body", DbType.String, objRemoveMail.Body);
     db.AddInParameter(dbCommand, "Processed", DbType.Boolean, objRemoveMail.Processed);
     db.AddInParameter(dbCommand, "FoundAndRemoved", DbType.Boolean, objRemoveMail.FoundAndRemoved);
     db.ExecuteNonQuery(dbCommand, trans);
 }