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

            for (int i = 0; i < filePath_in.Length; i++)
            {
                if (filePath_in[i].IsFile)
                {
                    _output[i] = XS__diagram.Load_fromFile(
                        filePath_in[i].LocalPath
                        )[0];
                    // no need! everything's been taken care at: XS__diagram.Load_fromFile(...)
                    //_output[i].root_diagram_ = ROOT + "." + DIAGRAM + "[" + 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__diagram) new XmlSerializer(typeof(XS__diagram)).Deserialize(
                            OGen.Libraries.PresentationLayer.WebForms.Utilities.ReadURL(
                                filePath_in[i].ToString()
                                )
                            );
                    } catch (Exception _ex) {
                        throw new Exception(string.Format(
                                                System.Globalization.CultureInfo.CurrentCulture,
                                                "\n---\n{0}.{1}.Load_fromURI():\nERROR READING XML:\n{2}\n---\n{3}",
                                                typeof(XS__diagram).Namespace,
                                                typeof(XS__diagram).Name,
                                                //(filePath_in[i].IsFile)
                                                //	? filePath_in[i].LocalPath
                                                //	:
                                                filePath_in[i].ToString(),
                                                _ex.Message
                                                ));
                    }
                    _output[i].root_diagram_ = ROOT + "." + DIAGRAM + "[" + i + "]";
                    _output[i].parent_ref    = root_ref_in;                  // ToDos: now!
                    if (root_ref_in != null)
                    {
                        _output[i].root_ref = root_ref_in;
                    }
                }
            }

            return(_output);
        }
Exemple #2
0
        public XS__RootMetadata(
                #endif
            string metadataFilepath_in
            )
        {
            string _metadataPath = System.IO.Path.GetDirectoryName(metadataFilepath_in);

            metadatafiles_ = Metadatas.Load_fromFile(metadataFilepath_in);

            #region int _total_xxx = ...;
            int _total_diagram = 0;
            for (int f = 0; f < metadatafiles_.MetadataFiles.Count; f++)
            {
                switch (metadatafiles_.MetadataFiles[f].XMLFileType)
                {
                case XS__diagram.DIAGRAM:
                    _total_diagram++;
                    break;
                }
            }
            #endregion
            #region string[] _xxxFilepath = new string[_total_xxx];
            string[] _diagramFilepath = new string[
                _total_diagram
                                        ];
            #endregion

            _total_diagram = 0;
            for (int f = 0; f < metadatafiles_.MetadataFiles.Count; f++)
            {
                switch (metadatafiles_.MetadataFiles[f].XMLFileType)
                {
                case XS__diagram.DIAGRAM:
                    _diagramFilepath[_total_diagram] = System.IO.Path.Combine(
                        _metadataPath,
                        metadatafiles_.MetadataFiles[f].XMLFilename
                        );
                    _total_diagram++;
                    break;
                }
            }

            diagramcollection_ = new XS__diagramCollection(
                XS__diagram.Load_fromFile(
                    (XS__RootMetadata)this,
                    _diagramFilepath
                    )
                );
        }
Exemple #3
0
        public static XS__diagram[] Load_fromFile(
            XS__RootMetadata root_ref_in,
            params string[] filePath_in
            )
        {
            FileStream _stream;

            XS__diagram[] _output
                = new XS__diagram[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__diagram) new XmlSerializer(typeof(XS__diagram)).Deserialize(
                        _stream
                        );
                    _stream.Close();
#if !NET_1_1
                    _stream.Dispose();
#endif
                } catch (Exception _ex) {
                    throw new Exception(string.Format(
                                            System.Globalization.CultureInfo.CurrentCulture,
                                            "\n---\n{0}.{1}.Load_fromFile():\nERROR READING XML:\n{2}\n---\n{3}\n---\n{4}\n---\n",
                                            typeof(XS__diagram).Namespace,
                                            typeof(XS__diagram).Name,
                                            filePath_in[i],
                                            _ex.Message,
                                            _ex.InnerException
                                            ));
                }
                _output[i].root_diagram_ = ROOT + "." + DIAGRAM + "[" + i + "]";

                _output[i].parent_ref = root_ref_in;                 // ToDos: now!
                if (root_ref_in != null)
                {
                    _output[i].root_ref = root_ref_in;
                }
            }
            return(_output);
        }
Exemple #4
0
		public static XS__diagram[] Load_fromFile(
			XS__RootMetadata root_ref_in, 
			params string[] filePath_in
		) {
			FileStream _stream;
			XS__diagram[] _output 
				= new XS__diagram[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__diagram)new XmlSerializer(typeof(XS__diagram)).Deserialize(
						_stream
					);
					_stream.Close();
#if !NET_1_1
					_stream.Dispose();
#endif
				} catch (Exception _ex) {
					throw new Exception(string.Format(
						System.Globalization.CultureInfo.CurrentCulture,
						"\n---\n{0}.{1}.Load_fromFile():\nERROR READING XML:\n{2}\n---\n{3}\n---\n{4}\n---\n",
						typeof(XS__diagram).Namespace, 
						typeof(XS__diagram).Name, 
						filePath_in[i],
						_ex.Message,
						_ex.InnerException
					));
				}
				_output[i].root_diagram_ = ROOT + "." + DIAGRAM + "[" + i + "]";

				_output[i].parent_ref = root_ref_in; // ToDos: now!
				if (root_ref_in != null) _output[i].root_ref = root_ref_in;
			}
			return _output;
		}
