예제 #1
0
        public ResultElement <DataRow> DataRowExecute(string sqlQuery)
        {
            var result = new ResultElement <DataRow>()
            {
                Element = null
            };

            try
            {
                var res = DataSetExecute(sqlQuery);
                if (res.Element == null)
                {
                    return(result);
                }
                var dataSet = res.Element;
                if (dataSet.Tables[0].Rows.Count > 0)
                {
                    result.Element = dataSet.Tables[0].Rows[0];
                }
            }
            catch (Exception ex)
            {
                var mensaje = ex.Message;
                result.Errors.Add(_codigoErrorException);
                result.Errors.Add(mensaje);
                if (Logger != null)
                {
                    var msj = $"Error en {GetType().Name}.{System.Reflection.MethodBase.GetCurrentMethod().Name}: {mensaje}.";
                    Logger.Error(msj);
                }
            }
            return(result);
        }
예제 #2
0
        public async Task <ResultElement <ParametroDto> > Crear(ParametroDto dto)
        {
            var result = new ResultElement <ParametroDto>();

            try
            {
                //var entity = new Parametro()
                //{
                //    Empresa = dto.Empresa,
                //    FechaProceso = dto.FechaProceso
                //};

                //var response = await _repo.Crear(entity);
                //if (response.HasErrors)
                //{
                //    result.Errors = response.Errors;
                //    return result;
                //}

                //var ele = response.Element;

                //result.Element = new ParametroDto()
                //{
                //    Empresa = ele.Empresa,
                //    FechaProceso = ele.FechaProceso
                //};
            }
            catch (Exception ex)
            {
                result.AddError(KeysConfiguration.ErrorBusinessException, ex.Message);
            }
            return(result);
        }
예제 #3
0
        public virtual IQueryState Accept(AggregateQueryExpression exp)
        {
            List <DbExpression> dbArguments = new List <DbExpression>(exp.Arguments.Count);

            foreach (Expression argument in exp.Arguments)
            {
                var arg = (LambdaExpression)argument;
                ScopeParameterDictionary scopeParameters = this._resultElement.ScopeParameters.Clone(arg.Parameters[0], this._resultElement.MappingObjectExpression);

                var dbArgument = GeneralExpressionVisitor.ParseLambda(arg, scopeParameters, this._resultElement.ScopeTables);
                dbArguments.Add(dbArgument);
            }

            DbAggregateExpression  dbAggregateExp = new DbAggregateExpression(exp.ElementType, exp.Method, dbArguments);
            MappingFieldExpression mfe            = new MappingFieldExpression(exp.ElementType, dbAggregateExp);

            ResultElement result = new ResultElement(this._resultElement.ScopeParameters, this._resultElement.ScopeTables);

            result.MappingObjectExpression = mfe;
            result.FromTable = this._resultElement.FromTable;
            result.AppendCondition(this._resultElement.Condition);

            AggregateQueryState state = new AggregateQueryState(result);

            return(state);
        }
예제 #4
0
 JoinQueryExpressionVisitor(ResultElement resultElement, JoinType joinType, LambdaExpression conditionExpression, ScopeParameterDictionary scopeParameters)
 {
     this._resultElement       = resultElement;
     this._joinType            = joinType;
     this._conditionExpression = conditionExpression;
     this._scopeParameters     = scopeParameters;
 }
예제 #5
0
 JoinQueryExpressionVisitor(ResultElement resultElement, DbJoinType joinType, LambdaExpression conditionExpression, List <IMappingObjectExpression> moeList)
 {
     this._resultElement       = resultElement;
     this._joinType            = joinType;
     this._conditionExpression = conditionExpression;
     this._moeList             = moeList;
 }
예제 #6
0
        public ResultElement <int> PutData(string sqlQuery, OracleTransaction oracleTransaction)
        {
            var result = new ResultElement <int>();

            try
            {
                _sqlComand = new OracleCommand(sqlQuery, oracleTransaction.Connection)
                {
                    Transaction = oracleTransaction
                };
                var executeScalarResult = _sqlComand.ExecuteScalar();
                result.Element = Convert.ToInt32(executeScalarResult);
            }
            catch (Exception ex)
            {
                var mensaje = ex.Message;
                result.Errors.Add(_codigoErrorException);
                result.Errors.Add(mensaje);
                if (Logger != null)
                {
                    var msj = $"Error en {GetType().Name}.{System.Reflection.MethodBase.GetCurrentMethod().Name}: {mensaje}.";
                    Logger.Error(msj);
                }
            }
            finally
            {
                _sqlComand = null;
            }
            return(result);
        }
