Exemplo n.º 1
0
        private IFunctionData UpdateToVersion2(IFunctionData data)
        {
            IPropertyData parametersProperty;

            if (data.TryFindPropertyById(ExecuteStoredProcedureShared.ParametersPropertyName, out parametersProperty))
            {
                DatabaseModel.ProcedureParameters parameterValues = parametersProperty.Value as DatabaseModel.ProcedureParameters;
                if (parameterValues != null)
                {
                    foreach (DatabaseModel.ProcedureParameter parameter in parameterValues)
                    {
                        IPropertyData parameterProperty;
                        if (data.TryFindPropertyById(parameter.Name, out parameterProperty))
                        {
                            data = data.UpdateProperty(parameterProperty,
                                                       parameter.DisplayPropertyId, parameter.DisplayPropertyName, parameterProperty.TypeReference, parameterProperty.Value, parameterProperty.IsVisible, parameterProperty.ValueUsage);
                        }
                    }
                }
            }

            return(data.UpdateVersion("2"));
        }
Exemplo n.º 2
0
        private IFunctionData AddMissingProperties(IFunctionData data)
        {
            IPropertyData loopResultsProperty;

            if (data.FindPropertyById(MongoDBMapReduceShared.Names.ReturnOptionsPropertyName) == null)
            {
                MongoDBMapReduceShared.ReturnModeType returnModeType = MongoDBMapReduceShared.ReturnModeType.ListOfRows;
                if (data.TryFindPropertyById("LoopResults", out loopResultsProperty))
                {
                    returnModeType = loopResultsProperty.GetValue <bool>() ? MongoDBMapReduceShared.ReturnModeType.RowByRow : MongoDBMapReduceShared.ReturnModeType.ListOfRows;
                    data           = data.RemoveProperty(data.FindPropertyById("LoopResults"));
                }
                data = data.AddProperty(new Property(MongoDBMapReduceShared.Names.ReturnOptionsPropertyName, typeof(MongoDBMapReduceShared.ReturnModeType), ValueUseOption.DesignTime, returnModeType)
                {
                    IsVisible = true
                });
            }

            return(data);
        }
Exemplo n.º 3
0
        private IFunctionData UpdateToVersion2(IFunctionData data)
        {
            IPropertyData loopResultsProperty;

            if (data.FindPropertyById(MongoDBReadShared.Names.ReturnOptionsPropertyName) == null)
            {
                MongoDBReadShared.ReturnModeType returnModeType = MongoDBReadShared.ReturnModeType.ListOfRows;
                if (data.TryFindPropertyById("LoopResults", out loopResultsProperty))
                {
                    returnModeType = loopResultsProperty.GetValue <bool>() ? MongoDBReadShared.ReturnModeType.RowByRow : MongoDBReadShared.ReturnModeType.ListOfRows;
                    data           = data.RemoveProperty(data.FindPropertyById("LoopResults"));
                }
                data = data.AddProperty(new Property(MongoDBReadShared.Names.ReturnOptionsPropertyName, typeof(MongoDBReadShared.ReturnModeType), ValueUseOption.DesignTime, returnModeType)
                {
                    IsVisible = true
                });
            }

            data = ChangeExecutionPathKey(data);
            return(data.UpdateVersion("2"));
        }
Exemplo n.º 4
0
        private IFunctionData TransformConnectionTypeProperty(IFunctionData data)
        {
            IPropertyData connectionTypeProperty;

            if (data.TryFindPropertyById(DbShared.ConnectionTypePropertyName, out connectionTypeProperty))
            {
                if (connectionTypeProperty.TypeReference.IsCompiled && connectionTypeProperty.TypeReference.GetUnderlyingType() == typeof(ConnectionTypeSelection))
                {
                    return(data);
                }

                var newConnectionTypeProperty = new Property(DbShared.ConnectionTypePropertyName, typeof(ConnectionTypeSelection), ValueUseOption.DesignTime, ConnectionTypeSelection.SqlServer)
                {
                    Value     = connectionTypeProperty.GetValue <ConnectionType>().ToConnectionTypeSelection(),
                    IsVisible = connectionTypeProperty.IsVisible
                };

                data = data.ReplaceProperty(connectionTypeProperty, newConnectionTypeProperty);
            }

            return(data);
        }
