public DepartmentStatistics GetDetailedStatistics(Guid branchId)
        {
            if (this.database.State != ConnectionState.Open)
            {
                this.database.Open();
            }

            using (SqlCommand cmd = this.helper.CreateCommand(StoredProcedure.communication_p_getStatisticsDetails.ToProcedureName(),
                                                              new SqlParameter("@branchId", SqlDbType.UniqueIdentifier),
                                                              branchId))
            {
                XDocument statisticsXml = this.helper.GetXmlDocument(cmd.ExecuteXmlReader());
                DBRow     statistics    = new DBXml(statisticsXml).Table("statistics").FirstRow();

                DepartmentStatistics branchStats = new DepartmentStatistics();
                branchStats.CurrentTime = DateTime.Parse(statistics.Element("currentTime").Value).Round(DateTimeAccuracy.Second);
                branchStats.SystemTime  = DateTime.Now.Round(DateTimeAccuracy.Second);
                if (statistics.Element("executionMessageTime") != null)
                {
                    branchStats.LastExecutionMessage = new MessageData(statistics.Element("lastExecutionMessage").Value, DateTime.Parse(statistics.Element("executionMessageTime").Value).Round(DateTimeAccuracy.Second));
                }
                if (statistics.Element("receiveMessageTime") != null)
                {
                    branchStats.LastReceiveMessage = new MessageData(statistics.Element("lastReceiveMessage").Value, DateTime.Parse(statistics.Element("receiveMessageTime").Value).Round(DateTimeAccuracy.Second));
                }
                if (statistics.Element("sentMessageTime") != null)
                {
                    branchStats.LastSendMessage = new MessageData(statistics.Element("lastSentMessage").Value, DateTime.Parse(statistics.Element("sentMessageTime").Value).Round(DateTimeAccuracy.Second));
                }

                SynchronizeStatisticTime(branchStats);

                return(branchStats);
            }
        }