예제 #7
0
        static ResultElement CreateResultElement(Type type)
        {
            //TODO init _resultElement
            ResultElement resultElement = new ResultElement();

            TypeDescriptor typeDescriptor = TypeDescriptor.GetDescriptor(type);

            string alias = resultElement.GenerateUniqueTableAlias(typeDescriptor.Table.Name);

            resultElement.FromTable = CreateRootTable(typeDescriptor.Table, alias);
            MappingObjectExpression moe = new MappingObjectExpression(typeDescriptor.EntityType.GetConstructor(Type.EmptyTypes));

            DbTableSegment tableExp = resultElement.FromTable.Table;
            DbTable        table    = new DbTable(alias);

            foreach (MappingMemberDescriptor item in typeDescriptor.MappingMemberDescriptors.Values)
            {
                DbColumnAccessExpression columnAccessExpression = new DbColumnAccessExpression(table, item.Column);

                moe.AddMemberExpression(item.MemberInfo, columnAccessExpression);
                if (item.IsPrimaryKey)
                {
                    moe.PrimaryKey = columnAccessExpression;
                }
            }

            resultElement.MappingObjectExpression = moe;

            return(resultElement);
        }
예제 #8
0
        private static BindAckPDU GetRPCBindResponse(BindPDU bindPDU, RemoteService service)
        {
            BindAckPDU bindAckPDU = new BindAckPDU();

            PrepareReply(bindAckPDU, bindPDU);
            // See DCE 1.1: Remote Procedure Call - 12.6.3.6
            // The client should set the assoc_group_id field either to 0 (zero), to indicate a new association group,
            // or to the known value. When the server receives a value of 0, this indicates that the client
            // has requested a new association group, and it assigns a server unique value to the group.
            if (bindPDU.AssociationGroupID == 0)
            {
                bindAckPDU.AssociationGroupID = m_associationGroupID;
                m_associationGroupID++;
                if (m_associationGroupID == 0)
                {
                    m_associationGroupID++;
                }
            }
            else
            {
                bindAckPDU.AssociationGroupID = bindPDU.AssociationGroupID;
            }
            bindAckPDU.SecondaryAddress        = @"\PIPE\" + service.PipeName;
            bindAckPDU.MaxReceiveFragmentSize  = bindPDU.MaxReceiveFragmentSize;
            bindAckPDU.MaxTransmitFragmentSize = bindPDU.MaxTransmitFragmentSize;
            foreach (ContextElement element in bindPDU.ContextList)
            {
                ResultElement resultElement = new ResultElement();
                if (element.AbstractSyntax.InterfaceUUID.Equals(service.InterfaceGuid))
                {
                    int index = IndexOfSupportedTransferSyntax(element.TransferSyntaxList);
                    if (index >= 0)
                    {
                        resultElement.Result         = NegotiationResult.Acceptance;
                        resultElement.TransferSyntax = element.TransferSyntaxList[index];
                    }
                    else if (element.TransferSyntaxList.Contains(new SyntaxID(BindTimeFeatureIdentifier3, 1)))
                    {
                        // [MS-RPCE] 3.3.1.5.3
                        // If the server supports bind time feature negotiation, it MUST reply with the result
                        // field in the p_result_t structure of the bind_ack PDU equal to negotiate_ack.
                        resultElement.Result = NegotiationResult.NegotiateAck;
                        resultElement.Reason = RejectionReason.AbstractSyntaxNotSupported;
                    }
                    else
                    {
                        resultElement.Result = NegotiationResult.ProviderRejection;
                        resultElement.Reason = RejectionReason.ProposedTransferSyntaxesNotSupported;
                    }
                }
                else
                {
                    resultElement.Result = NegotiationResult.ProviderRejection;
                    resultElement.Reason = RejectionReason.AbstractSyntaxNotSupported;
                }
                bindAckPDU.ResultList.Add(resultElement);
            }

            return(bindAckPDU);
        }
예제 #9
0
 public SearchResult(ResultElement resultElement)
 {
     if (resultElement.user.name != null)
     {
         _person = new Person.Person(resultElement.user);
         _person.PropertyChanged += PersonOnPropertyChanged;
     }
 }
