/// <summary>
        /// Perform the Create operations on the selected table.
        /// This method will filter creations using the 
        /// SqlQueryBuilder and the lookup conditions
        /// </summary>
        /// <param name="operationInput">The operation information being executed.</param>
        /// <returns>The result of the operation that was processed.</returns>
        public OperationResult CreateOperation(OperationInput operationInput)
        {
            OperationResult operationResult = new OperationResult();

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(Globals.ConnectorName, "Create"))
            {
                // Each record processed must return the following 3 pieces of information.
                // Each piece of information should be added in the same order it was received.
                // The first piece of information would be whether or not the request was successful.
                // If the requested record that has a key that already exists this should not result in a failure.
                List<bool> successList = new List<bool>();
                // The second piece of information is the number of records that have been processed.
                // If a duplicate key is detected when performing an insert then 0 rows should be added for the request.
                List<int> objectList = new List<int>();
                // In the event of an error during processing the record, error information should be added here.
                // If no error occured a null placeholder for that record is expected.
                List<ErrorResult> errors = new List<ErrorResult>();

                //Execute each of the inputs individually
                // **** Processing inputs individually is done because the
                //      connector is responsible for error handling on each.
                //      The connector must return results in the same order in which the
                //      data entities were received, this allows for reprocessing of failed records.
                //Note: If the SupportsBulk flag is not set in the ActionDefinition
                //      that corresponds to this operation, operationInput.Input
                //      will always have always have a length of 1.
                foreach (DataEntity inputEntity in operationInput.Input)
                {
                    try
                    {
                        //Use the query builder to parse input conditions
                        SqlQueryBuilder queryBuilder = new SqlQueryBuilder(
                            inputEntity, Globals.QueryType.Insert);

                        //execute the create query
                        int rowsEffected = _dataAccess.ExecuteNonQuery(queryBuilder.ToString());

                        //Add the result of the create to the result lists
                        successList.Add(SetSuccessResult(operationInput.AllowMultipleObject, rowsEffected));
                        objectList.Add(rowsEffected);
                        errors.Add(SetErrorResult(rowsEffected));
                    }
                    catch (OleDbException oleDbException)
                    {
                        //Create a new error result for ole db specific exeptions
                        ErrorResult errorResult = new ErrorResult();

                        var oleDbError = oleDbException.ErrorCode;
                        //Look for a specific error code that occurs when attempting to duplicate a record.
                        //This will tell ScribeOnline that an update is required rather than an Insert.
                        if (oleDbError == -2147217873)
                        {
                            //this is the error code for a 'Violation in unique index'
                            errorResult.Number = ErrorNumber.DuplicateUniqueKey;
                            if (oleDbException.Errors[0] != null && oleDbException.Errors[0] != null)
                            {
                                var dbError = oleDbException.Errors[0];
                                errorResult.Description = dbError != null ? dbError.Message : oleDbException.Message;

                                var error = oleDbException.Errors[1];
                                errorResult.Detail = error != null ? error.Message : oleDbException.StackTrace;
                            }
                        }
                        else
                        {
                            errorResult.Description = oleDbException.Message;
                            errorResult.Detail = oleDbException.StackTrace;
                            errorResult.Number = oleDbError;
                        }
                        successList.Add(false);
                        objectList.Add(0);
                        errors.Add(errorResult);
                    }
                    catch (Exception exception)
                    {
                        //In the event of an exception do not stop performing
                        //all operations simply log each individually.
                        successList.Add(false);
                        objectList.Add(0);
                        errors.Add(new ErrorResult() { Description = exception.Message, Detail = exception.ToString() });
                    }
                }

                //Add the results from the operations to the operation result object
                operationResult.Success = successList.ToArray();
                operationResult.ObjectsAffected = objectList.ToArray();
                operationResult.ErrorInfo = errors.ToArray();
            }

            return operationResult;
        }
Example #2
0
        public void DeleteNoRowsFoundInValidTest()
        {
            //create a new data entity
            DataEntity entity = new DataEntity();
            //create a new operation input with a new entity array for the input property
            OperationInput operationInput = new OperationInput { Input = new DataEntity[1] };
            //set the first item in the input property
            operationInput.Input[0] = entity;
            operationInput.Input[0].ObjectDefinitionFullName = "ScribeChangeHistory";
            //set the name of the operation
            operationInput.Name = "Delete";

            //create the comparison experssion for selecting the records to delete
            ComparisonExpression comparisonExpression = new ComparisonExpression();
            comparisonExpression.ExpressionType = ExpressionType.Comparison;
            comparisonExpression.Operator = ComparisonOperator.Less;
            comparisonExpression.LeftValue = new ComparisonValue { ValueType = ComparisonValueType.Constant, Value = "ModifiedOn" };
            comparisonExpression.RightValue = new ComparisonValue { ValueType = ComparisonValueType.Variable, Value = DateTime.MinValue };

            operationInput.LookupCondition[0] = comparisonExpression;
            //execute the operation from the connector
            OperationResult operationResult = _rsTargetConnector.ExecuteOperation(operationInput);
            //validate that the operation was not a success
            Assert.IsFalse(operationResult.Success[0]);
            //validate that no rows have been found
            Assert.AreEqual(0, operationResult.ObjectsAffected[0]);
        }
Example #3
0
    private IEnumerator PlayCor(OperationInput input, OperationOutput output, Action afterFinished)
    {
        yield return(PlayInput(input));

        foreach (var episode in output.episodes)
        {
            switch (episode.etype)
            {
            case OperationOutput.EpisodeType.ELIMINATION:
                yield return(PlayEminination(episode));

                break;

            case OperationOutput.EpisodeType.REFILL:
                yield return(PlayRefill(episode));

                break;

            case OperationOutput.EpisodeType.SHUFFLE:
                yield return(PlayShuffle(episode));

                break;

            default:
                break;
            }
        }

        afterFinished.Invoke();

        yield break;
    }
        public void DeleteValidTest()
        {
            //create a new data entity
            DataEntity entity = new DataEntity();
            //create a new operation input with a new entity array for the input property
            OperationInput operationInput = new OperationInput {
                Input = new DataEntity[1]
            };

            //set the first item in the input property
            operationInput.Input[0] = entity;
            operationInput.Input[0].ObjectDefinitionFullName = "ScribeChangeHistory";
            //set the name of the operation
            operationInput.Name = "Delete";

            //create the comparison experssion for selecting the records to delete
            ComparisonExpression comparisonExpression = new ComparisonExpression();

            comparisonExpression.ExpressionType = ExpressionType.Comparison;
            comparisonExpression.Operator       = ComparisonOperator.Less;
            comparisonExpression.LeftValue      = new ComparisonValue {
                ValueType = ComparisonValueType.Constant, Value = "ModifiedOn"
            };
            comparisonExpression.RightValue = new ComparisonValue {
                ValueType = ComparisonValueType.Variable, Value = DateTime.UtcNow
            };

            operationInput.LookupCondition[0] = comparisonExpression;
            //execute the operation from the connector
            OperationResult operationResult = _rsTargetConnector.ExecuteOperation(operationInput);

            //validate that the operation was a success
            Assert.IsTrue(operationResult.Success[0]);
        }
Example #5
0
        public OperationResult ExecuteOperation(OperationInput input)
        {
            using (new LogMethodExecution(ConnectorTypeDescription, methodInfo.GetCurrentMethodName()))
            {
                try
                {
                    if (service == null || service.IsConnected == false)
                    {
                        throw new ApplicationException("Must connect before calling " +
                                                       methodInfo.GetCurrentMethodName());
                    }

                    if (input == null)
                    {
                        throw new ArgumentNullException(nameof(input));
                    }

                    if (input.Input == null)
                    {
                        throw new ArgumentException("The 'Input' property of the 'input' parameter cannot be null.", nameof(input));
                    }

                    if (!Enum.TryParse(input.Name, out ConnectorService.SupportedActions action))
                    {
                        throw new InvalidExecuteOperationException("Unsupported operation: " + input.Name);
                    }

                    if (input.Input.Length < 1)
                    {
                        throw new ArgumentException("Input must have at least one data entity.", nameof(input));
                    }

                    if (input.Input.Length > 1)
                    {
                        throw new ArgumentException("Input must cannot have more than one data entity.", nameof(input));
                    }

                    switch (action)
                    {
                    case ConnectorService.SupportedActions.Create:
                        return(service.Create(input.Input[0]));

                    case ConnectorService.SupportedActions.Execute:
                        return(service.Execute(input.Input[0]));

                    default:
                        throw new InvalidExecuteOperationException("Unsupported operation: " + input.Name);
                    }
                }
                catch (InvalidExecuteOperationException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    unhandledExecptionHandler(methodInfo.GetCurrentMethodName(), exception);
                }
            }
            return(null);
        }
Example #6
0
        public void OP_Execute_CMD_WithArgs()
        {
            var script = @"Scripts\EchoArgs.cmd";
            var dir    = Directory.GetCurrentDirectory();

            script = Path.Combine(dir, script);

            var operationInput = new OperationInput
            {
                Name  = "Execute",
                Input = new DataEntity[]
                {
                    new DataEntity(ScriptRunnerService.ObjectNames.Script)
                    {
                        Properties =
                        {
                            { ScriptRunnerService.ScriptObjPropNames.Interpreter,        "Cmd.exe"    },
                            { ScriptRunnerService.ScriptObjPropNames.Script,             script       },
                            { ScriptRunnerService.ScriptObjPropNames.ScriptArguments,    "Marco Polo" },
                            { ScriptRunnerService.ScriptObjPropNames.ProcessWindowStyle, "Hidden"     },
                            { ScriptRunnerService.ScriptObjPropNames.WaitForExit,        "true"       }
                        }
                    }
                }
            };

            var results = connector.ExecuteOperation(operationInput);

            ExpectSuccess(results);
        }
Example #7
0
        public OperationResult ExecuteOperation(OperationInput input)
        {
            using (new LogMethodExecution(ConnectorTypeDescription, methodInfo.GetCurrentMethodName()))
            {
                try
                {
                    if (service == null || service.IsConnected == false)
                    {
                        throw new ApplicationException("Must connect before calling " +
                                                       methodInfo.GetCurrentMethodName());
                    }
                    if (input == null)
                    {
                        throw new ArgumentNullException(nameof(input));
                    }

                    if (input.Input == null)
                    {
                        throw new ArgumentException(StringMessages.ErrorInvalidComparisionExpression, nameof(input));
                    }

                    if (!Enum.TryParse(input.Name, out ConnectorService.SupportedActions action))
                    {
                        throw new InvalidExecuteOperationException("Unsupported operation: " + input.Name);
                    }

                    if (input.Input.Length < 1)
                    {
                        throw new ArgumentException(StringMessages.DuplicateFilterField, nameof(input));
                    }

                    switch (action)
                    {
                    case ConnectorService.SupportedActions.CreateWith:
                        return(service.Create(input.Input[0]));

                    //case ConnectorService.SupportedActions.Execute:
                    //    return service.Execute(input.Input[0]);
                    //case ConnectorService.SupportedActions.Remove:
                    //    return service.Remove(input.Input[0],
                    //        ExpressionParser.GetMatchCriteria(input.LookupCondition[0]));
                    //case ConnectorService.SupportedActions.UpdateWith:
                    //case ConnectorService.SupportedActions.Update:
                    //    return service.Update(input.Input[0],
                    //        ExpressionParser.GetMatchCriteria(input.LookupCondition[0]));
                    default:
                        throw new InvalidExecuteOperationException("Unsupported operation: " + input.Name);
                    }
                }
                catch (InvalidExecuteOperationException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    unhandledExecptionHandler(methodInfo.GetCurrentMethodName(), exception);
                }
            }
            return(null);
        }
Example #8
0
        /// <summary>
        /// Creates a test OperationInput
        /// </summary>
        /// <returns></returns>
        private OperationInput BuildOperationInput()
        {
            var inputs = new DataEntity[2];

            inputs[0] = new DataEntity
            {
                ObjectDefinitionFullName = "Registrant",
                Properties = new Core.ConnectorApi.Query.EntityProperties()
            };

            inputs[1] = new DataEntity
            {
                ObjectDefinitionFullName = "Registrant",
                Properties = new Core.ConnectorApi.Query.EntityProperties()
            };

            inputs[0].Properties.Add("Email", "*****@*****.**");
            inputs[0].Properties.Add("FirstName", "Bob");
            inputs[0].Properties.Add("LastName", "Roberts");
            inputs[0].Properties.Add("WebinarKey", "1235813");

            inputs[1].Properties.Add("Email", "*****@*****.**");
            inputs[1].Properties.Add("FirstName", "Joe");
            inputs[1].Properties.Add("LastName", "Josephs");
            inputs[1].Properties.Add("WebinarKey", "1235813");

            var operation = new OperationInput
            {
                Name  = "Create",
                Input = inputs
            };

            return(operation);
        }
