示例#1
0
        public static XS__metadataDB[] Load_fromURI(
            XS__RootMetadata root_ref_in,
            params Uri[] filePath_in
            )
        {
            XS__metadataDB[] _output
                = new XS__metadataDB[filePath_in.Length];

            for (int i = 0; i < filePath_in.Length; i++)
            {
                if (filePath_in[i].IsFile)
                {
                    _output[i] = XS__metadataDB.Load_fromFile(
                        filePath_in[i].LocalPath
                        )[0];
                    // no need! everything's been taken care at: XS__metadataDB.Load_fromFile(...)
                    //_output[i].root_metadatadb_ = ROOT + "." + METADATADB + "[" + i + "]";
                    //_output[i].parent_ref = root_ref_in; // ToDos: now!
                    //if (root_ref_in != null) _output[i].root_ref = root_ref_in;
                }
                else
                {
                    try {
                        _output[i] = (XS__metadataDB) new XmlSerializer(typeof(XS__metadataDB)).Deserialize(
                            OGen.lib.presentationlayer.webforms.utils.ReadURL(
                                filePath_in[i].ToString()
                                )
                            );
                    } catch (Exception _ex) {
                        throw new Exception(string.Format(
                                                "\n---\n{0}.{1}.Load_fromURI():\nERROR READING XML:\n{2}\n---\n{3}",
                                                typeof(XS__metadataDB).Namespace,
                                                typeof(XS__metadataDB).Name,
                                                //(filePath_in[i].IsFile)
                                                //	? filePath_in[i].LocalPath
                                                //	:
                                                filePath_in[i].ToString(),
                                                _ex.Message
                                                ));
                    }
                    _output[i].root_metadatadb_ = ROOT + "." + METADATADB + "[" + i + "]";
                    _output[i].parent_ref       = root_ref_in;               // ToDos: now!
                    if (root_ref_in != null)
                    {
                        _output[i].root_ref = root_ref_in;
                    }
                }
            }

            return(_output);
        }
示例#2
0
		public static XS__metadataDB Load_fromDB(
			XS__metadataDB.Load_fromDBDelegate notifyBack_in, 
			string subAppName_in, 

			params DBConnectionParam[] dbConnectionParam_in
		) {
			return Load_fromDB(
				notifyBack_in, 
				subAppName_in, 

				null,
				0, 

				dbConnectionParam_in
			);
		}
示例#3
0
        public static XS__metadataDB[] Load_fromFile(
            XS__RootMetadata root_ref_in,
            params string[] filePath_in
            )
        {
            FileStream _stream;

            XS__metadataDB[] _output
                = new XS__metadataDB[filePath_in.Length];

            for (int i = 0; i < filePath_in.Length; i++)
            {
                _stream = new FileStream(
                    filePath_in[i],
                    FileMode.Open,
                    FileAccess.Read,
                    FileShare.Read
                    );

                try {
                    _output[i] = (XS__metadataDB) new XmlSerializer(typeof(XS__metadataDB)).Deserialize(
                        _stream
                        );
                    _stream.Close();
#if !NET_1_1
                    _stream.Dispose();
#endif
                } catch (Exception _ex) {
                    throw new Exception(string.Format(
                                            "\n---\n{0}.{1}.Load_fromFile():\nERROR READING XML:\n{2}\n---\n{3}\n---\n{4}\n---\n",
                                            typeof(XS__metadataDB).Namespace,
                                            typeof(XS__metadataDB).Name,
                                            filePath_in[i],
                                            _ex.Message,
                                            _ex.InnerException
                                            ));
                }
                _output[i].root_metadatadb_ = ROOT + "." + METADATADB + "[" + i + "]";

                _output[i].parent_ref = root_ref_in;                 // ToDos: now!
                if (root_ref_in != null)
                {
                    _output[i].root_ref = root_ref_in;
                }
            }
            return(_output);
        }
