Exemplo n.º 1
0
        private QCriterioType DBTypeToCriterioType(string dbTypeParam)
        {
            QCriterioType retval = QCriterioType.Unspecified;

            if (dbTypeParam.Equals("datetime"))
            {
                retval = QCriterioType.Date;
            }

            return(retval);
        }
Exemplo n.º 2
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);
        }