TFS time info

How do I get the TFS time from a client I tried using the TFS object but all I could get was the time zone info of the server and not the actual server time.


Answer this question

TFS time info

  • orbit

    Sure Buck!

    We have an amazing development environment, some developers sit in US and some others in India. 

    We have the server(s) in India, we need to define a custom policy that prevents using from checking-in files for a specific time period (ideally be based on the TFS time).



  • mandoman2

    Well, if you want to prevent folks from checking in from say 2:00 am to 4:00 am server time, one really simple way to guarantee that is enforced is to set up a windows task on the application tier to remove the checkin permission from the appropriate group at 2:00 am and then restore it at 4:00 am.  You could run "tf permission" to do that.

    Buck

  • nron

    But, our requirement is not to block checkin completely but restrict it based on some rules as similar to other policies. The user should still have the option of overriding the policy!

  • Jose Fuentes

    Jeps, I have to admit that I'm really curious to know more about what you are trying to do.  Would share the details

    Buck



  • JoyK

    As Alex said, this was not really a capability we anticipated people needing.  Here are some approaches you can look at to get the info though.

    Try the web method at:

    http://yourserver:8080/versioncontrol/v1.0/administration.asmx/QueryServerInformation

    This will return the server start time and it's uptime.  By adding them together you can get what it believes is the current time.

    The other possibility (although probably harder) would be to access:

    http://yourserver:8080/versioncontrol/v1.0/administration.asmx/QueryServerRequests

    This will return a list of requests currently being processed.  The one with the most recent start time is going to be the server's current time within a few milliseconds (because your QueryServerRequests call will be processed VERY fast).

    Of course you can generate webservice proxies to make calling these easier.

  • integrators

    You cannot do that from the object model - getting the exact server time would require roundtrip to the server, which we usually want to avoid - we usually do that for querying, etc.

    I would like to know more why you need to do that - could you please explain your scenario

    Thanks,
    Alex


  • softwarejaeger

    Hi Alex,

    I'm trying to build a custom check in policy. This needs the server time info so that I can base my check-in on the server time instead of the local machine time.
    (for e.g. I allow check-in of a file only if a specific time has elapsed)

  • TFS time info