Example #9
0
        public void OP_Execute_Failure_ExeAsScript()
        {
            var script = @"Scripts\EchoTimeFake.exe";
            var dir    = Directory.GetCurrentDirectory();

            script = Path.Combine(dir, script);

            var operationInput = new OperationInput
            {
                Name  = "Execute",
                Input = new DataEntity[]
                {
                    new DataEntity(ScriptRunnerService.ObjectNames.Script)
                    {
                        Properties =
                        {
                            { ScriptRunnerService.ScriptObjPropNames.Interpreter,        "Cmd.exe" },
                            { ScriptRunnerService.ScriptObjPropNames.Script,             script    },
                            { ScriptRunnerService.ScriptObjPropNames.ProcessWindowStyle, "Hidden"  },
                            { ScriptRunnerService.ScriptObjPropNames.WaitForExit,        "true"    }
                        }
                    }
                }
            };

            var results = connector.ExecuteOperation(operationInput);

            ExpectError(results);
        }
        public void OP_Execute_CMD()
        {
            var script = @"Scripts\EchoTime.cmd";
            var dir    = Directory.GetCurrentDirectory();

            script = Path.Combine(dir, script);

            var operationInput = new OperationInput
            {
                Name  = "Execute",
                Input = new DataEntity[]
                {
                    new DataEntity(ScriptRunnerService.ObjectNames.Script)
                    {
                        Properties =
                        {
                            { ScriptRunnerService.ScriptObjPropNames.Interpreter, "Cmd.exe" },
                            { ScriptRunnerService.ScriptObjPropNames.Script,      script    }
                        }
                    }
                }
            };

            var results = connector.ExecuteOperation(operationInput);

            ExpectSuccess(results);
        }
        public void UpdateReplicationInvalidIntTest()
        {
            //create a new method input and use the appropriate operation name
            OperationInput operationInput = new OperationInput {
                Name = "update", AllowMultipleObject = false
            };
            var input      = new List <DataEntity>();
            var table      = new DataEntity();
            var columnData = new EntityProperties();

            //create the comparison experssion for selecting the records to update
            operationInput.LookupCondition = new Expression[]
            {
                new ComparisonExpression(ComparisonOperator.Equal,
                                         new ComparisonValue(ComparisonValueType.Constant, "Region"),
                                         new ComparisonValue(ComparisonValueType.Constant, "North"),
                                         null)
            };
            //add the columns to change
            table.ObjectDefinitionFullName = "Customers";
            columnData.Add("CreditOnHold", "5328475903427853943453245324532453425345324523453453453425345324523452342345");
            columnData.Add("ModifiedOn", DateTime.Now);

            table.Properties = columnData;
            input.Add(table);

            operationInput.Input = input.ToArray();

            var operationResult = _rsTargetConnector.ExecuteOperation(operationInput);

            Assert.IsFalse(operationResult.Success[0]);
            Assert.AreEqual(0, operationResult.ObjectsAffected[0]);
        }
        public void UpdateReplicationNullValueValidTest()
        {
            //create a new method input and use the appropriate operation name
            OperationInput operationInput = new OperationInput {
                Name = "update", AllowMultipleObject = false
            };

            var input      = new List <DataEntity>();
            var table      = new DataEntity();
            var columnData = new EntityProperties();

            //create the comparison experssion for selecting the records to update
            operationInput.LookupCondition = new Expression[]
            {
                new ComparisonExpression(
                    ComparisonOperator.IsNull, new ComparisonValue(ComparisonValueType.Constant, "Country"), null, null)
            };

            //add the columns to change
            table.ObjectDefinitionFullName = "Addresses";
            columnData.Add("Country", "USA");
            columnData.Add("ModifiedOn", DateTime.Now);

            table.Properties = columnData;
            input.Add(table);

            operationInput.Input = input.ToArray();

            var operationResult = _rsTargetConnector.ExecuteOperation(operationInput);

            Assert.IsTrue(operationResult.Success[0]);
            Assert.IsTrue(operationResult.ObjectsAffected[0] >= 1);
        }
Example #13
0
        public void DeleteInvalidDatePropertyTest()
        {
            //create a new data entity
            DataEntity entity = new DataEntity();

            //create a new operation input with a new entity array for the input property
            OperationInput operationInput = new OperationInput { Input = new DataEntity[1] };
            //set the first item in the input property
            operationInput.Input[0] = entity;

            //set the name of the operation
            operationInput.Name = "Delete";
            //create the comparison experssion for selecting the records to delete
            ComparisonExpression comparisonExpression = new ComparisonExpression();
            comparisonExpression.ExpressionType = ExpressionType.Comparison;
            comparisonExpression.Operator = ComparisonOperator.Less;
            comparisonExpression.LeftValue = new ComparisonValue { ValueType = ComparisonValueType.Constant, Value = "ModifiedOn" };
            //note: the invalid property where the date should be
            comparisonExpression.RightValue = new ComparisonValue { ValueType = ComparisonValueType.Variable, Value = InvalidPropertyValue };
            operationInput.LookupCondition[0] = comparisonExpression;
            //execute the operation from the connector
            OperationResult operationResult = _rsSourceConnector.ExecuteOperation(operationInput);
            //validate that the operation was not a success
            Assert.IsFalse(operationResult.Success[0]);
            //validate that the error info is filled in
            Assert.IsNotNull(operationResult.ErrorInfo[0]);
        }
        private static System.Xml.XmlQualifiedName DiscoverMethodMessage(string method, string httpHint, ServiceDescription sd)
        {
            string hint = method + httpHint + "In";

            System.Xml.XmlQualifiedName xMessage = null;

            string   serviceName = sd.Services[0].Name;
            PortType pt          = sd.PortTypes[serviceName + httpHint];

            if (pt == null)
            {
                return(null);
            }

            foreach (Operation opItem in pt.Operations)
            {
                if (opItem.Name == method)
                {
                    foreach (OperationMessage mss in opItem.Messages)
                    {
                        OperationInput inputMessage = mss as OperationInput;
                        if (inputMessage != null)
                        {
                            xMessage = inputMessage.Message;
                            break;
                        }
                    }
                }
            }

            return(xMessage);
        }
        /// <summary>
        /// This method will execute an operation returning a result. This method is also used in bulk operations.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public OperationResult ExecuteOperation(OperationInput input)
        {
            OperationResult operationResult;

            // Use LogMethodExecution to add entry and exit tracing to a method. 
            // When wrapped in a using statement, the exit point 
            // is written during garbage collection.
            using (new LogMethodExecution
                (Globals.ConnectorName, "Execute Operation"))
            {
                //Construct a new instance of the operation handler
                //passing along the current instance of the data access object
                OperationHandler operationHandler = new OperationHandler(_dataAccess);

                try
                {
                    // Use the name stored in the operation 
                    // input to determine the correct operation to execute
                    switch (input.Name.ToLower())
                    {
                        case "delete":
                            operationResult = operationHandler.DeleteOperation(input);
                            break;
                        case "create":
                            operationResult = operationHandler.CreateOperation(input);
                            break;
                        case "update":
                            operationResult = operationHandler.UpdateOperation(input);
                            break;
                        default:
                            // Throw an exception when an operation 
                            // that does not exist is requested
                            throw new InvalidExecuteOperationException(
                                ErrorCodes.UnknownOperation.Number, 
                                ErrorCodes.UnknownOperation.Description);
                    }
                    LogOperationResult(operationResult);
                }
                //Here we throw the Fatal Error Exception which is 
                //used to notify upper layers that an error has occured 
                //in the Connector and will be unable to recover from it
                catch (FatalErrorException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    //Log any other exceptions that occur in method execution and 
                    //throw the Invalid Execute Operation Exception 
                    string msg = string.Format("{0} {1}",
                        Globals.ConnectorName, exception.Message);
                    Logger.Write(Logger.Severity.Error,
                        Globals.ConnectorName, msg);
                    throw new InvalidExecuteOperationException(msg);
                }
            }

            return operationResult;
        }
Example #16
0
        /// <summary>
        /// Perform the Delete operation on the created ScribeChangeHistory table
        /// Note: If the data-source already has a process for tracking changes, this
        ///       method will only need to return a positive success in the operation result
        /// </summary>
        /// <param name="operationInput"></param>
        /// <returns></returns>
        public OperationResult DeleteOperation(OperationInput operationInput)
        {
            OperationResult operationResult = new OperationResult();

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(Globals.ConnectorName, "Delete"))
            {
                List <bool>        successList = new List <bool>();
                List <int>         objectList  = new List <int>();
                List <ErrorResult> errors      = new List <ErrorResult>();

                int index = 0;
                //Execute each of the inputs individually
                foreach (DataEntity inputEntity in operationInput.Input)
                {
                    try
                    {
                        //Construct the query that will remove any records in the change
                        //history table that were used in a previous syncronization

                        /*Note:
                         * A more enhanced example of query parsing can be found in
                         * SqlQueryBuilder.cs which is part of the Sample RS Target Connector
                         */
                        string query = string.Format("DELETE FROM ScribeChangeHistory {0}",
                                                     ParseComparisionExpression(
                                                         operationInput.LookupCondition[index] as ComparisonExpression));
                        //execute the query to clean the scribe change history table
                        int recordsDeleted = _dataAccess.ExecuteNonQuery(query);
                        //add a new success result
                        successList.Add(true);
                        objectList.Add(recordsDeleted);
                        errors.Add(new ErrorResult());
                        index++;
                    }
                    catch (Exception exception)
                    {
                        //In the event of an exception do not stop performing all operations
                        //simple log each individually
                        successList.Add(false);
                        objectList.Add(0);
                        errors.Add(new ErrorResult
                        {
                            Description = exception.Message, Detail = exception.ToString()
                        });
                    }
                }

                //Add the results from the operations to the operation result object
                operationResult.Success         = successList.ToArray();
                operationResult.ObjectsAffected = objectList.ToArray();
                operationResult.ErrorInfo       = errors.ToArray();
            }

            return(operationResult);
        }
Example #17
0
        public void loadWSDL(string wsdlString)
        {
            if (!wsdlString.Equals(""))
            {
                StringReader  sr = new StringReader(wsdlString);
                XmlTextReader tx = new XmlTextReader(sr);

                ServiceDescription t = ServiceDescription.Read(tx);
                // Initialize a service description importer.

                ServiceDescription serviceDescription = t.Services[0].ServiceDescription;
                Types types = serviceDescription.Types;
                PortTypeCollection portTypes = serviceDescription.PortTypes;
                MessageCollection  messages  = serviceDescription.Messages;
                XmlSchema          schema    = types.Schemas[0];
                PortType           porttype  = portTypes[0];
                Operation          operation = porttype.Operations[0];
                OperationInput     input     = operation.Messages[0].Operation.Messages.Input;
                Message            message   = messages[input.Message.Name];

                MessagePart messagePart = message.Parts[0];
                //        XmlSchemaObject fsdf = types.Schemas[0].Elements[messagePart.Element];
                XmlSchema fsdf = types.Schemas[0];
                if (fsdf == null)
                {
                    Console.WriteLine("Test");
                }
                StringWriter twriter = new StringWriter();
                //  TextWriter writer= new TextWriter(twriter);
                fsdf.Write(twriter);
                DataSet       set       = new DataSet();
                StringReader  sreader   = new StringReader(twriter.ToString());
                XmlTextReader xmlreader = new XmlTextReader(sreader);
                set.ReadXmlSchema(xmlreader);

                soap = new XmlDocument();
                XmlNode node, envelope, header, body, securityHeader;
                node = soap.CreateXmlDeclaration("1.0", "ISO-8859-1", "yes");

                soap.AppendChild(node);
                envelope = soap.CreateElement("s", "Envelope", "http://www.w3.org/2003/05/soap-envelope");


                soap.AppendChild(envelope);

                body = soap.CreateElement("s", "Body", "http://www.w3.org/2003/05/soap-envelope");
                XmlNode   eingabe = soap.CreateElement("tns", set.Tables[0].ToString(), set.Tables[0].Namespace);
                DataTable table   = set.Tables[0];
                foreach (DataColumn tempColumn in table.Columns)
                {
                    XmlNode neu = soap.CreateElement("tns", tempColumn.ColumnName, set.Tables[0].Namespace);
                    eingabe.AppendChild(neu);
                }
                body.AppendChild(eingabe);
                envelope.AppendChild(body);
                mySettings.Soap = xmlToString(soap);
            }
        }
Example #18
0
        public int[] CalculateCoins(OperationInput operationInput)
        {
            Operation operation = new Operation {
                Target = operationInput.Target, Range = operationInput.Range, Date = DateTime.Now, Type = "Operação"
            };

            _operation.Add(operation);
            return(CoinCalculation.Calculate(operation.Range, operation.Target));
        }
        public void UnknownOperationInvalidTest()
        {
            //create a new operation input with an invalid name
            OperationInput operationInput = new OperationInput {
                Name = "insert"
            };

            //Execute the operation in the connector
            _rsTargetConnector.ExecuteOperation(operationInput);
        }
Example #20
0
        public string[] WsOperations(string url)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                return new string[] { "Please enter a valid URL" }
            }
            ;
            try
            {
                //http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL
                //http://www.thomas-bayer.com/axis2/services/BLZService?wsdl
                List <WsOperation> wsOperations = new List <WsOperation>();

                XmlTextReader      reader = new XmlTextReader(url);
                ServiceDescription wsdl = ServiceDescription.Read(reader);
                string             opName = "", inParam = "", outParam = "";
                foreach (PortType pt in wsdl.PortTypes)
                {
                    foreach (Operation op in pt.Operations)
                    {
                        opName = op.Name;
                        foreach (OperationMessage msg in op.Messages)
                        {
                            if (msg is OperationInput)
                            {
                                inParam = inParam + msg.Message.Name; // check for two or more input parameters?
                                OperationInput oi = msg as OperationInput;
                            }
                            else if (msg is OperationOutput)
                            {
                                outParam = msg.Message.Name;
                            }
                        }

                        wsOperations.Add(new WsOperation(opName, inParam, outParam));
                    }
                }
                if (wsOperations.Count > 0)
                {
                    var outputArray = wsOperations.Select(x => x.operationName + "," + x.inputParameter + "," + x.outputParameter).ToArray();
                    return(outputArray);
                }
                else
                {
                    return(new string[] { "There are no Operations in the provided URL. Please try with different URL" });
                }
            }
            catch (Exception e)
            {
                return(new string[] { e.Message });
            }
            finally
            {
            }
        }
