コード例 #1
0
        XPDictionary PrepareDictionary(Type[] entityTypes)
        {
            var dict = new ReflectionDictionary();

            dict.GetDataStoreSchema(entityTypes);
            return(dict);
        }
コード例 #2
0
    private static IDataLayer GetDataLayer()
    {
        // set XpoDefault.Session to null to prevent accidental use of XPO default session
        XpoDefault.Session = null;

        string       conn = MSSqlConnectionProvider.GetConnectionString("(local)", "XpoWebTest");
        XPDictionary dict = new ReflectionDictionary();

        /* Note: The database schema must exactly match your persistent classes' definition. ASP.NET applications
         * should not update the database schema themselves; moreover, they often don't have enough permission
         * to read the database schema.  You may need to create a separate tool which manages your database.
         * On the one hand, we recommend using AutoCreateOption.SchemaAlreadyExists for the XPO data layer of your
         * Web site.  On the other hand, the ThreadSafeDataLayer intensively uses data which is stored in the XPO's
         * XPObjectType service table.  This sample project maps to the XpoWebTest database on your MS SQL Server.
         * This database is created via the DatabaseUpdater project, which must be launched before this Site is
         * published. */

        IDataStore store = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.SchemaAlreadyExists);

        // initialize the XPO dictionary
        dict.GetDataStoreSchema(typeof(PersistentObjects.Customer).Assembly);

        // create a ThreadSafeDataLayer
        IDataLayer dl = new ThreadSafeDataLayer(dict, store);

        return(dl);
    }
コード例 #3
0
        private static void RegistrarObjectSpace()
        {
            string connectionString = "";

            if (ConfigurationManager.ConnectionStrings["ConnectionString"] != null)
            {
                connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            }

            IDataStore   store = XpoDefault.GetConnectionProvider(connectionString, AutoCreateOption.SchemaAlreadyExists);
            XPDictionary dict  = new ReflectionDictionary();

            dict.GetDataStoreSchema(System.Reflection.Assembly.GetExecutingAssembly());
            XpoDefault.DataLayer = new ThreadSafeDataLayer(dict, store);

            XpoTypesInfoHelper.ForceInitialize();
            XpoTypesInfoHelper.GetXpoTypeInfoSource();

            XafTypesInfo.Instance.RegisterEntity(typeof(Venta));
            XafTypesInfo.Instance.RegisterEntity(typeof(TipoDocumento));
            XafTypesInfo.Instance.RegisterEntity(typeof(CobroPendiente));
            XafTypesInfo.Instance.RegisterEntity(typeof(ReporteCxcEmpleado));
            XafTypesInfo.Instance.RegisterEntity(typeof(CorteDeCaja));
            XafTypesInfo.Instance.RegisterEntity(typeof(Empleado));

            XafTypesInfo.Instance.RegisterEntity(typeof(Sucursal));


            XafTypesInfo.Instance.RegisterEntity(typeof(ReportDataV2));

            XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(connectionString, null, true);

            ObjectsPaceConnection.PropObjectSpace = directProvider.CreateObjectSpace();
            ObjectsPaceConnection.Session         = ((XPObjectSpace)ObjectsPaceConnection.PropObjectSpace).Session;
        }
        static IDataLayer SetupDB1()
        {
            string       connString = MSSqlConnectionProvider.GetConnectionString("(local)", "SampleDB1");
            XPDictionary dict       = new ReflectionDictionary();

            dict.CollectClassInfos(typeof(Contact));
            IDataLayer dal = XpoDefault.GetDataLayer(connString, dict, AutoCreateOption.DatabaseAndSchema);

            using (UnitOfWork uow = new UnitOfWork(dal)) {
                uow.UpdateSchema(typeof(Contact));
                if (uow.FindObject <Contact>(null) == null)
                {
                    Contact contact1 = new Contact(uow)
                    {
                        FirstName = "John", LastName = "Doe"
                    };
                    Contact contact2 = new Contact(uow)
                    {
                        FirstName = "Paul", LastName = "Smith"
                    };
                    uow.CommitChanges();
                }
            }
            return(dal);
        }
コード例 #5
0
        /// <summary>
        /// 创建 XPO 的 ThreadSafeDataLayer
        /// </summary>
        /// <param name="assemblies"></param>
        /// <returns></returns>
        static IDataLayer GetDataLayer(params Assembly[] assemblies)
        {
            ReflectionDictionary dict = new ReflectionDictionary();

            dict.CollectClassInfos(assemblies);

            IDataLayer dataLayer;

            int maxConnections = GetMaxConnections();

            if (maxConnections > 1)
            {
                IDataStore[] stores = new IDataStore[maxConnections];
                for (int i = 0; i < maxConnections; i++)
                {
                    stores[i] = GetDataStore();
                }
                dataLayer = new ThreadSafeDataLayer(dict, new DataStoreFork(stores));
            }
            else
            {
                dataLayer = new ThreadSafeDataLayer(dict, GetDataStore());
            }

            return(dataLayer);
        }
