コード例 #1
0
        /// <summary>
        /// Get List Count
        /// </summary>
        /// <param name="server">Device Server name</param>
        /// <returns>List Count on specified server</returns>
        public Int32 GetListCount(String server)
        {
            ADCServer deviceServer;

            if (_lists == null)
            {
                throw new ServerNotRunningException(ServerNotRunningException.GetFormattedMessage(server));
            }
            var targetServer = _lists.FirstOrDefault(listServer => listServer.Key == server);

            if (targetServer.Equals(default(KeyValuePair <string, List <ADCListHelper> >)))
            {
                if (_servers.Any(serverAdapter => serverAdapter.ServerName == server))
                {
                    throw new ServerNotRunningException(ServerNotRunningException.GetFormattedMessage(server));
                }
                throw new ServerNotExistException(ServerNotExistException.GetFormattedMessage(server));
            }
            if (targetServer.Value == null)
            {
                throw new ServerNotRunningException(ServerNotRunningException.GetFormattedMessage(server));
            }
            deviceServer = targetServer.Value.ElementAt(0).DS;
            if (deviceServer != null && deviceServer.IsAlive)
            {
                return(deviceServer.NumberOfLists);
            }
            return(0);
        }
コード例 #2
0
        private ADCListHelper GetListHelper(String server, Int32 list)
        {
            if (_lists == null)
            {
                throw new ServerNotRunningException(ServerNotRunningException.GetFormattedMessage(server));
            }
            var targetServer = _lists.FirstOrDefault(listServer => listServer.Key == server);

            if (targetServer.Equals(default(KeyValuePair <string, List <ADCListHelper> >)))
            {
                if (_servers.Any(serverAdapter => serverAdapter.ServerName == server))
                {
#if (DEBUG)
                    Logger.ServiceLogger.Warning(String.Format("Server ({0}) is not Running. There is no list helpers.", server));
#endif
                    throw new ServerNotRunningException(ServerNotRunningException.GetFormattedMessage(server));
                }
#if (DEBUG)
                Logger.ServiceLogger.Warning(String.Format("Server ({0}) is not Configured. '_servers' collection does not contain this server.", server));
#endif
                throw new ServerNotExistException(ServerNotExistException.GetFormattedMessage(server));
            }
            if (targetServer.Value == null)
            {
#if (DEBUG)
                Logger.ServiceLogger.Warning(String.Format("Server ({0}) is not Running. The list helpers collection is null.", server));
#endif
                throw new ServerNotRunningException(ServerNotRunningException.GetFormattedMessage(server));
            }
            var listHelper = targetServer.Value.FirstOrDefault(helper => helper.GetListNumber() == list);
            if (listHelper == null)
            {
                throw new ListServiceListNotEnabledException(ListServiceListNotEnabledException.GetFormattedMessage(server, list));
            }
            if (!listHelper.DS.IsAlive)
            {
#if (DEBUG)
                Logger.ServiceLogger.Warning(String.Format("Server ({0}) is not Configured. The server adapter is not alive.", server));
#endif
                throw new ServerNotExistException(ServerNotExistException.GetFormattedMessage(server));
            }

            return(listHelper);
        }