Example #21
0
        /// <summary>
        /// Perform the Delete operation on the created ScribeChangeHistory table
        /// Note: If the data-source already has a process for tracking changes, this 
        ///       method will only need to return a positive success in the operation result
        /// </summary>
        /// <param name="operationInput"></param>
        /// <returns></returns>
        public OperationResult DeleteOperation(OperationInput operationInput)
        {
            OperationResult operationResult = new OperationResult();

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(Globals.ConnectorName, "Delete"))
            {
                List<bool> successList = new List<bool>();
                List<int> objectList = new List<int>();
                List<ErrorResult> errors = new List<ErrorResult>();

                int index = 0;
                //Execute each of the inputs individually
                foreach (DataEntity inputEntity in operationInput.Input)
                {
                    try
                    {
                        //Construct the query that will remove any records in the change
                        //history table that were used in a previous syncronization
                        /*Note:
                         * A more enhanced example of query parsing can be found in
                         * SqlQueryBuilder.cs which is part of the Sample RS Target Connector
                        */
                        string query = string.Format("DELETE FROM ScribeChangeHistory {0}",
                             ParseComparisionExpression(
                             operationInput.LookupCondition[index] as ComparisonExpression));
                        //execute the query to clean the scribe change history table
                        int recordsDeleted = _dataAccess.ExecuteNonQuery(query);
                        //add a new success result
                        successList.Add(true);
                        objectList.Add(recordsDeleted);
                        errors.Add(new ErrorResult());
                        index++;
                    }
                    catch (Exception exception)
                    {
                        //In the event of an exception do not stop performing all operations
                        //simple log each individually
                        successList.Add(false);
                        objectList.Add(0);
                        errors.Add(new ErrorResult
                        { Description = exception.Message, Detail = exception.ToString() });
                    }
                }

                //Add the results from the operations to the operation result object
                operationResult.Success = successList.ToArray();
                operationResult.ObjectsAffected = objectList.ToArray();
                operationResult.ErrorInfo = errors.ToArray();
            }

            return operationResult;
        }
        public string[] WsOperations(string url)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                return new string[] { "ERROR", "Please enter a valid URL" }
            }
            ;
            try
            {
                List <WsOperation> wsOperations = new List <WsOperation>();

                XmlTextReader      reader = new XmlTextReader(url);
                ServiceDescription wsdl   = ServiceDescription.Read(reader);

                foreach (PortType pt in wsdl.PortTypes)
                {
                    foreach (Operation op in pt.Operations)
                    {
                        string opName = "", inParam = "", outParam = "";
                        opName = op.Name;
                        foreach (OperationMessage msg in op.Messages)
                        {
                            if (msg is OperationInput)
                            {
                                inParam = inParam + msg.Message.Name; // check for two or more input parameters?
                                OperationInput oi = msg as OperationInput;
                            }
                            else if (msg is OperationOutput)
                            {
                                outParam = msg.Message.Name;
                            }
                        }

                        wsOperations.Add(new WsOperation(opName, inParam, outParam));
                    }
                }
                if (wsOperations.Count > 0)
                {
                    var outputArray = wsOperations.Select(x => x.operationName + "," + x.inputParameter + "," + x.outputParameter).ToArray();
                    return(outputArray);
                }
                else
                {
                    return(new string[] { "ERROR", "There are no Operations in the provided URL. Please try with different URL" });
                }
            }
            catch (Exception e)
            {
                return(new string[] { "ERROR", e.Message });
            }
            finally
            {
            }
        }
    }
Example #23
0
        public List <WSOperation> GetOperations()
        {
            List <WSOperation> lst = new List <WSOperation>();

            if (serviceDescription != null)
            {
                foreach (Service ser in serviceDescription.Services)
                {
                    String webServiceName = ser.Name.ToString();
                    foreach (Port port in ser.Ports)
                    {
                        string  portName = port.Name;
                        string  binding  = port.Binding.Name;
                        Binding bind     = bindColl[binding];

                        if (bind != null)
                        {
                            PortType portTyp = portTypColl[bind.Type.Name];

                            foreach (Operation op in portTyp.Operations)
                            {
                                WSOperation operObj = new WSOperation();
                                operObj.ClassName  = webServiceName;
                                operObj.MethodName = op.Name;

                                if (lst.Where(it => it.ClassName.Equals(operObj.ClassName) && it.MethodName.Equals(operObj.MethodName)).Count() == 0)
                                {
                                    OperationMessageCollection opMsgColl = op.Messages;
                                    OperationInput             opInput   = opMsgColl.Input;
                                    OperationOutput            opOutput  = opMsgColl.Output;
                                    string inputMsg  = opInput.Message.Name;
                                    string outputMsg = opOutput.Message.Name;

                                    Message            msgInput   = msgColl[inputMsg];
                                    List <WSParameter> InputParam = GetParameters(msgInput);

                                    Message            msgOutput    = msgColl[outputMsg];
                                    List <WSParameter> OutputParams = GetParameters(msgOutput);

                                    operObj.Parameters = InputParam;
                                    if (OutputParams != null && OutputParams.Count > 0)
                                    {
                                        operObj.ReturnType = OutputParams[0].TypeName;
                                    }

                                    lst.Add(operObj);
                                }
                            }
                        }
                    }
                }
            }
            return(lst);
        }
Example #24
0
        /// <summary>
        /// Perform the Delete operations on the selected table.
        /// This method will filter deletes using the SqlQueryBuilder and the lookup conditions
        /// </summary>
        /// <param name="operationInput"></param>
        /// <returns></returns>
        public OperationResult DeleteOperation(OperationInput operationInput)
        {
            OperationResult operationResult = new OperationResult();

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(Globals.ConnectorName, "Delete"))
            {
                List <bool>        successList = new List <bool>();
                List <int>         objectList  = new List <int>();
                List <ErrorResult> errors      = new List <ErrorResult>();

                int index = 0;
                //Execute each of the inputs individually
                foreach (DataEntity inputEntity in operationInput.Input)
                {
                    try
                    {
                        //use the query builder to parse input conditions
                        SqlQueryBuilder queryBuilder = new SqlQueryBuilder(
                            inputEntity, operationInput.LookupCondition[index],
                            Globals.OperationType.Delete);

                        //Execute the query generated from the operation input.
                        int rowsEffected = _dataAccess.ExecuteNonQuery(queryBuilder.ToString());

                        //Add a the result to the result list.
                        successList.Add(rowsEffected >= 1);
                        objectList.Add(rowsEffected);
                        errors.Add(SetErrorResult(rowsEffected));
                        index++;
                    }
                    catch (Exception exception)
                    {
                        // In the event of an exception do not stop performing
                        // all operations simply log each individually
                        successList.Add(false);
                        objectList.Add(0);
                        errors.Add(new ErrorResult()
                        {
                            Description = exception.Message, Detail = exception.ToString()
                        });
                    }
                }

                //Add the results from the operations to the operation result object
                operationResult.Success         = successList.ToArray();
                operationResult.ObjectsAffected = objectList.ToArray();
                operationResult.ErrorInfo       = errors.ToArray();
            }

            return(operationResult);
        }
Example #25
0
        public OperationResult ExecuteOperation(OperationInput input)
        {
            using (new LogMethodExecution(ConnectorTypeDescription, methodInfo.GetCurrentMethodName()))
            {
                try
                {
                    if (service == null || service.IsConnected == false)
                    {
                        throw new ApplicationException("Must connect before calling " +
                                                       methodInfo.GetCurrentMethodName());
                    }

                    if (input == null)
                    {
                        throw new ArgumentNullException(nameof(input));
                    }

                    if (input.Input == null)
                    {
                        throw new ArgumentException(StringMessages.InputPropertyCannotBeNull, nameof(input));
                    }

                    if (!Enum.TryParse(input.Name, out ConnectorService.SupportedActions action))
                    {
                        throw new InvalidExecuteOperationException("Unsupported operation: " + input.Name);
                    }

                    if (input.Input.Length < 1)
                    {
                        throw new ArgumentException(StringMessages.InputNeedsAtLeastOneEntity, nameof(input));
                    }

                    switch (action)
                    {
                    case ConnectorService.SupportedActions.Update:
                        return(service.Update(input.Input[0],
                                              ExpressionParser.GetMatchCriteria(input.LookupCondition[0])));

                    default:
                        throw new InvalidExecuteOperationException("Unsupported operation: " + input.Name);
                    }
                }
                catch (InvalidExecuteOperationException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    unhandledExecptionHandler(methodInfo.GetCurrentMethodName(), exception);
                }
            }
            return(null);
        }
Example #26
0
        internal OperationResult ExecuteOperation(OperationInput operationInput)
        {
            var operationResult = new OperationResult();
            // arrays to keep track of the operations statuses
            var operationSuccess = new List <bool>();
            var entitiesAffected = new List <int>();
            var errorList        = new List <ErrorResult>();
            var entities         = new List <DataEntity>();

            switch (operationInput.Name)
            {
            case "Create":
                foreach (var scribeEntity in operationInput.Input)
                {
                    var returnEntity = new DataEntity();
                    try
                    {
                        if (scribeEntity.ObjectDefinitionFullName == Utils.ConstantUtils.EmployeeCreateFlat_Entity)
                        {
                            var candidate = ScribeUtils.EntityToObject <EmployeeCreateFlat>(scribeEntity);
                            _dayforceClient.CreateEmployee(_connectionInfo, candidate);
                        }

                        operationSuccess.Add(true);
                        errorList.Add(null);
                        entitiesAffected.Add(1);
                        entities.Add(returnEntity);
                    }
                    catch (Exception ex)
                    {
                        //add an error to our collections:
                        var errorResult = new ErrorResult
                        {
                            Description = string.Format("An error returned from DayForce in Create Action: {0}", ex.Message),
                            Detail      = ex.StackTrace,
                        };
                        operationSuccess.Add(false);
                        errorList.Add(errorResult);
                        entitiesAffected.Add(0);
                        entities.Add(null);
                    }
                }
                break;
            }

            //Completed the requests, hand back the results:
            operationResult.Success         = operationSuccess.ToArray();
            operationResult.ObjectsAffected = entitiesAffected.ToArray();
            operationResult.ErrorInfo       = errorList.ToArray();
            operationResult.Output          = entities.ToArray();

            return(operationResult);
        }
Example #27
0
        public void MultiplyOperation_Calculate_Success()
        {
            var operation = new MultiplyOperation();
            var input     = new OperationInput <int>()
            {
                Num1 = 3, Num2 = 5
            };
            var output = operation.Do(input);

            Assert.IsNotNull(output);
            Assert.IsInstanceOfType(output, typeof(OperationOutput <int>));
            Assert.AreEqual(((OperationOutput <int>)output).Result, 15);
        }
Example #28
0
        internal static ParameterCollection Create(OperationInput operation, ReturnValue returnValue, TinyXdto.XdtoFactory factory)
        {
            var data  = new List <Parameter> ();
            var parts = new List <MessagePartProxy> ();

            var def = operation.Operation.PortType.ServiceDescription;

            var message = def.Messages [operation.Message.Name];

            foreach (var oPart in message.Parts)
            {
                var parametersPart = oPart as MessagePart;

                var partParameters = new List <Parameter> ();
                foreach (var oSchema in def.Types.Schemas)
                {
                    var schema = oSchema as XmlSchema;

                    var type = schema.Elements [parametersPart.Element] as XmlSchemaElement;
                    if (type == null)
                    {
                        continue;
                    }

                    var items = ((type.SchemaType as XmlSchemaComplexType).Particle as XmlSchemaSequence).Items;

                    foreach (var item in items)
                    {
                        var element   = item as XmlSchemaElement;
                        var direction = returnValue.OutputParamNames.Contains(element.Name)
                                                                                                   ? ParameterDirectionEnum.InOut
                                                                                                   : ParameterDirectionEnum.In
                        ;

                        partParameters.Add(new Parameter(element, direction, factory));
                    }
                }

                data.AddRange(partParameters);
                parts.Add(new MessagePartProxy {
                    Parameters   = partParameters,
                    Name         = parametersPart.Name,
                    ElementName  = parametersPart.Element.Name,
                    NamespaceUri = parametersPart.Element.Namespace
                });
            }

            // TODO: добавить ТОЛЬКО выходные параметры

            return(new ParameterCollection(data, parts));
        }
Example #29
0
        public async Task <IBuiltTransaction> GetManyOutputsTransferTransactionAsync(OperationInput fromAddress,
                                                                                     IList <OperationOutput> toAddresses,
                                                                                     bool includeFee)
        {
            var input   = fromAddress.ToBitcoinInput(_addressValidator);
            var outputs = toAddresses.Select(o => o.ToBitcoinOutput(_addressValidator)).ToList();
            var builder = new TransactionBuilder();

            foreach (var operationBitcoinOutput in outputs)
            {
                builder.Send(operationBitcoinOutput.Address, operationBitcoinOutput.Amount);
            }

            var minConfirmations = includeFee ? _confirmationsSettings.MinConfirmationsToDetectOperation : 0;
            var coins            = await GetUnspentCoins(input, minConfirmations);

            var addressBalance = coins.Sum(o => o.Amount);
            var sendAmount     = outputs.Sum(o => o.Amount);;
            var sentFees       = Money.Zero;

            builder.SetChange(input.Address);

            var change = addressBalance - sendAmount;

            if (change < new TxOut(Money.Zero, input.Address).GetDustThreshold(builder.StandardTransactionPolicy.MinRelayTxFee) && change > 0)
            {
                builder.SendFees(change);
                sentFees = change;
            }

            builder.AddCoins(coins);

            var calculatedFee = await _feeService.CalcFeeForTransactionAsync(builder) - sentFees;

            var requiredBalance = sendAmount + calculatedFee;

            if (addressBalance < requiredBalance)
            {
                throw new BusinessException($"The sum of total applicable outputs is less than the required : {requiredBalance} satoshis.", ErrorCode.NotEnoughFundsAvailable);
            }

            if (calculatedFee > 0)
            {
                builder.SendFees(calculatedFee);
            }

            var tx        = builder.BuildTransaction(false);
            var usedCoins = builder.FindSpentCoins(tx).ToArray();

            return(BuiltTransaction.Create(tx, tx.GetFee(usedCoins), usedCoins.Cast <Coin>()));
        }
        public OperationResult ExecuteOperation(OperationInput operationInput)
        {
            var operationResult  = new OperationResult();
            var operationSuccess = new List <bool>();
            var entitiesAffected = new List <int>();
            var errorList        = new List <ErrorResult>();
            var entities         = new List <DataEntity>();

            operationResult.Success         = operationSuccess.ToArray();
            operationResult.ObjectsAffected = entitiesAffected.ToArray();
            operationResult.ErrorInfo       = errorList.ToArray();
            operationResult.Output          = entities.ToArray();

            return(operationResult);
        }
        public OperationResult ExecuteOperation(OperationInput input)
        {
            using (new LogMethodExecution(ConnectorTypeDescription, methodInfo.GetCurrentMethodName()))
            {
                try
                {
                    if (service == null || service.IsConnected == false)
                    {
                        throw new ApplicationException("Must connect before calling " + methodInfo.GetCurrentMethodName());
                    }

                    if (input == null)
                    {
                        throw new ArgumentNullException("input");
                    }

                    if (input.Input == null)
                    {
                        throw new ArgumentNullException("input.Input");
                    }

                    ScriptRunnerService.SupportedActions action;
                    if (!Enum.TryParse(input.Name, out action))
                    {
                        throw new InvalidExecuteOperationException("Unsupported operation: " + input.Name);
                    }

                    switch (action)
                    {
                    case ScriptRunnerService.SupportedActions.Execute:
                        return(service.ExecuteExecute(input));

                    default:
                        throw new InvalidExecuteOperationException("Unsupported operation: " + input.Name);
                    }
                }
                catch (InvalidExecuteOperationException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    unhandledExecptionHandler(methodInfo.GetCurrentMethodName(), exception);
                }
            }

            return(null);
        }
