Esempio n. 1
0
        public void DataExtensionRowDelete()
        {
            var deRow = new ETDataExtensionRow
            {
                AuthStub          = client,
                DataExtensionName = dataExtensionName,
            };

            deRow.ColumnValues.Add("CustomerNumber", "Customer_");
            deRow.ColumnValues.Add("FirstName", "FirstName_");
            deRow.ColumnValues.Add("LastName", "LastName_");

            var derResponse = deRow.Post();

            Assert.AreEqual(derResponse.Code, 200);
            Assert.AreEqual(derResponse.Results[0].StatusMessage, "Created DataExtensionObject");
            var custKey = ((ETDataExtensionRow)derResponse.Results[0].Object).CustomerKey;

            deRow = new ETDataExtensionRow
            {
                AuthStub          = client,
                DataExtensionName = dataExtensionName,
                Props             = new[] { "CustomerNumber", "FirstName" },
                SearchFilter      = new SimpleFilterPart {
                    Property = "CustomerNumber", SimpleOperator = SimpleOperators.equals, Value = new[] { "Customer_" }
                },
            };
            var derGetResponse = deRow.Get();

            Assert.AreEqual(derGetResponse.Code, 200);
            Assert.AreEqual(((ETDataExtensionRow)derGetResponse.Results[0]).ColumnValues["FirstName"], "FirstName_");

            deRow = new ETDataExtensionRow
            {
                AuthStub          = client,
                DataExtensionName = dataExtensionName
            };
            deRow.CustomerKey = custKey;
            //for any update/delete operation, make sure to set the primary key value
            deRow.ColumnValues.Add("CustomerNumber", "Customer_");
            deRow.Delete();

            deRow = new ETDataExtensionRow
            {
                AuthStub          = client,
                DataExtensionName = dataExtensionName,
                Props             = new[] { "CustomerNumber", "FirstName" },
                SearchFilter      = new SimpleFilterPart {
                    Property = "CustomerNumber", SimpleOperator = SimpleOperators.equals, Value = new[] { "Customer_" }
                },
            };
            derGetResponse = deRow.Get();
            Assert.AreEqual(derGetResponse.Code, 200);
            Assert.AreEqual(derGetResponse.Results.Length, 0);
        }
Esempio n. 2
0
        public void DataExtensionRowCreate()
        {
            for (int i = 0; i < 50; i++)
            {
                var deRow = new ETDataExtensionRow
                {
                    AuthStub          = client,
                    DataExtensionName = dataExtensionName,
                };
                deRow.ColumnValues.Add("CustomerNumber", "Customer_" + i.ToString());
                deRow.ColumnValues.Add("FirstName", "FirstName_" + i.ToString());
                deRow.ColumnValues.Add("LastName", "LastName_" + i.ToString());

                var derResponse = deRow.Post();
                Assert.AreEqual(derResponse.Code, 200);
                Assert.AreEqual(derResponse.Results[0].StatusMessage, "Created DataExtensionObject");
            }
        }
        public void Setup()
        {
            dataExtensionName = Guid.NewGuid().ToString();
            targetDEKey       = Guid.NewGuid().ToString();
            desc        = "Query definition created by C# SDK";
            updatedDesc = "Updated Query definition created by C# SDK";
            var deObj = new ETDataExtension
            {
                AuthStub    = client,
                Name        = dataExtensionName,
                CustomerKey = dataExtensionName,
                Columns     = new[] {
                    new ETDataExtensionColumn {
                        Name = "CustomerNumber", FieldType = DataExtensionFieldType.Text, IsPrimaryKey = true, MaxLength = 100, IsRequired = true
                    },
                    new ETDataExtensionColumn {
                        Name = "StoreId", FieldType = DataExtensionFieldType.Number
                    },
                    new ETDataExtensionColumn {
                        Name = "FirstName", FieldType = DataExtensionFieldType.Text, MaxLength = 256
                    },
                    new ETDataExtensionColumn {
                        Name = "LastName", FieldType = DataExtensionFieldType.Text, MaxLength = 256
                    }
                }
            };

            var result = deObj.Post();

            dataExtension = (ETDataExtension)result.Results[0].Object;

            for (int i = 0; i < 3; i++)
            {
                var deRow = new ETDataExtensionRow
                {
                    AuthStub          = client,
                    DataExtensionName = dataExtensionName,
                };
                deRow.ColumnValues.Add("CustomerNumber", i.ToString());
                deRow.ColumnValues.Add("StoreId", i % 2 == 0 ? "101" : "102");
                deRow.ColumnValues.Add("FirstName", "FirstName_" + i.ToString());
                deRow.ColumnValues.Add("LastName", "LastName_" + i.ToString());

                var derResponse = deRow.Post();
                Assert.AreEqual(derResponse.Code, 200);
                Assert.AreEqual(derResponse.Results[0].StatusMessage, "Created DataExtensionObject");
            }

            queryDefKey = Guid.NewGuid().ToString();
            var qDef = new ETQueryDefinition
            {
                AuthStub            = client,
                Name                = queryDefKey,
                Description         = desc,
                CustomerKey         = queryDefKey,
                DataExtensionTarget = new InteractionBaseObject {
                    CustomerKey = targetDEKey, Name = "Store102DEx"
                },
                QueryText        = string.Format("SELECT * FROM [{0}] WHERE STOREID=102", dataExtensionName),
                TargetType       = "DE",
                TargetUpdateType = "Overwrite"
            };
            var qdefResponse = qDef.Post();

            Assert.AreEqual(qdefResponse.Code, 200);
            Assert.AreEqual(qdefResponse.Status, true);
            Assert.AreEqual(qdefResponse.Results[0].StatusMessage, "QueryDefinition created");
            queryDef = (ETQueryDefinition)qdefResponse.Results[0].Object;
        }