コード例 #6
0
        public static async Task ExecAsync(Func <UnitOfWork, Task> action)
        {
            XpoDefault.Session = null;

            if (DATA_LAYER == null)
            {
                var sqlHelper = new SqlServerTestDbHelper("Xpo");
                sqlHelper.ResetDatabase();

                var dict = new ReflectionDictionary();
                dict.GetDataStoreSchema(
                    typeof(DefaultSort.DataItem),
                    typeof(RemoteGroupingStress.DataItem),
                    typeof(Summary.DataItem),
                    typeof(Bug339.DataItem),
                    typeof(PaginateViaPrimaryKey.DataItem),
                    typeof(Async.DataItem)
                    );

                var provider = XpoDefault.GetConnectionProvider(
                    sqlHelper.ConnectionString,
                    AutoCreateOption.SchemaOnly
                    );

                DATA_LAYER = new SimpleDataLayer(dict, provider);
            }

            using (var uow = new UnitOfWork(DATA_LAYER)) {
                await action(uow);
            }
        }
コード例 #7
0
        private void UpdateSchemaInternal(ITypesInfo typesInfo)
        {
            List <BusinessObjectExtension> NewTypes = new List <BusinessObjectExtension>();
            var UoW = XpoHelper.CreateUnitOfWork();
            Dictionary <XPClassInfo, XPCollection <BusinessObjectField> > DynamicClasses = new Dictionary <XPClassInfo, XPCollection <BusinessObjectField> >();
            var Model = UoW.Query <ExtendedModel>().FirstOrDefault(model => model.Name == ModelName);

            if (Model == null)
            {
                Debug.WriteLine($"Model {ModelName} not found");
                return;
            }

            XPDictionary dictionary = new ReflectionDictionary();
            XPClassInfo  BaseClass  = dictionary.GetClassInfo(typeof(BaseObject));

            foreach (BusinessObjectExtension businessObjectExtension in Model.BusinessObjectExtensions)
            {
                if (!String.IsNullOrEmpty(businessObjectExtension.Type))
                {
                    ITypeInfo ClassInfo = typesInfo.FindTypeInfo(businessObjectExtension.Type);
                    CreateFields(ClassInfo, businessObjectExtension.BusinessObjectFields);
                }
            }
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: ARMO-Systems/Feedbacks
        private static int Main()
        {
            try
            {
                // ExtractTimexLog();
                var reflectionDict = new ReflectionDictionary();
                reflectionDict.GetDataStoreSchema(typeof(ClientXPO).Assembly);
                XpoDefault.DataLayer = new ThreadSafeDataLayer(reflectionDict,
                                                               new MSSqlConnectionProvider(
                                                                   new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString),
                                                                   AutoCreateOption.DatabaseAndSchema));
                XpoDefault.Session = null;

                //ExtractTimexLog();
                new Statistic();

                /*switch ( args[ 0 ] )
                 * {
                 *  case "2":
                 *
                 *      break;
                 *  case "3":
                 *      GetStatisticData( args[ 1 ], args[ 2 ], args[ 3 ] );
                 *      break;
                 * }*/
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
                return(-1);
            }
        }
コード例 #9
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            ConfigureFilters(Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory);


            RestApiAgnosticDataStoreImp.Register();

            string connectionString = "XpoProvider=RestApiAgnosticDataStoreImp;EndPoint=http://192.168.1.64/XpoServer/api/DataStoreAgnosticMultiDb;Token=Empty;DataStoreId=ConnectionString";
            var    DataStore        = XpoDefault.GetConnectionProvider(connectionString, DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);

            var dictionary = new ReflectionDictionary();

            dictionary.GetDataStoreSchema(typeof(Item).Assembly);


            //Updating schema XPO way
            SimpleDataLayer UpdateSchemaDal = new SimpleDataLayer(dictionary, DataStore);
            UnitOfWork      UpdateSchemaUoW = new UnitOfWork(UpdateSchemaDal);

            UpdateSchemaUoW.UpdateSchema();
            UpdateSchemaUoW.CreateObjectTypeRecords();
            //Finish updating schema

            XpoDefault.DataLayer = new SimpleDataLayer(dictionary, DataStore);

            this.InitializeComponent();
            this.Suspending += OnSuspending;
        }
コード例 #10
0
        private static ReflectionDictionary GetDictionary(Type[] types)
        {
            var reflectionDictionary = new ReflectionDictionary();

            reflectionDictionary.CollectClassInfos(types);
            return(reflectionDictionary);
        }