예제 #10
0
        public ResultElement <DataSet> DataSetExecuteStoreProcedure(string nameStoreProcedure, int fetchSize, params OracleParameter[] parameters)
        {
            var result = new ResultElement <DataSet>()
            {
                Element = null
            };

            try
            {
                if (!OpenConnection())
                {
                    result.Errors.Add(_errorOpenConection);
                    return(result);
                }
                var command = new OracleCommand
                {
                    Connection  = OracleConnection,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = nameStoreProcedure,
                    BindByName  = true,
                };

                command.FetchSize = command.FetchSize * fetchSize;

                if (parameters != null)
                {
                    foreach (var p in parameters)
                    {
                        command.Parameters.Add(p);
                    }
                }
                using (var oracleDataAdapter = new OracleDataAdapter(command))
                {
                    var dataSet = new DataSet(DatasetName);
                    oracleDataAdapter.Fill(dataSet);
                    result.Element = dataSet;
                }
            }
            catch (Exception ex)
            {
                var mensaje = ex.Message;
                result.Errors.Add(_codigoErrorException);
                result.Errors.Add(mensaje);
                if (Logger != null)
                {
                    var msj = $"Error en {GetType().Name}.{System.Reflection.MethodBase.GetCurrentMethod().Name}: {mensaje}.";
                    Logger.Error(msj);
                }
            }
            finally
            {
                CloseConnection();
            }
            return(result);
        }
예제 #11
0
        public virtual GeneralQueryState AsSubQueryState()
        {
            DbSqlQueryExpression sqlQuery = this.CreateSqlQuery();
            DbSubQueryExpression subQuery = new DbSubQueryExpression(sqlQuery);

            ResultElement result = new ResultElement();

            DbTableSegment        tableSeg  = new DbTableSegment(subQuery, result.GenerateUniqueTableAlias());
            DbFromTableExpression fromTable = new DbFromTableExpression(tableSeg);

            result.FromTable = fromTable;

            DbTable table = new DbTable(tableSeg.Alias);

            //TODO 根据旧的生成新 MappingMembers
            IMappingObjectExpression newMoe = this.Result.MappingObjectExpression.ToNewObjectExpression(sqlQuery, table);

            result.MappingObjectExpression = newMoe;

            //得将 subQuery.SqlQuery.Orders 告诉 以下创建的 result
            //将 orderPart 传递下去
            if (this.Result.Orderings.Count > 0)
            {
                for (int i = 0; i < this.Result.Orderings.Count; i++)
                {
                    DbOrdering   ordering    = this.Result.Orderings[i];
                    DbExpression orderingExp = ordering.Expression;

                    string alias = null;

                    DbColumnSegment columnExpression = sqlQuery.ColumnSegments.Where(a => DbExpressionEqualityComparer.EqualsCompare(orderingExp, a.Body)).FirstOrDefault();

                    // 对于重复的则不需要往 sqlQuery.Columns 重复添加了
                    if (columnExpression != null)
                    {
                        alias = columnExpression.Alias;
                    }
                    else
                    {
                        alias = Utils.GenerateUniqueColumnAlias(sqlQuery);
                        DbColumnSegment columnSeg = new DbColumnSegment(orderingExp, alias);
                        sqlQuery.ColumnSegments.Add(columnSeg);
                    }

                    DbColumnAccessExpression columnAccessExpression = new DbColumnAccessExpression(orderingExp.Type, table, alias);
                    result.Orderings.Add(new DbOrdering(columnAccessExpression, ordering.OrderType));
                }
            }

            result.InheritOrderings = true;

            GeneralQueryState queryState = new GeneralQueryState(result);

            return(queryState);
        }