示例#4
0
		public static XS__metadataDB[] Load_fromFile(
			XS__RootMetadata root_ref_in, 
			params string[] filePath_in
		) {
			FileStream _stream;
			XS__metadataDB[] _output 
				= new XS__metadataDB[filePath_in.Length];

			for (int i = 0; i < filePath_in.Length; i++) {
				_stream = new FileStream(
					filePath_in[i],
					FileMode.Open,
					FileAccess.Read,
					FileShare.Read
				);

				try {
					_output[i] = (XS__metadataDB)new XmlSerializer(typeof(XS__metadataDB)).Deserialize(
						_stream
					);
					_stream.Close();
#if !NET_1_1
					_stream.Dispose();
#endif
				} catch (Exception _ex) {
					throw new Exception(string.Format(
						"\n---\n{0}.{1}.Load_fromFile():\nERROR READING XML:\n{2}\n---\n{3}\n---\n{4}\n---\n",
						typeof(XS__metadataDB).Namespace, 
						typeof(XS__metadataDB).Name, 
						filePath_in[i],
						_ex.Message,
						_ex.InnerException
					));
				}
				_output[i].root_metadatadb_ = ROOT + "." + METADATADB + "[" + i + "]";

				_output[i].parent_ref = root_ref_in; // ToDos: now!
				if (root_ref_in != null) _output[i].root_ref = root_ref_in;
			}
			return _output;
		}
