Code Examples: Creating AgilePoint API objects using Interfaces

The code examples in this topic show how to create AgilePoint API objects using Interfaces.

Example 1: GetAdminService

public IWFAdminService GetAdm()
{
    System.Net.ICredentials credentials = credentials = new 
    System.Net.NetworkCredential(username, password, domainname);
    if (credentials == null) return m_adm;
    string locale = "en-US";// Set locale us value
    string hostingMechanism = null;
    if (String.IsNullOrEmpty(ConfigurationSettings.AppSettings["HostingMechanism"]))
                hostingMechanism = "IIS";
    else
        hostingMechanism = (String)ConfigurationSettings.AppSettings["HostingMechanism"];
    if (hostingMechanism.ToLower() != "wcf")
    {
        string agilePointServerURL = (String)ConfigurationSettings.AppSettings["ServerUrl"];
        if (!agilePointServerURL.EndsWith("/")) agilePointServerURL += "/";
        System.Net.CookieContainer cookieContainer = new System.Net.CookieContainer();
        AdminService m_adm_temp = new AdminService();
        m_adm_temp.Url = agilePointServerURL + "Admin.asmx";
        m_adm_temp.Credentials = credentials;
        m_adm_temp.CookieContainer = cookieContainer;
        m_adm_temp.Timeout = 1000 * 60 * 60;
        m_adm_temp.SetClientAppName("SampleClient");
        m_adm_temp.SetClientLocale(locale);
        m_adm = m_adm_temp;
    }
    else
    {
        string user = domainname + @"\" + username;
        string adminBinding = (String)ConfigurationSettings.AppSettings["AdminBindingUsed"];
        m_adm = new WCFAdminProxy("SampleApplication", "CSC-NINE", locale, user, credentials, adminBinding);
        String username = m_adm.CheckAuthenticated();
     }
        return m_adm;
}

Example 2: GetWorkflowService

public IWFWorkflowService GetApi()
{
    System.Net.ICredentials credentials = credentials = new 
    System.Net.NetworkCredential(username, password, domainname);
    string locale = "en-US"; // Set locale value
    string hostingMechanism = null;
    if (String.IsNullOrEmpty(ConfigurationSettings.AppSettings["HostingMechanism"]))
        hostingMechanism = "IIS";
    else
        hostingMechanism = (String)ConfigurationSettings.AppSettings["HostingMechanism"];
    if (hostingMechanism.ToLower() != "wcf")
    {
    string agilePointServerURL = (String)ConfigurationSettings.AppSettings["ServerUrl"];
    if (!agilePointServerURL.EndsWith("/")) agilePointServerURL += "/";
        System.Net.CookieContainer cookieContainer = new System.Net.CookieContainer();
        WorkflowService m_api_temp = new WorkflowService();
        m_api_temp.Url = agilePointServerURL + "Workflow.asmx";
        m_api_temp.Credentials = credentials;
        m_api_temp.CookieContainer = cookieContainer;
        m_api_temp.Timeout = 1000 * 60 * 60;
        m_api_temp.SetClientAppName("MyApplication");
        m_api_temp.SetClientLocale(locale);
        m_api = m_api_temp;
    }
    else
    {
        string user = domainname + @"\" + username;
        string workflowBinding = (String)ConfigurationSettings.AppSettings["WorkFlowBindingUsed"]; // WCF Binding used
        m_api = new WCFWorkflowProxy("MyApplication", "CSC-NINE", locale, user, credentials, workflowBinding);
        m_api.CheckAuthenticated();
    }
        return m_api;
}