Exemplo n.º 1
0
 public void Remove(SessionElement session)
 {
     if (BaseIndexOf(session) >= 0)
     {
         BaseRemove(session.Name);
     }
 }
Exemplo n.º 2
0
        private Settings BuildSettings(SessionElement sessionElement)
        {
            Settings            settings           = new Settings();
            IConnectionProvider connectionProvider = ConnectionProviderFactory.NewConnectionProvider(sessionElement);
            ITransactionFactory transactionFactory = CreateTransactionFactory(sessionElement);
            string releaseModeName            = sessionElement.ConnectionReleaseMode;
            ConnectionReleaseMode releaseMode = "auto".Equals(releaseModeName) ? ConnectionReleaseMode.AfterTransaction : ParseConnectionReleaseMode(releaseModeName);

            settings.SessionFactoryName    = sessionElement.Name;
            settings.ConnectionReleaseMode = releaseMode;
            // settings.DefaultBatchFetchSize = sessionElement.DefaultBatchFetchSize;
            settings.BatchSize      = sessionElement.BatchSize;
            settings.BatcherFactory = new BatcherFactory();// CreateBatcherFactory(sessionElement, settings.BatchSize, connectionProvider);
            string         isolationString = sessionElement.IsolationString;
            IsolationLevel isolation       = IsolationLevel.Unspecified;

            if (isolationString.Length > 0)
            {
                try
                {
                    isolation = (IsolationLevel)Enum.Parse(typeof(IsolationLevel), isolationString);
                }
                catch
                {
                    throw new Exception("The isolation level of " + isolationString + " is not a valid IsolationLevel.  Please use one of the Member Names from the IsolationLevel.");
                }
            }
            settings.IsolationLevel     = isolation;
            settings.ConnectionProvider = connectionProvider;
            settings.TransactionFactory = transactionFactory;
            return(settings);
        }
Exemplo n.º 3
0
        /// <summary>
        /// <see cref="ISessionService.StoreSession(string, string, string, string, string, string)"/>
        /// </summary>
        public void StoreSession(
            string applicationKey,
            string sessionToken,
            string environmentUrl,
            string solutionId = null,
            string userToken  = null,
            string instanceId = null)
        {
            if (HasSession(applicationKey, solutionId, userToken, instanceId))
            {
                string solutionIdText = solutionId == null ? "" : "[solutionId=" + solutionId + "]";
                string userTokenText  = userToken == null ? "" : "[userToken=" + userToken + "]";
                string instanceIdText = instanceId == null ? "" : "[instanceId=" + instanceId + "]";
                var    message        =
                    $"Session with the following credentials already exists - [applicationKey={applicationKey}]{solutionIdText}{userTokenText}{instanceIdText}.";

                throw new ConfigurationErrorsException(message);
            }

            if (HasSessionToken(sessionToken))
            {
                var message = $"Session already exists with a session token of {sessionToken}.";

                throw new ConfigurationErrorsException(message);
            }

            var sessionElement =
                new SessionElement(applicationKey, sessionToken, environmentUrl, solutionId, userToken, instanceId);

            SessionsSection.Sessions.Add(sessionElement);
            Configuration.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection(SifFrameworkSectionGroup.SectionGroupReference);
        }
Exemplo n.º 4
0
        public SessionRuleContext(StatefulSessionImpl session, SessionElement <T> item)
        {
            _session    = session;
            _betaMemory = new Dictionary <int, BetaMemory <T> >();

            Element = item;
        }
        public static IConnectionProvider NewConnectionProvider(SessionElement settings)
        {
            IConnectionProvider connectionProvider;
            string providerClass = settings.ConnectionProvider;

            if (!string.IsNullOrEmpty(providerClass))
            {
                try
                {
                    connectionProvider = (IConnectionProvider)Activator.CreateInstance(Type.GetType(providerClass));
                }
                catch (Exception e)
                {
                    throw new Exception("Could not instantiate connection provider: " + providerClass, e);
                }
            }
            else if (!string.IsNullOrEmpty(settings.ConnectionString))
            {
                connectionProvider = new DriverConnectionProvider();
            }
            else
            {
                connectionProvider = new UserSuppliedConnectionProvider();
            }
            connectionProvider.Configure(settings);
            return(connectionProvider);
        }
Exemplo n.º 6
0
 public virtual void Configure(SessionElement settings)
 {
     dirverSettings = settings;
     // Command timeout, -1
     commandTimeout = settings.CommandTimeOut;
     // Prepare sql enabled, false
     prepareSql = settings.PrepareSqlEnable;
 }
        /// <summary>
        /// <see cref="ISessionService.UpdateSubscriptionId(string, string, string, string, string)"/>
        /// </summary>
        public void UpdateSubscriptionId(string subscriptionId, string applicationKey, string solutionId = null, string userToken = null, string instanceId = null)
        {
            SessionElement sessionElement = RetrieveSessionEntry(applicationKey, solutionId, userToken, instanceId);

            if (sessionElement != null)
            {
                sessionElement.SubscriptionId = subscriptionId;
                Configuration.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection(SifFrameworkSectionGroup.SectionGroupReference);
            }
        }