예제 #12
0
        public override IQueryState Visit(JoinQueryExpression exp)
        {
            ResultElement resultElement = new ResultElement();

            IQueryState     qs = QueryExpressionVisitor.VisitQueryExpression(exp.PrevExpression);
            FromQueryResult fromQueryResult = qs.ToFromQueryResult();

            DbFromTableExpression fromTable = fromQueryResult.FromTable;

            resultElement.FromTable = fromTable;

            List <IMappingObjectExpression> moeList = new List <IMappingObjectExpression>();

            moeList.Add(fromQueryResult.MappingObjectExpression);

            foreach (JoiningQueryInfo joiningQueryInfo in exp.JoinedQueries)
            {
                JoinQueryResult joinQueryResult = JoinQueryExpressionVisitor.VisitQueryExpression(joiningQueryInfo.Query.QueryExpression, resultElement, joiningQueryInfo.JoinType, joiningQueryInfo.Condition, moeList);

                var nullChecking = DbExpression.CaseWhen(new DbCaseWhenExpression.WhenThenExpressionPair(joinQueryResult.JoinTable.Condition, DbConstantExpression.One), DbConstantExpression.Null, DbConstantExpression.One.Type);

                if (joiningQueryInfo.JoinType == JoinType.LeftJoin)
                {
                    joinQueryResult.MappingObjectExpression.SetNullChecking(nullChecking);
                }
                else if (joiningQueryInfo.JoinType == JoinType.RightJoin)
                {
                    foreach (IMappingObjectExpression item in moeList)
                    {
                        item.SetNullChecking(nullChecking);
                    }
                }
                else if (joiningQueryInfo.JoinType == JoinType.FullJoin)
                {
                    joinQueryResult.MappingObjectExpression.SetNullChecking(nullChecking);
                    foreach (IMappingObjectExpression item in moeList)
                    {
                        item.SetNullChecking(nullChecking);
                    }
                }

                fromTable.JoinTables.Add(joinQueryResult.JoinTable);
                moeList.Add(joinQueryResult.MappingObjectExpression);
            }

            IMappingObjectExpression moe = SelectorExpressionVisitor.ResolveSelectorExpression(exp.Selector, moeList);

            resultElement.MappingObjectExpression = moe;

            GeneralQueryState queryState = new GeneralQueryState(resultElement);

            return(queryState);
        }
예제 #13
0
        public override ResultElement ToFromQueryResult()
        {
            if (this.Result.Condition == null)
            {
                ResultElement result = new ResultElement(this.Result.ScopeParameters, this.Result.ScopeTables);
                result.FromTable = this.Result.FromTable;
                result.MappingObjectExpression = this.Result.MappingObjectExpression;
                return(result);
            }

            return(base.ToFromQueryResult());
        }
예제 #14
0
        static ResultElement CreateResultElement(Type type, string explicitTableName)
        {
            if (type.IsAbstract || type.IsInterface)
            {
                throw new ArgumentException("The type of input can not be abstract class or interface.");
            }

            //TODO init _resultElement
            ResultElement resultElement = new ResultElement();

            TypeDescriptor typeDescriptor = TypeDescriptor.GetDescriptor(type);

            DbTable dbTable = typeDescriptor.Table;

            if (explicitTableName != null)
            {
                dbTable = new DbTable(explicitTableName, dbTable.Schema);
            }
            string alias = resultElement.GenerateUniqueTableAlias(dbTable.Name);

            resultElement.FromTable = CreateRootTable(dbTable, alias);

            ConstructorInfo constructor = typeDescriptor.EntityType.GetConstructor(Type.EmptyTypes);

            if (constructor == null)
            {
                throw new ArgumentException(string.Format("The type of '{0}' does't define a none parameter constructor.", type.FullName));
            }

            MappingObjectExpression moe = new MappingObjectExpression(constructor);

            DbTableSegment tableExp = resultElement.FromTable.Table;
            DbTable        table    = new DbTable(alias);

            foreach (MappingMemberDescriptor item in typeDescriptor.MappingMemberDescriptors.Values)
            {
                DbColumnAccessExpression columnAccessExpression = new DbColumnAccessExpression(table, item.Column);

                moe.AddMappingMemberExpression(item.MemberInfo, columnAccessExpression);
                if (item.IsPrimaryKey)
                {
                    moe.PrimaryKey = columnAccessExpression;
                }
            }

            resultElement.MappingObjectExpression = moe;

            return(resultElement);
        }
예제 #15
0
        public ResultElement <ParametroDto> GetLastParametro()
        {
            var result = new ResultElement <ParametroDto>();

            try
            {
                //var res = _repo.GetLastParametro();
                //result = res;
            }
            catch (Exception ex)
            {
                result.AddError(KeysConfiguration.ErrorBusinessException, ex.Message);
            }
            return(result);
        }
