예제 #1
0
        private static ConvertedQuery ConvertToMSSqlSyntax(ISqlFunctionInfo queryInfo, IDictionary <string, object> parameterNames)
        {
            ConvertedQuery convertedQuery = new ConvertedQuery();

            StringBuilder builder = new StringBuilder();

            foreach (string name in parameterNames.Keys)
            {
                builder.Append(name);
                builder.Append("|");
            }
            builder.Remove(builder.Length - 1, 1);
            string regExp = builder.ToString();

            MatchCollection collection = new Regex(regExp).Matches(queryInfo.Command);

            IDictionary <string, object> oleDbParams = new Dictionary <string, object>();
            int i = 1;

            foreach (Match match in collection)
            {
                oleDbParams.Add("@sp" + i, parameterNames[match.Value.Trim()]);
                i++;
            }

            convertedQuery.Parameters = oleDbParams;
            convertedQuery.Query      = queryInfo.Command;

            foreach (string name in parameterNames.Keys)
            {
                convertedQuery.Query = convertedQuery.Query.Replace(name, "?");
            }

            return(convertedQuery);
        }
        public Dictionary <EntityToken, IEnumerable <EntityToken> > GetParents(IEnumerable <EntityToken> entityTokens)
        {
            var result = new Dictionary <EntityToken, IEnumerable <EntityToken> >();

            foreach (EntityToken entityToken in entityTokens)
            {
                var dataEntityToken = entityToken as DataEntityToken;

                if (dataEntityToken.InterfaceType == typeof(ISqlFunctionInfo))
                {
                    ISqlFunctionInfo sqlFunctionInfo = dataEntityToken.Data as ISqlFunctionInfo;

                    var parentEntityToken = new SqlFunctionProviderFolderEntityToken(sqlFunctionInfo.Namespace, _context.ProviderName, sqlFunctionInfo.ConnectionId.ToString());

                    result.Add(entityToken, new EntityToken[] { parentEntityToken });
                }
                else if (dataEntityToken.InterfaceType == typeof(ISqlConnection))
                {
                    var parentEntityToken = new SqlFunctionProviderRootEntityToken(_context.ProviderName, _context.ProviderName);

                    result.Add(entityToken, new EntityToken[] { parentEntityToken });
                }
            }

            return(result);
        }
예제 #3
0
 private static bool ShouldConvert(ISqlFunctionInfo info, IDictionary <string, object> parameters)
 {
     if (info.IsStoredProcedure)
     {
         return(false);
     }
     if (parameters.Count == 0)
     {
         return(false);
     }
     return(true);
 }
        private void finalizeActivity_ExecuteCode(object sender, EventArgs e)
        {
            AddNewTreeRefresher addNewTreeRefresher = this.CreateAddNewTreeRefresher(this.EntityToken);

            ISqlFunctionInfo sqlFunctionInfo = this.GetBinding <ISqlFunctionInfo>("NewSqlQueryInfo");

            sqlFunctionInfo = DataFacade.AddNew <ISqlFunctionInfo>(sqlFunctionInfo);

            UserSettings.LastSpecifiedNamespace = sqlFunctionInfo.Namespace;

            addNewTreeRefresher.PostRefreshMesseges(sqlFunctionInfo.GetDataEntityToken());

            this.ExecuteWorklow(sqlFunctionInfo.GetDataEntityToken(), typeof(EditSqlFunctionProviderWorkflow));
        }
