static IDataLayer CreateDataLayer()
        {
            DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            dict.GetDataStoreSchema(typeof(Person).Assembly);
            DataSetDataStore dataStore = new DataSetDataStore(new DataSet(), AutoCreateOption.DatabaseAndSchema);
            using(UnitOfWork uow = new UnitOfWork(new SimpleDataLayer(dict, dataStore))) {
                uow.UpdateSchema(typeof(Person));
                Person p1 = new Person(uow);
                p1.FirstName = "Slava";
                p1.LastName = "Donchak";

                Person p2 = new Person(uow);
                p2.FirstName = "Dan";
                p2.LastName = "Ignatov";

                Product xaf = new Product(uow);
                xaf.Name = "Xaf";
                xaf.Manager = p2;

                Product xpo = new Product(uow);
                xpo.Name = "Xpo";
                xpo.Manager = p1;

                uow.CommitChanges();
            }

            return new ThreadSafeDataLayer(dict, dataStore);
        }
示例#2
0
        protected void Session_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            //string conn = DevExpress.Xpo.DB.MSSqlConnectionProvider.GetConnectionString(@".\SqlExpress", "sa", "123", "DBSymaiMall");
            var    configConStr = ConfigurationManager.ConnectionStrings["DreamMallConnectString"].ConnectionString;
            var    userId       = Utils.GetItemValueFromConnectionString(configConStr, "User ID");
            var    password     = Utils.GetItemValueFromConnectionString(configConStr, "Password");
            var    server       = Utils.GetItemValueFromConnectionString(configConStr, "Data Source");
            var    catalog      = Utils.GetItemValueFromConnectionString(configConStr, "Initial Catalog");
            string conn         = DevExpress.Xpo.DB.MSSqlConnectionProvider.GetConnectionString(
                server,
                userId,
                password,
                catalog
                );

            DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            // Initialize the XPO dictionary.

            dict.GetDataStoreSchema(new Type[] { typeof(zhongcj.cc.Models.BusinessObjects.DreamWeb.Article) });
            dict.GetDataStoreSchema(new Type[] { typeof(zhongcj.cc.Models.BusinessObjects.DreamMallMember.Member) });
            dict.GetDataStoreSchema(typeof(zhongcj.cc.Models.BusinessObjects.DreamMall.Product).Assembly);

            DevExpress.Xpo.XpoDefault.Session = null;
            DevExpress.Xpo.DB.IDataStore store = DevExpress.Xpo.XpoDefault.GetConnectionProvider(conn, DevExpress.Xpo.DB.AutoCreateOption.SchemaOnly);
            DevExpress.Xpo.XpoDefault.DataLayer = new DevExpress.Xpo.ThreadSafeDataLayer(dict, store);
        }
