Пример #1
0
        public static void SaveLicense(LicenseFeaturesParams p)
        {
            using (var dc = new LicenseManagerClassesDataContext())
            {
                //save client
                ClientService.SaveClient(p.ClientID, p.ClientName);

                //save site
                SiteService.SaveSite(p.SiteID, p.ClientID, p.SiteName);

                //save license
                LicenseManager4Web.Entities.License l = dc.Licenses.SingleOrDefault(x => x.ID == p.LicenseID);
                l.LicenseType   = (int)p.LicenseType;
                l.Product       = p.Product;
                l.LicenseID     = p.LicenseKey;
                l.GeneratedTime = p.GeneratedDate;
                l.GeneratedBy   = p.GeneratedBy;

                //save license features
                LicenseManager4Web.Entities.LicenseFeature f = dc.LicenseFeatures.SingleOrDefault(x => x.LicenseID == p.LicenseID);
                Mapper.Map(p, f);

                dc.SubmitChanges();
            }
        }
Пример #2
0
        public static int CreateLicense(LicenseFeaturesParams p)
        {
            using (var dc = new LicenseManagerClassesDataContext())
            {
                //create site if it doesn't exist
                if (p.ClientID == -1)
                {
                    p.ClientID = ClientService.CreateClient(p.ClientName);
                }

                //create site if it doesn't exist
                if (p.SiteID == -1)
                {
                    p.SiteID = SiteService.CreateSite(p.ClientID, p.SiteName);
                }

                //create new or save license
                LicenseManager4Web.Entities.License l = new LicenseManager4Web.Entities.License();

                l.LicenseType   = (int)p.LicenseType;
                l.Product       = p.Product;
                l.LicenseID     = p.LicenseKey;
                l.ClientID      = p.ClientID;
                l.SiteID        = p.SiteID;
                l.GeneratedTime = p.GeneratedDate;
                l.GeneratedBy   = p.GeneratedBy;

                //insert new license
                dc.Licenses.InsertOnSubmit(l);
                dc.SubmitChanges();

                //create new features list and map params to it
                LicenseManager4Web.Entities.LicenseFeature f = new LicenseManager4Web.Entities.LicenseFeature();
                Mapper.Map(p, f);

                //insert new license features
                f.LicenseID = l.ID;
                dc.LicenseFeatures.InsertOnSubmit(f);
                dc.SubmitChanges();

                return(l.ID);
            }
        }
Пример #3
0
        public static LicenseFeaturesParams GetLicenseFeatureParams(int licenseId)
        {
            using (var dc = new LicenseManagerClassesDataContext())
            {
                LicenseManager4Web.Entities.LicenseFeature f = dc.LicenseFeatures.SingleOrDefault(x => x.LicenseID == licenseId);
                LicenseFeaturesParams p = new LicenseFeaturesParams();

                Mapper.Map(f, p);

                p.ClientID      = f.License.ClientID;
                p.SiteID        = f.License.SiteID;
                p.ClientName    = f.License.Client.ClientName;
                p.SiteName      = f.License.Site.SiteName;
                p.GeneratedBy   = f.License.GeneratedBy;
                p.GeneratedDate = f.License.GeneratedTime;
                p.Product       = f.License.Product;
                p.LicenseType   = (LicenseType)Enum.ToObject(typeof(LicenseType), f.License.LicenseType);

                return(p);
            }
        }