getTimestamp() public method

public getTimestamp ( ) : string
return string
コード例 #1
0
        internal void heartbeat()
        {
            Dictionary<string, List<AbstractConnection>> cxnsToRemove = new Dictionary<string, List<AbstractConnection>>();

            foreach (string site in _connections.Keys)
            {
                foreach (AbstractConnection cxn in _connections[site])
                {
                    if (DateTime.Now.Subtract(cxn.LastQueryTimestamp).Seconds > _cxnRefreshTime)
                    {
                        try
                        {
                            VistaToolsDao dao = new VistaToolsDao(cxn);
                            dao.getTimestamp();
                        }
                        catch (Exception)
                        {
                            if (!cxnsToRemove.ContainsKey(site))
                            {
                                cxnsToRemove.Add(site, new List<AbstractConnection>());
                            }
                            cxnsToRemove[site].Add(cxn);
                        }
                    }
                }
            }

            if (cxnsToRemove.Count > 0)
            {
                foreach (string site in cxnsToRemove.Keys)
                {
                    foreach (AbstractConnection cxn in cxnsToRemove[site])
                    {
                        _connections[site].Remove(cxn);
                        _currentActiveConnections--;
                    }
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// This function should locate a connection marked as available, verify the connection
 /// is still active (using a simple getTimestamp query), re-allocate any encountered failed
 /// connections out of process, and return the first connection that is available and connected
 /// </summary>
 /// <param name="siteId"></param>
 /// <returns></returns>
 internal AbstractConnection getAvailableConnection(string siteId)
 {
     lock (_connections)
     {
         if (_connections.ContainsKey(siteId) && _connections[siteId].Count > 0)
         {
             foreach (AbstractConnection cxn in _connections[siteId])
             {
                 if (cxn.IsAvailable)
                 {
                     VistaToolsDao dao = new VistaToolsDao(cxn);
                     try
                     {
                         dao.getTimestamp();
                         cxn.IsAvailable = false;
                         return cxn;
                     }
                     catch (Exception)
                     {
                         _currentActiveConnections--;
                         cxn.IsAvailable = false;
                         reallocateConnection(cxn);
                     }
                 }
             }
         }
     }
     return null;
 }