public SalesOrderTransformation(RequestContext context)
     : base(context, SupportedResourceKinds.salesOrders)
 {
     _salesOrderLineTransformation =
         TransformationFactory.GetTransformation <SalesOrderLineTransformation>(
             SupportedResourceKinds.salesOrderLines, context);
 }
Ejemplo n.º 2
0
    public AFormat TransformTo(String fName)
    {
        ITransformation step1 = TransformationFactory.CreateTransformation(Name, "find"),
                        step2 = TransformationFactory.CreateTransformation("find", fName);

        return(step2.Transform(step1.Transform(this)));
    }
Ejemplo n.º 3
0
 public UnitOfMeasureWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.unitsOfMeasure)
 {
     _entity         = new UnitOfMeasure();
     _transformation = TransformationFactory.GetTransformation
                       <ITransformation <UnitOfMeasureDocument, UnitOfMeasurePayload> >
                           (SupportedResourceKinds.unitsOfMeasure, context);
 }
 public EmailWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.emails)
 {
     _entity         = new Email();
     _transformation = TransformationFactory.GetTransformation
                       <ITransformation <EmailDocument, EmailPayload> >
                           (SupportedResourceKinds.emails, context);
 }
Ejemplo n.º 5
0
 public CommodityGroupWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.commodityGroups)
 {
     _entity         = new ProductFamily();
     _transformation = TransformationFactory.GetTransformation
                       <ITransformation <ProductFamilyDocument, CommodityGroupPayload> >
                           (SupportedResourceKinds.commodityGroups, context);
 }
Ejemplo n.º 6
0
 public PriceWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.prices)
 {
     _entity         = new Price();
     _transformation = TransformationFactory.GetTransformation
                       <ITransformation <PriceDocument, PricePayload> >
                           (SupportedResourceKinds.prices, context);
 }
Ejemplo n.º 7
0
 public PostalAddressWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.postalAddresses)
 {
     _entity         = new Account();
     _transformation = TransformationFactory.GetTransformation <ITransformation <AddressDocument, PostalAddressPayload> >
                           (SupportedResourceKinds.postalAddresses, context);
     _tradingAccountUuidPayloadPath = _resourceKind.ToString() + "/" + SupportedResourceKinds.tradingAccounts.ToString();
 }
 public PhoneNumberWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.phoneNumbers)
 {
     _entity         = new Account();
     _transformation = TransformationFactory.GetTransformation <ITransformation <PhoneDocument, PhoneNumberPayload> >
                           (SupportedResourceKinds.phoneNumbers, context);
     _tradingAccountUuidPayloadPath = _resourceKind.ToString() + "/" + SupportedResourceKinds.tradingAccounts.ToString();
 }
Ejemplo n.º 9
0
 public ContactWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.contacts)
 {
     _entity         = new Account();
     _transformation = TransformationFactory.GetTransformation <ITransformation <PersonDocument, ContactPayload> >
                           (SupportedResourceKinds.contacts, context);
     _tradingAccountUuidPayloadPath = _resourceKind.ToString() + "/" + SupportedResourceKinds.tradingAccounts.ToString();
 }
Ejemplo n.º 10
0
        public void Should_ReturnCorrectTransformation(Transformation transformation, Type expectedType)
        {
            //Arrange
            var sut = new TransformationFactory();

            //Act
            var createdTransformation = sut.Create(transformation);

            //Assert
            createdTransformation.Should().BeOfType(expectedType);
        }
        public void TryGetCodeAndName_ShouldGetExpected(
            string propertyName,
            bool expectedResult,
            string expectedPropertyName)
        {
            // arrange
            var result = TransformationFactory.TryGetCodeAndName(propertyName, out _, out var name);

            // assert
            result.Should().Be(expectedResult);
            name.Should().Be(expectedPropertyName);
        }
Ejemplo n.º 12
0
        public void Should_ThrowException_If_InvalidTransformation()
        {
            //Arrange
            const Transformation invalidTransformation = (Transformation)Int32.MaxValue;
            var sut = new TransformationFactory();

            //Act
            Func <ITransformation> act = () => sut.Create(invalidTransformation);

            //Assert
            act.Should().Throw <ArgumentOutOfRangeException>();
        }