コード例 #11
0
        public void AutoScript()
        {
            // Создание скрипта
            const string path = "autoscript.txt";
            StreamWriter script = new StreamWriter(path);
            ReflectionDictionary dictionary = new ReflectionDictionary();
            XPDictionaryInformer.Register(dictionary);
            SimpleDataLayer dataLayer = new SimpleDataLayer(dictionary, new OracleConnectionProviderEx(
                ODPConnectionProvider.CreateConnection(Properties.Settings.Default.ConnectionAdmin), AutoCreateOption.SchemaOnly, script, UpdateSchemaOptions.Default));
            dataLayer.UpdateSchema(false, new Type[] {
                typeof(AutoIdClass), typeof(StringIdClass), typeof(ComplexIdClass), typeof(NoIdClass),
                typeof(NotNullClass), typeof(ReadOnlyClass),
                typeof(ConsistentPeriodClass), typeof(ConsistentPeriodClass2), typeof(ContinuousPeriodClass), typeof(HierarchyClass),
                typeof(SimpleConstraintClass), typeof(ConstraintClass), typeof(CategoryClass), typeof(SecurityClass),
                typeof(UniqueBaseClass), typeof(UniqueClass),
                typeof(DevExpress.Xpo.XPObjectType)
            }.Select(c => dictionary.GetClassInfo(c)).ToArray());
            script.Close();

            // Проверка непустого содержания файла
            FileStream file = new FileStream(path, FileMode.Open);
            Assert.IsFalse(file.Length == 0, "File of autoscript is empty.");
            file.Close();

            // Проверка валидности скрипта
            Connection.ExecuteFile(path);
            dataLayer.Dispose();
        }
コード例 #12
0
            static XPDictionary PrepareDictionary()
            {
                var dict = new ReflectionDictionary();

                dict.GetDataStoreSchema(ConnectionHelper.GetPersistentTypes());
                return(dict);
            }
コード例 #13
0
        public static void Exec(Action <UnitOfWork> action)
        {
            lock (LOCK) {
                XpoDefault.Session = null;

                if (DATA_LAYER == null)
                {
                    var sqlHelper = new SqlServerTestDbHelper("Xpo");
                    sqlHelper.ResetDatabase();

                    var dict = new ReflectionDictionary();
                    dict.GetDataStoreSchema(
                        typeof(DefaultSort.DataItem),
                        typeof(RemoteGroupingStress.DataItem),
                        typeof(Summary.DataItem)
                        );

                    var provider = XpoDefault.GetConnectionProvider(
                        sqlHelper.ConnectionString,
                        AutoCreateOption.SchemaOnly
                        );

                    DATA_LAYER = new SimpleDataLayer(dict, provider);
                }

                using (var uow = new UnitOfWork(DATA_LAYER)) {
                    action(uow);
                }
            }
        }
コード例 #14
0
ファイル: MasterXpoHelper.cs プロジェクト: bajwaimran/mpwapi
        public static IDataLayer GetDataLayer()
        {
            XpoDefault.Session = null;
            var uow           = XpoHelper.GetNewUnitOfWork();
            var sqlConnection = uow.FindObject <SQLConnection>(CriteriaOperator.Parse("Oid==?", 1));
            //string conn = MySqlConnectionProvider.GetConnectionString("localhost", "root", "", "CUFE");
            string sqlConnectionString = MSSqlConnectionProvider.GetConnectionString(sqlConnection.IP, sqlConnection.user, sqlConnection.password, sqlConnection.Datenbank);
            //string conn = System.Configuration.ConfigurationManager.ConnectionStrings[sqlConnectionString].ConnectionString;
            XPDictionary dict  = new ReflectionDictionary();
            IDataStore   store = XpoDefault.GetConnectionProvider(sqlConnectionString, AutoCreateOption.None);

            //DevExpress.Xpo.Metadata.ReflectionClassInfo.SuppressSuspiciousMemberInheritanceCheck = true;
            //dict.GetDataStoreSchema(typeof(Inscripcion).Assembly);
            //IDataLayer dl = new ThreadSafeDataLayer(dict, store);
            ////using (UnitOfWork uow = new UnitOfWork(dl))
            ////{
            ////    int cnt = (int)uow.Evaluate<CUFE.Models.Country>(CriteriaOperator.Parse("count"), null);
            ////    if (cnt == 0)
            ////    {
            ////        new CUFE.Models.Country(uow) { CountryName = "Germany" };
            ////        uow.CommitChanges();
            ////    }
            ////}
            //return dl;

            return(XpoDefault.GetDataLayer(sqlConnectionString, AutoCreateOption.SchemaAlreadyExists));
        }
コード例 #15
0
        public App()
        {
            InitializeComponent();


            RestApiAgnosticDataStoreImp.Register();

            string connectionString = "XpoProvider=RestApiAgnosticDataStoreImp;EndPoint=http://192.168.1.64/XpoServer/api/DataStoreAgnosticMultiDb;Token=Empty;DataStoreId=ConnectionString";
            var    DataStore        = DevExpress.Xpo.XpoDefault.GetConnectionProvider(connectionString, DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);

            var dictionary = new ReflectionDictionary();

            dictionary.GetDataStoreSchema(typeof(Item).Assembly);


            //Updating schema XPO way
            SimpleDataLayer UpdateSchemaDal = new SimpleDataLayer(dictionary, DataStore);
            UnitOfWork      UpdateSchemaUoW = new UnitOfWork(UpdateSchemaDal);

            UpdateSchemaUoW.UpdateSchema();
            UpdateSchemaUoW.CreateObjectTypeRecords();
            //Finish updating schema

            XpoDefault.DataLayer = new SimpleDataLayer(dictionary, DataStore);



            DependencyService.Register <MockDataStore>();
            MainPage = new MainPage();
        }
