Skip to main content
deleted 3 characters in body
Source Link
Marko Milic
  • 8.9k
  • 3
  • 24
  • 60

I would like to note I am using Core Services through a console application without any issues. Are there any other ways to consume Core Services through the Event System (class library type) or is something else causing this error.?
Well, as you advised I was started to use TOM.NET API for this purpose but can't figure out why code below doesn't work. Trying to change component metadata date fields...

I have seen the changes in logs but not in tridionTridion component. Other Eventsevents triggered and worked as intended. Old one event system uninstall as suggested. Network Service is only one impersonate user visible through SDL Tridion Management console application.

I would like to note I am using Core Services through a console application without any issues. Are there any other ways to consume Core Services through the Event System (class library type) or is something else causing this error.
Well as you advised I was started to use TOM.NET API for this purpose but can't figure out why code below doesn't work. Trying to change component metadata date fields...

I have seen the changes in logs but not in tridion component. Other Events triggered and worked as intended. Old one event system uninstall as suggested. Network Service is only one impersonate user visible through SDL Tridion Management console application.

I would like to note I am using Core Services through a console application without any issues. Are there any other ways to consume Core Services through the Event System (class library type) or is something else causing this error?
Well, as you advised I was started to use TOM.NET API for this purpose but can't figure out why code below doesn't work. Trying to change component metadata date fields...

I have seen the changes in logs but not in Tridion component. Other events triggered and worked as intended. Old event system uninstall as suggested. Network Service is only one impersonate user visible through SDL Tridion Management console application.

Added event sytem code with Tom.NET example
Source Link

I would like to note I am using Core Services through a console application without any issues. Are there any other ways to consume Core Services through the Event System (class library type) or is something else causing this error.
Well as you advised I was started to use TOM.NET API for this purpose but can't figure out why code below doesn't work. Trying to change component metadata date fields...

    public class Events:TcmExtension
{
    public Events()
    {
        ImplementedEvents();
    }
    private void ImplementedEvents()
    {
        //Here should be subscription for used events
        EventSystem.Subscribe<Component, CheckInEventArgs>(OnComponentCheckedPre, EventPhases.Initiated);
        EventSystem.Subscribe<Component, PublishEventArgs>(ComponentPublished, EventPhases.Processed);
        EventSystem.Subscribe<StructureGroup, PublishEventArgs>(StructureGroupPublished, EventPhases.Processed);
      
    }
    /// <summary>
    /// Edit news metadata DateTime values and remove checked button for modify component metadata from content in case if editor checked in this box
    /// </summary>
    /// <param name="component"></param>
    /// <param name="arg"></param>
    /// <param name="phase"></param>
    public void OnComponentCheckedPre(Component component, CheckInEventArgs arg, EventPhases phase)
    {

        if (component.Schema.Title.ToLower().Equals("ks News Private") || component.Schema.Title.ToLower().Equals("ks News Business"))
        {
            EditNewsComponent(component);
        }
    }

    private void EditNewsComponent(Component component)
    {
        try
        {
           
            ItemFields componentContentItemFields = new ItemFields(component.Content, component.Schema);
            ItemFields componentMetadataItemFields = new ItemFields(component.Metadata, component.MetadataSchema);
            
            WriteEventLog("comp metadata xml elements before :" + componentMetadataItemFields.ToXml().InnerXml );

            if (componentMetadataItemFields.Contains("Created"))
            {
                DateField createdMetaField = (DateField)componentMetadataItemFields["Created"];
                if (createdMetaField.Value == DateTime.MinValue)
                {
                    createdMetaField.Value = component.RevisionDate;
                }
            }
            
            if(componentMetadataItemFields.Contains("Modified"))
            { 
                DateField modifiedMetaField = (DateField)componentMetadataItemFields["Modified"];
                if (modifiedMetaField.Value == DateTime.MinValue)
                {
                    modifiedMetaField.Value = DateTime.Now;
                }
            }
            
            if (componentContentItemFields.Contains("SettModified"))
            {
                DateField modifiedMetaField = (DateField)componentMetadataItemFields["Modified"];
                modifiedMetaField.Value = DateTime.Now;
            }
           
            if (componentMetadataItemFields.Contains("ValidTo"))
            {
                DateField validToMetaField = (DateField)componentMetadataItemFields["ValidTo"];
                if (validToMetaField.Value == DateTime.MinValue)
                {
                    validToMetaField.Value = DateTime.Now.AddYears(100);
                }
            }
            WriteEventLog("metadata item fields value after checking :" + componentMetadataItemFields.ToXml().InnerXml);

            ((TextField)componentContentItemFields["Ingress"]).Value = "ingress test event system";
            component.Content = componentContentItemFields.ToXml();               
            
           // component.Content.InnerXml = componentContentItemFields.ToXml().InnerXml;
            WriteEventLog("component content  after to xml: " + component.Content.InnerXml);
                     
            component.Metadata= componentMetadataItemFields.ToXml();
           
            WriteEventLog("component metadata  xml: " + component.Metadata.InnerXml);
            //Changes visible in log files. Not in Tridion
        }
        catch (Exception ex)
        {
            WriteEventLog("Unable to edit FIKS component " + component.Id + ". Error:" + ex.Message);
            
        }
    }

I have seen the changes in logs but not in tridion component. Other Events triggered and worked as intended. Old one event system uninstall as suggested. Network Service is only one impersonate user visible through SDL Tridion Management console application.

I would like to note I am using Core Services through a console application without any issues. Are there any other ways to consume Core Services through the Event System (class library type) or is something else causing this error.

I would like to note I am using Core Services through a console application without any issues. Are there any other ways to consume Core Services through the Event System (class library type) or is something else causing this error.
Well as you advised I was started to use TOM.NET API for this purpose but can't figure out why code below doesn't work. Trying to change component metadata date fields...