Exemple #5
0
//		public void New(
//			string applicationPath_in,
//			string documentationName_in,
//			dNotifyBack notifyBack_in
//		) {
//			if (notifyBack_in != null) notifyBack_in("creating...", true);
//			#region DocMetadata _metadata_temp = new DocMetadata(); ...;
//			XS__documentation _metadata_temp = new XS__documentation();
//			_metadata_temp.DocumentationName = documentationName_in;
//			#endregion
//
//			if (notifyBack_in != null) notifyBack_in("- generating xml file", true);
//			#region string _xmlfile = ...;
//			string _xmlfile = string.Format(
//				"{0}{1}OGenDoc-metadatas{1}MD_{2}.OGenDoc-metadata.xml",
//				/*0*/applicationPath_in,
//				/*1*/System.IO.Path.DirectorySeparatorChar,
//				/*2*/documentationName_in
//			);
//			#endregion
//			_metadata_temp.SaveState_toFile(_xmlfile);
//
//			if (notifyBack_in != null) notifyBack_in("... finished!", true);
//			if (notifyBack_in != null) notifyBack_in("", true);
//
//			Open(
//				_xmlfile,
//				true,
//				notifyBack_in
//			);
//		}
        #endregion
        #region public void Open(...);
        public void Open(
            string filename_in,
            bool force_doNOTsave_in,
            dNotifyBack notifyBack_in
            )
        {
            #region Checking...
            if (this.hasChanges)
            {
                if (!force_doNOTsave_in)
                {
                    throw new Exception(string.Format(
                                            "{0}.{1}.Open(): - must save before open",
                                            this.GetType().Namespace,
                                            this.GetType().Name
                                            ));
                }
            }
            #endregion
            filename_ = filename_in;

            if (notifyBack_in != null)
            {
                notifyBack_in("opening...", true);
            }
            if (notifyBack_in != null)
            {
                notifyBack_in("- reading metadata from xml file", true);
            }

            diagram_ = XS__diagram.Load_fromFile(
                filename_
                )[0];
            diagram_.FilePath = filename_;

            if (notifyBack_in != null)
            {
                notifyBack_in("... finished", true);
            }
        }
