/// <summary>
        /// Invoke dbo.[SendMemberWelcomePack]
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void MemberService_Created(IMemberService sender, NewEventArgs<IMember> e)
        {
            string Name = e.Entity.Name;
            string Email = e.Entity.Email;

            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }

            SqlTransaction tran = connection.BeginTransaction();
            var command = new SqlCommand("dbo.[SendMemberWelcomePack]", connection, tran);
            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.Add("@name", SqlDbType.NVarChar, 256);
            command.Parameters["@name"].Value = Name;

            command.Parameters.Add("@email", SqlDbType.NVarChar, 256);
            command.Parameters["@email"].Value = Email;

            command.Parameters.Add("@ConversationHandle", SqlDbType.UniqueIdentifier);
            command.Parameters["@ConversationHandle"].Direction = ParameterDirection.Output;

            command.ExecuteNonQuery();
            tran.Commit();
        }
Exemplo n.º 2
0
        static void ContentService_Created(IContentService sender, NewEventArgs<IContent> e)
        {
            if (UmbracoContext.Current == null) return;

            if (e.Entity.ContentType.Alias.InvariantEquals("ArticulateRichText")
                || e.Entity.ContentType.Alias.InvariantEquals("ArticulateMarkdown"))
            {
                if (UmbracoContext.Current.Security.CurrentUser != null)
                {
                    e.Entity.SetValue("author", UmbracoContext.Current.Security.CurrentUser.Name);
                }
                e.Entity.SetValue("publishedDate", DateTime.Now);
                e.Entity.SetValue("enableComments", 1);
            }
            else if (e.Entity.ContentType.Alias.InvariantEquals("Articulate"))
            {
                e.Entity.SetValue("theme", "VAPOR");
                e.Entity.SetValue("pageSize", 10);
                e.Entity.SetValue("categoriesUrlName", "categories");
                e.Entity.SetValue("tagsUrlName", "tags");
                e.Entity.SetValue("searchUrlName", "search");
                e.Entity.SetValue("categoriesPageName", "Categories");
                e.Entity.SetValue("tagsPageName", "Tags");
                e.Entity.SetValue("searchPageName", "Search results");
            }
        }
Exemplo n.º 3
0
 public static StylesheetProperty MakeNew(string Text, StyleSheet sheet, BusinessLogic.User user) {
     CMSNode newNode = CMSNode.MakeNew(sheet.Id, moduleObjectType, user.Id, 2, Text, Guid.NewGuid());
     SqlHelper.ExecuteNonQuery(String.Format("Insert into cmsStylesheetProperty (nodeId,stylesheetPropertyAlias,stylesheetPropertyValue) values ('{0}','{1}','')", newNode.Id, Text));
     StylesheetProperty ssp = new StylesheetProperty(newNode.Id);
     NewEventArgs e = new NewEventArgs();
     ssp.OnNew(e);
     return ssp;
 }
Exemplo n.º 4
0
 private void cmdDelete_Click(object sender, EventArgs e)
 {
     var d = new NewEventArgs();
     d.LineItemID = UserControlLineItemID;
     d.PriceChange = txtPrice.Text;
     d.QuantityChange = txtQuantity.Text;
     if (this.DeleteClick != null)
         this.DeleteClick(this, d);
 }
Exemplo n.º 5
0
        public static CreatedPackage MakeNew(string name) {
            CreatedPackage pack = new CreatedPackage();
            pack.Data = data.MakeNew(name, IOHelper.MapPath(Settings.CreatedPackagesSettings));

            NewEventArgs e = new NewEventArgs();
            pack.OnNew(e);
            
            return pack;
        }
Exemplo n.º 6
0
        private void txtPrice_LostFocus(object sender, EventArgs e)
        {
            var d = new NewEventArgs();
            d.LineItemID = UserControlLineItemID;
            d.PriceChange = txtPrice.Text;
            d.QuantityChange = txtQuantity.Text;

            if (this.TextChange != null)
                this.TextChange(sender, d);
        }