예제 #5
0
        private void EnsureUpdated()
        {
            if (Updated)
            {
                return;
            }

            ISqlFunctionInfo oldValue = _functionInfo;

            _functionInfo = (ISqlFunctionInfo)DataFacade.GetDataFromDataSourceId(_functionInfo.DataSourceId, true);

            Verify.That(_functionInfo != null, "Failed to get function '{0}'", oldValue.Name);

            Updated = true;
        }
        private void finalizeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            DataEntityToken token = this.EntityToken as DataEntityToken;

            ISqlFunctionInfo sqlFunctionInfo = (ISqlFunctionInfo)token.Data;

            if (DataFacade.WillDeleteSucceed(token.Data))
            {
                DeleteTreeRefresher treeRefresher = this.CreateDeleteTreeRefresher(this.EntityToken);

                DataFacade.Delete(sqlFunctionInfo);

                int count =
                    (from info in DataFacade.GetData <ISqlFunctionInfo>()
                     where info.Namespace == sqlFunctionInfo.Namespace
                     select info).Count();

                if (count == 0)
                {
                    ISqlConnection sqlConnection =
                        (from connection in DataFacade.GetData <ISqlConnection>()
                         where connection.Id == sqlFunctionInfo.ConnectionId
                         select connection).Single();

                    SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher();
                    specificTreeRefresher.PostRefreshMesseges(sqlConnection.GetDataEntityToken());
                }
                else
                {
                    treeRefresher.PostRefreshMesseges();
                }
            }
            else
            {
                this.ShowMessage(
                    DialogType.Error,
                    StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "CascadeDeleteErrorTitle"),
                    StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "CascadeDeleteErrorMessage")
                    );
            }
        }
        private void initialize_ExecuteCode(object sender, EventArgs e)
        {
            DataEntityToken token = this.EntityToken as DataEntityToken;

            ISqlFunctionInfo functionInfo = (ISqlFunctionInfo)token.Data;
            IEnumerable <ManagedParameterDefinition> parameters = ManagedParameterManager.Load(functionInfo.Id);

            this.Bindings.Add("SqlQuery", functionInfo);
            this.Bindings.Add("Parameters", parameters);
            this.Bindings.Add("ParameterTypeOptions", GetParameterTypes().ToList());

            // Creating a session state object
            Guid stateId = Guid.NewGuid();
            var  state   = new EditSqlFunctionState {
                WorkflowId = WorkflowInstanceId, ConsoleIdInternal = GetCurrentConsoleId()
            };

            SessionStateManager.DefaultProvider.AddState <IParameterEditorState>(stateId, state, DateTime.Now.AddDays(7.0));

            this.Bindings.Add("SessionStateProvider", SessionStateManager.DefaultProviderName);
            this.Bindings.Add("SessionStateId", stateId);
        }
        private void previewCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            try
            {
                ISqlFunctionInfo queryInfo = this.GetBinding <ISqlFunctionInfo>("SqlQuery");


                var           parameterDefinitions = this.GetBinding <IEnumerable <ManagedParameterDefinition> >("Parameters");
                ParameterList parameters           = ManagedParameterManager.GetParametersListForTest(parameterDefinitions);
                IEnumerable <ParameterProfile> parameterProfiles = ManagedParameterManager.GetParameterProfiles(parameterDefinitions);

                SqlFunction function = new SqlFunction(queryInfo, parameterProfiles);

                XElement result = function.Execute(parameters, new FunctionContextContainer()) as XElement;

                Page currentPage = HttpContext.Current.Handler as Page;
                if (currentPage == null)
                {
                    throw new InvalidOperationException("The Current HttpContext Handler must be a System.Web.Ui.Page");
                }

                UserControl inOutControl = (UserControl)currentPage.LoadControl(UrlUtils.ResolveAdminUrl("controls/Misc/MarkupInOutView.ascx"));
                inOutControl.Attributes.Add("out", result.ToString());

                FlowControllerServicesContainer serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
                var webRenderService = serviceContainer.GetService <IFormFlowWebRenderingService>();
                webRenderService.SetNewPageOutput(inOutControl);
            }
            catch (Exception ex)
            {
                FlowControllerServicesContainer serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId);
                Control errOutput        = new LiteralControl("<pre>" + ex.ToString() + "</pre>");
                var     webRenderService = serviceContainer.GetService <IFormFlowWebRenderingService>();
                webRenderService.SetNewPageOutput(errOutput);
            }
        }
        private void initializeActivity_ExecuteCode(object sender, EventArgs e)
        {
            string         namespaceName;
            ISqlConnection sqlConnection;

            if ((this.EntityToken is DataEntityToken))
            {
                DataEntityToken dataEntityToken = (DataEntityToken)this.EntityToken;

                namespaceName = UserSettings.LastSpecifiedNamespace;
                sqlConnection = (ISqlConnection)dataEntityToken.Data;
            }
            else if ((this.EntityToken is SqlFunctionProviderFolderEntityToken))
            {
                Guid connectionId = new Guid(((SqlFunctionProviderFolderEntityToken)this.EntityToken).ConnectionId);

                namespaceName = this.EntityToken.Id;
                sqlConnection = DataFacade.GetData <ISqlConnection>(x => x.Id == connectionId).First();
            }
            else
            {
                throw new NotImplementedException();
            }


            ISqlFunctionInfo sqlFunctionInfo = DataFacade.BuildNew <ISqlFunctionInfo>();

            sqlFunctionInfo.IsQuery      = true;
            sqlFunctionInfo.ConnectionId = sqlConnection.Id;
            sqlFunctionInfo.Id           = Guid.NewGuid();
            sqlFunctionInfo.Name         = "";
            sqlFunctionInfo.Namespace    = namespaceName;
            sqlFunctionInfo.Description  = "";

            this.Bindings.Add("NewSqlQueryInfo", sqlFunctionInfo);
        }
 public SqlNamespaceTreeBuilderLeafInfo(ISqlFunctionInfo sqlFunctionInfo)
 {
     _sqlFunctionInfo = sqlFunctionInfo;
 }
