Custom Resource Quota Management in Hosting Controller

Question:  How does HC calculate quota for custom resource?

Solution:
Hosting Controller provides facility to integrate new products with panel without writing a single line of code. This feature was initially available in HC6 and now new HC provides Custom resource Quota Management in improved way. Custom resource's sold and used quota will be managed by HC as done in case of System Resources.

HC provides Callback Stored Procedures for quota management. Hostadmin has to call this stored procedure with administrative rights from the application to be integrated, on every switched OFF/ON for a particular website.

These are the steps involved in subscribing your custom resource for automatic quota management:

  1. Add a custom resource from Hosting Plans :: Add-Ons :: Add Resource. 
  2. Then add Menu and its link through My Server :: Custom Menus :: Add Custom Menu. This makes your application become integrated with HC Panel. 
  3. Now call stored procedures "pmCustomQuotaManager" from your code.

Sample Code for .Net Applications:

          //Opening connection with HC database.

          string strConnectionString = "Your HC connection string";
           
SqlConnection m_con = new SqlConnection();

m_con.Open();

//Creating Command

SqlCommand cmd = new SqlCommand("pmCustomQuotaManager", m_con);

cmd.CommandType = CommandType.StoredProcedure;

cmd.CommandTimeout = 1000; 

 //Add parameters

cmd.Parameters.Add(new SqlParameter("@ResourceName ","mycustomresoruce"));

/* Its value should be the unique name assign to each Resource, You can get exact resource name from ResourceName field of tblResources.*/

cmd.Parameters.Add(new SqlParameter("@WebsiteId",nwebsiteid));

/*Where nwebsiteid is the id (a unique identification number given by HC to every website) of that website to which you are tuning ON/OFF this resource.It should be integer value.*/

cmd.Parameters.Add(new SqlParameter("@ResourceUsage",1/0));

/* Its value can be 1 or 0, I for turning ON and 0 for turning OFF*/

//now running procedure

cmd.ExecuteNonQuery();


Once you have added this function in your application code, HC will automatically calculate and manage quota for this integrated application.