Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • marthin 87 posts 106 karma points
    Sep 09, 2010 @ 14:41
    marthin
    0

    EventHandler problem

    Hi,

     

    im trying to attach the following to umbraco:

    namespace Ecommerce.EventHandlers
    {
        public class DomainHandler : ApplicationBase
        {
            public DomainHandler()
            {
                Domain.BeforeSave += new Domain.SaveEventHandler(RegisterDomain2Product);
            }

            public void RegisterDomain2Product(Domain dom, umbraco.cms.businesslogic.SaveEventArgs e)
            {
                Log.Add(LogTypes.Custom, dom.Id, "Saving domain");

                new DataHelpers.DomainHelpers.CreateRelation(dom);

            }
        }

     

       public class CreateRelation
        {
            private ISqlHelper sqlHelper;

            //this must be used by super-admins since they dont belong to a company
            public CreateRelation(Domain dom)
            {
                try
                {
                    var SQL = sqlHelper.ExecuteNonQuery("INSERT INTO eCommerceCompanies2Domains VALUES(@companyId, @domainId)", sqlHelper.CreateParameter("@companyId", 2), sqlHelper.CreateParameter("@domainId", 5));
                }
                catch (Exception e)
                {
                    Log.Add(LogTypes.Custom, 1, "Failed to insert into database");
                }
     
            }
        }

    }

    So what im trying to do here is to connect a new Domain to a Company in a db table

    But this event dosnt fire?

  • marthin 87 posts 106 karma points
    Sep 13, 2010 @ 09:10
    marthin
    0

    Has any on else had any problems with the Domain.AfterSave event in v4.0.3?

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Sep 13, 2010 @ 09:52
    Richard Soeteman
    0

    Hi,

    Did you try to set a breakpoint and did it got hit? Another question did you use the app_code folder to store your class? I have seen issues with events and the use of the app_code folder instead of compiling a dll.

    Cheers,

    Richard 

  • marthin 87 posts 106 karma points
    Sep 13, 2010 @ 10:43
    marthin
    0

    Hi Richard,

     

    I use a dll file so I dont belive that to be the problem.

    For now, iv changed the event to a Domain.New and this seems to work. Not sure why though =)

Please Sign in or register to post replies

Write your reply to:

Draft