示例#3
0
        protected XpoTestsBase()
        {
            DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            // Initialize the XPO dictionary.
            dict.GetDataStoreSchema(typeof(Customer).Assembly);

            XpoDefault.DataLayer = new ThreadSafeDataLayer(dict, new InMemoryDataStore());
        }
        static IDataLayer CreateDataLayer()
        {
            DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            dict.GetDataStoreSchema(typeof(Person).Assembly);

            IDataStore store = XpoDefault.GetConnectionProvider(Constants.DatabaseConnectionString, DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists);
            return new ThreadSafeDataLayer(dict, store);
        }
 static IDataLayer CreateDataLayer()
 {
     DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
     dict.GetDataStoreSchema(typeof(AnungooODataServiceService).Assembly);
     IDataLayer dataLayer = new ThreadSafeDataLayer(dict, global::AnungooODataService.Anungoo.ConnectionHelper.GetConnectionProvider(DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists));
     XpoDefault.DataLayer = dataLayer;
     XpoDefault.Session = null;
     return dataLayer;
 }
        private void LoadAssembly_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            string assemblyFile = GetAssemblyPath();

            if (string.IsNullOrEmpty(assemblyFile))
            {
                return;
            }

            var asm = Assembly.LoadFrom(assemblyFile);

            var types = asm.GetExportedTypes();



            CompiledModel compiledModel = (CompiledModel)e.CurrentObject;

            compiledModel.Assembly = assemblyFile;
            compiledModel.Name     = Path.GetFileName(assemblyFile);

            //System.Object,DevExpress.Xpo.IXPObject,DevExpress.Xpo.IXPSimpleObject,DevExpress.Xpo.Helpers.IXPClassInfoAndSessionProvider,DevExpress.Xpo.Helpers.IXPClassInfoProvider,DevExpress.Xpo.Metadata.Helpers.IXPDictionaryProvider,DevExpress.Xpo.Helpers.ISessionProvider,DevExpress.Xpo.Helpers.IObjectLayerProvider,DevExpress.Xpo.Helpers.IDataLayerProvider,DevExpress.Xpo.IXPCustomPropertyStore,DevExpress.Xpo.IXPModificationsStore,DevExpress.Xpo.IXPInvalidateableObject,DevExpress.Xpo.IXPReceiveOnChangedFromDelayedProperty,DevExpress.Xpo.IXPReceiveOnChangedFromArbitrarySource,System.ComponentModel.INotifyPropertyChanged,DevExpress.Xpo.Helpers.IXPImmutableHashCode,System.ComponentModel.IEditableObject,System.ComponentModel.ICustomTypeDescriptor,System.IComparable,DevExpress.Xpo.IXPReceiveOnChangedFromXPPropertyDescriptor,DevExpress.Xpo.XPObject,DevExpress.Xpo.XPCustomObject,DevExpress.Xpo.XPBaseObject,DevExpress.Xpo.PersistentBase,System.Object
            var AllXpoBases = "System.Object,DevExpress.Xpo.IXPObject,DevExpress.Xpo.IXPSimpleObject,DevExpress.Xpo.Helpers.IXPClassInfoAndSessionProvider,DevExpress.Xpo.Helpers.IXPClassInfoProvider,DevExpress.Xpo.Metadata.Helpers.IXPDictionaryProvider,DevExpress.Xpo.Helpers.ISessionProvider,DevExpress.Xpo.Helpers.IObjectLayerProvider,DevExpress.Xpo.Helpers.IDataLayerProvider,DevExpress.Xpo.IXPCustomPropertyStore,DevExpress.Xpo.IXPModificationsStore,DevExpress.Xpo.IXPInvalidateableObject,DevExpress.Xpo.IXPReceiveOnChangedFromDelayedProperty,DevExpress.Xpo.IXPReceiveOnChangedFromArbitrarySource,System.ComponentModel.INotifyPropertyChanged,DevExpress.Xpo.Helpers.IXPImmutableHashCode,System.ComponentModel.IEditableObject,System.ComponentModel.ICustomTypeDescriptor,System.IComparable,DevExpress.Xpo.IXPReceiveOnChangedFromXPPropertyDescriptor,DevExpress.Xpo.XPObject,DevExpress.Xpo.XPCustomObject,DevExpress.Xpo.XPBaseObject,DevExpress.Xpo.PersistentBase,System.Object";

            var         AllXpoBasesList = AllXpoBases.Split(',').ToList();
            var         GetTypes        = asm.GetTypes();
            List <Type> AllTypes        = new List <Type>();

            foreach (Type type in GetTypes)
            {
                var Parents    = type.GetParentTypes();
                var matches    = Parents.Where(bt => AllXpoBases.Contains(bt.FullName));
                int MatchCount = matches.Count();
                //All types should have at least 1 match that is the object base object
                Debug.WriteLine(MatchCount);
                if (MatchCount > 1)
                {
                    //AllTypes.Add(type);


                    var Found = compiledModel.CompiledModelClasses.FirstOrDefault(mc => mc.Name == type.Name);
                    if (ReferenceEquals(Found, null))
                    {
                        Found               = this.ObjectSpace.CreateObject <CompiledModelClass>();
                        Found.Name          = type.Name;
                        Found.CompiledModel = compiledModel;
                        Found.FullType      = type.FullName;
                    }

                    if (this.View.ObjectSpace.IsModified)
                    {
                        this.View.ObjectSpace.CommitChanges();
                    }
                }
            }
        }
