A disk quota code using ASP.NET to operate COM.

zhaozj2021-02-16  57

Using system; using diskquotatypelibrary; namespace ex3cut3.libraries {////

/// ////

public

Class quotaclass {

Private diskquotacontrolclass _diskquotacontrol;

// this path as to be in this Format OR

// else is going to give an error of invalid Path

Private

Const

String filesharevolume = @

"// Server / C $ /";

Private

Const

INT MBTOBYTES =

1048576;

Public Diskquotacontrolclass Diskquotacontrol

{

get

{

IF

THIS._DISKQUOTACONTROL ==

NULL)

{

THIS._DISKQUOTACONTROL =

New diskquotacontrolclass ();

// Initializes the control to the specified path

THIS._DISKQUOTACONTROL.INITIALIZE (Filesharevolume,

True);

}

Return

THIS._DISKQUOTACONTROL;

}

}

Public quotaclass ()

{

}

///// Adds a user to the quota entries of the volume /////

/// the name of the user to add

//// the domain what the user buy es logon

/// The quota limit of this user

public

Void Add (

String username,

String UserDomain,

Int quotalimit)

{

DidiskquoTauser dskuser =

NULL;

// in Some Cases if you use name resolution,

// The application will give an error.

this.diskquotacontrol.usernameresolution =

UsernameresolutionConstants.dqresolvent;

// Here We Had the user to the quotas entrys of

// The Volume, We use user@domain.net the logon name of the user.

// You can use the domain / user or just the user,

// But in Like this Works Faster

DSKUSER =

this.diskquotacontrol.adduser

User.SAMACCOUNTNAME

"@" user.domain;

// Here We set the limit of the quota, this is IS

// Prepared to receive MB SO I Convert it to bytes

DSKUSER.QUOTALIMIT =

Int) quotalimit * mbtobytes;

// Here is the set of the warning limited

DSKUSER.QUOTATHRESHOLD =

int) (quotalimit / 1.2) * MBTOBYTES;

DSKUSER =

NULL;

}

///// Removes The user form the quota entries list //////

///

public

Void Remove

String Username)

{

// Here We Just Use the User, And Invoke

// the Method Deleteuser from the control

this.diskquotacontrol.deleteuser

this.getuser (username);

}

///// a private function to return the user object /////

/// the user name

///

A DIDISKQUOTAUSER OBJECT

/// of the specified user

Private DidiskquoTauser Getuser

String Username)

{

// invokes the method to find a user in a quota entry List

Return

this.diskquotacontrol.finduser (username);

}

/// // Gets the quota of the user /////

/// the user name

///

A formated string of the quota

/// limited of the user

Private

String getquota

String Username)

{

// Here We return the text of the quota limit

///0.0 bytes, 0.0 kb, 0.0 MB ETC

Return

this.getuser (username) .quotalimitText;

}

///// Gets the quota currently buy by the user ///

/// the user name

///

A formated string of the quota

/// use by the user

Private

String getquotaused

String Username)

{

Return

THIS.GETUSER (UserName) .quotausedText;

}

/// // Change the quota of a specified user ///

/// the user name

/// The new quota limit of the user

Private

Void Changequota

String username,

Int quotalimit)

{

DidiskquoTauser dskuser =

this.getuser (username);

DSKUSER.QUOTALIMIT = quotalimit * support.constants.convertbtomb;

DSKUSER.QUOTATHRESHOLD = (Quotalimit /

1.2)

* Support.constants.convertbtomb;

}

}

}

Description: 1. This action COM first wants to reference a COM interaction RWC, first add to DiskQuotatypelibrary.

2, add <% @ page language = "c #" asp.compat = "true"%> 3, if you want to operate COM in ASP.NET, and ASP.NET The user's permissions are not enough, so add this line in Web.config

Of course, you can also grant permissions in other ways.

4, OK, tell a paragraph first. <% @ Page language = "c #" ASPCompat = "true" autoeventwireup = "false"%> <% @ page language = "c #" aspCompat = "true" autoeventwireup = "false"%> <% @ Page language = "c #" aspcompat = "true" autoeventwireup = "false"%>

转载请注明原文地址:https://www.9cbs.com/read-21670.html

New Post(0)