Example #1
0
        public static MembershipUserWrapper AddUser(String username, String password, String email, String firstname, String lastname)
        {
            MembershipUserWrapper existing = FindByUsername(username);
            if (existing.MembershipUser != null)
                throw new MembershipException("The username " + username + " already exists and may not be used again.");

            if (!IsValidUsername(username))
                throw new MembershipException("The username " + username + " is not valid and may not be used.");

            if (!IsValidEmail(email))
                throw new MembershipException("The email " + email + " is not valid and may not be used.");

            UserInfo info = new UserInfo();
            info.Guid = Guid.NewGuid().ToString();
            info.Firstname = firstname;
            info.Lastname = lastname;
            info.Username = username;
            info.Email = email;
            info.Created = UtcDateTime.Now;

            UserInfoDao dao = new UserInfoDao();
            using (Transaction tx = new Transaction())
            {
                dao.Save<UserInfo>(info);
                tx.Commit();
            }

            MembershipUser user = System.Web.Security.Membership.CreateUser(info.Username, password, info.Email);
            return new MembershipUserWrapper(info, user);
        }
        public void Process(NCrawler.Crawler crawler, NCrawler.PropertyBag propertyBag)
        {
            String uri = propertyBag.Step.Uri.ToString();
            try
            {
                ImportedItem item = new ImportedItem();
                item.ImportHash = this.siteHash;
                item.Guid = System.Guid.NewGuid().ToString();
                item.SubscriptionId = this.siteGuid;
                item.ContentType = propertyBag.ContentType;
                item.ContentEncoding = propertyBag.ContentEncoding;
                item.Expires = UtcDateTime.Now.AddHours(6);
                item.Inserted = UtcDateTime.Now;
                item.Title = propertyBag.Title;
                item.Uri = propertyBag.Step.Uri.ToString();

                ImportedItemDao dao = new ImportedItemDao();
                using (Transaction tx = new Transaction())
                {
                    dao.Save<ImportedItem>(item);
                    tx.Commit();
                }
            }
            catch (Exception e)
            {
                Logging.Database.Write("import-error", "Unexpected exception importing url:" + uri + ", stack:" + e.StackTrace);
            }
        }
        private void CommitAndCloseSession(object sender, EventArgs e)
        {
            Transaction tx = new Transaction();
            if (tx.IsActive())
                tx.Commit();

            SessionProvider.Instance.Close();
        }
Example #4
0
 public void Add(BillingHistory history)
 {
     BillingHistoryDao dao = new BillingHistoryDao();
     using (Transaction tx = new Transaction())
     {
         dao.Save<BillingHistory>(history);
         tx.Commit();
     }
 }
Example #5
0
 public void Update(Receipt receipt)
 {
     ReceiptDao dao = new ReceiptDao();
     using (Transaction tx = new Transaction())
     {
         dao.Save<Receipt>(receipt);
         tx.Commit();
     }
 }
Example #6
0
        public void DeleteBySiteHash(string siteHash)
        {
            using (Transaction tx = new Transaction())
            {
                foreach (ImportedItem item in FindbyHash(Hash.New(siteHash)))
                    base.Delete<ImportedItem>(item);

                tx.Commit();
            }
        }
Example #7
0
        public void Add(HelpPage page)
        {
            page.Hash = TextHash.MD5(page.Path).Value;

            HelpPageDao dao = new HelpPageDao();
            using (Transaction tx = new Transaction())
            {
                dao.Save<HelpPage>(page);
                tx.Commit();
            }
        }
Example #8
0
 public void DeleteAllBySite(Guid siteGuid)
 {
     String hql = "select image from CmsImage image where image.SubscriptionId = :siteGuid";
     using (Transaction tx = new Transaction())
     {
         foreach (CmsImage image in base.NewHqlQuery(hql).SetString("siteGuid",siteGuid.Value).List<CmsImage>())
         {
             base.Delete(image);
         }
         tx.Commit();
     }
 }
Example #9
0
        public void Issue(Receipt receipt)
        {
            receipt.Processed = DateTime.MaxValue;
            receipt.PaidDeveloperOn = DateTime.MaxValue;

            ReceiptDao dao = new ReceiptDao();
            using (Transaction tx = new Transaction())
            {
                dao.Save<Receipt>(receipt);
                tx.Commit();
            }
        }
Example #10
0
        public void Save(CmsForm form)
        {
            if (form.Guid == null)
                form.Guid = System.Guid.NewGuid().ToString();

            CmsFormDao dao = new CmsFormDao();
            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsForm>(form);
                tx.Commit();
            }
        }
Example #11
0
 public void RemoveImportedItems(IList<Data.Guid> removed)
 {
     using (Transaction tx = new Transaction())
     {
         foreach (Data.Guid guid in removed)
         {
             ImportedItem item = FindByGuid(guid);
             if (item != null)
                 base.Delete<ImportedItem>(item);
         }
         tx.Commit();
     }
 }