示例#7
0
        private static IDataLayer CreateDataLayer()
        {
            DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            dict.GetDataStoreSchema(typeof(ODataService4Service).Assembly);
            IDataLayer dataLayer = new ThreadSafeDataLayer(dict, global::ODataService4.WebDemo1.ConnectionHelper.GetConnectionProvider(DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists));

            XpoDefault.DataLayer = dataLayer;
            XpoDefault.Session   = null;
            return(dataLayer);
        }
        private static IDataLayer CreateDataLayer()
        {
            var dict     = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            var classes  = dict.CollectClassInfos(typeof(SampleObject).Assembly);
            var provider = XpoDefault.GetConnectionProvider(DevExpress.Xpo.DB.MSSqlConnectionProvider.GetConnectionString("localhost", "XpoImportHelperTest"), Xpo.DB.AutoCreateOption.DatabaseAndSchema);
            var dal      = new SimpleDataLayer(dict, provider);

            ((IDataLayerForTests)dal).ClearDatabase();
            dal.UpdateSchema(false, classes);
            return(dal);
        }
    private static IDataLayer GetDataLayer()
    {
        XpoDefault.Session = null;

        InMemoryDataStore ds = new InMemoryDataStore();

        DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
        dict.GetDataStoreSchema(typeof(MyObject).Assembly);

        return(new ThreadSafeDataLayer(dict, ds));
    }
示例#10
0
        static DevExpress.Xpo.ThreadSafeDataLayer CreateThreadSafeDataLayer(SqlConnection conn)
        {
            DevExpress.Xpo.Metadata.XPDictionary dict  = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            DevExpress.Xpo.DB.IDataStore         store = DevExpress.Xpo.XpoDefault.GetConnectionProvider(conn, DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists);
            //注意:如果项目中的XPO对象不是集中在一个类库而是分散在多个类库的话,我们需要在这里从每一个
            //      类库中都任意抓取一个对象作为参数传递给 GetDataStoreSchema 方法
            dict.GetDataStoreSchema(
                typeof(Hwagain.Components.BaseData).Assembly,
                typeof(YiKang.RBACS.AccessService).Assembly
                );

            return(new DevExpress.Xpo.ThreadSafeDataLayer(dict, store));
        }
示例#11
0
        public static void Init()
        {
            var config = new AppSettingsReader();
            var connectionString = ((string)config.GetValue("connect", typeof(string)));

            DevExpress.Xpo.Metadata.XPDictionary dict =
            new DevExpress.Xpo.Metadata.ReflectionDictionary();
            // Initialize the XPO dictionary.
            dict.GetDataStoreSchema(typeof(AudienceJournal), typeof(AudienceRadio), typeof(AudienceTV), typeof(Individu), typeof(Signalitique), typeof(Vague), typeof(XpoSupportPresse), typeof(XpoSupportRadio), typeof(XpoSupportTV), typeof(XpoTarifPr), typeof(XpoTarifRd), typeof(XpoTarifTv), typeof(XpoLigneTarifTv), typeof(XpoLigneTarifRd), typeof(XpoLigneTarifPr));

            DevExpress.Xpo.DB.IDataStore store = DevExpress.Xpo.XpoDefault.GetConnectionProvider(connectionString,
                DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);
            DevExpress.Xpo.XpoDefault.DataLayer = new DevExpress.Xpo.ThreadSafeDataLayer(dict, store);
            DevExpress.Xpo.XpoDefault.Session = null;
        }
示例#12
0
        public static void SetThreadSafeDataLayer(out ThreadSafeDataLayer Tsdl, string conn)
        {
            // Code that runs on application startup
            DevExpress.Xpo.Metadata.XPDictionary dict =
                new DevExpress.Xpo.Metadata.ReflectionDictionary();
            dict.GetDataStoreSchema(typeof(NewNetServicesModule).Assembly);
            DevExpress.Xpo.DB.IDataStore store =
                DevExpress.Xpo.XpoDefault
                .GetConnectionProvider(conn,
                                       DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists);
            store = new DevExpress.Xpo.DB.DataCacheNode(new DevExpress.Xpo.DB.DataCacheRoot(store));
            var layer = new DevExpress.Xpo.ThreadSafeDataLayer(dict, store);

            Tsdl = layer;
        }
示例#13
0
        public static void Init()
        {
            var connectionString = @"XpoProvider=MSAccess;Provider=Microsoft.Jet.OLEDB.4.0;Mode=Share Deny None;data source=C:\DataBase\audience.mdb;Jet OLEDB:Database Password=diesirae";

            DevExpress.Xpo.Metadata.XPDictionary dict =
                new DevExpress.Xpo.Metadata.ReflectionDictionary();
            // Initialize the XPO dictionary.
            dict.GetDataStoreSchema(typeof(AudienceJournal), typeof(AudienceRadio), typeof(AudienceTV), typeof(Individu), typeof(Signalitique), typeof(Vague), typeof(XpoSupportPresse), typeof(XpoSupportRadio), typeof(XpoSupportTV));


            DevExpress.Xpo.DB.IDataStore store = DevExpress.Xpo.XpoDefault.GetConnectionProvider(connectionString,
                                                                                                 DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);
            DevExpress.Xpo.XpoDefault.DataLayer = new DevExpress.Xpo.ThreadSafeDataLayer(dict, store);
            DevExpress.Xpo.XpoDefault.Session   = null;
        }