//		public void New(
//			string applicationPath_in, 
//			string documentationName_in, 
//			dNotifyBack notifyBack_in
//		) {
//			if (notifyBack_in != null) notifyBack_in("creating...", true);
//			#region DocMetadata _metadata_temp = new DocMetadata(); ...;
//			XS__documentation _metadata_temp = new XS__documentation();
//			_metadata_temp.DocumentationName = documentationName_in;
//			#endregion
//
//			if (notifyBack_in != null) notifyBack_in("- generating xml file", true);
//			#region string _xmlfile = ...;
//			string _xmlfile = string.Format(
//				"{0}{1}OGenDoc-metadatas{1}MD_{2}.OGenDoc-metadata.xml", 
//				/*0*/applicationPath_in, 
//				/*1*/System.IO.Path.DirectorySeparatorChar, 
//				/*2*/documentationName_in
//			);
//			#endregion
//			_metadata_temp.SaveState_toFile(_xmlfile);
//
//			if (notifyBack_in != null) notifyBack_in("... finished!", true);
//			if (notifyBack_in != null) notifyBack_in("", true);
//
//			Open(
//				_xmlfile, 
//				true, 
//				notifyBack_in
//			);
//		}
		#endregion
		#region public void Open(...);
		public void Open(
			string filename_in, 
			bool force_doNOTsave_in, 
			dNotifyBack notifyBack_in
		) {
			#region Checking...
			if (this.hasChanges) {
				if (!force_doNOTsave_in) {
					throw new Exception(string.Format(
						"{0}.{1}.Open(): - must save before open", 
						this.GetType().Namespace, 
						this.GetType().Name
					));
				}
			}
			#endregion
			filename_ = filename_in;

			if (notifyBack_in != null) notifyBack_in("opening...", true);
			if (notifyBack_in != null) notifyBack_in("- reading metadata from xml file", true);

			diagram_ = XS__diagram.Load_fromFile(
				filename_
			)[0];
			diagram_.FilePath = filename_;

			if (notifyBack_in != null) notifyBack_in("... finished", true);


			#region more Checking...
			if (notifyBack_in != null) notifyBack_in("checking...", true);

			OGen.lib.datalayer.PostgreSQL.DBUtils_convert_Postgresql _utils_pgsql = new OGen.lib.datalayer.PostgreSQL.DBUtils_convert_Postgresql();
			OGen.lib.datalayer.SQLServer.DBUtils_convert_SQLServer _utils_sqls = new OGen.lib.datalayer.SQLServer.DBUtils_convert_SQLServer();
			Nullable<System.Data.DbType> _dbtype_psql;
			Nullable<System.Data.DbType> _dbtype_sqls;
			bool _isUsingPostgreSQL = false;
			bool _isUsingSQLServer = false;
			DBTableField[] _dbtablefields;
			DBTableField[] _dbtablefields2;
			XS_objectType.FK[] __fks;
			System.Collections.Generic.Dictionary<string, XS_objectType.FK> _fks;
			bool _foundFKTable;
			bool _foundFKField;
			for (int l = 0; l < diagram_.LayerCollection.Count; l++) {
				for (int o = 0; o < diagram_.LayerCollection[l].ObjectCollection.Count; o++) {
					_dbtablefields = diagram_.Table_search(l, o).TableFields();
					diagram_.Table_search(l, o).TableFKs(
						out __fks,
						out _fks
					);

					#region checking for invalid foreign keys
					if (
						_fks.ContainsKey("")
					) {
						throw new Exception(string.Format(
							"invalid foreign key at table: {0}.? -> {1}.?",

							diagram_.Table_search(l, o).TableName,
							_fks[""].FK_TableName
						));
					}
					#endregion

					#region _isUsingPostgreSQL = ...; _isUsingSQLServer = ...;
					for (int f = 0; f < _dbtablefields.Length; f++) {
						if (
							(_dbtablefields[f].PostgreSQLTypeName != null)
							&&
							(_dbtablefields[f].PostgreSQLTypeName.Trim() != "")
						) {
							_isUsingPostgreSQL = true;
						}
						if (
							(_dbtablefields[f].SQLServerTypeName != null)
							&&
							(_dbtablefields[f].SQLServerTypeName.Trim() != "")
						) {
							_isUsingSQLServer = true;
						}
						if (
							_isUsingPostgreSQL
							&&
							_isUsingSQLServer
						) {
							break;
						}
					}
					#endregion

					for (int f = 0; f < _dbtablefields.Length; f++) {
						#region checking if db server type supported
						if (
							!_isUsingPostgreSQL
							&&
							!_isUsingSQLServer
						) {
							throw new Exception(string.Format(
								"no db type defined (should use at least one of the supported db servers: PostgreSQL or SQLServer)",
								_dbtablefields[f].TableName,
								_dbtablefields[f].Name
							));
						}
						#endregion

						#region checking postgresql field type . . .
						_dbtype_psql = null;

						if (
							_isUsingPostgreSQL
						) {
							if (
								(_dbtablefields[f].PostgreSQLTypeName == null)
								||
								(_dbtablefields[f].PostgreSQLTypeName.Trim() == "")
							) {
								throw new Exception(string.Format(
									"invalid table field type - empty postgresql type: {0}.{1}",
									_dbtablefields[f].TableName,
									_dbtablefields[f].Name
								));
							}

							_dbtype_psql = _utils_pgsql.XDbType2DbType(
								_utils_pgsql.XDbType_Parse(
									_dbtablefields[f].PostgreSQLTypeName,
									false
								)
							);
						} 
						#endregion
						#region checking sql server field type . . .
						_dbtype_sqls = null;

						if (
							_isUsingSQLServer
						) {
							if (
								(_dbtablefields[f].SQLServerTypeName == null)
								||
								(_dbtablefields[f].SQLServerTypeName.Trim() == "")
							) {
								throw new Exception(string.Format(
									"invalid table field type - empty sql server type: {0}.{1}",
									_dbtablefields[f].TableName,
									_dbtablefields[f].Name
								));
							}

							_dbtype_sqls = _utils_sqls.XDbType2DbType(
								_utils_sqls.XDbType_Parse(
									_dbtablefields[f].SQLServerTypeName,
									false
								)
							);
						} 
						#endregion

						#region checking if field types match . . .
						if (
							_isUsingPostgreSQL
							&&
							_isUsingSQLServer
						) {
							if (
								(_dbtype_psql == null)
								||
								(_dbtype_sqls == null)
								||
								(
									_dbtype_psql.Value
									!=
									_dbtype_sqls.Value
								)
							) {
								throw new Exception(string.Format(
									"table field types don't match: {0}.{1}",
									_dbtablefields[f].TableName,
									_dbtablefields[f].Name
								));
							}
						} 
						#endregion

						#region //checking FKs . . .
						//if (
						//    (_dbtablefields[f].FK_TableName != null)
						//    &&
						//    (_dbtablefields[f].FK_TableName.Trim() != "")
						//) {
						//    _foundFKTable = false;
						//    _foundFKField = false;
						//    for (int l2 = 0; l2 < diagram_.LayerCollection.Count; l2++) {
						//        for (int o2 = 0; o2 < diagram_.LayerCollection[l2].ObjectCollection.Count; o2++) {
						//            if (
						//                diagram_.Table_search(l2, o2).TableName
						//                ==
						//                _dbtablefields[f].FK_TableName
						//            ) {
						//                _dbtablefields2 = diagram_.Table_search(l2, o2).TableFields();

						//                for (int f2 = 0; f2 < _dbtablefields2.Length; f2++) {
						//                    if (
						//                        _dbtablefields2[f2].Name
						//                        ==
						//                        _dbtablefields[f].FK_FieldName
						//                    ) {

						//                        if (
						//                            _dbtablefields2[f2].PostgreSQLTypeName
						//                            !=
						//                            _dbtablefields[f].PostgreSQLTypeName
						//                        ) {
						//                            throw new Exception(string.Format(
						//                                "foreign key postgresql db type mismatch: {0}.{1}",
						//                                _dbtablefields[f].FK_TableName,
						//                                _dbtablefields[f].FK_FieldName
						//                            ));
						//                        }
						//                        if (
						//                            _dbtablefields2[f2].SQLServerTypeName
						//                            !=
						//                            _dbtablefields[f].SQLServerTypeName
						//                        ) {
						//                            throw new Exception(string.Format(
						//                                "foreign key sql server db type mismatch: {0}.{1}",
						//                                _dbtablefields[f].FK_TableName,
						//                                _dbtablefields[f].FK_FieldName
						//                            ));
						//                        }

						//                        _foundFKField = true;
						//                        break;
						//                    }
						//                }

						//                _foundFKTable = true;
						//                break;
						//            }
						//        }
						//    }

						//    if (!_foundFKTable) {
						//        throw new Exception(string.Format(
						//            "can't find foreign key TABLE: {0}.{1}",
						//            _dbtablefields[f].FK_TableName,
						//            _dbtablefields[f].FK_FieldName
						//        ));
						//    }
						//    if (!_foundFKField) {
						//        throw new Exception(string.Format(
						//            "can't find foreign key FIELD: {0}.{1}",
						//            _dbtablefields[f].FK_TableName,
						//            _dbtablefields[f].FK_FieldName
						//        ));
						//    }
						//}
						#endregion
						#region checking FKs . . .
						if (
							_fks.ContainsKey(
								_dbtablefields[f].Name
							)
						) {
							_foundFKTable = false;
							_foundFKField = false;
							for (int l2 = 0; l2 < diagram_.LayerCollection.Count; l2++) {
							    for (int o2 = 0; o2 < diagram_.LayerCollection[l2].ObjectCollection.Count; o2++) {
									if (
										diagram_.Table_search(l2, o2).TableName
										==
										_fks[_dbtablefields[f].Name].FK_TableName
									) {
										_dbtablefields2 = diagram_.Table_search(l2, o2).TableFields();

										for (int f2 = 0; f2 < _dbtablefields2.Length; f2++) {
											if (
												_dbtablefields2[f2].Name
												==
												_fks[_dbtablefields[f].Name].FK_TableFieldName
											) {

												if (
													(
														(_dbtablefields2[f2].PostgreSQLTypeName == null)
														!=
														(_dbtablefields[f].PostgreSQLTypeName == null)
													)
													||
													(
														//_dbtablefields2[f2].PostgreSQLTypeName
														//!=
														//_dbtablefields[f].PostgreSQLTypeName

														!(
															(_dbtablefields2[f2].PostgreSQLTypeName == _dbtablefields[f].PostgreSQLTypeName)
															||
															(
																(_dbtablefields2[f2].PostgreSQLTypeName == "serial")
																&&
																(_dbtablefields[f].PostgreSQLTypeName == "integer")
															)
															||
															(
																(_dbtablefields[f].PostgreSQLTypeName == "serial")
																&&
																(_dbtablefields2[f2].PostgreSQLTypeName == "integer")
															)
															||
															(
																(_dbtablefields2[f2].PostgreSQLTypeName == "bigserial")
																&&
																(_dbtablefields[f].PostgreSQLTypeName == "bigint")
															)
															||
															(
																(_dbtablefields[f].PostgreSQLTypeName == "bigserial")
																&&
																(_dbtablefields2[f2].PostgreSQLTypeName == "bigint")
															)
														)
													)
												) {
													throw new Exception(string.Format(
														"foreign key postgresql db type mismatch: {0}.{1} -> {2}.{3}",

														diagram_.Table_search(l, o).TableName,
														_dbtablefields[f].Name,

														_fks[_dbtablefields[f].Name].FK_TableName,
														_fks[_dbtablefields[f].Name].FK_TableFieldName
													));
												}
												if (
													(
														(_dbtablefields2[f2].SQLServerTypeName == null)
														!=
														(_dbtablefields[f].SQLServerTypeName == null)
													)
													||
													(
														_dbtablefields2[f2].SQLServerTypeName
														!=
														_dbtablefields[f].SQLServerTypeName
													)
												) {
													throw new Exception(string.Format(
														"foreign key sql server db type mismatch: {0}.{1} -> {2}.{3}",

														diagram_.Table_search(l, o).TableName,
														_dbtablefields[f].Name,

														_fks[_dbtablefields[f].Name].FK_TableName,
														_fks[_dbtablefields[f].Name].FK_TableFieldName
													));
												}

												_foundFKField = true;
												break;
											}
										}

										_foundFKTable = true;
										break;
							        }
							    }
							}

							if (!_foundFKTable) {
								throw new Exception(string.Format(
									"can't find foreign key TABLE: {0}.{1} -> {2}.{3}",

									diagram_.Table_search(l, o).TableName,
									_dbtablefields[f].Name,

									_fks[_dbtablefields[f].Name].FK_TableName,
									_fks[_dbtablefields[f].Name].FK_TableFieldName
								));
							}
							if (!_foundFKField) {
								throw new Exception(string.Format(
									"can't find foreign key FIELD: {0}.{1} -> {2}.{3}",

									diagram_.Table_search(l, o).TableName,
									_dbtablefields[f].Name,

									_fks[_dbtablefields[f].Name].FK_TableName,
									_fks[_dbtablefields[f].Name].FK_TableFieldName
								));
							}
						}
						#endregion
					}
				}
			}

			if (notifyBack_in != null) notifyBack_in("... finished", true);
			#endregion
		}
