Example #1
0
        public ValidationDBPage(ActDBValidation validationDB)
        {
            InitializeComponent();

            this.mValidationDB = validationDB;

            if (String.IsNullOrEmpty(mValidationDB.GetInputParamValue("SQL")))
            {
                mValidationDB.AddOrUpdateInputParamValue("SQL", mValidationDB.GetInputParamValue("Value"));
            }

            FillAppComboBox();

            //New UI Controls:
            //Query Type selection radio button :
            QueryTypeRadioButton.Init(typeof(ActDBValidation.eQueryType), SqlSelection, mValidationDB.GetOrCreateInputParam(ActDBValidation.Fields.QueryTypeRadioButton, ActDBValidation.eQueryType.FreeSQL.ToString()), QueryType_SelectionChanged);
            checkQueryType();

            //Free SQL
            //needs to be unmarked when fixed VE issue
            SQLUCValueExpression.Init(mValidationDB.GetOrCreateInputParam(ActDBValidation.Fields.SQL));

            //Read from sql file
            QueryFile.Init(mValidationDB.GetOrCreateInputParam(ActDBValidation.Fields.QueryFile), true, true, UCValueExpression.eBrowserType.File, "sql", BrowseQueryFile_Click);

            QueryFile.ValueTextBox.TextChanged += ValueTextBox_TextChanged;

            //Import SQL file in to solution folder
            GingerCore.General.ActInputValueBinding(ImportFile, CheckBox.IsCheckedProperty, mValidationDB.GetOrCreateInputParam(ActDBValidation.Fields.ImportFile, "True"));

            //OLD binding and UI
            App.FillComboFromEnumVal(ValidationCfgComboBox, validationDB.DBValidationType);

            //TODO: fix hard coded
            App.ObjFieldBinding(ValidationCfgComboBox, ComboBox.SelectedValueProperty, validationDB, "DBValidationType");

            App.ObjFieldBinding(AppNameComboBox, ComboBox.TextProperty, validationDB, ActDBValidation.Fields.AppName);
            App.ObjFieldBinding(DBNameComboBox, ComboBox.TextProperty, validationDB, ActDBValidation.Fields.DBName);
            App.ObjFieldBinding(TablesComboBox, ComboBox.TextProperty, validationDB, ActDBValidation.Fields.Table);
            App.ObjFieldBinding(KeySpaceComboBox, ComboBox.TextProperty, validationDB, ActDBValidation.Fields.Keyspace);
            App.ObjFieldBinding(ColumnComboBox, ComboBox.TextProperty, validationDB, ActDBValidation.Fields.Column);
            App.ObjFieldBinding(txtWhere, TextBox.TextProperty, validationDB, ActDBValidation.Fields.Where);
            GingerCore.General.ActInputValueBinding(CommitDB, CheckBox.IsCheckedProperty, mValidationDB.GetOrCreateInputParam(ActDBValidation.Fields.CommitDB));

            KeySpaceComboBox.Items.Add(mValidationDB.Keyspace);
            ComboAutoSelectIfOneItemOnly(KeySpaceComboBox);
            TablesComboBox.Items.Add(mValidationDB.Table);
            ComboAutoSelectIfOneItemOnly(TablesComboBox);
            ColumnComboBox.Items.Add(mValidationDB.Column);
            ComboAutoSelectIfOneItemOnly(ColumnComboBox);
            SetVisibleControlsForAction();
            SetQueryParamsGrid();
        }
