コード例 #1
0
        public IActionResult SetParameters([FromQuery] string parametersFile)
        {
            ReportsAutoDiscoveryConfigModel pathSearchConfig = GetAutoDiscoveryConfig();
            ExecutionConfig config = ExecutionConfigManager.Read(Path.Combine(pathSearchConfig.ParametersFilesDirectory, parametersFile));
            ParametersModel model  = new ParametersModel();

            model.ParametersFile = parametersFile;
            if (config.DataSource == ReportDataSource.StoredProcedure)
            {
                IDictionary <Tuple <ParameterType, string>, object> data = config.StoredProcedureParameters.Select(p =>
                                                                                                                   new KeyValuePair <Tuple <ParameterType, string>, object>(new Tuple <ParameterType, string>(ParameterType.StoredProcedure, p.ParameterName),
                                                                                                                                                                            p.ParameterValue)).ToDictionary(item => item.Key, item => item.Value);
                model.Parameters        = data;
                model.IsStoredProcedure = true;
            }
            else
            {
                IDictionary <Tuple <ParameterType, string>, object> whereParams = config.ViewParameters.WhereParameters.Select(p =>
                                                                                                                               new KeyValuePair <Tuple <ParameterType, string>, object>(new Tuple <ParameterType, string>(ParameterType.Where, p.ParameterName),
                                                                                                                                                                                        p.ParameterValue)).ToDictionary(item => item.Key, item => item.Value);
                IDictionary <Tuple <ParameterType, string>, object> orderParams = config.ViewParameters.OrderByParameters.Select(p =>
                                                                                                                                 new KeyValuePair <Tuple <ParameterType, string>, object>(new Tuple <ParameterType, string>(ParameterType.Order, p.ParameterName),
                                                                                                                                                                                          p.ParameterValue)).ToDictionary(item => item.Key, item => item.Value);
                IDictionary <Tuple <ParameterType, string>, object> groupParams = config.ViewParameters.GroupByParameters.Select(p =>
                                                                                                                                 new KeyValuePair <Tuple <ParameterType, string>, object>(new Tuple <ParameterType, string>(ParameterType.Group, p.ParameterName),
                                                                                                                                                                                          p.ParameterValue)).ToDictionary(item => item.Key, item => item.Value);
                IDictionary <Tuple <ParameterType, string>, object> result = new Dictionary <Tuple <ParameterType, string>, object>();
                result                  = result.Concat(whereParams).Concat(orderParams).Concat(groupParams).ToDictionary(item => item.Key, item => item.Value);
                model.Parameters        = result;
                model.IsStoredProcedure = false;
            }
            return(PartialView("Modals/SetParametersModal", model));
        }
コード例 #2
0
        static void Main(string[] args)
        {
            List <int> myIntList = new List <int>();

            for (int i = 0; i < 150; i++)
            {
                myIntList.Add(i + 1);
            }

            var config = new ExecutionConfig
            {
                BatchSize      = 30,
                BatchDelayInMS = 200 //this property will be ignored in the Parallel mode
            };

            Console.WriteLine("Normal:");
            var result = BatchMaster.Execute(myIntList, (batch) => { DoSomethingWithMyBatch(batch.ToList()); }, config);

            Console.WriteLine(result);

            Console.WriteLine("-------------------------------------");

            Console.WriteLine("Parallel:");
            var pResult = BatchMaster.ExecuteParallel(myIntList, (batch) => { DoSomethingWithMyBatch(batch.ToList()); }, config);

            Console.WriteLine(pResult);

            Console.ReadLine();
        }
コード例 #3
0
        public void TestReadConfig(ReportDataSource source, string file)
        {
            ExecutionConfig expectedConfig = GetConfig(source);
            ExecutionConfig actualConfig   = ExecutionConfigManager.Read(file);

            Assert.NotNull(actualConfig);
            CheckConfigs(expectedConfig, actualConfig);
        }
