Esempio n. 1
0
 /// <summary>
 /// Initialize Db Context
 /// </summary>
 public DbContext()
 {
     if (Context == null)
     {
         Context = new DBEntities();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Dispose the context
        /// </summary>
        public void Dispose()
        {
            if (Context != null)
            {
                Context.Dispose();

                Context = null;
            }
        }
 //this is fired when there is exception is raised by the service
 static void ServiceException(object sender, Exception exception)
 {
     //Do something here
     using (var context = new DBEntities())
     {
         context.ErrorLogs.Add(new ErrorLog
         {
             FormData = "",
             LoggedInDetails = "",
             QueryData = "",
             RouteData = "",
             InnerException = exception.ToString(),
             LoggedAt = DateTime.UtcNow,
             Message = exception.Message,
             StackTrace = exception.StackTrace
         });
         context.SaveChanges();
     }
 }
 //this is raised when a notification is failed due to some reason
 static void NotificationFailed(object sender, INotification notification, Exception notificationFailureException)
 {
     //Do something here
     using (var context = new DBEntities())
     {
         context.ErrorLogs.Add(new ErrorLog
         {
             FormData = "",
             LoggedInDetails = "",
             QueryData = "",
             RouteData = "",
             InnerException = notificationFailureException.GetBaseException().ToString(),
             LoggedAt = DateTime.UtcNow,
             Message = notificationFailureException.Message,
             StackTrace = notificationFailureException.StackTrace
         });
         context.SaveChanges();
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Reinitiate the database context.
 /// </summary>
 public void ReinitiateContext()
 {
     Dispose();
     Context = new DBEntities();
 }