none
API to retrieve work hour start time and end time RRS feed

  • Question

  • Hi,

    I am looking for an API to retrieve working hours of a person from the exchange server. Let me know, if you have any specific API call to retrieve this.

    Thanks

    Tuesday, October 15, 2013 10:45 PM

All replies

  • What version of Exchange are you using ? on Exchange 2010,2013 you can use EWS via the UserConfiguration operation eg http://msdn.microsoft.com/en-us/library/exchange/gg274398(v=exchg.80).aspx

    eg

                UserConfiguration WorkHours;
                WorkHours = UserConfiguration.Bind(service, "WorkHours", WellKnownFolderName.Calendar, UserConfigurationProperties.All);
                XmlDocument xmlConfig = new XmlDocument();
                xmlConfig.LoadXml(Encoding.UTF8.GetString(WorkHours.XmlData));
    
                XmlNodeList xmlList = xmlConfig.GetElementsByTagName("TimeSlot");
                if (xmlList.Count > 0) {
                    for (Int32 ncCnt = 0; xmlList[0].ChildNodes.Count > ncCnt;ncCnt++ )
                    {
                        XmlNode ChildNode = xmlList[0].ChildNodes[ncCnt];
                        if (ChildNode.Name == "Start")
                        {
                            Console.WriteLine(ChildNode.InnerText);
                        }
                        if (ChildNode.Name == "End")
                        {
                            Console.WriteLine(ChildNode.InnerText);
                        }
                    }
                    
                }
                XmlNodeList xmlList1 = xmlConfig.GetElementsByTagName("TimeZone");
                if (xmlList1.Count > 0)
                {
                    for (Int32 ncCnt = 0; xmlList1[0].ChildNodes.Count > ncCnt; ncCnt++)
                    {
                        XmlNode ChildNode = xmlList1[0].ChildNodes[ncCnt];
                        if (ChildNode.Name == "Name") {
                            Console.WriteLine(ChildNode.InnerText);
                        }
                    }
    
                }

    The format of the XMLdocument is documented in http://msdn.microsoft.com/en-us/library/cc463899(v=exchg.80).aspx

    Cheers
    Glen


    Wednesday, October 16, 2013 5:35 AM
  • Hi Glen,

    Thanks for your reply. As I am looking for a whole organizations working time, Is it possible to track all the resources working time through external api's or any other.

    ~Gokul


    Wednesday, October 16, 2013 5:25 PM
  • Hello Gokulramkumar,

    if using PowerShell is a valid option for you, using the Get-MailboxCalendarConfiguration Cmdlet ought to do the trick for you. Since I usually start things from the PowerShell side and add other Apis / languages to it, I have no experience launching PowerShell commandlets from C#, so I can't help you with that, but I think I've heard there's a fairly simple way to do that. The search function ought to go a long way for that.

    Cheers,
    Fred

    Ps.: Please note, that you need the Exchange Management Shell to run Exchange Cmdlets (It can be installed using the Exchange Server Installer, ought to be already available on all Exchange 2010+ Servers and can be installed on any current Server or Client Windows OS). That's a PSSnapin, not a module, which may cause it to act odd outside PowerShell. You only see Cmdlets you have the permissions to use. This means, trying to run the command without permissions will not throw a "Permission Denied" Error, but an "Unknown Command" Error, as it never has been loaded in the first place.


    There's no place like 127.0.0.1

    Wednesday, October 16, 2013 8:37 PM