コード例 #16
0
        private static List <TableInfo> GetTablesBasicInfo()
        {
            List <TableInfo> tables = new List <TableInfo>();
            XPDictionary     dict   = new ReflectionDictionary();

            var assemblyInstance = GlobalMethods.GetAssemblyByName("CoreModel");

            dict.CollectClassInfos(assemblyInstance);

            foreach (XPClassInfo item in dict.Classes)
            {
                if (item.ClassType == typeof(TableBase))
                {
                    continue;
                }
                var tableNameProp = item.ClassType.GetField("TableName");
                var tableTypeProp = item.ClassType.GetField("TableType");
                if (item.IsPersistent &&
                    tableNameProp != null &&
                    tableTypeProp != null)
                {
                    var tn = tableNameProp.GetValue(null);
                    var tt = tableTypeProp.GetValue(null);
                    if (tn != null && tt != null)
                    {
                        var le_TableName = (TableEnum)tn;
                        var le_TableType = (MyEnums.TableType)tt;
                        var info         = ReadClassInfo(item.ClassType, le_TableName, le_TableType);
                        tables.Add(info);
                    }
                }
            }

            return(tables);
        }
コード例 #17
0
        private IDataLayer ConfigureConnection(params Type[] types)
        {
            XpoDefault.Session = null;
            var          store      = XpoDefault.GetConnectionProvider(_settings.ConnectionString, _settings.CreateOption, out var objectsToRelase);
            XPDictionary dictionary = new ReflectionDictionary();

            if (types != null)
            {
                dictionary.GetDataStoreSchema(types);
            }

            IDataLayer dataLayer = new ThreadSafeDataLayer(dictionary, store);

            // DATABASE MIGRATION CODE
            if (_settings.CreateOption == AutoCreateOption.SchemaOnly &&
                types != null)
            {
                // Prepare database structure
                using (DevExpress.Xpo.UnitOfWork session = new DevExpress.Xpo.UnitOfWork(dataLayer))
                {
                    session.UpdateSchema(types);
                    session.CreateObjectTypeRecords(types);
                }
            }

            return(dataLayer);
        }
コード例 #18
0
ファイル: XpoHelper.cs プロジェクト: egarim/XpoExtenderDemo
        static XPDictionary PrepareDictionary()
        {
            var dict = new ReflectionDictionary();

            dict.GetDataStoreSchema(assembly);
            return(dict);
        }
        static void Main()
        {
            ConnectionProviderSql provider =
                (ConnectionProviderSql)XpoDefault.GetConnectionProvider(SQLiteConnectionProvider.GetConnectionString(@"CustomCommand.sqlite"),
                                                                        AutoCreateOption.DatabaseAndSchema);

            provider.RegisterCustomFunctionOperator(new GetMonthFunction());
            XPDictionary dict = new ReflectionDictionary();

            dict.CustomFunctionOperators.Add(new GetMonthFunction());
            XpoDefault.DataLayer = new SimpleDataLayer(dict, provider);
            CreateData();

            using (Session session = new Session()) {
                XPView view = new XPView(session, typeof(Order));
                view.AddProperty("Month", "custom('GetMonth', OrderDate)");

                foreach (ViewRecord prop in view)
                {
                    Console.WriteLine(prop["Month"]);
                }

                var list = from o in new XPQuery <Order>(session)
                           where o.OrderName == "Chai"
                           select new { Month = GetMonthFunction.GetMonth(o.OrderDate) };

                foreach (var item in list)
                {
                    Console.WriteLine(item.Month);
                }
            }
            Console.WriteLine("done\npress any key to exit ..");
            Console.ReadKey();
        }
コード例 #20
0
 public static void TestsInitialize(TestContext testContext)
 {
     ReflectionDictionary dictionary = new ReflectionDictionary();
     XPDictionaryInformer.Register(dictionary);
     OracleConnectionProviderEx provider = new OracleConnectionProviderEx(
         ODPConnectionProvider.CreateConnection(Properties.Settings.Default.Connection), AutoCreateOption.SchemaAlreadyExists);
     XpoDefault.DataLayer = new SimpleDataLayerEx(dictionary, provider);
 }
コード例 #21
0
        static IDataLayer GetDataLayer()
        {
            XpoDefault.Session = null;
            XPDictionary dict = new ReflectionDictionary();

            dict.GetDataStoreSchema(typeof(Person).Assembly);
            return(new ThreadSafeDataLayer(dict, new DataCacheNode(new CachingDataStore("http://localhost:1556/CachingService.asmx"))));
        }
    static XpoHelper()
    {
        XPDictionary dict = new ReflectionDictionary();

        dict.GetDataStoreSchema(typeof(Person).Assembly);
        AuditTrailService.Instance.SetXPDictionary(dict);
        AuditTrailService.Instance.AuditDataStore = new AuditDataStore <bi.AuditDataItemPersistent, bi.AuditedObjectWeakReference>();
    }