    public class Events:TcmExtension
{
    public Events()
    {
        ImplementedEvents();
    }
    private void ImplementedEvents()
    {
        //Here should be subscription for used events
        EventSystem.Subscribe<Component, CheckInEventArgs>(OnComponentCheckedPre, EventPhases.Initiated);
        EventSystem.Subscribe<Component, PublishEventArgs>(ComponentPublished, EventPhases.Processed);
        EventSystem.Subscribe<StructureGroup, PublishEventArgs>(StructureGroupPublished, EventPhases.Processed);
      
    }
    /// <summary>
    /// Edit news metadata DateTime values and remove checked button for modify component metadata from content in case if editor checked in this box
    /// </summary>
    /// <param name="component"></param>
    /// <param name="arg"></param>
    /// <param name="phase"></param>
    public void OnComponentCheckedPre(Component component, CheckInEventArgs arg, EventPhases phase)
    {

        if (component.Schema.Title.ToLower().Equals("ks News Private") || component.Schema.Title.ToLower().Equals("ks News Business"))
        {
            EditNewsComponent(component);
        }
    }

    private void EditNewsComponent(Component component)
    {
        try
        {
           
            ItemFields componentContentItemFields = new ItemFields(component.Content, component.Schema);
            ItemFields componentMetadataItemFields = new ItemFields(component.Metadata, component.MetadataSchema);
            
            WriteEventLog("comp metadata xml elements before :" + componentMetadataItemFields.ToXml().InnerXml );

            if (componentMetadataItemFields.Contains("Created"))
            {
                DateField createdMetaField = (DateField)componentMetadataItemFields["Created"];
                if (createdMetaField.Value == DateTime.MinValue)
                {
                    createdMetaField.Value = component.RevisionDate;
                }
            }
            
            if(componentMetadataItemFields.Contains("Modified"))
            { 
                DateField modifiedMetaField = (DateField)componentMetadataItemFields["Modified"];
                if (modifiedMetaField.Value == DateTime.MinValue)
                {
                    modifiedMetaField.Value = DateTime.Now;
                }
            }
            
            if (componentContentItemFields.Contains("SettModified"))
            {
                DateField modifiedMetaField = (DateField)componentMetadataItemFields["Modified"];
                modifiedMetaField.Value = DateTime.Now;
            }
           
            if (componentMetadataItemFields.Contains("ValidTo"))
            {
                DateField validToMetaField = (DateField)componentMetadataItemFields["ValidTo"];
                if (validToMetaField.Value == DateTime.MinValue)
                {
                    validToMetaField.Value = DateTime.Now.AddYears(100);
                }
            }
            WriteEventLog("metadata item fields value after checking :" + componentMetadataItemFields.ToXml().InnerXml);

            ((TextField)componentContentItemFields["Ingress"]).Value = "ingress test event system";
            component.Content = componentContentItemFields.ToXml();               
            
           // component.Content.InnerXml = componentContentItemFields.ToXml().InnerXml;
            WriteEventLog("component content  after to xml: " + component.Content.InnerXml);
                     
            component.Metadata= componentMetadataItemFields.ToXml();
           
            WriteEventLog("component metadata  xml: " + component.Metadata.InnerXml);
            //Changes visible in log files. Not in Tridion
        }
        catch (Exception ex)
        {
            WriteEventLog("Unable to edit FIKS component " + component.Id + ". Error:" + ex.Message);
            
        }
    }

I have seen the changes in logs but not in tridion component. Other Events triggered and worked as intended. Old one event system uninstall as suggested. Network Service is only one impersonate user visible through SDL Tridion Management console application.

Tweeted twitter.com/#!/StackTridion/status/324262773678809088
minor formatting updates, grammar
Source Link
Glenn Stevens
  • 1.9k
  • 2
  • 18
  • 33

I am trying to consume Core serviceServices through event systemthe Event System. The Event systemSystem is a Class library as expected. Added was app.config with

I added the content nodes from Tridion.ContentManager.CoreService.Client.dll.config to app.config. No matter which endpoint I am tryingtry to use I always get an error such as the following (which happens when trying to initialize SessionAwareCoreServiceClient):

Could not find endpoint element with name "" and contract

That happens when trying to initialize SessionAwareCoreServiceClient

I would like to note that I am using core serviceCore Services through a console application without any kind of issues. Does existAre there any other wayways to consume Core serviceServices through the Event systemSystem (class library type) or is something else cause ancausing this error. I know it is hard to say but help appreciated anyway...

I am trying to consume Core service through event system. Event system is Class library as expected. Added was app.config with content nodes from Tridion.ContentManager.CoreService.Client.dll.config. No matter which endpoint I am trying to use always get an error

Could not find endpoint element with name "" and contract

That happens when trying to initialize SessionAwareCoreServiceClient

I would like to note that I am using core service through console application without any kind of issues. Does exist any other way to consume Core service through Event system (class library type) or something else cause an error. I know it is hard to say but help appreciated anyway...

I am trying to consume Core Services through the Event System. The Event System is a Class library as expected.

I added the content nodes from Tridion.ContentManager.CoreService.Client.dll.config to app.config. No matter which endpoint I am try to use I always get an error such as the following (which happens when trying to initialize SessionAwareCoreServiceClient):

Could not find endpoint element with name "" and contract

I would like to note I am using Core Services through a console application without any issues. Are there any other ways to consume Core Services through the Event System (class library type) or is something else causing this error.

Source Link
Loading