Exemplo n.º 5
0
        private IFunctionData AddMissingProperties(IFunctionData data)
        {
            IPropertyData criteriaProperty;
            IPropertyData aggregationPipelineProperty;

            object criteria            = string.Empty;
            object aggregationPipeline = string.Empty;

            MongoDBReadShared.OperationType operationType = MongoDBReadShared.OperationType.Find;

            if (data.TryFindPropertyById("Criteria", out criteriaProperty) &&
                data.TryFindPropertyById("Aggregation pipeline", out aggregationPipelineProperty))
            {
                criteria            = criteriaProperty.Value;
                aggregationPipeline = aggregationPipelineProperty.Value;

                if (string.IsNullOrEmpty(criteria.ToString()) && !string.IsNullOrEmpty(aggregationPipeline.ToString()))
                {
                    operationType = MongoDBReadShared.OperationType.Aggregate;
                }
                data = data.RemoveProperty(criteriaProperty);
                data = data.RemoveProperty(aggregationPipelineProperty);
            }

            if (data.FindPropertyById(MongoDBReadShared.Names.Operation) == null)
            {
                data = data.AddProperty(new Property(MongoDBReadShared.Names.Operation, typeof(MongoDBReadShared.OperationType), ValueUseOption.DesignTime, operationType));
            }

            if (data.FindPropertyById(MongoDBReadShared.Names.AggregationPipeline) == null)
            {
                data = data.AddProperty(new Property(MongoDBReadShared.Names.AggregationPipeline, typeof(string), ValueUseOption.RuntimeRead, aggregationPipeline)
                {
                    IsVisible = true
                });
            }

            if (data.FindPropertyById(MongoDBReadShared.Names.Query) == null)
            {
                data = data.AddProperty(new Property(MongoDBReadShared.Names.Query, typeof(string), ValueUseOption.RuntimeRead, criteria)
                {
                    IsVisible = true
                });
            }

            if (data.FindPropertyById(MongoDBReadShared.Names.Fields) == null)
            {
                data = data.AddProperty(new Property(MongoDBReadShared.Names.Fields, typeof(string), ValueUseOption.RuntimeRead, string.Empty)
                {
                    IsVisible = true
                });
            }

            if (data.FindPropertyById(MongoDBReadShared.Names.Sort) == null)
            {
                data = data.AddProperty(new Property(MongoDBReadShared.Names.Sort, typeof(string), ValueUseOption.RuntimeRead, string.Empty)
                {
                    IsVisible = true
                });
            }

            if (data.FindPropertyById(MongoDBReadShared.Names.Skip) == null)
            {
                data = data.AddProperty(new Property(MongoDBReadShared.Names.Skip, typeof(int), ValueUseOption.RuntimeRead, 0)
                {
                    IsVisible = true
                });
            }

            if (data.FindPropertyById(MongoDBReadShared.Names.Limit) == null)
            {
                data = data.AddProperty(new Property(MongoDBReadShared.Names.Limit, typeof(int), ValueUseOption.RuntimeRead, 0)
                {
                    IsVisible = true
                });
            }

            string        criteriaExpressionKey = "CriteriaExpression";
            List <string> criteriaExpressionIDs = data.Properties.Keys.Where(key => key.StartsWith(criteriaExpressionKey)).ToList();

            foreach (string criteriaExpressionID in criteriaExpressionIDs)
            {
                IPropertyData criteriaExpressionProperty = data.Properties[criteriaExpressionID];
                string        queryExpressionName        = criteriaExpressionID.Replace(criteriaExpressionKey, MongoDBReadShared.Names.QueryExpressions);
                data = data.AddProperty(new Property(queryExpressionName, criteriaExpressionProperty.TypeReference, criteriaExpressionProperty.ValueUsage, criteriaExpressionProperty.Value)
                {
                    IsVisible = criteriaExpressionProperty.IsVisible
                });
                data = data.RemoveProperty(criteriaExpressionProperty);
            }

            return(data);
        }