コード例 #23
0
 void FillDictionaries(XPDictionary xpDictionary)
 {
     foreach (XPClassInfo queryClassInfo in xpDictionary.Classes.OfType <XPClassInfo>().Where(info => !(info is IntermediateClassInfo)))
     {
         ReflectionDictionary reflectionDictionary = _dataStoreManager.GetDictionary(queryClassInfo);
         reflectionDictionary.QueryClassInfo(queryClassInfo.ClassType);
     }
 }
        public void Setup()
        {
            XPDictionary dict = new ReflectionDictionary();

            dict.GetDataStoreSchema(typeof(BasePersistentClass).Assembly);
            XpoDefault.DataLayer = new SimpleDataLayer(dict, new InMemoryDataStore(AutoCreateOption.DatabaseAndSchema));
            XpoDefault.Session   = null;
        }
コード例 #25
0
ファイル: DBProvider.cs プロジェクト: mosk-a-v/Weather
        public void InitializeRaspperyDB(string connectionString)
        {
            raspperyStore = XpoDefault.GetConnectionProvider(connectionString, AutoCreateOption.SchemaAlreadyExists);
            var dict = new ReflectionDictionary();

            dict.CollectClassInfos(typeof(TemperatureValue).Assembly);
            raspperyDataLayer = new ThreadSafeDataLayer(dict, raspperyStore);
        }
コード例 #26
0
ファイル: DBProvider.cs プロジェクト: mosk-a-v/Weather
        public void InitializeLocalDB(string connectionString)
        {
            localStore = XpoDefault.GetConnectionProvider(connectionString, AutoCreateOption.DatabaseAndSchema);
            var dict = new ReflectionDictionary();

            dict.CollectClassInfos(typeof(TemperatureValue).Assembly);
            localDataLayer = new ThreadSafeDataLayer(dict, localStore);
        }
コード例 #27
0
        public void Initialize(string northwindConnectionString, string appConnectionString)
        {
            Guard.ArgumentIsNotNullOrEmpty(appConnectionString, "appConnectionString");
            Guard.ArgumentIsNotNullOrEmpty(northwindConnectionString, "northwindConnectionString");

            northwindDictionary            = new ReflectionDictionary();
            this.northwindConnectionString = northwindConnectionString;
            this.appConnectionString       = appConnectionString;
        }
コード例 #28
0
        IDataLayer CreateDataLayer()
        {
            string connectionString = Configuration["ConnectionString"];
            var    provider         = XpoDefault.GetConnectionProvider(connectionString, DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);
            var    dictionary       = new ReflectionDictionary();

            dictionary.GetDataStoreSchema(typeof(Customer), typeof(Order));
            return(new ThreadSafeDataLayer(dictionary, provider));
        }
コード例 #29
0
        private IDataLayer CreateDataLayer()
        {
            XPDictionary dictionary = new ReflectionDictionary();
            dictionary.CollectClassInfos(typeof(XpoAsyncTests).Assembly);

            var memoryDataStore = new InMemoryDataStore(AutoCreateOption.DatabaseAndSchema);

            return new ThreadSafeDataLayer(dictionary, memoryDataStore);
        }
    private static IDataLayer GetDataLayer()
    {
        XpoDefault.Session = null;
        XPDictionary dict = new ReflectionDictionary();

        dict.GetDataStoreSchema(Assembly.GetExecutingAssembly());
        return(new ThreadSafeDataLayer(dict, XpoDefault.GetConnectionProvider(ConfigurationManager.ConnectionStrings[ConnectionStringName].ConnectionString,
                                                                              AutoCreateOption.None)));
    }
コード例 #31
0
        private static IDataLayer GetDataLayer()
        {
            XpoDefault.Session = null;
            XPDictionary dict = new ReflectionDictionary();
            dict.GetDataStoreSchema(Assembly.GetExecutingAssembly());

            return new ThreadSafeDataLayer(dict, XpoDefault.GetConnectionProvider(ConfigurationManager.ConnectionStrings[ConnectionString].ConnectionString,AutoCreateOption.None));

        }
コード例 #32
0
ファイル: XPObjectsTests.cs プロジェクト: jannisk/VideoRent
 public override void Init()
 {
     base.Init();
     if (dict == null)
     {
         dict = new ReflectionDictionary();
     }
     copy = new UnitOfWork(new TestDataLayer(dict, DataStoreHelper.CreateInMemoryDataStore()));
 }
