예제 #1
0
        public static LicenseManager4Web.Entities.Written.Activation ActivateLicense(int licenseId, string cpuID)
        {
            using (var dc = new LicenseManagerClassesDataContext())
            {
                //never activated or has matching cpuid
                LicenseManager4Web.Entities.Activation a = (from act in dc.Activations
                                                            join l in dc.Licenses on act.LicenseID equals l.ID
                                                            join lf in dc.LicenseFeatures on act.LicenseID equals lf.LicenseID
                                                            where act.LicenseID == licenseId && act.Enabled == true &&
                                                            (act.CPUID == string.Empty && act.IsActivated == false || act.CPUID == cpuID && act.IsActivated == false)
                                                            select act).FirstOrDefault();


                if (DateTime.Compare(a.License.LicenseFeatures[0].ExtendedExpirationDate.Value, DateTime.Now) <= 0)
                {
                    throw new Exception("Activation has expired.");
                }

                a.CPUID       = cpuID;
                a.IsActivated = true;

                a.License.LicenseFeatures[0].ExtendedExpirationDate = a.ExpirationDate;

                dc.SubmitChanges();

                return(MapActivation(a));
            }
        }
예제 #2
0
        public static LicenseManager4Web.Entities.Written.Activation MapActivation(LicenseManager4Web.Entities.Activation dbo)
        {
            LicenseManager4Web.Entities.Written.Activation obj = new LicenseManager4Web.Entities.Written.Activation();
            Mapper.Map(dbo, obj);

            return(obj);
        }