Ejemplo n.º 1
0
 public override void Update()
 {
     SetParameter(IGSMSTATUS_MAXCONNECTIONS, IGServerManagerLocal.LocalInstance.GetNbConnections().ToString());
     SetParameter(IGSMSTATUS_NBCONNECTIONS, IGServerManagerLocal.LocalInstance.GetNbUserConnections().ToString());
     m_lUsers.Clear();
     m_xmlNodeUsers.RemoveAll();
     foreach (IGConnectionLocal connection in IGServerManagerLocal.LocalInstance.GetConnections())
     {
         IGSMStatusUser userStatus = connection.GetUserStatus();
         userStatus.Stop();
         userStatus.OnTimedEvent(null, null);
         if (connection.m_sUser != null)
         {
             IGSMStatusUser statusUser = new IGSMStatusUser(connection);
             XmlNode userNodeAnswer = statusUser.GetAnswer();
             XmlNode userNodeStatus = userNodeAnswer.SelectSingleNode("./Params");
             XmlNode userNode = m_xmlDoc.CreateNode(XmlNodeType.Element, IGSMSTATUS_USER, null);
             foreach (XmlAttribute att in userNodeStatus.Attributes)
             {
                 XmlAttribute newAtt = m_xmlDoc.CreateAttribute(att.Name);
                 newAtt.Value = att.Value;
                 userNode.Attributes.Append(newAtt);
             }
             XmlNode xmlSessionLength = userNode.Attributes.GetNamedItem(IGSMSTATUS_SESSIONLENGTH);
             if (xmlSessionLength != null)
             {
                 DateTime sessionLength = new DateTime(Convert.ToInt64(xmlSessionLength.Value) * 10000);
                 XmlNode xmlIdleTime = userNode.Attributes.GetNamedItem(IGSMSTATUS_IDLETIME);
                 if (xmlIdleTime != null)
                 {
                     DateTime idleTime = new DateTime(Convert.ToInt64(xmlIdleTime.Value) * 10000);
                     string sSessionLength = (sessionLength.Hour > 0) ? sessionLength.Hour + " : " : "";
                     sSessionLength += (sessionLength.Minute > 0) ? sessionLength.Minute + "' " : "";
                     sSessionLength += sessionLength.Second + "''";
                     string sIdleTime = (idleTime.Hour > 0) ? idleTime.Hour + " : " : "";
                     sIdleTime += (idleTime.Minute > 0) ? idleTime.Minute + "' " : "";
                     sIdleTime += idleTime.Second + "''";
                     int nStatus = Convert.ToInt32(userNode.Attributes.GetNamedItem(IGSMSTATUS_STATUS).Value);
                     string sStatus = (nStatus == (int)IGSMStatus.IGState.IGSMSTATUS_READY) ? "Ready" :
                                     (nStatus == (int)IGSMStatus.IGState.IGSMSTATUS_WORKING) ? "Working..." :
                                     (nStatus == (int)IGSMStatus.IGState.IGSMSTATUS_NOTRESPONDING) ? "Not Responding" :
                                     (nStatus == (int)IGSMStatus.IGState.IGSMSTATUS_DISCONNECTING) ? "Disconnecting" : "Unknown";
                     XmlAttribute newUserAtt = m_xmlDoc.CreateAttribute(IGSMSTATUS_SESSIONLENGTH);
                     newUserAtt.Value = sSessionLength;
                     userNode.Attributes.Append(newUserAtt);
                     newUserAtt = m_xmlDoc.CreateAttribute(IGSMSTATUS_IDLETIME);
                     newUserAtt.Value = sIdleTime;
                     userNode.Attributes.Append(newUserAtt);
                     newUserAtt = m_xmlDoc.CreateAttribute(IGSMSTATUS_STATUS);
                     newUserAtt.Value = sStatus;
                     userNode.Attributes.Append(newUserAtt);
                     newUserAtt = m_xmlDoc.CreateAttribute(IGSMSTATUS_STATUSID);
                     newUserAtt.Value = nStatus.ToString();
                     userNode.Attributes.Append(newUserAtt);
                     foreach (XmlNode childNode in userNodeAnswer.SelectNodes("./Image"))
                     {
                         XmlNode imageNode = m_xmlDoc.CreateNode(XmlNodeType.Element, IGSMSTATUS_IMAGE, null);
                         foreach (XmlAttribute att in childNode.Attributes)
                         {
                             XmlAttribute newAtt = m_xmlDoc.CreateAttribute(att.Name);
                             newAtt.Value = att.Value;
                             imageNode.Attributes.Append(newAtt);
                         }
                         int nImageStatus = Convert.ToInt32(imageNode.Attributes.GetNamedItem(IGSMSTATUS_STATUS).Value);
                         string sImageStatus = (nImageStatus == (int)IGSMStatusUser.IGState.IGSMSTATUS_READY) ? "Ready" :
                                                 (nImageStatus == (int)IGSMStatusUser.IGState.IGSMSTATUS_WORKING) ? "Working..." : "Not Responding";
                         XmlAttribute newImageAtt = m_xmlDoc.CreateAttribute(IGSMSTATUS_STATUS);
                         newImageAtt.Value = sImageStatus;
                         imageNode.Attributes.Append(newImageAtt);
                         userNode.AppendChild(imageNode);
                     }
                     m_xmlNodeUsers.AppendChild(userNode);
                     m_lUsers.Add(statusUser);
                 }
             }
             userStatus.Start();
         }
     }
     if (m_delegateOnUpdate != null)
         m_delegateOnUpdate(m_xmlDoc.SelectSingleNode("*/Params"));
 }
Ejemplo n.º 2
0
 public override IGAnswer CreateAnswer()
 {
     IGSMAnswer status = null;
     switch (m_eType)
     {
         case IGSMStatus.IGSMStatusType.IGSMSTATUS_FULLSTART:
             status = new IGSMFullStatusStart();
             break;
         case IGSMStatus.IGSMStatusType.IGSMSTATUS_FULLSTOP:
             status = new IGSMFullStatusStop();
             break;
         case IGSMStatus.IGSMStatusType.IGSMSTATUS_USER:
             status = new IGSMStatusUser(m_sUser);
             break;
         case IGSMStatus.IGSMStatusType.IGSMSTATUS_ISUSERCONNECTED:
             status = new IGSMStatusUserConnected(m_sUser);
             break;
         case IGSMStatus.IGSMStatusType.IGSMSTATUS_AVAILABILITY:
             status = new IGSMStatusAvailability();
             break;
         default:
             status = new IGSMAnswerActionDone(this);
             break;
     }
     return status;
 }
Ejemplo n.º 3
0
 public IGConnectionLocal(IGServer igServer)
     : base(igServer)
 {
     m_status = new IGSMStatusUser();
     m_lsImages = new List<string>();
 }