コード例 #33
0
        static void InitializeDataLayer(IDbConnection connection)
        {
            ConnectionProviderSql prov = (ConnectionProviderSql)XpoDefault.GetConnectionProvider(connection, AutoCreateOption.None);
            XPDictionary          dict = new ReflectionDictionary();

            DBTable[] tables = prov.GetStorageTables("Categories");
            AddClass(dict, tables[0]);
            XpoDefault.DataLayer = new SimpleDataLayer(dict, prov);
        }
コード例 #34
0
 ReflectionDictionary GetReflectionDictionary() {
     Type persistentAssemblyInfoType = TypesInfo.Instance.PersistentAssemblyInfoType;
     IEnumerable<Type> types = persistentAssemblyInfoType.Assembly.GetTypes().Where(type => type.Namespace.StartsWith(persistentAssemblyInfoType.Namespace));
     var reflectionDictionary = new ReflectionDictionary();
     foreach (var type in types) {
         reflectionDictionary.QueryClassInfo(type);    
     }
     return reflectionDictionary;
 }
コード例 #35
0
        static IDataLayer GetThreadSafeDataLayer(SqlConnection conn)
        {
            IDataStore   dataStore = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.DatabaseAndSchema);
            XPDictionary dict      = new ReflectionDictionary();

            IDataLayer dataLayer = new ThreadSafeDataLayer(dict, dataStore);

            return(dataLayer);
        }
コード例 #36
0
ファイル: DataStoreManager.cs プロジェクト: akingunes/eXpand
 ReflectionDictionary GetDictionary(string key) {
     if (!_reflectionDictionaries.ContainsKey(key)) {
         var reflectionDictionary = new ReflectionDictionary();
         _reflectionDictionaries.Add(key, reflectionDictionary);
         var simpleDataLayer = new SimpleDataLayer(reflectionDictionary,GetConnectionProvider(key));
         _simpleDataLayers.Add(key, simpleDataLayer);
         _tables.Add(key,new List<string>());
     }
     return _reflectionDictionaries[key];
 }
コード例 #37
0
 public static ReflectionDictionary GetReflectionDictionary(XpandModuleBase moduleBase) {
     var externalModelBusinessClassesList = moduleBase.GetAdditionalClasses(moduleBase.Application.Modules);
     Type persistentAssemblyInfoType = externalModelBusinessClassesList.FirstOrDefault(type1 => typeof(IPersistentAssemblyInfo).IsAssignableFrom(type1));
     if (persistentAssemblyInfoType == null)
         throw new ArgumentNullException("Add a business object that implements " +
                                         typeof(IPersistentAssemblyInfo).FullName + " at your AdditionalBusinessClasses (module.designer.cs)");
     IEnumerable<Type> types = persistentAssemblyInfoType.Assembly.GetTypes().Where(type => (type.Namespace + "").StartsWith(persistentAssemblyInfoType.Namespace + ""));
     var reflectionDictionary = new ReflectionDictionary();
     foreach (var type in types) {
         reflectionDictionary.QueryClassInfo(type);
     }
     return reflectionDictionary;
 }
コード例 #38
0
 public VidoWebService()
 {
     XPDictionary dict = new ReflectionDictionary();
     dict.GetDataStoreSchema(typeof(SimpleUser).Assembly);
     dict.GetDataStoreSchema(typeof(Student).Assembly);
     //We use the demo connection string here.
     string defaultConnectionString = "";
     if (ConfigurationManager.ConnectionStrings["ConnectionString"] != null)
         defaultConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
     //Usually, your web service should not update the database. The line below is just for demo purposes.
     IDataStore store = DevExpress.Xpo.XpoDefault.GetConnectionProvider(defaultConnectionString,
         DevExpress.Xpo.DB.AutoCreateOption.None);
     XpoDefault.DataLayer = new ThreadSafeDataLayer(dict, store);
     XpoDefault.Session = null;
 }
コード例 #39
0
 private static IDataLayer GetDataLayer()
 {
     try
     {
         XpoDefault.Session = null;
         String conn = ConfigurationManager.ConnectionStrings["AuditConnectionString"].ConnectionString;
         XPDictionary dict = new ReflectionDictionary();
         IDataStore store = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.DatabaseAndSchema);
         dict.GetDataStoreSchema(typeof(Calls).Assembly);
         IDataLayer dl = new ThreadSafeDataLayer(dict, store);
         return dl;
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #40
0
ファイル: SessionManager.cs プロジェクト: Zeus6221/Practicas
        private static IDataLayer GetDataLayer()
        {
            XpoDefault.Session = null;

            AppSettingsReader config = new AppSettingsReader();

            string conn = (string)(config.GetValue("ConectionString", typeof(string)));

            XPDictionary dict = new ReflectionDictionary();

            IDataStore store = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.DatabaseAndSchema);

            dict.GetDataStoreSchema(typeof(ContinenteXPO).Assembly);

            IDataLayer dl = new ThreadSafeDataLayer(dict, store);

            return dl;
        }