示例#5
0
        public static XS__metadataDB Load_fromDB(
            XS__metadataDB.Load_fromDBDelegate notifyBack_in,
            string subAppName_in,

            XS__RootMetadata root_ref_in,
            int index_in,

            params DBSimpleConnectionstring[] dbConnectionParam_in
            )
        {
            #region XS__metadataDB _output = ...;
            XS__metadataDB _output = new XS__metadataDB();

            _output.root_metadatadb_ = ROOT + "." + METADATADB + "[" + index_in.ToString() + "]";
            _output.parent_ref       = root_ref_in;       // ToDos: now!
            if (root_ref_in != null)
            {
                _output.root_ref = root_ref_in;
            }
            #endregion

            bool                _getTables_exists;
            bool                _getTableFields_exists;
            DBConnection        _connection;
            DBTable[]           _tables_aux;
            DBTableField[]      _fields_aux;
            XS_tableType        _table;
            XS_tableDBType      _tabledb;
            XS_tableFieldType   _field;
            XS_tableFieldDBType _fielddb;
            int          _searchindex;
            const string OGEN_SP0__GETTABLEFIELDS = "OGen_sp0__getTableFields";
            const string OGEN_SP0__GETTABLES      = "OGen_sp0__getTables";

            for (int c = 0; c < dbConnectionParam_in.Length; c++)
            {
                #region notifyBack_in(...);
                if (notifyBack_in != null)
                {
                    notifyBack_in(
                        string.Format(
                            "#{0}/{1} - {2}",
                            c + 1,
                            dbConnectionParam_in.Length,
                            dbConnectionParam_in[c].DBServerType.ToString()
                            ),
                        true
                        );
                }
                #endregion
                _connection = DBConnectionsupport.CreateInstance(
                    dbConnectionParam_in[c].DBServerType,
                    dbConnectionParam_in[c].Connectionstring
                    );

                #region _tables_aux = ...;
                _getTables_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLES);
                _tables_aux       = _connection.getTables(
                    subAppName_in,
                    _getTables_exists
                                                ? OGEN_SP0__GETTABLES
                                                : string.Empty
                    );
                #endregion
                #region _fields_aux = ...;
                switch ((DBServerTypes)Enum.Parse(typeof(DBServerTypes), _connection.DBServerType))
                {
#if PostgreSQL
                case DBServerTypes.PostgreSQL:
                    _getTableFields_exists = _connection.SQLFunction_exists(OGEN_SP0__GETTABLEFIELDS);
                    break;
#endif
                default:
                    _getTableFields_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLEFIELDS);
                    break;
                }

                _fields_aux = _connection.getTableFields(
                    // _tables_aux[t].Name, // get's specific table fields
                    string.Empty,                     // get's fields for all tables
                    _getTableFields_exists
                                                ? OGEN_SP0__GETTABLEFIELDS
                                                : string.Empty
                    );
                #endregion
                for (int t = 0; t < _tables_aux.Length; t++)
                {
                    #region _table = ...; _table.Name = ...;
                    _searchindex = _output.Tables.TableCollection.Search(
                        _tables_aux[t].Name
                        );
                    if (_searchindex >= 0)
                    {
                        _table = _output.Tables.TableCollection[_searchindex];
                    }
                    else
                    {
                        _table = new XS_tableType(
                            _tables_aux[t].Name
                            );
                        _output.Tables.TableCollection.Add(_table);
                    }
                    #endregion
                    _table.isVirtualTable = _tables_aux[t].isVirtualTable;

                    #region _tabledb = ...; _tabledb.DBServerType = ...;
                    _searchindex = _table.TableDBs.TableDBCollection.Search(
                        dbConnectionParam_in[c].DBServerType.ToString()
                        );
                    if (_searchindex >= 0)
                    {
                        _tabledb = _table.TableDBs.TableDBCollection[_searchindex];
                    }
                    else
                    {
                        _tabledb = new XS_tableDBType(
                            dbConnectionParam_in[c].DBServerType.ToString()
                            );
                        _table.TableDBs.TableDBCollection.Add(_tabledb);
                    }
                    #endregion
                    _tabledb.DBTableName   = _tables_aux[t].Name;
                    _tabledb.DBDescription = _tables_aux[t].DBDescription;

                    for (int f = 0; f < _fields_aux.Length; f++)
                    {
                        if (
#if MySQL
                            (
                                (dbConnectionParam_in[c].DBServerType == DBServerTypes.MySQL)
                                &&
                                (_tables_aux[t].Name.ToLower() != _fields_aux[f].TableName.ToLower())
                            )
                            ||
#endif
                            (_tables_aux[t].Name != _fields_aux[f].TableName)
                            )
                        {
                            continue;
                        }

                        #region _field = ...; _field.Name = ...;
                        _searchindex = _table.TableFields.TableFieldCollection.Search(
                            _fields_aux[f].Name
                            );
                        if (_searchindex >= 0)
                        {
                            _field = _table.TableFields.TableFieldCollection[_searchindex];
                        }
                        else
                        {
                            _field = new XS_tableFieldType(
                                _fields_aux[f].Name
                                );
                            _table.TableFields.TableFieldCollection.Add(_field);
                        }
                        #endregion
                        _field.isPK             = _fields_aux[f].isPK;
                        _field.isIdentity       = _fields_aux[f].isIdentity;
                        _field.isNullable       = _fields_aux[f].isNullable;
                        _field.NumericPrecision = _fields_aux[f].Numeric_Precision;
                        _field.NumericScale     = _fields_aux[f].Numeric_Scale;
                        _field.Size             = _fields_aux[f].Size;
#if MySQL
                        if (
                            (dbConnectionParam_in[c].DBServerType == DBServerTypes.MySQL)
                            &&
                            (_field.FKTableName == string.Empty)
                            )
                        {
                            _field.FKTableName = _fields_aux[f].FK_TableName;
                        }
                        else if (
                            (dbConnectionParam_in[c].DBServerType != DBServerTypes.MySQL)
                            )
                        {
                            _field.FKTableName = _fields_aux[f].FK_TableName;
                        }
#else
                        _field.FKTableName = _fields_aux[f].FK_TableName;
#endif
                        _field.FKFieldName = _fields_aux[f].FK_FieldName;

                        #region _fielddb = ...; _fielddb.DBServerType = ...;
                        _searchindex = _field.TableFieldDBs.TableFieldDBCollection.Search(
                            dbConnectionParam_in[c].DBServerType
                            );
                        if (_searchindex >= 0)
                        {
                            _fielddb = _field.TableFieldDBs.TableFieldDBCollection[_searchindex];
                        }
                        else
                        {
                            _fielddb = new XS_tableFieldDBType(
                                dbConnectionParam_in[c].DBServerType.ToString()
                                );
                            _field.TableFieldDBs.TableFieldDBCollection.Add(_fielddb);
                        }
                        #endregion
                        _fielddb.DBType          = _fields_aux[f].DBType_inDB_name;
                        _fielddb.DBDescription   = _fields_aux[f].DBDescription;
                        _fielddb.DBDefaultValue  = _fields_aux[f].DBDefaultValue;
                        _fielddb.DBCollationName = _fields_aux[f].DBCollationName;
                        _fielddb.DBFieldName     = _fields_aux[f].Name;
                    }
                }
            }

            return(_output);
        }
