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); } }
public void CreatesNewCollectionWhenAddingItems() { ErrorMessageList list = ErrorMessageList.Empty.With(ErrorMessage.Expected("expectation")); list.ToString().ShouldBe("expectation expected"); list.ShouldNotBeSameAs(ErrorMessageList.Empty); }
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); }
public void CanIndicateErrorsWhichCausedBacktracking() { var position = new Position(3, 4); ErrorMessageList errors = ErrorMessageList.Empty .With(ErrorMessage.Expected("a")) .With(ErrorMessage.Expected("b")); var error = (BacktrackErrorMessage)ErrorMessage.Backtrack(position, errors); error.Position.ShouldBe(position); error.Errors.ShouldBe(errors); error.ToString().ShouldBe("(3, 4): a or b expected"); }
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); } }
protected override bool DoValidation(ErrorMessageList errorList) { bool result = base.DoValidation(errorList); if (string.IsNullOrEmpty(this.Query)) { result = false; EditableBase.AddError(errorList, "Query", string.Format(Saleslogix.Social.Mashups.Properties.Resources.PropertyCannotBeEmpty, SR.GetString("TwitterProcessor_Query_DisplayName"))); } else { if (this._query.Error != null) { result = false; EditableBase.AddError(errorList, "Query", string.Format("{0}: {1}", SR.GetString("TwitterProcessor_Query_DisplayName"), this._query.Error)); } } return(result); }
public StringBuilder ErrorMessagesToString() { //Creates the string which should contain all items in the ErrorMessageList StringBuilder errorMessageString = new StringBuilder(); //If the ErrormessageList has items make a long string of all the errors with each item on a new line (by using "\n") if (ErrorMessageList.Count() != 0) { int lastItem = ErrorMessageList.Count() - 1; for (int i = 0; i < ErrorMessageList.Count(); i++) { //Adds an item to the string errorMessageString.Append(ErrorMessageList[i]); //adds comma separation between each item. If it is the last item in the list, then a period is added. errorMessageString.Append(i != lastItem ? ",\n " : "."); } } return(errorMessageString); }
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; } }
internal BacktrackErrorMessage(Position position, ErrorMessageList errors) { Position = position; Errors = errors; }
public static ErrorMessage Backtrack(Position position, ErrorMessageList errors) => new BacktrackErrorMessage(position, errors);
public void AddErrorMessage(string message) { ErrorMessageList.Add(message); }
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); }
public Parsed(T value, TokenStream unparsedTokens, ErrorMessageList potentialErrors) { Value = value; UnparsedTokens = unparsedTokens; ErrorMessages = potentialErrors; }
protected override bool DoValidation(ErrorMessageList errorList) { bool valid = true; if (string.IsNullOrEmpty(LegacyProject) && LegacyPlugins.Count == 0) { valid = false; AddError(errorList, "SolutionFolder", "Please specify either a legacy project or some discrete plugins."); } return (base.DoValidation(errorList) & valid); }
protected override bool DoValidation(ErrorMessageList errorList) { bool result = base.DoValidation(errorList); if (string.IsNullOrEmpty(this.Query)) { result = false; EditableBase.AddError(errorList, "Query", string.Format(Saleslogix.Social.Mashups.Properties.Resources.PropertyCannotBeEmpty, SR.GetString("TwitterProcessor_Query_DisplayName"))); } else { if (this._query.Error != null) { result = false; EditableBase.AddError(errorList, "Query", string.Format("{0}: {1}", SR.GetString("TwitterProcessor_Query_DisplayName"), this._query.Error)); } } return result; }
public LabeledParser(Parser <T> parser, string expectation) { this.parser = parser; errors = ErrorMessageList.Empty.With(ErrorMessage.Expected(expectation)); }
private void TransferNow_OnDoWork(object sender, DoWorkEventArgs e) { var usvm = e.Argument as UpdateSourceElementViewModel; if (usvm != null) { usvm.CurrentSize = 0; var totalSize = ServiceManager.TransferToServerAgent(new TransferToAgentDataRequest { SourceUrl = usvm.UpdateSourceUrl, UpdateSourceId = usvm.Id }); usvm.TotalSize = (int)totalSize; usvm.ProgressVisible = true; var aTimer = new Timer(); aTimer.Elapsed += delegate { if (usvm.CurrentSize < usvm.TotalSize - CalculateSizeOnTenPercent(usvm.TotalSize)) { usvm.CurrentSize += 1; } }; aTimer.Interval = 1000; aTimer.Enabled = true; var timeOut = 60 * 10000; //10 minutes while (true) { var dataRequest = new StringAuthenticateObject { StringAuth = "OK", StringValue = usvm.Id.ToString() }; var dataResponse = ServiceManager.Invoke( sc => RequestResponseUtils.GetData <TransferDataResponse>(sc.GetTransferStatus, dataRequest)); //Break when unable execute transfer to Agent if (dataResponse.FileSize < 0) { ErrorMessageList.AddRange(dataResponse.ErrorMessage.Select(c => string.Format("[{0}]: {1}", usvm.UpdateSourceName, c))); usvm.CurrentSize = 0; usvm.ProgressVisible = false; aTimer.Enabled = false; aTimer.Stop(); e.Result = null; break; } if (timeOut == 0 || totalSize == dataResponse.FileSize) { //Timeout or transfer complete aTimer.Enabled = false; aTimer.Stop(); e.Result = usvm; break; } Thread.Sleep(1000); timeOut -= 1000; } } }