コード例 #41
0
        static void Main(string[] args)
        {
            XPDictionary dictionary = new ReflectionDictionary();
            dictionary.GetDataStoreSchema(typeof(Person).Assembly);

            Console.WriteLine("Opening service host...");

            ThreadSafeDataLayer dataLayer = new ThreadSafeDataLayer(dictionary, XpoDefault.GetConnectionProvider(Constants.DatabaseConnectionString, AutoCreateOption.SchemaAlreadyExists));
            SerializableObjectLayer objectlayer = new SerializableObjectLayer(new UnitOfWork(new SimpleObjectLayer(dataLayer)));
            ServiceHost host = new ServiceHost(new SerializableObjectLayerSingletonService(objectlayer));
            host.AddServiceEndpoint(typeof(ISerializableObjectLayerService), new BasicHttpBinding(), Constants.WCF_Server_Uri);
            host.Open();

            Console.WriteLine("Service host is opened.");
            Console.WriteLine("Press Enter to close");
            Console.ReadLine();

            Console.WriteLine("Closing service host...");
            host.Close();
            Console.WriteLine("Service host is closed.");
        }
コード例 #42
0
        /// <summary>
        /// Initializes the proxy.
        /// </summary>
        /// <param name="dictionary">The dictionary.</param>
        /// <param name="appConnectionString">The app connection string.</param>
        /// <param name="secondStorageConnectionString">The replication storage connection string.</param>
        /// <param name="secondStorageClasses">The second storage classes.</param>
        public void Initialize(XPDictionary dictionary, string appConnectionString,
            string secondStorageConnectionString, IEnumerable<XPClassInfo> secondStorageClasses)
        {
            var appDictionary = new ReflectionDictionary();
            secondStorageDictionary = new ReflectionDictionary();

            secondStorageClasses.ToList().ForEach(x => secondStorageTableNames.Add(x.TableName));

            foreach(XPClassInfo ci in dictionary.Classes)
            {
                if (secondStorageTableNames.Contains(ci.TableName))
                    secondStorageDictionary.QueryClassInfo(ci.ClassType);

                appDictionary.QueryClassInfo(ci.ClassType);
            }

            appDataStore = XpoDefault.GetConnectionProvider(appConnectionString, AutoCreateOption.DatabaseAndSchema);
            appDataLayer = new SimpleDataLayer(appDictionary, appDataStore);

            secondStorageConnStr = secondStorageConnectionString;
        }
コード例 #43
0
ファイル: DataStoreManager.cs プロジェクト: aries544/eXpand
 ReflectionDictionary GetDictionary(KeyInfo keyInfo) {
     if (!_reflectionDictionaries.ContainsKey(keyInfo)) {
         var reflectionDictionary = new ReflectionDictionary();
         _reflectionDictionaries.Add(keyInfo, reflectionDictionary);
         _tables.Add(keyInfo.Key, new List<string>());
     }
     return _reflectionDictionaries[keyInfo];
 }
コード例 #44
0
ファイル: Updater.cs プロジェクト: aries544/eXpand
        public bool Run(RuntimeSetupInfo setupInfo) {
            var typesInfo = new TypesInfo();
            typesInfo.AddEntityStore(new NonPersistentEntityStore(typesInfo));
            var reflectionDictionary = new ReflectionDictionary();reflectionDictionary.CollectClassInfos(typeof(ModuleArtifact).Assembly);
            var xpoTypeInfoSource = new XpoTypeInfoSource(typesInfo,reflectionDictionary);
            typesInfo.AddEntityStore(xpoTypeInfoSource);
            typesInfo.LoadTypes(typeof(ModuleArtifact).Assembly);
            var exportedTypesFromAssembly = ModuleHelper.CollectExportedTypesFromAssembly(typeof(ModuleArtifact).Assembly,ExportedTypeHelpers.IsExportedType);
            foreach (var type in exportedTypesFromAssembly){
                xpoTypeInfoSource.RegisterEntity(type);
            }

            var objectSpace = new XPObjectSpace(typesInfo, xpoTypeInfoSource, () => new UnitOfWork(reflectionDictionary){ ConnectionString = setupInfo.ConnectionString });
            if (!objectSpace.Contains<ModuleChild>()){
                var moduleTypes = GetModuleTypes(setupInfo);
                var childModules = objectSpace.GetModuleChilds(moduleTypes);
                foreach (var childModule in childModules){
                    childModule.Value.CreateArtifacts(childModule.Key);
                    childModule.Value.CreateExtenderInterfaces(childModule.Key);
                }
                UpdateMapViewModule(childModules, objectSpace);
            }
            CreateObjects(objectSpace, setupInfo);
            objectSpace.CommitChanges();
            return true;
        }