Example #32
0
        public OperationResult ExecuteOperation(OperationInput input)
        {
            OperationResult operationResult = null;

            try
            {
                operationResult = this.OperationProcessor.ExecuteOperation(input);
            }

            catch (Exception ex)
            {
                var message = string.Format("{0} {1}", "Error!", ex.Message);
                throw new InvalidExecuteOperationException(message);
            }
            return(operationResult);
        }
Example #33
0
    public bool IsLegalOperation(OperationInput op)
    {
        var xRelative = op.x1 - op.x2;
        var yRelative = op.y1 - op.y2;

        foreach (var r in operationRules)
        {
            if (xRelative == r.xRelative && yRelative == r.yRelative)
            {
                return(true);
            }
            if (xRelative == -r.xRelative && yRelative == -r.yRelative)
            {
                return(true);
            }
        }
        return(false);
    }
 public static OperationBitcoinInput ToBitcoinInput(this OperationInput input, IAddressValidator addressValidator)
 {
     var address = addressValidator.GetBitcoinAddress(input.Address);
     if (address == null)
         throw new BusinessException("Invalid bitcoin address", ErrorCode.BadInputParameter);
     PubKey pubKey = null;
     if (!string.IsNullOrEmpty(input.AddressContext))
     {
         pubKey = addressValidator.GetPubkey(input.AddressContext);
         if (pubKey == null)
             throw new BusinessException("Invalid pubkey", ErrorCode.BadInputParameter);
     }
     return new OperationBitcoinInput
     {
         Address = address,
         Redeem = pubKey?.WitHash.ScriptPubKey,
         Amount = new Money(input.Amount)
     };
 }
Example #35
0
	void PlayInput(Pos2D a, Pos2D b)
	{
		var input = new OperationInput();
		input.x1 = a.x;
		input.y1 = a.y;
		input.x2 = b.x;
		input.y2 = b.y;
		if (!env.IsLegalOperation(input))
		{
			return;
		}
		var output = env.PerformOperation(input);
		if (!output.IsRejected)
		{
			isPlaying = true;
			view.Play(input, output, ()=>{
				isPlaying = false;
			});
		}
	}
Example #36
0
 public void UnknownOperationInvalidTest()
 {
     //create a new operation input with an invalid name
     OperationInput operationInput = new OperationInput { Name = "insert" };
     //Execute the operation in the connector
     _sysConnector.ExecuteOperation(operationInput);
 }
        /// <summary>
        /// This method will execute an operation returning a result. This method is also used in bulk operations.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public OperationResult ExecuteOperation(OperationInput input)
        {
            OperationResult operationResult;

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution
                (Globals.ConnectorName, "Execute Operation"))
            {
                //Construct a new instance of the operation handler
                //passing along the current instance of the data access object
                OperationHandler operationHandler = new OperationHandler(_dataAccess);

                try
                {
                    // Use the name stored in the operation
                    // input to determine the correct operation to execute
                    switch (input.Name.ToLower())
                    {
                        case "delete":
                            operationResult = operationHandler.DeleteOperation(input);
                            break;
                        case "create":
                            operationResult = operationHandler.CreateOperation(input);
                            break;
                        case "update":
                            operationResult = operationHandler.UpdateOperation(input);
                            break;
                        default:
                            // Throw an exception when an operation
                            // that does not exist is requested
                            throw new InvalidExecuteOperationException(
                                ErrorCodes.UnknownOperation.Number,
                                ErrorCodes.UnknownOperation.Description);
                    }
                    LogOperationResult(operationResult);
                }
                //Here we throw the Fatal Error Exception which is
                //used to notify upper layers that an error has occured
                //in the Connector and will be unable to recover from it
                catch (FatalErrorException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    //Log any other exceptions that occur in method execution and
                    //throw the Invalid Execute Operation Exception
                    string msg = string.Format("{0} {1}",
                        Globals.ConnectorName, exception.Message);
                    Logger.Write(Logger.Severity.Error,
                        Globals.ConnectorName, msg);
                    throw new InvalidExecuteOperationException(msg);
                }
            }

            return operationResult;
        }
Example #38
0
        public void DeleteTooManyRowsInvalidTest()
        {
            //create a new data entity
            DataEntity entity = new DataEntity();
            //create a new operation input with a new entity array for the input property
            OperationInput operationInput = new OperationInput { Input = new DataEntity[1] };
            //***   this does not allow multiple rows to be processed with one query
            //      Note: this is the Default value
            operationInput.AllowMultipleObject = false;
            //set the first item in the input property
            operationInput.Input[0] = entity;
            operationInput.Input[0].ObjectDefinitionFullName = "PickLists";
            //set the name of the operation
            operationInput.Name = "Delete";

            //create the comparison experssion for selecting the records to delete
            ComparisonExpression comparisonExpression = new ComparisonExpression();
            comparisonExpression.ExpressionType = ExpressionType.Comparison;
            comparisonExpression.Operator = ComparisonOperator.Equal;
            comparisonExpression.LeftValue = new ComparisonValue { ValueType = ComparisonValueType.Property, Value = "Description" };
            comparisonExpression.RightValue = new ComparisonValue { ValueType = ComparisonValueType.Constant, Value = null };

            operationInput.LookupCondition[0] = comparisonExpression;
            //execute the operation from the connector
            OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
            //validate that the operation was a success
            Assert.IsFalse(operationResult.Success[0]);
        }
Example #39
0
        public void InsertBulkRowsValidTest()
        {
            //create a new method input and use the appropriate operation name
            OperationInput operationInput = new OperationInput { Name = "Create" };

            var input = new List<DataEntity>();
            var screwdriver = new DataEntity("Products");
            var handSaw = new DataEntity("Products");
            var drill = new DataEntity("Products");

            //add the row data to the input
            screwdriver.Properties = new EntityProperties
                                 {
                                     //{"ProductNumber", DateTime.Now.GetHashCode()},
                                     {"ProductNumber", "ZD250"},
                                     {"ProductName", "Screwdriver"},
                                     {"Type", "FinishGood"},
                                     {"UoMSchedule", null},
                                     {"ListPrice", "2"},
                                     {"Cost", "1"},
                                     {"StandardCost", "1"},
                                     {"QuantityInStock", "25"},
                                     {"QuantityOnOrder", "10"},
                                     {"Discontinued", "0"}
                                 };

            //Note: this row should fail because the product number already exists
            handSaw.Properties = new EntityProperties
                                 {
                                     {"ProductNumber", "ZD250"},
                                     {"ProductName", "Hand saw"},
                                     {"Type", "FinishGood"},
                                     {"UoMSchedule", null},
                                     {"ListPrice", "15"},
                                     {"Cost", "5"},
                                     {"StandardCost", "7"},
                                     {"QuantityInStock", "20"},
                                     {"QuantityOnOrder", "15"},
                                     {"Discontinued", "0"}
                                 };

            drill.Properties = new EntityProperties
                                 {
                                     {"ProductNumber", DateTime.UtcNow.GetHashCode()},
                                     {"ProductName", "Drill"},
                                     {"Type", "FinishGood"},
                                     {"UoMSchedule", null},
                                     {"ListPrice", "99"},
                                     {"Cost", "65"},
                                     {"StandardCost", "65"},
                                     {"QuantityInStock", "12"},
                                     {"QuantityOnOrder", "2"},
                                     {"Discontinued", "0"}
                                 };

            //add all records to the input list
            input.Add(screwdriver);
            input.Add(handSaw);
            input.Add(drill);

            operationInput.Input = input.ToArray();

            //execute the selected operation
            OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);

            //verify the result is not a success
            Assert.IsTrue(operationResult.Success[0]);
            //validate that only 1 record was processed
            Assert.AreEqual(1, operationResult.ObjectsAffected[0]);

            //verify that the second result was not a success
            Assert.IsFalse(operationResult.Success[1]);
            //validate that no rows were processed
            Assert.AreEqual(0, operationResult.ObjectsAffected[1]);

            //verify that the final insert was a success
            Assert.IsTrue(operationResult.Success[2]);
            //validate that only 1 record was processed
            Assert.AreEqual(1, operationResult.ObjectsAffected[2]);
        }
Example #40
0
        public void InsertExistingRowInvalidTest()
        {
            //create a new method input and use the appropriate operation name
            OperationInput operationInput = new OperationInput { Name = "create" };

            var input = new List<DataEntity>();
            var table = new DataEntity("Customers");

            var columnData = new EntityProperties();

            //create a DataEntity for the row
            table.ObjectDefinitionFullName = "Customers";
            columnData.Add("CustomerNumber", "ABERDEEN0001");
            columnData.Add("CompanyName", "Aberdeen Inc.");
            columnData.Add("Active", "1");

            //add the row data to the input
            table.Properties = columnData;
            input.Add(table);

            operationInput.Input = input.ToArray();

            //execute the selected operation
            OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
            //verify the result is not a success
            Assert.IsFalse(operationResult.Success[0]);
            //verify that a row was added
            Assert.AreEqual(ErrorNumber.DuplicateUniqueKey, operationResult.ErrorInfo[0].Number);
        }
Example #41
0
 public void DeleteValidTest()
 {
     //create a new data entity
     DataEntity entity = new DataEntity();
     //create a new operation input with a new entity array for the input property
     OperationInput operationInput = new OperationInput {Input = new DataEntity[1]};
     //set the first item in the input property
     operationInput.Input[0] = entity;
     //set the name of the operation
     operationInput.Name = "Delete";
     //create the comparison experssion for selecting the records to delete
     ComparisonExpression comparisonExpression = new ComparisonExpression();
     comparisonExpression.ExpressionType = ExpressionType.Comparison;
     comparisonExpression.Operator = ComparisonOperator.Less;
     comparisonExpression.LeftValue = new ComparisonValue { ValueType = ComparisonValueType.Constant, Value = "ModifiedOn" };
     comparisonExpression.RightValue = new ComparisonValue { ValueType = ComparisonValueType.Variable, Value = DateTime.Now };
     operationInput.LookupCondition[0] = comparisonExpression;
     //execute the operation from the connector
     OperationResult operationResult = _rsSourceConnector.ExecuteOperation(operationInput);
     //validate that the operation was a success
     Assert.IsTrue(operationResult.Success[0]);
 }
Example #42
0
        public void UpdateInvalidIntTest()
        {
            //create a new method input and use the appropriate operation name
            OperationInput operationInput = new OperationInput { Name = "update", AllowMultipleObject = false };
            var input = new List<DataEntity>();
            var table = new DataEntity();
            var columnData = new EntityProperties();

            //create the comparison experssion for selecting the records to update
            operationInput.LookupCondition = new Expression[]
                                        {
                                            new ComparisonExpression(ComparisonOperator.Equal,
                                                                     new ComparisonValue(ComparisonValueType.Property, "Region"),
                                                                     new ComparisonValue(ComparisonValueType.Constant, "North"),
                                                                     null)
                                        };
            //add the columns to change
            table.ObjectDefinitionFullName = "Customers";
            columnData.Add("CreditOnHold", "5328475903427853943453245324532453425345324523453453453425345324523452342345");
            columnData.Add("ModifiedOn", DateTime.Now);

            table.Properties = columnData;
            input.Add(table);

            operationInput.Input = input.ToArray();

            var operationResult = _sysConnector.ExecuteOperation(operationInput);
            //validate that the result of the operation was not a success
            Assert.IsFalse(operationResult.Success[0]);
            //validate that no objects have been affected
            Assert.AreEqual(0, operationResult.ObjectsAffected[0]);
        }
Example #43
0
        public void UpdateMultipleRowsValidTest()
        {
            //create a new method input and use the appropriate operation name
            OperationInput operationInput = new OperationInput { Name = "update", AllowMultipleObject = true };

            var input = new List<DataEntity>();
            var table = new DataEntity();
            var columnData = new EntityProperties();

            //create the comparison experssion for selecting the records to update
            operationInput.LookupCondition = new Expression[]
            {
                new ComparisonExpression(
                    ComparisonOperator.IsNull,new ComparisonValue(ComparisonValueType.Property, "TaxSchedule"), null, null)
            };

            //add the columns to change
            table.ObjectDefinitionFullName = "Addresses";
            columnData.Add("TaxSchedule", "ST-PA");

            table.Properties = columnData;
            input.Add(table);

            operationInput.Input = input.ToArray();

            //execute the selected operaiton
            var operationResult = _sysConnector.ExecuteOperation(operationInput);

            //validate that the operation was success
            Assert.IsTrue(operationResult.Success[0]);
            //validate that multiple rows have been updated
            Assert.IsTrue(operationResult.ObjectsAffected[0] >= 1);
        }
Example #44
0
        public void UpdateMultipleRowsWithComparisonValidTest()
        {
            //create a new data entity
            DataEntity entity = new DataEntity();
            //create a new operation input with a new entity array for the input property
            OperationInput operationInput = new OperationInput { Input = new DataEntity[1] };
            //*** this allows multiple rows to be processed with one query
            operationInput.AllowMultipleObject = true;

            //set the first item in the input property
            entity.ObjectDefinitionFullName = "Addresses";
            entity.Properties.Add("Country", "USA");
            operationInput.Input[0] = entity;

            //set the name of the operation
            operationInput.Name = "update";

            //create the right comparison experssion for selecting the records to update
            ComparisonExpression leftComparisonExpression = new ComparisonExpression();
            leftComparisonExpression.ExpressionType = ExpressionType.Comparison;
            leftComparisonExpression.Operator = ComparisonOperator.IsNull;
            leftComparisonExpression.LeftValue = new ComparisonValue { ValueType = ComparisonValueType.Property, Value = "Phone" };
            leftComparisonExpression.RightValue = null;

            //create the left comparison experssion for selecting the records to update
            ComparisonExpression rightComparisonExpression = new ComparisonExpression();
            rightComparisonExpression.ExpressionType = ExpressionType.Comparison;
            rightComparisonExpression.Operator = ComparisonOperator.IsNull;
            rightComparisonExpression.LeftValue = new ComparisonValue { ValueType = ComparisonValueType.Property, Value = "AddressLine2" };
            rightComparisonExpression.RightValue = null;

            //create a logical expression which will combine the left and right comparison expressions using an AND operator
            LogicalExpression logicalExpression = new LogicalExpression();
            logicalExpression.ExpressionType = ExpressionType.Logical;
            logicalExpression.LeftExpression = leftComparisonExpression;
            logicalExpression.RightExpression = rightComparisonExpression;
            logicalExpression.Operator = LogicalOperator.And;

            //set the logical expression as the parent of the right and left comparison expressions
            leftComparisonExpression.ParentExpression = logicalExpression;
            rightComparisonExpression.ParentExpression = logicalExpression;

            operationInput.LookupCondition[0] = logicalExpression;
            //execute the operation from the connector
            OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
            //validate that the operation was a success
            Assert.IsTrue(operationResult.Success[0]);
            //Validate the amount of rows that have been updated
            //NOTE: this will only work with a clean ScribeSampleRSSource database
            Assert.AreEqual(10, operationResult.ObjectsAffected[0]);
        }
