Exemple #1
0
        public void ReadAllDeliveriesWithMessageDetail()
        {
            Deliveries deliveries = new Deliveries(Login);

            StartTimer("Reading all Deliveries");
            deliveryFilter filter   = GetDeliveryDateFilter();
            readDeliveries doptions = new readDeliveries()
            {
                includeContent = false
            };
            List <deliveryObject> list = ReadDeliveriesInternal(deliveries, filter, doptions);

            Console.WriteLine(EndTimer().ToString());
            Console.WriteLine("{0} deliveries read", list.Count);
            if (list.Count > 0)
            {
                Messages messages = new Messages(Login);

                foreach (var item in list) // get message details for each delivery
                {
                    messageFilter msgFilter = new messageFilter()
                    {
                        id = new string[] { item.messageId }
                    };
                    readMessages moptions = new readMessages()
                    {
                        includeContent = true
                    };
                    List <messageObject> message = messages.Read(msgFilter, moptions);
                    WriteDeliveryAndMessageToConsole(item, message.FirstOrDefault());
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Reads contacts from bronto using a filter and the specified return fields and information
        /// </summary>
        /// <param name="filter">The filter to use when reading</param>
        /// <param name="options">The fields and information to return. Use the extension methods on the readDeliveries class to specify options</param>
        /// <returns>the list of contacts</returns>
        public async Task <List <deliveryObject> > ReadAsync(deliveryFilter filter, readDeliveries options = null)
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter", "The filter must be specified. Alternatively call the Read() function");
            }
            using (BrontoSoapPortTypeClient client = BrontoSoapClient.Create(Timeout))
            {
                readDeliveries c = options ?? new readDeliveries();
                c.filter     = filter;
                c.pageNumber = 1;
                List <deliveryObject>  list     = new List <deliveryObject>();
                readDeliveriesResponse response = await client.readDeliveriesAsync(session.SessionHeader, c);

                deliveryObject[] result = response.@return;
                if (result != null)
                {
                    list.AddRange(result);
                }
                while (result != null && result.Length > 0)
                {
                    c.pageNumber += 1;
                    response      = await client.readDeliveriesAsync(session.SessionHeader, c);

                    result = response.@return;
                    if (result != null)
                    {
                        list.AddRange(result);
                    }
                }
                return(list);
            }
        }
        public Dictionary <string, string> GetMessageDeliveryStatus(string[] messageIds)
        {
            Dictionary <string, string> delStatus = new Dictionary <string, string>();

            var filter = new deliveryFilter();

            filter.id = messageIds;

            var deliveries = wrapper.ReadDeliveries(filter);

            if (deliveries != null)
            {
                string status;
                foreach (deliveryObject d in deliveries)
                {
                    if (d.bounceRate == 1.0)
                    {
                        status = "bounced";
                    }
                    else if (d.deliveryRate == 1.0)
                    {
                        status = "delivered";
                    }
                    else
                    {
                        status = d.status;
                    }

                    delStatus.Add(d.id, status);
                }
            }

            return(delStatus);
        }
Exemple #4
0
        private deliveryFilter GetDeliveryDateFilter()
        {
            deliveryFilter filter = new deliveryFilter();

            filter.start = new dateValue[]
            {
                new dateValue()
                {
                    @operator         = filterOperator.SameDay,
                    operatorSpecified = true,
                    value             = DateTime.Today,
                    valueSpecified    = true
                }
            };
            return(filter);
        }
Exemple #5
0
        public void ReadAllDeliveries()
        {
            Deliveries deliveries = new Deliveries(Login);

            StartTimer("Reading all Deliveries");
            deliveryFilter        filter = GetDeliveryDateFilter();
            List <deliveryObject> list   = ReadDeliveriesInternal(deliveries, filter, null);

            Console.WriteLine(EndTimer().ToString());
            Console.WriteLine("{0} deliveries read", list.Count);
            if (list.Count > 0)
            {
                foreach (var item in list)
                {
                    WriteDeliveryToConsole(item);
                }
            }
        }
Exemple #6
0
 public deliveryObject[] ReadDeliveries(deliveryFilter filter)
 {
     return(api.readDeliveries(filter, true, false, 0));
 }
        public IEnumerable<IMetricsProvider> GetMetrics(int days)
        {

            ///////////////////////////////////////////////////////////////////
            //
            // Instantiate the client
            //
            ///////////////////////////////////////////////////////////////////

            sessionHeader header = new sessionHeader();
            BrontoSoapPortTypeClient client = new BrontoSoapPortTypeClient();
            header.sessionId = client.login(ConfigurationManager.AppSettings[GetType().Name]);


            ///////////////////////////////////////////////////////////////////
            //
            // Retrieve the contact for which you need the metrics.
            //
            ///////////////////////////////////////////////////////////////////

            contactFilter cf = new contactFilter();
            cf.id = new string[] { "4a8e4dc1-e38f-438b-b8b5-75e46799bc9c" };
            readContacts rc = new readContacts();
            rc.filter = cf;
            contactObject[] co = client.readContacts(header, rc);
            contactObject mycontact = co[0];
            ///////////////////////////////////////////////////////////////////
            //
            // Create a deliverFilter and read all deliverObjects
            //
            ///////////////////////////////////////////////////////////////////

            deliveryFilter df = new deliveryFilter();
            df.deliveryType = new string[] { "normal","test","automated","split","transactional","triggered" };
            readDeliveries rd = new readDeliveries();
       
            rd.filter = df;
            deliveryObject[] dos = client.readDeliveries(header, rd);

            ///////////////////////////////////////////////////////////////////
            //
            // Extract deliverObjects into ProviderMetrics
            //
            ///////////////////////////////////////////////////////////////////
            List<IMetricsProvider> list = new List<IMetricsProvider>();
            try
            {
                foreach (deliveryObject doj in dos)
                {
                    ProviderMetrics item = new ProviderMetrics();

                    //deliveryRecipientObject[] dro = doj.recipients;
                    // id can be contact id, list id or segment id
                    //dro[0].id
                    // if contactId, there are metrics by contact, but that doesn't tell the full story

                    /*
                    deliveryRecipientFilter drf = new deliveryRecipientFilter();
                    drf.deliveryId = doj.id;
                    readDeliveryRecipients rdr = new readDeliveryRecipients();
                    rdr.filter = drf;
                    deliveryRecipientStatObject[] drso = client.readDeliveryRecipients(header, rdr);
                    */
                    // Once we receive the deliveryRecipientStatObject, we have to check
                    // if this object has click/send/bounce and store the contactId accordingly


                    item.Name = doj.messageId;
                    item.Bounces = (int)doj.numBounces;
                    item.Clicks = (int)doj.numClicks;
                    item.Opens = (int)doj.numOpens;
                    item.Sends = (int)doj.numSends;
                    // read unsubscribes
                    unsubscribeFilter uf = new unsubscribeFilter();
                    uf.deliveryId = doj.id;
                    readUnsubscribes ru = new readUnsubscribes();
                    ru.filter = uf;
                    ru.pageNumber = 1;
                    if (client.readUnsubscribes(header, ru) == null)
                        item.Unsubscribes = 0;
                    else
                    item.Unsubscribes = client.readUnsubscribes(header, ru).Length;
                    list.Add(item);
                }
                

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                ProviderMetrics item = new ProviderMetrics();
                item.Name = "null";
                item.Bounces = 0;
                item.Clicks = 0;
                item.Opens = 0;
                item.Sends = 0;
                item.Unsubscribes = 0;
                list.Add(item);
            }
            return list;
          
        }
Exemple #8
0
 private List <deliveryObject> ReadDeliveriesInternal(Deliveries deliveries, deliveryFilter filter, readDeliveries options)
 {
     return(deliveries.Read(filter, options));
 }