Esempio n. 1
0
 public void Create(IPersistentAssemblyInfo persistentAssemblyInfo, IDataStoreLogonObject dataStoreLogonObject)
 {
     if (persistentAssemblyInfo.PersistentClassInfos.Any())
     {
         var persistentAssemblyDataStoreAttributeInfo = _objectSpace.CreateWCObject <IPersistentAssemblyDataStoreAttributeInfo>();
         persistentAssemblyDataStoreAttributeInfo.DataStoreLogon      = dataStoreLogonObject;
         persistentAssemblyDataStoreAttributeInfo.PersistentClassInfo = persistentAssemblyInfo.PersistentClassInfos[0];
         persistentAssemblyInfo.Attributes.Add(persistentAssemblyDataStoreAttributeInfo);
     }
 }
Esempio n. 2
0
        static Dictionary<string, string> GetParamsDict(IDataStoreLogonObject dataStoreLogonObject) {

            var parameters = new Dictionary<string, string>();
            if (dataStoreLogonObject.UserName != null)
                parameters.Add(ProviderFactory.UserIDParamID, dataStoreLogonObject.UserName);
            if (dataStoreLogonObject.PassWord != null)
                parameters.Add(ProviderFactory.PasswordParamID, dataStoreLogonObject.PassWord);
            parameters.Add(ProviderFactory.ReadOnlyParamID, "1");
            parameters.Add(ProviderFactory.ServerParamID, dataStoreLogonObject.ServerName);
            if (dataStoreLogonObject.DataBase != null)
                parameters.Add(ProviderFactory.DatabaseParamID, dataStoreLogonObject.DataBase.Name);
            parameters.Add(ProviderFactory.UseIntegratedSecurityParamID, (dataStoreLogonObject.Authentication == DataStoreAuthentication.Windows) ? "true" : "false");
            return parameters;

        }
Esempio n. 3
0
 public void Map(Database database, IMapperInfo mapperInfo) {
     var attributeMapper = new AttributeMapper(_objectSpace);
     var tableMapper = new TableMapper(_objectSpace, database, attributeMapper);
     var dataTypeMapper = new DataTypeMapper();
     var columnMapper = new ColumnMapper(dataTypeMapper, attributeMapper);
     Tracing.Tracer.LogSeparator("DBMapper Start mapping database " + database.Name);
     foreach (Table table in database.Tables.OfType<Table>().Where(table => !(table.IsSystemObject))) {
         Tracing.Tracer.LogValue("Table", table.Name);
         IPersistentClassInfo persistentClassInfo = tableMapper.Create(table, _persistentAssemblyInfo, mapperInfo);
         foreach (Column column in table.Columns) {
             columnMapper.Create(column, persistentClassInfo);
         }
     }
     _dataStoreLogonObject = (IDataStoreLogonObject)ReflectionHelper.CreateObject(XafTypesInfo.Instance.FindBussinessObjectType<IDataStoreLogonObject>(), new object[] { _persistentAssemblyInfo.Session, _dataStoreLogonObject });
     attributeMapper.Create(_persistentAssemblyInfo, _dataStoreLogonObject);
     Func<ITemplateInfo, bool> templateInfoPredicate = info => info.Name == ExtraInfoBuilder.SupportPersistentObjectsAsAPartOfACompositeKey;
     CodeEngine.SupportCompositeKeyPersistentObjects(_persistentAssemblyInfo, templateInfoPredicate);
 }
