private bool Load()
        {
            bool retval = false;

            try
            {
                // clear state
                ClearState();

                QDatabase  database = QInstance.Environments.GetDatabase(DatabaseName);
                SqlCommand command  = new SqlCommand("SELECT DSRC_CODE, DSRC_DEFINITION FROM TLK_DATASOURCES WHERE DSRC_NAME = @name");
                command.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = name;
                DataTable dt = database.ExecuteCommand(command);
                if (dt != null)
                {
                    code       = Convert.ToInt32(dt.Rows[0]["DSRC_CODE"].ToString());
                    definition = dt.Rows[0]["DSRC_DEFINITION"].ToString();
                    retval     = true;
                }
            }
            catch (Exception ex)
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.ConfigureDatasource,
                    Description  = ex.Message,
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);
            }
            return(retval);
        }
示例#2
0
        private bool CheckRec()
        {
            bool retval = true;

            try
            {
                // do not check LCY fields
                if (!fieldName.EndsWith("_LCY"))
                {
                    QDatabase database = QInstance.Environments.GetDatabase(DatabaseName);
                    // first check if the field ui record exists
                    DataTable tbRec = database.ExecuteCommand(GetInstUiFieldCommand());
                    if (tbRec.Rows.Count == 0)
                    {
                        QCRAction check = new QCRAction()
                        {
                            State        = QCRActionState.NeedsAction,
                            ActionType   = QCRActionType.CheckDatasourceField,
                            Description  = string.Format("Add field \"{0}\" to Dynamic UI \"{1}\".", FieldName, DynamicUIName),
                            DatabaseName = this.DatabaseName
                        };
                        Actions.Add(check);
                        retval = false;
                    }
                }
                // everything ok
                if (Actions.Count == 0)
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.WellImplemented,
                        ActionType   = QCRActionType.NoActionNeeded,
                        Description  = string.Format("Add field \"{0}\" to Dynamic UI \"{1}\".", FieldName, DynamicUIName),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                    retval = true;
                }
            }
            catch (Exception ex)
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.CheckDUIField,
                    Description  = string.Format(ex.Message),
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);
                retval = false;
            }

            return(retval);
        }
示例#3
0
        protected bool CheckHasChildren()
        {
            bool retval = true;

            if (Children.Count == 0)
            {
                QCRAction check = new QCRAction()
                {
                    State       = QCRActionState.NeedsAction,
                    ActionType  = QCRActionType.AddCRChildren,
                    Description = "Add children change requests."
                };
                Actions.Add(check);
                retval = false;
            }
            return(retval);
        }
示例#4
0
        private bool ColumnExists()
        {
            bool result = true;

            try
            {
                QDatabase      database = QInstance.Environments.GetDatabase(DatabaseName);
                QDBTableSchema schema   = ((QAlterViewCR)Parent).GetSchema(false);
                schema.Load(database, ViewName);
                if (schema.ContainsColumn(ColumnName))
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.WellImplemented,
                        ActionType   = QCRActionType.NoActionNeeded,
                        Description  = string.Format("Add field {0} in view {1}", ColumnName, ViewName),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                }
                else
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.NeedsAction,
                        ActionType   = QCRActionType.AddColumn,
                        Description  = string.Format("Add field {0} in view {1}", ColumnName, ViewName),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                }
            }
            catch (Exception ex)
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.AddColumn,
                    Description  = string.Format(ex.Message),
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);
                result = false;
            }
            return(result);
        }
示例#5
0
        private bool CheckFieldInTable()
        {
            bool result = true;

            try
            {
                QDatabase      database = QInstance.Environments.GetDatabase(DatabaseName);
                QDBTableSchema schema   = ((QAlterTableCR)Parent).GetSchema(false);
                schema.Load(database, TableName);
                if (schema.ContainsColumn(ColumnName))
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.WellImplemented,
                        ActionType   = QCRActionType.NoActionNeeded,
                        Description  = this.Description,
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                }
                else
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.NeedsAction,
                        ActionType   = QCRActionType.AddColumn,
                        Description  = this.Description,
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                }
            }
            catch (Exception ex)
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.AddColumn,
                    Description  = ex.Message,
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);
                result = false;
            }
            return(result);
        }
