示例#1
0
        protected bool Parse(out IScriptFragment fragment)
        {
            TSql100Parser      parser = new TSql100Parser(false);
            IList <ParseError> errors;

            fragment = parser.Parse(new StringReader(QueryToValidate), out errors);
            if (errors != null && errors.Count > 0)
            {
                List <string> errorList = new List <string>();
                foreach (var error in errors)
                {
                    if (ErrorMessageList == null)
                    {
                        ErrorMessageList = new List <string>();
                    }
                    ErrorMessageList.Add(error.Message);
                }
            }
            if (ErrorMessageList == null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        protected bool IsSelect(IScriptFragment fragment)
        {
            var script = fragment as TSqlScript;
            IList <TSqlStatement> statements = null;
            bool isSelectStatement           = false;
            int  statementNo = 1;

            foreach (var batch in script.Batches)
            {
                statements = batch.Statements;
                foreach (var st in statements)
                {
                    if (st is SelectStatement)
                    {
                        isSelectStatement = true;
                    }
                    else
                    {
                        if (ErrorMessageList == null)
                        {
                            ErrorMessageList = new List <string>();
                        }
                        ErrorMessageList.Add("Query:#" + statementNo + " is not a select query");
                        isSelectStatement = false;
                        break;
                    }
                    statementNo++;
                }
            }
            return(isSelectStatement);
        }
示例#3
0
        protected bool CheckColumnExistence(TSqlScript fragment)
        {
            bool hasColumnName               = true;
            int  statementNo                 = 1;
            int  invalidStatements           = 0;
            IList <TSqlStatement> statements = GetStatements(fragment);

            foreach (var st in statements)
            {
                IList <TSqlFragment> selectStatements = new List <TSqlFragment>();
                var specTemp = ((SelectStatement)st).QueryExpression;
                CheckForQueryExpression(specTemp, ref selectStatements);

                foreach (SelectColumn col in selectStatements)
                {
                    if (col.ColumnName != null)
                    {
                        if (((Identifier)col.ColumnName).Value.ToLower() == "entityguid")
                        {
                            hasColumnName = true;
                            break;
                        }
                        else
                        {
                            hasColumnName = false;
                        }
                    }
                }
                if (!hasColumnName)
                {
                    invalidStatements++;
                    if (ErrorMessageList == null)
                    {
                        ErrorMessageList = new List <string>();
                    }
                    ErrorMessageList.Add("Query does not have Column with Name 'EntityGUID'");
                }
                statementNo++;
            }
            if (invalidStatements > 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#4
0
 protected void ValidateForNoOfStatements(TSqlScript fragment)
 {
     SetNoOfStatements(fragment);
     if (TotalStatements != 1)
     {
         QueryValid = false;
         if (ErrorMessageList == null)
         {
             ErrorMessageList = new List <string>();
         }
         if (TotalStatements == 0)
         {
             ErrorMessageList.Add("Query must have atleast one statement");
         }
         else
         {
             ErrorMessageList.Add("Query must have only one statement");
         }
     }
     else
     {
         QueryValid = true;
     }
 }
示例#5
0
 public void AddErrorMessage(string message)
 {
     ErrorMessageList.Add(message);
 }
示例#6
0
        private ErrorMessageList Validate()
        {
            ErrorMessageList errors = new ErrorMessageList();

            if (!internalState.VendorID.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.VENDORID));
            }
            if (!internalState.VendorName.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.VENDORNAME));
            }
            if (!internalState.VendorTypeID.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.VENDORTYPEID));
            }
            if (!internalState.PhoneNumber.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.PHONENUMBER));
            }
            if (!internalState.Description.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.DESCRIPTION));
            }
            if (!internalState.OrderLeadMins.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.ORDERLEADMINS));
            }
            if (!internalState.MinimumOrderAmt.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.MINIMUMORDERAMT));
            }
            if (!internalState.GratuityOrderAmt.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.GRATUITYORDERAMT));
            }
            if (!internalState.GratuityPct.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.GRATUITYPCT));
            }
            if (!internalState.TaxRate.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.TAXRATE));
            }
            if (!internalState.AccountNumber.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.ACCOUNTNUMBER));
            }
            if (!internalState.OrderEventTypeID.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.ORDEREVENTTYPEID));
            }
            if (!internalState.EffectiveDate.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.EFFECTIVEDATE));
            }
            if (!internalState.ExpirationDate.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.EXPIRATIONDATE));
            }
            if (!internalState.ContactUserID.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.CONTACTUSERID));
            }
            if (!internalState.LogoFile.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.LOGOFILE));
            }
            if (!internalState.StatusNormal.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.STATUSNORMAL));
            }
            if (!internalState.StatusBusy.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.STATUSBUSY));
            }
            if (!internalState.StatusVeryBusy.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.STATUSVERYBUSY));
            }
            if (!internalState.DiscountRate.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.DISCOUNTRATE));
            }
            if (!internalState.IsPercent.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.ISPERCENT));
            }
            if (!internalState.DefaultTerms.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.DEFAULTTERMS));
            }
            if (!internalState.IsCreditTranFeeDeducted.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.ISCREDITTRANFEEDEDUCTED));
            }
            if (!internalState.BasisID.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.BASISID));
            }
            if (!internalState.IsOverrideLowerLevel.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.ISOVERRIDELOWERLEVEL));
            }
            if (!internalState.VendorDescription.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.VENDORDESCRIPTION));
            }
            if (!internalState.DeliveryFee.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.DELIVERYFEE));
            }
            if (!internalState.DeliveryFeeIsPercent.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.DELIVERYFEEISPERCENT));
            }
            if (!internalState.DeliveryFeeOnTax.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.DELIVERYFEEONTAX));
            }
            if (!internalState.LocationCount.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.LOCATIONCOUNT));
            }
            if (!internalState.DefaultOrderEventTypeID.IsValid)
            {
                errors.Add(MessageConditionEnum.MISSING_REQUIRED_FIELD, StringType.Parse(VendorData.DEFAULTORDEREVENTTYPEID));
            }
            return(errors);
        }