コード例 #1
0
ファイル: LicenseService.cs プロジェクト: klimkina/CSharp
        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);
            }
        }
コード例 #2
0
ファイル: SiteService.cs プロジェクト: klimkina/CSharp
 public static int CreateSite(int clientId, string siteName)
 {
     return(SiteService.CreateSite(clientId, siteName, string.Empty));
 }