Example #12
0
 public void DeleteAllByImportHash(Hash hash)
 {
     IList<ImportedItem> items = FindbyHash(hash);
     using (Transaction tx = new Transaction())
     {
         foreach (ImportedItem item in items)
         {
             if (item != null)
                 base.Delete<ImportedItem>(item);
         }
         tx.Commit();
     }
 }
Example #13
0
            public static void Write(String eventType, String message)
            {
                Gooeycms.Data.Model.Logging log = new Data.Model.Logging();
                log.Inserted = DateTime.Now;
                log.EventType = eventType;
                log.EventMessage = message;

                Gooeycms.Data.Model.LoggingDao dao = new Data.Model.LoggingDao();
                using (Transaction tx = new Transaction())
                {
                    dao.Save(log);
                    tx.Commit();
                }
            }
Example #14
0
        public static void SaveImagesToDatabase(Data.Guid siteGuid, IStorageClient client, String container, String folder, IList<StorageFile> images, IList<StorageFile> results)
        {
            CmsImageDao dao = new CmsImageDao();
            using (Transaction tx = new Transaction())
            {
                foreach (StorageFile file in images)
                {
                    StorageFile actualFile;

                    if (results != null)
                        actualFile = client.GetInfo(container, folder, file.Filename);
                    else
                        actualFile = file;

                    if (actualFile.Exists())
                    {
                        CmsImage temp = dao.FindByUrl(actualFile.Url);
                        if (temp == null)
                        {
                            FileInfo info = new FileInfo(actualFile.Filename);

                            String mimetype = "image/png";
                            if (ImageMimeTypes.ContainsKey(info.Extension))
                                mimetype = ImageMimeTypes[info.Extension];

                            temp = new CmsImage();
                            temp.CloudUrl = actualFile.Url;
                            temp.ContentType = mimetype;
                            temp.Created = UtcDateTime.Now;
                            temp.Directory = folder;
                            temp.Filename = actualFile.Filename;
                            temp.Guid = System.Guid.NewGuid().ToString();
                            temp.SubscriptionId = siteGuid.Value;
                            temp.Length = actualFile.Size;

                            dao.Save<CmsImage>(temp);
                        }

                        if (results != null)
                            results.Add(actualFile);
                    }
                }
                tx.Commit();
            }
        }
Example #15
0
        public void Approve(Data.Guid guid)
        {
            CmsInviteDao dao = new CmsInviteDao();
            CmsInvite invite = dao.FindByGuid(guid);
            if (invite == null)
                throw new ArgumentException("Could not find an invite matching the specified guid: " + guid);

            String token = TokenManager.Issue(guid.Value,TimeSpan.FromDays(60),1);

            invite.Issued = UtcDateTime.Now;
            invite.Token = token;

            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsInvite>(invite);
                tx.Commit();
            }
            SendEmail(GooeyConfigManager.ApprovedEmailTemplate, "GooeyCMS Invite Request", invite);
        }
Example #16
0
        public void AddContentType(Data.Guid siteGuid, CmsContentType type)
        {
            if (String.IsNullOrEmpty(type.Guid))
                type.Guid = Data.Guid.Create().Value;

            if (!type.IsGlobalType)
                type.SubscriptionId = siteGuid.Value;

            //make sure this name doesn't already exist
            CmsContentTypeDao dao = new CmsContentTypeDao();

            CmsContentType existing = dao.FindBySiteAndName(type.SubscriptionId, type.Name);
            if (existing != null)
                throw new ArgumentException("This type name already exists and may not be used again.");

            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsContentType>(type);
                tx.Commit();
            }

            type = GetContentType(type.Guid);
        }
Example #17
0
        public void Add(String firstname, String lastname, String email)
        {
            CmsInviteDao dao = new CmsInviteDao();
            CmsInvite invite = dao.FindByEmail(email);
            if (invite != null)
                throw new ArgumentException("This email address has already been registered.");

            invite = new CmsInvite();
            invite.Guid = System.Guid.NewGuid().ToString();
            invite.Firstname = firstname;
            invite.Lastname = lastname;
            invite.Email = email;
            invite.Created = UtcDateTime.Now;
            invite.Issued = DateTime.MaxValue;
            invite.Responded = DateTime.MaxValue;

            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsInvite>(invite);
                tx.Commit();
            }

            SendEmail(GooeyConfigManager.InviteEmailTemplate, "GooeyCMS Invite Request", invite);
        }
Example #18
0
 public void Delete(CmsContentType contentType)
 {
     if (contentType != null)
     {
         CmsContentTypeDao dao = new CmsContentTypeDao();
         using (Transaction tx = new Transaction())
         {
             dao.Delete<CmsContentType>(contentType);
             tx.Commit();
         }
     }
 }