Exemple #7
0
        //#endregion

        #region public Methods...
        #region         //public void New(...);
//		public void New(
//			string applicationPath_in,
//			string documentationName_in,
//			dNotifyBack notifyBack_in
//		) {
//			if (notifyBack_in != null) notifyBack_in("creating...", true);
//			#region DocMetadata _metadata_temp = new DocMetadata(); ...;
//			XS__documentation _metadata_temp = new XS__documentation();
//			_metadata_temp.DocumentationName = documentationName_in;
//			#endregion
//
//			if (notifyBack_in != null) notifyBack_in("- generating xml file", true);
//			#region string _xmlfile = ...;
//			string _xmlfile = string.Format(
//              System.Globalization.CultureInfo.CurrentCulture,
//				"{0}{1}OGenDoc-metadatas{1}MD_{2}.OGenDoc-metadata.xml",
//				/*0*/applicationPath_in,
//				/*1*/System.IO.Path.DirectorySeparatorChar,
//				/*2*/documentationName_in
//			);
//			#endregion
//			_metadata_temp.SaveState_toFile(_xmlfile);
//
//			if (notifyBack_in != null) notifyBack_in("... finished!", true);
//			if (notifyBack_in != null) notifyBack_in("", true);
//
//			Open(
//				_xmlfile,
//				true,
//				notifyBack_in
//			);
//		}
        #endregion
        #region public void Open(...);
        public void Open(
            string fileName_in,
            bool force_doNOTSave_in,
            OGen.Dia.Libraries.Generator.NotifyBack notifyBack_in
            )
        {
            #region Checking...
            if (this.HasChanges)
            {
                if (!force_doNOTSave_in)
                {
                    throw new Exception(string.Format(
                                            System.Globalization.CultureInfo.CurrentCulture,
                                            "{0}.{1}.Open(): - must save before open",
                                            this.GetType().Namespace,
                                            this.GetType().Name
                                            ));
                }
            }
            #endregion
            this.filename_ = fileName_in;

            if (notifyBack_in != null)
            {
                notifyBack_in("opening...", true);
            }
            if (notifyBack_in != null)
            {
                notifyBack_in("- reading metadata from xml file", true);
            }

            this.diagram_ = XS__diagram.Load_fromFile(
                this.filename_
                )[0];
            this.diagram_.FilePath = this.filename_;

            if (notifyBack_in != null)
            {
                notifyBack_in("... finished", true);
            }


            #region more Checking...
            if (notifyBack_in != null)
            {
                notifyBack_in("checking...", true);
            }

            OGen.Libraries.DataLayer.PostgreSQL.DBUtilities_convert_Postgresql _utilities_pgsql = new OGen.Libraries.DataLayer.PostgreSQL.DBUtilities_convert_Postgresql();
            OGen.Libraries.DataLayer.SQLServer.DBUtilities_convert_SQLServer   _utilities_sqls  = new OGen.Libraries.DataLayer.SQLServer.DBUtilities_convert_SQLServer();
            System.Data.DbType?_dbtype_psql;
            System.Data.DbType?_dbtype_sqls;
            bool           _isUsingPostgreSQL = false;
            bool           _isUsingSQLServer  = false;
            DBTableField[] _dbtablefields;
            DBTableField[] _dbtablefields2;
            OGen.Dia.Libraries.Metadata.Diagram.ForeignKey[] __fks;
            System.Collections.Generic.Dictionary <string, OGen.Dia.Libraries.Metadata.Diagram.ForeignKey> _fks;
            bool _foundFKTable;
            bool _foundFKField;
            for (int l = 0; l < this.diagram_.LayerCollection.Count; l++)
            {
                for (int o = 0; o < this.diagram_.LayerCollection[l].ObjectCollection.Count; o++)
                {
                    _dbtablefields = this.diagram_.Table_search(l, o).TableFields();
                    this.diagram_.Table_search(l, o).TableForeignKeys(
                        out __fks,
                        out _fks
                        );

                    #region checking for invalid foreign keys
                    if (
                        _fks.ContainsKey("")
                        )
                    {
                        throw new Exception(string.Format(
                                                System.Globalization.CultureInfo.CurrentCulture,
                                                "invalid foreign key at table: {0}.? -> {1}.?",

                                                this.diagram_.Table_search(l, o).TableName,
                                                _fks[""].ForeignKey_TableName
                                                ));
                    }
                    #endregion

                    #region _isUsingPostgreSQL = ...; _isUsingSQLServer = ...;
                    for (int f = 0; f < _dbtablefields.Length; f++)
                    {
                        if (!string.IsNullOrEmpty(_dbtablefields[f].PostgreSQLTypeName))
                        {
                            _isUsingPostgreSQL = true;
                        }
                        if (!string.IsNullOrEmpty(_dbtablefields[f].SQLServerTypeName))
                        {
                            _isUsingSQLServer = true;
                        }
                        if (
                            _isUsingPostgreSQL
                            &&
                            _isUsingSQLServer
                            )
                        {
                            break;
                        }
                    }
                    #endregion

                    for (int f = 0; f < _dbtablefields.Length; f++)
                    {
                        #region checking if db server type supported
                        if (
                            !_isUsingPostgreSQL
                            &&
                            !_isUsingSQLServer
                            )
                        {
                            throw new Exception(string.Format(
                                                    System.Globalization.CultureInfo.CurrentCulture,
                                                    "no db type defined (should use at least one of the supported db servers: PostgreSQL or SQLServer)",
                                                    _dbtablefields[f].TableName,
                                                    _dbtablefields[f].Name
                                                    ));
                        }
                        #endregion

                        #region checking postgresql field type . . .
                        _dbtype_psql = null;

                        if (
                            _isUsingPostgreSQL
                            )
                        {
                            if (string.IsNullOrEmpty(_dbtablefields[f].PostgreSQLTypeName))
                            {
                                throw new Exception(string.Format(
                                                        System.Globalization.CultureInfo.CurrentCulture,
                                                        "invalid table field type - empty postgresql type: {0}.{1}",
                                                        _dbtablefields[f].TableName,
                                                        _dbtablefields[f].Name
                                                        ));
                            }

                            _dbtype_psql = _utilities_pgsql.XDbType2DbType(
                                _utilities_pgsql.XDbType_Parse(
                                    _dbtablefields[f].PostgreSQLTypeName,
                                    false
                                    )
                                );
                        }
                        #endregion
                        #region checking sql server field type . . .
                        _dbtype_sqls = null;

                        if (
                            _isUsingSQLServer
                            )
                        {
                            if (string.IsNullOrEmpty(_dbtablefields[f].SQLServerTypeName))
                            {
                                throw new Exception(string.Format(
                                                        System.Globalization.CultureInfo.CurrentCulture,
                                                        "invalid table field type - empty sql server type: {0}.{1}",
                                                        _dbtablefields[f].TableName,
                                                        _dbtablefields[f].Name
                                                        ));
                            }

                            _dbtype_sqls = _utilities_sqls.XDbType2DbType(
                                _utilities_sqls.XDbType_Parse(
                                    _dbtablefields[f].SQLServerTypeName,
                                    false
                                    )
                                );
                        }
                        #endregion

                        #region checking if field types match . . .
                        if (
                            _isUsingPostgreSQL
                            &&
                            _isUsingSQLServer
                            )
                        {
                            if (
                                (_dbtype_psql == null)
                                ||
                                (_dbtype_sqls == null)
                                ||
                                (
                                    _dbtype_psql.Value
                                    !=
                                    _dbtype_sqls.Value
                                )
                                )
                            {
                                throw new Exception(string.Format(
                                                        System.Globalization.CultureInfo.CurrentCulture,
                                                        "table field types don't match: {0}.{1}",
                                                        _dbtablefields[f].TableName,
                                                        _dbtablefields[f].Name
                                                        ));
                            }
                        }
                        #endregion

                        #region                         //checking FKs . . .
                        //if (
                        //    (_dbtablefields[f].ForeignKey_TableName != null)
                        //    &&
                        //    (_dbtablefields[f].ForeignKey_TableName.Trim() != "")
                        //) {
                        //    _foundFKTable = false;
                        //    _foundFKField = false;
                        //    for (int l2 = 0; l2 < diagram_.LayerCollection.Count; l2++) {
                        //        for (int o2 = 0; o2 < diagram_.LayerCollection[l2].ObjectCollection.Count; o2++) {
                        //            if (
                        //                diagram_.Table_search(l2, o2).TableName
                        //                ==
                        //                _dbtablefields[f].ForeignKey_TableName
                        //            ) {
                        //                _dbtablefields2 = diagram_.Table_search(l2, o2).TableFields();

                        //                for (int f2 = 0; f2 < _dbtablefields2.Length; f2++) {
                        //                    if (
                        //                        _dbtablefields2[f2].Name
                        //                        ==
                        //                        _dbtablefields[f].ForeignKey_TableFieldName
                        //                    ) {

                        //                        if (
                        //                            _dbtablefields2[f2].PostgreSQLTypeName
                        //                            !=
                        //                            _dbtablefields[f].PostgreSQLTypeName
                        //                        ) {
                        //                            throw new Exception(string.Format(
                        //                                System.Globalization.CultureInfo.CurrentCulture,
                        //                                "foreign key postgresql db type mismatch: {0}.{1}",
                        //                                _dbtablefields[f].ForeignKey_TableName,
                        //                                _dbtablefields[f].ForeignKey_TableFieldName
                        //                            ));
                        //                        }
                        //                        if (
                        //                            _dbtablefields2[f2].SQLServerTypeName
                        //                            !=
                        //                            _dbtablefields[f].SQLServerTypeName
                        //                        ) {
                        //                            throw new Exception(string.Format(
                        //                                System.Globalization.CultureInfo.CurrentCulture,
                        //                                "foreign key sql server db type mismatch: {0}.{1}",
                        //                                _dbtablefields[f].ForeignKey_TableName,
                        //                                _dbtablefields[f].ForeignKey_TableFieldName
                        //                            ));
                        //                        }

                        //                        _foundFKField = true;
                        //                        break;
                        //                    }
                        //                }

                        //                _foundFKTable = true;
                        //                break;
                        //            }
                        //        }
                        //    }

                        //    if (!_foundFKTable) {
                        //        throw new Exception(string.Format(
                        //            System.Globalization.CultureInfo.CurrentCulture,
                        //            "can't find foreign key TABLE: {0}.{1}",
                        //            _dbtablefields[f].ForeignKey_TableName,
                        //            _dbtablefields[f].ForeignKey_TableFieldName
                        //        ));
                        //    }
                        //    if (!_foundFKField) {
                        //        throw new Exception(string.Format(
                        //            System.Globalization.CultureInfo.CurrentCulture,
                        //            "can't find foreign key FIELD: {0}.{1}",
                        //            _dbtablefields[f].ForeignKey_TableName,
                        //            _dbtablefields[f].ForeignKey_TableFieldName
                        //        ));
                        //    }
                        //}
                        #endregion
                        #region checking FKs . . .
                        if (
                            _fks.ContainsKey(
                                _dbtablefields[f].Name
                                )
                            )
                        {
                            _foundFKTable = false;
                            _foundFKField = false;
                            for (int l2 = 0; l2 < this.diagram_.LayerCollection.Count; l2++)
                            {
                                for (int o2 = 0; o2 < this.diagram_.LayerCollection[l2].ObjectCollection.Count; o2++)
                                {
                                    if (
                                        this.diagram_.Table_search(l2, o2).TableName
                                        ==
                                        _fks[_dbtablefields[f].Name].ForeignKey_TableName
                                        )
                                    {
                                        _dbtablefields2 = this.diagram_.Table_search(l2, o2).TableFields();

                                        for (int f2 = 0; f2 < _dbtablefields2.Length; f2++)
                                        {
                                            if (
                                                _dbtablefields2[f2].Name
                                                ==
                                                _fks[_dbtablefields[f].Name].ForeignKey_TableFieldName
                                                )
                                            {
                                                if (
                                                    (
                                                        (_dbtablefields2[f2].PostgreSQLTypeName == null)
                                                        !=
                                                        (_dbtablefields[f].PostgreSQLTypeName == null)
                                                    )
                                                    ||
                                                    (
                                                        //_dbtablefields2[f2].PostgreSQLTypeName
                                                        //!=
                                                        //_dbtablefields[f].PostgreSQLTypeName

                                                        !(
                                                            (_dbtablefields2[f2].PostgreSQLTypeName == _dbtablefields[f].PostgreSQLTypeName)
                                                            ||
                                                            (
                                                                (_dbtablefields2[f2].PostgreSQLTypeName == "serial")
                                                                &&
                                                                (_dbtablefields[f].PostgreSQLTypeName == "integer")
                                                            )
                                                            ||
                                                            (
                                                                (_dbtablefields[f].PostgreSQLTypeName == "serial")
                                                                &&
                                                                (_dbtablefields2[f2].PostgreSQLTypeName == "integer")
                                                            )
                                                            ||
                                                            (
                                                                (_dbtablefields2[f2].PostgreSQLTypeName == "bigserial")
                                                                &&
                                                                (_dbtablefields[f].PostgreSQLTypeName == "bigint")
                                                            )
                                                            ||
                                                            (
                                                                (_dbtablefields[f].PostgreSQLTypeName == "bigserial")
                                                                &&
                                                                (_dbtablefields2[f2].PostgreSQLTypeName == "bigint")
                                                            )
                                                            )
                                                    )
                                                    )
                                                {
                                                    throw new Exception(string.Format(
                                                                            System.Globalization.CultureInfo.CurrentCulture,
                                                                            "foreign key postgresql db type mismatch: {0}.{1} -> {2}.{3}",

                                                                            this.diagram_.Table_search(l, o).TableName,
                                                                            _dbtablefields[f].Name,

                                                                            _fks[_dbtablefields[f].Name].ForeignKey_TableName,
                                                                            _fks[_dbtablefields[f].Name].ForeignKey_TableFieldName
                                                                            ));
                                                }
                                                if (
                                                    (
                                                        (_dbtablefields2[f2].SQLServerTypeName == null)
                                                        !=
                                                        (_dbtablefields[f].SQLServerTypeName == null)
                                                    )
                                                    ||
                                                    (
                                                        _dbtablefields2[f2].SQLServerTypeName
                                                        !=
                                                        _dbtablefields[f].SQLServerTypeName
                                                    )
                                                    )
                                                {
                                                    throw new Exception(string.Format(
                                                                            System.Globalization.CultureInfo.CurrentCulture,
                                                                            "foreign key sql server db type mismatch: {0}.{1} -> {2}.{3}",

                                                                            this.diagram_.Table_search(l, o).TableName,
                                                                            _dbtablefields[f].Name,

                                                                            _fks[_dbtablefields[f].Name].ForeignKey_TableName,
                                                                            _fks[_dbtablefields[f].Name].ForeignKey_TableFieldName
                                                                            ));
                                                }

                                                _foundFKField = true;
                                                break;
                                            }
                                        }

                                        _foundFKTable = true;
                                        break;
                                    }
                                }
                            }

                            if (!_foundFKTable)
                            {
                                throw new Exception(string.Format(
                                                        System.Globalization.CultureInfo.CurrentCulture,
                                                        "can't find foreign key TABLE: {0}.{1} -> {2}.{3}",

                                                        this.diagram_.Table_search(l, o).TableName,
                                                        _dbtablefields[f].Name,

                                                        _fks[_dbtablefields[f].Name].ForeignKey_TableName,
                                                        _fks[_dbtablefields[f].Name].ForeignKey_TableFieldName
                                                        ));
                            }
                            if (!_foundFKField)
                            {
                                throw new Exception(string.Format(
                                                        System.Globalization.CultureInfo.CurrentCulture,
                                                        "can't find foreign key FIELD: {0}.{1} -> {2}.{3}",

                                                        this.diagram_.Table_search(l, o).TableName,
                                                        _dbtablefields[f].Name,

                                                        _fks[_dbtablefields[f].Name].ForeignKey_TableName,
                                                        _fks[_dbtablefields[f].Name].ForeignKey_TableFieldName
                                                        ));
                            }
                        }
                        #endregion
                    }
                }
            }

            if (notifyBack_in != null)
            {
                notifyBack_in("... finished", true);
            }
            #endregion
        }
