Question: How does HC calculate quota for custom resource?
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:
- Add a custom resource from Hosting Plans :: Add-Ons :: Add Resource.
- Then add Menu and its link through My Server :: Custom Menus :: Add Custom Menu. This makes your application become integrated with HC Panel.
- 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();
SqlCommand cmd = new SqlCommand("pmCustomQuotaManager", m_con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 1000;
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.*/
/*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.*/
/* Its value can be 1 or 0, I for turning ON and 0 for turning OFF*/
//now running procedure
Once you have added this function in your application code, HC will automatically calculate and manage quota for this integrated application.