Beispiel #1
0
        public void Init(FlexDesignerHostServices provider, ReportParameter parameter)
        {
            _provider      = provider;
            _parameterName = parameter.Name;
            // _updating = true;

            var values     = parameter.AllowedValuesDefinition.Values;
            var labelIndex = c1FlexGrid1.Cols.Fixed;
            var valueIndex = labelIndex + 1;

            foreach (var value in values)
            {
                var row = c1FlexGrid1.Rows.Add();
                row[labelIndex] = ScriptValueHelper.ToString(value.Label);
                row[valueIndex] = ScriptValueHelper.ToString(value.Value);
            }

            c1FlexGrid1.Col = labelIndex;
            if (values.Count > 0)
            {
                c1FlexGrid1.Row = c1FlexGrid1.Rows.Fixed;
            }

            UpdateButtonsSatus();

            // _updating = false;
        }
Beispiel #2
0
        protected override void OnDropDownClosed(DropDownClosedEventArgs e)
        {
            base.OnDropDownClosed(e);

            if (_listBox.SelectedItem is ScriptValueList.ScriptEditorItem)
            {
                var scriptEditor = _provider.GetService(typeof(IScriptEditorService)) as IScriptEditorService;
                if (scriptEditor == null)
                {
                    return;
                }

                var scriptSource = _scriptSource;
                if (string.IsNullOrEmpty(scriptSource))
                {
                    scriptSource = _report.DataSourceName;
                }

                object result;
                scriptEditor.EditScript(_report, scriptSource, _kind, this, "Expression", _scriptName, true,
                                        out result);
            }
            else if (_listBox.SelectedItem is ScriptValueList.ValueItem)
            {
                var item = _listBox.SelectedItem as ScriptValueList.ValueItem;
                Expression =
                    ScriptValueHelper.TextToObject(item.Text, typeof(ScriptStringValue), item.IsExpression).ToString();
            }
        }
Beispiel #3
0
        protected override void OnDropDownOpened(EventArgs e)
        {
            base.OnDropDownOpened(e);

            DropDownForm.UpdatePerferedSize(Size);

            var    expression   = Expression;
            object selectedItem = null;

            foreach (var item in _listBox.Items)
            {
                var valueItem = item as ScriptValueList.ValueItem;
                if (valueItem == null)
                {
                    continue;
                }
                var itemExpression =
                    ScriptValueHelper.TextToObject(valueItem.Text, typeof(ScriptStringValue), valueItem.IsExpression).ToString();
                if (expression == itemExpression)
                {
                    selectedItem = item;
                    break;
                }
            }
            _listBox.SelectedItem = selectedItem;
        }
Beispiel #4
0
        /// <summary>
        /// Parses a Block inside an open ReplSession
        /// </summary>
        /// <param name="expression">the Expression-Block that must be executed</param>
        /// <param name="replSession">the current repl-session</param>
        /// <returns>the result of the Execution-block</returns>
        public static object ParseBlock(string expression, IDisposable replSession)
        {
            if (replSession is InterpreterBuffer.RunnerItem rii)
            {
                ITVScriptingBaseVisitor <ScriptValue> visitor  = InterpreterBuffer.GetInterpreter(rii);
                ITVScriptingParser.ProgramContext     executor = GetProgramTree(expression);
                ScriptValue retVal = visitor.VisitProgram(executor);
                return(ScriptValueHelper.GetScriptValueResult <object>(retVal, false));
            }

            return(ParseBlock(expression, replSession, null));
        }
Beispiel #5
0
        /// <summary>
        /// Runs a script inside a specific Scripting context
        /// </summary>
        /// <param name="scriptingContext">the scripting context in which a script is running</param>
        /// <returns>the result of the script</returns>
        public TOutput Execute(IDisposable scriptingContext)
        {
            CheckDate();
            bool ok = false;

            while (!ok)
            {
                lock (runCounterLock)
                {
                    ok = executionWait.WaitOne(100);
                    if (ok)
                    {
                        currentRuns++;
                    }
                }

                if (!ok)
                {
                    executionWait.WaitOne();
                }
            }

            try
            {
                if (!runnable)
                {
                    throw new ScriptException(string.Format("Script is not runnable! Suspect Line: {0}{2}Complete Error-List:{2} {1}", suspectLine, errors, Environment.NewLine));
                }

                var         visitor = InterpreterBuffer.GetInterpreter(scriptingContext);
                ScriptValue retVal  = visitor.VisitProgram(program);
                return(ScriptValueHelper.GetScriptValueResult <TOutput>(retVal, false));
            }
            finally
            {
                lock (runCounterLock)
                {
                    currentRuns--;
                    Monitor.Pulse(runCounterLock);
                }
            }
        }
        /// <summary>
        /// Invokes the body of this function using the provided arguments
        /// </summary>
        /// <param name="arguments">the arguments whith which to initialize the visitor for this method</param>
        /// <returns>the result of this method</returns>
        public object Invoke(object[] arguments)
        {
            var dct = scope.PrepareCall();

            try
            {
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                for (int i = 0; i < this.arguments.Length; i++)
                {
                    object val = i < (arguments?.Length ?? 0) ? arguments[i] : null;
                    parameters[this.arguments[i]] = val;
                }

                parameters["parameters"] = arguments;
                scope.Clear(parameters);
                return(ScriptValueHelper.GetScriptValueResult <object>(visitor.Visit(body), false));
            }
            finally
            {
                scope.FinalizeScope(dct);
            }
        }
Beispiel #7
0
        public void Init(FlexDesignerHostServices provider, ReportParameterValues parameterValues)
        {
            Debug.Assert(parameterValues != null);

            _provider = provider;
            C1FlexReport anotherReport;

            GetReportParameterValuesEnviroment(parameterValues, out _scriptNamePrefix, out anotherReport);
            _report = parameterValues.Report;

            _updating = true;

            _valueEditor = new ValueEditor(c1FlexGrid1);
            _valueEditor.Init(provider, _report.DataSourceName, "");
            C1ThemeController.ApplyThemeToControlTree(_valueEditor, MainForm.TheMainForm.CachedTheme);
            _nameEditor = new NameEditor(c1FlexGrid1);
            _nameEditor.Init(provider, anotherReport);
            C1ThemeController.ApplyThemeToControlTree(_nameEditor, MainForm.TheMainForm.CachedTheme);

            var labelIndex = c1FlexGrid1.Cols.Fixed;
            var valueIndex = labelIndex + 1;

            foreach (var item in parameterValues)
            {
                var row = c1FlexGrid1.Rows.Add();
                row[labelIndex] = ScriptValueHelper.ToString(item.Name);
                row[valueIndex] = ScriptValueHelper.ToString(item.Value);
            }

            c1FlexGrid1.Col = labelIndex;
            if (parameterValues.Count > 0)
            {
                c1FlexGrid1.Row = c1FlexGrid1.Rows.Fixed;
            }

            UpdateButtonsSatus();

            _updating = false;
        }