public void AddScreenshot(Data.Guid packageGuid, String filename, byte[] imagedata)
        {
            Package package = GetPackage(packageGuid);
            if (package != null)
            {
                String imageFilename = packageGuid + "-" + filename;

                package.Screenshots = package.Screenshots + imageFilename + Package.ScreenshotSeparator;

                IStorageClient client = StorageHelper.GetStorageClient();
                client.Save("package-screenshots", package.PackageTypeString, imageFilename, imagedata, Permissions.Public);

                PackageDao dao = new PackageDao();
                using (Transaction tx = new Transaction())
                {
                    dao.Save<Package>(package);
                    tx.Commit();
                }
            }
        }
 public void Save(Package package)
 {
     PackageDao dao = new PackageDao();
     using (Transaction tx = new Transaction())
     {
         dao.Save<Package>(package);
         tx.Commit();
     }
 }
        public void UnapprovePackage(Data.Guid guid)
        {
            Package package = this.GetPackage(guid);
            if (package != null)
            {
                package.IsApproved = false;

                PackageDao dao = new PackageDao();
                using (Transaction tx = new Transaction())
                {
                    dao.Save<Package>(package);
                    tx.Commit();
                }
            }
        }
 public IList<Package> GetSitePackagesForUser(UserInfo user)
 {
     PackageDao dao = new PackageDao();
     return dao.FindByUserId(user.Id);
 }
 public IList<Package> GetUnapprovedPackages()
 {
     PackageDao dao = new PackageDao();
     return dao.FindByApprovalStatus(false);
 }
 public Package GetPackage(Data.Guid packageGuid)
 {
     PackageDao dao = new PackageDao();
     return dao.FindByPackageGuid(packageGuid);
 }
        public IList<Package> GetPurchasedPackages(UserInfo user)
        {
            IList<Package> packages = new List<Package>();

            UserPackageDao dao = new UserPackageDao();
            PackageDao packageDao = new PackageDao();

            IList<UserPackage> ups = dao.FindByUserAndPackage(user.Guid);
            foreach (UserPackage up in ups)
            {
                Package package = packageDao.FindByPackageGuid(up.PackageGuid);
                if (package != null)
                    packages.Add(package);
            }

            return packages;
        }
 public IList<Package> GetAllApprovedPackages()
 {
     PackageDao dao = new PackageDao();
     return dao.FindByApprovalStatus(true);
 }
        public IList<Package> GetApprovedPackages(string packageType, int lastMaxPos, double minPrice, double maxPrice)
        {
            PackageDao dao = new PackageDao();
            IList<Package> packages = dao.FindByPackageTypeAndPrice(packageType, PackageDao.ApprovalStatus.Approved, minPrice,maxPrice);

            int end = (lastMaxPos + 8);
            if (end > packages.Count)
                end = packages.Count;

            IList<Package> results = new List<Package>();
            for (int i = lastMaxPos; i < end; i++)
                results.Add(packages[i]);

            return results;
        }
示例#10
0
        public void DeployDemoPackage(Data.Guid packageGuid, IPackageStatusNotifier notifier)
        {
            DoNotify(notifier, "Deploying Demo Package");

            PackageDao dao = new PackageDao();
            Package package = dao.FindByPackageGuid(packageGuid);
            if (package != null)
            {
                //Get the owner's subscription for this package
                CmsSubscription owner = SubscriptionManager.GetSubscription(package.OwnerSubscriptionId);
                DoNotify(notifier, "Creating Demo Account");

                //Check if our demo account exists
                MembershipUserWrapper wrapper = MembershipUtil.FindByUsername(MembershipUtil.DemoAccountUsername);
                if (!wrapper.IsValid())
                    wrapper = MembershipUtil.CreateDemoAccount();

                //Find a free subdomain name
                String subdomain = "demo-" + owner.Subdomain;
                Boolean isAvailable = SubscriptionManager.IsSubdomainAvailable(subdomain);
                int i = 1;
                while (!isAvailable)
                {
                    i++;
                    subdomain = "demo" + i.ToString() + "-" + owner.Subdomain;
                    isAvailable = SubscriptionManager.IsSubdomainAvailable(subdomain);
                }

                //Create a new subscription for the demo account
                CmsSubscription subscription = new CmsSubscription();
                subscription.Guid = package.Guid;
                subscription.Created = UtcDateTime.Now;
                subscription.Subdomain = subdomain;
                subscription.StagingDomain = subscription.Subdomain + GooeyConfigManager.DefaultCmsDomain;
                subscription.SubscriptionPlan = SubscriptionManager.GetSubscriptionPlan(SubscriptionPlans.Demo);
                subscription.PrimaryUser= wrapper.UserInfo;
                subscription.IsDemo = true;
                subscription.IsCampaignEnabled = true;
                subscription.Expires = DateTime.MaxValue;
                subscription.Culture = GooeyConfigManager.DefaultCulture;
                SubscriptionManager.Create(wrapper, subscription);

                DoNotify(notifier, "Reading Package From Archive");
                //Deploy the package into the demo site
                IStorageClient client = StorageHelper.GetStorageClient();
                byte [] zipped = client.Open(PackageContainer, PackageDirectory, package.Guid + PackageExtension);

                Compression.ZipHandler zip = new Compression.ZipHandler(zipped);
                byte [] serialized = zip.Decompress()[0].Data;

                SitePackage sitepackage = Serializer.ToObject<SitePackage>(serialized);

                Data.Guid guid = Data.Guid.New(subscription.Guid);

                DoNotify(notifier, "Deploying Package Themes To Site");
                DeployThemes(sitepackage, guid, notifier);

                DoNotify(notifier, "Deploying Package Pages To Site");
                DeployPages(sitepackage, guid, notifier);

                DoNotify(notifier, "Deploying Package Content Types To Site");
                DeployContentTypes(sitepackage, guid);

                DoNotify(notifier, "Deploying Package Content To Site");
                DeployContent(sitepackage, guid);
            }
        }