コード例 #4
0
        public async Task <IActionResult> Generate([FromQuery] string dataSourceType, [FromQuery] string dataSourceConnStr,
                                                   [FromQuery] string parametersFile, [FromQuery] string templateFile,
                                                   [FromQuery] int worksheet, [FromQuery] int row, [FromQuery] int column,
                                                   [FromBody] ParameterInfoModel[] parameters)
        {
            ReportsAutoDiscoveryConfigModel pathSearchConfig   = GetAutoDiscoveryConfig();
            KeyValuePair <DbEngine, string> dataSourceDbEngine = _availableDataSources.First(item => string.Equals(item.Value.Trim().ToLower(), dataSourceType.Trim().ToLower()));
            IReportGeneratorManager         manager            = new ExcelReportGeneratorManager(_loggerFactory, dataSourceDbEngine.Key, dataSourceConnStr);
            string          reportFile = GetExcelFilePath("Report", Guid.NewGuid());
            ExecutionConfig config     = ExecutionConfigManager.Read(Path.Combine(pathSearchConfig.ParametersFilesDirectory, parametersFile));

            if (parameters != null && parameters.Length > 0)
            {
                if (config.DataSource == ReportDataSource.StoredProcedure)
                {
                    foreach (ParameterInfoModel parameter in parameters)
                    {
                        StoredProcedureParameter existingStoreProcParam = config.StoredProcedureParameters.FirstOrDefault(p => string.Equals(p.ParameterName.ToLower(), parameter.Key.ToLower()));
                        if (existingStoreProcParam != null)
                        {
                            existingStoreProcParam.ParameterValue = parameter.Value;
                        }
                    }
                }
                else
                {
                    foreach (ParameterInfoModel parameter in parameters)
                    {
                        DbQueryParameter sqlStatementPrameter = null;
                        if (parameter.Type == ParameterType.Where)
                        {
                            sqlStatementPrameter = config.ViewParameters.WhereParameters.FirstOrDefault(p => string.Equals(p.ParameterName.ToLower(), parameter.Key.ToLower()));
                        }
                        if (parameter.Type == ParameterType.Order)
                        {
                            sqlStatementPrameter = config.ViewParameters.OrderByParameters.FirstOrDefault(p => string.Equals(p.ParameterName.ToLower(), parameter.Key.ToLower()));
                        }
                        if (parameter.Type == ParameterType.Group)
                        {
                            sqlStatementPrameter = config.ViewParameters.GroupByParameters.FirstOrDefault(p => string.Equals(p.ParameterName.ToLower(), parameter.Key.ToLower()));
                        }
                        if (sqlStatementPrameter != null)
                        {
                            sqlStatementPrameter.ParameterValue = parameter.Value.ToString();
                        }
                    }
                }
            }
            bool result = await manager.GenerateAsync(Path.Combine(pathSearchConfig.TemplatesFilesDirectory, templateFile), config, reportFile,
                                                      ExcelReportGeneratorHelper.CreateParameters(worksheet, row, column));

            if (result)
            {
                byte[] bytes = System.IO.File.ReadAllBytes(reportFile);
                return(File(bytes, _expectedMimeTypes[MsExcelExtension], "Report.xlsx"));
            }
            return(null);
        }
コード例 #5
0
        private ReportParametersInfoModel Create(FileInfo file)
        {
            ExecutionConfig config = ExecutionConfigManager.Read(file.FullName);

            string[] fileContent = System.IO.File.ReadAllLines(file.FullName);
            ReportParametersInfoModel parametersInfo = new ReportParametersInfoModel(file.Name, config.DisplayName, config.Description, fileContent);

            return(parametersInfo);
        }