예제 #16
0
        //public ServiceParametros(IRepoParametros pRepository)
        //{
        //    _repo = pRepository ?? throw new ArgumentNullException(nameof(pRepository));
        //}

        #endregion

        #region General

        public async Task <ResultElement <ParametroDto> > Editar(ParametroDto dto)
        {
            var result = new ResultElement <ParametroDto>();

            try
            {
                //var res = await _repo.Editar(dto);
                //result = res;
            }
            catch (Exception ex)
            {
                result.AddError(KeysConfiguration.ErrorBusinessException, ex.Message);
            }
            return(result);
        }
예제 #17
0
        public async Task <ResultElement <PersonaDto> > ObtenerAsync(PersonaDto dto)
        {
            var result = new ResultElement <PersonaDto>();
            //var entity = await _uow.Personas.AsNoTracking()
            //                             .Include(x => x.Propiedad_One)
            //                             .ThenInclude(y => y.Propiedad_Two)
            //                             .SingleOrDefaultAsync(x => x.Id.Equals(dto.Id));
            var entity = await _uow.Personas.AsNoTracking()
                         .SingleOrDefaultAsync(x => x.Id.Equals(dto.Id));

            if (entity != null)
            {
                result.Element = _mapperConfig.CreateMapper().Map <PersonaDto>(entity);
            }
            return(result);
        }
예제 #18
0
        public virtual ResultElement CreateNewResult(LambdaExpression selector)
        {
            ResultElement result = new ResultElement(this._resultElement.ScopeParameters, this._resultElement.ScopeTables);
            result.FromTable = this._resultElement.FromTable;

            ScopeParameterDictionary scopeParameters = this._resultElement.ScopeParameters.Clone(selector.Parameters[0], this._resultElement.MappingObjectExpression);

            IMappingObjectExpression r = SelectorExpressionVisitor.ResolveSelectorExpression(selector, scopeParameters, this._resultElement.ScopeTables);
            result.MappingObjectExpression = r;
            result.Orderings.AddRange(this._resultElement.Orderings);
            result.AppendCondition(this._resultElement.Condition);

            result.GroupSegments.AddRange(this._resultElement.GroupSegments);
            result.AppendHavingCondition(this._resultElement.HavingCondition);

            return result;
        }
예제 #19
0
        public virtual ResultElement CreateNewResult(LambdaExpression selector)
        {
            ResultElement result = new ResultElement();

            result.FromTable = this._resultElement.FromTable;

            IMappingObjectExpression r = SelectorExpressionVisitor.VisitSelectExpression(selector, this.MoeList);

            result.MappingObjectExpression = r;
            result.Orderings.AddRange(this._resultElement.Orderings);
            result.AppendCondition(this._resultElement.Condition);

            result.GroupSegments.AddRange(this._resultElement.GroupSegments);
            result.AppendHavingCondition(this._resultElement.HavingCondition);

            return(result);
        }
예제 #20
0
        public virtual ResultElement ToFromQueryResult()
        {
            ResultElement result = new ResultElement(this._resultElement.ScopeParameters, this._resultElement.ScopeTables);

            string alias = result.GenerateUniqueTableAlias(UtilConstants.DefaultTableAlias);
            DbSqlQueryExpression sqlQuery = this.CreateSqlQuery();
            DbSubQueryExpression subQuery = new DbSubQueryExpression(sqlQuery);

            DbTableSegment        tableSeg  = new DbTableSegment(subQuery, alias, LockType.Unspecified);
            DbFromTableExpression fromTable = new DbFromTableExpression(tableSeg);

            DbTable table = new DbTable(tableSeg.Alias);
            IMappingObjectExpression newMoe = this.Result.MappingObjectExpression.ToNewObjectExpression(sqlQuery, table);

            result.FromTable = fromTable;
            result.MappingObjectExpression = newMoe;
            return(result);
        }
예제 #21
0
        /// <summary>
        /// Helper Method which accepts a single GoogleSearchResult.ResultElement
        /// then formats the results into an html string
        /// </summary>
        /// <param name="resultToFormat">string</param>
        /// <returns>string - formated html results</returns>
        private string FormatResults(ResultElement resultToFormat)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<p><b><u><a href=");
            sb.Append(resultToFormat.URL);
            sb.Append(" target=new>");
            sb.Append(resultToFormat.title);
            sb.Append("</a></u></b></p>");
            sb.Append("<p>");
            sb.Append(resultToFormat.snippet);
            sb.Append("<br>");
            sb.Append(resultToFormat.URL);
            sb.Append("&nbsp;");
            sb.Append(resultToFormat.cachedSize);
            sb.Append("</p>");

            return(sb.ToString());
        }
