Пример #1
0
        static void Main(string[] args)
        {
            //https://github.com/salesforce-marketingcloud/FuelSDK-CSharp/blob/Dot9/objsamples/Sample_DataExtension.cs
            DataExtensionHelper deHelper = new DataExtensionHelper();

            //////--------------CREAR
            //var response = deHelper.Create(new DataExtensionHead
            //{
            //    Nombre = "Demo25112016",
            //    DataExtensionDetalleList = new List<DataExtensionDetalle>
            //    {
            //        new DataExtensionDetalle { Campo = "EMAIL", EsNulo = false, EsClavePrimaria = true, Tamanio = 100, Tipo = 5 },
            //        new DataExtensionDetalle { Campo = "NOMBRE", EsNulo = false, EsClavePrimaria = false, Tamanio = 200, Tipo = 1 }

            //    }
            //});

            //GetAllColumns
            var response = deHelper.GetAllColumns(new DataExtensionSearch
            {
                Nombre = "METASAPPBENEFICIOS",
                Columnas = new[] { "Name", "FieldType" }
            });

            if (response.Success)
                foreach (ET_DataExtensionColumn column in (FuelSDK.APIObject[])response.Data)
                    Console.WriteLine("-- Name: " + column.Name + "  Type: " + column.FieldType.ToString());

            ////--------------AddColumns
            //var response = deHelper.AddColumns(new DataExtensionHead
            //{
            //    Nombre = "Demo25112016",
            //    DataExtensionDetalleList = new List<DataExtensionDetalle>
            //    {
            //        new DataExtensionDetalle { Campo = "DNI", EsNulo = false, EsClavePrimaria = false, Tamanio = 0, Tipo = 2 },
            //        new DataExtensionDetalle { Campo = "VISITAS", EsNulo = false, EsClavePrimaria = false, Tamanio = 0, Tipo = 2 }

            //    }
            //});

            ////AddRowsByCustomerKey
            //var response = deHelper.AddRowsByCustomerKey(new DataExtensionRowHead
            //{
            //    CustomerKey = "Demo02012011",
            //    DataExtensionRowList = new List<DataExtensionRow>
            //    {
            //        new DataExtensionRow { Nombre = "NOMBRE", Valor = "admin" },
            //        new DataExtensionRow { Nombre = "Email", Valor = "*****@*****.**" },
            //        new DataExtensionRow { Nombre = "DNI", Valor = "45454545"},
            //        new DataExtensionRow { Nombre = "VISITAS", Valor = "2"}
            //    }
            //});

            ////AddRowsByDataExtensionName
            //var response = deHelper.AddRowsByDataExtensionName(new DataExtensionRowHead
            //{
            //    DataExtensionName = "Demo02012011",
            //    DataExtensionRowList = new List<DataExtensionRow>
            //    {
            //        new DataExtensionRow { Nombre = "NOMBRE", Valor = "admin2" },
            //        new DataExtensionRow { Nombre = "Email", Valor = "*****@*****.**" },
            //        new DataExtensionRow { Nombre = "DNI", Valor = "44444444"},
            //        new DataExtensionRow { Nombre = "VISITAS", Valor = "3"}
            //    }
            //});

            ////UpdateRowsByCustomerKey
            //var response = deHelper.UpdateRowsByCustomerKey(new DataExtensionRowHead
            //{
            //    CustomerKey = "Demo24112016",
            //    DataExtensionRowList = new List<DataExtensionRow>
            //    {
            //        new DataExtensionRow { Nombre = "NOMBRE", Valor = "admin5" },
            //        new DataExtensionRow { Nombre = "EMAIL", Valor = "*****@*****.**" },
            //        new DataExtensionRow { Nombre = "DNI", Valor = "55555555"},
            //        new DataExtensionRow { Nombre = "VISITAS", Valor = "5"}
            //    }
            //});

            ////UpdateRowsByExtensionName
            //var response = deHelper.UpdateRowsByExtensionName(new DataExtensionRowHead
            //{
            //    DataExtensionName = "Demo02012011",
            //    DataExtensionRowList = new List<DataExtensionRow>
            //    {
            //        new DataExtensionRow { Nombre = "NOMBRE", Valor = "admin3" },
            //        new DataExtensionRow { Nombre = "Email", Valor = "*****@*****.**" },
            //        new DataExtensionRow { Nombre = "DNI", Valor = "33333333"},
            //        new DataExtensionRow { Nombre = "VISITAS", Valor = "4"}
            //    }
            //});

            ////--------------GETROW
            //var response = deHelper.GetRow(new DataExtensionSearch
            //{
            //    Nombre = "Demo02012011",
            //    Columnas = new[] { "EMAIL", "NOMBRE" },
            //    FilterName = "EMAIL",
            //    FilterValue = "*****@*****.**"
            //});

            //if (response.Success)
            //    foreach (ET_DataExtensionRow column in (FuelSDK.APIObject[])response.Data)
            //        Console.WriteLine("--EMAIL: " + column.ColumnValues["EMAIL"] + " - NOMBRE: " + column.ColumnValues["NOMBRE"]);

            ////DeleteRowByDataExtensionName
            //var response = deHelper.DeleteRowByDataExtensionName(new DataExtensionRowHead
            //{
            //    DataExtensionName = "Demo02012011",
            //    DataExtensionRowList = new List<DataExtensionRow>
            //    {
            //        new DataExtensionRow { Nombre = "Email", Valor = "*****@*****.**" }
            //    }
            //});

            ////DeleteByCustomerKey
            //var response = deHelper.DeleteByCustomerKey(new DataExtensionHead
            //{
            //    CustomerKey = "Demo02012011"
            //});

            ////DeleteByDataExtensionName
            //var response = deHelper.DeleteByDataExtensionName(new DataExtensionHead
            //{
            //    Nombre = "Demo02012011"
            //});

            ////GetInfo
            //var response = deHelper.GetInfo();

            //if(response.Success)
            //    foreach (ET_PropertyDefinition def in (ET_PropertyDefinition[])response.Data)
            //        Console.WriteLine("--Name: " + def.Name + ", IsRetrievable: " + def.IsRetrievable.ToString());

            ////DeleteByDataExtensionName
            //var response = deHelper.DeleteByDataExtensionName("Demo25112016");

            ////DeleteByCustomerKey
            //var response = deHelper.DeleteByCustomerKey("Demo24112016");

            ////--------------GetAllMetas
            //var response = deHelper.GetAllMetas(new MetaSearchModel
            //{
            //    NumeroDocumento = "44843843"
            //});

            ////--------------ActivateMeta
            //var response = deHelper.ActivateMeta(new MetaSearchModel
            //{
            //    Id = "1"
            //});

            ////--------------GetAllMetas
            //var response = deHelper.GetMeta(new MetaSearchModel
            //{
            //    Id = "2"
            //});

            //--------------GETALLROWS
            response = deHelper.GetAllRow(new DataExtensionSearch
            {
                Nombre = "METASAPPBENEFICIOS",
                Columnas = new[] { "ID", "NUMERODOCUMENTO", "IMAGEN", "TITLE" }
            });

            if (response.Success)
                foreach (ET_DataExtensionRow column in (FuelSDK.APIObject[])response.Data)
                    Console.WriteLine("--ID: " + column.ColumnValues["ID"] + " - NUMERODOCUMENTO: " + column.ColumnValues["NUMERODOCUMENTO"] + " - IMAGEN: " + column.ColumnValues["IMAGEN"] + " - TITLE: " + column.ColumnValues["TITLE"]);

            Console.ReadLine();
        }
        public Response GetAllColumns(DataExtensionSearch dataExtensionSearch)
        {
            var jsonResponse = new Response { Success = false };
            DataExtensionHelper deHelper = new DataExtensionHelper();

            try
            {
                jsonResponse = deHelper.GetAllColumns(dataExtensionSearch);
            }
            catch (Exception ex)
            {
                LogError(ex);
            }

            return jsonResponse;
        }