示例#14
0
 public static void Connect(DevExpress.Xpo.DB.AutoCreateOption autoCreateOption, bool threadSafe = false)
 {
     if (threadSafe)
     {
         var provider   = XpoDefault.GetConnectionProvider(ConnectionString, autoCreateOption);
         var dictionary = new DevExpress.Xpo.Metadata.ReflectionDictionary();
         dictionary.GetDataStoreSchema(persistentTypes);
         XpoDefault.DataLayer = new ThreadSafeDataLayer(dictionary, provider);
     }
     else
     {
         XpoDefault.DataLayer = XpoDefault.GetDataLayer(ConnectionString, autoCreateOption);
     }
     XpoDefault.Session = null;
 }
        private void InitXpoDal()
        {
            // for SQL Express
            //string connStr = @"Data Source=.\sqlexpress;Integrated Security=true;AttachDbFilename=|DataDirectory|\MvcGridView.mdf;User Instance=true;";

            // for SQL Server
            string connStr = @"Data Source=(local);Integrated Security=true;AttachDbFilename=|DataDirectory|\MvcGridView.mdf;";

            SqlConnection conn = new SqlConnection(connStr);

            DevExpress.Xpo.Metadata.XPDictionary dict  = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            DevExpress.Xpo.DB.IDataStore         store = DevExpress.Xpo.XpoDefault.GetConnectionProvider(conn, AutoCreateOption.SchemaAlreadyExists);
            dict.GetDataStoreSchema(typeof(Order).Assembly);  // <<< initialize the XPO dictionary
            XpoDefault.DataLayer = new ThreadSafeDataLayer(dict, store);
            XpoDefault.Session   = null;
        }
示例#16
0
        public static void Init()
        {
            AppSettingsReader config = new AppSettingsReader();
            var connectionString     = ((string)config.GetValue("connect", typeof(string)));

            DevExpress.Xpo.Metadata.XPDictionary dict =
                new DevExpress.Xpo.Metadata.ReflectionDictionary();
            // Initialize the XPO dictionary.
            dict.GetDataStoreSchema(typeof(XpoStock), typeof(XpoProductLine), typeof(XpoProduct), typeof(XpoSector), typeof(XpoClient), typeof(XpoOrder), typeof(XpoOrderLine), typeof(XpoWilaya), typeof(XpoCommune));


            DevExpress.Xpo.DB.IDataStore store = DevExpress.Xpo.XpoDefault.GetConnectionProvider(connectionString,
                                                                                                 DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);
            DevExpress.Xpo.XpoDefault.DataLayer = new DevExpress.Xpo.ThreadSafeDataLayer(dict, store);
            DevExpress.Xpo.XpoDefault.Session   = null;
        }
        static IDataLayer CreateDataLayer()
        {
            DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            // Initialize the XPO dictionary.
            dict.GetDataStoreSchema(typeof(Orders).Assembly);
            InMemoryDataStore store      = new InMemoryDataStore(AutoCreateOption.SchemaOnly);
            string            DBFileName = DevExpress.Utils.FilesHelper.FindingFileName(HttpRuntime.AppDomainAppPath, "App_Data\\nwind.xml");

            if (DBFileName != "")
            {
                store.ReadXml(DBFileName);
            }
            IDataLayer dataLayer = new ThreadSafeDataLayer(dict, store);

            XpoDefault.DataLayer = dataLayer;
            XpoDefault.Session   = null;
            return(dataLayer);
        }
