Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();
            isDbHandlerInitialized = false;
            isSlxModelInitialized = false;
            this.fields = new FieldInformationManager(this.Log);

            this.cmbNewSize.Text = strKeepCurrent;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates a FieldInformationCollection instance
        /// filling it with field data read from the db
        /// </summary>
        /// <param name="dbFields">The field collection to update</param>
        /// <returns></returns>
        public FieldInformationManager ReadTableDataFromSLXDb(FieldInformationManager dbFields)
        {
            OpenDbConnection();
            var cmd = dbConnection.CreateCommand();
            cmd.CommandText = DbHandler.getFieldsQueryString;
            cmd.CommandType = System.Data.CommandType.Text;

            // read the field information from the db
            var recSet = cmd.ExecuteReader();

            if (!recSet.HasRows)
                throw new Exception("No field information found in the db. Check your configuration!");

            // read sql info for each field
            while (recSet.Read())
            {
                FieldInformation f = dbFields.InitField(recSet["TableName"].ToString(), recSet["FieldName"].ToString());

                f.sqlType = recSet["SqlDataType"].ToString();
                f.sqlLength = (int) recSet["SqlMaximumLength"];
            }

            recSet.Close();
            CloseConnection();

            return dbFields;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Fills the provided FieldInformationManager instance
        /// with entity metadata coming from the Model
        /// </summary>
        /// <param name="dbFields"></param>
        /// <returns></returns>
        public FieldInformationManager FindEntityModels(FieldInformationManager dbFields)
        {
            /* Example XML property snippet:
             * <property xsi:type="OrmFieldProperty" id="d6e61b3a-4663-4d89-a605-beb0fc07cae2" lastModifiedUtc="2009-04-20T02:51:53.3856462Z" name="LastName" audited="false" columnName="LASTNAME" maxLength="50" precision="0" scale="0" ordinal="5" isReadOnly="false" isDynamic="false">
             *   <ExtendedPropertiesCollection>
             *     <extendee type="Sage.Platform.Orm.Entities.OrmFieldProperty" />
             *   </ExtendedPropertiesCollection>
             *   <SystemDataType guid="ccc0f01d-7ba5-408e-8526-a3f942354b3a">
             *     <TextDataType>
             *       <Length>50</Length>
             *     </TextDataType>
             *   </SystemDataType>
             * </property>
             * <property xsi:type="OrmFieldProperty" id="37a5bc92-84cc-4e43-ab62-6c9c6208bb84" lastModifiedUtc="2011-04-13T14:56:08.9030225Z" name="CountryLocal" audited="false" columnName="COUNTRYLOCAL" maxLength="64" precision="0" scale="0" ordinal="8" isReadOnly="false" isDynamic="false">
             *   <ExtendedPropertiesCollection>
             * 	<extendee type="Sage.Platform.Orm.Entities.OrmFieldProperty" />
             *   </ExtendedPropertiesCollection>
             *   <SystemDataType guid="76c537a8-8b08-4b35-84cf-fa95c6c133b0">
             * 	<UnicodeTextDataType>
             * 	  <Length>64</Length>
             * 	</UnicodeTextDataType>
             *   </SystemDataType>
             * </property>
             */
            try
            {
                foreach (XPathDocument entityXml in ModelPersister.GetEntityFiles())
                {
                    ReadFieldInformationsForEntity(dbFields, entityXml.CreateNavigator());
                }
            }
            catch (Exception)
            {
                throw new Exception("Error reading entity model files!");
            }

            return dbFields;
        }
Ejemplo n.º 4
0
        private static void ReadFieldInformationsForEntity(FieldInformationManager dbFields, XPathNavigator nav)
        {
            var tableName = nav.SelectSingleNode("//entity").GetAttribute("tableName", String.Empty);

            foreach (XPathNavigator property in nav.Select("//property"))
            {
                string slxType = GetSlxTypeOfXmlProperty(property);

                if (!String.IsNullOrEmpty(slxType))
                {
                    var propertyName = property.GetAttribute("columnName", String.Empty).ToString();
                    var field = dbFields.InitField(tableName.ToUpper(), propertyName.ToUpper());

                    field.slxType = slxType;
                    field.slxLength = GetFieldLengthFromPropertyXml(property);
                }
            }
        }