Ejemplo n.º 1
0
        public void MultipleDBAccessUsingMultipleSessionScopes()
        {
            SessionScope scope1 = new SessionScope((ISessionFactory)ctx["SessionFactory1"], false);
            SessionScope scope2 = new SessionScope((ISessionFactory)ctx["SessionFactory2"], false);

            scope1.Open();
            scope2.Open();

            // do something
            MultipleDBAccess();

            scope1.Close();
            scope2.Close();
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Execute the actual job. The job data map will already have been
 ///     applied as object property values by execute. The contract is
 ///     exactly the same as for the standard Quartz execute method.
 /// </summary>
 /// <seealso cref="M:Spring.Scheduling.Quartz.QuartzJobObject.Execute(Quartz.IJobExecutionContext)" />
 protected override void ExecuteInternal(IJobExecutionContext context)
 {
     if (IsAutomaticBillSettlingActive)
     {
         try {
             using (SessionScope sessionScope = new SessionScope(SessionFactory, true)) {
                 IList <Bill> settledBills = BillService.SettleAllSettleableBills();
                 _logger.Info($"Es wurden {settledBills.Count} automatisch abgerechnet.");
                 sessionScope.Close();
             }
         } catch (Exception e) {
             _logger.Error(e);
         }
     }
 }