Exemplo n.º 8
0
 protected virtual void ConfigureDriver(SessionElement settings)
 {
     try
     {
         driver = (IDriver)Activator.CreateInstance(Type.GetType(settings.Driver));
         driver.Configure(settings);
     }
     catch (Exception e)
     {
         throw new Exception("Could not create the driver from " + settings.Driver + ".", e);
     }
 }
        /// <summary>
        /// Retrieve the session entry that matches the specified parameters.
        /// </summary>
        /// <param name="applicationKey">Application key.</param>
        /// <param name="solutionId">Solution ID.</param>
        /// <param name="userToken">User token.</param>
        /// <param name="instanceId">Instance ID.</param>
        /// <returns>Session entry if found; null otherwise.</returns>
        private SessionElement RetrieveSessionEntry(string applicationKey, string solutionId = null, string userToken = null, string instanceId = null)
        {
            SessionElement sessionElement = null;

            foreach (SessionElement session in SessionsSection.Sessions)
            {
                if (string.Equals(applicationKey, session.ApplicationKey) &&
                    (solutionId == null ? string.IsNullOrWhiteSpace(session.SolutionId) : solutionId.Equals(session.SolutionId)) &&
                    (userToken == null ? string.IsNullOrWhiteSpace(session.UserToken) : userToken.Equals(session.UserToken)) &&
                    (instanceId == null ? string.IsNullOrWhiteSpace(session.InstanceId) : instanceId.Equals(session.InstanceId)))
                {
                    sessionElement = session;
                    break;
                }
            }

            return(sessionElement);
        }
        /// <summary>
        /// <see cref="ISessionService.StoreSession(string, string, string, string, string, string)"/>
        /// </summary>
        public void StoreSession(string applicationKey, string sessionToken, string environmentUrl, string solutionId = null, string userToken = null, string instanceId = null)
        {
            if (HasSession(applicationKey, solutionId, userToken, instanceId))
            {
                string message = string.Format("Session with the following credentials already exists - [applicationKey={0}]{1}{2}{3}.",
                                               applicationKey,
                                               (solutionId == null ? "" : "[solutionId=" + solutionId + "]"),
                                               (userToken == null ? "" : "[userToken=" + userToken + "]"),
                                               (instanceId == null ? "" : "[instanceId=" + instanceId + "]"));
                throw new ConfigurationErrorsException(message);
            }

            if (HasSession(sessionToken))
            {
                string message = string.Format("Session already exists with a session token of {0}.", sessionToken);
                throw new ConfigurationErrorsException(message);
            }

            SessionElement sessionElement = new SessionElement(applicationKey, sessionToken, environmentUrl, solutionId, userToken, instanceId);

            SessionsSection.Sessions.Add(sessionElement);
            Configuration.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection(SifFrameworkSectionGroup.SectionGroupReference);
        }
Exemplo n.º 11
0
        // TransactionManagerLookup transactionManagerLookup = TransactionManagerLookupFactory.GetTransactionManagerLookup( properties );

        private static ITransactionFactory CreateTransactionFactory(SessionElement sessionElement)
        {
            return((ITransactionFactory)Activator.CreateInstance(Type.GetType(sessionElement.TransactionFactory)));
        }
Exemplo n.º 12
0
 public void Add(SessionElement session)
 {
     BaseAdd(session);
 }
Exemplo n.º 13
0
 public int IndexOf(SessionElement session)
 {
     return(BaseIndexOf(session));
 }
Exemplo n.º 14
0
 protected virtual string GetNamedConnectionString(SessionElement settings)
 {
     return(settings.ConnectionString);
 }
Exemplo n.º 15
0
 public virtual void Configure(SessionElement settings)
 {
     connString = GetNamedConnectionString(settings);
     ConfigureDriver(settings);
 }
Exemplo n.º 16
0
 public static void SetElement(SessionElement sessionElement, object value)
 {
     HttpContext.Current.Session[sessionElement.ToString()] = value;
 }
Exemplo n.º 17
0
		public void Add(SessionElement element)
		{
			_elements.Add(element);
		}
 /// <summary>
 /// Configures the ConnectionProvider with only the Driver class.
 /// </summary>
 /// <param name="settings"></param>
 /// <remarks>
 /// All other settings of the Connection are the responsibility of the User since they configured
 /// ORM to use a Connection supplied by the User.
 /// </remarks>
 public override void Configure(SessionElement settings)
 {
     ConfigureDriver(settings);
 }
Exemplo n.º 19
0
 public void Add(SessionElement element)
 {
     _elements.Add(element);
 }
Exemplo n.º 20
0
        public static T GetElement <T>(SessionElement sessionElement)
        {
            var element = HttpContext.Current.Session[sessionElement.ToString()];

            return(element == null ? default(T) : (T)element);
        }