Exemple #1
0
/// <summary>
/// Get new data & update grid
/// </summary>

        void UpdateGrid()
        {
            InUpdateGrid = true;

            ServiceHostInfo svcInf = ServiceFacade.ServiceFacade.GetServiceHostInfo();

            if (svcInf == null)
            {
                return;
            }

            List <Mobius.NativeSessionClient.SessionInfo> sil = new Mobius.NativeSessionClient.NativeSessionClient().GetSessionInfoForAllSessions();

            if (sil == null)
            {
                sil = new List <SessionInfo>();
            }

            Label.Text =
                "Server: " + svcInf.ServerName +
                ", Version: " + VersionMx.FormatVersion(svcInf.Version) +
                ", Count: " + sil.Count;

            DataTable.Rows.Clear();
            DateTime now = DateTime.Now;

            foreach (SessionInfo si in sil)
            {
                DataRow dr = DataTable.NewRow();
                dr["SessionIdCol"]   = si.Id;
                dr["IsNonNativeCol"] = si.Native ? "" : "Y";
                dr["UserIdCol"]      = si.UserId;
                try { dr["UserNameCol"] = SecurityUtil.GetShortPersonNameReversed(si.UserId); }
                catch { }

                dr["CreationDtCol"] = CommandLine.FormatTimeSpan(now.Subtract(si.CreationDT));

                if (!si.ExpirationDT.Equals(DateTime.MinValue))                 // calc idle time
                {
                    dr["IdleTimeCol"] = CommandLine.FormatTimeSpan(now.Subtract(si.ExpirationDT));
                }

                if (si.ProcessId > 0)
                {
                    dr["ProcessIdCol"] = si.ProcessId;
                }

                if (si.CpuTimeSecs > 0)
                {
                    dr["CpuTimeCol"] = (int)si.CpuTimeSecs;
                }

                if (si.MemoryMb > 0)
                {
                    dr["MemoryCol"] = si.MemoryMb;
                }

                if (si.Threads > 0)
                {
                    dr["ThreadsCol"] = si.Threads;
                }

                if (si.Handles > 0)
                {
                    dr["HandlesCol"] = si.Handles;
                }

                DataTable.Rows.Add(dr);
            }

            Grid.DataSource = DataTable;
            Grid.Refresh();
            Application.DoEvents();

            InUpdateGrid = false;
            return;
        }