예제 #1
0
        /// <summary>
        /// Creates HostingSpacesRow class instance.
        /// </summary>
        /// <param name="hsRow">Hosting Space information data row</param>
        /// <param name="currentOverusageReport">The report to update.</param>
        /// <param name="isDiskspaceOverused">Shows whether diskspace is overused.</param>
        /// <param name="isBandwidthOverused">Shows whether bandwidth is overused.</param>
        /// <param name="packageFullTree">Hosting spaces tree.</param>
        /// <returns>HostingSpacesRow class instance.</returns>
        private static Reports.OverusageReport.HostingSpaceRow CreateHostingSpacesRow(DataRow hsRow, Reports.OverusageReport currentOverusageReport, bool isDiskspaceOverused, bool isBandwidthOverused, string packageFullTree)
        {
            Reports.OverusageReport.HostingSpaceRow row = Reports.OverusageReport.HostingSpaceRow.CreateFromHostingSpacesRow(currentOverusageReport, hsRow, isDiskspaceOverused, isBandwidthOverused, packageFullTree);

            //TODO: Optimiza it in some way :)
            PackageInfo packageInfo = GetPackage((int)row.HostingSpaceId);
            row.Location = ServerController.GetServerShortDetails(packageInfo.ServerId).ServerName;
            row.HostingSpaceCreationDate = packageInfo.PurchaseDate;

            return row;
        }
예제 #2
0
        /// <summary>
        /// Gathers summary information about disksapce usage.
        /// </summary>
        /// <param name="report"></param>
        /// <param name="packageId"></param>
        /// <param name="rootHostingSpacePath"></param>
        /// <returns></returns>
        private static Reports.OverusageReport GetDiskspaceReport(Reports.OverusageReport report, int userId, long packageId, string rootHostingSpacePath)
        {
            DataTable dsTable = GetPackagesDiskspacePaged(userId, (int)packageId);

            Reports.OverusageReport.HostingSpaceRow hsRow = null;

            //1. generate basic list of reports
            foreach (DataRow dsRow in dsTable.Rows)
            {
                if (Reports.OverusageReport.HostingSpaceRow
                    .VerifyIfDiskspaceOverused(dsRow))
                {
                    //determine whether this row already exists in the table
                    hsRow = report.HostingSpace.FindByHostingSpaceId(
                        Reports.OverusageReport.HostingSpaceRow.GetPackageId(dsRow)
                        );
                    if (hsRow != null)
                    {
                        //if so, just update it's Diskspace overusage status
                        hsRow.IsDiskspaceOverused = true;
                    }
                    else
                    {
                        //othrewise, create a new one
                        report.HostingSpace.AddHostingSpaceRow(
                            CreateHostingSpacesRow(dsRow, report, true, false, rootHostingSpacePath)
                        );
                    }

                    report.DiskspaceOverusage.AddDiskspaceOverusageRow(
                        Reports.OverusageReport.DiskspaceOverusageRow
                        .CreateFromHostingSpacesRow(report, dsRow)
                    );
                }
            }

            //2. analyze children
            foreach (DataRow dsRow in dsTable.Rows)
            {
                if (Reports.OverusageReport.HostingSpaceRow.IsContainChildSpaces(dsRow))
                {
                    report = GetDiskspaceReport(
                              report
                            , userId
                            , Reports.OverusageReport.HostingSpaceRow.GetPackageId(dsRow)
                            , String.Format(
                                      "{0} \\ {1}"
                                    , rootHostingSpacePath
                                    , Reports.OverusageReportUtils.GetStringOrDefault(dsRow, "PackageName", String.Empty)
                              )
                        );
                }
            }

            return report;
        }