Example #45
0
	private IEnumerator PlayInput(OperationInput input)
	{
		var time = Time.time;
		var list = new List<MoveCellHelper>();

		var move1 = new List<Pos2D>(){ new Pos2D(input.x1, input.y1), new Pos2D(input.x2, input.y2) };
		var move2 = new List<Pos2D>(){ new Pos2D(input.x2, input.y2), new Pos2D(input.x1, input.y1) };
		var a = cells[input.y1, input.x1];
		var b = cells[input.y2, input.x2];

		list.Add(CreateMoveCellHelper(time, a, move1));
		list.Add(CreateMoveCellHelper(time, b, move2));
		yield return PlayMovements(list);

		cells[input.y1, input.x1] = b;
		cells[input.y2, input.x2] = a;
		yield break;
	}
Example #46
0
	public void Play(OperationInput input, OperationOutput output, Action afterFinished)
	{
		StartCoroutine(RecursiveCoroutine.Recursion(PlayCor(input, output, afterFinished)));
	}
Example #47
0
	private IEnumerator PlayCor(OperationInput input, OperationOutput output, Action afterFinished)
	{
		yield return PlayInput(input);

		foreach (var episode in output.episodes)
		{
			switch (episode.etype)
			{
			case OperationOutput.EpisodeType.ELIMINATION:
				yield return PlayEminination(episode);
				break;
			case OperationOutput.EpisodeType.REFILL:
				yield return PlayRefill(episode);
				break;
			case OperationOutput.EpisodeType.SHUFFLE:
				yield return PlayShuffle(episode);
				break;
			default:
				break;
			}
		}

		afterFinished.Invoke();

		yield break;
	}
Example #48
0
        public void InsertUnknownTableInValidTest()
        {
            //create a new method input and use the appropriate operation name
            OperationInput operationInput = new OperationInput { Name = "create" };

            var input = new List<DataEntity>();
            var table = new DataEntity();
            var columnData = new EntityProperties();

            //create a DataEntity for the row
            table.ObjectDefinitionFullName = InvalidPropertyValue;
            columnData.Add("RecordId", Guid.NewGuid().ToString());
            columnData.Add("ProductNumber", "134234g");
            columnData.Add("ProductName", "Screwdriver");
            columnData.Add("Type", "FinishGood");
            columnData.Add("UoMSchedule", "65");
            columnData.Add("ListPrice", "65");
            columnData.Add("Cost", "65");
            columnData.Add("StandardCost", "65");
            columnData.Add("QuantityInStock", "65");
            columnData.Add("QuantityOnOrder", "65");
            columnData.Add("Discontinued", "0");
            columnData.Add("CreatedOn", DateTime.Now);
            columnData.Add("ModifiedOn", DateTime.Now);

            //add the row data to the input
            table.Properties = columnData;
            input.Add(table);

            operationInput.Input = input.ToArray();
            //execute the selected operation
            OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
            //verify the result is not a success
            Assert.IsFalse(operationResult.Success[0]);
            Assert.AreEqual(0, operationResult.ObjectsAffected[0]);
        }
Example #49
0
        public void InsertRowValidTest()
        {
            //create a new method input and use the appropriate operation name
            OperationInput operationInput = new OperationInput { Name = "create" };

            var input = new List<DataEntity>();
            var table = new DataEntity();
            var columnData = new EntityProperties();

            //create a DataEntity for the row
            table.ObjectDefinitionFullName = "Products";
            columnData.Add("RecordId", Guid.NewGuid().ToString());
            columnData.Add("ProductNumber", DateTime.Now.GetHashCode());
            columnData.Add("ProductName", "Screwdriver");
            columnData.Add("Type", "FinishGood");
            columnData.Add("UoMSchedule", null);
            columnData.Add("ListPrice", "65");
            columnData.Add("Cost", "65");
            columnData.Add("StandardCost", "65");
            columnData.Add("QuantityInStock", "65");
            columnData.Add("QuantityOnOrder", "65");
            columnData.Add("Discontinued", "0");

            //add the row data to the input
            table.Properties = columnData;
            input.Add(table);

            operationInput.Input = input.ToArray();

            //execute the selected operation
            OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
            //verify the result is a success
            Assert.IsTrue(operationResult.Success[0]);
            //verify that a row was added
            Assert.IsTrue(operationResult.ObjectsAffected[0] >= 1);
        }
Example #50
0
        public void UpdateInvalidDateTest()
        {
            //create a new method input and use the appropriate operation name
            OperationInput operationInput = new OperationInput { Name = "update", AllowMultipleObject = false };

            var input = new List<DataEntity>();
            var table = new DataEntity();
            var columnData = new EntityProperties();

            //create the comparison experssion for selecting the records to update
            operationInput.LookupCondition = new Expression[]
                                        {
                                            new ComparisonExpression(ComparisonOperator.Equal,
                                                                     new ComparisonValue(ComparisonValueType.Property, "Type"),
                                                                     new ComparisonValue(ComparisonValueType.Constant, "Order"),
                                                                     null)
                                        };
            //add the columns to change
            table.ObjectDefinitionFullName = "SalesOrders";
            columnData.Add("OrderDate", InvalidPropertyValue);
            columnData.Add("ModifiedOn", DateTime.Now);

            table.Properties = columnData;
            input.Add(table);

            operationInput.Input = input.ToArray();

            var operationResult = _sysConnector.ExecuteOperation(operationInput);

            Assert.IsFalse(operationResult.Success[0]);
            Assert.AreEqual(0, operationResult.ObjectsAffected[0]);
        }