示例#6
0
        public override bool Check()
        {
            bool result = base.Check();

            Actions.Clear();
            // everything ok
            QCRAction check = new QCRAction()
            {
                State       = QCRActionState.WellImplemented,
                ActionType  = QCRActionType.NoActionNeeded,
                Description = string.Format("Add field \"{0}\" to pool.", FieldName)
            };

            Actions.Add(check);

            NotifyPropertyChanged(nameof(CheckResultType));
            return(result);
        }
示例#7
0
        private bool CheckSpecValue(object specValue, object dbValue, string valueName)
        {
            bool retval = true;

            if (!specValue.Equals(dbValue))
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.CheckCriterio,
                    Description  = string.Format("Specification mismatch: Specification of \"{0}\" \"{1}\" does not match to implemented \"{2}\"", valueName, specValue, dbValue),
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);
                retval = false;
            }
            return(retval);
        }
示例#8
0
        private bool CheckSpecValue(string specValue, string dbValue, string valueName, bool checkIfContains)
        {
            bool retval  = true;
            bool invalid = (checkIfContains && !dbValue.Contains(specValue)) || (!checkIfContains && !specValue.Equals(dbValue));

            if (invalid)
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.CheckCriterio,
                    Description  = string.Format("Specification mismatch: Specification of \"{0}\" \"{1}\" does not match to implemented \"{2}\"", valueName, specValue, dbValue),
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);
                retval = false;
            }
            return(retval);
        }
示例#9
0
        private bool CheckInternal()
        {
            bool retval = false;

            try
            {
                // clear state
                ClearState();

                string sql = @"SELECT DUIP.INST_CODE, DUIV.DUIV_VERSION_VALUE, DUI.DUI_NAME, DUI.DUI_CODE, DSRC.DSRC_NAME, DSRC.DSRC_CODE, UIR.UIR_DESCRIPTION
                           FROM TLK_DYNAMICUI DUI
                           INNER JOIN TLK_DYNAMICUI_DEPL_PROP DUIP
                           ON DUIP.DUI_CODE = DUI.DUI_CODE AND DUIP.INST_CODE=@inst_code
                           INNER JOIN TLK_DYNAMICUI_VERSIONS DUIV
                           ON DUIV.DUIp_CODE=DUIP.DUIP_CODE
                           INNER JOIN TLK_DATASOURCES DSRC
                           ON DUI.DSRC_CODE = DSRC.DSRC_CODE
                           INNER JOIN TLK_UI_ROLES UIR
                           ON UIR.UIR_INTERNAL_DESC=DUIV.DUIV_VERSION_VALUE AND UIR.UIR_DESCRIPTION=@version_value
                           WHERE DUI.DUI_NAME=@dui_name";
                if (VersionValue.Equals("#BASE_VERSION#"))
                {
                    sql = @"SELECT DUIP.INST_CODE, DUIV.DUIV_VERSION_VALUE, DUI.DUI_NAME, DUI.DUI_CODE, DSRC.DSRC_NAME, DSRC.DSRC_CODE
                           FROM TLK_DYNAMICUI DUI
                           INNER JOIN TLK_DYNAMICUI_DEPL_PROP DUIP
                           ON DUIP.DUI_CODE = DUI.DUI_CODE AND DUIP.INST_CODE=@inst_code
                           INNER JOIN TLK_DYNAMICUI_VERSIONS DUIV 
                           ON DUIV.DUIp_CODE=DUIP.DUIP_CODE AND DUIV.DUIV_VERSION_VALUE='#BASE_VERSION#'
                           INNER JOIN TLK_DATASOURCES DSRC
                           ON DUI.DSRC_CODE = DSRC.DSRC_CODE                           
                           WHERE DUI.DUI_NAME=@dui_name";
                }

                QDatabase  database = QInstance.Environments.GetDatabase(DatabaseName);
                SqlCommand command  = new SqlCommand(sql);
                command.Parameters.Add("@dui_name", SqlDbType.NVarChar, 50).Value      = name;
                command.Parameters.Add("@version_value", SqlDbType.NVarChar, 50).Value = versionValue;
                command.Parameters.Add("@inst_code", SqlDbType.Int, 50).Value          = installationCode;
                try
                {
                    DataTable dt = database.ExecuteCommand(command);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        code           = Convert.ToInt32(dt.Rows[0]["DUI_CODE"].ToString());
                        datasourceCode = Convert.ToInt32(dt.Rows[0]["DSRC_CODE"].ToString());
                        string tmpDatasourceName = Convert.ToString(dt.Rows[0]["DSRC_NAME"].ToString());
                        if (tmpDatasourceName != datasourceName)
                        {
                            QCRAction check = new QCRAction()
                            {
                                State        = QCRActionState.NeedsAction,
                                ActionType   = QCRActionType.CheckDUI,
                                Description  = string.Format("The DUI \"{0}\" is not connected to datasource \"{1}\" but to \"{2}\".", Name, DatasourceName, tmpDatasourceName),
                                DatabaseName = this.DatabaseName
                            };
                            Actions.Add(check);
                        }
                        retval = true;
                    }
                    else
                    {
                        Actions.Add(new QCRAction(QCRActionState.NeedsAction, QCRActionType.ConfigureDatasource, string.Format("Add datasource \"{0}\".", Name), DatabaseName));
                    }
                }
                catch (Exception ex)
                {
                    Actions.Add(new QCRAction(QCRActionState.NeedsAction, QCRActionType.CheckDatabase, string.Format(ex.Message), DatabaseName));
                }
            }
            catch (Exception ex)
            {
                Actions.Add(new QCRAction(QCRActionState.NeedsAction, QCRActionType.CheckDatabase, string.Format(ex.Message), DatabaseName));
            }
            return(retval);
        }