Exemple #8
0
        public FK[] TableFKs()
        {
            System.Collections.Generic.List <FK> _output
                = new System.Collections.Generic.List <FK>();

            XS_objectType _table_a;
            string        _tableName_a;
            string        _tableFieldName_a;

            XS_objectType _table_b;
            string        _tableName_b;
            string        _tableFieldName_b;

            string _direction;

            XS_objectTypeCollection _objecttypecollection = (XS_objectTypeCollection)this.parent_ref;
            XS_layerType            _layertype            = (XS_layerType)_objecttypecollection.parent_ref;
            XS_layerTypeCollection  _layertypecollection  = (XS_layerTypeCollection)_layertype.parent_ref;
            XS__diagram             _root_ref             = (XS__diagram)_layertypecollection.parent_ref;

            for (int l = 0; l < _root_ref.LayerCollection.Count; l++)
            {
                for (int o = 0; o < _root_ref.LayerCollection[l].ObjectCollection.Count; o++)
                {
                    switch (_root_ref.LayerCollection[l].ObjectCollection[o].Type)
                    {
                    case "UML - Association":
                        if (_root_ref.LayerCollection[l].ObjectCollection[o].Connections.ConnectionCollection.Count != 2)
                        {
                            break;
                        }

                        _table_a          = null;
                        _tableName_a      = "";
                        _tableFieldName_a = "";

                        _table_b          = null;
                        _tableName_b      = "";
                        _tableFieldName_b = "";

                        _direction = "";

                        for (int a = 0; a < _root_ref.LayerCollection[l].ObjectCollection[o].AttributeCollection.Count; a++)
                        {
                            switch (_root_ref.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].Name)
                            {
                            case "direction":
                                _direction = _root_ref.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].Enum.Val;
                                break;

                            case "role_a":
                                _table_a = _root_ref.Table_search(
                                    _root_ref.LayerCollection[l].ObjectCollection[o].Connections.ConnectionCollection[0].To
                                    );
                                _tableName_a      = _table_a.TableName;
                                _tableFieldName_a = _root_ref.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].String.Replace("#", "");
                                break;

                            case "role_b":
                                _table_b = _root_ref.Table_search(
                                    _root_ref.LayerCollection[l].ObjectCollection[o].Connections.ConnectionCollection[1].To
                                    );
                                _tableName_b      = _table_b.TableName;
                                _tableFieldName_b = _root_ref.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].String.Replace("#", "");
                                break;
                            }
                        }

                        if (
                            (_table_a == this)
                            &&
                            (_direction == "2")
                            )
                        {
                            _output.Add(new FK(
                                            _tableFieldName_a,
                                            _tableName_b,
                                            _tableFieldName_b
                                            ));
                        }
                        if (
                            (_table_b == this)
                            &&
                            (_direction == "1")
                            )
                        {
                            _output.Add(new FK(
                                            _tableFieldName_b,
                                            _tableName_a,
                                            _tableFieldName_a
                                            ));
                        }
                        break;
                    }
                }
            }

            return(_output.ToArray());
        }
		public XS0__diagramCollection(
			XS__diagram[] diagramcollection_in
		) : base (
			diagramcollection_in
		) {
		}
		public XS__diagramCollection(
		#endif
			XS__diagram[] diagramCollection_in
		) {
			this.diagramcollection_ = diagramCollection_in;
		}