示例#6
0
		public static XS__metadataDB Load_fromDB(
			XS__metadataDB.Load_fromDBDelegate notifyBack_in, 
			string subAppName_in, 

			XS__RootMetadata root_ref_in, 
			int index_in, 

			params DBConnectionParam[] dbConnectionParam_in
		) {
			#region XS__metadataDB _output = ...;
			XS__metadataDB _output = new XS__metadataDB();

			_output.root_metadatadb_ = ROOT + "." + METADATADB + "[" + index_in.ToString() + "]";
			_output.parent_ref = root_ref_in; // ToDos: now!
			if (root_ref_in != null) _output.root_ref = root_ref_in;
			#endregion

			bool _getTables_exists;
			bool _getTableFields_exists;
			DBConnection _connection;
			cDBTable[] _tables_aux;
			cDBTableField[] _fields_aux;
			XS_tableType _table;
			XS_tableDBType _tabledb;
			XS_tableFieldType _field;
			XS_tableFieldDBType _fielddb;
			int _searchindex;
			const string OGEN_SP0__GETTABLEFIELDS = "OGen_sp0__getTableFields";
			const string OGEN_SP0__GETTABLES = "OGen_sp0__getTables";

			for (int c = 0; c < dbConnectionParam_in.Length; c++) {
				#region notifyBack_in(...);
				if (notifyBack_in != null) {
					notifyBack_in(
						string.Format(
							"#{0}/{1} - {2}",
							c + 1,
							dbConnectionParam_in.Length,
							dbConnectionParam_in[c].DBServerType.ToString()
						),
						true
					);
				}
				#endregion
				_connection = DBConnectionsupport.CreateInstance(
					dbConnectionParam_in[c].DBServerType,
					dbConnectionParam_in[c].Connectionstring
				);

				#region _tables_aux = ...;
				_getTables_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLES);
				_tables_aux = _connection.getTables(
					subAppName_in,
					_getTables_exists 
						? OGEN_SP0__GETTABLES
						: string.Empty
				);
				#endregion
				#region _fields_aux = ...;
				_getTableFields_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLEFIELDS);
				_fields_aux = _connection.getTableFields(
					// _tables_aux[t].Name, // get's specific table fields
					string.Empty, // get's fields for all tables
					_getTableFields_exists
						? OGEN_SP0__GETTABLEFIELDS
						: string.Empty
				);
				#endregion
				for (int t = 0; t < _tables_aux.Length; t++) {
					#region _table = ...; _table.Name = ...;
					_searchindex = _output.Tables.TableCollection.Search(
						_tables_aux[t].Name,
						true
					);
					if (_searchindex >= 0) {
						_table = _output.Tables.TableCollection[_searchindex];
					} else {
						_table = new XS_tableType(
							_tables_aux[t].Name
						);
						_output.Tables.TableCollection.Add(_table);
					}
					#endregion
					_table.isVirtualTable = _tables_aux[t].isVirtualTable;

					#region _tabledb = ...; _tabledb.DBServerType = ...;
					_searchindex = _table.TableDBs.TableDBCollection.Search(
						dbConnectionParam_in[c].DBServerType.ToString(),
						true
					);
					if (_searchindex >= 0) {
						_tabledb = _table.TableDBs.TableDBCollection[_searchindex];
					} else {
						_tabledb = new XS_tableDBType(
							dbConnectionParam_in[c].DBServerType.ToString()
						);
						_table.TableDBs.TableDBCollection.Add(_tabledb);
					}
					#endregion
					_tabledb.DBTableName = _tables_aux[t].Name;
					_tabledb.DBDescription = _tables_aux[t].DBDescription;

					for (int f = 0; f < _fields_aux.Length; f++) {
						if (_tables_aux[t].Name != _fields_aux[f].TableName) {
							continue;
						}

						#region _field = ...; _field.Name = ...;
						_searchindex = _table.TableFields.TableFieldCollection.Search(
							_fields_aux[f].Name,
							true
						);
						if (_searchindex >= 0) {
							_field = _table.TableFields.TableFieldCollection[_searchindex];
						} else {
							_field = new XS_tableFieldType(
								_fields_aux[f].Name
							);
							_table.TableFields.TableFieldCollection.Add(_field);
						}
						#endregion
						_field.isPK = _fields_aux[f].isPK;
						_field.isIdentity = _fields_aux[f].isIdentity;
						_field.isNullable = _fields_aux[f].isNullable;
						_field.NumericPrecision = _fields_aux[f].Numeric_Precision;
						_field.NumericScale = _fields_aux[f].Numeric_Scale;
						_field.Size = _fields_aux[f].Size;
						_field.FKTableName = _fields_aux[f].FK_TableName;
						_field.FKFieldName = _fields_aux[f].FK_FieldName;

						#region _fielddb = ...; _fielddb.DBServerType = ...;
						_searchindex = _field.TableFieldDBs.TableFieldDBCollection.Search(
							dbConnectionParam_in[c].DBServerType.ToString(),
							true
						);
						if (_searchindex >= 0) {
							_fielddb = _field.TableFieldDBs.TableFieldDBCollection[_searchindex];
						} else {
							_fielddb = new XS_tableFieldDBType(
								dbConnectionParam_in[c].DBServerType.ToString()
							);
						}
						#endregion
						_fielddb.DBType = _fields_aux[f].DBType_inDB_name;
						_fielddb.DBDescription = _fields_aux[f].DBDescription;
						_fielddb.DBDefaultValue = _fields_aux[f].DBDefaultValue;
						_fielddb.DBCollationName = _fields_aux[f].DBCollationName;
						_fielddb.DBFieldName = _fields_aux[f].Name;
					}
				}
			}

			return _output;
		}