示例#10
0
        private bool CheckRec()
        {
            bool retval = true;

            try
            {
                QDatabase database = QInstance.Environments.GetDatabase(DatabaseName);
                // first check if the field ui record exists
                DataTable tbRec = database.ExecuteCommand(GetCriterioCommand());
                if (tbRec.Rows.Count == 0)
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.NeedsAction,
                        ActionType   = QCRActionType.AddCriterio,
                        Description  = string.Format("Add criterio \"{0}\".", Name),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                    retval = false;
                }
                else if (tbRec.Rows.Count == 1)
                {
                    QCriterioType tmpCriterioType    = (QCriterioType)Convert.ToInt32(tbRec.Rows[0]["CRI_TYPE"]);
                    bool          tmpQueues          = (bool)tbRec.Rows[0]["CRI_QUEUE"];
                    bool          tmpDynamicQueues   = (bool)tbRec.Rows[0]["CRI_DYNAMIC_QUEUE"];
                    bool          tmpWorklist        = (bool)tbRec.Rows[0]["CRI_WORKLIST"];
                    bool          tmpRevocation      = (bool)tbRec.Rows[0]["CRI_REVOCATION"];
                    bool          tmpStrategy        = (bool)tbRec.Rows[0]["CRI_STRATEGY"];
                    bool          tmpDecisionTree    = (bool)tbRec.Rows[0]["CRI_DECISION_TREE"];
                    string        tmpCategoryDesc    = (string)tbRec.Rows[0]["CATEGORY_DESC"];
                    bool          tmpIsCustomerLevel = (bool)tbRec.Rows[0]["CRI_IS_CUSTOMER_LEVEL"];
                    bool          tmpClosedCases     = (bool)tbRec.Rows[0]["CRI_CLOSED_CASES"];
                    string        tmpCriWhereTable   = (string)tbRec.Rows[0]["CRI_WHERE_TABLE"];
                    string        tmpCriWhereField   = (string)tbRec.Rows[0]["CRI_WHERE_FIELD"];
                    string        tmpCrjCode         = (string)tbRec.Rows[0]["CRJ_CODE"];
                    retval = CheckSpecValue(CriterioType, tmpCriterioType, "Criterio Type") && retval;
                    retval = CheckSpecValue(Queues, tmpQueues, "Queues") && retval;
                    retval = CheckSpecValue(DynamicQueues, tmpDynamicQueues, "DynamicQueues") && retval;
                    retval = CheckSpecValue(Revocation, tmpRevocation, "Revocation") && retval;
                    retval = CheckSpecValue(Strategy, tmpStrategy, "Strategy") && retval;
                    retval = CheckSpecValue(DecisionTree, tmpDecisionTree, "DecisionTree") && retval;
                    retval = CheckSpecValue(CategoryDesc, tmpCategoryDesc, "CategoryDesc") && retval;
                    retval = CheckSpecValue(IsCustomerLevel, tmpIsCustomerLevel, "IsCustomerLevel") && retval;
                    retval = CheckSpecValue(WhereField, tmpCriWhereField, "FieldName", true) && retval;
                    retval = CheckSpecValue(WhereTable, tmpCriWhereTable, "TableName") && retval;
                    retval = CheckSpecValue(CrjCode, tmpCrjCode, "CrjCode") && retval;


                    // set output fields
                    criUniqueId          = (string)tbRec.Rows[0]["CRI_UNIQUE_ID"];
                    criTable             = (string)tbRec.Rows[0]["CRI_TABLE"];
                    criFields            = (string)tbRec.Rows[0]["CRI_FIELDS"];
                    criWhere             = (string)tbRec.Rows[0]["CRI_WHERE"];
                    crjCode              = Convert.ToString(tbRec.Rows[0]["CRJ_CODE"]);
                    criWhereShow         = (string)tbRec.Rows[0]["CRI_WHERE_SHOW"];
                    criWhereFieldSqlType = (string)tbRec.Rows[0]["CRI_WHERE_FIELD_SQL_TYPE"];
                }
                else if (tbRec.Rows.Count > 1)
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.NeedsAction,
                        ActionType   = QCRActionType.AddCriterio,
                        Description  = string.Format("Found more than one criteria \"{0}\".", Name),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                    retval = false;
                }

                // everything ok
                if (Actions.Count == 0)
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.WellImplemented,
                        ActionType   = QCRActionType.NoActionNeeded,
                        Description  = string.Format("Add criterio \"{0}\".", Name),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                    retval = true;
                }
            }
            catch (Exception ex)
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.AddCriterio,
                    Description  = string.Format(ex.Message),
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);
                retval = false;
            }
            return(retval);
        }