コード例 #6
0
        private void CheckConfigs(ExecutionConfig expectedConfig, ExecutionConfig actualConfig)
        {
            Assert.Equal(expectedConfig.Name, actualConfig.Name);
            Assert.Equal(expectedConfig.DisplayName, actualConfig.DisplayName);
            Assert.Equal(expectedConfig.Description, actualConfig.Description);
            Assert.Equal(expectedConfig.DataSource, actualConfig.DataSource);
            if (expectedConfig.DataSource == ReportDataSource.StoredProcedure)
            {
                for (int i = 0; i < expectedConfig.StoredProcedureParameters.Count; i++)
                {
                    Assert.Equal(expectedConfig.StoredProcedureParameters[i].ParameterName, actualConfig.StoredProcedureParameters[i].ParameterName);
                    Assert.Equal(expectedConfig.StoredProcedureParameters[i].ParameterType, actualConfig.StoredProcedureParameters[i].ParameterType);
                    Assert.Equal(expectedConfig.StoredProcedureParameters[i].ParameterValue, actualConfig.StoredProcedureParameters[i].ParameterValue);
                }
            }
            else
            {
                for (int i = 0; i < expectedConfig.ViewParameters.WhereParameters.Count; i++)
                {
                    if (expectedConfig.ViewParameters.WhereParameters[i].Conditions != null)
                    {
                        for (int j = 0; j < expectedConfig.ViewParameters.WhereParameters[i].Conditions.Count; j++)
                        {
                            Assert.Equal(expectedConfig.ViewParameters.WhereParameters[i].Conditions[j], actualConfig.ViewParameters.WhereParameters[i].Conditions[j]);
                        }
                    }
                    Assert.Equal(expectedConfig.ViewParameters.WhereParameters[i].ParameterName, actualConfig.ViewParameters.WhereParameters[i].ParameterName);
                    Assert.Equal(expectedConfig.ViewParameters.WhereParameters[i].ParameterValue, actualConfig.ViewParameters.WhereParameters[i].ParameterValue);
                    if (expectedConfig.ViewParameters.WhereParameters[i].ComparisonOperator != null)
                    {
                        Assert.Equal(expectedConfig.ViewParameters.WhereParameters[i].ComparisonOperator, actualConfig.ViewParameters.WhereParameters[i].ComparisonOperator);
                    }
                }

                for (int i = 0; i < expectedConfig.ViewParameters.OrderByParameters.Count; i++)
                {
                    Assert.Null(expectedConfig.ViewParameters.OrderByParameters[i].Conditions);
                    Assert.Empty(actualConfig.ViewParameters.OrderByParameters[i].Conditions);
                    Assert.Equal(expectedConfig.ViewParameters.OrderByParameters[i].ParameterName, actualConfig.ViewParameters.OrderByParameters[i].ParameterName);
                    Assert.Equal(expectedConfig.ViewParameters.OrderByParameters[i].ParameterValue, actualConfig.ViewParameters.OrderByParameters[i].ParameterValue);
                    Assert.Null(expectedConfig.ViewParameters.OrderByParameters[i].ComparisonOperator);
                    Assert.Null(actualConfig.ViewParameters.OrderByParameters[i].ComparisonOperator);
                }

                for (int i = 0; i < expectedConfig.ViewParameters.GroupByParameters.Count; i++)
                {
                    Assert.Null(expectedConfig.ViewParameters.GroupByParameters[i].Conditions);
                    Assert.Empty(actualConfig.ViewParameters.GroupByParameters[i].Conditions);
                    Assert.Equal(expectedConfig.ViewParameters.GroupByParameters[i].ParameterName, actualConfig.ViewParameters.GroupByParameters[i].ParameterName);
                    Assert.Null(expectedConfig.ViewParameters.GroupByParameters[i].ParameterValue);
                    Assert.Null(actualConfig.ViewParameters.GroupByParameters[i].ParameterValue);
                    Assert.Null(expectedConfig.ViewParameters.GroupByParameters[i].ComparisonOperator);
                    Assert.Null(actualConfig.ViewParameters.GroupByParameters[i].ComparisonOperator);
                }
            }
        }
