示例#1
0
        public DataFlowOperator Operator(DataFlowOpInitializeContext context)
        {
            var titleText = DataFlowParameterResolution.ResolveStringOptional("title", Title, context);
            var layoutText = DataFlowParameterResolution.ResolveStringOptional("layout", Layout, context);
            var logFlag = DataFlowParameterResolution.ResolveWithDefault<bool>("log", Log, true, context);
            var linefeedFlag = DataFlowParameterResolution.ResolveWithDefault<bool>("linefeed", Linefeed, true, context);

            ConsoleOpRenderer renderer;
            var formatText = DataFlowParameterResolution.ResolveStringOptional("format", Format, context);
            if (formatText == null) {
                renderer = new ConsoleOpRendererSummary();
            }
            else {
                LogSinkOutputFormat formatEnum = EnumHelper.Parse<LogSinkOutputFormat>(formatText);
                if (formatEnum == LogSinkOutputFormat.summary) {
                    renderer = new ConsoleOpRendererSummary();
                }
                else if (formatEnum == LogSinkOutputFormat.json || formatEnum == LogSinkOutputFormat.xml) {
                    renderer = new ConsoleOpRendererXmlJSon(formatEnum, context.AgentInstanceContext.EPRuntimeRenderEvent);
                }
                else {
                    throw new EPException(
                        "Format '" + formatText + "' is not supported, expecting any of " + CompatExtensions.RenderAny(
                            EnumHelper.GetValues<LogSinkOutputFormat>()));
                }
            }

            return new LogSinkOp(this, context.DataFlowInstanceId, renderer, titleText, layoutText, logFlag, linefeedFlag);
        }
示例#2
0
 public DataFlowOperator Operator(DataFlowOpInitializeContext context)
 {
     var fileName = DataFlowParameterResolution.ResolveStringRequired(
         "file", File, context);
     var appendFlag = DataFlowParameterResolution.ResolveWithDefault(
         "append", Append, false, context);
     return new FileSinkCSV(this, fileName, appendFlag);
 }
示例#3
0
        public DataFlowOperator Operator(DataFlowOpInitializeContext context)
        {
            var container = context.Container;
            var adapterInputSourceValue = DataFlowParameterResolution.ResolveOptionalInstance <AdapterInputSource>(
                "adapterInputSource",
                AdapterInputSource,
                context);
            var fileName = DataFlowParameterResolution.ResolveWithDefault <string>(
                "file",
                File,
                null,
                context);

            if (adapterInputSourceValue == null)
            {
                if (fileName != null)
                {
                    adapterInputSourceValue = new AdapterInputSource(container, new FileInfo(fileName));
                }
                else
                {
                    throw new EPException("Failed to find required parameter, either the file or the adapterInputSource parameter is required");
                }
            }

            var formatValue = DataFlowParameterResolution.ResolveStringOptional("format", Format, context);

            switch (formatValue)
            {
            case null:
            case "csv": {
                var hasHeaderLineFlag = DataFlowParameterResolution.ResolveWithDefault <bool?>(
                    "hasHeaderLine",
                    HasHeaderLine,
                    false,
                    context);
                var hasTitleLineFlag = DataFlowParameterResolution.ResolveWithDefault <bool?>(
                    "hasTitleLine",
                    HasTitleLine,
                    false,
                    context);
                var numLoopsValue = DataFlowParameterResolution.ResolveWithDefault <int?>(
                    "numLoops",
                    NumLoops,
                    null,
                    context);
                var dateFormatValue = DataFlowParameterResolution.ResolveStringOptional(
                    "dateFormat",
                    DateFormat,
                    context);

                return(new FileSourceCSV(
                           this,
                           context,
                           adapterInputSourceValue,
                           hasHeaderLineFlag ?? false,
                           hasTitleLineFlag ?? false,
                           numLoopsValue,
                           PropertyNames,
                           dateFormatValue));
            }

            case "line": {
                var propertyNameLineValue = DataFlowParameterResolution.ResolveStringOptional("propertyNameLine", PropertyNameLine, context);
                var propertyNameFileValue = DataFlowParameterResolution.ResolveStringOptional("propertyNameFile", PropertyNameFile, context);
                return(new FileSourceLineUnformatted(this, context, adapterInputSourceValue, fileName, propertyNameLineValue, propertyNameFileValue));
            }

            default:
                throw new ArgumentException("Unrecognized file format '" + formatValue + "'");
            }
        }