Ejemplo n.º 13
0
        public void Should_TransformTextCorrect(Transformation transformation, string inputText, string expectedTransformedText)
        {
            //Arrange
            var transformationFactory = new TransformationFactory();
            var sut = new TextService(transformationFactory);

            //Act
            var transformedText = sut.TransformText(transformation, inputText);

            //Assert
            transformedText.Should().Be(expectedTransformedText);
        }
Ejemplo n.º 14
0
        public void Should_ReturnTrimmedInputText()
        {
            //Arrange
            const string textSurroundedByWhiteSpaces = "     text      ";
            const string expectedText          = "text";
            var          transformationFactory = new TransformationFactory();
            var          sut = new TextService(transformationFactory);

            //Act
            var transformedText = sut.TransformText(Transformation.None, textSurroundedByWhiteSpaces);

            //Assert
            transformedText.Should().Be(expectedText);
        }
Ejemplo n.º 15
0
        public void Should_ReturnEmptyString_If_TextIsEmpty()
        {
            //Arrange
            const string emptyText             = "";
            const string expectedText          = "";
            var          transformationFactory = new TransformationFactory();
            var          sut = new TextService(transformationFactory);

            //Act
            var transformedText = sut.TransformText(Transformation.None, emptyText);

            //Assert
            transformedText.Should().Be(expectedText);
        }
Ejemplo n.º 16
0
        // testing Markov Rules, to start
        // had to make changes to the Markov Generator.
        // but now we can serialize/deserialize
        // plus, some names make a tiny bit more sense
        // I'm rethinking the whole "MarkovRuleType" necessity.
        // it's almos all params EXCEPT for the XrayWord type -- that has words and puncts as tokens.
        // can that be done with a regex?
        public void TestRuleSerialization()
        {
            // List<ITransformer> globalRules

            //// THIS WORKS
            //var l = new Leet();
            //var lx = l.ToXml();
            //var ll = new Leet().FromXML(lx);

            // THIS does NOT work
            var tf    = new TransformationFactory(Granularity.Word);
            var rules = tf.GetTransformers();

            // cannot deserialize Leet....
            var rx = rules.ToXml();
            var rr = new List <TransformerBase>().FromXML(rx);
        }