コード例 #7
0
        private ExecutionConfig GetConfig(ReportDataSource source)
        {
            ExecutionConfig config = new ExecutionConfig();

            config.DataSource = source;
            if (source == ReportDataSource.StoredProcedure)
            {
                List <StoredProcedureParameter> procedureParameters = new List <StoredProcedureParameter>();
                procedureParameters.Add(new StoredProcedureParameter((int)SqlDbType.NVarChar, "City", "N'Yekaterinburg"));
                procedureParameters.Add(new StoredProcedureParameter((int)SqlDbType.Int, "PostalCode", "620000"));
                procedureParameters.Add(new StoredProcedureParameter((int)SqlDbType.DateTime, "DateOfBirth", "'2018-01-01'"));
                config.StoredProcedureParameters = procedureParameters;
                config.Name        = "GetSitizensByCityAndDateOfBirth";
                config.DisplayName = "Get citizens";
                config.Description = "Get citizens from SQL Server via parametrized stored procedure (city, postal code and date of birth)";
            }
            else
            {
                ViewParameters viewParameters = new ViewParameters();
                config.ViewParameters = viewParameters;
                config.Name           = "CitizensView";
                config.DisplayName    = "Get citizens";
                config.Description    = "Get citizens from SQL Server view by group of params";
                List <DbQueryParameter> whereParameters = new List <DbQueryParameter>();
                whereParameters.Add(new DbQueryParameter(null, "FirstName", "=", "N'Michael'"));
                whereParameters.Add(new DbQueryParameter(new List <JoinCondition>()
                {
                    JoinCondition.And, JoinCondition.Not
                }, "City", "=", "N'Yekaterinburg'"));
                whereParameters.Add(new DbQueryParameter(new List <JoinCondition>()
                {
                    JoinCondition.And
                }, "Age", "BETWEEN", "18 AND 60"));
                whereParameters.Add(new DbQueryParameter(new List <JoinCondition>()
                {
                    JoinCondition.And
                }, "District", "IN", "(N'D1', N'A3', N'A5', N'C7')"));
                whereParameters.Add(new DbQueryParameter(new List <JoinCondition>()
                {
                    JoinCondition.Or
                }, "Region", "!=", "N'Sverdlovskaya oblast'"));
                config.ViewParameters.WhereParameters = whereParameters;

                List <DbQueryParameter> orderByParameters = new List <DbQueryParameter>();
                orderByParameters.Add(new DbQueryParameter(null, "FirstName", null, "ASC"));
                orderByParameters.Add(new DbQueryParameter(null, "LastName", null, "DESC"));
                config.ViewParameters.OrderByParameters = orderByParameters;

                List <DbQueryParameter> groupByParameters = new List <DbQueryParameter>();
                groupByParameters.Add(new DbQueryParameter(null, "District", null, null));
                config.ViewParameters.GroupByParameters = groupByParameters;
            }
            return(config);
        }
コード例 #8
0
 protected AbstractRuntimeUdfContext(
     TaskInfo taskInfo,
     ExecutionConfig executionConfig,
     IDictionary <string, IAccumulator <object, object> > accumulators,
     IDictionary <string, TaskCompletionSource <string> > cpTasks,
     IMetricGroup metrics)
 {
     _taskInfo        = taskInfo;
     ExecutionConfig  = executionConfig;
     DistributedCache = new DistributedCache(cpTasks);
     _accumulators    = Preconditions.CheckNotNull(accumulators);
     MetricGroup      = metrics;
 }
コード例 #9
0
 public DefaultOperatorStateBackendBuilder(
     Type userType,
     ExecutionConfig executionConfig,
     bool asynchronousSnapshots,
     IList <IOperatorStateHandle> stateHandles,
     CloseableRegistry cancelStreamRegistry)
 {
     UserType              = userType;
     ExecutionConfig       = executionConfig;
     AsynchronousSnapshots = asynchronousSnapshots;
     RestoreStateHandles   = stateHandles;
     CancelStreamRegistry  = cancelStreamRegistry;
 }