示例#18
0
        public static void XPOStart()
        {
            try
            {
                string conString = SQLiteConnectionProvider.GetConnectionString(string.Format("{0}\\projects.ldb", System.Windows.Forms.Application.StartupPath));
                DevExpress.Xpo.Metadata.XPDictionary dictionary = new DevExpress.Xpo.Metadata.ReflectionDictionary();
                XpoDefault.DataLayer = XpoDefault.GetDataLayer(conString, AutoCreateOption.DatabaseAndSchema);
                DevExpress.Xpo.XpoDefault.Session = new DevExpress.Xpo.Session(XpoDefault.DataLayer);
                //DevExpress.Xpo.Helpers.SessionStateStack.SuppressCrossThreadFailuresDetection = true;
                //DevExpress.Xpo.Session.DefaultSession.UpdateSchema();

                //IDataStore store = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.SchemaAlreadyExists);
                //var layer = new ThreadSafeDataLayer(dictionary, store);
            }
            catch (Exception ex)
            {
                Utility.Hata(ex);
            }
        }
示例#19
0
        private void btnConvert_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                tbOracleConnectionStringText = TbOracleConnectionString.Text;
                TbCmsConnectionStringText    = TbCmsConnectionString.Text;
                string conn = TbCmsConnectionStringText;
                //get thread safe klayer
                if (conn != null)
                {
                    // Code that runs on application startup
                    DevExpress.Xpo.Metadata.XPDictionary dict =
                        new DevExpress.Xpo.Metadata.ReflectionDictionary();
                    dict.GetDataStoreSchema(typeof(NewNetServicesModule).Assembly);
                    DevExpress.Xpo.DB.IDataStore store =
                        DevExpress.Xpo.XpoDefault
                        .GetConnectionProvider(conn,
                                               DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists);
                    store = new DevExpress.Xpo.DB.DataCacheNode(new DevExpress.Xpo.DB.DataCacheRoot(store));
                    var layer = new DevExpress.Xpo.ThreadSafeDataLayer(dict, store);
                    Tsdl = layer;
                }
                if (Tsdl == null)
                {
                    //DevExpress.XtraEditors.XtraMessageBox.Show($"Couldn't create dl");
                    return;
                }
                //   MAINWorker.Connect(tsdl);
            }
            catch (Exception ex)
            {
                NewNetServices.Module.Core.StaticHelperMethods.WriteOut($"{ex}");
            }

            BtnConvert.IsEnabled = false;
            Task.Factory
            .StartNew(() =>
            {
                Task.WhenAll(BeginWork());
                Dispatcher.Invoke(() => BtnConvert.IsEnabled = true);
            });
        }
 public static void Connect(DevExpress.Xpo.DB.AutoCreateOption autoCreateOption, bool threadSafe = false)
 {
     ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
     if (threadSafe)
     {
         var provider   = XpoDefault.GetConnectionProvider(ConnectionString, autoCreateOption);
         var dictionary = new DevExpress.Xpo.Metadata.ReflectionDictionary();
         dictionary.GetDataStoreSchema(persistentTypes);
         XpoDefault.DataLayer = new ThreadSafeDataLayer(dictionary, provider);
     }
     else
     {
         XpoDefault.DataLayer = XpoDefault.GetDataLayer(ConnectionString, autoCreateOption);
     }
     //UseInMemoryStore = true;
     if (UseInMemoryStore)
     {
         XpoDefault.DataLayer = new SimpleDataLayer(new InMemoryDataStore());
     }
     XpoDefault.Session = null;
 }
示例#21
0
        public static ThreadSafeDataLayer GetThreadSafeDataLayer()
        {
            string ConnectionString = AccessConnectionProvider.GetConnectionString("Web.mdb"); //SQLiteConnectionProvider.GetConnectionString("Web.DB");

            // 加入线程安全
            List<Assembly> dataAssemblies = new List<Assembly>();
            dataAssemblies.Add(typeof(Leo2.Model.Page).Assembly);
            dataAssemblies.Add(typeof(Leo2.Model.Web).Assembly);

            //XpoDefault.ConnectionString = AccessConnectionProvider.GetConnectionString("data.mdb");
            //var dataStore = XpoDefault.GetConnectionProvider(AutoCreateOption.DatabaseAndSchema);

            //var dict = new ReflectionDictionary();
            //dict.CollectClassInfos(dataAssemblies.ToArray());
            //var dataLayer = new ThreadSafeDataLayer(dict, dataStore);

            DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            IDataStore store = XpoDefault.GetConnectionProvider(ConnectionString, AutoCreateOption.SchemaAlreadyExists);
            dict.GetDataStoreSchema(dataAssemblies.ToArray());
            return new ThreadSafeDataLayer(dict, store);
        }
