Ejemplo n.º 1
0
        public bool II_PushRecord(RecordData recordDataIn)
        {
            // Prepare the output
            AlteryxRecordInfoNet.Record recordOut = _recordInfoOut.CreateRecord();
            recordOut.Reset();

            // Transfer existing data
            //copyRecordData(recordDataIn, recordOut);
            _recordCopier.Copy(recordOut, recordDataIn);

            // Collect data from fields
            string data   = getFieldBaseStringData(_dataField, recordDataIn);
            string schema = getFieldBaseStringData(_schemaField, recordDataIn);

            // Shortcut out if sanity checks fail
            if (string.IsNullOrWhiteSpace(data))
            {
                return(setOutput("MISSING_XML_DATA", recordOut));
            }
            if (string.IsNullOrWhiteSpace(schema))
            {
                return(setOutput("MISSING_XML_SCHEMA", recordOut));
            }
            if (!data.TrimStart().StartsWith("<"))
            {
                return(setOutput("DATA_NOT_XML", recordOut));
            }

            // We have two non-empty strings.

            // Schemas are expected as filenames, separated by semicolons.
            XmlSchemaSet setOfSchemas = XmlValidatorMechanics.getXmlSchemaSet(schema);

            XDocument doc = XDocument.Parse(data);

            List <string> errors = new List <string>();

            doc.Validate(setOfSchemas, (o, e) =>
            {
                errors.Add(e.Message);
            }, true);

            string allErrors = string.Join("|", errors);

            // If no errors, say VALID, else, say the errors.
            if (string.IsNullOrWhiteSpace(allErrors))
            {
                return(setOutput("VALID", recordOut));
            }
            else
            {
                return(setOutput(allErrors, recordOut));
            }
        }
Ejemplo n.º 2
0
        public bool II_PushRecord(RecordData recordDataIn)
        {
            prepRecordInfoOut();

            string secret  = getFieldBaseStringData(_secretField, recordDataIn);
            string message = getFieldBaseStringData(_messageField, recordDataIn);


            AlteryxRecordInfoNet.Record recordOut = _recordInfoOut.CreateRecord();
            recordOut.Reset();

            // Transfer existing data
            copyRecordData(recordDataIn, recordOut);

            string sHash = performHash(secret, message);

            // Output Field is last
            AlteryxRecordInfoNet.FieldBase fbOut = _recordInfoOut[(int)_recordInfoIn.NumFields()];
            fbOut.SetFromString(recordOut, sHash);

            _outputHelper.PushRecord(recordOut.GetRecord());

            return(true);
        }
        public bool II_PushRecord(RecordData recordDataIn)
        {
            DebugMessage($"II_PushRecord() Entering; ToolID={_toolID}");

            // The same object is used in each call, so reset the result fields before using them.
            _retCode = "";
            _cmdLine = "";
            lock (_sbStdOutLock) { _sbStdOut.Clear(); }
            lock (_sbExceptionsLock) { _sbExceptions.Clear(); }



            // Check the paths to Executable and Script...
            string exePath = getFieldBaseStringData(_exePathField, recordDataIn);

            checkValidPath(exePath, _exePathField);

            // Do the magic
            shell(exePath, getArguments(recordDataIn));

            // Get the output
            string stdOut = "";

            lock (_sbStdOutLock)
            { stdOut = _sbStdOut.ToString(); }

            // Get the exceptions
            string exceptions = "";

            lock (_sbExceptionsLock)
            { exceptions = _sbExceptions.ToString(); }


            // Prepare the output
            AlteryxRecordInfoNet.Record recordOut = _recordInfoOut.CreateRecord();
            recordOut.Reset();

            // Transfer existing data
            _recordCopier.Copy(recordOut, recordDataIn);


            // Set Output Fields
            var numInputFields = (int)_recordInfoIn.NumFields();

            AlteryxRecordInfoNet.FieldBase fbStdOut = _recordInfoOut[numInputFields];
            fbStdOut.SetFromString(recordOut, stdOut);

            AlteryxRecordInfoNet.FieldBase fbRetCode = _recordInfoOut[numInputFields + 1];
            fbRetCode.SetFromString(recordOut, _retCode);

            AlteryxRecordInfoNet.FieldBase fbExceptions = _recordInfoOut[numInputFields + 2];
            fbExceptions.SetFromString(recordOut, exceptions);

            AlteryxRecordInfoNet.FieldBase fbDiagnostics = _recordInfoOut[numInputFields + 3];
            fbDiagnostics.SetFromString(recordOut, _cmdLine);


            // Output
            _outputHelper.PushRecord(recordOut.GetRecord());


            // Clear the accumulated strings for next record
            _retCode = "";
            _cmdLine = "";
            lock (_sbStdOutLock) { _sbStdOut.Clear(); }
            lock (_sbExceptionsLock) { _sbExceptions.Clear(); }

            DebugMessage($"II_PushRecord() Exiting; ToolID={_toolID}");
            return(true);
        }