public void SavePermission(DataConnection connection, Permission permission)
        {
            List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>();
            ScreenDataCommandParameter        p          = null;


            p = new ScreenDataCommandParameter(ParameterPermissionName, permission.Name);
            parameters.Add(p);

            p = new ScreenDataCommandParameter(ParameterCategory, permission.Category);
            parameters.Add(p);

            p = new ScreenDataCommandParameter(ParameterDescription, permission.Description);
            parameters.Add(p);

            DataCommand command = DataCommand.GetDataCommand(DataCommandPermissionSave);



            if (command == null)
            {
                throw new Exception(String.Format("DataCommand {0} could not be found in configuration", DataCommandPermissionSave));
            }
            //execute command
            sql.ExecuteCommand(null, connection, command, parameters, command.Text);
        }
        private void ExecuteDataCommand(string dataCommand, List <ScreenDataCommandParameter> parameters)
        {
            if (Connection == null)
            {
                sql.ExecuteDataCommand(dataCommand, parameters);
            }
            else
            {
                DataCommand command = DataCommand.GetDataCommand(dataCommand);

                if (command == null)
                {
                    throw new Exception(String.Format("DataCommand {0} could not be found in configuration", dataCommand));
                }

                sql.ExecuteCommand(null, Connection, command, parameters, command.Text);
            }
        }
Пример #3
0
        public override void Execute(System.Data.Common.DbTransaction tran, string WorkflowCode, string FromWorkflowStepCode, string ToWorkflowStepCode, string EntityID, string Comment, string UserName)
        {
            //base.Execute(tran);


            DataCommandService dataCommandDB = DataCommandService.GetInstance();

            DataCommand command = DataCommand.GetDataCommand(this.ExecuteCommand);

            if (command == null)
            {
                throw new ApplicationException(String.Format("DataCommand {0} could not be found in configuration", this.ExecuteCommand));
            }


            List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>();
            ScreenDataCommandParameter        parameter  = null;

            if (!String.IsNullOrEmpty(this.WorkflowCodeParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = this.WorkflowCodeParameter;
                parameter.Value = WorkflowCode;
                parameters.Add(parameter);
            }

            if (!String.IsNullOrEmpty(this.FromWorkflowStepCodeParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = this.FromWorkflowStepCodeParameter;
                parameter.Value = FromWorkflowStepCode;
                parameters.Add(parameter);
            }

            if (!String.IsNullOrEmpty(this.ToWorkflowStepCodeParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = this.ToWorkflowStepCodeParameter;
                parameter.Value = ToWorkflowStepCode;
                parameters.Add(parameter);
            }

            if (!String.IsNullOrEmpty(this.EntityIDParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = this.EntityIDParameter;
                parameter.Value = EntityID;
                parameters.Add(parameter);
            }

            if (!String.IsNullOrEmpty(this.CommentParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = this.CommentParameter;
                parameter.Value = Comment;
                parameters.Add(parameter);
            }

            if (!String.IsNullOrEmpty(this.UsernameParameter))
            {
                parameter       = new ScreenDataCommandParameter();
                parameter.Name  = this.UsernameParameter;
                parameter.Value = UserName;
                parameters.Add(parameter);
            }

            //execute command with transaction
            //CommandType type = (command.Type == DataCommandCommandType.StoredProcedure) ? CommandType.StoredProcedure : CommandType.Text;
            object retVal = dataCommandDB.ExecuteCommand(tran, command, parameters, command.Text);
        }