示例#22
0
        void CreateDataLayer()
        {
            TbCmsConnectionStringText = TbCmsConnectionString.Text;
            string conn = TbCmsConnectionStringText;

            //get thread safe klayer
            if (conn != null)
            {
                // Code that runs on application startup
                DevExpress.Xpo.Metadata.XPDictionary dict =
                    new DevExpress.Xpo.Metadata.ReflectionDictionary();
                dict.GetDataStoreSchema(typeof(NewNetServicesModule).Assembly);
                DevExpress.Xpo.DB.IDataStore store =
                    DevExpress.Xpo.XpoDefault
                    .GetConnectionProvider(conn,
                                           DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists);
                store = new DevExpress.Xpo.DB.DataCacheNode(new DevExpress.Xpo.DB.DataCacheRoot(store));
                var layer = new DevExpress.Xpo.ThreadSafeDataLayer(dict, store);
                Tsdl = layer;
            }
        }
示例#23
0
        //[System.Diagnostics.Conditional("XPO")]
        public static void XPOStart()
        {
            try
            {
                //string conString = PostgreSqlConnectionProvider.GetConnectionString("192.168.2.19", 5432, "whm", "whm123", "WHM");
                string conString = PostgreSqlConnectionProvider.GetConnectionString("192.168.1.84", 5432, "postgres", "1", "ors_test");
                DevExpress.Xpo.Metadata.XPDictionary dictionary = new DevExpress.Xpo.Metadata.ReflectionDictionary();
                XpoDefault.DataLayer = XpoDefault.GetDataLayer(conString, AutoCreateOption.DatabaseAndSchema);
                DevExpress.Xpo.XpoDefault.Session = new DevExpress.Xpo.Session(XpoDefault.DataLayer);
                DevExpress.Xpo.Session.DefaultSession.UpdateSchema();
                //DevExpress.Xpo.Helpers.SessionStateStack.SuppressCrossThreadFailuresDetection = true;
                //DevExpress.Xpo.Session.DefaultSession.UpdateSchema();

                //IDataStore store = XpoDefault.GetConnectionProvider(conn, AutoCreateOption.SchemaAlreadyExists);
                //var layer = new ThreadSafeDataLayer(dictionary, store);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                System.Windows.Forms.Application.Exit();
            }
        }
示例#24
0
        public static void InitDatabase()
        {
            // Code that runs on the application startup
            // Specify the connection string, which is used to open a database.
            // It's supposed that you've already created the Comments database within the App_Data folder.
            string conn = DevExpress.Xpo.DB.AccessConnectionProvider.GetConnectionString("Web.mdb");
            DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            // Initialize the XPO dictionary.
            dict.GetDataStoreSchema(typeof(Page).Assembly);
            dict.GetDataStoreSchema(typeof(Web).Assembly);
            DevExpress.Xpo.XpoDefault.Session = null;
            DevExpress.Xpo.DB.IDataStore store = DevExpress.Xpo.XpoDefault.GetConnectionProvider(conn, DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);
            DevExpress.Xpo.XpoDefault.DataLayer = new DevExpress.Xpo.ThreadSafeDataLayer(dict, store);
            DevExpress.Xpo.XpoDefault.Session = new Session(XpoDefault.DataLayer);

            //// 设置当前的数据库联接
            //string ConnectionString = AccessConnectionProvider.GetConnectionString("Web.mdb"); //SQLiteConnectionProvider.GetConnectionString("Web.DB");
            ////XpoDefault.DataLayer = XpoDefault.GetDataLayer(ConnectionString, AutoCreateOption.DatabaseAndSchema);

            //// 加入线程安全
            //List<Assembly> dataAssemblies = new List<Assembly>();
            //dataAssemblies.Add(typeof(Leo2.Model.Page).Assembly);
            //dataAssemblies.Add(typeof(Leo2.Model.Web).Assembly);

            ////XpoDefault.ConnectionString = AccessConnectionProvider.GetConnectionString("data.mdb");
            ////var dataStore = XpoDefault.GetConnectionProvider(AutoCreateOption.DatabaseAndSchema);

            ////var dict = new ReflectionDictionary();
            ////dict.CollectClassInfos(dataAssemblies.ToArray());
            ////var dataLayer = new ThreadSafeDataLayer(dict, dataStore);

            //DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            //IDataStore store = XpoDefault.GetConnectionProvider(ConnectionString, AutoCreateOption.SchemaAlreadyExists);
            //dict.GetDataStoreSchema(dataAssemblies.ToArray());
            //ThreadSafeDataLayer datalayer = new ThreadSafeDataLayer(dict, store);
            //XpoDefault.DataLayer = datalayer;
        }