예제 #11
0
 /// <exclude />
 public SqlFunction(ISqlFunctionInfo functionInfo)
 {
     _functionInfo = functionInfo;
     Updated       = true;
 }
예제 #12
0
 private static bool ShouldConvert(ISqlFunctionInfo info, IDictionary<string, object> parameters)
 {
     if (info.IsStoredProcedure)
     {
         return false;
     }
     if (parameters.Count == 0)
     {
         return false;
     }
     return true;
 }
예제 #13
0
        private void EnsureUpdated()
        {
            if (Updated) return;

            ISqlFunctionInfo oldValue = _functionInfo;

            _functionInfo = (ISqlFunctionInfo) DataFacade.GetDataFromDataSourceId(_functionInfo.DataSourceId, true);

            Verify.That(_functionInfo != null, "Failed to get function '{0}'", oldValue.Name);

            Updated = true;
        }
예제 #14
0
 /// <exclude />
 public SqlFunction(ISqlFunctionInfo functionInfo, IEnumerable <ParameterProfile> parameterProfiles)
     : this(functionInfo)
 {
     _parameterProfiles = parameterProfiles;
 }
예제 #15
0
 /// <exclude />
 public SqlFunction(ISqlFunctionInfo functionInfo, IEnumerable<ParameterProfile> parameterProfiles)
     : this(functionInfo)
 {
     _parameterProfiles = parameterProfiles;
 }
예제 #16
0
 /// <exclude />
 public SqlFunction(ISqlFunctionInfo functionInfo)
 {
     _functionInfo = functionInfo;
     Updated = true;
 }
예제 #17
0
        private static ConvertedQuery ConvertToMSSqlSyntax(ISqlFunctionInfo queryInfo, IDictionary<string, object> parameterNames)
        {
            ConvertedQuery convertedQuery = new ConvertedQuery();

            StringBuilder builder = new StringBuilder();
            foreach (string name in parameterNames.Keys)
            {
                builder.Append(name);
                builder.Append("|");
            }
            builder.Remove(builder.Length - 1, 1);
            string regExp = builder.ToString();

            MatchCollection collection = new Regex(regExp).Matches(queryInfo.Command);

            IDictionary<string, object> oleDbParams = new Dictionary<string, object>();
            int i = 1;
            foreach (Match match in collection)
            {
                oleDbParams.Add("@sp" + i, parameterNames[match.Value.Trim()]);
                i++;
            }

            convertedQuery.Parameters = oleDbParams;
            convertedQuery.Query = queryInfo.Command;

            foreach (string name in parameterNames.Keys)
            {
                convertedQuery.Query = convertedQuery.Query.Replace(name, "?");
            }

            return convertedQuery;
        }