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); }
protected XpoTestsBase() { DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary(); // Initialize the XPO dictionary. dict.GetDataStoreSchema(typeof(BaseClass).Assembly); dict.GetDataStoreSchema(typeof(Customer).Assembly); dict.GetDataStoreSchema(typeof(StockTransaction).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); 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); }
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 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 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)); }
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)); }
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; }
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; }
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; }
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; }
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; }
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; }
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); }
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; }
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; } }
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 //{ }
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; }
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); }