예제 #22
0
        public ResultElement <DataSet> DataSetExecute(string sqlQuery)
        {
            var result = new ResultElement <DataSet>()
            {
                Element = null
            };

            try
            {
                if (!OpenConnection())
                {
                    result.Errors.Add(_errorOpenConection);
                    return(result);
                }
                var oracleCommand = base.OracleConnection.CreateCommand();
                oracleCommand.CommandType = CommandType.Text;
                oracleCommand.CommandText = sqlQuery;
                using (var oracleDataAdapter = new OracleDataAdapter(oracleCommand))
                {
                    var dataSet = new DataSet(DatasetName);
                    oracleDataAdapter.Fill(dataSet);
                    result.Element = dataSet;
                }
            }
            catch (Exception ex)
            {
                var mensaje = ex.Message;
                result.Errors.Add(_codigoErrorException);
                result.Errors.Add(mensaje);
                if (Logger != null)
                {
                    var msj = $"Error en {GetType().Name}.{System.Reflection.MethodBase.GetCurrentMethod().Name}: {mensaje}.";
                    Logger.Error(msj);
                }
            }
            finally
            {
                CloseConnection();
            }
            return(result);
        }
예제 #23
0
        public ResultElement <int> PutData(string sqlQuery, OracleConnection oracleConexion)
        {
            var result = new ResultElement <int>();

            try
            {
                var moComand = new OracleCommand(sqlQuery, oracleConexion);
                result.Element = moComand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                var mensaje = ex.Message;
                result.Errors.Add(_codigoErrorException);
                result.Errors.Add(mensaje);
                if (Logger != null)
                {
                    var msj = $"Error en {GetType().Name}.{System.Reflection.MethodBase.GetCurrentMethod().Name}: {mensaje}.";
                    Logger.Error(msj);
                }
            }
            return(result);
        }
예제 #24
0
        Hit FromGoogleResultElement(ResultElement res, int rank)
        {
            Hit hit = new Hit();

            hit.Uri      = new Uri(res.URL, true);
            hit.Type     = "Google";
            hit.MimeType = "text/html";             // FIXME
            hit.Source   = "Google";

            // FIXME: We don't get scoring information from Google
            // other than the ranks.  This is a hack.
            hit.Score = 0.2f / (1 + rank);

            hit ["Summary"]        = res.summary;
            hit ["Snippet"]        = res.snippet;
            hit ["Title"]          = res.title;
            hit ["CachedSize"]     = res.cachedSize;
            hit ["HostName"]       = res.hostName;
            hit ["DirectoryTitle"] = res.directoryTitle;

            return(hit);
        }
예제 #25
0
		Hit FromGoogleResultElement (ResultElement res, int rank)
		{
			Hit hit = new Hit ();

			hit.Uri      = new Uri (res.URL, true);
			hit.Type     = "Google";
			hit.MimeType = "text/html"; // FIXME
			hit.Source   = "Google";

			// FIXME: We don't get scoring information from Google
			// other than the ranks.  This is a hack.
			hit.Score    = 0.2f / (1 + rank);

			hit ["Summary"]        = res.summary;
			hit ["Snippet"]        = res.snippet;
			hit ["Title"]          = res.title;
			hit ["CachedSize"]     = res.cachedSize;
			hit ["HostName"]       = res.hostName;
			hit ["DirectoryTitle"] = res.directoryTitle;

			return hit;
		}
        /// <summary>
        ///
        /// </summary>
        /// <param name="re">The result element containing the data</param>
        /// <param name="values">The values to be plotted</param>
        /// <param name="dir">The direction in which the plot should go</param>
        /// <param name="sFac">Scaling factor for the graph</param>
        private List <Curve> CreateCurvesFromResults(ResultElement re, List <double> values, Vector3d dir, double sFac)
        {
            List <Curve> crvs = new List <Curve>();

            // Get points on original element
            List <Point3d> basePts = new List <Point3d>();
            List <Point3d> pts     = new List <Point3d>();

            Rhino.Geometry.Vector3d elX     = re.LocalX;
            List <double>           lengths = re.pos;

            foreach (double l in lengths)
            {
                Vector3d vec = l * elX;
                Point3d  pt  = new Point3d(re.sPos.X + vec.X, re.sPos.Y + vec.Y, re.sPos.Z + vec.Z);
                pts.Add(pt);
                basePts.Add(pt);
            }

            // Move points to get curve points
            for (int i = 0; i < values.Count; i++)
            {
                pts[i] = pts[i] + dir * sFac * values[i];
            }

            // Create curve and add it to _dispCrvs
            crvs.Add(Rhino.Geometry.Curve.CreateInterpolatedCurve(pts, 3));
            crvs.Add(Rhino.Geometry.Curve.CreateInterpolatedCurve(basePts, 1));
            for (int i = 0; i < pts.Count; i++)
            {
                crvs.Add(new Rhino.Geometry.Line(basePts[i], pts[i]).ToNurbsCurve());
            }

            // Add points to bounding box
            _bbPts.AddRange(pts);

            return(crvs);
        }