Exemple #11
0
		public static XS__diagram[] Load_fromURI(
			XS__RootMetadata root_ref_in, 
			params Uri[] filePath_in
		) {
			XS__diagram[] _output 
				= new XS__diagram[filePath_in.Length];

			for (int i = 0; i < filePath_in.Length; i++) {
				if (filePath_in[i].IsFile) {
					_output[i] = XS__diagram.Load_fromFile(
						filePath_in[i].LocalPath
					)[0];
					// no need! everything's been taken care at: XS__diagram.Load_fromFile(...)
					//_output[i].root_diagram_ = ROOT + "." + DIAGRAM + "[" + 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__diagram)new XmlSerializer(typeof(XS__diagram)).Deserialize(
							OGen.Libraries.PresentationLayer.WebForms.Utilities.ReadURL(
								filePath_in[i].ToString()
							)
						);
					} catch (Exception _ex) {
						throw new Exception(string.Format(
							System.Globalization.CultureInfo.CurrentCulture,
							"\n---\n{0}.{1}.Load_fromURI():\nERROR READING XML:\n{2}\n---\n{3}",
							typeof(XS__diagram).Namespace, 
							typeof(XS__diagram).Name, 
							//(filePath_in[i].IsFile)
							//	? filePath_in[i].LocalPath
							//	: 
							filePath_in[i].ToString(),
							_ex.Message
						));
					}
					_output[i].root_diagram_ = ROOT + "." + DIAGRAM + "[" + i + "]";
					_output[i].parent_ref = root_ref_in; // ToDos: now!
					if (root_ref_in != null) _output[i].root_ref = root_ref_in;
				}
			}

			return _output;
		}