示例#11
0
        public void DeleteScreenshot(Data.Guid packageGuid, String imageFilename)
        {
            Package package = GetPackage(packageGuid);
            if (package != null)
            {
                package.Screenshots = package.Screenshots.Replace(imageFilename + Package.ScreenshotSeparator, "");

                IStorageClient client = StorageHelper.GetStorageClient();
                client.Delete("package-screenshots", package.PackageTypeString, imageFilename);

                PackageDao dao = new PackageDao();
                using (Transaction tx = new Transaction())
                {
                    dao.Save<Package>(package);
                    tx.Commit();
                }
            }
        }
示例#12
0
        public void DeletePackage(string packageGuid)
        {
            Package package = GetPackage(packageGuid);
            if (package != null)
            {
                //Delete the entries in the database
                CmsSubscription subscription = SubscriptionManager.GetSubscription(package.Guid);
                SubscriptionManager.Delete(subscription);

                PackageDao packageDao = new PackageDao();
                using (Transaction tx = new Transaction())
                {
                    packageDao.Delete<Package>(package);
                    tx.Commit();
                }

                //Delete the file from the cloud storage
                IStorageClient client = StorageHelper.GetStorageClient();
                try
                {
                    foreach (String screenshot in package.ScreenshotList)
                    {
                        client.Delete("package-screenshots", package.PackageTypeString, screenshot);
                    }
                    client.Delete(PackageContainer, PackageDirectory, package.Guid + PackageExtension);
                }
                catch (Exception e)
                {
                    Logging.Error("There was a problem deleting the package " + package.Guid, e);
                }

                //Delete the snapshots associated with this package
                String imageDirectory = SiteHelper.GetStorageKey(SiteHelper.ImagesContainerKey, package.OwnerSubscriptionId);
                client.DeleteSnapshots(imageDirectory, StorageClientConst.RootFolder);
            }
        }
示例#13
0
        public Data.Guid CreatePackage(Package package, IPackageStatusNotifier notifier)
        {
            PackageDao dao = new PackageDao();

            this.guid = package.Guid;
            String siteGuid = package.OwnerSubscriptionId;

            SitePackage sitepackage = new SitePackage();
            IList<SitePackageTheme> packageThemes = new List<SitePackageTheme>();
            IList<SitePackagePage> packagePages = new List<SitePackagePage>();
            IList<SiteContentType> packageContentTypes = new List<SiteContentType>();
            IList<SiteContent> packageContent = new List<SiteContent>();
            IList<CmsSitePath> sitePaths = new List<CmsSitePath>();

            DoNotify(notifier, "Packaging Themes");
            PackageThemes(siteGuid, packageThemes, notifier);

            DoNotify(notifier, "Packaging Pages");
            PackagePages(siteGuid, packagePages);

            DoNotify(notifier, "Packaging Content Types");
            PackageContentTypes(siteGuid, packageContentTypes);

            DoNotify(notifier, "Packaging Content");
            PackageContent(siteGuid, packageContent);

            IStorageClient client = StorageHelper.GetStorageClient();
            String imageDirectory = SiteHelper.GetStorageKey(SiteHelper.ImagesContainerKey, siteGuid);

            DoNotify(notifier, "Creating Page Image Snapshots (please wait)");
            sitepackage.PageImages = client.CreateSnapshot(imageDirectory, StorageClientConst.RootFolder);
            sitepackage.Themes = packageThemes;
            sitepackage.SiteMapPaths = CmsSiteMap.Instance.GetAllPaths(siteGuid);
            sitepackage.Pages = packagePages;
            sitepackage.ContentTypes = packageContentTypes;
            sitepackage.SiteContent = packageContent;
            sitepackage.OriginalSiteGuid = siteGuid;

            DoNotify(notifier, "Creating Package Archive");
            byte[] data = null;
            using (MemoryStream outputstream = new MemoryStream())
            {
                //Serialize the object and then compress the serialized object
                data = Serializer.ToByteArray<SitePackage>(sitepackage);
                using (ZipFile zip = new ZipFile())
                {
                    zip.AddEntry("sitepackage.bin", data);
                    zip.Save(outputstream);
                }
                data = null;

                //Write the serialized data to the container
                data = outputstream.ToArray();
            }

            DoNotify(notifier, "Saving Package Archive");
            client = StorageHelper.GetStorageClient();
            client.Save(PackageContainer,PackageDirectory, package.Guid + PackageExtension, data, Permissions.Private);

            return package.Guid;
        }
示例#14
0
        public void ApprovePackage(Data.Guid guid)
        {
            Package package = this.GetPackage(guid);
            if (package != null)
            {
                package.IsApproved = true;
                package.Approved = UtcDateTime.Now;

                PackageDao dao = new PackageDao();
                using (Transaction tx = new Transaction())
                {
                    dao.Save<Package>(package);
                    tx.Commit();
                }
            }
        }