/// <summary> /// Creating <see cref="HostingSpaceRow"/> from DataRow containing data about Hosting Space /// </summary> /// <param name="report">Current <see cref="OverusageReport"/></param> /// <param name="hostingSpaceRow"><see cref="DataRow"/> containing information about Hosting Space.</param> /// <param name="isDiskspaceOverused">Indicates whether disk space is overused.</param> /// <param name="isBandwidthOverused">Indicates whether bandwidth is overusaed.</param> /// <param name="packageFullTree">File system -like path to hosting space described by <paramref name="hostingSpaceRow"/></param> /// <returns><see cref="HostingSpaceRow"/> instance.</returns> /// <exception cref="ArgumentNullException">When <paramref name="report"/> or <paramref name="hostingSpaceRow"/> is null.</exception> public static HostingSpaceRow CreateFromHostingSpacesRow(OverusageReport report, DataRow hostingSpaceRow, bool isDiskspaceOverused, bool isBandwidthOverused, string packageFullTree) { if (report == null) { throw new ArgumentNullException("report"); } if (hostingSpaceRow == null) { throw new ArgumentNullException("hostingSpaceRow"); } HostingSpaceRow row = report.HostingSpace.NewHostingSpaceRow(); row.IsBandwidthOverused = isBandwidthOverused; row.IsDiskspaceOverused = isDiskspaceOverused; row.HostingSpaceName = OverusageReportUtils.GetStringOrDefault(hostingSpaceRow, "PackageName", String.Empty); row.UserEmail = OverusageReportUtils.GetStringOrDefault(hostingSpaceRow, "Email", String.Empty); row.UserName = OverusageReportUtils.GetStringOrDefault(hostingSpaceRow, "Username", String.Empty); row.UserId = OverusageReportUtils.GetLongValueOrDefault(hostingSpaceRow["UserId"].ToString(), 0); row.HostingSpaceId = OverusageReportUtils.GetLongValueOrDefault(hostingSpaceRow["PackageID"].ToString(), 0); row.ChildSpaceQuantity = (int)OverusageReportUtils.GetLongValueOrDefault(hostingSpaceRow["PackagesNumber"].ToString(), 0); row.Status = hostingSpaceRow["StatusID"].ToString(); row.HostingSpaceFullTreeName = packageFullTree; return(row); }
/// <summary> /// Creates <see cref="OverusageDetailsRow"/> using information about Hosting Space bandwidth. /// </summary> /// <param name="report">Current <see cref="OverusageReport"/> instance.</param> /// <param name="bandwidthRow"><see cref="DataRow"/> containing information about Hosting Space bandwidth.</param> /// <param name="hostingSpaceId">Hosting Space Id.</param> /// <param name="overusageType">Type of overusage. Diskspace, Bandwidth, etc.</param> /// <returns><see cref="OverusageDetailsRow"/> filled from <paramref name="bandwidthRow"/>.</returns> /// <exception cref="ArgumentNullException">When <paramref name="report"/>, <paramref name="bandwidthRow"/> or <paramref name="overusageType"/> is null.</exception> /// <exception cref="ArgumentOutOfRangeException">When <paramref name="hostingSpaceId"/> less then 1.</exception> public static OverusageDetailsRow CreateFromBandwidthRow(OverusageReport report, DataRow bandwidthRow, long hostingSpaceId, string overusageType) { if (report == null) { throw new ArgumentNullException("report"); } if (bandwidthRow == null) { throw new ArgumentNullException("bandwidthRow"); } if (String.IsNullOrEmpty(overusageType)) { throw new ArgumentNullException("overusageType"); } if (hostingSpaceId < 1) { throw new ArgumentOutOfRangeException( "hostingSpaceId" , String.Format( "Hosting Space Id cannot be less then 1, however it is {0}." , hostingSpaceId ) ); } OverusageDetailsRow row = report.OverusageDetails.NewOverusageDetailsRow(); row.HostingSpaceId = hostingSpaceId; row.OverusageType = overusageType; row.ResourceGroupName = OverusageReportUtils.GetStringOrDefault(bandwidthRow, "GroupName", "Files"); row.Used = OverusageReportUtils.GetLongValueOrDefault(bandwidthRow["MegaBytesSent"].ToString(), 0); row.AdditionalField = OverusageReportUtils.GetLongValueOrDefault(bandwidthRow["MegaBytesReceived"].ToString(), 0); row.Allowed = 0; return(row); }