Exemple #12
0
        public void TableForeignKeys(
            out OGen.Dia.Libraries.Metadata.Diagram.ForeignKey[] foreignKeys_out,
            out System.Collections.Generic.Dictionary <string, OGen.Dia.Libraries.Metadata.Diagram.ForeignKey> foreignKeys_dic_out
            )
        {
            System.Collections.Generic.List <OGen.Dia.Libraries.Metadata.Diagram.ForeignKey> _output
                = new System.Collections.Generic.List <OGen.Dia.Libraries.Metadata.Diagram.ForeignKey>();
            System.Collections.Generic.Dictionary <string, OGen.Dia.Libraries.Metadata.Diagram.ForeignKey> _output2
                = new System.Collections.Generic.Dictionary <string, OGen.Dia.Libraries.Metadata.Diagram.ForeignKey>();

            XS_objectType _table_a;
            string        _tableName_a;
            string        _tableFieldName_a;

            XS_objectType _table_b;
            string        _tableName_b;
            string        _tableFieldName_b;

            string _direction;

            XS_objectTypeCollection _objecttypecollection = (XS_objectTypeCollection)this.parent_ref;
            XS_layerType            _layertype            = (XS_layerType)_objecttypecollection.parent_ref;
            XS_layerTypeCollection  _layertypecollection  = (XS_layerTypeCollection)_layertype.parent_ref;
            XS__diagram             _root_ref             = (XS__diagram)_layertypecollection.parent_ref;

            OGen.Dia.Libraries.Metadata.Diagram.ForeignKey _aux;

            for (int l = 0; l < _root_ref.LayerCollection.Count; l++)
            {
                for (int o = 0; o < _root_ref.LayerCollection[l].ObjectCollection.Count; o++)
                {
                    switch (_root_ref.LayerCollection[l].ObjectCollection[o].Type)
                    {
                    case "UML - Association":
                        if (_root_ref.LayerCollection[l].ObjectCollection[o].Connections.ConnectionCollection.Count != 2)
                        {
                            break;
                        }

                        _table_a          = null;
                        _tableName_a      = "";
                        _tableFieldName_a = "";

                        _table_b          = null;
                        _tableName_b      = "";
                        _tableFieldName_b = "";

                        _direction = "";

                        for (int a = 0; a < _root_ref.LayerCollection[l].ObjectCollection[o].AttributeCollection.Count; a++)
                        {
                            switch (_root_ref.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].Name)
                            {
                            case "direction":
                                _direction = _root_ref.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].Enum.Value;
                                break;

                            case "role_a":
                                _table_a = _root_ref.Table_search(
                                    _root_ref.LayerCollection[l].ObjectCollection[o].Connections.ConnectionCollection[0].To
                                    );
                                _tableName_a      = _table_a.TableName;
                                _tableFieldName_a = _root_ref.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].String.Replace("#", "");
                                break;

                            case "role_b":
                                _table_b = _root_ref.Table_search(
                                    _root_ref.LayerCollection[l].ObjectCollection[o].Connections.ConnectionCollection[1].To
                                    );
                                _tableName_b      = _table_b.TableName;
                                _tableFieldName_b = _root_ref.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].String.Replace("#", "");
                                break;
                            }
                        }

                        if (
                            (_table_a == this)
                            &&
                            (_direction == "1")
                            )
                        {
                            _output2.Add(
                                _tableFieldName_a,
                                _aux = new OGen.Dia.Libraries.Metadata.Diagram.ForeignKey(
                                    _tableFieldName_a,
                                    _tableName_b,
                                    _tableFieldName_b
                                    )
                                );
                            _output.Add(_aux);
                        }
                        if (
                            (_table_b == this)
                            &&
                            (_direction == "2")
                            )
                        {
                            _output2.Add(
                                _tableFieldName_b,
                                _aux = new OGen.Dia.Libraries.Metadata.Diagram.ForeignKey(
                                    _tableFieldName_b,
                                    _tableName_a,
                                    _tableFieldName_a
                                    )
                                );
                            _output.Add(_aux);
                        }
                        break;
                    }
                }
            }

            foreignKeys_dic_out = _output2;
            foreignKeys_out     = _output.ToArray();

            //return _output.ToArray();
        }