示例#25
0
        private void btnConvert_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                dbName = TbDb.Text;
                if (!wcTable.Contains(dbName))
                {
                    wcTable                  = dbName + "." + wcTable;
                    oltTable                 = dbName + "." + oltTable;
                    oltPortsTable            = dbName + "." + oltPortsTable;
                    splitterTable            = dbName + "." + splitterTable;
                    splitterPortsTable       = dbName + "." + splitterPortsTable;
                    oltSplitterDpTable       = dbName + "." + oltSplitterDpTable;
                    outdPairsTable           = dbName + "." + outdPairsTable;
                    assignmentPrimlocTable   = dbName + "." + assignmentPrimlocTable;
                    assignmentDPairsTable    = dbName + "." + assignmentDPairsTable;
                    assignmentSplitPortTable = dbName + "." + assignmentSplitPortTable;
                    assignmentOltTable       = dbName + "." + assignmentOltTable;
                    addressTable             = dbName + "." + addressTable;
                    cablesWithOUTSpansTable  = dbName + "." + cablesWithOUTSpansTable;
                    conTable                 = dbName + ".Conduits";
                    CABLEPAIR_Table          = dbName + ".CablePairs";
                    dgroupTable              = dbName + ".DesignationGroups";
                    cpdpTable                = dbName + ".CABLEPAIRDESIGNATIONPAIR";
                    dpTable                  = dbName + ".DesignationPairs";
                    junkTable                = dbName + ".JUNCTIONS";
                    subTable                 = dbName + ".Subscribers";
                }
                tbOracleConnectionStringText = TbOracleConnectionString.Text;
                TbCmsConnectionStringText    = TbCmsConnectionString.Text;
                string conn = TbCmsConnectionStringText;
                //get thread safe klayer
                if (conn != null)
                {
                    // Code that runs on application startup
                    DevExpress.Xpo.Metadata.XPDictionary dict =
                        new DevExpress.Xpo.Metadata.ReflectionDictionary();
                    dict.GetDataStoreSchema(typeof(NewNetServicesModule).Assembly);
                    DevExpress.Xpo.DB.IDataStore store =
                        DevExpress.Xpo.XpoDefault
                        .GetConnectionProvider(conn,
                                               DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists);
                    store = new DevExpress.Xpo.DB.DataCacheNode(new DevExpress.Xpo.DB.DataCacheRoot(store));
                    var layer = new DevExpress.Xpo.ThreadSafeDataLayer(dict, store);
                    Tsdl = layer;
                }
                if (Tsdl == null)
                {
                    //DevExpress.XtraEditors.XtraMessageBox.Show($"Couldn't create dl");
                    return;
                }
                //   MAINWorker.Connect(tsdl);
            }
            catch (Exception ex)
            {
                NewNetServices.Module.Core.StaticHelperMethods.WriteOut($"{ex}");
            }

            using (UnitOfWork uow = new UnitOfWork(Tsdl))
            {
                //using (UnitOfWork uow = MAINWorker.OptimisticLockingReadBehavior = LockingOption)
                //    uow = MAINWorker. LockingOption  STATE = (DefaultFields
                this.state = DefaultFields.GetBusinessObjectDefault <State>(uow,
                                                                            new List <Tuple <string, object> >()
                {
                    new Tuple <string, object>("ShortName", State),
                    new Tuple <string, object>("LongName", (State == "IA" ? "Iowa" : State == "ND"? "North Dakota" :""))
                })
                             .Oid;
            }
            BtnConvert.IsEnabled = false;
            Task.Factory
            .StartNew(() =>
            {
                Task.WhenAll(BeginWork());
                Dispatcher.Invoke(() => BtnConvert.IsEnabled = true);
            });
            //if (ToggleStep.IsChecked.HasValue && ToggleStep.IsChecked.Value)
            //{
            //    Dispatcher.Invoke(() => ProgressBar.Maximum = 0);

            //    WorkBeginning?.Invoke("GID GUID Matching..", null);
            //    HandleStep2<Location>();
            //    HandleStep2<Cable>();
            //}
            //else
            //{
        }