/// <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 a <see cref="BandwidthOverusageRow"/> using the <see cref="OverusageReport"/> /// DataSet from a row that contains information about bandwidth usage. /// </summary> /// <param name="report">Instance of <see cref="OverusageReport"/> class.</param> /// <param name="hostingSpaceDataRow">DataRow with bandwidth information.</param> /// <returns><see cref="BandwidthOverusageRow"/>.</returns> /// <exception cref="ArgumentNullException">When <paramref name="report"/> or either <paramref name="hostingSpaceDataRow"/> is <code>null</code>.</exception> public static BandwidthOverusageRow CreateFromHostingSpaceDataRow(OverusageReport report, DataRow hostingSpaceDataRow) { if (report == null) { throw new ArgumentNullException("report"); } if (hostingSpaceDataRow == null) { throw new ArgumentNullException("hostingSpaceDataRow"); } BandwidthOverusageRow row = report.BandwidthOverusage.NewBandwidthOverusageRow(); row.HostingSpaceId = OverusageReportUtils.GetLongValueOrDefault(hostingSpaceDataRow["PackageID"].ToString(), 0); row.Allocated = OverusageReportUtils.GetLongValueOrDefault(hostingSpaceDataRow["QuotaValue"].ToString(), 0); row.Used = OverusageReportUtils.GetLongValueOrDefault(hostingSpaceDataRow["Bandwidth"].ToString(), 0); row.Usage = (row.Used - row.Allocated); return(row); }
/// <summary> /// Creates <see cref="DiskspaceOverusageRow"/> using <see cref="PackageInfo"/> information. /// </summary> /// <param name="report">Current <see cref="OverusageReport"/></param> /// <param name="packageInfo">Hosting Space information.</param> /// <returns><see cref="DiskspaceOverusageRow"/> instance.</returns> /// <exception cref="ArgumentNullException">When <paramref name="report"/> or <paramref name="packageInfo"/> is null.</exception> public static DiskspaceOverusageRow CreateFromPackageInfo(OverusageReport report, PackageInfo packageInfo) { if (report == null) { throw new ArgumentNullException("report"); } if (packageInfo == null) { throw new ArgumentNullException("packageInfo"); } DiskspaceOverusageRow row = report.DiskspaceOverusage.NewDiskspaceOverusageRow(); row.HostingSpaceId = packageInfo.PackageId; row.Allocated = packageInfo.DiskSpaceQuota; row.Used = packageInfo.DiskSpace; row.Usage = (row.Used - row.Allocated); return(row); }
/// <summary> /// Creates <see cref="HostingSpaceRow"/> using <see cref="PackageInfo"/>. /// </summary> /// <param name="report">Current <see cref="OverusageReport"/>.</param> /// <param name="packageInfo">Information about Hosting Space</param> /// <param name="userInfo">Information about user <paramref name="packageInfo"/> belongs to.</param> /// <param name="serverInfo">Information about server. Physical storage of a hosting space described in <paramref name="packageInfo"/></param> /// <param name="isDiskspaceOverused">Indicates whether disk space is overused.</param> /// <param name="isBandwidthOverused">Indicates whether bandwidht is overused.</param> /// <param name="packageFullTree">File system -like path of the location of a hosting space described in <paramref name="packageInfo"/></param> /// <returns><see cref="HostingSpaceRow"/> instance.</returns> /// <exception cref="ArgumentNullException">When <paramref name="report"/>, <paramref name="packageInfo"/>, <paramref name="userInfo"/> or <paramref name="serverInfo"/> is null.</exception> public static HostingSpaceRow CreateFromPackageInfo(OverusageReport report, PackageInfo packageInfo, UserInfo userInfo, ServerInfo serverInfo, bool isDiskspaceOverused, bool isBandwidthOverused, string packageFullTree) { if (report == null) { throw new ArgumentNullException("report"); } if (packageInfo == null) { throw new ArgumentNullException("packageInfo"); } if (userInfo == null) { throw new ArgumentNullException("userInfo"); } if (serverInfo == null) { throw new ArgumentNullException("serverInfo"); } HostingSpaceRow row = report.HostingSpace.NewHostingSpaceRow(); row.IsBandwidthOverused = isBandwidthOverused; row.IsDiskspaceOverused = isDiskspaceOverused; row.HostingSpaceName = packageInfo.PackageName; row.UserEmail = userInfo.Username; row.UserName = userInfo.Email; row.ChildSpaceQuantity = 1; row.UserId = packageInfo.UserId; row.HostingSpaceId = packageInfo.PackageId; row.Status = packageInfo.StatusId.ToString(); row.HostingSpaceFullTreeName = packageFullTree; row.HostingSpaceCreationDate = packageInfo.PurchaseDate; row.Location = serverInfo.ServerName; 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); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); OverusageReport ds = new OverusageReport(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "HostingSpaceDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { OverusageReport ds = new OverusageReport(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }