Example #1
0
        private IXpoDataStoreProvider GetDataStoreProvider(string connectionString, System.Data.IDbConnection connection)
        {
            System.Web.HttpApplicationState application       = (System.Web.HttpContext.Current != null) ? System.Web.HttpContext.Current.Application : null;
            IXpoDataStoreProvider           dataStoreProvider = null;

            if (application != null && application["DataStoreProvider"] != null)
            {
                dataStoreProvider = application["DataStoreProvider"] as IXpoDataStoreProvider;
            }
            else
            {
                if (!String.IsNullOrEmpty(connectionString))
                {
                    connectionString  = DevExpress.Xpo.XpoDefault.GetConnectionPoolString(connectionString);
                    dataStoreProvider = new ConnectionStringDataStoreProvider(connectionString, true);
                }
                else if (connection != null)
                {
                    dataStoreProvider = new ConnectionDataStoreProvider(connection);
                }
                if (application != null)
                {
                    application["DataStoreProvider"] = dataStoreProvider;
                }
            }
            return(dataStoreProvider);
        }
Example #2
0
        private IXpoDataStoreProvider GetDataStoreProvider(string connectionString, IDbConnection connection)
        {
            var application = HttpContext.Current != null ? HttpContext.Current.Application : null;
            IXpoDataStoreProvider dataStoreProvider = null;

            if (application != null && application["DataStoreProvider"] != null)
            {
                dataStoreProvider = application["DataStoreProvider"] as IXpoDataStoreProvider;
            }
            else
            {
                if (!string.IsNullOrEmpty(connectionString))
                {
                    connectionString  = XpoDefault.GetConnectionPoolString(connectionString);
                    dataStoreProvider = new ConnectionStringDataStoreProvider(connectionString, true);
                }
                else if (connection != null)
                {
                    dataStoreProvider = new ConnectionDataStoreProvider(connection);
                }
                if (application != null)
                {
                    application["DataStoreProvider"] = dataStoreProvider;
                }
            }
            return(dataStoreProvider);
        }
Example #3
0
        private void CreateXPObjectSpaceProvider(string connectionString, CreateCustomObjectSpaceProviderEventArgs e)
        {
            System.Web.HttpApplicationState application       = (System.Web.HttpContext.Current != null) ? System.Web.HttpContext.Current.Application : null;
            IXpoDataStoreProvider           dataStoreProvider = null;

            if (application != null && application["DataStoreProvider"] != null)
            {
                dataStoreProvider     = application["DataStoreProvider"] as IXpoDataStoreProvider;
                e.ObjectSpaceProvider = new XPObjectSpaceProvider(dataStoreProvider, true);
            }
            else
            {
                if (!String.IsNullOrEmpty(connectionString))
                {
                    connectionString  = DevExpress.Xpo.XpoDefault.GetConnectionPoolString(connectionString);
                    dataStoreProvider = new ConnectionStringDataStoreProvider(connectionString, true);
                }
                else if (e.Connection != null)
                {
                    dataStoreProvider = new ConnectionDataStoreProvider(e.Connection);
                }
                if (application != null)
                {
                    application["DataStoreProvider"] = dataStoreProvider;
                }
                e.ObjectSpaceProvider = new XPObjectSpaceProvider(dataStoreProvider, true);
            }
        }
Example #4
0
        private IXpoDataStoreProvider GetDataStoreProvider(CreateCustomObjectSpaceProviderEventArgs args)
        {
            var application = HttpContext.Current != null ? HttpContext.Current.Application : null;
            IXpoDataStoreProvider dataStoreProvider;

            if (application?["DataStoreProvider"] != null)
            {
                dataStoreProvider = application["DataStoreProvider"] as IXpoDataStoreProvider;
            }
            else
            {
                dataStoreProvider = new ConnectionStringDataStoreProvider(args.ConnectionString);
                if (args.ConnectionString.Contains("Memory"))
                {
                    dataStoreProvider = new MemoryDataStoreProvider();
                }
                // dataStoreProvider = new ConnectionStringDataStoreProvider(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
                if (application != null)
                {
                    application["DataStoreProvider"] = dataStoreProvider;
                }
            }

            return(dataStoreProvider);
        }
        public static XPObjectSpaceProvider CreateObjectSpaceProvider(string connectionString)
        {
            XpoTypesInfoHelper.ForceInitialize();
            ITypesInfo        typesInfo         = XpoTypesInfoHelper.GetTypesInfo();
            XpoTypeInfoSource xpoTypeInfoSource = XpoTypesInfoHelper.GetXpoTypeInfoSource();

            RegisterBOTypes(typesInfo);
            ConnectionStringDataStoreProvider dataStoreProvider = new ConnectionStringDataStoreProvider(connectionString);

            return(new XPObjectSpaceProvider(dataStoreProvider, typesInfo, xpoTypeInfoSource));
        }
        private static XPObjectSpaceProvider CreateObjectSpaceProvider(string CompanyId) //TODO use companyID
        {
            XpoTypesInfoHelper.ForceInitialize();
            ITypesInfo        typesInfo         = XpoTypesInfoHelper.GetTypesInfo();
            XpoTypeInfoSource xpoTypeInfoSource = XpoTypesInfoHelper.GetXpoTypeInfoSource();

            RegisterBOTypes(typesInfo);
            ConnectionStringDataStoreProvider dataStoreProvider = new ConnectionStringDataStoreProvider(MSSqlConnectionProvider.GetConnectionString("weedware101.database.windows.net,1433", "demodbjose", "*.mk3247", "demodbjose"));

            return(new XPObjectSpaceProvider(dataStoreProvider, typesInfo, xpoTypeInfoSource));
        }