コード例 #10
0
        public override void BeforeRun(ExecutionConfig config)
        {
            App currentApp = App.Current as App;

            Parameter = "\""
                        + "start_game=true is_debug=true setting.nosplash=true setting.windowed="
                        + currentApp.DebugWindowed.ToString().ToLower() + " setting.resx=" + currentApp.DebugResolutionX
                        + " setting.resy=" + currentApp.DebugResolutionY + " cheat=" + currentApp.DebugCheat.ToString().ToLower()
                        + " updatelib=" + currentApp.DebugUpdateLib.ToString().ToLower() + " setting.mod=\'"
                        + config.ModName + "\'\"";
            UseShellExecute        = false;
            CreateNoWindow         = true;
            RedirectStandardError  = true;
            RedirectStandardOutput = true;
        }
コード例 #11
0
 public WindowContext(TWindow window,
                      WindowAssigner <TInput, TWindow> windowAssigner,
                      AbstractKeyedStateBackend <TKey> keyedStateBackend,
                      ExecutionConfig executionConfig,
                      IInternalTimerService <TWindow> internalTimerService,
                      IOutput <StreamRecord <TOutput> > output,
                      WindowOperator <TKey, TInput, TAccumulator, TOutput, TWindow> windowOperator)
 {
     Window = window;
     _internalTimerService = internalTimerService;
     _output          = output;
     _windowOperator  = windowOperator;
     WindowStateStore = windowAssigner is MergingWindowAssigner <TInput, TWindow>
                        ?(AbstractPerWindowStateStore) new MergingWindowStateStore(keyedStateBackend, executionConfig)
                            : new PerWindowStateStore(keyedStateBackend, executionConfig);
 }
コード例 #12
0
 /// <summary>Ctor.</summary>
 public ConfigurationEngineDefaults()
 {
     Threading          = new ThreadingConfig();
     ViewResources      = new ViewResourcesConfig();
     EventMeta          = new EventMetaConfig();
     Logging            = new LoggingConfig();
     Variables          = new VariablesConfig();
     StreamSelection    = new StreamSelectionConfig();
     TimeSource         = new TimeSourceConfig();
     MetricsReporting   = new MetricsReportingConfig();
     Language           = new LanguageConfig();
     Expression         = new ExpressionConfig();
     Execution          = new ExecutionConfig();
     ExceptionHandling  = new ExceptionHandlingConfig();
     ConditionHandling  = new ConditionHandlingConfig();
     AlternativeContext = new AlternativeContextConfig();
     Patterns           = new PatternsConfig();
     MatchRecognize     = new MatchRecognizeConfig();
     Scripts            = new ScriptsConfig();
 }
コード例 #13
0
        private async Task <int> GenerateImplAsync(string template, ExecutionConfig config, string reportFile, object[] parameters)
        {
            try
            {
                _logger.LogDebug("Report generation started");
                DbData result = config.DataSource == ReportDataSource.View ? await _extractor.ExtractAsync(config.Name, config.ViewParameters)
                    : await _extractor.ExtractAsync(config.Name, config.StoredProcedureParameters);

                if (result == null)
                {
                    return(-1);
                }
                IReportGenerator generator = new ExcelReportGenerator(_loggerFactory.CreateLogger <ExcelReportGenerator>(), template, reportFile);
                _logger.LogDebug("Report generation completed");
                return(await generator.GenerateAsync(result, parameters));
            }
            catch (Exception e)
            {
                _logger.LogError($"An error occurred during report generation, exception is: {e}");
                return(-1);
            }
        }
