Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Product API

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support
View previous topic :: View next topic  
Author Message
BradBeech



Joined: 08 Jan 2015
Posts: 10

PostPosted: Thu Jan 08, 2015 7:10 am    Post subject: Product API Reply with quote

Hi

Is it possible to create new products and insert them, via an API? So maybe via Infralution.Licensing.Data.dll?

I see there is A Product class but it takes an XmlReader or DbDataReader. We tried modifying an existing product and then calling insert but if fails since with an Unused column error (extra column in parameters that is not in the database I see).

Could we go straight into SQL (as a last resort)?

Thanks!
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Jan 08, 2015 9:49 pm    Post subject: Reply with quote

The Infralution.Licensing.Data API doesn't support adding new products directly - because it isn't something you would normally want to do via the API. It does have a method to create a new product from an XML Stream which is designed to support synchronization of the Authentication database with the main LicenseTracker database. To use this method to create a new product however you would have to know the ID's of the existing Products in the database. It would probably be much easier to simply write SQL to create the record in the database directly.

Why do you need to create products dynamically like this?
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
BradBeech



Joined: 08 Jan 2015
Posts: 10

PostPosted: Fri Jan 09, 2015 7:14 am    Post subject: Reply with quote

We are wanting to create an ecosystem around product management and license generation. Including workflow before creation of licenses, feature management (info to be put in AuthenticationData). This is basically all fine, an fits in as per your Key Generator Sample.

We are to implement this in web technologies.

Our license administrator would generate keys via this website, however we would love to have this person manage the products as well from the website, and not have to have a separate app (LicenseTracker) to manage the products.

We are not reselling a licensing system. This is for licensing our software products and version thereof.

Does what we are trying to do make sense?
Back to top
View user's profile Send private message
BradBeech



Joined: 08 Jan 2015
Posts: 10

PostPosted: Fri Jan 09, 2015 7:25 am    Post subject: Reply with quote

Forgive this hacky code - this is what I have found so far. It is using your xml constructor you mention.

The Product.UpdateOrInsert() method was throwing an exception since it tries tries to update a column called 'Unused', and fails. I added this column to the Products table to see if it would work, and it did. I don't feel this is the correct solution however - maybe just adding the product to the table directly via sql instead of using the Product class as you suggest?

AuthenticatedLicenseParameters parms = new AuthenticatedLicenseParameters();
parms.AuthenticationPassword = "AUTHENTICATEME";
parms.AuthenticationServerURL = "http://localhost:2142/AuthenticationService.asmx";
parms.IncludeApplicationData = false;
parms.MaxAuthentications = 2;
parms.ProductName = DateTime.Now.ToString("s");
parms.ProductPassword = "TEST";

var parameters = parms.WriteToString(true);
XElement elem = XElement.Parse(string.Format("<Product>{0}</Product>", parameters));

using (StringReader sr = new StringReader(elem.ToString(SaveOptions.OmitDuplicateNamespaces)))
using (var xmlTextReader = new XmlTextReader(sr))
{
Product product = new Product(database, xmlTextReader);

product.ExpiryDays = 30;
product.KeyMaxAuthentications = parms.MaxAuthentications;
//product.DefaultProductInfo = product.GetDefaultProductInfo();
//product.ImportAsParentProduct = true;
//product.IsBaseProduct = true;
product.Name = parms.ProductName;
product.LicenseType = LicenseType.AuthenticatedLicense;
product.IpnItemName = product.Name;

product.UpdateOrInsert();
}
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Sun Jan 11, 2015 1:33 am    Post subject: Reply with quote

The Infralution.Licensing.DataProduct class is designed for importing Product data from the main license tracker database into the remote Authentication database. The remote Authentication database has an extract column used to track the Products which are no longer used - which is why that is failing. I think it would be cleaner to write to the database directly using SQL
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group