protected string FormIdentifier(DataObject objDef, DataRow dataRow)
        {
            try
            {
                string[]    identifierParts = new string[objDef.keyProperties.Count];
                IDataObject dataObject      = ToDataObject(dataRow, objDef);

                for (int i = 0; i < objDef.keyProperties.Count; i++)
                {
                    KeyProperty keyProp = objDef.keyProperties[i];
                    object      value   = dataObject.GetPropertyValue(keyProp.keyPropertyName);

                    if (value != null)
                    {
                        identifierParts[i] = value.ToString();
                    }
                    else
                    {
                        identifierParts[i] = String.Empty;
                    }
                }

                return(string.Join(objDef.keyDelimeter, identifierParts));
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Error forming identifier from data row: {0}", ex));
                throw ex;
            }
        }
Exemple #2
0
        private void btnSaveDbDictionary_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                biBusyWindow.IsBusy = true;
                selectedCBItem      = cbDictionary.SelectedItem.ToString();
                string projectName     = cbDictionary.SelectedItem.ToString().Split('.')[1];
                string applicationName = cbDictionary.SelectedItem.ToString().Split('.')[2];

                DatabaseDictionary databaseDictionary = new DatabaseDictionary();
                object             currentObject      = null;
                DataObject         table;
                databaseDictionary.dataObjects      = new List <DataObject>();
                databaseDictionary.connectionString = tvwItemDestinationRoot.Tag.ToString().Split('~')[0];
                string provider = tvwItemDestinationRoot.Tag.ToString().Split('~')[1];
                databaseDictionary.provider = (Provider)Enum.Parse(typeof(Provider), provider, true);
                foreach (TreeViewItem tableTreeViewItem in tvwItemDestinationRoot.Items)
                {
                    table         = new DataObject();
                    currentObject = tableTreeViewItem.Tag;
                    if (currentObject is DataObject)
                    {
                        table.objectName        = ((DataObject)currentObject).objectName;
                        table.tableName         = ((DataObject)currentObject).tableName;
                        table.keyProperties     = new KeyProperties();
                        table.dataRelationships = new List <DataRelationship>();
                        table.dataProperties    = new List <DataProperty>();
                    }
                    foreach (TreeViewItem columnTreeViewItem in tableTreeViewItem.Items)
                    {
                        currentObject = columnTreeViewItem.Tag;
                        if (currentObject is org.iringtools.library.KeyProperty)
                        {
                            //    DataType dataType =  (DataType)Enum.Parse(typeof(DataType),((org.iringtools.library.KeyProperty)currentObject).dataType.ToString(),true);
                            org.iringtools.library.KeyProperty key = new org.iringtools.library.KeyProperty();
                            key.columnName = ((org.iringtools.library.KeyProperty)currentObject).columnName;
                            key.dataLength = ((org.iringtools.library.KeyProperty)currentObject).dataLength;
                            //    key.dataType = dataType;
                            key.isNullable   = ((org.iringtools.library.KeyProperty)currentObject).isNullable;
                            key.propertyName = ((org.iringtools.library.KeyProperty)currentObject).propertyName;
                            table.keyProperties.Add(key);
                        }
                        else
                        {
                            //    DataType dataType = (DataType)Enum.Parse(typeof(DataType), ((Column)currentObject).dataType.ToString(), true);
                            DataProperty column = new DataProperty();
                            column.columnName = ((DataProperty)currentObject).columnName;
                            column.dataLength = ((DataProperty)currentObject).dataLength;
                            //     column.dataType = dataType;
                            column.isNullable   = ((DataProperty)currentObject).isNullable;
                            column.propertyName = ((DataProperty)currentObject).propertyName;
                            table.dataProperties.Add(column);
                        }
                    }
                    databaseDictionary.dataObjects.Add(table);
                }

                _dal.SaveDatabaseDictionary(databaseDictionary, projectName, applicationName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occured. Please retry.", "Save Database Dictionary Error", MessageBoxButton.OK);
                biBusyWindow.IsBusy = false;
            }
        }