Exemplo n.º 7
0
 void MediaService_Created(IMediaService sender, NewEventArgs<IMedia> e)
 {
     // When a file is created underneath a bulletin folder, change its type to "Bulletin File"
     if (e.Entity.Parent() != null && e.Entity.Parent().ContentType.Alias == "BulletinFolder" && (e.Entity.ContentType.Alias == "File" || e.Entity.ContentType.Alias == "Image"))
     {
         e.Entity.ChangeContentType(ApplicationContext.Current.Services.ContentTypeService.GetMediaType("BulletinFile"));
     }
     // When a file is created underneath a Manual folder, change its type to "Manual File"
     if (e.Entity.Parent() != null && e.Entity.Parent().ContentType.Alias == "ManualFolder" && (e.Entity.ContentType.Alias == "File" || e.Entity.ContentType.Alias == "Image"))
     {
         e.Entity.ChangeContentType(ApplicationContext.Current.Services.ContentTypeService.GetMediaType("ManualFile"));
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Creates a new language given the culture code - ie. da-dk  (denmark)
        /// </summary>
        /// <param name="CultureCode">Culturecode of the language</param>
        public static void MakeNew(string CultureCode)
        {
            if (new CultureInfo(CultureCode) != null)
            {
                SqlHelper.ExecuteNonQuery(
                    "insert into umbracoLanguage (languageISOCode) values (@CultureCode)",
                    SqlHelper.CreateParameter("@CultureCode", CultureCode));

                InvalidateCache();

                NewEventArgs e = new NewEventArgs();
                GetByCultureCode(CultureCode).OnNew(e);
            }
        }
Exemplo n.º 9
0
    public bool Equals(NewEventArgs <TEntity>?other)
    {
        if (ReferenceEquals(null, other))
        {
            return(false);
        }

        if (ReferenceEquals(this, other))
        {
            return(true);
        }

        return(base.Equals(other) && string.Equals(Alias, other.Alias) &&
               EqualityComparer <TEntity> .Default.Equals(Parent, other.Parent) && ParentId == other.ParentId);
    }
Exemplo n.º 10
0
        public static void MakeNew(string DomainName, int RootNodeId, int LanguageId)
        {
            var domain = new UmbracoDomain(DomainName)
            {
                RootContentId = RootNodeId,
                LanguageId    = LanguageId
            };

            if (ApplicationContext.Current.Services.DomainService.Save(domain))
            {
                var e           = new NewEventArgs();
                var legacyModel = new Domain(domain);
                legacyModel.OnNew(e);
            }
        }
Exemplo n.º 11
0
		/// <summary>
		/// Create a new MemberType
		/// </summary>
		/// <param name="Text">The name of the MemberType</param>
		/// <param name="u">Creator of the MemberType</param>
		public static MemberType MakeNew(User u,string Text) 
		{		
			int ParentId= -1;
			int level = 1;
			Guid uniqueId = Guid.NewGuid();
			CMSNode n = CMSNode.MakeNew(ParentId, _objectType, u.Id, level,Text, uniqueId);

			ContentType.Create(n.Id, Text,"");
	        MemberType mt = new MemberType(n.Id);
		    mt.IconUrl = "member.gif";
            NewEventArgs e = new NewEventArgs();
            mt.OnNew(e);

            return mt; 
		}
Exemplo n.º 12
0
        /// <summary>
        /// Create a new MemberType
        /// </summary>
        /// <param name="Text">The name of the MemberType</param>
        /// <param name="u">Creator of the MemberType</param>
        public static MemberType MakeNew(User u, string Text)
        {
            int     ParentId = -1;
            int     level    = 1;
            Guid    uniqueId = Guid.NewGuid();
            CMSNode n        = CMSNode.MakeNew(ParentId, _objectType, u.Id, level, Text, uniqueId);

            ContentType.Create(n.Id, Text, "");
            MemberType   mt = new MemberType(n.Id);
            NewEventArgs e  = new NewEventArgs();

            mt.OnNew(e);

            return(mt);
        }
Exemplo n.º 13
0
        public static StyleSheet MakeNew(BusinessLogic.User user, string Text, string FileName, string Content)
        {
            // Create the umbraco node
            var newNode = CMSNode.MakeNew(-1, ModuleObjectType, user.Id, 1, Text, Guid.NewGuid());

            // Create the stylesheet data
            SqlHelper.ExecuteNonQuery(string.Format("insert into cmsStylesheet (nodeId, filename, content) values ('{0}','{1}',@content)", newNode.Id, FileName), SqlHelper.CreateParameter("@content", Content));

            // save to file to avoid file coherency issues
            var newCss = new StyleSheet(newNode.Id, false, false);
            var e      = new NewEventArgs();

            newCss.OnNew(e);

            return(newCss);
        }
 void Member_New(Member sender, NewEventArgs e)
 {
     //This is a bit of a hack to ensure that the member is approved when created since many people will be using
     // this old api to create members on the front-end and they need to be approved - which is based on whether or not 
     // the Umbraco membership provider is configured.
     var provider = Membership.Provider as UmbracoMembershipProvider;
     if (provider != null)
     {
         var approvedField = provider.ApprovedPropertyTypeAlias;
         var property = sender.getProperty(approvedField);
         if (property != null)
         {
             property.Value = 1;
         }
     }            
 }
Exemplo n.º 15
0
        internal static MediaType MakeNew(BusinessLogic.User u, string text, int parentId)
        {
            var mediaType = new Umbraco.Core.Models.MediaType(parentId)
            {
                Name = text, Alias = text, CreatorId = u.Id, Thumbnail = "folder.png", Icon = "folder.gif"
            };

            ApplicationContext.Current.Services.ContentTypeService.Save(mediaType, u.Id);
            var mt = new MediaType(mediaType.Id);

            NewEventArgs e = new NewEventArgs();

            mt.OnNew(e);

            return(mt);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Creates a new Media
        /// </summary>
        /// <param name="Name">The name of the media</param>
        /// <param name="dct">The type of the media</param>
        /// <param name="u">The user creating the media</param>
        /// <param name="ParentId">The id of the folder under which the media is created</param>
        /// <returns></returns>
        public static Media MakeNew(string Name, MediaType dct, BusinessLogic.User u, int ParentId)
        {
            Guid newId = Guid.NewGuid();
            // Updated to match level from base node
            CMSNode n = new CMSNode(ParentId);
            int newLevel = n.Level;
            newLevel++;
            CMSNode.MakeNew(ParentId, _objectType, u.Id, newLevel, Name, newId);
            Media tmp = new Media(newId);
            tmp.CreateContent(dct);

            NewEventArgs e = new NewEventArgs();
            tmp.OnNew(e);

            return tmp;
        }
Exemplo n.º 17
0
        public static DocumentType MakeNew(User u, string Text)
        {
            var contentType = new Umbraco.Core.Models.ContentType(-1)
            {
                Name = Text, Alias = Text, CreatorId = u.Id, Thumbnail = "icon-folder", Icon = "icon-folder"
            };

            ApplicationContext.Current.Services.ContentTypeService.Save(contentType, u.Id);
            var newDt = new DocumentType(contentType);

            //event
            NewEventArgs e = new NewEventArgs();

            newDt.OnNew(e);

            return(newDt);
        }
Exemplo n.º 18
0
        public static DocumentType MakeNew(User u, string Text)
        {
            int     ParentId = -1;
            int     level    = 1;
            Guid    uniqueId = Guid.NewGuid();
            CMSNode n        = MakeNew(ParentId, _objectType, u.Id, level, Text, uniqueId);

            Create(n.Id, Text, "");
            DocumentType newDt = new DocumentType(n.Id);

            //event
            NewEventArgs e = new NewEventArgs();

            newDt.OnNew(e);

            return(newDt);
        }
        void Member_New(Member sender, NewEventArgs e)
        {
            //This is a bit of a hack to ensure that the member is approved when created since many people will be using
            // this old api to create members on the front-end and they need to be approved - which is based on whether or not
            // the Umbraco membership provider is configured.
            var provider = MembershipProviderExtensions.GetMembersMembershipProvider() as UmbracoMembershipProvider;

            if (provider != null)
            {
                var approvedField = provider.ApprovedPropertyTypeAlias;
                var property      = sender.getProperty(approvedField);
                if (property != null)
                {
                    property.Value = 1;
                    sender.Save();
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Given the protected modifier the CMSNode.MakeNew method can only be accessed by
        /// derived classes &gt; who by definition knows of its own objectType.
        /// </summary>
        /// <param name="parentId">The parent CMSNode id</param>
        /// <param name="objectType">The objecttype identifier</param>
        /// <param name="userId">Creator</param>
        /// <param name="level">The level in the tree hieararchy</param>
        /// <param name="text">The name of the CMSNode</param>
        /// <param name="uniqueID">The unique identifier</param>
        /// <returns></returns>
        protected static CMSNode MakeNew(int parentId, Guid objectType, int userId, int level, string text, Guid uniqueID)
        {
            CMSNode parent;
            string  path      = "";
            int     sortOrder = 0;

            if (level > 0)
            {
                parent    = new CMSNode(parentId);
                sortOrder = parent.ChildCount + 1;
                path      = parent.Path;
            }
            else
            {
                path = "-1";
            }

            // Ruben 8/1/2007: I replace this with a parameterized version.
            // But does anyone know what the 'level++' is supposed to be doing there?
            // Nothing obviously, since it's a postfix.

            SqlHelper.ExecuteNonQuery("INSERT INTO umbracoNode(trashed, parentID, nodeObjectType, nodeUser, level, path, sortOrder, uniqueID, text, createDate) VALUES(@trashed, @parentID, @nodeObjectType, @nodeUser, @level, @path, @sortOrder, @uniqueID, @text, @createDate)",
                                      SqlHelper.CreateParameter("@trashed", 0),
                                      SqlHelper.CreateParameter("@parentID", parentId),
                                      SqlHelper.CreateParameter("@nodeObjectType", objectType),
                                      SqlHelper.CreateParameter("@nodeUser", userId),
                                      SqlHelper.CreateParameter("@level", level++),
                                      SqlHelper.CreateParameter("@path", path),
                                      SqlHelper.CreateParameter("@sortOrder", sortOrder),
                                      SqlHelper.CreateParameter("@uniqueID", uniqueID),
                                      SqlHelper.CreateParameter("@text", text),
                                      SqlHelper.CreateParameter("@createDate", DateTime.Now));

            CMSNode retVal = new CMSNode(uniqueID);

            retVal.Path = path + "," + retVal.Id.ToString();

            //event
            NewEventArgs e = new NewEventArgs();

            retVal.FireAfterNew(e);

            return(retVal);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Creates a new Media
        /// </summary>
        /// <param name="Name">The name of the media</param>
        /// <param name="dct">The type of the media</param>
        /// <param name="u">The user creating the media</param>
        /// <param name="ParentId">The id of the folder under which the media is created</param>
        /// <returns></returns>
        public static Media MakeNew(string Name, MediaType dct, BusinessLogic.User u, int ParentId)
        {
            Guid newId = Guid.NewGuid();
            // Updated to match level from base node
            CMSNode n        = new CMSNode(ParentId);
            int     newLevel = n.Level;

            newLevel++;
            CMSNode.MakeNew(ParentId, _objectType, u.Id, newLevel, Name, newId);
            Media tmp = new Media(newId);

            tmp.CreateContent(dct);

            NewEventArgs e = new NewEventArgs();

            tmp.OnNew(e);

            return(tmp);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Creates a new macro given the name
        /// </summary>
        /// <param name="Name">Userfriendly name</param>
        /// <returns>The newly macro</returns>
        public static Macro MakeNew(string Name)
        {
            var macro = new Umbraco.Core.Models.Macro
            {
                Name  = Name,
                Alias = Name.Replace(" ", String.Empty)
            };

            ApplicationContext.Current.Services.MacroService.Save(macro);

            var newMacro = new Macro(macro);

            //fire new event
            var e = new NewEventArgs();

            newMacro.OnNew(e);

            return(newMacro);
        }
Exemplo n.º 23
0
        public static Macro MakeNew(string Name)
        {
            int macroId = 0;

            // The method is synchronized
            SqlHelper.ExecuteNonQuery("INSERT INTO cmsMacro (macroAlias, macroName) values (@macroAlias, @macroName)",
                                      SqlHelper.CreateParameter("@macroAlias", Name.Replace(" ", String.Empty)),
                                      SqlHelper.CreateParameter("@macroName", Name));
            macroId = SqlHelper.ExecuteScalar <int>("SELECT MAX(id) FROM cmsMacro");

            Macro newMacro = new Macro(macroId);

            //fire new event
            NewEventArgs e = new NewEventArgs();

            newMacro.OnNew(e);

            return(newMacro);
        }
Exemplo n.º 24
0
        public static Media MakeNew(string Name, MediaType dct, BusinessLogic.User u, int ParentId)
        {
            var e = new NewEventArgs();
            OnNewing(e);
            if (e.Cancel)
            {
                return null;
            }

            var media = ApplicationContext.Current.Services.MediaService.CreateMedia(Name, ParentId, dct.Alias, u.Id);
            //The media object will only have the 'WasCancelled' flag set to 'True' if the 'Creating' event has been cancelled
            if (((Entity)media).WasCancelled)
                return null;

            ApplicationContext.Current.Services.MediaService.Save(media);
            var tmp = new Media(media);

            tmp.OnNew(e);

            return tmp;
        }
Exemplo n.º 25
0
        public static void MakeNew(string DomainName, int RootNodeId, int LanguageId)
        {
            if (Exists(DomainName.ToLower()))
            {
                throw new Exception("Domain " + DomainName + " already exists!");
            }

            //need to check if the language exists first
            if (Language.GetAllAsList().SingleOrDefault(x => x.id == LanguageId) == null)
            {
                throw new ArgumentException("No language exists for the LanguageId specified");
            }

            SqlHelper.ExecuteNonQuery("insert into umbracoDomains (domainDefaultLanguage, domainRootStructureID, domainName) values (@domainDefaultLanguage, @domainRootStructureID, @domainName)",
                                      SqlHelper.CreateParameter("@domainDefaultLanguage", LanguageId),
                                      SqlHelper.CreateParameter("@domainRootStructureID", RootNodeId),
                                      SqlHelper.CreateParameter("@domainName", DomainName.ToLower()));

            var e = new NewEventArgs();

            new Domain(DomainName).OnNew(e);
        }
Exemplo n.º 26
0
        public static Media MakeNew(string Name, MediaType dct, BusinessLogic.User u, int ParentId)
        {
            var e = new NewEventArgs();

            OnNewing(e);
            if (e.Cancel)
            {
                return(null);
            }

            var media = ApplicationContext.Current.Services.MediaService.CreateMediaWithIdentity(Name, ParentId, dct.Alias, u.Id);

            //The media object will only have the 'WasCancelled' flag set to 'True' if the 'Creating' event has been cancelled
            if (((Entity)media).WasCancelled)
            {
                return(null);
            }

            var tmp = new Media(media);

            tmp.OnNew(e);

            return(tmp);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Create a new MemberType
        /// </summary>
        /// <param name="Text">The name of the MemberType</param>
        /// <param name="u">Creator of the MemberType</param>
        public static MemberType MakeNew(User u, string Text)
        {
            var alias = helpers.Casing.SafeAliasWithForcingCheck(Text);

            //special case, if it stars with an underscore, we have to re-add it for member types
            if (Text.StartsWith("_"))
            {
                alias = "_" + alias;
            }
            var mt = new Umbraco.Core.Models.MemberType(-1)
            {
                Level = 1,
                Name  = Text,
                Icon  = "icon-user",
                Alias = alias
            };

            ApplicationContext.Current.Services.MemberTypeService.Save(mt);
            var legacy = new MemberType(mt);
            var e      = new NewEventArgs();

            legacy.OnNew(e);
            return(legacy);
        }
 void Domain_New(Domain sender, NewEventArgs e)
 {
     UmbracoHelper.ClearDomains();
 }
Exemplo n.º 29
0
        public static Member MakeNew(string Name, string LoginName, string Email, MemberType mbt, User u)
        {
            var loginName = (!String.IsNullOrEmpty(LoginName)) ? LoginName : Name;

            if (String.IsNullOrEmpty(loginName))
                throw new ArgumentException("The loginname must be different from an empty string", "loginName");

            // Test for e-mail
            if (Email != "" && Member.GetMemberFromEmail(Email) != null)
                throw new Exception(String.Format("Duplicate Email! A member with the e-mail {0} already exists", Email));
            else if (Member.GetMemberFromLoginName(loginName) != null)
                throw new Exception(String.Format("Duplicate User name! A member with the user name {0} already exists", loginName));

            Guid newId = Guid.NewGuid();

            //create the cms node first
            CMSNode newNode = MakeNew(-1, _objectType, u.Id, 1, Name, newId);

            //we need to create an empty member and set the underlying text property
            Member tmp = new Member(newId, true);
            tmp.SetText(Name);

            //create the content data for the new member
            tmp.CreateContent(mbt);

            // Create member specific data ..
            SqlHelper.ExecuteNonQuery(
                "insert into cmsMember (nodeId,Email,LoginName,Password) values (@id,@email,@loginName,'')",
                SqlHelper.CreateParameter("@id", tmp.Id),
                SqlHelper.CreateParameter("@loginName", loginName),
                SqlHelper.CreateParameter("@email", Email));

            //read the whole object from the db
            Member m = new Member(newId);

            NewEventArgs e = new NewEventArgs();

            m.OnNew(e);

            m.Save();

            return m;
        }
Exemplo n.º 30
0
        internal static MediaType MakeNew(BusinessLogic.User u, string text, int parentId)
        {
            var mediaType = new Umbraco.Core.Models.MediaType(parentId) { Name = text, Alias = text, CreatorId = u.Id, Thumbnail = "folder.png", Icon = "folder.gif" };
            ApplicationContext.Current.Services.ContentTypeService.Save(mediaType, u.Id);
            var mt = new MediaType(mediaType.Id);

            NewEventArgs e = new NewEventArgs();
            mt.OnNew(e);

            return mt;
        }
        /// <summary>
        /// ContentService_Created
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="contentEventArgs"></param>
        void ContentService_Created(IContentService sender, NewEventArgs <IContent> contentEventArgs)
        {
            try
            {
                List <AutoPopulatePropertiesModel> APP_JSONConfiguration = JsonConvert.DeserializeObject <List <AutoPopulatePropertiesModel> >(System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath(AF_AutoPopulateProperties_ConfigFile)));

                var APP_CreatedAction = APP_JSONConfiguration.Find(apfconfig => apfconfig.SectionName == "content").Actions.Find(apfsection => apfsection.ActionName == "created");

                if ((APP_CreatedAction != null) && (APP_CreatedAction.Doctypes.Where(doc => doc.DoctypeAlias == contentEventArgs.Entity.ContentType.Alias || doc.DoctypeAlias == string.Empty).Count() > 0))
                {
                    foreach (var APP_Doctype in APP_CreatedAction.Doctypes.Where(doc => doc.DoctypeAlias == contentEventArgs.Entity.ContentType.Alias || doc.DoctypeAlias == string.Empty))
                    {
                        if (APP_Doctype.Properties.Count > 0)
                        {
                            foreach (var APP_Property in APP_Doctype.Properties)
                            {
                                if (contentEventArgs.Entity.HasProperty(APP_Property.PropertyAlias))
                                {
                                    switch (APP_Property.Config.PropertyType)
                                    {
                                    case "bool":
                                        if (APP_Property.Config.DefaultValue == "true")
                                        {
                                            contentEventArgs.Entity.SetValue(APP_Property.PropertyAlias, true);
                                        }
                                        break;

                                    case "datetime":
                                        if (APP_Property.Config.DefaultValue == "now")
                                        {
                                            contentEventArgs.Entity.SetValue(APP_Property.PropertyAlias, DateTime.Now);
                                        }
                                        else
                                        {
                                            // the date value must be in this format: yyyy,mm,dd,hh,mm,ss
                                            int[] dateValue = APP_Property.Config.DefaultValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                                            if (dateValue.Length > 0)
                                            {
                                                DateTime formattedDate = new DateTime(dateValue[0], dateValue[1], dateValue[2], dateValue[3], dateValue[4], dateValue[5]);

                                                contentEventArgs.Entity.SetValue(APP_Property.PropertyAlias, formattedDate);
                                            }
                                        }
                                        break;

                                    case "string":
                                    default:
                                        contentEventArgs.Entity.SetValue(APP_Property.PropertyAlias, APP_Property.Config.DefaultValue);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 private void DocumentNew(Document document, NewEventArgs e)
 {
     _autoDocuments.SetDocumentDate(document);
 }
Exemplo n.º 33
0
 static void DomainNew(Domain sender, NewEventArgs e)
 {
     DistributedCache.Instance.RefreshDomainCache(sender);
 }
Exemplo n.º 34
0
        private Attempt <IPartialView> CreatePartialViewMacro(IPartialView partialView, PartialViewType partialViewType, string snippetName = null, int userId = 0)
        {
            string partialViewHeader;

            switch (partialViewType)
            {
            case PartialViewType.PartialView:
                partialViewHeader = PartialViewHeader;
                break;

            case PartialViewType.PartialViewMacro:
                partialViewHeader = PartialViewMacroHeader;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(partialViewType));
            }

            string partialViewContent = null;

            if (snippetName.IsNullOrWhiteSpace() == false)
            {
                //create the file
                var snippetPathAttempt = TryGetSnippetPath(snippetName);
                if (snippetPathAttempt.Success == false)
                {
                    throw new InvalidOperationException("Could not load snippet with name " + snippetName);
                }

                using (var snippetFile = new StreamReader(System.IO.File.OpenRead(snippetPathAttempt.Result)))
                {
                    var snippetContent = snippetFile.ReadToEnd().Trim();

                    //strip the @inherits if it's there
                    snippetContent = StripPartialViewHeader(snippetContent);

                    partialViewContent = $"{partialViewHeader}{Environment.NewLine}{snippetContent}";
                }
            }

            using (var scope = ScopeProvider.CreateScope())
            {
                var newEventArgs = new NewEventArgs <IPartialView>(partialView, true, partialView.Alias, -1);
                if (scope.Events.DispatchCancelable(CreatingPartialView, this, newEventArgs))
                {
                    scope.Complete();
                    return(Attempt <IPartialView> .Fail());
                }

                var repository = GetPartialViewRepository(partialViewType);
                if (partialViewContent != null)
                {
                    partialView.Content = partialViewContent;
                }
                repository.Save(partialView);

                newEventArgs.CanCancel = false;
                scope.Events.Dispatch(CreatedPartialView, this, newEventArgs);

                Audit(AuditType.Save, userId, -1, partialViewType.ToString());

                scope.Complete();
            }

            return(Attempt <IPartialView> .Succeed(partialView));
        }
Exemplo n.º 35
0
		public static Macro MakeNew(string Name) 
		{
            int macroId = 0;
            // The method is synchronized
            SqlHelper.ExecuteNonQuery("INSERT INTO cmsMacro (macroAlias, macroName) values (@macroAlias, @macroName)",
                SqlHelper.CreateParameter("@macroAlias", Name.Replace(" ", String.Empty)),
                SqlHelper.CreateParameter("@macroName", Name));
            macroId = SqlHelper.ExecuteScalar<int>("SELECT MAX(id) FROM cmsMacro");

            Macro newMacro = new Macro(macroId);
           
            //fire new event
            NewEventArgs e = new NewEventArgs();
            newMacro.OnNew(e);
            
            return newMacro;
		}
 /// <summary>
 /// Fires when a langauge is created
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 static void LanguageNew(global::umbraco.cms.businesslogic.language.Language sender, NewEventArgs e)
 {
     DistributedCache.Instance.RefreshLanguageCache(sender);
 }
Exemplo n.º 37
0
        public static DocumentType MakeNew(User u, string Text)
        {
            var contentType = new Umbraco.Core.Models.ContentType(-1) { Name = Text, Alias = Text, CreatorId = u.Id, Thumbnail = "folder.png", Icon = "folder.gif" };
            ApplicationContext.Current.Services.ContentTypeService.Save(contentType, u.Id);
            var newDt = new DocumentType(contentType);

            //event
            NewEventArgs e = new NewEventArgs();
            newDt.OnNew(e);

            return newDt;
        }
Exemplo n.º 38
0
 /// <summary>
 /// Fires when a langauge is created
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 static void LanguageNew(global::umbraco.cms.businesslogic.language.Language sender, NewEventArgs e)
 {
     DistributedCache.Instance.RefreshLanguageCache(sender);
 }
Exemplo n.º 39
0
        public static StyleSheet MakeNew(BusinessLogic.User user, string Text, string FileName, string Content)
        {

            // Create the umbraco node
            var newNode = CMSNode.MakeNew(-1, ModuleObjectType, user.Id, 1, Text, Guid.NewGuid());

            // Create the stylesheet data
            SqlHelper.ExecuteNonQuery(string.Format("insert into cmsStylesheet (nodeId, filename, content) values ('{0}','{1}',@content)", newNode.Id, FileName), SqlHelper.CreateParameter("@content", Content));

            // save to file to avoid file coherency issues
            var newCss = new StyleSheet(newNode.Id, false, false);
            var e = new NewEventArgs();
            newCss.OnNew(e);

            return newCss;
        }
Exemplo n.º 40
0
 static void PermissionNew(UserPermission sender, NewEventArgs e)
 {
     InvalidateCacheForPermissionsChange(sender);
 }
Exemplo n.º 41
0
 void Domain_New(Domain sender, NewEventArgs e)
 {
     Compatibility.Domain.InvalidateCache();
 }
Exemplo n.º 42
0
        public void ProcessMemberCreated(IMemberService sender, NewEventArgs <IMember> args)
        {
            var member = args.Entity;

            _intranetMemberGroupService.AssignDefaultMemberGroup(member.Id);
        }
Exemplo n.º 43
0
 void Domain_New(Domain sender, NewEventArgs e)
 {
     UmbracoHelper.ClearDomains();
 }
Exemplo n.º 44
0
 void MemberService_Created(IMemberService sender, NewEventArgs<IMember> e)
 {
   
 }
Exemplo n.º 45
0
        public static void MakeNew(string DomainName, int RootNodeId, int LanguageId)
        {
            if (Exists(DomainName.ToLower()))
                throw new Exception("Domain " + DomainName + " already exists!");
            
            //need to check if the language exists first
            if (Language.GetAllAsList().SingleOrDefault(x => x.id == LanguageId) == null)
            {
                throw new ArgumentException("No language exists for the LanguageId specified");
            }
                
            SqlHelper.ExecuteNonQuery("insert into umbracoDomains (domainDefaultLanguage, domainRootStructureID, domainName) values (@domainDefaultLanguage, @domainRootStructureID, @domainName)",
                                      SqlHelper.CreateParameter("@domainDefaultLanguage", LanguageId),
                                      SqlHelper.CreateParameter("@domainRootStructureID", RootNodeId),
                                      SqlHelper.CreateParameter("@domainName", DomainName.ToLower()));

            var e = new NewEventArgs();
            new Domain(DomainName).OnNew(e);
        }
Exemplo n.º 46
0
 protected virtual void OnNew(NewEventArgs e);
Exemplo n.º 47
0
 private void Document_New(Document sender, NewEventArgs e)
 {
     sender.getProperty("umbracoUrlName").Value = "your_urlname_here";
     sender.Save();
 }
Exemplo n.º 48
0
        public static Document MakeNew(string Name, DocumentType dct, User u, int ParentId)
        {
            //allows you to cancel a document before anything goes to the DB
            var newingArgs = new DocumentNewingEventArgs()
                                 {
                                     Text = Name,
                                     DocumentType = dct,
                                     User = u,
                                     ParentId = ParentId
                                 };
            Document.OnNewing(newingArgs);
            if (newingArgs.Cancel)
            {
                return null;
            }

            //Create a new IContent object based on the passed in DocumentType's alias, set the name and save it
            IContent content = ApplicationContext.Current.Services.ContentService.CreateContentWithIdentity(Name, ParentId, dct.Alias, u.Id);
            //The content object will only have the 'WasCancelled' flag set to 'True' if the 'Creating' event has been cancelled, so we return null.
            if (((Entity)content).WasCancelled)
                return null;

            //read the whole object from the db
            Document d = new Document(content);

            //event
            NewEventArgs e = new NewEventArgs();
            d.OnNew(e);

            // Log
            LogHelper.Info<Document>(string.Format("New document {0}", d.Id));

            // Run Handler				
            BusinessLogic.Actions.Action.RunActionHandlers(d, ActionNew.Instance);

            // Save doc
            d.Save();

            return d;
        }
Exemplo n.º 49
0
        static void DocumentNew(Document sender, NewEventArgs e)
        {
            #region Forum Topic Events
            if (sender.ContentType.Alias == "CLC-Discussion")
            {
                if (sender.Parent != null)  //If top of tree, something is wrong.  Skip.
                {
                    try
                    {
                        var postDate = DateTime.Now;

                        string[] strArray = { postDate.Year.ToString(), postDate.Month.ToString(), postDate.Day.ToString() };
                        if (strArray.Length == 3)
                        {
                            var topPostLevel = new Node(sender.Parent.Id);
                            //Traverse up the tree to find a forum category since we are likely in a Date Folder path
                            while (topPostLevel != null && topPostLevel.NodeTypeAlias != "CLC-Membergroup")
                            {
                                topPostLevel = topPostLevel.Parent != null ? new Node(topPostLevel.Parent.Id) : null;
                            }

                            if (topPostLevel != null)
                            {
                                Document document;
                                Node     folderNode = null;
                                foreach (Node ni in topPostLevel.Children)
                                {
                                    if (ni.Name == strArray[0])
                                    {
                                        folderNode = new Node(ni.Id);
                                        document   = new Document(ni.Id);
                                        break;
                                    }
                                }
                                if (folderNode == null)
                                {
                                    document = Document.MakeNew(strArray[0], DocumentType.GetByAlias("ForumDateFolder"), sender.User, topPostLevel.Id);
                                    document.Publish(sender.User);
                                    library.UpdateDocumentCache(document.Id);
                                    folderNode = new Node(document.Id);
                                }

                                Node folderNode2 = null;
                                foreach (Node ni in folderNode.Children)
                                {
                                    if (ni.Name == strArray[1])
                                    {
                                        folderNode2 = new Node(ni.Id);
                                        break;
                                    }
                                }
                                if (folderNode2 == null)
                                {
                                    var document2 = Document.MakeNew(strArray[1], DocumentType.GetByAlias("ForumDateFolder"), sender.User, folderNode.Id);
                                    document2.Publish(sender.User);
                                    library.UpdateDocumentCache(document2.Id);
                                    folderNode2 = new Node(document2.Id);
                                }

                                if (sender.Parent.Id != folderNode2.Id)
                                {
                                    sender.Move(folderNode2.Id);
                                }
                            }
                            else
                            {
                                Log.Add(LogTypes.Debug, sender.User, sender.Id, string.Format("Unable to determine top category for forum topic {0} while attempting to move to new Topic", sender.Id));
                            }
                        }
                    }
                    catch (Exception exp)
                    {
                        Log.Add(LogTypes.Debug, sender.User, sender.Id, string.Format("Error while Finding Forum Folders for Forum Topic {0} while trying to move to new Topic.  Error: {1}", sender.Id, exp.Message));
                    }

                    library.RefreshContent();
                }
            }
            #endregion

            #region Category

            if (sender.ContentType.Alias == "CLC-Membergroup" && sender.ParentId != -20)
            {
                sender.getProperty("forumCategoryParentID").Value = sender.ParentId;
            }

            #endregion
        }
Exemplo n.º 50
0
 private void MemberService_Created(IMemberService sender, NewEventArgs <IMember> e)
 {
     // Always add user to "Main Client" group
     sender.AssignRole(e.Entity.Username, "Main Client");
     sender.Save(e.Entity);
 }
Exemplo n.º 51
0
        private static Template MakeNew(string name, BusinessLogic.User u, Template master, string design)
        {

            // CMSNode MakeNew(int parentId, Guid objectType, int userId, int level, string text, Guid uniqueID)
            CMSNode n = CMSNode.MakeNew(-1, _objectType, u.Id, 1, name, Guid.NewGuid());

            //ensure unique alias 
            name = helpers.Casing.SafeAlias(name);
            if (GetByAlias(name) != null)
                name = EnsureUniqueAlias(name, 1);
            name = name.Replace("/", ".").Replace("\\", "");

            if (name.Length > 100)
                name = name.Substring(0, 95) + "...";

          
            SqlHelper.ExecuteNonQuery("INSERT INTO cmsTemplate (NodeId, Alias, design, master) VALUES (@nodeId, @alias, @design, @master)",
                                      SqlHelper.CreateParameter("@nodeId", n.Id),
                                      SqlHelper.CreateParameter("@alias", name),
                                      SqlHelper.CreateParameter("@design", ' '),
                                      SqlHelper.CreateParameter("@master", DBNull.Value));

            Template t = new Template(n.Id);
            NewEventArgs e = new NewEventArgs();
            t.OnNew(e);

            if (master != null)
                t.MasterTemplate = master.Id;

			switch (DetermineRenderingEngine(t, design))
			{
				case RenderingEngine.Mvc:
					ViewHelper.CreateViewFile(t);
					break;
				case RenderingEngine.WebForms:
					MasterPageHelper.CreateMasterPage(t);
					break;
			}

			//if a design is supplied ensure it is updated.
			if (!design.IsNullOrWhiteSpace())
			{
				t.ImportDesign(design);
			}

            return t;
        }
Exemplo n.º 52
0
        public static Template MakeNew(string Name, BusinessLogic.User u)
        {
            //ensure unique alias
            if (GetByAlias(Name) != null)
                Name = EnsureUniqueAlias(Name, 1);

            // CMSNode MakeNew(int parentId, Guid objectType, int userId, int level, string text, Guid uniqueID)
            CMSNode n = CMSNode.MakeNew(-1, _objectType, u.Id, 1, Name, Guid.NewGuid());
            Name = Name.Replace("/", ".").Replace("\\", "");

            if (Name.Length > 100)
                Name = Name.Substring(0, 95) + "...";

            SqlHelper.ExecuteNonQuery("INSERT INTO cmsTemplate (NodeId, Alias, design, master) VALUES (@nodeId, @alias, @design, @master)",
                                      SqlHelper.CreateParameter("@nodeId", n.Id),
                                      SqlHelper.CreateParameter("@alias", Name),
                                      SqlHelper.CreateParameter("@design", ' '),
                                      SqlHelper.CreateParameter("@master", DBNull.Value));

            Template t = new Template(n.Id);
            NewEventArgs e = new NewEventArgs();
            t.OnNew(e);

            return t;
        }
Exemplo n.º 53
0
        public static DocumentType MakeNew(User u, string Text)
        {
            int ParentId = -1;
            int level = 1;
            Guid uniqueId = Guid.NewGuid();
            CMSNode n = MakeNew(ParentId, _objectType, u.Id, level, Text, uniqueId);

            Create(n.Id, Text, "");
            DocumentType newDt = new DocumentType(n.Id);

            //event
            NewEventArgs e = new NewEventArgs();
            newDt.OnNew(e);

            return newDt;
        }
 public virtual void Created(IContentService contentService, NewEventArgs <IContent> args)
 {
 }
 static void DomainNew(Domain sender, NewEventArgs e)
 {
     DistributedCache.Instance.RefreshDomainCache(sender);
 }
Exemplo n.º 56
0
        static void DocumentNew(Document sender, NewEventArgs e)
        {
            #region Forum Topic Events
            if (sender.ContentType.Alias == "ForumTopic")
            {
                if (sender.Parent != null)  //If top of tree, something is wrong.  Skip.
                {
                    try
                    {
                        var postDate = DateTime.Now;

                            string[] strArray = { postDate.Year.ToString(), postDate.Month.ToString(), postDate.Day.ToString() };
                            if (strArray.Length == 3)
                            {
                                var topPostLevel = new Node(sender.Parent.Id);
                                //Traverse up the tree to find a forum category since we are likely in a Date Folder path
                                while (topPostLevel != null && topPostLevel.NodeTypeAlias != "ForumCategory")
                                {
                                    topPostLevel = topPostLevel.Parent != null ? new Node(topPostLevel.Parent.Id) : null;
                                }

                                if (topPostLevel != null)
                                {
                                    Document document;
                                    Node folderNode = null;
                                    foreach (Node ni in topPostLevel.Children)
                                    {
                                        if (ni.Name == strArray[0])
                                        {
                                            folderNode = new Node(ni.Id);
                                            document = new Document(ni.Id);
                                            break;
                                        }
                                    }
                                    if (folderNode == null)
                                    {
                                        document = Document.MakeNew(strArray[0], DocumentType.GetByAlias("ForumDateFolder"), sender.User, topPostLevel.Id);
                                        document.Publish(sender.User);
                                        library.UpdateDocumentCache(document.Id);
                                        folderNode = new Node(document.Id);
                                    }

                                    Node folderNode2 = null;
                                    foreach (Node ni in folderNode.Children)
                                    {
                                        if (ni.Name == strArray[1])
                                        {
                                            folderNode2 = new Node(ni.Id);
                                            break;
                                        }
                                    }
                                    if (folderNode2 == null)
                                    {
                                        var document2 = Document.MakeNew(strArray[1], DocumentType.GetByAlias("ForumDateFolder"), sender.User, folderNode.Id);
                                        document2.Publish(sender.User);
                                        library.UpdateDocumentCache(document2.Id);
                                        folderNode2 = new Node(document2.Id);
                                    }

                                    if (sender.Parent.Id != folderNode2.Id)
                                    {
                                        sender.Move(folderNode2.Id);
                                    }
                                }
                                else
                                {
                                    Log.Add(LogTypes.Debug, sender.User, sender.Id, string.Format("Unable to determine top category for forum topic {0} while attempting to move to new Topic", sender.Id));
                                }

                            }
                    }
                    catch (Exception exp)
                    {
                        Log.Add(LogTypes.Debug, sender.User, sender.Id, string.Format("Error while Finding Forum Folders for Forum Topic {0} while trying to move to new Topic.  Error: {1}", sender.Id, exp.Message));
                    }

                    library.RefreshContent();
                }
            }
            #endregion

            #region Category

            if (sender.ContentType.Alias == "ForumCategory" && sender.ParentId != -20)
            {
                sender.getProperty("forumCategoryParentID").Value = sender.ParentId;
            }

            #endregion
        }
 static void PermissionNew(UserPermission sender, NewEventArgs e)
 {
     InvalidateCacheForPermissionsChange(sender);
 }
Exemplo n.º 58
0
 private static void OnNew(UserPermission permission, NewEventArgs args)
 {
     if (New != null)
     {
         New(permission, args);
     }
 }
Exemplo n.º 59
0
 protected virtual void OnNew(NewEventArgs e) {
     if (New != null)
         New(this, e);
 }
Exemplo n.º 60
0
 public static void OnCreated(IContentService sender, NewEventArgs <IContent> args)
 {
     RemoveItemsFromCache();
 }