Example #1
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);
        }
Example #2
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));
        }
Example #3
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;
        }
        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;
        }
Example #5
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);
            });
        }
Example #6
0
        /// <summary>
        /// Registers the IdentityServer stores with the container
        /// If the <paramref name="connectionString"> is passed , a <see name="IDocumentStore"> and <see name="IDocumentSession"> are registered
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="connectionString">A Xpo connectionstring</param>
        /// <returns></returns>
        public static IIdentityServerBuilder AddXpo(
            this IIdentityServerBuilder builder, string connectionString = null, params Assembly[] xpoAssemblys)
        {
            builder.Services.AddTransient <IClientStore, ClientStore>();
            builder.Services.AddTransient <IResourceStore, ResourceStore>();
            builder.Services.AddTransient <ICorsPolicyService, CorsPolicyService>();

            if (!string.IsNullOrEmpty(connectionString))
            {
                builder.Services
                .AddXpoDefaultUnitOfWork(true, options => options
                                         .UseConnectionString(connectionString)
                                         .UseThreadSafeDataLayer(true)
                                                                                                                      //.UseConnectionPool(false) // Remove this line if you use a network database like SQL Server, Oracle, PostgreSql etc.
                                         .UseAutoCreationOption(DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema) // Remove this line if the database already exists
                                                                                                                      //.UseEntityTypes(typeof(Customer), typeof(Order)) // Pass all of your persistent object types to this method.
                                         .UseCustomDictionaryFactory(() =>
                {
                    DevExpress.Xpo.Metadata.XPDictionary dictionary = new ReflectionDictionary();
                    //DevExpress.Xpo.Metadata.ReflectionClassInfo.SuppressSuspiciousMemberInheritanceCheck = true;

                    var assemblys = new List <Assembly>
                    {
                        typeof(ApiResource).Assembly
                    };
                    if (xpoAssemblys != null)
                    {
                        assemblys.AddRange(xpoAssemblys);
                    }
                    dictionary.GetDataStoreSchema(assemblys.ToArray());
                    //DevExpress.Xpo.DB.IDataStore store = DevExpress.Xpo.XpoDefault.GetConnectionProvider(conn, DevExpress.Xpo.DB.AutoCreateOption.SchemaOnly);
                    DevExpress.Xpo.DB.IDataStore store  = DevExpress.Xpo.XpoDefault.GetConnectionProvider(connectionString, DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);
                    DevExpress.Xpo.XpoDefault.DataLayer = new DevExpress.Xpo.ThreadSafeDataLayer(dictionary, store);
                    DevExpress.Xpo.XpoDefault.Session   = new DevExpress.Xpo.Session(DevExpress.Xpo.XpoDefault.DataLayer);
                    return(dictionary);
                })
                                         );
            }

            return(builder);
        }
Example #7
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;
            }
        }
Example #8
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
            //{
        }
Example #9
0
 public CustomCreateDataLayerEventArgs(XPDictionary dictionary, DevExpress.Xpo.DB.IDataStore dataStore)
 {
     Dictionary = dictionary;
     DataStore  = dataStore;
 }