예제 #27
0
        public virtual IQueryState Accept(FunctionExpression exp)
        {
            List <DbExpression> dbParameters = new List <DbExpression>(exp.Parameters.Count);

            foreach (Expression pExp in exp.Parameters)
            {
                var dbExp = GeneralExpressionVisitor.VisitPredicate((LambdaExpression)pExp, this.MoeList);
                dbParameters.Add(dbExp);
            }

            DbFunctionExpression   dbFuncExp = new DbFunctionExpression(exp.ElementType, exp.Method, dbParameters);
            MappingFieldExpression mfe       = new MappingFieldExpression(exp.ElementType, dbFuncExp);

            ResultElement result = new ResultElement();

            result.MappingObjectExpression = mfe;
            result.FromTable = this._resultElement.FromTable;
            result.AppendCondition(this._resultElement.Condition);

            FunctionQueryState state = new FunctionQueryState(result);

            return(state);
        }
예제 #28
0
 public virtual IQueryState CreateQueryState(ResultElement result)
 {
     return new GeneralQueryState(result);
 }
예제 #29
0
        public virtual GeneralQueryState AsSubQueryState()
        {
            DbSqlQueryExpression sqlQuery = this.CreateSqlQuery();
            DbSubQueryExpression subQuery = new DbSubQueryExpression(sqlQuery);

            ResultElement result = new ResultElement();

            DbTableSegment tableSeg = new DbTableSegment(subQuery, result.GenerateUniqueTableAlias());
            DbFromTableExpression fromTable = new DbFromTableExpression(tableSeg);

            result.FromTable = fromTable;

            DbTable table = new DbTable(tableSeg.Alias);

            //TODO 根据旧的生成新 MappingMembers
            IMappingObjectExpression newMoe = this.Result.MappingObjectExpression.ToNewObjectExpression(sqlQuery, table);
            result.MappingObjectExpression = newMoe;

            //得将 subQuery.SqlQuery.Orders 告诉 以下创建的 result
            //将 orderPart 传递下去
            if (this.Result.OrderSegments.Count > 0)
            {
                for (int i = 0; i < this.Result.OrderSegments.Count; i++)
                {
                    DbOrderSegment orderPart = this.Result.OrderSegments[i];
                    DbExpression orderExp = orderPart.DbExpression;

                    string alias = null;

                    DbColumnSegment columnExpression = sqlQuery.ColumnSegments.Where(a => DbExpressionEqualityComparer.EqualsCompare(orderExp, a.Body)).FirstOrDefault();

                    // 对于重复的则不需要往 sqlQuery.Columns 重复添加了
                    if (columnExpression != null)
                    {
                        alias = columnExpression.Alias;
                    }
                    else
                    {
                        alias = Utils.GenerateUniqueColumnAlias(sqlQuery);
                        DbColumnSegment columnSeg = new DbColumnSegment(orderExp, alias);
                        sqlQuery.ColumnSegments.Add(columnSeg);
                    }

                    DbColumnAccessExpression columnAccessExpression = new DbColumnAccessExpression(orderExp.Type, table, alias);
                    result.OrderSegments.Add(new DbOrderSegment(columnAccessExpression, orderPart.OrderType));
                }
            }

            result.IsOrderSegmentsFromSubQuery = true;

            GeneralQueryState queryState = new GeneralQueryState(result);
            return queryState;
        }
예제 #30
0
        public virtual IQueryState Accept(SelectExpression exp)
        {
            ResultElement result = this.CreateNewResult(exp.Selector);

            return(this.CreateQueryState(result));
        }
예제 #31
0
 protected QueryStateBase(ResultElement resultElement)
 {
     this._resultElement = resultElement;
 }