Example #7
0
        private IXpoDataStoreProvider GetDataStoreProvider(string connectionString, System.Data.IDbConnection connection)
        {
            IXpoDataStoreProvider dataStoreProvider = null;

            if (!String.IsNullOrEmpty(connectionString))
            {
                dataStoreProvider = new ConnectionStringDataStoreProvider(connectionString);
            }
            else if (connection != null)
            {
                dataStoreProvider = new ConnectionDataStoreProvider(connection);
            }
            return(dataStoreProvider);
        }
        public IEnumerable <IObjectSpaceProvider> CreateProviders()
        {
            var moduleInfos = _dynamicModules.Select(m => new{ Module = m, Attribute = m.GetType().Assembly.Attribute <DataStoreAttribute>() })
                              .Where(info => info.Attribute != null);

            foreach (var moduleInfo in moduleInfos)
            {
                var connectionStringDataStoreProvider = new ConnectionStringDataStoreProvider(moduleInfo.Attribute.ConnectionString);
                var reflectionDictionary = new ReflectionDictionary();
                var assembly             = moduleInfo.Module.GetType().Assembly;
                reflectionDictionary.CollectClassInfos(assembly);
                AssemblyXpoTypeInfoSource.CreateSource(assembly);
                yield return(new XPObjectSpaceProvider(connectionStringDataStoreProvider,
                                                       moduleInfo.Module.Application.TypesInfo, AssemblyXpoTypeInfoSource.AssemblyInstance[assembly]));
            }
        }
Example #9
0
 private void CreateXPObjectSpaceProvider(string connectionString, CreateCustomObjectSpaceProviderEventArgs e)
 {
     System.Web.HttpApplicationState application = (System.Web.HttpContext.Current != null) ? System.Web.HttpContext.Current.Application : null;
     IXpoDataStoreProvider dataStoreProvider = null;
     if(application != null && application["DataStoreProvider"] != null) {
         dataStoreProvider = application["DataStoreProvider"] as IXpoDataStoreProvider;
         e.ObjectSpaceProvider = new XPObjectSpaceProvider(dataStoreProvider, true);
     }
     else {
         if(!String.IsNullOrEmpty(connectionString)) {
             connectionString = DevExpress.Xpo.XpoDefault.GetConnectionPoolString(connectionString);
             dataStoreProvider = new ConnectionStringDataStoreProvider(connectionString, true);
         }
         else if(e.Connection != null) {
             dataStoreProvider = new ConnectionDataStoreProvider(e.Connection);
         }
         if (application != null) {
             application["DataStoreProvider"] = dataStoreProvider;
         }
         e.ObjectSpaceProvider = new XPObjectSpaceProvider(dataStoreProvider, true);
     }
 }
Example #10
0
        /// <summary>
        /// Handles the CreateCustomObjectSpaceProvider event of the application control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DevExpress.ExpressApp.CreateCustomObjectSpaceProviderEventArgs"/> instance containing the event data.</param>
        private void application_CreateCustomObjectSpaceProvider(object sender,
                                                                 CreateCustomObjectSpaceProviderEventArgs e)
        {
            IXpoDataStoreProvider dataStoreProvider = null;

            if (providerFactory != null)
            {
                dataStoreProvider = providerFactory.CreateDataStoreProvider(e.Connection, e.ConnectionString);
            }
            if (dataStoreProvider == null)
            {
                if (e.Connection == null)
                {
                    dataStoreProvider = new ConnectionStringDataStoreProvider(e.ConnectionString);
                }
                else
                {
                    dataStoreProvider = new ConnectionDataStoreProvider(e.Connection);
                }
            }
            e.ObjectSpaceProvider = new ObjectSpaceProvider(dataStoreProvider);
        }
Example #11
0
 /// <summary>
 /// Handles the CreateCustomObjectSpaceProvider event of the application control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="DevExpress.ExpressApp.CreateCustomObjectSpaceProviderEventArgs"/> instance containing the event data.</param>
 private void application_CreateCustomObjectSpaceProvider(object sender, 
     CreateCustomObjectSpaceProviderEventArgs e)
 {
     IXpoDataStoreProvider dataStoreProvider = null;
     if(providerFactory != null)
         dataStoreProvider = providerFactory.CreateDataStoreProvider(e.Connection, e.ConnectionString);
     if (dataStoreProvider == null)
     {
         if (e.Connection == null)
             dataStoreProvider = new ConnectionStringDataStoreProvider(e.ConnectionString);
         else
             dataStoreProvider = new ConnectionDataStoreProvider(e.Connection);
     }
     e.ObjectSpaceProvider = new ObjectSpaceProvider(dataStoreProvider);
 }