示例#11
0
        private bool CheckRecLCYField()
        {
            bool retval = true;

            try
            {
                QDatabase database = QInstance.Environments.GetDatabase(DatabaseName);
                // first check if the field ui record exists
                DataTable tbRec = database.ExecuteCommand(GetLCYFieldCommand());
                if (tbRec.Rows.Count == 0)
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.NeedsAction,
                        ActionType   = QCRActionType.CheckDatasourceField,
                        Description  = string.Format("Add field \"{0}\" to datasource \"{1}\".", FieldName, DatasourceName),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                    retval = false;
                }
                else if (tbRec.Rows.Count > 0)
                {
                    // check if fields exists
                    DataRow[] row = tbRec.Select(string.Format("INST_CODE = {0}", InstallationCode));
                    if (row.Length == 0)
                    {
                        row = tbRec.Select("INST_CODE IS NULL");
                    }
                    if (row.Length == 0)
                    {
                        // field does not exist in default or in described installation
                        QCRAction check = new QCRAction()
                        {
                            State        = QCRActionState.NeedsAction,
                            ActionType   = QCRActionType.CheckDatasourceField,
                            Description  = string.Format("Add field \"{0}\" to datasource \"{1}\".", FieldName, DatasourceName),
                            DatabaseName = this.DatabaseName
                        };
                        Actions.Add(check);
                        retval = false;
                    }
                    if (row.Length == 1) // record found
                    {
                        // check active flag
                        if (!((bool)row[0]["DSF_ACTIVE"]))
                        {
                            QCRAction check = new QCRAction()
                            {
                                State        = QCRActionState.NeedsAction,
                                ActionType   = QCRActionType.CheckDatasourceField,
                                Description  = string.Format("The field \"{0}\" in datasource \"{1}\" for the installation \"{2}\" is not active.", FieldName, DatasourceName, InstallationCode),
                                DatabaseName = this.DatabaseName
                            };
                            Actions.Add(check);
                            retval = false;
                        }
                    }
                }
                // everything ok
                if (Actions.Count == 0)
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.WellImplemented,
                        ActionType   = QCRActionType.NoActionNeeded,
                        Description  = string.Format("Add field \"{0}\" to Datasource \"{1}\".", FieldName, DatasourceName),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                    retval = true;
                }
            }
            catch (Exception ex)
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.CheckDatasourceField,
                    Description  = string.Format(ex.Message),
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);

                retval = false;
            }
            return(retval);
        }