コード例 #14
0
 public DefaultKeyedStateStore(IKeyedStateBackend <TKey> keyedStateBackend, ExecutionConfig executionConfig)
 {
     KeyedStateBackend = Preconditions.CheckNotNull(keyedStateBackend);
     ExecutionConfig   = Preconditions.CheckNotNull(executionConfig);
 }
コード例 #15
0
        public async Task <int> GenerateAsync(string template, string executionConfigFile, string reportFile, object[] parameters)
        {
            ExecutionConfig config = ExecutionConfigManager.Read(executionConfigFile);

            return(await GenerateImplAsync(template, config, reportFile, parameters));
        }
コード例 #16
0
 public void SetOutputType(Type outTypeInfo, ExecutionConfig executionConfig)
 {
     throw new NotImplementedException();
 }
コード例 #17
0
 public override TypeSerializer <Row> CreateSerializer(ExecutionConfig config)
 {
     throw new NotImplementedException();
 }
コード例 #18
0
 /// <summary>
 /// Creates a serializer for the type. The serializer may use the ExecutionConfig for parameterization.
 /// </summary>
 /// <param name="config">used to parameterize the serializer.</param>
 /// <returns>A serializer for this type.</returns>
 public abstract TypeSerializer <T> CreateSerializer(ExecutionConfig config);
コード例 #19
0
 public TypeComparator <T> CreateTypeComparator(ExecutionConfig config)
 {
     throw new NotImplementedException();
 }
コード例 #20
0
 public override TypeSerializer <TimeWindow> GetWindowSerializer(ExecutionConfig executionConfig)
 {
     throw new NotImplementedException();
 }
コード例 #21
0
 internal ExecutionState(ExecutionConfig config, object result, Exception exception)
 {
     this.Config     = config;
     this._result    = result;
     this._exception = exception;
 }
コード例 #22
0
        public override TypeSerializer <IList <T> > CreateSerializer(ExecutionConfig config)
        {
            var elementTypeSerializer = ElementTypeInfo.CreateSerializer(config);

            return(new ListSerializer <T>(elementTypeSerializer));
        }
コード例 #23
0
 public override TypeSerializer <GlobalWindow> GetWindowSerializer(ExecutionConfig executionConfig)
 {
     throw new System.NotImplementedException();
 }
コード例 #24
0
 public override TypeSerializer <InvalidTypesException> CreateSerializer(ExecutionConfig config) => throw new InvalidOperationException("The missing type information cannot be used as a type information.");
コード例 #25
0
 public TypeComparator <T> CreateComparator(bool sortOrderAscending, ExecutionConfig executionConfig)
 {
     throw new NotImplementedException();
 }
コード例 #26
0
 public DockerContainer(string id, ExecutionConfig config)
 {
     _id     = id;
     _config = config;
 }
コード例 #27
0
 public async Task <int> GenerateAsync(string template, ExecutionConfig config, string reportFile, object[] parameters)
 {
     return(await GenerateImplAsync(template, config, reportFile, parameters));
 }
コード例 #28
0
 public PerWindowStateStore(IKeyedStateBackend <TKey> keyedStateBackend, ExecutionConfig executionConfig)
     : base(keyedStateBackend, executionConfig)
 {
 }
コード例 #29
0
 protected KUITaskBase(TaskExecutor exec, bool isRoot)
 {
     this._executor = exec;
     this._config   = isRoot ? new ExecutionConfig(this) : null;
 }
コード例 #30
0
        public static async Task <DockerContainer> CreateContainerAsync(string image, ExecutionConfig config)
        {
            var result = await RunDockerCommandAsync($"run --network=none --cpus={config.CPUs} --memory={config.Memory} -t -d {image}", false);

            if (result.ExitCode != 0)
            {
                throw new Exception($"An error occurred creating a container (exit code ${result.ExitCode}): {result.StandardError}");
            }
            if (string.IsNullOrEmpty(result.StandardOutput))
            {
                throw new Exception("Unable to retrieve container ID");
            }
            return(new DockerContainer(result.StandardOutput, config));
        }