Esempio n. 4
0
        static Dictionary <string, string> GetParamsDict(IDataStoreLogonObject dataStoreLogonObject)
        {
            var parameters = new Dictionary <string, string>();

            if (dataStoreLogonObject.UserName != null)
            {
                parameters.Add(ProviderFactory.UserIDParamID, dataStoreLogonObject.UserName);
            }
            if (dataStoreLogonObject.PassWord != null)
            {
                parameters.Add(ProviderFactory.PasswordParamID, dataStoreLogonObject.PassWord);
            }
            parameters.Add(ProviderFactory.ReadOnlyParamID, "1");
            parameters.Add(ProviderFactory.ServerParamID, dataStoreLogonObject.ServerName);
            if (dataStoreLogonObject.DataBase != null)
            {
                parameters.Add(ProviderFactory.DatabaseParamID, dataStoreLogonObject.DataBase.Name);
            }
            parameters.Add(ProviderFactory.UseIntegratedSecurityParamID, (dataStoreLogonObject.Authentication == DataStoreAuthentication.Windows) ? "true" : "false");
            return(parameters);
        }
Esempio n. 5
0
        public void Map(Database database, IMapperInfo mapperInfo)
        {
            var attributeMapper = new AttributeMapper(_objectSpace);
            var tableMapper     = new TableMapper(_objectSpace, database, attributeMapper);
            var dataTypeMapper  = new DataTypeMapper();
            var columnMapper    = new ColumnMapper(dataTypeMapper, attributeMapper);

            Tracing.Tracer.LogSeparator("DBMapper Start mapping database " + database.Name);
            foreach (Table table in database.Tables.OfType <Table>().Where(table => !(table.IsSystemObject)))
            {
                Tracing.Tracer.LogValue("Table", table.Name);
                IPersistentClassInfo persistentClassInfo = tableMapper.Create(table, _persistentAssemblyInfo, mapperInfo);
                foreach (Column column in table.Columns)
                {
                    columnMapper.Create(column, persistentClassInfo);
                }
            }
            _dataStoreLogonObject = (IDataStoreLogonObject)XafTypesInfo.Instance.FindBussinessObjectType <IDataStoreLogonObject>().CreateInstance(new object[] { _persistentAssemblyInfo.Session, _dataStoreLogonObject });
            attributeMapper.Create(_persistentAssemblyInfo, _dataStoreLogonObject);
            Func <ITemplateInfo, bool> templateInfoPredicate = info => info.Name == ExtraInfoBuilder.SupportPersistentObjectsAsAPartOfACompositeKey;

            CodeEngine.SupportCompositeKeyPersistentObjects(_persistentAssemblyInfo, templateInfoPredicate);
        }
Esempio n. 6
0
 public DbMapper(XPObjectSpace objectSpace, IPersistentAssemblyInfo persistentAssemblyInfo, IDataStoreLogonObject dataStoreLogonObject) {
     _objectSpace = objectSpace;
     _persistentAssemblyInfo = persistentAssemblyInfo;
     _dataStoreLogonObject = dataStoreLogonObject;
 }
Esempio n. 7
0
 public static string GetConnectionString(this IDataStoreLogonObject dataStoreLogonObject)
 {
     return(new MSSqlProviderFactory().GetConnectionString(GetParamsDict(dataStoreLogonObject)));
 }
Esempio n. 8
0
 public void Create(IPersistentAssemblyInfo persistentAssemblyInfo, IDataStoreLogonObject dataStoreLogonObject) {
     if (persistentAssemblyInfo.PersistentClassInfos.Any()) {
         var persistentAssemblyDataStoreAttributeInfo = _objectSpace.CreateWCObject<IPersistentAssemblyDataStoreAttributeInfo>();
         persistentAssemblyDataStoreAttributeInfo.DataStoreLogon = dataStoreLogonObject;
         persistentAssemblyDataStoreAttributeInfo.PersistentClassInfo = persistentAssemblyInfo.PersistentClassInfos[0];
         persistentAssemblyInfo.Attributes.Add(persistentAssemblyDataStoreAttributeInfo);
     }
 }
Esempio n. 9
0
 public DbMapper(XPObjectSpace objectSpace, IPersistentAssemblyInfo persistentAssemblyInfo, IDataStoreLogonObject dataStoreLogonObject)
 {
     _objectSpace            = objectSpace;
     _persistentAssemblyInfo = persistentAssemblyInfo;
     _dataStoreLogonObject   = dataStoreLogonObject;
 }