Exemplo n.º 1
0
        private void AccurateSettings_Load(object sender, EventArgs e)
        {
            BL.OWLConfiguration owlConfig = new BL.OWLConfiguration();

            XElement xElement = owlConfig.OWLConfigurations.Count > 0 ? owlConfig.OWLConfigurations[0] : null;

            if (xElement != null)
            {
                BL.OWLDescription OWLDesc = new BL.OWLDescription(xElement);

                //set account - contact related tables to calculate accuration of a customer record
                DataSet dsTable = new DataSet();
                try
                {
                    dsTable = new BusinessLayer.DataDescription(OWLDesc.StagingDatabase.ConnectionString).GetCustomerReferencedTables();
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.Message + "\n" + exp.StackTrace);
                    return;
                }

                foreach (DataTable dtTable in dsTable.Tables)
                {
                    foreach (DataRow drColumn in dtTable.Rows)
                    {
                        CommonTools.Node tableNode = new CommonTools.Node(drColumn["ParentObject"].ToString());
                        tableNode.ImageId = 0;

                        DataSet dsTableChild = new BusinessLayer.DataDescription(OWLDesc.StagingDatabase.ConnectionString).GetColumnsByTableId(drColumn["ParentObjectId"].ToString());

                        foreach (DataTable dtTableChild in dsTableChild.Tables)
                        {
                            foreach (DataRow drColumnChild in dtTableChild.Rows)
                            {
                                CommonTools.Node columnNode = new CommonTools.Node(new object[] {
                                    drColumnChild["name"].ToString()
                                });
                                columnNode.ImageId = 1;
                                tableNode.Nodes.Add(columnNode);
                            }
                        }
                        treeListViewStaging.Nodes.Add(tableNode);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtBusinessRequired.Text.Length < 1 && txtBusinessRecommend.Text.Length < 1 && txtNoConstraint.Text.Length < 1)
            {
                MessageBox.Show("Please fill High,Medium and Low fields in order to calculate exact value of accuration ");
                return;
            }

            BL.OWLConfiguration owlConfiguration = new BL.OWLConfiguration();

            //insert OWLConfiguration object
            XElement _newElement = new XElement("OWLItem", new XAttribute("type", "Accurate"), new XAttribute("low", txtLow.Text), new XAttribute("medium", txtMedium.Text), new XAttribute("high", txtHigh.Text), new XAttribute("businessrequired", txtBusinessRequired.Text), new XAttribute("businessrecommend", txtBusinessRecommend.Text), new XAttribute("noconstraint", txtNoConstraint.Text));

            foreach (CommonTools.Node node in treeListViewAccurateXML.Nodes)
            {
                _newElement.Add(new XElement("Map", new XAttribute("key", node[0]), new XAttribute("value", node[1])));
            }

            OWLItem _owlItem = (OWLItem)OWLItem.CreateOWLItem(_newElement);

            _owlItem.Save();

            MessageBox.Show("Accurate configuration file has just completed.", "Accurate");
        }
Exemplo n.º 3
0
        private void btnGenerateMapFile_Click(object sender, EventArgs e)
        {
            bool isExistingMapSelected = false;

            if (cmbExistingMap.Text == String.Empty)
            {
                MessageBox.Show("Select map name from list or type name for new map...");
                return;
            }

            if (!DatabaseMappingForm.isValid.HasValue)
            {
                MessageBox.Show("Mapping has not check for validation!, Please click Validate button to check", "Validation requires");
                return;
            }

            if (!DatabaseMappingForm.isValid.Value)
            {
                MessageBox.Show("Mapping is not valid!, Please click Validate button to display invalid parts", "is not Valid");
                return;
            }

            if (cmbExistingMap.SelectedIndex != -1)
            {
                if (MessageBox.Show("Existing map will destroy,are you sure?", "Existing Map Confirmation", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
                isExistingMapSelected = true;
            }

            BL.DatabaseMap databaseMap = new BL.DatabaseMap();


            if (isExistingMapSelected)
            {
                //delete map from DatabaseMap.xml
                XElement _deleteElement = databaseMap.DatabaseMaps.Find(x => x.Attribute(XName.Get("name")).Value.Contains(cmbExistingMap.Text));
                databaseMap.DatabaseMaps.Remove(_deleteElement);
                databaseMap.Save();
            }

            //insert DatabaseMap object
            XElement _newElement = new XElement("DatabaseMap", new XAttribute("name", cmbExistingMap.Text));

            //Source
            _newElement.Add(new XElement("Database", new XAttribute("type", "source"), new XAttribute("connectionString", txtSourceConnectionString.Text)));
            //Staging
            _newElement.Add(new XElement("Database", new XAttribute("type", "staging"), new XAttribute("connectionString", txtStagingDatabaseConnectionString.Text)));
            //OWL File Path
            _newElement.Add(new XElement("OWL", new XAttribute("type", "file"), new XAttribute("path", txtOWLFilePath.Text)));
            //Tables
            foreach (Node table in treeListViewMap.Nodes)
            {
                XElement _newTableElement = new XElement("Table", new XAttribute("name", table[0]));
                foreach (Node map in table.Nodes)
                {
                    _newTableElement.Add(new XElement("Map", new XAttribute("from", map[0]), new XAttribute("fromtype", map[1]), new XAttribute("to", map[2]), new XAttribute("totype", map[3])));
                }

                _newElement.Add(_newTableElement);
            }

            databaseMap.DatabaseMaps.Add(_newElement);
            databaseMap.Save();

            BL.OWLConfiguration owlConfiguration = new BL.OWLConfiguration();

            //insert OWLConfiguration object
            _newElement = new XElement("OWLConfiguration");
            //Staging
            _newElement.Add(new XElement("Database", new XAttribute("type", "staging"), new XAttribute("connectionString", txtStagingDatabaseConnectionString.Text)));
            //OWL Item
            _newElement.Add(new XElement("OWLItem", new XAttribute("type", "Accurate"), new XAttribute("low", "-1"), new XAttribute("medium", "-1"), new XAttribute("high", "-1"), new XAttribute("businessrequired", "-1"), new XAttribute("businessrecommend", "-1"), new XAttribute("noconstraint", "-1")));

            owlConfiguration.OWLConfigurations.RemoveRange(0, owlConfiguration.OWLConfigurations.Count);
            owlConfiguration.OWLConfigurations.Add(_newElement);
            owlConfiguration.Save();

            MessageBox.Show(cmbExistingMap.Text + " is generated.");
        }