Search Results for

    Show / Hide Table of Contents

    How To: Use C# to Access time cockpit API

    You can not only access time cockpit's API using IronPython, you can also use your favorite .NET programming language (e.g. C#).

    Note

    Note that the code in this example connects to a user's server data store. This is the recommended procedure for implementing interfaces that import or export data.

    Project References

    Before you can access the time cockpit data store from C# you have to add certain references to your project:

    Note

    You can find the assemblies mentioned in this list in time cockpit's installation directory.

    • Antlr3.Runtime
    • Antlr3.StringTemplate
    • IronPython
    • log4net.dll
    • Microsoft.Dynamic
    • Microsoft.Scripting
    • Newtonsoft.Json.Net35
    • System.CoreEx.dll
    • System.Data.SqlServerCe.dll
    • System.Reactive.dll
    • TimeCockpit.Common
    • TimeCockpit.Data
    • TimeCockpit.Data.QueryLanguage
    • TimeCockpit.Data.RoutingService

    Web Service Endpoint Definition

    time cockpit uses a web service to locate the user's server data store. Therefore it is necessary to define the web service endpoint in the program's application config file:

    <?xml version="1.0" encoding="utf-8" ?> 
    <configuration> 
        <system.serviceModel> 
            <client> 
                <endpoint name="" address="https://management.timecockpit.com/ManagementService.svc" binding="customBinding" 
                    bindingConfiguration="CustomBinding_IManagementService" contract="WebManagementService.IManagementService" /> 
            </client> 
    
            <bindings> 
                <customBinding> 
                    <binding name="CustomBinding_IManagementService"> 
                        <security defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport" requireDerivedKeys="true" 
                            securityHeaderLayout="Strict" includeTimestamp="true" keyEntropyMode="CombinedEntropy" 
                            messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"> 
    
                            <localClientSettings cacheCookies="true" detectReplays="false" replayCacheSize="900000" maxClockSkew="23:00:00" 
                                maxCookieCachingTime="Infinite" replayWindow="00:05:00" sessionKeyRenewalInterval="10:00:00" 
                                sessionKeyRolloverInterval="00:05:00" reconnectTransportOnFailure="true" timestampValidityDuration="00:05:00" 
                                cookieRenewalThresholdPercentage="60"/> 
    
                            <localServiceSettings detectReplays="false" issuedCookieLifetime="10:00:00" maxStatefulNegotiations="128" 
                                replayCacheSize="900000" maxClockSkew="23:00:00" negotiationTimeout="01:01:00" replayWindow="00:05:00" 
                                inactivityTimeout="00:02:00" sessionKeyRenewalInterval="15:00:00" sessionKeyRolloverInterval="00:05:00" 
                                reconnectTransportOnFailure="true" maxPendingSessions="128" maxCachedCookies="1000" timestampValidityDuration="00:05:00"/> 
                            <secureConversationBootstrap/> 
                        </security> 
    
                        <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap11" writeEncoding="utf-8"> 
                            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> 
                        </textMessageEncoding> 
    
                        <httpsTransport manualAddressing="false" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" allowCookies="false" 
                            authenticationScheme="Anonymous" bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard" 
                            keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" 
                            unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="false" requireClientCertificate="false" /> 
                    </binding> 
                </customBinding> 
    
                <wsHttpBinding> 
                    <remove name="WorkflowControlHttpsBinding"/> 
                    <binding name="WorkflowControlHttpsBinding" transactionFlow="true"> 
                        <security mode="Transport"/> 
                    </binding> 
    
                    <remove name="WorkflowControlHttpBinding"/> 
                    <binding name="WorkflowControlHttpBinding" transactionFlow="true"/> 
                </wsHttpBinding> 
            </bindings> 
        </system.serviceModel> 
    </configuration>
    

    Select Data

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using TimeCockpit.Data;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                try
                {
                    var dataContext = DataContext.Create("user@demo.com", "myPassword");
                    var projects = dataContext.Select("From P In Project Select P").Cast<dynamic>();
                    projects.ToList().ForEach(p => Console.WriteLine(p.ProjectName));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception: {0}", ex.ToString());
                }
    
                Console.ReadKey();
            }
        }
    }
    
    • Improve this Doc
    In This Article
    Back to top Copyright © 2020 software architects gmbh