Example #19
0
 public void DeleteField(Data.Guid contentTypeGuid, int fieldKey)
 {
     CmsContentTypeField field = GetContentTypeField(contentTypeGuid, fieldKey);
     if (field != null)
     {
         CmsContentTypeDao dao = new CmsContentTypeDao();
         using (Transaction tx = new Transaction())
         {
             dao.Delete<CmsContentTypeField>(field);
             tx.Commit();
         }
     }
 }
Example #20
0
        public CmsContent CreateContent(CmsContent content, System.Web.UI.WebControls.Table dynamicControls)
        {
            if (content.SubscriptionId == null)
                throw new ApplicationException("The subscription id must not be null. This is a programming error.");

            IList<CmsContentField> fields = new List<CmsContentField>();
            PopulateFields(content.SubscriptionId,dynamicControls, content, null);

            CmsContentDao dao = new CmsContentDao();
            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsContent>(content);
                tx.Commit();
            }

            return content;
        }
Example #21
0
 public void Delete(CmsContent content)
 {
     if (content != null)
     {
         CmsContentDao dao = new CmsContentDao();
         using (Transaction tx = new Transaction())
         {
             dao.Delete<CmsContent>(content);
             tx.Commit();
         }
     }
 }
Example #22
0
        public void Add(CmsCampaign campaign)
        {
            if (campaign.SubscriptionId == null)
                throw new ApplicationException("The subscription id for this campaign has not been set.");

            if (campaign.Guid == null)
            {
                //Make sure this tracking code hasn't been used
                CmsCampaign check = GetByTrackingCode(campaign.SubscriptionId, campaign.TrackingCode);
                if (check != null)
                    throw new ArgumentException("The tracking code: " + campaign.TrackingCode + " has already been associated with camapaign: " + check.Name + " and may not be used again.");

                campaign.Guid = System.Guid.NewGuid().ToString();
            }

            CmsCampaignDao dao = new CmsCampaignDao();
            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsCampaign>(campaign);
                tx.Commit();
            }
        }
Example #23
0
 public void Save(CmsCampaignElement element)
 {
     CmsCampaignElementDao dao = new CmsCampaignElementDao();
     using (Transaction tx = new Transaction())
     {
         dao.Save<CmsCampaignElement>(element);
         tx.Commit();
     }
 }
Example #24
0
 public void Delete(CmsCampaignElement element)
 {
     if (element != null)
     {
         CmsCampaignElementDao dao = new CmsCampaignElementDao();
         using (Transaction tx = new Transaction())
         {
             dao.Delete<CmsCampaignElement>(element);
             tx.Commit();
         }
     }
 }
Example #25
0
        public void Delete(Data.Guid siteGuid, Data.Guid guid)
        {
            CmsCampaign campaign = GetCampaign(siteGuid, guid);
            if (campaign != null)
            {
                //Delete it from the subscription itself
                SubscriptionManager.RemovePhoneFromSubscription(CurrentSite.Guid, campaign.PhoneNumber);

                CmsCampaignDao dao = new CmsCampaignDao();
                using (Transaction tx = new Transaction())
                {
                    dao.Delete<CmsCampaign>(campaign);
                    tx.Commit();
                }
            }
        }
Example #26
0
 public void Save(CmsContentType type)
 {
     CmsContentTypeDao dao = new CmsContentTypeDao();
     using (Transaction tx = new Transaction())
     {
         dao.Save<CmsContentType>(type);
         tx.Commit();
     }
 }
Example #27
0
        public void Save(CmsContent item)
        {
            CmsContentDao dao = new CmsContentDao();
            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsContent>(item);
                tx.Commit();
            }

            SitePageCacheRefreshInvoker.InvokeRefresh(item.SubscriptionId, SitePageRefreshRequest.PageRefreshType.All);
        }
Example #28
0
 private static void Delete(Registration registration)
 {
     RegistrationDao dao = new RegistrationDao();
     using (Transaction tx = new Transaction())
     {
         dao.DeleteObject(registration);
         tx.Commit();
     }
 }
Example #29
0
        public void AddContentTypeField(CmsContentType type, CmsContentTypeField field)
        {
            CmsContentTypeDao dao = new CmsContentTypeDao();
            field.Parent = type;

            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsContentTypeField>(field);
                tx.Commit();
            }
        }
Example #30
0
 /// <summary>
 /// Saves or updates the registration
 /// </summary>
 /// <param name="registration"></param>
 public static void Save(Registration registration)
 {
     RegistrationDao dao = new RegistrationDao();
     using (Transaction tx = new Transaction())
     {
         dao.Save(registration);
         tx.Commit();
     }
 }