Example #2
0
        private void ValueTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            string SolutionFolder = WorkSpace.UserProfile.Solution.Folder.ToUpper();
            bool   ImportFileFlag = false;
            string FileName       = QueryFile.ValueTextBox.Text;

            Boolean.TryParse(mValidationDB.GetInputParamValue(ActDBValidation.Fields.ImportFile), out ImportFileFlag);
            if (ImportFileFlag && !FileName.StartsWith(@"~\"))
            {
                //TODO import request File
                string targetPath = System.IO.Path.Combine(SolutionFolder, @"Documents\SQL");
                if (!System.IO.Directory.Exists(targetPath))
                {
                    System.IO.Directory.CreateDirectory(targetPath);
                }
                string destFile  = System.IO.Path.Combine(targetPath, FileName.Remove(0, FileName.LastIndexOf(@"\") + 1));
                int    fileNum   = 1;
                string copySufix = "_Copy";
                while (System.IO.File.Exists(destFile))
                {
                    fileNum++;
                    string newFileName = System.IO.Path.GetFileNameWithoutExtension(destFile);
                    if (newFileName.IndexOf(copySufix) != -1)
                    {
                        newFileName = newFileName.Substring(0, newFileName.IndexOf(copySufix));
                    }
                    newFileName = newFileName + copySufix + fileNum.ToString() + System.IO.Path.GetExtension(destFile);
                    destFile    = System.IO.Path.Combine(targetPath, newFileName);
                }
                System.IO.File.Copy(FileName, destFile, true);
                QueryFile.ValueTextBox.Text = @"~\Documents\SQL\" + System.IO.Path.GetFileName(destFile);
            }
            //if (FileName != "" && File.Exists(FileName.Replace(@"~\", SolutionFolder)))
            if (FileName != "" && File.Exists(amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.ConvertSolutionRelativePath(FileName)))
            {
                mValidationDB.QueryParams.Clear();
                //string[] script = File.ReadAllLines(FileName.Replace(@"~\",SolutionFolder));
                string[] script = File.ReadAllLines(amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.ConvertSolutionRelativePath(FileName));

                parseScriptHeader(script);
                if (mValidationDB.QueryParams.Count > 0)
                {
                    QueryParamsPanel.Visibility = Visibility.Visible;
                }
                else
                {
                    QueryParamsPanel.Visibility = Visibility.Collapsed;
                }
                QueryParamsGrid.DataSourceList = mValidationDB.QueryParams;
            }
        }
Example #3
0
        public ValidationDBPage(ActDBValidation act)
        {
            InitializeComponent();

            this.mAct = act;

            if (String.IsNullOrEmpty(mAct.GetInputParamValue("SQL")))
            {
                mAct.AddOrUpdateInputParamValue("SQL", mAct.GetInputParamValue("Value"));
            }

            FillAppComboBox();

            //New UI Controls:
            //Query Type selection radio button :
            QueryTypeRadioButton.Init(typeof(ActDBValidation.eQueryType), SqlSelection, mAct.GetOrCreateInputParam(ActDBValidation.Fields.QueryTypeRadioButton, ActDBValidation.eQueryType.FreeSQL.ToString()), QueryType_SelectionChanged);
            checkQueryType();

            //Free SQL
            //needs to be unmarked when fixed VE issue
            SQLUCValueExpression.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(ActDBValidation.Fields.SQL));

            //Read from sql file
            QueryFile.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(ActDBValidation.Fields.QueryFile), true, true, UCValueExpression.eBrowserType.File, "sql", BrowseQueryFile_Click, WorkSpace.Instance.SolutionRepository.SolutionFolder);

            QueryFile.ValueTextBox.TextChanged += ValueTextBox_TextChanged;

            //OLD binding and UI
            GingerCore.General.FillComboFromEnumObj(ValidationCfgComboBox, act.DBValidationType);

            //TODO: fix hard coded
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(ValidationCfgComboBox, ComboBox.SelectedValueProperty, act, "DBValidationType");

            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(AppNameComboBox, ComboBox.TextProperty, act, ActDBValidation.Fields.AppName);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(DBNameComboBox, ComboBox.TextProperty, act, ActDBValidation.Fields.DBName);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(TablesComboBox, ComboBox.TextProperty, act, ActDBValidation.Fields.Table);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(KeySpaceComboBox, ComboBox.TextProperty, act, ActDBValidation.Fields.Keyspace);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(ColumnComboBox, ComboBox.TextProperty, act, ActDBValidation.Fields.Column);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(txtWhere, TextBox.TextProperty, act, ActDBValidation.Fields.Where);
            GingerCore.GeneralLib.BindingHandler.ActInputValueBinding(CommitDB, CheckBox.IsCheckedProperty, mAct.GetOrCreateInputParam(ActDBValidation.Fields.CommitDB));

            KeySpaceComboBox.Items.Add(mAct.Keyspace);
            ComboAutoSelectIfOneItemOnly(KeySpaceComboBox);
            TablesComboBox.Items.Add(mAct.Table);
            ComboAutoSelectIfOneItemOnly(TablesComboBox);
            ColumnComboBox.Items.Add(mAct.Column);
            ComboAutoSelectIfOneItemOnly(ColumnComboBox);
            SetVisibleControlsForAction();
            SetQueryParamsGrid();
        }
Example #4
0
        private void SetVisibleControlsForAction()
        {
            if (ValidationCfgComboBox.SelectedItem == null)
            {
                RadioButtonsSection.Visibility     = System.Windows.Visibility.Visible;
                FreeSQLStackPanel.Visibility       = System.Windows.Visibility.Collapsed;
                SqlFile.Visibility                 = System.Windows.Visibility.Collapsed;
                FreeSQLStackPanel.Visibility       = System.Windows.Visibility.Collapsed;
                DoCommit.Visibility                = System.Windows.Visibility.Collapsed;
                Keyspace.Visibility                = System.Windows.Visibility.Collapsed;
                TableColWhereStackPanel.Visibility = System.Windows.Visibility.Collapsed;
                return;
            }

            //Ugly code but working, find way to make it simple use the enum val from combo
            ActDBValidation.eDBValidationType validationType = (ActDBValidation.eDBValidationType)ValidationCfgComboBox.SelectedValue;

            switch (validationType)
            {
            case ActDBValidation.eDBValidationType.UpdateDB:
                RadioButtonsSection.Visibility = System.Windows.Visibility.Visible;
                checkQueryType();
                TableColWhereStackPanel.Visibility = System.Windows.Visibility.Collapsed;
                FreeSQLLabel.Content = "Update DB SQL:";
                DoCommit.Visibility  = System.Windows.Visibility.Visible;
                Keyspace.Visibility  = System.Windows.Visibility.Collapsed;
                break;

            case ActDBValidation.eDBValidationType.FreeSQL:
                checkQueryType();
                RadioButtonsSection.Visibility = System.Windows.Visibility.Visible;
                if (mAct.GetInputParamValue(ActDBValidation.Fields.QueryTypeRadioButton) == ActDBValidation.eQueryType.FreeSQL.ToString())
                {
                    FreeSQLStackPanel.Visibility = System.Windows.Visibility.Visible;
                    SqlFile.Visibility           = System.Windows.Visibility.Collapsed;
                }
                else
                {
                    SqlFile.Visibility           = System.Windows.Visibility.Visible;
                    FreeSQLStackPanel.Visibility = System.Windows.Visibility.Collapsed;

                    if (mAct.QueryParams != null)
                    {
                        if (mAct.QueryParams.Count > 0)
                        {
                            QueryParamsPanel.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            QueryParamsPanel.Visibility = Visibility.Collapsed;
                        }
                        QueryParamsGrid.DataSourceList = mAct.QueryParams;
                    }
                }
                DoCommit.Visibility = System.Windows.Visibility.Collapsed;
                TableColWhereStackPanel.Visibility = System.Windows.Visibility.Collapsed;
                FreeSQLLabel.Content = "Free SQL:";
                Keyspace.Visibility  = System.Windows.Visibility.Collapsed;
                break;

            case ActDBValidation.eDBValidationType.SimpleSQLOneValue:
                checkQueryType();
                try
                {
                    string DBName = DBNameComboBox.Text;
                    db = (Database)(from d in EA.Dbs where d.Name == DBName select d).FirstOrDefault();
                    if (!(db == null))
                    {
                        if (db.DBType == Database.eDBTypes.Cassandra)
                        {
                            Keyspace.Visibility = System.Windows.Visibility.Visible;
                        }
                        else
                        {
                            Keyspace.Visibility = System.Windows.Visibility.Collapsed;
                        }
                    }
                }
                catch { }
                FreeSQLStackPanel.Visibility       = System.Windows.Visibility.Collapsed;
                RadioButtonsSection.Visibility     = System.Windows.Visibility.Collapsed;
                TableColWhereStackPanel.Visibility = System.Windows.Visibility.Visible;
                DoCommit.Visibility = System.Windows.Visibility.Collapsed;
                SqlFile.Visibility  = System.Windows.Visibility.Collapsed;
                break;

            case ActDBValidation.eDBValidationType.RecordCount:
                checkQueryType();
                try
                {
                    string DBName = DBNameComboBox.Text;
                    db = (Database)(from d in EA.Dbs where d.Name == DBName select d).FirstOrDefault();
                    if (!(db == null))
                    {
                        if (db.DBType == Database.eDBTypes.Cassandra)
                        {
                            Keyspace.Visibility = System.Windows.Visibility.Visible;
                        }
                        else
                        {
                            Keyspace.Visibility = System.Windows.Visibility.Collapsed;
                        }
                    }
                }
                catch { }
                RadioButtonsSection.Visibility     = System.Windows.Visibility.Collapsed;
                FreeSQLStackPanel.Visibility       = System.Windows.Visibility.Visible;
                TableColWhereStackPanel.Visibility = System.Windows.Visibility.Collapsed;
                DoCommit.Visibility  = System.Windows.Visibility.Collapsed;
                SqlFile.Visibility   = System.Windows.Visibility.Collapsed;
                FreeSQLLabel.Content = @"Record count - SELECT COUNT(1) FROM {Table} - Enter only Table name below (+optional WHERE clause)";
                break;
            }
        }