示例#12
0
        private bool CheckRecNoLCYField()
        {
            bool retval = true;

            try
            {
                QDatabase database = QInstance.Environments.GetDatabase(DatabaseName);
                // first check if the field ui record exists
                DataTable tbRec = database.ExecuteCommand(GetInstUiFieldCommand());
                if (tbRec.Rows.Count == 0)
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.NeedsAction,
                        ActionType   = QCRActionType.CheckDatasourceField,
                        Description  = string.Format("Add field \"{0}\" to datasource \"{1}\".", FieldName, DatasourceName),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                    retval = false;
                }
                else if (tbRec.Rows.Count > 0)
                {
                    // check if there are  fields in the specific installation.
                    int count = (int)database.ExecuteScalar(GetInstUIFieldsCountCommand());
                    // check if fields exists
                    DataRow[] row = tbRec.Select(string.Format("INST_CODE = {0}", InstallationCode));
                    if (row.Length == 0 && count > 0)
                    {
                        QCRAction check = new QCRAction()
                        {
                            State        = QCRActionState.NeedsAction,
                            ActionType   = QCRActionType.CheckDatasourceField,
                            Description  = string.Format("The datasource \"{0}\" contains the field \"{1}\" for the default installation only.Override for \"{2}\"", DatasourceName, FieldName, InstallationCode),
                            DatabaseName = this.DatabaseName
                        };
                        Actions.Add(check);
                        retval = false;
                    }
                    if (row.Length == 1) // record found
                    {
                        // check active flag
                        if (!((bool)row[0]["DSF_ACTIVE"]))
                        {
                            QCRAction check = new QCRAction()
                            {
                                State        = QCRActionState.NeedsAction,
                                ActionType   = QCRActionType.CheckDatasourceField,
                                Description  = string.Format("The field \"{0}\" in datasource \"{1}\" for the installation \"{2}\" is not active.", FieldName, DatasourceName, InstallationCode),
                                DatabaseName = this.DatabaseName
                            };
                            Actions.Add(check);
                            retval = false;
                        }
                        // check visible in ui flag
                        if (!((bool)row[0]["DSFU_UI_VISIBLE"]))
                        {
                            QCRAction check = new QCRAction()
                            {
                                State        = QCRActionState.NeedsAction,
                                ActionType   = QCRActionType.CheckDatasourceField,
                                Description  = string.Format("The field \"{0}\" in datasource \"{1}\" for the installation \"{2}\" is not visible in ui.", FieldName, DatasourceName, InstallationCode),
                                DatabaseName = this.DatabaseName
                            };
                            Actions.Add(check);
                            retval = false;
                        }
                        // check caption
                        if (((string)row[0]["DSFU_UI_CAPTION"]) != FieldCaption)
                        {
                            QCRAction check = new QCRAction()
                            {
                                State        = QCRActionState.NeedsAction,
                                ActionType   = QCRActionType.CheckDatasourceField,
                                Description  = string.Format("The field \"{0}\" in datasource \"{1}\" for the installation \"{2}\" has different caption than the specification.", FieldName, DatasourceName, InstallationCode),
                                DatabaseName = this.DatabaseName
                            };
                            Actions.Add(check);
                            retval = false;
                        }
                    }
                }
                // everything ok
                if (Actions.Count == 0)
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.WellImplemented,
                        ActionType   = QCRActionType.NoActionNeeded,
                        Description  = string.Format("Add field \"{0}\" to Datasource \"{1}\".", FieldName, DatasourceName),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                    retval = true;
                }
            }
            catch (Exception ex)
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.CheckDatasourceField,
                    Description  = string.Format(ex.Message),
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);

                retval = false;
            }
            return(retval);
        }