예제 #32
0
 public virtual IQueryState CreateQueryState(ResultElement result)
 {
     return(new GeneralQueryState(result));
 }
예제 #33
0
        public virtual ResultElement CreateNewResult(LambdaExpression selector)
        {
            ResultElement result = new ResultElement();
            result.FromTable = this._resultElement.FromTable;

            IMappingObjectExpression r = SelectorExpressionVisitor.VisitSelectExpression(selector, this.MoeList);
            result.MappingObjectExpression = r;
            result.OrderSegments.AddRange(this._resultElement.OrderSegments);
            result.AppendCondition(this._resultElement.Condition);

            result.GroupSegments.AddRange(this._resultElement.GroupSegments);
            result.AppendHavingCondition(this._resultElement.HavingCondition);

            return result;
        }
예제 #34
0
        public static JoinQueryResult VisitQueryExpression(QueryExpression queryExpression, ResultElement resultElement, DbJoinType joinType, LambdaExpression conditionExpression, List <IMappingObjectExpression> moeList)
        {
            JoinQueryExpressionVisitor visitor = new JoinQueryExpressionVisitor(resultElement, joinType, conditionExpression, moeList);

            return(queryExpression.Accept(visitor));
        }
예제 #35
0
 public GroupingQueryState(ResultElement resultElement)
     : base(resultElement)
 {
 }
예제 #36
0
 public LimitQueryState(ResultElement resultElement, int skipCount, int takeCount)
     : base(resultElement)
 {
     this.SkipCount = skipCount;
     this.TakeCount = takeCount;
 }
예제 #37
0
        public virtual IQueryState Accept(FunctionExpression exp)
        {
            List<DbExpression> dbParameters = new List<DbExpression>(exp.Parameters.Count);
            foreach (Expression pExp in exp.Parameters)
            {
                var dbExp = GeneralExpressionVisitor.VisitPredicate((LambdaExpression)pExp, this.MoeList);
                dbParameters.Add(dbExp);
            }

            DbFunctionExpression dbFuncExp = new DbFunctionExpression(exp.ElementType, exp.Method, dbParameters);
            MappingFieldExpression mfe = new MappingFieldExpression(exp.ElementType, dbFuncExp);

            ResultElement result = new ResultElement();

            result.MappingObjectExpression = mfe;
            result.FromTable = this._resultElement.FromTable;
            result.AppendCondition(this._resultElement.Condition);

            FunctionQueryState state = new FunctionQueryState(result);
            return state;
        }
예제 #38
0
 protected QueryStateBase(ResultElement resultElement)
 {
     this._resultElement = resultElement;
 }
예제 #39
0
 public override IQueryState CreateQueryState(ResultElement result)
 {
     return new LimitQueryState(result, this.SkipCount, this.TakeCount);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="re">The result element containing the data</param>
        /// <param name="values">The values to be plotted</param>
        /// <param name="dir">The direction in which the plot should go</param>
        /// <param name="sFac">Scaling factor for the graph</param>
        private List<Curve> CreateCurvesFromResults(ResultElement re, List<double> values, Vector3d dir, double sFac)
        {
            List<Curve> crvs = new List<Curve>();

            // Get points on original element
            List<Point3d> basePts = new List<Point3d>();
            List<Point3d> pts = new List<Point3d>();
            Rhino.Geometry.Vector3d elX = re.LocalX;
            List<double> lengths = re.pos;
            foreach (double l in lengths)
            {
                Vector3d vec = l * elX;
                Point3d pt = new Point3d(re.sPos.X + vec.X, re.sPos.Y + vec.Y, re.sPos.Z + vec.Z);
                pts.Add(pt);
                basePts.Add(pt);
            }

            // Move points to get curve points
            for (int i = 0; i < values.Count; i++)
                pts[i] = pts[i] + dir * sFac * values[i];

            // Create curve and add it to _dispCrvs
            crvs.Add(Rhino.Geometry.Curve.CreateInterpolatedCurve(pts, 3));
            crvs.Add(Rhino.Geometry.Curve.CreateInterpolatedCurve(basePts, 1));
            for (int i = 0; i < pts.Count; i++)
                crvs.Add(new Rhino.Geometry.Line(basePts[i], pts[i]).ToNurbsCurve());

            // Add points to bounding box
            _bbPts.AddRange(pts);

            return crvs;
        }