예제 #3
0
        private static Reports.OverusageReport GetBandwidthReport(Reports.OverusageReport report, int userId, long packageId, string rootHostingSpacePath, DateTime startDate, DateTime endDate)
        {
            DataTable bwTable = GetPackagesBandwidthPaged(userId, (int)packageId, startDate, endDate);

            Reports.OverusageReport.HostingSpaceRow hsRow = null;

            // 1.
            foreach (DataRow bwRow in bwTable.Rows)
            {
                if (Reports.OverusageReport.HostingSpaceRow
                    .VerifyIfBandwidthOverused(bwRow))
                {
                    hsRow = report.HostingSpace.FindByHostingSpaceId(
                        Reports.OverusageReport.HostingSpaceRow.GetPackageId(bwRow)
                    );

                    if (hsRow != null)
                    {
                        hsRow.IsBandwidthOverused = true;
                    }
                    else
                    {
                        report.HostingSpace.AddHostingSpaceRow(
                            CreateHostingSpacesRow(bwRow, report, false, true, rootHostingSpacePath)
                            );
                    }

                    report.BandwidthOverusage.AddBandwidthOverusageRow(
                             Reports.OverusageReport.BandwidthOverusageRow
                             .CreateFromHostingSpaceDataRow(report, bwRow)
                        );
                }
            }


            // 2.
            foreach (DataRow bwRow in bwTable.Rows)
            {
                if (Reports.OverusageReport.HostingSpaceRow
                    .IsContainChildSpaces(bwRow))
                {
                    report = GetBandwidthReport(
                          report
                        , userId
                        , Reports.OverusageReport.HostingSpaceRow.GetPackageId(bwRow)
                        , String.Format(
                                      "{0} \\ {1}"
                                    , rootHostingSpacePath
                                    , Reports.OverusageReportUtils.GetStringOrDefault(bwRow, "PackageName", String.Empty)
                              )
                        , startDate
                        , endDate
                    );
                }
            }


            return report;
        }
예제 #4
0
        private static Reports.OverusageReport GetDiskspaceDetails(Reports.OverusageReport report)
        {
            foreach (Reports.OverusageReport.HostingSpaceRow hsRow in report.HostingSpace.Rows)
            {
                DataSet ds = GetPackageDiskspace((int)hsRow.HostingSpaceId);

                foreach (DataRow dsRow in ds.Tables[0].Rows)
                {
                    report.OverusageDetails.AddOverusageDetailsRow(
                        Reports.OverusageReport.OverusageDetailsRow
                        .CreateFromPackageDiskspaceRow(report, dsRow, hsRow.HostingSpaceId, "Diskspace")
                    );
                }
            }

            return report;
        }
예제 #5
0
        private static Reports.OverusageReport GetBandwidthDetails(Reports.OverusageReport report, DateTime startDate, DateTime endDate)
        {
            foreach (Reports.OverusageReport.HostingSpaceRow hsRow in report.HostingSpace.Rows)
            {
                DataSet ds = GetPackageBandwidth((int)hsRow.HostingSpaceId, startDate, endDate);

                foreach (DataRow bwRow in ds.Tables[0].Rows)
                {
                    report.OverusageDetails.AddOverusageDetailsRow(
                        Reports.OverusageReport.OverusageDetailsRow
                        .CreateFromBandwidthRow(report, bwRow, hsRow.HostingSpaceId, "Bandwidth")
                    );
                }
            }

            return report;
        }
예제 #6
0
        private static Reports.OverusageReport GetBandwidthInformationAboutPackage(Reports.OverusageReport report, int packageId, DateTime startDate, DateTime endDate)
        {
            PackageInfo packageInfo = GetPackage(packageId);
            packageInfo.BandWidthQuota = GetPackageQuota(packageId, "OS.Bandwidth").QuotaAllocatedValue;
            packageInfo.BandWidthQuota = packageInfo.BandWidthQuota < 1 ? 0 : packageInfo.BandWidthQuota;

            // 1. Add HostingSpace row
            report.HostingSpace.AddHostingSpaceRow(
                Reports.OverusageReport.HostingSpaceRow
                .CreateFromPackageInfo(
                      report
                    , packageInfo
                    , UserController.GetUser(packageInfo.UserId)
                    , ServerController.GetServerByIdInternal(packageInfo.ServerId)
                    , packageInfo.DiskSpace > packageInfo.DiskSpaceQuota
                    , packageInfo.BandWidth > packageInfo.BandWidthQuota
                    , String.Empty
                )
            );

            // 2. Add BandwidthOverusage row
            report.BandwidthOverusage.AddBandwidthOverusageRow(
                Reports.OverusageReport.BandwidthOverusageRow
                .CreateFromPackageInfo(
                      report
                    , packageInfo
                )
            );

            return report;
        }