Exemple #13
0
        static void Main(string[] args)
        {
            XS__diagram _dia = XS__diagram.Load_fromFile(
                @"X:\test\modeloDados.dia"
                )[0];

            for (int l = 0; l < _dia.LayerCollection.Count; l++)
            {
                for (int o = 0; o < _dia.LayerCollection[l].ObjectCollection.Count; o++)
                {
                    switch (_dia.LayerCollection[l].ObjectCollection[o].Type)
                    {
                    case "Database - Table":
                        for (int a = 0; a < _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection.Count; a++)
                        {
                            switch (_dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].Name)
                            {
                            case "name":
                                Console.WriteLine(
                                    "table-name: {0} ('{1}')",
                                    _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].String,
                                    _dia.LayerCollection[l].ObjectCollection[o].Id
                                    );
                                break;

                            case "comment":
                                Console.WriteLine("table-comments: {0}", _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].String);
                                break;

                            case "attributes":
                                for (int c = 0; c < _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].CompositeCollection.Count; c++)
                                {
                                    switch (_dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].CompositeCollection[c].Type)
                                    {
                                    case "table_attribute":
                                        for (int aa = 0; aa < _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].CompositeCollection[c].AttributeCollection.Count; aa++)
                                        {
                                            switch (_dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Name)
                                            {
                                            case "name":
                                                Console.WriteLine("\tfield-name: {0}", _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].String);
                                                break;

                                            case "type":
                                                Console.WriteLine("\tfield-type: {0}", _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].String);
                                                break;

                                            case "comment":
                                                Console.WriteLine("\tfield-comments: {0}", _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].String);
                                                break;

                                            case "primary_key":
                                                Console.WriteLine("\tfield-pk: {0}", _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Boolean.Val);
                                                break;

                                            case "nullable":
                                                Console.WriteLine("\tfield-nullable: {0}", _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Boolean.Val);
                                                break;

                                            case "unique":
                                                Console.WriteLine("\tfield-unique: {0}", _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].CompositeCollection[c].AttributeCollection[aa].Boolean.Val);
                                                break;

                                            default:
                                                break;
                                            }
                                        }
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                        break;

                    case "UML - Association":
                        if (_dia.LayerCollection[l].ObjectCollection[o].Connections.ConnectionCollection.Count != 2)
                        {
                            break;
                        }

                        for (int a = 0; a < _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection.Count; a++)
                        {
                            switch (_dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].Name)
                            {
                            case "role_a":
                                Console.WriteLine(
                                    "ROLE_A: {0}.{1}",
                                    _dia.LayerCollection[l].ObjectCollection[o].Connections.ConnectionCollection[0].To,
                                    _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].String
                                    );
                                break;

                            case "role_b":
                                Console.WriteLine(
                                    "ROLE_B: {0}.{1}",
                                    _dia.LayerCollection[l].ObjectCollection[o].Connections.ConnectionCollection[1].To,
                                    _dia.LayerCollection[l].ObjectCollection[o].AttributeCollection[a].String
                                    );
                                break;
                            }
                        }
                        break;
                    }
                }
            }
        }
Exemple #14
0
//		public void New(
//			string applicationPath_in, 
//			string documentationName_in, 
//			dNotifyBack notifyBack_in
//		) {
//			if (notifyBack_in != null) notifyBack_in("creating...", true);
//			#region DocMetadata _metadata_temp = new DocMetadata(); ...;
//			XS__documentation _metadata_temp = new XS__documentation();
//			_metadata_temp.DocumentationName = documentationName_in;
//			#endregion
//
//			if (notifyBack_in != null) notifyBack_in("- generating xml file", true);
//			#region string _xmlfile = ...;
//			string _xmlfile = string.Format(
//				"{0}{1}OGenDoc-metadatas{1}MD_{2}.OGenDoc-metadata.xml", 
//				/*0*/applicationPath_in, 
//				/*1*/System.IO.Path.DirectorySeparatorChar, 
//				/*2*/documentationName_in
//			);
//			#endregion
//			_metadata_temp.SaveState_toFile(_xmlfile);
//
//			if (notifyBack_in != null) notifyBack_in("... finished!", true);
//			if (notifyBack_in != null) notifyBack_in("", true);
//
//			Open(
//				_xmlfile, 
//				true, 
//				notifyBack_in
//			);
//		}
		#endregion
		#region public void Open(...);
		public void Open(
			string filename_in, 
			bool force_doNOTsave_in, 
			dNotifyBack notifyBack_in
		) {
			#region Checking...
			if (this.hasChanges) {
				if (!force_doNOTsave_in) {
					throw new Exception(string.Format(
						"{0}.{1}.Open(): - must save before open", 
						this.GetType().Namespace, 
						this.GetType().Name
					));
				}
			}
			#endregion
			filename_ = filename_in;

			if (notifyBack_in != null) notifyBack_in("opening...", true);
			if (notifyBack_in != null) notifyBack_in("- reading metadata from xml file", true);

			diagram_ = XS__diagram.Load_fromFile(
				filename_
			)[0];
			diagram_.FilePath = filename_;

			if (notifyBack_in != null) notifyBack_in("... finished", true);
		}