Ejemplo n.º 17
0
        public TradingAccountTransformation(RequestContext context)
            : base(context, SupportedResourceKinds.tradingAccounts)
        {
            _postalAdressTransformation =
                TransformationFactory.GetTransformation <PostalAdressTransformation>(
                    SupportedResourceKinds.postalAddresses, context);

            _contactTransformation =
                TransformationFactory.GetTransformation <ContactTransformation>(
                    SupportedResourceKinds.contacts, context);

            _emailAdressTransformation =
                TransformationFactory.GetTransformation <EmailAdressTransformation>(
                    SupportedResourceKinds.emails, context);

            _phoneNumberTransformation =
                TransformationFactory.GetTransformation <PhoneNumberTransformation>(
                    SupportedResourceKinds.phoneNumbers, context);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Quick controller for fun image display. Better to split it out if more is needed in the future.
        /// </summary>
        /// <param name="rows">Number of rows to create</param>
        /// <param name="columns">Number of columns to create</param>
        /// <returns>An image and 200 response</returns>
        /// <remarks>
        ///		The call is http://yourserverhere/api/Image?row=r&column=c. For example, from the sample:
        ///		http://localhost:64876/api/Image?row=F&column=12
        /// </remarks>
        public HttpResponseMessage Get(string row, int column)
        {
            Triangle          tri1  = new Triangle(new Vertex(0.0, 0.0), new Vertex(10.0, 0.0), new Vertex(0.0, 10.0));
            Triangle          tri2  = (Triangle)TransformationFactory.Translate(TransformationFactory.RotateOnCenter(tri1, Math.PI), 10.0, 10.0);
            KaleidoscopeImage image = new KaleidoscopeImage(new List <IPolygon>()
            {
                tri1, tri2
            }, 10, 10);
            KaledioscopeRepeater repeater = new KaledioscopeRepeater(image, row, column);
            KaleidoscopeDrawer   drawer   = new KaleidoscopeDrawer(repeater);
            Bitmap bmp = drawer.GetImage();

            using (MemoryStream ms = new MemoryStream())
            {
                bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
                response.Content = new ByteArrayContent(ms.ToArray());
                response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/png");
                return(response);
            }
        }
Ejemplo n.º 19
0
        public void RotateTest_Success()
        {
            // Setup: Create simple triangle poly (right triangle)
            Triangle tri = new Triangle(new List <Vertex>()
            {
                new Vertex(0.0, 0.0),
                new Vertex(1.0, 0.0),
                new Vertex(0.0, 1.0)
            });

            // Test 180deg rotation
            Triangle rotatedTri = (Triangle)TransformationFactory.RotateOnCenter(tri, Math.PI);

            // Assert: Make sure all vertices are what we would expect
            bool pointC = false;
            bool pointB = false;
            bool pointA = false;

            foreach (Line line in rotatedTri.GetLines())
            {
                // This will make sure all three points are the same
                if ((line.V1.X == 0.0 && line.V1.Y == 0.0) || (line.V2.X == 0.0 && line.V2.Y == 0.0))
                {
                    pointC = true;
                }

                if (line.V1.X == -1.0 && line.V1.Y == 0.0 || (line.V2.X == -1.0 && line.V2.Y == 0.0))
                {
                    pointB = true;
                }

                if (line.V1.X == 0.0 && line.V1.Y == -1.0 || (line.V2.X == 0.0 && line.V2.Y == -1.0))
                {
                    pointA = true;
                }
            }
            Assert.IsTrue(pointA && pointB && pointC, "Point A: " + pointA.ToString() + " Point B: " + pointB.ToString() + " Point C: " + pointC.ToString());
        }
Ejemplo n.º 20
0
 public RuleSetEditor(TransformationFactory fac, MultipleSelectionControl control, List <RuleSet> activeRuleSetEditors)
     : this(control, activeRuleSetEditors)
 {
     RuleSet       = new RuleSet(fac.Granularity);
     RuleSet.Rules = fac.GetTransformers();
 }
Ejemplo n.º 21
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            // Reloads invalidate the ParentContainer, so we should do it much later.
            string etlName =
                patternNavigator.SelectSingleNode("@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;

            Message.Trace(Severity.Notification, "{0}", etlName);
            bool delayValidation = patternNavigator.SelectSingleNode("@DelayValidation").ValueAsBoolean;

            string sourceName = patternNavigator.SelectSingleNode("rc:SourceConnection/@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;

            Connection sourceConnection =
                Connection.GetExistingConnection(
                    VulcanPackage,
                    patternNavigator.SelectSingleNode("rc:SourceConnection/@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value
                    );

            if (sourceConnection != null)
            {
                string query = patternNavigator.SelectSingleNode("rc:Query", VulcanPackage.VulcanConfig.NamespaceManager).Value.Trim();

                // Add the Data Flow Task to the Package.
                DTS.TaskHost pipeHost = (DTS.TaskHost)ParentContainer.Executables.Add("STOCK:PipelineTask");
                pipeHost.Properties["DelayValidation"].SetValue(pipeHost, delayValidation);
                MainPipe dataFlowTask = (MainPipe)pipeHost.InnerObject;
                pipeHost.Name = etlName;

                // Add the Source (this is temporary and will be replaced with a new style of Source element)
                IDTSComponentMetaData90 sourceDataComponent = dataFlowTask.ComponentMetaDataCollection.New();
                sourceDataComponent.ComponentClassID = "DTSAdapter.OleDbSource.1";

                // IMPORTANT! If you do not Instantiate() and ProvideComponentProperties first,
                // the component names do not get set... this is bad.
                CManagedComponentWrapper oleInstance = sourceDataComponent.Instantiate();
                oleInstance.ProvideComponentProperties();

                sourceDataComponent.Name = etlName + " Source";

                if (sourceDataComponent.RuntimeConnectionCollection.Count > 0)
                {
                    sourceDataComponent.RuntimeConnectionCollection[0].ConnectionManager =
                        DTS.DtsConvert.ToConnectionManager90(
                            sourceConnection.ConnectionManager
                            );
                    sourceDataComponent.RuntimeConnectionCollection[0].ConnectionManagerID =
                        sourceConnection.ConnectionManager.ID;
                }

                oleInstance.SetComponentProperty("AccessMode", 2);
                oleInstance.SetComponentProperty("SqlCommand", query);

                try
                {
                    oleInstance.AcquireConnections(null);
                    oleInstance.ReinitializeMetaData();
                    oleInstance.ReleaseConnections();
                }
                catch (System.Runtime.InteropServices.COMException ce)
                {
                    Message.Trace(Severity.Error, ce, "OLEDBSource:{0}: {1}: Source {2}: Query {3}", sourceDataComponent.GetErrorDescription(ce.ErrorCode), ce.Message, sourceConnection.ConnectionManager.Name, query);
                }
                catch (Exception e)
                {
                    Message.Trace(Severity.Error, e, "OLEDBSource:{0}: Source {1}: Query {2}", e.Message, sourceConnection.ConnectionManager.Name, query);
                }

                //Map parameter variables:

                StringBuilder parameterBuilder = new StringBuilder();
                foreach (XPathNavigator paramNav in patternNavigator.Select("rc:Parameter", VulcanPackage.VulcanConfig.NamespaceManager))
                {
                    string name    = paramNav.SelectSingleNode("@Name").Value;
                    string varName = paramNav.SelectSingleNode("@VariableName").Value;

                    if (VulcanPackage.DTSPackage.Variables.Contains(varName))
                    {
                        DTS.Variable variable = VulcanPackage.DTSPackage.Variables[varName];
                        parameterBuilder.AppendFormat("\"{0}\",{1};", name, variable.ID);
                    }
                    else
                    {
                        Message.Trace(Severity.Error, "DTS Variable {0} does not exist", varName);
                    }
                }

                oleInstance.SetComponentProperty("ParameterMapping", parameterBuilder.ToString());

                ///Transformation Factory
                IDTSComponentMetaData90 parentComponent = sourceDataComponent;
                XPathNavigator          transNav        = patternNavigator.SelectSingleNode("rc:Transformations", VulcanPackage.VulcanConfig.NamespaceManager);
                if (transNav != null)
                {
                    foreach (XPathNavigator nav in transNav.SelectChildren(XPathNodeType.Element))
                    {
                        // this is naughty but can be fixed later :)
                        Transformation t = TransformationFactory.ProcessTransformation(VulcanPackage, parentComponent, dataFlowTask, nav);
                        if (t != null)
                        {
                            parentComponent = t.Component;
                        }
                    }
                }

                XPathNavigator destNav = patternNavigator.SelectSingleNode("rc:Destination", VulcanPackage.VulcanConfig.NamespaceManager);
                if (destNav != null)
                {
                    string           name             = destNav.SelectSingleNode("@Name").Value;
                    Connection       destConnection   = Connection.GetExistingConnection(VulcanPackage, destNav.SelectSingleNode("@ConnectionName").Value);
                    string           tableName        = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", destNav.SelectSingleNode("@Table").Value.Trim());
                    OLEDBDestination oledbDestination = new OLEDBDestination(VulcanPackage, dataFlowTask, parentComponent, name, name, destConnection, tableName);

                    string accessMode       = destNav.SelectSingleNode("@AccessMode").Value;
                    bool   tableLock        = destNav.SelectSingleNode("@TableLock").ValueAsBoolean;
                    bool   checkConstraints = destNav.SelectSingleNode("@CheckConstraints").ValueAsBoolean;
                    bool   keepIdentity     = destNav.SelectSingleNode("@KeepIdentity").ValueAsBoolean;
                    bool   keepNulls        = destNav.SelectSingleNode("@KeepNulls").ValueAsBoolean;

                    int rowsPerBatch        = destNav.SelectSingleNode("@RowsPerBatch").ValueAsInt;
                    int maxInsertCommitSize = destNav.SelectSingleNode("@MaximumInsertCommitSize").ValueAsInt;

                    switch (accessMode.ToUpperInvariant())
                    {
                    case "TABLE":
                        oledbDestination.ComponentInstance.SetComponentProperty("AccessMode", 0);
                        oledbDestination.ComponentInstance.SetComponentProperty("OpenRowset", tableName);
                        break;

                    case "TABLEFASTLOAD":
                        oledbDestination.ComponentInstance.SetComponentProperty("AccessMode", 3);
                        oledbDestination.ComponentInstance.SetComponentProperty("OpenRowset", tableName);

                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadKeepIdentity", keepIdentity);
                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadKeepNulls", keepNulls);
                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadMaxInsertCommitSize", maxInsertCommitSize);

                        StringBuilder fastLoadOptions = new StringBuilder();
                        if (tableLock)
                        {
                            fastLoadOptions.AppendFormat("TABLOCK,");
                        }
                        if (checkConstraints)
                        {
                            fastLoadOptions.AppendFormat("CHECK_CONSTRAINTS,");
                        }
                        if (rowsPerBatch > 0)
                        {
                            fastLoadOptions.AppendFormat("ROWS_PER_BATCH = {0}", rowsPerBatch);
                        }
                        fastLoadOptions = fastLoadOptions.Replace(",", "", fastLoadOptions.Length - 5, 5);

                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadOptions", fastLoadOptions.ToString());
                        break;

                    default:
                        Message.Trace(Severity.Error, "Unknown Destination Load Type of {0}", accessMode);
                        break;
                    }

                    try
                    {
                        oledbDestination.InitializeAndMapDestination();
                    }
                    catch (Exception)
                    {
                    }

                    // Map any overrides
                    foreach (XPathNavigator nav in destNav.Select("rc:Map", VulcanPackage.VulcanConfig.NamespaceManager))
                    {
                        string source = nav.SelectSingleNode("@Source").Value;
                        string destination;
                        bool   unMap = false;

                        if (nav.SelectSingleNode("@Destination") == null)
                        {
                            unMap       = true;
                            destination = source;
                        }
                        else
                        {
                            destination = nav.SelectSingleNode("@Destination").Value;
                        }

                        oledbDestination.Map(source, destination, unMap);
                    }
                } // end DestNav != null
                this.FirstExecutableGeneratedByPattern = pipeHost;
                this.LastExecutableGeneratedByPattern  = pipeHost;
            } //END sourceConnection != null
            else
            {
                Message.Trace(Severity.Error, "Source Connection {0} does not exist in {1}", sourceName, etlName);
            }
        } //END function Emit
Ejemplo n.º 22
0
 public virtual TC Rotate(double angle)
 {
     Transformations.Add(TransformationFactory.Rotation(angle));
     return((TC)this);
 }
Ejemplo n.º 23
0
 public Source(SourceOptions options)
 {
     Id = options.Id;
     Transformations = options.Transformations?.Select((it) => TransformationFactory.GetInstance(it)) ?? new List <ITransformation <object> >();
 }
Ejemplo n.º 24
0
 public virtual TC Scale(double xFactor, double yFactor)
 {
     Transformations.Add(TransformationFactory.Scaling(xFactor, yFactor));
     return((TC)this);
 }
Ejemplo n.º 25
0
 public virtual TC Translate(double xOffset, double yOffset)
 {
     Transformations.Add(TransformationFactory.Translation(xOffset, yOffset));
     return((TC)this);
 }
Ejemplo n.º 26
0
 public virtual TC YMirror()
 {
     Transformations.Add(TransformationFactory.YMirror());
     return((TC)this);
 }
Ejemplo n.º 27
0
 public virtual TC YSkew(double angle)
 {
     Transformations.Add(TransformationFactory.YSkew(angle));
     return((TC)this);
 }
Ejemplo n.º 28
0
 public TradingAccountWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.tradingAccounts)
 {
     _entity         = new Account();
     _transformation = TransformationFactory.GetTransformation <ITransformation <AccountDocument, TradingAccountPayload> >(SupportedResourceKinds.tradingAccounts, context);
 }
Ejemplo n.º 29
0
 public Sink(SinkOptions options)
 {
     Id = options.Id;
     Transformations = options.Transformations?.Select((it) => TransformationFactory.GetInstance(it)) ?? new List <ITransformation <object> >();
     Next            = Subject.AsObservable().Pipe(Transformations.Select(it => it.GetOperator()).ToArray());
 }