/// <summary> /// Cria a instancia com o nome do indice não encontrado. /// </summary> /// <param name="indexName"></param> public IndexNotFoundException(string indexName) : base(ResourceMessageFormatter.Create(() => Properties.Resources.IndexNotFoundException_Message, indexName)) { }
/// <summary> /// Método acionado quando ocorre uma falha ao carregar /// um assembly para o sistema. /// </summary> /// <param name="e"></param> public void FailOnLoadAssembly(FailOnLoadAssemblyArgs e) { _logger.Error(ResourceMessageFormatter.Create(() => Properties.Resources.LoggerAssemblyRepositoryCatalogObserver_FailOnAssembly, e.AssemblyName.FullName, e.Error.Message), e.Error); }
/// <summary> /// Formata texto de um <see cref="ConditionalTerm"/> /// </summary> /// <param name="conditionalTerm">Termo condicional</param> /// <param name="sqlCommand">Objeto <see cref="StringBuilder"/> no qual será adicionado texto</param> /// <returns>Retorna o próprio objeto</returns> private MySqlPersistenceSqlParser Format(ConditionalTerm conditionalTerm, StringBuilder sqlCommand) { if (conditionalTerm is Constant) { Append(((Constant)conditionalTerm).Text, sqlCommand); } else if (conditionalTerm is Column) { Format((Column)conditionalTerm, sqlCommand); } else if (conditionalTerm is Variable) { var variable = (Variable)conditionalTerm; var parameter = Action != null?Action.Parameters.Where(f => f.Name == variable.Name).FirstOrDefault() : null; if (parameter != null && (parameter.Value is QueryInfo || parameter.Value is Colosoft.Query.Queryable)) { this.Action.Parameters.Remove(parameter); var value = parameter.Value; if (value is Colosoft.Query.Queryable) { value = ((Colosoft.Query.Queryable)value).CreateQueryInfo(); } Format(new QueryTerm((QueryInfo)value), sqlCommand); } else { Append(((Variable)conditionalTerm).Name, sqlCommand); } } else if (conditionalTerm is ValuesArray) { var values = (ValuesArray)conditionalTerm; if (values.Values != null && values.Values.Length == 1 && values.Values[0] is Variable) { var variable = (Variable)values.Values[0]; var parameter = Action != null?Action.Parameters.Where(f => f.Name == variable.Name).FirstOrDefault() : null; if (parameter != null && (parameter.Value is QueryInfo || parameter.Value is Colosoft.Query.Queryable)) { this.Action.Parameters.Remove(parameter); var value = parameter.Value; if (value is Colosoft.Query.Queryable) { value = ((Colosoft.Query.Queryable)value).CreateQueryInfo(); } Format(new QueryTerm((QueryInfo)value), sqlCommand); values = null; } } if (values != null) { Append(conditionalTerm.ToString(), sqlCommand); } } else if (conditionalTerm is ConditionalContainer) { Format((ConditionalContainer)conditionalTerm, sqlCommand); } else if (conditionalTerm is QueryTerm) { Format((QueryTerm)conditionalTerm, sqlCommand); } else if (conditionalTerm is FunctionCall) { var f = (FunctionCall)conditionalTerm; var name = f.Call.ToString().Replace("'", String.Empty); if (StringComparer.InvariantCultureIgnoreCase.Equals(name, "DATEADD") && f.Parameters.Length == 3) { sqlCommand.Append("DATE_ADD("); Format(f.Parameters[2], sqlCommand); sqlCommand.Append(", INTERVAL "); Format(f.Parameters[1], sqlCommand); sqlCommand.Append(' '); Format(f.Parameters[0], sqlCommand); sqlCommand.Append(')'); } else { if (StringComparer.InvariantCultureIgnoreCase.Equals(name, "ISNULL")) { name = "COALESCE"; } Append(name, sqlCommand); Append('(', sqlCommand); var gone = false; foreach (var paramTerm in f.Parameters) { if (gone) { Append(", ", sqlCommand); } else { gone = true; } if (paramTerm != null) { Format(paramTerm, sqlCommand); } else { Append("NULL", sqlCommand); } } Append(')', sqlCommand); } } else if (conditionalTerm is Formula) { Format((Formula)conditionalTerm, sqlCommand); } else if (conditionalTerm is MinusTerm) { sqlCommand.Append("-"); Format(((MinusTerm)conditionalTerm).Term, sqlCommand); } else if (conditionalTerm is Conditional) { Format((Conditional)conditionalTerm, sqlCommand); } else { throw new NotSupportedException(ResourceMessageFormatter.Create(() => Properties.Resources.NotSupportedException_TypeOfConditionalTermNotSupported, conditionalTerm.GetType().ToString()).Format()); } return(this); }
/// <summary> /// Formata texto de um <see cref="ConditionalTerm"/> /// </summary> /// <param name="conditionalTerm">Termo condicional</param> /// <param name="sqlCommand">Objeto <see cref="StringBuilder"/> no qual será adicionado texto</param> /// <returns>Retorna o próprio objeto</returns> private OraclePersistenceSqlParser Format(ConditionalTerm conditionalTerm, StringBuilder sqlCommand) { if (conditionalTerm is Constant) { Append(((Constant)conditionalTerm).Text, sqlCommand); } else if (conditionalTerm is Column) { Format((Column)conditionalTerm, sqlCommand); } else if (conditionalTerm is Variable) { var variable = (Variable)conditionalTerm; var parameter = Action != null?Action.Parameters.Where(f => f.Name == variable.Name).FirstOrDefault() : null; Colosoft.Query.QueryParameter queryParameter = null; if (parameter == null && Action != null && Action.Conditional != null) { queryParameter = Action.Conditional.ParameterContainer.FirstOrDefault(f => f.Name == variable.Name); if (queryParameter != null) { parameter = new PersistenceParameter(queryParameter.Name, queryParameter.Value); } } if (parameter != null && (parameter.Value is QueryInfo || parameter.Value is Colosoft.Query.Queryable)) { if (queryParameter == null) { this.Action.Parameters.Remove(parameter); } else if (Action.Conditional.ParameterContainer is Colosoft.Query.IQueryParameterContainerExt) { ((Colosoft.Query.IQueryParameterContainerExt)Action.Conditional.ParameterContainer).Remove(queryParameter); } var value = parameter.Value; if (value is Colosoft.Query.Queryable) { value = ((Colosoft.Query.Queryable)value).CreateQueryInfo(); } Format(new QueryTerm((QueryInfo)value), sqlCommand); } else { Append(((Variable)conditionalTerm).Name, sqlCommand); } } else if (conditionalTerm is ValuesArray) { var values = (ValuesArray)conditionalTerm; if (values.Values != null && values.Values.Length == 1 && values.Values[0] is Variable) { var variable = (Variable)values.Values[0]; var parameter = Action != null?Action.Parameters.Where(f => f.Name == variable.Name).FirstOrDefault() : null; Colosoft.Query.QueryParameter queryParameter = null; if (parameter == null && Action != null && Action.Conditional != null) { queryParameter = Action.Conditional.ParameterContainer.FirstOrDefault(f => f.Name == variable.Name); if (queryParameter != null) { parameter = new PersistenceParameter(queryParameter.Name, queryParameter.Value); } } if (parameter != null && (parameter.Value is QueryInfo || parameter.Value is Colosoft.Query.Queryable)) { if (queryParameter == null) { this.Action.Parameters.Remove(parameter); } else if (Action.Conditional.ParameterContainer is Colosoft.Query.IQueryParameterContainerExt) { ((Colosoft.Query.IQueryParameterContainerExt)Action.Conditional.ParameterContainer).Remove(queryParameter); } var value = parameter.Value; if (value is Colosoft.Query.Queryable) { value = ((Colosoft.Query.Queryable)value).CreateQueryInfo(); } Format(new QueryTerm((QueryInfo)value), sqlCommand); values = null; } } if (values != null) { Append(conditionalTerm.ToString(), sqlCommand); } } else if (conditionalTerm is ConditionalContainer) { Format((ConditionalContainer)conditionalTerm, sqlCommand); } else if (conditionalTerm is QueryTerm) { Format((QueryTerm)conditionalTerm, sqlCommand); } else if (conditionalTerm is FunctionCall) { var f = (FunctionCall)conditionalTerm; var name = f.Call.ToString().Replace("'", String.Empty); Append(name, sqlCommand); Append('(', sqlCommand); var gone = false; foreach (var paramTerm in f.Parameters) { if (gone) { Append(", ", sqlCommand); } else { gone = true; } if (paramTerm != null) { Format(paramTerm, sqlCommand); } else { Append("NULL", sqlCommand); } } Append(')', sqlCommand); } else if (conditionalTerm is Formula) { Format((Formula)conditionalTerm, sqlCommand); } else if (conditionalTerm is MinusTerm) { sqlCommand.Append("-"); Format(((MinusTerm)conditionalTerm).Term, sqlCommand); } else if (conditionalTerm is Conditional) { Format((Conditional)conditionalTerm, sqlCommand); } else { throw new NotSupportedException(ResourceMessageFormatter.Create(() => Database.Properties.Resources.NotSupportedException_TypeOfConditionalTermNotSupported, conditionalTerm.GetType().ToString()).Format()); } return(this); }
/// <summary> /// Para a execução. /// </summary> /// <param name="message"></param> private void StopExecution(string message) { this.LogError(ResourceMessageFormatter.Create(() => Properties.Resources.HttpServiceHost_ServiceHostStops, message)); }
/// <summary> /// Formata a mensagem do erro. /// </summary> /// <param name="descriptor"></param> /// <returns></returns> private static string FormatMessage(Record.RecordDescriptor descriptor) { return(ResourceMessageFormatter.Create(() => Properties.Resources.InvalidRecordChecksumException_Message, string.Join("; ", descriptor.Select(f => f.Name).ToArray())).Format()); }
/// <summary> /// Executa a consulta. /// </summary> /// <returns>Resultado na forma de um vetor de <see cref="QueryResult"/></returns> public IEnumerable <IQueryResult> Execute() { _dataSource.Require("_dataSource").NotNull(); QueryInfo[] info = CreateQueryInfos(); IEnumerable <IQueryResult> result = null; try { result = _dataSource.Execute(info); } catch (Exception ex) { for (int i = 0; i < _queries.Count; i++) { QueryCallBackWrapper callback; if (_callbacks.TryGetValue(i, out callback)) { callback.ExecuteFailedCallBack(this, info[i], new QueryFailedInfo(QueryFailedReason.Error, ex.Message.GetFormatter(), ex)); } } throw; } for (int i = 0; i < _queries.Count; i++) { _queries[i].Parameters = info[i].Parameters; } if (_callbacks.Where(f => f.Value != null).Any()) { var result2 = new List <IQueryResult>(); try { var position = 0; var processed = 0; using (var resultEnumerator = result.GetEnumerator()) { for (processed = 0; processed < _queries.Count && resultEnumerator.MoveNext(); processed++) { for (position = 0; position < info.Length; position++) { if (info[position].Id == resultEnumerator.Current.Id) { break; } } QueryCallBackWrapper callback; if (_callbacks.TryGetValue(position, out callback)) { var queryResult = resultEnumerator.Current; callback.ExecuteCallBack(this, info[position], queryResult); result2.Add(new QueryResult()); } else { using (var recordEnumerator = resultEnumerator.Current.GetEnumerator()) { if (recordEnumerator.MoveNext()) { var records = new List <Record>(); records.Add(recordEnumerator.Current); while (recordEnumerator.MoveNext()) { records.Add(recordEnumerator.Current); } result2.Add(new QueryResult(records[0].Descriptor, records, _queries[position])); } else { result2.Add(new QueryResult()); } } } } if (processed < _queries.Count) { throw new QueryException(ResourceMessageFormatter.Create(() => Properties.Resources.MultiQueryable_MultiQueryableExecuteErrorProcess).Format()); } } } finally { if (result is IDisposable) { if (!(result is IDisposableState) || !((IDisposableState)result).IsDisposed) { ((IDisposable)result).Dispose(); } } } result = result2; } return(result); }
/// <summary> /// Executa um comando de delete no banco de dados. /// </summary> /// <param name="commandText">Texto do comando a ser executado.</param> /// <param name="action">Informação da ação de persistência.</param> /// <param name="transaction">Transação do comando.</param> /// <param name="primaryKeyMappings">Dicionário que mapeia ids virtuais para reais.</param> /// <returns>Retorna resultado da ação de persistência.</returns> protected virtual PersistenceActionResult ExecuteDeleteCommand(string commandText, PersistenceAction action, IPersistenceTransactionExecuter transaction, Dictionary <int, int> primaryKeyMappings) { var trans = (PersistenceTransactionExecuter)transaction; var typeMetadata = TypeSchema.GetTypeMetadata(action.EntityFullName); bool hasRowVersion = typeMetadata.IsVersioned && (action.Conditional == null); var actionParameters = action.Parameters.Where(f => !(f.Value is PropertyReference || f.Value is ExpressionParameter || f.Value is QueryInfo || f.Value is Colosoft.Query.Queryable)); var conditionalParameters = action.Conditional != null?action.Conditional.Where(f => !(f.Value is PropertyReference || f.Value is ExpressionParameter || f.Value is QueryInfo || f.Value is Colosoft.Query.Queryable) && !actionParameters.Any(x => x.Name == f.Name)).ToArray() : new QueryParameter[0]; int parameterCount = conditionalParameters.Where(f => !actionParameters.Any(x => x.Name == f.Name)).Count() + actionParameters.Count(); if (hasRowVersion) { parameterCount++; } var parameters = new GDAParameter[parameterCount]; var index = 0; if (action.Conditional == null) { foreach (var actionParameter in actionParameters) { var propertyMetadata = typeMetadata[actionParameter.Name]; if (propertyMetadata == null) { parameters[index++] = CreateParameter(!string.IsNullOrEmpty(actionParameter.Name) && actionParameter.Name.StartsWith("?") ? actionParameter.Name : '?' + actionParameter.Name, actionParameter.Value); } else { parameters[index++] = CreateParameter('?' + propertyMetadata.Name, actionParameter.Value); } } } else { foreach (var param in conditionalParameters.Where(f => !actionParameters.Any(x => x.Name == f.Name))) { parameters[index] = CreateParameter(param.Name, param.Value); index++; } foreach (var param in actionParameters) { parameters[index] = CreateParameter(param.Name, param.Value); index++; } } if (hasRowVersion) { parameters[index] = CreateParameter('?' + DataAccessConstants.RowVersionPropertyName, action.RowVersion, 0, (System.Data.ParameterDirection)((int)Colosoft.Query.ParameterDirection.InputOutput)); } var da = new DataAccess(trans.Transaction.ProviderConfiguration); int affectedRows = 0; try { affectedRows = da.ExecuteCommand(trans.Transaction, CommandType.Text, action.CommandTimeout, commandText, parameters); } catch (GDAException ex) { Exception ex2 = ex; if (ex.InnerException is System.Data.Common.DbException || ex.InnerException is DataException) { ex2 = ex.InnerException; } ex2 = new DataException(ResourceMessageFormatter.Create(() => Properties.Resources.Exception_ExecuteDatabaseCommand, ex2.Message).Format(), ex2); action.NotifyError(ex2); return(new PersistenceActionResult { Success = false, AffectedRows = -1, FailureMessage = ex2.Message }); } if (affectedRows == 0 && hasRowVersion) { return new PersistenceActionResult { Success = false, AffectedRows = -1, FailureMessage = ResourceMessageFormatter.Create(() => Properties.Resources.Exception_RowsNotAffected, typeMetadata.FullName, action.RowVersion).Format() } } ; action.NotifyExecution(); var actionResult = new PersistenceActionResult() { Success = true, AffectedRows = affectedRows, Parameters = action.Parameters.ToArray(), ActionId = action.ActionId, RowVersion = (hasRowVersion) ? (long)action.RowVersion : 0 }; return(actionResult); }
/// <summary> /// Executa um comando de update no banco de dados. /// </summary> /// <param name="commandText">Texto do comando a ser executado.</param> /// <param name="action">Informação da ação de persistência.</param> /// <param name="transaction">Transação do comando.</param> /// <param name="primaryKeyMappings">Dicionário que mapeia ids virtuais para reais.</param> /// <returns>Retorna resultado da ação de persistência.</returns> protected virtual PersistenceActionResult ExecuteUpdateCommand(string commandText, PersistenceAction action, IPersistenceTransactionExecuter transaction, Dictionary <int, int> primaryKeyMappings) { var trans = (PersistenceTransactionExecuter)transaction; var typeMetadata = TypeSchema.GetTypeMetadata(action.EntityFullName); bool hasRowVersion = typeMetadata.IsVersioned && (action.Conditional == null); var actionParameters = action.Parameters.Where(f => !(f.Value is PropertyReference || f.Value is ExpressionParameter || f.Value is QueryInfo || f.Value is Colosoft.Query.Queryable)); var volatileProperties = typeMetadata.GetVolatileProperties().ToArray(); var onlyResultProperties = volatileProperties.Where(f => !action.Parameters.Any(g => g.Name == f.Name)).ToArray(); int parameterCount = actionParameters.Count(); if (action.Conditional != null) { parameterCount += action.Conditional.Where(f => !(f.Value is PropertyReference || f.Value is ExpressionParameter || f.Value is QueryInfo || f.Value is Colosoft.Query.Queryable) && !actionParameters.Any(x => x.Name == f.Name)).Count(); } if (action.Query != null) { parameterCount += action.Query.Parameters.Where(f => !(f.Value is PropertyReference || f.Value is ExpressionParameter || f.Value is QueryInfo || f.Value is Colosoft.Query.Queryable) && !actionParameters.Any(x => x.Name == f.Name)).Count(); } if (hasRowVersion) { parameterCount++; } var resultParameters = new PersistenceParameter[action.Parameters.Count + onlyResultProperties.Length]; var parameters = new GDAParameter[parameterCount]; int index = 0; foreach (var actionParameter in actionParameters) { var propertyMetadata = typeMetadata[actionParameter.Name]; if (propertyMetadata == null) { parameters[index] = CreateParameter(!string.IsNullOrEmpty(actionParameter.Name) && actionParameter.Name.StartsWith("?") ? actionParameter.Name : '?' + actionParameter.Name, actionParameter.Value); } else { parameters[index] = CreateParameter('?' + propertyMetadata.Name, actionParameter.Value); } if (actionParameter.DbType != DbType.AnsiString) { parameters[index].DbType = actionParameter.DbType; } resultParameters[index] = actionParameter; if (volatileProperties.Any(p => p.Name == actionParameter.Name)) { parameters[index].Direction = System.Data.ParameterDirection.InputOutput; } index++; } index = actionParameters.Count(); if (action.Conditional == null) { var index2 = index; foreach (var property in onlyResultProperties) { resultParameters[index2++] = new PersistenceParameter(property.Name, string.Empty, Query.ParameterDirection.Output); } } else { foreach (var param in action.Conditional.Where(f => !(f.Value is PropertyReference || f.Value is ExpressionParameter || f.Value is QueryInfo || f.Value is Colosoft.Query.Queryable) && !actionParameters.Any(x => x.Name == f.Name))) { parameters[index++] = CreateParameter(param.Name, param.Value); } } if (action.Query != null) { foreach (var param in action.Query.Parameters.Where(f => !(f.Value is PropertyReference || f.Value is ExpressionParameter || f.Value is QueryInfo || f.Value is Colosoft.Query.Queryable) && !actionParameters.Any(x => x.Name == f.Name))) { parameters[index++] = CreateParameter(param.Name, param.Value); } } if (hasRowVersion) { parameters[index++] = CreateParameter('?' + DataAccessConstants.RowVersionPropertyName, action.RowVersion, 0, System.Data.ParameterDirection.Input); } //// Recupera o parametro para recuperar a quantidade de linhas afetadas var da = new DataAccess(trans.Transaction.ProviderConfiguration); int affectedRows = 0; try { affectedRows = da.ExecuteCommand(trans.Transaction, CommandType.Text, action.CommandTimeout, commandText, parameters); } catch (GDAException ex) { Exception ex2 = ex; if (ex.InnerException is System.Data.Common.DbException || ex.InnerException is DataException) { ex2 = ex.InnerException; } ex2 = new DataException(ResourceMessageFormatter.Create(() => Properties.Resources.Exception_ExecuteDatabaseCommand, ex2.Message).Format(), ex2); action.NotifyError(ex2); return(new PersistenceActionResult { Success = false, AffectedRows = -1, FailureMessage = ex2.Message }); } if (affectedRows == 0 && hasRowVersion) { return new PersistenceActionResult { Success = false, AffectedRows = -1, FailureMessage = ResourceMessageFormatter.Create(() => Database.Generic.Properties.Resources.Exception_RowsNotAffected, typeMetadata.FullName, action.RowVersion).Format(), } } ; var actionResult = new PersistenceActionResult() { Success = true, AffectedRows = affectedRows, Parameters = resultParameters, ActionId = action.ActionId, RowVersion = (hasRowVersion) ? (long)parameters[parameters.Length - 1].Value : 0 }; return(actionResult); }
/// <summary> /// Executa um comando de insert no banco de dados. /// </summary> /// <param name="commandText">Texto do comando a ser executado.</param> /// <param name="action">Informação da ação de persistência.</param> /// <param name="transaction">Transação do comando.</param> /// <param name="primaryKeyMappings">Dicionário que mapeia ids virtuais para reais.</param> /// <returns>Retorna resultado da ação de persistência.</returns> protected virtual PersistenceActionResult ExecuteInsertCommand(string commandText, PersistenceAction action, IPersistenceTransactionExecuter transaction, Dictionary <int, int> primaryKeyMappings) { var trans = (PersistenceTransactionExecuter)transaction; var typeMetadata = TypeSchema.GetTypeMetadata(action.EntityFullName); bool hasRowVersion = typeMetadata.IsVersioned; var onlyResultProperties = typeMetadata.GetVolatileProperties().Where(f => action.Parameters.Count(g => g.Name == f.Name) == 0); int onlyResultCount = onlyResultProperties.Count(); int parameterCount = action.Parameters.Count + onlyResultCount; if (hasRowVersion) { parameterCount++; } var resultParameters = new PersistenceParameter[action.Parameters.Count + onlyResultCount]; var parameters = new GDAParameter[parameterCount + onlyResultCount]; for (int i = 0; i < action.Parameters.Count; i++) { parameters[i] = CreateParameter('?' + action.Parameters[i].Name, action.Parameters[i].Value); if (action.Parameters[i].DbType != DbType.AnsiString) { parameters[i].DbType = action.Parameters[i].DbType; } resultParameters[i] = action.Parameters[i]; } int index = action.Parameters.Count; foreach (var property in onlyResultProperties) { parameters[index] = CreateParameter('?' + property.Name, "", 0, System.Data.ParameterDirection.InputOutput); resultParameters[index] = new PersistenceParameter(property.Name, ""); index++; } if (hasRowVersion) { parameters[index] = CreateParameter('?' + DataAccessConstants.RowVersionPropertyName, action.RowVersion, 0, System.Data.ParameterDirection.Output); } int affectedRows = 0; try { var da = new DataAccess(trans.Transaction.ProviderConfiguration); affectedRows = da.ExecuteCommand(trans.Transaction, CommandType.Text, action.CommandTimeout, commandText, parameters); } catch (Exception ex) { Exception ex2 = ex; if (ex.InnerException is System.Data.Common.DbException || ex.InnerException is DataException) { ex2 = ex.InnerException; } ex = new DataException(ResourceMessageFormatter.Create(() => Properties.Resources.Exception_ExecuteDatabaseCommand, ex2.Message).Format(), ex2); action.NotifyError(ex); return(new PersistenceActionResult() { Success = false, AffectedRows = affectedRows, ActionId = action.ActionId, FailureMessage = ex.Message, RowVersion = (hasRowVersion) ? (long)parameters[parameters.Length - 1].Value : 0 }); } var keyRepository = GetKeyRepository(trans.ProviderName); if (keyRepository.IsPosCommand(action.EntityFullName)) { IPropertyMetadata identityMetadata = typeMetadata.GetKeyProperties().FirstOrDefault(); if (identityMetadata != null && identityMetadata.ParameterType == Schema.PersistenceParameterType.IdentityKey) { for (int i = 0; i < parameters.Length; i++) { if (action.Parameters[i].Name == identityMetadata.Name) { int identityValue = 0; var key = keyRepository.GetPrimaryKey(transaction, typeMetadata.FullName); if (key is int) { identityValue = (int)key; } else if (key is uint) { identityValue = (int)(uint)key; } else { identityValue = Convert.ToInt32(key); } parameters[i].Value = identityValue; var virtualIdValue = action.Parameters[i].Value; int virtualId = 0; if (virtualIdValue is int) { virtualId = (int)virtualIdValue; } else if (virtualIdValue is uint) { virtualId = (int)(uint)virtualIdValue; } else { virtualId = Convert.ToInt32(virtualIdValue); } action.Parameters[i].Value = identityValue; primaryKeyMappings.Add(virtualId, identityValue); break; } } } } action.NotifyExecution(); return(new PersistenceActionResult() { Success = true, AffectedRows = affectedRows, Parameters = resultParameters, ActionId = action.ActionId, RowVersion = (hasRowVersion) ? (long)parameters[parameters.Length - 1].Value : 0 }); }
/// <summary> /// Recupera as propriedades da string informada. /// </summary> /// <param name="propString"></param> /// <returns></returns> private Hashtable GetProperties(string propString) { bool flag = false; Hashtable hashtable = new Hashtable(); Tokenizer tokenizer = new Tokenizer(propString); string tokenValue = ""; int num = 0; State keyNeeded = State.keyNeeded; Stack stack = new Stack(); while (true) { switch (tokenizer.GetNextToken()) { case Tokenizer.UNNEST: if (keyNeeded != State.keyNeeded) { throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_CloseParanthesisMisplaced).Format()); } if (num < 1) { throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_CloseParenthesisUnexpected).Format()); } if (flag) { flag = false; } hashtable = stack.Pop() as Hashtable; num--; continue; case Tokenizer.ID: int num2; switch (keyNeeded) { case State.keyNeeded: if (tokenValue == "parameters") { flag = true; } tokenValue = tokenizer.TokenValue; num2 = tokenizer.GetNextToken(); if (((num2 == Tokenizer.CONTINUE) || (num2 == Tokenizer.UNNEST)) || ((num2 == Tokenizer.ID) || (num2 == Tokenizer.EOF))) { throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_KeyFollowingBadToken).Format()); } switch (num2) { case Tokenizer.ASSIGN: keyNeeded = State.valNeeded; continue; case Tokenizer.NEST: stack.Push(hashtable); hashtable[tokenValue.ToLower()] = new Hashtable(); hashtable = hashtable[tokenValue.ToLower()] as Hashtable; keyNeeded = State.keyNeeded; num++; break; } continue; case State.valNeeded: { string str2 = tokenizer.TokenValue; num2 = tokenizer.GetNextToken(); keyNeeded = State.keyNeeded; switch (num2) { case Tokenizer.ASSIGN: case Tokenizer.ID: case Tokenizer.EOF: throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_ValueFollowingBadToken).Format()); } if (flag) { hashtable[tokenValue] = str2; } else { hashtable[tokenValue.ToLower()] = str2; } switch (num2) { case Tokenizer.NEST: stack.Push(hashtable); hashtable[tokenValue.ToLower()] = new Hashtable(); hashtable = hashtable[tokenValue.ToLower()] as Hashtable; hashtable.Add("id", tokenValue); hashtable.Add("type", str2); keyNeeded = State.keyNeeded; num++; break; case Tokenizer.UNNEST: if (num < 1) { throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_CloseParenthesisUnexpected).Format()); } if (flag) { flag = false; } hashtable = stack.Pop() as Hashtable; num--; keyNeeded = State.keyNeeded; break; } continue; } } continue; case Tokenizer.EOF: if (keyNeeded != State.keyNeeded) { throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_InvalidEOF).Format()); } if (num > 0) { throw new ConfigurationException("Invalid property string, un-matched paranthesis"); } return(hashtable); } throw new ConfigurationException("Invalid property string"); } }