Exigo Developer Resources

This database contains the documentation for Exigo's OData API's, as well as C# sample code and fully-realized demo applications ready to be customized for your needs. Start building downline viewers, reporting tools and shopping carts on the Exigo platform today!

Create an account Sign In

Binary Grid Viewer


A visual tree manager that allows a user to navigate one pane at a time over his/her binary downline. This viewer includes a search and a breadcrumb trail feature to easily navigate through their tree.


This sample requires the following namespaces:

using ExigoOData;
using System.Data.Services.Client;
using System.IO;
using System.Text;
using System.Web.UI.HtmlControls;

Exigo API Authentication

This sample accesses OData using the ExigoContext object:

    public ExigoContext ExigoOData
            var context = new ExigoOData.ExigoContext(new Uri("http://api.exigo.com/4.0/" + exigoAPICompany + "/model"));
            context.IgnoreMissingProperties = true;
            var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(exigoAPILoginName + ":" + exigoAPIPassword));
            context.SendingRequest +=
                (object s, SendingRequestEventArgs e) =>
                    e.RequestHeaders.Add("Authorization", "Basic " + credentials);
            return context;

Fetching Binary Downline via OData

When grabbing the binary downline from the server, we use the BinaryTreePeriodVolumes OData query. Note how the Level is used as the filter and how the lookup properties are used to fill the BinaryNode object.

            _downline = (
                from n in ExigoOData.BinaryTreePeriodVolumes
                where n.TopCustomerID == fromCustomerID
                where n.Period.PeriodTypeID == periodTypeID
                where n.Period.IsCurrentPeriod
                where n.Level <= LevelCount
                select new BinaryNode
                    CustomerID = n.CustomerID,
                    ParentID = n.ParentID,
                    Placement = n.Placement,
                    Level = n.Level,

                    PaidRankID = n.PeriodVolume.PaidRankID,
                    PaidRankDescription = n.PeriodVolume.PaidRank.RankDescription,
                    RankID = n.PeriodVolume.RankID,
                    RankDescription = n.PeriodVolume.Rank.RankDescription,

                    EnrollerID = n.Customer.EnrollerID.HasValue ? n.Customer.EnrollerID.Value : 0,
                    FirstName = n.Customer.FirstName,
                    LastName = n.Customer.LastName,
                    Company = n.Customer.Company,

                    CustomerTypeID = n.Customer.CustomerTypeID,
                    CustomerTypeDescription = n.Customer.CustomerType.CustomerTypeDescription,
                    CustomerStatusTypeID = n.Customer.CustomerStatusID,
                    CustomerStatusTypeDescription = n.Customer.CustomerStatus.CustomerStatusDescription,

Direct Render with Ajax Handler

The Binary Tree uses the ICallbackEventHandler to process all the ajax calls to retrieve the next section and handle searching.

public partial class BinaryTreeApplication : System.Web.UI.UserControl, ICallbackEventHandler

Our user control is implementing the ICallbackEventHandler interface to manage our Ajax calls. The GetCallbackResult() method takes the various commands and delegates it to the different functions. Note how a StringWriter is used from the Ajax portion calling the same functions that an HtmlTextWriter was passed into earlier.

    public string GetCallbackResult()
            string[] a = _eventArgument.Split('|');
            StringBuilder sb = new StringBuilder(1000);
            StringWriter sw = new StringWriter(sb);

            switch (a[0])
                case "drill":
                    DoDrill(sw, Convert.ToInt32(a[1]));
                case "bottom":
                    DoDrill(sw, GetBottomID(Convert.ToInt32(a[1]), Convert.ToInt32(a[2])));
                case "search":
                    RenderSearchResult(sw, a[1]);

            return sb.ToString();
        catch (Exception ex)
            return ex.ToString();

Fetching Binary Upline via OData

When grabbing the binary upline from the server, we use a special DataServiceQuery called "GetBinaryUpline". We use this data to show the upline of the currently-selected customer up to the backoffice owner.

    public List<SearchResult> GetUpline(int fromCustomerID, int toCustomerID)
        return (from s in ExigoOData.CreateQuery<NodeSearchResult>("GetBinaryUpline")
             .AddQueryOption("bottomCustomerID", fromCustomerID)
             .AddQueryOption("topCustomerID", toCustomerID)
                select new SearchResult
                    CustomerID = s.NodeID,
                    FirstName = s.FirstName,
                    LastName = s.LastName,
                    Company = s.Company,
                    Level = s.Level