コード例 #45
0
ファイル: XpoHelper.cs プロジェクト: trantrung2608/ilinkbay
    private static IDataLayer GetDataLayer()
    {
        try
        {
            SqlConnection connection;
            MSSqlConnectionProvider connectionProvider;
            //Session workSession;
            connection = new SqlConnection(connectionString);
            connectionProvider = new MSSqlConnectionProvider(connection, AutoCreateOption.None);
            XpoDefault.Session = null;
            XPDictionary dict = new ReflectionDictionary();

            IDataStore store = XpoDefault.GetConnectionProvider(connectionString, AutoCreateOption.SchemaAlreadyExists);

            string[] tablesList = connectionProvider.GetStorageTablesList(true);
            dynamicClasses = new Dictionary<string, DynamicDataTableClassInfo>(tablesList.Length);
            for (int i = 0; i < tablesList.Length; i++)
            {
                string tableName = tablesList[i];
                SqlDataAdapter adapter = new SqlDataAdapter(string.Format("SELECT TOP 1 * FROM [{0}]", tableName), connection);
                DataTable dataTable = new DataTable(tableName);
                adapter.FillSchema(dataTable, SchemaType.Source);
                if (dataTable.PrimaryKey.Length == 0)
                {
                    if (dataTable.Columns[0].DataType != typeof(Int32))
                    {
                        DataColumn dc = new DataColumn(tableName + "_idgen");
                        dc.AutoIncrement = true;
                        dc.AutoIncrementSeed = 1;
                        dc.AutoIncrementStep = 1;
                        dc.DataType = typeof(Int32);
                        dataTable.Columns.Add(dc);
                        DataColumn[] key = new DataColumn[1];
                        key[0] = dc;
                        dataTable.PrimaryKey = key;

                    }
                    else
                    {
                        DataColumn[] key = new DataColumn[1];
                        key[0] = dataTable.Columns[0];
                        dataTable.PrimaryKey = key;

                    }

                }

                dynamicClasses.Add(tableName, new DynamicDataTableClassInfo(dict, dataTable));

            }

            IDataLayer dl = new ThreadSafeDataLayer(dict, store);

            return dl;
        }
        catch (Exception ex)
        {
            SiAuto.Main.LogColored(Color.Red, "Loi BindData:" + ex.ToString());
            throw ex;
        }
    }
コード例 #46
0
ファイル: DataStoreManager.cs プロジェクト: noxe/eXpand
 ReflectionDictionary GetDictionary(KeyInfo keyInfo) {
     if (!_reflectionDictionaries.ContainsKey(keyInfo.Key)) {
         var reflectionDictionary = new ReflectionDictionary();
         _reflectionDictionaries.Add(keyInfo.Key, reflectionDictionary);
         var simpleDataLayer = new DataStoreManagerSimpleDataLayer(reflectionDictionary, GetConnectionProvider(keyInfo.Key), keyInfo.Key == StrDefault, keyInfo.IsLegacy);
         _simpleDataLayers.Add(keyInfo.Key, simpleDataLayer);
         _tables.Add(keyInfo.Key, new List<string>());
     }
     return _reflectionDictionaries[keyInfo.Key];
 }
コード例 #47
0
ファイル: Updater.cs プロジェクト: aries544/eXpand
        private UnitOfWork GetXmlUnitOfWork() {
            var reflectionDictionary = new ReflectionDictionary();
            var appSetting = string.Format(ConfigurationManager.AppSettings["VideoRentLegacyPath"], AssemblyInfo.VersionShort);
            var fullPath = Environment.ExpandEnvironmentVariables(appSetting);

            var legacyAssembly = Assembly.LoadFrom(Path.Combine(fullPath + @"\bin", @"DevExpress.VideoRent.dll"));
            reflectionDictionary.CollectClassInfos(legacyAssembly);
            var inMemoryDataStore = new InMemoryDataStore();
            inMemoryDataStore.ReadXml(Path.Combine(fullPath + @"\CS\DevExpress.VideoRent\Data", @"VideoRent.xml"));
            var simpleDataLayer = new SimpleDataLayer(reflectionDictionary, inMemoryDataStore);
            return new UnitOfWork(simpleDataLayer);
        }
コード例 #48
0
ファイル: DBManage.cs プロジェクト: fenyiwudian/farmer
        private static IDataLayer GetDataLayer()
        {
            //DevExpress.Xpo.Helpers.SessionStateStack.SuppressCrossThreadFailuresDetection = true;
            XpoDefault.Session = null;
            var dict = new ReflectionDictionary();
            dict.GetDataStoreSchema(Assembly.Load("FarmerInfo"));
            //dict.GetDataStoreSchema(Assembly.Load("vCloud.Survey.Model.SurveyAdminInfo"));
            //dict.GetDataStoreSchema(Assembly.Load("vCloud.Survey.Model.Log"));
            //dict.GetDataStoreSchema(typeof(MemberInformation).Assembly); // <<< initialize the XPO dictionary
            //dict.GetDataStoreSchema(typeof(Code).Assembly);
            //dict.GetDataStoreSchema(typeof(Account).Assembly);
            string connStr=ConfigurationManager.ConnectionStrings[ConnectionStringName].ConnectionString;
            var store = XpoDefault.GetConnectionProvider(connStr,  AutoCreateOption.None);

            return new ThreadSafeDataLayer(dict,store);
        }