示例#1
0
        private DataTable PopulateChartData(int assetID)
        {
            DataTable resultsDataTable = new DataTable();

            DataTable uniqueDrivesDataTable = _statisticsDAO.UniqueDriveLettersForAsset(assetID);
            DataTable serverDriveDataTable  = _statisticsDAO.StatisticsServerData(assetID);

            DataColumn dataColumn = new DataColumn();

            dataColumn.DataType   = Type.GetType("System.String");
            dataColumn.ColumnName = "Drive Letter";
            resultsDataTable.Columns.Add(dataColumn);

            dataColumn            = new DataColumn();
            dataColumn.DataType   = Type.GetType("System.Int32");
            dataColumn.ColumnName = "Used Space";
            resultsDataTable.Columns.Add(dataColumn);

            dataColumn            = new DataColumn();
            dataColumn.DataType   = Type.GetType("System.Int32");
            dataColumn.ColumnName = "Free Space";
            resultsDataTable.Columns.Add(dataColumn);

            try
            {
                foreach (DataRow driveLetterRow in uniqueDrivesDataTable.Rows)
                {
                    string driveLetter = (string)driveLetterRow.ItemArray[1];

                    DataRow[] serverDriveRows = serverDriveDataTable.Select("_CATEGORY = '" + driveLetter + "'");

                    if (serverDriveRows[6].ItemArray[3].ToString() != "Fixed Drive")
                    {
                        continue;
                    }

                    DataRow newDataRow = resultsDataTable.NewRow();
                    newDataRow[0] = serverDriveRows[3].ItemArray[3].ToString();

                    int usedSpace = Convert.ToInt32(serverDriveRows[4].ItemArray[3]) - Convert.ToInt32(serverDriveRows[5].ItemArray[3]);

                    newDataRow[1] = usedSpace;
                    newDataRow[2] = Convert.ToInt32(serverDriveRows[4].ItemArray[3]) - usedSpace;

                    resultsDataTable.Rows.Add(newDataRow);
                }
            }
            catch (Exception ex)
            {
            }

            DateTime lastAuditDate = new AssetDAO().GetLastAuditDate(assetID);

            if (lastAuditDate != DateTime.MinValue)
            {
                lblAuditDate.Text = "* Data correct as of " + lastAuditDate.ToLongDateString() + " at " + lastAuditDate.ToShortTimeString();
            }
            else
            {
                lblAuditDate.Text = String.Empty;
            }

            return(resultsDataTable);
        }