Example #51
0
        public OperationResult ExecuteOperation(OperationInput input)
        {
            this.product = "2700,2701,2702,2703,2704,2705,2706,2707,2708,2709,2734";
            this.package = "pkgBorgCheck,pkgBorgVerify,pkgBorgMoveUpdate,pkgBorgGeoPoint,pkgBorgAppend,pkgBorgAppend,pkgBorgAppend,pkgBorgAppend,pkgBorgGeoCode,pkgIntAddressCheck,pkgIntGeoCode";

            if (this.system.Contains("credit"))
            {
                this.serviceUri = new Uri(CheckInputSizeRequest(licensekey));
                HttpWebRequest mykHttpWebRequest = null;
                HttpWebResponse mykHttpWebResponse = null;
                XmlDocument mykXMLDocument = null;
                XmlTextReader mykXMLReader = null;
                mykHttpWebRequest = WebRequest.Create(serviceUri) as HttpWebRequest;
                mykHttpWebRequest.Timeout = 60000;
                mykHttpWebRequest.ReadWriteTimeout = 60000;
                mykHttpWebRequest.Method = "GET";
                mykHttpWebRequest.ContentType = "application/xml; charset=utf-8";
                mykHttpWebRequest.Accept = "application/xml";

                bool calloutSuccess = false;
                while (!calloutSuccess)
                {
                    try
                    {
                        mykHttpWebResponse = (HttpWebResponse)mykHttpWebRequest.GetResponse();
                        calloutSuccess = true;
                    }
                    catch (WebException e)
                    {
                        calloutSuccess = false;
                    }
                }

                mykXMLDocument = new XmlDocument();
                mykXMLReader = new XmlTextReader(mykHttpWebResponse.GetResponseStream());
                mykXMLDocument.Load(mykXMLReader);
                XmlNode krequestNode = mykXMLDocument.DocumentElement.ChildNodes[2];
                int creditbalance;

                try
                {
                    if (input.Input[0].ObjectDefinitionFullName.Contains("Personator"))
                    {
                        this.row++;
                        this.counter++;
                        creditbalance = int.Parse(krequestNode.InnerText);
                    }
                    else
                    {
                        this.row++;
                        this.counter = this.counter + 20;
                        creditbalance = int.Parse(krequestNode.InnerText);
                    }
                }
                catch
                {
                    Logger.Write(Logger.Severity.Info, "Data Results", "Empty List");
                    Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException.ReferenceEquals("Data Results", "Empty List").ToString();
                    throw new System.ArgumentException("Data Results", "Empty List");
                }

                if (creditbalance > this.counter)
                {
                    this.IsConnected = true;
                    Logger.Write(Logger.Severity.Info, "Credit Check Good", "Successful! Credit Balance: " + creditbalance + "On row: " + this.row);
                }
                else
                {
                    if (this.geo > 0)
                    {
                        chargeGEO();
                    }
                    if (this.IntGeo > 0)
                    {
                        chargeIntGeo();
                    }
                    if (this.IntCheck > 0)
                    {
                        chargeIntCheck();
                    }
                    if (this.check > 0)
                    {
                        chargeCheck();
                    }
                    if (this.move > 0)
                    {
                        chargeMove();
                    }
                    if (this.verify > 0)
                    {
                        chargeVerify();
                    }
                    if (this.GeoBasic > 0)
                    {
                        chargeGeoCodeBasic();
                    }
                    if ((this.appendaddress > 0) || (this.appendphone > 0) || (this.appendemail > 0) || (this.appendname > 0))
                    {
                        chargeAppend();
                    }

                    Logger.Write(Logger.Severity.Info, "Process Exception", " Not enough Credits for row: " + this.row + " Estimated Balance: " + (creditbalance - this.counter) + ", Please purchase more credits at http://www.melissadata.com/dqt/credits.htm");
                    this.IsConnected = false;
                    throw new Scribe.Core.ConnectorApi.Exceptions.FatalErrorException("Processing Exception: Not enough Credits for row: " + this.row + " Estimated Balance: " + (creditbalance - this.counter) + ", Please purchase more credits at http://www.melissadata.com/dqt/credits.htm");
                }
            }

            ErrorResult[] ErrorResultArray = new ErrorResult[input.Input.Length];
            int[] ObjectsAffectedArray = new int[input.Input.Length];
            bool[] SuccessArray = new bool[input.Input.Length];
            var outputEntityArray = new DataEntity[input.Input.Length];

            if (input.Input[0].ObjectDefinitionFullName.Contains("Personator") || input.Input[0].ObjectDefinitionFullName.Contains("BulkPersonator"))
            {
                System.ServiceModel.BasicHttpBinding myBinding = new System.ServiceModel.BasicHttpBinding();
                myBinding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
                myBinding.MaxReceivedMessageSize = 900000000;
                System.ServiceModel.EndpointAddress myEndpointAddress = new System.ServiceModel.EndpointAddress("https://personator.melissadata.net/v3/SOAP/ContactVerify");
                SOAP.ServicemdContactVerifySOAPClient client = new SOAP.ServicemdContactVerifySOAPClient(myBinding, myEndpointAddress);
                SOAP.Request request = new SOAP.Request();
                request.CustomerID = licensekey;
                int numLoops = 0;
                if ((input.Input.Length % 100) == 0)
                {
                    numLoops = (int)(input.Input.Length / 100);
                }
                else
                {
                    numLoops = (int)(input.Input.Length / 100) + 1;
                }

                for (int i = 0; i < numLoops; i++)
                {
                    DataEntity data = null;
                    int floorDiv = (int)(input.Input.Length / 100);
                    int innerCount = 0;
                    request.Records = new SOAP.RequestRecord[((i < floorDiv) ? 100 : input.Input.Length % 100)];

                    for (int j = 0; j < ((i < floorDiv) ? 100 : input.Input.Length % 100); j++)
                    {
                        request.Records[j] = new SOAP.RequestRecord();
                        data = input.Input[innerCount];

                        if (data.Properties.ContainsKey("Input_RecordID"))
                        {
                            if (data.Properties["Input_RecordID"] == null)
                            {
                                request.Records[j].RecordID = "";
                            }
                            else
                            {
                                request.Records[j].RecordID = data.Properties["Input_RecordID"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_City"))
                        {
                            if (data.Properties["Input_City"] == null)
                            {
                                request.Records[j].City = "";
                            }
                            else
                            {
                                request.Records[j].City = data.Properties["Input_City"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_State"))
                        {
                            if (data.Properties["Input_State"] == null)
                            {
                                request.Records[j].State = "";
                            }
                            else
                            {
                                request.Records[j].State = data.Properties["Input_State"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_PostalCode"))
                        {
                            if (data.Properties["Input_PostalCode"] == null)
                            {
                                request.Records[j].PostalCode = "";
                            }
                            else
                            {
                                request.Records[j].PostalCode = data.Properties["Input_PostalCode"].ToString();
                            }
                        }

                        if ((data.Properties.ContainsKey("Setting_Columns")))
                        {
                            string Columns = data.Properties["Setting_Columns"].ToString();
                            string[] cols;
                            char[] charcolSeparators = new char[] { ',' };
                            cols = Columns.Split(charcolSeparators, 8, StringSplitOptions.RemoveEmptyEntries);
                            for (int c = 0; c < cols.Length; c++)
                            {
                                if ((data.Properties.ContainsKey("Setting_Columns")) && !cols[c].ToString().Trim().ToLower().Equals("grpaddressdetails") && (!cols[c].ToString().Trim().ToLower().Equals("grpcensus")) && (!cols[c].ToString().Trim().ToLower().Equals("grpgeocode")) && (!cols[c].ToString().Trim().ToLower().Equals("grpnamedetails")) && (!cols[c].ToString().Trim().ToLower().Equals("grpparsedaddress")) && (!cols[c].ToString().Trim().ToLower().Equals("grpparsedemail")) && (!cols[c].ToString().Trim().ToLower().Equals("grpparsedphone")) && (!cols[c].ToString().Trim().ToLower().Equals("grpall")) && (!cols[c].ToString().Trim().ToLower().Equals("grpdemographicbasic")))
                                {
                                    throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid Action, action must be either ({blank}, GrpAddressDetails, GrpCensus, GrpGeocode, GrpNameDetails, GrpParsedAddress, GrpParsedEmail, GrpParsedPhone, GrpAll");
                                }
                                else
                                {
                                    request.Columns = (!data.Properties.ContainsKey("Setting_Columns") ? "" : data.Properties["Setting_Columns"].ToString());
                                }
                            }
                        }

                        if (data.Properties.ContainsKey("Setting_Actions"))
                        {
                            if (data.Properties["Setting_Actions"] == null)
                            {
                                request.Actions = "check";
                            }
                            else
                            {
                                request.Actions = data.Properties["Setting_Actions"].ToString();
                            }
                        }
                        else
                        {
                            request.Actions = "check";
                        }

                        if ((data.Properties.ContainsKey("Setting_Actions")))
                        {
                            string Actions = data.Properties["Setting_Actions"].ToString();
                            string[] act;
                            char[] charSeparators = new char[] { ',' };
                            act = Actions.Split(charSeparators, 4, StringSplitOptions.RemoveEmptyEntries);
                            for (int k = 0; k < act.Length; k++)
                            {
                                if ((data.Properties.ContainsKey("Setting_Actions")) && !act[k].ToString().Trim().ToLower().Equals("append") && (!act[k].ToString().Trim().ToLower().Equals("check")) && (!act[k].ToString().Trim().ToLower().Equals("verify")) && (!act[k].ToString().Trim().ToLower().Equals("move")))
                                {
                                    throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid Action, action must be either (Check, Verify, Append, Move");
                                }
                                else
                                {
                                    request.Actions = (!data.Properties.ContainsKey("Setting_Actions") ? "Check" : data.Properties["Setting_Actions"].ToString());
                                }
                            }
                        }

                        if ((data.Properties.ContainsKey("Setting_AdvancedAddressCorrection")) && (!data.Properties["Setting_AdvancedAddressCorrection"].ToString().Trim().ToLower().Equals("on") && (!data.Properties["Setting_AdvancedAddressCorrection"].ToString().Trim().ToLower().Equals("off"))))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid AdvancedAddressCorrection Property, action must be either (on, off");
                        }
                        else
                        {
                            request.Options = request.Options + "AdvancedAddressCorrection:" + (!data.Properties.ContainsKey("Setting_AdvancedAddressCorrection") ? "off;" : data.Properties["Setting_AdvancedAddressCorrection"].ToString() + ";");
                        }

                        if ((data.Properties.ContainsKey("Setting_CentricHint")) && (!data.Properties["Setting_CentricHint"].ToString().Trim().ToLower().Equals("auto")) && (!data.Properties["Setting_CentricHint"].ToString().Trim().ToLower().Equals("address")) && (!data.Properties["Setting_CentricHint"].ToString().Trim().ToLower().Equals("phone")) && (!data.Properties["Setting_CentricHint"].ToString().Trim().ToLower().Equals("email")))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid CentricHint Property, action must be either (auto, address, phone, email");
                        }
                        else
                        {
                            request.Options = request.Options + "CentricHint:" + (!data.Properties.ContainsKey("Setting_CentricHint") ? "off;" : data.Properties["Setting_CentricHint"].ToString() + ";");
                        }
                        if ((data.Properties.ContainsKey("Setting_Append")) && (!data.Properties["Setting_Append"].ToString().Trim().ToLower().Equals("blank")) && (!data.Properties["Setting_Append"].ToString().Trim().ToLower().Equals("checkerror")) && (!data.Properties["Setting_Append"].ToString().Trim().ToLower().Equals("always")))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid Append Property, action must be either (checkerror, blank, always");
                        }
                        else
                        {
                            request.Options = request.Options + "Append:" + (!data.Properties.ContainsKey("Setting_Append") ? "Always;" : data.Properties["Setting_Append"].ToString() + ";");
                        }

                        if ((data.Properties.ContainsKey("Setting_UsePreferredCity")) && (!data.Properties["Setting_UsePreferredCity"].ToString().Trim().ToLower().Equals("on")) && (!data.Properties["Setting_UsePreferredCity"].ToString().Trim().ToLower().Equals("off")))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid Append Property, action must be either (off, on)");
                        }
                        else
                        {
                            request.Options = request.Options + "UsePreferredCity:" + (!data.Properties.ContainsKey("Setting_UsePreferredCity") ? "off;" : data.Properties["Setting_UsePreferredCity"].ToString() + ";");
                        }

                        if (data.Properties.ContainsKey("Input_AddressLine2"))
                        {
                            if (data.Properties["Input_AddressLine2"] == null)
                            {
                                request.Records[j].AddressLine2 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine2 = data.Properties["Input_AddressLine2"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_Country"))
                        {
                            if (data.Properties["Input_Country"] == null)
                            {
                                request.Records[j].Country = "";
                            }
                            else
                            {
                                request.Records[j].Country = data.Properties["Input_Country"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_CompanyName"))
                        {
                            if (data.Properties["Input_CompanyName"] == null)
                            {
                                request.Records[j].CompanyName = "";
                            }
                            else
                            {
                                request.Records[j].CompanyName = data.Properties["Input_CompanyName"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_FullName"))
                        {
                            if (data.Properties["Input_FullName"] == null)
                            {
                                request.Records[j].FullName = "";
                            }
                            else
                            {
                                request.Records[j].FullName = data.Properties["Input_FullName"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_LastName"))
                        {
                            if (data.Properties["Input_LastName"] == null)
                            {
                                request.Records[j].LastName = "";
                            }
                            else
                            {
                                request.Records[j].LastName = data.Properties["Input_LastName"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_PhoneNumber"))
                        {
                            if (data.Properties["Input_PhoneNumber"] == null)
                            {
                                request.Records[j].PhoneNumber = "";
                            }
                            else
                            {
                                request.Records[j].PhoneNumber = data.Properties["Input_PhoneNumber"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_AddressLine1"))
                        {
                            if (data.Properties["Input_AddressLine1"] == null)
                            {
                                request.Records[j].AddressLine1 = "";
                            }
                            else
                            {
                                request.Records[j].City = request.Records[j].City != null ? request.Records[j].City.Trim() : "";
                                request.Records[j].State = request.Records[j].State != null ? request.Records[j].State.Trim() : "";
                                request.Records[j].PostalCode = request.Records[j].PostalCode != null ? request.Records[j].PostalCode.Trim() : "";
                                request.Records[j].FreeForm = request.Records[j].FreeForm != null ? request.Records[j].FreeForm.Trim() : "";

                                if (request.Records[j].City == "" && request.Records[j].State == "" && request.Records[j].PostalCode == "" && request.Records[j].FreeForm == "")
                                {
                                    request.Records[j].AddressLine1 = "";
                                    request.Records[j].FreeForm = data.Properties["Input_AddressLine1"].ToString();
                                }
                                else
                                {
                                    request.Records[j].AddressLine1 = data.Properties["Input_AddressLine1"].ToString();
                                }
                            }
                        }

                        if (data.Properties.ContainsKey("Input_FreeForm"))
                        {
                            if (data.Properties["Input_FreeForm"] == null)
                            {
                                request.Records[j].FreeForm = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine1 = "";
                                request.Records[j].FreeForm = data.Properties["Input_FreeForm"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_EmailAddress"))
                        {
                            if (data.Properties["Input_EmailAddress"] == null)
                            {
                                request.Records[j].EmailAddress = "";
                            }
                            else
                            {
                                request.Records[j].EmailAddress = data.Properties["Input_EmailAddress"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Setting_Columns"))
                        {
                            if (data.Properties["Setting_Columns"] == null)
                            {
                                request.Columns = "";
                            }
                            else
                            {
                                request.Columns = data.Properties["Setting_Columns"].ToString();
                            }
                        }

                        if (request.Records[j].PostalCode == "" && request.Records[j].State == "" && request.Records[j].City == "" && request.Records[j].FreeForm == "")
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("City, State or Zipcode or Freeform required.");
                        }

                        innerCount++;
                    }

                    this.serviceUri = new Uri(RequestToken(licensekey, this.product, this.package, ((i < floorDiv) ? 100 : input.Input.Length % 100).ToString()));
                    HttpWebRequest myeHttpWebRequest = null;
                    HttpWebResponse myeHttpWebResponse = null;
                    XmlDocument myXMLDocument = null;
                    XmlTextReader myXMLReader = null;
                    myeHttpWebRequest = WebRequest.Create(serviceUri) as HttpWebRequest;
                    myeHttpWebRequest.Timeout = 60000;
                    myeHttpWebRequest.ReadWriteTimeout = 60000;
                    myeHttpWebRequest.Method = "GET";
                    myeHttpWebRequest.ContentType = "application/xml; charset=utf-8";
                    myeHttpWebRequest.Accept = "application/xml";

                    bool success = false;
                    while (!success)
                    {
                        try
                        {
                            myeHttpWebResponse = (HttpWebResponse)myeHttpWebRequest.GetResponse();
                            success = true;
                        }
                        catch (WebException e)
                        {
                            success = false;
                        }
                    }

                    myXMLDocument = new XmlDocument();

                    myXMLReader = new XmlTextReader(myeHttpWebResponse.GetResponseStream());
                    myXMLDocument.Load(myXMLReader);
                    XmlNode resultNode = myXMLDocument.DocumentElement.ChildNodes[0];
                    XmlNode tokenNode = myXMLDocument.DocumentElement.ChildNodes[1];
                    if (resultNode.InnerText.Contains("TS01") || resultNode.InnerText.Contains("TS02"))
                    {
                        request.CustomerID = tokenNode.InnerText;
                        Logger.Write(Logger.Severity.Info, "Connection Results", "Token Successful");
                    }
                    else
                    {
                        Logger.Write(Logger.Severity.Info, "Connection Results", "Token Successful");
                    }
                    SOAP.Response response = null;

                    while (response == null)
                    {
                        try
                        {
                            response = client.doContactVerify(request);
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    for (int l = 0; l < response.Records.Length; l++)
                    {
                        List<PropertyInfo> responseProperties = response.Records[l].GetType().GetProperties().ToList();

                        var output = new DataEntity(input.Input[100 * i + l].ObjectDefinitionFullName);
                        if ((response.Records[l].Results.Contains("AS")))
                        {
                            this.check++;
                        }
                        if (response.Records[l].Results.Contains("GS05") || response.Records[l].Results.Contains("GS06"))
                        {
                            this.geo++;
                        }
                        if (response.Records[l].Results.Contains("GS01"))
                        {
                            this.GeoBasic++;
                        }
                        if (response.Records[l].Results.Contains("VR"))
                        {
                            this.verify++;
                        }
                        if (response.Records[l].Results.Contains("AS12"))
                        {
                            this.move++;
                        }
                        if (response.Records[l].Results.Contains("DA10"))
                        {
                            this.appendname++;
                        }
                        if (response.Records[l].Results.Contains("DA00"))
                        {
                            this.appendaddress++;
                        }
                        if (response.Records[l].Results.Contains("DA30"))
                        {
                            this.appendphone++;
                        }
                        if (response.Records[l].Results.Contains("DA40"))
                        {
                            this.appendemail++;
                        }
                        foreach (PropertyInfo property in responseProperties)
                        {
                            string getValue = property.GetValue(response.Records[l], null) != null ? property.GetValue(response.Records[l], null).ToString() : "";

                            output.Properties["MD_" + property.Name] = getValue;
                        }

                        outputEntityArray[i * 100 + l] = output;
                    }
                }

                ErrorResultArray = new ErrorResult[input.Input.Length];
                ObjectsAffectedArray = new int[input.Input.Length];
                SuccessArray = new bool[input.Input.Length];

                for (int x = 0; x < input.Input.Length; x++)
                {
                    ErrorResultArray[x] = new ErrorResult();
                    ObjectsAffectedArray[x] = 1;
                    SuccessArray[x] = true;
                }
            }

            if (input.Input[0].ObjectDefinitionFullName.Contains("Global_Address_Verification") || input.Input[0].ObjectDefinitionFullName.Contains("BulkGlobal"))
            {
                System.ServiceModel.BasicHttpBinding myBinding = new System.ServiceModel.BasicHttpBinding();
                myBinding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
                myBinding.MaxReceivedMessageSize = 900000000;
                System.ServiceModel.EndpointAddress myEndpointAddress = new System.ServiceModel.EndpointAddress("https://address.melissadata.net/v3/SOAP/GlobalAddress");
                SOAP3.AddressCheckSoapClient client = new SOAP3.AddressCheckSoapClient(myBinding, myEndpointAddress);
                SOAP3.Request request = new SOAP3.Request();
                request.CustomerID = licensekey;
                int numLoops = 0;
                if ((input.Input.Length % 100) == 0)
                {
                    numLoops = (int)(input.Input.Length / 100);
                }
                else
                {
                    numLoops = (int)(input.Input.Length / 100) + 1;
                }

                for (int i = 0; i < numLoops; i++)
                {
                    DataEntity data = null;
                    int floorDiv = (int)(input.Input.Length / 100);
                    int innerCount = 0;
                    request.Records = new SOAP3.RequestRecord[((i < floorDiv) ? 100 : input.Input.Length % 100)];
                    for (int j = 0; j < ((i < floorDiv) ? 100 : input.Input.Length % 100); j++)
                    {
                        request.Records[j] = new SOAP3.RequestRecord();
                        data = input.Input[innerCount];

                        if (data.Properties.ContainsKey("Input_RecordID"))
                        {
                            if (data.Properties["Input_RecordID"] == null)
                            {
                                request.Records[j].RecordID = "";
                            }
                            else
                            {
                                request.Records[j].RecordID = data.Properties["Input_RecordID"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_Organization"))
                        {
                            if (data.Properties["Input_Organization"] == null)
                            {
                                request.Records[j].Organization = "";
                            }
                            else
                            {
                                request.Records[j].Organization = data.Properties["Input_Organization"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_AddressLine1"))
                        {
                            if (data.Properties["Input_AddressLine1"] == null)
                            {
                                request.Records[j].AddressLine1 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine1 = data.Properties["Input_AddressLine1"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine2"))
                        {
                            if (data.Properties["Input_AddressLine2"] == null)
                            {
                                request.Records[j].AddressLine2 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine2 = data.Properties["Input_AddressLine2"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine3"))
                        {
                            if (data.Properties["Input_AddressLine3"] == null)
                            {
                                request.Records[j].AddressLine3 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine3 = data.Properties["Input_AddressLine3"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_AddressLine4"))
                        {
                            if (data.Properties["Input_AddressLine4"] == null)
                            {
                                request.Records[j].AddressLine4 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine4 = data.Properties["Input_AddressLine4"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine5"))
                        {
                            if (data.Properties["Input_AddressLine5"] == null)
                            {
                                request.Records[j].AddressLine5 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine5 = data.Properties["Input_AddressLine5"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine6"))
                        {
                            if (data.Properties["Input_AddressLine6"] == null)
                            {
                                request.Records[j].AddressLine6 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine6 = data.Properties["Input_AddressLine6"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine7"))
                        {
                            if (data.Properties["Input_AddressLine7"] == null)
                            {
                                request.Records[j].AddressLine7 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine7 = data.Properties["Input_AddressLine7"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine8"))
                        {
                            if (data.Properties["Input_AddressLine8"] == null)
                            {
                                request.Records[j].AddressLine8 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine8 = data.Properties["Input_AddressLine8"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_DoubleDependentLocality"))
                        {
                            if (data.Properties["Input_DoubleDependentLocality"] == null)
                            {
                                request.Records[j].DoubleDependentLocality = "";
                            }
                            else
                            {
                                request.Records[j].DoubleDependentLocality = data.Properties["Input_DoubleDependentLocality"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_DependentLocality"))
                        {
                            if (data.Properties["Input_DependentLocality"] == null)
                            {
                                request.Records[j].DependentLocality = "";
                            }
                            else
                            {
                                request.Records[j].DependentLocality = data.Properties["Input_DependentLocality"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_Locality"))
                        {
                            if (data.Properties["Input_Locality"] == null)
                            {
                                request.Records[j].Locality = "";
                            }
                            else
                            {
                                request.Records[j].Locality = data.Properties["Input_Locality"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_SubAdministrativeArea"))
                        {
                            if (data.Properties["Input_SubAdministrativeArea"] == null)
                            {
                                request.Records[j].SubAdministrativeArea = "";
                            }
                            else
                            {
                                request.Records[j].SubAdministrativeArea = data.Properties["Input_SubAdministrativeArea"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_AdministrativeArea"))
                        {
                            if (data.Properties["Input_AdministrativeArea"] == null)
                            {
                                request.Records[j].AdministrativeArea = "";
                            }
                            else
                            {
                                request.Records[j].AdministrativeArea = data.Properties["Input_AdministrativeArea"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_PostalCode"))
                        {
                            if (data.Properties["Input_PostalCode"] == null)
                            {
                                request.Records[j].PostalCode = "";
                            }
                            else
                            {
                                request.Records[j].PostalCode = data.Properties["Input_PostalCode"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_SubNationalArea"))
                        {
                            if (data.Properties["Input_SubNationalArea"] == null)
                            {
                                request.Records[j].SubNationalArea = "";
                            }
                            else
                            {
                                request.Records[j].SubNationalArea = data.Properties["Input_SubNationalArea"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_Country"))
                        {
                            if (data.Properties["Input_Country"] == null)
                            {
                                request.Records[j].Country = "";
                            }
                            else
                            {
                                request.Records[j].Country = data.Properties["Input_Country"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Setting_DeliveryLines"))
                        {
                            if (data.Properties["Setting_DeliveryLines"] == null)
                            {
                                request.Records[j].Country = "";
                            }
                            else
                            {
                                request.Records[j].Country = data.Properties["Setting_DeliveryLines"].ToString();
                            }
                        }

                        if ((data.Properties.ContainsKey("Setting_DeliveryLines")) && (!data.Properties["Setting_DeliveryLines"].ToString().Trim().ToLower().Equals("on") && (!data.Properties["Setting_DeliveryLines"].ToString().Trim().ToLower().Equals("off"))))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid DeliveryLines Property, action must be either (on, off");
                        }
                        else
                        {
                            request.Options = request.Options + "DeliveryLines:" + (!data.Properties.ContainsKey("Setting_DeliveryLines") ? "off;" : data.Properties["Setting_DeliveryLines"].ToString() + ";");
                        }

                        if ((data.Properties.ContainsKey("Setting_LineSeparator")) && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("semicolon") && (!data.Properties["Setting_DeliveryLines"].ToString().Trim().ToLower().Equals("pipe") && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("cr") && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("lf") && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("crlf") && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("tab") && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("br")))))))))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid LineSeparator Property, action must be either (semicolon (default), pipe, cr, lf, crlf, tab, br (line break)");
                        }
                        else
                        {
                            request.Options = request.Options + "LineSeparator:" + (!data.Properties.ContainsKey("LineSeparator") ? "SEMICOLON;" : data.Properties["Setting_DeliveryLines"].ToString() + ";");
                        }

                        if ((data.Properties.ContainsKey("Setting_OutputScript")) && (!data.Properties["Setting_OutputScript"].ToString().Trim().ToLower().Equals("nochange") && (!data.Properties["Setting_OutputScript"].ToString().Trim().ToLower().Equals("latn")) && (!data.Properties["Setting_OutputScript"].ToString().Trim().ToLower().Equals("native"))))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid LineSeparator Property, action must be either (nochange (default), latn, native");
                        }
                        else
                        {
                            request.Options = request.Options + "OutputScript:" + (!data.Properties.ContainsKey("Setting_OutputScript") ? "nochange;" : data.Properties["Setting_OutputScript"].ToString() + ";");
                        }

                        if ((data.Properties.ContainsKey("Setting_CountryOfOrigin")))
                        {
                            request.Options = request.Options + "CountryOfOrigin:" + data.Properties["Setting_CountryOfOrigin"].ToString() + ";";
                        }

                        innerCount++;
                    }
                    this.serviceUri = new Uri(RequestToken(licensekey, this.product, this.package, ((i < floorDiv) ? 100 : input.Input.Length % 100).ToString()));

                    HttpWebRequest myeHttpWebRequest = null;
                    HttpWebResponse myeHttpWebResponse = null;
                    XmlDocument myXMLDocument = null;
                    XmlTextReader myXMLReader = null;
                    myeHttpWebRequest = WebRequest.Create(serviceUri) as HttpWebRequest;
                    myeHttpWebRequest.Timeout = 60000;
                    myeHttpWebRequest.ReadWriteTimeout = 60000;
                    myeHttpWebRequest.Method = "GET";
                    myeHttpWebRequest.ContentType = "application/xml; charset=utf-8";
                    myeHttpWebRequest.Accept = "application/xml";

                    bool success = false;
                    while (!success)
                    {
                        try
                        {
                            myeHttpWebResponse = (HttpWebResponse)myeHttpWebRequest.GetResponse();
                            success = true;
                        }
                        catch (WebException e)
                        {
                            success = false;
                        }
                    }

                    myXMLDocument = new XmlDocument();

                    myXMLReader = new XmlTextReader(myeHttpWebResponse.GetResponseStream());
                    myXMLDocument.Load(myXMLReader);
                    XmlNode resultNode = myXMLDocument.DocumentElement.ChildNodes[0];
                    XmlNode tokenNode = myXMLDocument.DocumentElement.ChildNodes[1];
                    if (resultNode.InnerText.Contains("TS01") || resultNode.InnerText.Contains("TS02"))
                    {
                        request.CustomerID = tokenNode.InnerText;
                        Logger.Write(Logger.Severity.Info, "Connection Results", "Token Successful");
                    }

                    SOAP3.Response response = client.doGlobalAddress(request);

                    for (int l = 0; l < response.Records.Length; l++)
                    {
                        List<PropertyInfo> responseProperties = response.Records[l].GetType().GetProperties().ToList();

                        var output = new DataEntity(input.Input[100 * i + l].ObjectDefinitionFullName);

                        if ((response.Records[l].Results.Contains("AV")))
                        {
                            this.IntCheck++;
                        }
                        if (response.Records[l].Results.Contains("GS"))
                        {
                            this.IntGeo++;
                        }

                        foreach (PropertyInfo property in responseProperties)
                        {
                            string getValue = property.GetValue(response.Records[l], null) != null ? property.GetValue(response.Records[l], null).ToString() : "";

                            output.Properties["MD_" + property.Name] = getValue;
                        }

                        outputEntityArray[i * 100 + l] = output;
                    }
                }

                ErrorResultArray = new ErrorResult[input.Input.Length];
                ObjectsAffectedArray = new int[input.Input.Length];
                SuccessArray = new bool[input.Input.Length];

                for (int x = 0; x < input.Input.Length; x++)
                {
                    ErrorResultArray[x] = new ErrorResult();
                    ObjectsAffectedArray[x] = 1;
                    SuccessArray[x] = true;
                }
            }

            foreach (var entity in outputEntityArray)
            {
                bulkQueue.Enqueue(entity);
            }

            return new OperationResult(input.Input.Length)
            {
                ErrorInfo = ErrorResultArray,
                ObjectsAffected = ObjectsAffectedArray,
                Output = outputEntityArray,
                Success = SuccessArray
            };
        }
Example #52
0
        /// <summary>
        /// Perform the Delete operations on the selected table.
        /// This method will filter deletes using the SqlQueryBuilder and the lookup conditions
        /// </summary>
        /// <param name="operationInput">The operation information being executed.</param>
        /// <returns>The result of the operation that was processed.</returns>
        public OperationResult DeleteOperation(OperationInput operationInput)
        {
            OperationResult operationResult = new OperationResult();

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(Globals.ConnectorName, "Delete"))
            {
                // Each record processed must return the following 3 pieces of information.
                // Each piece of information should be added in the same order it was received.
                // The first piece of information would be whether or not the request was successful.
                // If the requested record does not exist it should not result in a failure.
                List<bool> successList = new List<bool>();
                // The second piece of information is the number of records that have been processed.
                // If a delete is attempted on a record that does not exist then 0 rows should be reported here.
                List<int> objectList = new List<int>();
                // In the event of an error during processing the record, error information should be added here.
                // If no error occured a null placeholder for that record is expected.
                List<ErrorResult> errors = new List<ErrorResult>();

                int index = 0;
                // Execute each of the inputs individually
                // **** Processing inputs individually is done because the
                //      connector is responsible for error handling on each.
                //      The connector must return results in the same order in which the
                //      data entities were received, this allows for reprocessing of failed records.
                //Note: If the SupportsBulk flag is not set in the ActionDefinition
                //      that corresponds to this operation, operationInput.Input
                //      will always have always have a length of 1.
                foreach (DataEntity inputEntity in operationInput.Input)
                {
                    try
                    {
                        // Process the number of rows that will be deleted.
                        ValidateRowCount(inputEntity, operationInput.LookupCondition[index],
                                                   operationInput.AllowMultipleObject);

                        // Use the query builder to parse input conditions.
                        var query = new SqlQueryBuilder(inputEntity, operationInput.LookupCondition[index], Globals.QueryType.Delete);

                        // Execute the query generated from the operation input.
                        int rowCount = _dataAccess.ExecuteNonQuery(query.ToString());

                        // Add a the result to the result list.
                        successList.Add(SetSuccessResult(operationInput.AllowMultipleObject, rowCount));
                        objectList.Add(rowCount);
                        errors.Add(SetErrorResult(rowCount));
                        index++;

                    }
                    catch (ArgumentException argumentException)
                    {
                        // This will catch a filter that returns multiple rows
                        // when only one is expected.
                        var errorResult = new ErrorResult()
                        {
                            Description = argumentException.Message,
                            Number = ErrorCodes.TooManyRowsReturned.Number
                        };

                        errors.Add(errorResult);
                        successList.Add(false);
                        objectList.Add(0);
                    }
                    catch (Exception exception)
                    {
                        // In the event of an exception do not stop performing
                        // all operations simply log each individually
                        successList.Add(false);
                        objectList.Add(0);
                        errors.Add(new ErrorResult() { Description = exception.Message, Detail = exception.ToString() });
                    }
                }

                //Add the results from the operations to the operation result object
                operationResult.Success = successList.ToArray();
                operationResult.ObjectsAffected = objectList.ToArray();
                operationResult.ErrorInfo = errors.ToArray();
            }

            return operationResult;
        }
        /// <summary>
        /// Creates a test OperationInput
        /// </summary>
        /// <returns></returns>
        private OperationInput BuildOperationInput()
        {
            var inputs = new DataEntity[2];
            inputs[0] = new DataEntity
            {
                ObjectDefinitionFullName = "Registrant",
                Properties = new Core.ConnectorApi.Query.EntityProperties()
            };

            inputs[1] = new DataEntity
            {
                ObjectDefinitionFullName = "Registrant",
                Properties = new Core.ConnectorApi.Query.EntityProperties()
            };

            inputs[0].Properties.Add("Email", "*****@*****.**");
            inputs[0].Properties.Add("FirstName", "Bob");
            inputs[0].Properties.Add("LastName", "Roberts");
            inputs[0].Properties.Add("WebinarKey", "1235813");

            inputs[1].Properties.Add("Email", "*****@*****.**");
            inputs[1].Properties.Add("FirstName", "Joe");
            inputs[1].Properties.Add("LastName", "Josephs");
            inputs[1].Properties.Add("WebinarKey", "1235813");

            var operation = new OperationInput
            {
                Name = "Create",
                Input = inputs
            };

            return operation;
        }
Example #54
0
        /// <summary>
        /// Perform the Upsert operations on the selected table. The connector will first identify if the DataEntity
        /// already exists in the data source and then perform either an update or insert operation based on the results.
        /// This method will filter updates using the 
        /// SqlQueryBuilder and the lookup conditions
        /// </summary>
        /// <param name="operationInput">The operation information being executed.</param>
        /// <param name="metadataAccess">Metadata associated with the active connection.</param>
        /// <returns>The result of the operation that was processed.</returns>
        public OperationResult UpsertOperation(OperationInput operationInput, OleDbMetadataAccess metadataAccess)
        {
            OperationResult operationResult = new OperationResult();

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(Globals.ConnectorName, "Upsert"))
            {
                // Each record processed must return the following 3 pieces of information.
                // Each piece of information should be added in the same order it was received.
                // The first piece of information would be whether or not the request was successful.
                List<bool> successList = new List<bool>();
                // The second piece of information is the number of records that have been processed.
                List<int> objectList = new List<int>();
                // In the event of an error during processing the record, error information should be added here.
                // If no error occured a null placeholder for that record is expected.
                List<ErrorResult> errors = new List<ErrorResult>();

                //Execute each of the inputs individually
                // **** Processing inputs individually is done because the
                //      connector is responsible for error handling on each.
                //      The connector must return results in the same order in which the
                //      data entities were received, this allows for reprocessing of failed records.
                //Note: If the SupportsBulk flag is not set in the ActionDefinition
                //      that corresponds to this operation, operationInput.Input
                //      will always have always have a length of 1.
                foreach (DataEntity inputEntity in operationInput.Input)
                {
                    try
                    {
                        var primaryKeyPropertes = GetPrimaryKeyProperties(inputEntity, metadataAccess);

                        //Generate the query to perform the upsert
                        var upsertQuery =
                            new SqlQueryBuilder(inputEntity, primaryKeyPropertes, Globals.QueryType.Upsert);

                        //execute the upsert query
                        int rowsEffected = _dataAccess.ExecuteNonQuery(upsertQuery.ToString());

                        //Add the result of the update to the result lists
                        //set the appropriate success results, If multiple records were returned but the operation did not allow multiples
                        //then the operation was not successfull.
                        successList.Add(SetSuccessResult(operationInput.AllowMultipleObject, rowsEffected));
                        objectList.Add(rowsEffected);
                        errors.Add(SetErrorResult(rowsEffected));
                    }
                    catch (Exception exception)
                    {
                        //In the event of an exception do not stop performing all operations
                        //simple log each individually
                        successList.Add(false);
                        objectList.Add(0);
                        errors.Add(new ErrorResult() { Description = exception.Message, Detail = exception.ToString() });
                    }
                }

                //Add the results from the operations to the operation result object
                operationResult.Success = successList.ToArray();
                operationResult.ObjectsAffected = objectList.ToArray();
                operationResult.ErrorInfo = errors.ToArray();
            }
            return operationResult;
        }
Example #55
0
        public void DeleteValidTest()
        {
            //create a new data entity
            DataEntity entity = new DataEntity();
            //create a new operation input with a new entity array for the input property
            OperationInput operationInput = new OperationInput { Input = new DataEntity[1] };
            //set the first item in the input property
            operationInput.Input[0] = entity;
            operationInput.Input[0].ObjectDefinitionFullName = "Picklists";
            //set the name of the operation
            operationInput.Name = "Delete";

            //create the comparison experssion for selecting the records to delete
            ComparisonExpression comparisonExpression = new ComparisonExpression();
            comparisonExpression.ExpressionType = ExpressionType.Comparison;
            comparisonExpression.Operator = ComparisonOperator.Equal;
            comparisonExpression.LeftValue = new ComparisonValue { ValueType = ComparisonValueType.Property, Value = "Code" };
            comparisonExpression.RightValue = new ComparisonValue { ValueType = ComparisonValueType.Constant, Value = "NH" };

            operationInput.LookupCondition[0] = comparisonExpression;
            //execute the operation from the connector
            OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
            //validate that the operation was a success
            Assert.IsTrue(operationResult.Success[0]);
            //Validate that only one row of data has been deleted
            //NOTE: this will only work with a clean ScribeSampleRSSource database
            Assert.AreEqual(1, operationResult.ObjectsAffected[0]);
        }
Example #56
0
        public void DeleteBulkRowsValidTest()
        {
            //create a new data entities
            DataEntity micronesia = new DataEntity("Picklists");
            DataEntity samoa = new DataEntity("Picklists");
            DataEntity doesNotExist = new DataEntity("Picklists");
            DataEntity alberta = new DataEntity("Picklists");

            //add the data entities to the input list
            var input = new List<DataEntity> {micronesia, samoa, doesNotExist, alberta};

            //create a new operation input and set the name of the operation
            OperationInput operationInput = new OperationInput("Delete");
            //*** this allows multiple rows to be processed with one query
            operationInput.AllowMultipleObject = false;
            //set the input property
            operationInput.Input = input.ToArray();

            //create the comparison experssion for selecting the micronesia data entitiy
            ComparisonExpression micronesiaExpression = new ComparisonExpression();
            micronesiaExpression.ExpressionType = ExpressionType.Comparison;
            micronesiaExpression.Operator = ComparisonOperator.Equal;
            micronesiaExpression.LeftValue = new ComparisonValue
            { ValueType = ComparisonValueType.Property, Value = "Description" };
            micronesiaExpression.RightValue = new ComparisonValue
            { ValueType = ComparisonValueType.Constant, Value = "Federated States of Micronesia" };

            //create the comparison experssion for selecting the samoa data entitiy
            ComparisonExpression samoaExpression = new ComparisonExpression();
            samoaExpression.ExpressionType = ExpressionType.Comparison;
            samoaExpression.Operator = ComparisonOperator.Equal;
            samoaExpression.LeftValue = new ComparisonValue
            { ValueType = ComparisonValueType.Property, Value = "Description" };
            samoaExpression.RightValue = new ComparisonValue
            { ValueType = ComparisonValueType.Constant, Value = "American Samoa" };

            //create the comparison experssion for selecting the doesNotExist data entitiy
            ComparisonExpression doesNotExistExpression = new ComparisonExpression();
            doesNotExistExpression.ExpressionType = ExpressionType.Comparison;
            doesNotExistExpression.Operator = ComparisonOperator.Equal;
            doesNotExistExpression.LeftValue = new ComparisonValue
            { ValueType = ComparisonValueType.Property, Value = "Description" };
            //since this value does not exist in the table it will result in an error
            doesNotExistExpression.RightValue = new ComparisonValue
            { ValueType = ComparisonValueType.Constant, Value = "Does Not Exist" };

            //create the comparison experssion for selecting the alberta data entitiy
            ComparisonExpression albertaExpression = new ComparisonExpression();
            albertaExpression.ExpressionType = ExpressionType.Comparison;
            albertaExpression.Operator = ComparisonOperator.Equal;
            albertaExpression.LeftValue = new ComparisonValue
            { ValueType = ComparisonValueType.Property, Value = "Description" };
            albertaExpression.RightValue = new ComparisonValue
            { ValueType = ComparisonValueType.Constant, Value = "Alberta" };

            // Create a list to hold the expressions.
            // Notice the expressions will be in the same order as the data entities.
            // The number of expressions will always be the same as the number of data entities.
            var expressions = new List<Expression>();
            expressions.Add(micronesiaExpression);
            expressions.Add(samoaExpression);
            expressions.Add(doesNotExistExpression);
            expressions.Add(albertaExpression);
            operationInput.LookupCondition = expressions.ToArray();

            //execute the operation from the connector
            OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);

            // *** Validate the results of the operation, note the number of results
            // *** must be equal to the number of inputs and must also share the same index.

            //validate the micronesion delete operation
            Assert.IsTrue(operationResult.Success[0]);
            Assert.AreEqual(1, operationResult.ObjectsAffected[0]);

            //validate the samoa delete operation
            Assert.IsTrue(operationResult.Success[1]);
            Assert.AreEqual(1, operationResult.ObjectsAffected[1]);

            //validate the does not exist delete operation
            Assert.IsTrue(operationResult.Success[2]);
            Assert.AreEqual(0, operationResult.ObjectsAffected[2]);
            Assert.IsNotNull(operationResult.ErrorInfo[2].Description);

            //validate the micronesion delete operaiton
            Assert.IsTrue(operationResult.Success[3]);
            Assert.AreEqual(1, operationResult.ObjectsAffected[3]);
        }
Example #57
0
        public void DeleteNoRowsFoundInValidTest()
        {
            //create a new data entity
            DataEntity entity = new DataEntity();
            //create a new operation input with a new entity array for the input property
            OperationInput operationInput = new OperationInput { Input = new DataEntity[1] };
            //set the first item in the input property
            operationInput.Input[0] = entity;
            operationInput.Input[0].ObjectDefinitionFullName = "Products";
            //set the name of the operation
            operationInput.Name = "Delete";

            //create the comparison experssion for selecting the records to delete
            ComparisonExpression comparisonExpression = new ComparisonExpression();
            comparisonExpression.ExpressionType = ExpressionType.Comparison;
            comparisonExpression.Operator = ComparisonOperator.Greater;
            comparisonExpression.LeftValue = new ComparisonValue { ValueType = ComparisonValueType.Property, Value = "Products.ModifiedOn" };
            comparisonExpression.RightValue = new ComparisonValue { ValueType = ComparisonValueType.Constant, Value = DateTime.UtcNow };

            operationInput.LookupCondition[0] = comparisonExpression;
            //execute the operation from the connector
            OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
            //validate that the operation was a success
            Assert.IsTrue(operationResult.Success[0]);
            //validate that no rows have been found
            Assert.AreEqual(0, operationResult.ObjectsAffected[0]);
            //validate the proper error code has been returned
            //Note: this error code can be found in the connector in ErrorCodes.cs
            Assert.AreEqual(17, operationResult.ErrorInfo[0].Number);
        }
Example #58
0
        public void UpdateBulkRowsValidTest()
        {
            //create a new method input and use the appropriate operation name
            OperationInput operationInput = new OperationInput { Name = "Update" };

            var inputs = new List<DataEntity>();
            var lookupConditions = new List<Expression>();

            // Each update will consist of one DataEntity object and one LookupCondition object.
            // The reletated objects have the same indexes in their corresponding arrays.
            var retail = new DataEntity("Picklists");
            //add the row data to the input
            retail.Properties = new EntityProperties { { "Description", DateTime.UtcNow } };
            //Generate the comparison expression for retail, this will define the where clause portion of the query.
            var retailLookupCondition = new ComparisonExpression( ComparisonOperator.Equal,
                new ComparisonValue(ComparisonValueType.Property, "Code"),
                new ComparisonValue(ComparisonValueType.Constant, "Retail"),
                null);

            inputs.Add(retail);
            lookupConditions.Add(retailLookupCondition);

            var priceLists = new DataEntity("Picklists");
            priceLists.Properties = new EntityProperties { { "Code", "Wholesale" } };
            // Note: This record will return success but with not rows processed
            //       because 'PriceList' does not exist in the [Code] column
            var priceListsLookupCondition = new ComparisonExpression(
                ComparisonOperator.Equal,
                new ComparisonValue(ComparisonValueType.Property, "Code"),
                new ComparisonValue(ComparisonValueType.Constant, "PriceList"),
                null);

            inputs.Add(priceLists);
            lookupConditions.Add(priceListsLookupCondition);

            var finishGood = new DataEntity("Picklists");
            // Note: This record will fail because null is not a valid value for PickListName
            finishGood.Properties = new EntityProperties {{"PickListName", null}};
            var finishGoodLookupCondition = new ComparisonExpression(
                ComparisonOperator.Equal,
                new ComparisonValue(ComparisonValueType.Property, "Code"),
                new ComparisonValue(ComparisonValueType.Constant, "FinishGood"),
                null);

            inputs.Add(finishGood);
            lookupConditions.Add(finishGoodLookupCondition);

            var invoiceType = new DataEntity("Picklists");
            invoiceType.Properties = new EntityProperties
                                 { {"Description", DateTime.UtcNow } };
            var invoiceLookupCondition = new ComparisonExpression(
                ComparisonOperator.Equal,
                new ComparisonValue(ComparisonValueType.Property, "Code"),
                new ComparisonValue(ComparisonValueType.Constant, "Invoice"),
                null);

            // Add the data entity and lookup condition.
            // Note: This is the same order the results MUST be returned.
            inputs.Add(invoiceType);
            lookupConditions.Add(invoiceLookupCondition);

            // Input and LookupCondition will be received by the connector as an array.
            operationInput.Input = inputs.ToArray();
            operationInput.LookupCondition = lookupConditions.ToArray();

            //execute the selected operation
            OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);

            //verify the result is not a success
            Assert.IsTrue(operationResult.Success[0]);
            //validate that only 1 record was processed
            Assert.AreEqual(1, operationResult.ObjectsAffected[0]);

            //verify the result is not a success
            Assert.IsTrue(operationResult.Success[1]);
            //validate that no records were processed
            Assert.AreEqual(0, operationResult.ObjectsAffected[1]);

            //verify that the second result was not a success
            Assert.IsFalse(operationResult.Success[2]);
            //validate that no rows were processed
            Assert.AreEqual(0, operationResult.ObjectsAffected[2]);

            //verify that the final update was a success
            Assert.IsTrue(operationResult.Success[3]);
            //validate that only 1 record was processed
            Assert.AreEqual(1, operationResult.ObjectsAffected[3]);
        }
Example #59
0
        public void UpdateBooleanValidTest()
        {
            var input = new List<DataEntity>();
            var table = new DataEntity();
            var columnData = new EntityProperties();
            var operationInput = new OperationInput();
            operationInput.Name = "update";

            operationInput.AllowMultipleObject = false;

            //create a new comparison expression that will only attempt to update one row of data
            operationInput.LookupCondition = new Expression[]
                                        {
                                            new ComparisonExpression(ComparisonOperator.Equal,
                                                                     new ComparisonValue(ComparisonValueType.Property, "ProductNumber"),
                                                                     new ComparisonValue(ComparisonValueType.Constant,"ME256"),
                                                                     null)
                                        };

            table.ObjectDefinitionFullName = "Products";
            //This will only accept a value that has a value of 1, or 0 for TRUE or FALSE
            columnData.Add("Discontinued", 1);

            table.Properties = columnData;
            input.Add(table);

            operationInput.Input = input.ToArray();

            var operationResult = _sysConnector.ExecuteOperation(operationInput);
            //validate the the result was a success
            Assert.IsTrue(operationResult.Success[0]);
            //validate that only one row of data was affected
            Assert.AreEqual(1, operationResult.ObjectsAffected[0]);
        }
Example #60
0
 public OperationResult ExecuteOperation(OperationInput input)
 {
     throw new NotImplementedException();
 }