示例#7
0
		public static XS__metadataDB[] Load_fromURI(
			XS__RootMetadata root_ref_in, 
			params Uri[] filePath_in
		) {XS__metadataDB[] _output 
				= new XS__metadataDB[filePath_in.Length];

			for (int i = 0; i < filePath_in.Length; i++) {
				if (filePath_in[i].IsFile) {
					_output[i] = XS__metadataDB.Load_fromFile(
						filePath_in[i].LocalPath
					)[0];
					// no need! everything's been taken care at: XS__metadataDB.Load_fromFile(...)
					//_output[i].root_metadatadb_ = ROOT + "." + METADATADB + "[" + i + "]";
					//_output[i].parent_ref = root_ref_in; // ToDos: now!
					//if (root_ref_in != null) _output[i].root_ref = root_ref_in;
				} else {
					try {
						_output[i] = (XS__metadataDB)new XmlSerializer(typeof(XS__metadataDB)).Deserialize(
							OGen.lib.presentationlayer.webforms.utils.ReadURL(
								filePath_in[i].ToString()
							)
						);
					} catch (Exception _ex) {
						throw new Exception(string.Format(
							"\n---\n{0}.{1}.Load_fromURI():\nERROR READING XML:\n{2}\n---\n{3}",
							typeof(XS__metadataDB).Namespace, 
							typeof(XS__metadataDB).Name, 
							//(filePath_in[i].IsFile)
							//	? filePath_in[i].LocalPath
							//	: 
							filePath_in[i].ToString(),
							_ex.Message
						));
					}
					_output[i].root_metadatadb_ = ROOT + "." + METADATADB + "[" + i + "]";
					_output[i].parent_ref = root_ref_in; // ToDos: now!
					if (root_ref_in != null) _output[i].root_ref = root_ref_in;
				}
			}

			return _output;
		}
		public XS__metadataDBCollection(
		#endif
			XS__metadataDB[] metadatadbcollection_in
		) {
			metadatadbcollection_ = metadatadbcollection_in;
		}
示例#9
0
		public XS__metadataDBCollection(
			XS__metadataDB[] metadatadbcollection_in
		) : base (
			metadatadbcollection_in
		) {
		}