Author Topic: WDE 8.5 - Get Interaction ID or all message properties  (Read 5615 times)

Offline fabus

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
WDE 8.5 - Get Interaction ID or all message properties
« on: October 05, 2015, 11:52:47 AM »
Hello,

I'm trying to modify InteractionExtensionSample, to display email interaction ID after clicked on "Button" or it would be perfect id I can get subject, from, to and body directly from items in red border.

[img width=640 height=451]http://s17.postimg.org/fezzhimzj/2015_10_05_13h36_41.png[/img]

What I already done is:
[code]
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            IInteractionEmail email = container.Resolve<IInteractionEmail>();
            MessageBox.Show(email.InteractionId);
        }
[/code]

But result is empty.

Can somebody help to find me a way to get this data? Further I would like to save all data to text file on disk.

Best regards
Fabian

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2752
  • Karma: 44
Re: WDE 8.5 - Get Interaction ID or all message properties
« Reply #1 on: October 05, 2015, 12:10:35 PM »
Is IInteraction part of your ViewModel?

Offline fabus

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: WDE 8.5 - Get Interaction ID or all message properties
« Reply #2 on: October 05, 2015, 12:15:50 PM »
Nope I only add IInteractionEmail in Button_Click action. How to add it, because I'm not sure what you exactly mean?

Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 126
  • Karma: 13
Re: WDE 8.5 - Get Interaction ID or all message properties
« Reply #3 on: October 05, 2015, 04:09:16 PM »
In the InteractionExtensionSample you have the Case in MySamplePresentationModel.cs, so you need to set that.

In the MySampleView.xaml.cs modify the Create method to look like this:

[code]
public void Create()
{
            IDictionary<string, object> contextDictionary = Context as IDictionary<string, object>;
                object caseView;
                contextDictionary.TryGetValue("CaseView", out caseView);
                object caseObject;
                contextDictionary.TryGetValue("Case", out caseObject);
                ICase @case = caseObject as ICase;

                if (@case != null)
                {
                    Model.Case = @case;
                }
}[/code]

Then in your button press method you can get the Case and from the Case get the Interaction, check what type of interaction it is and then get the properties of that interaction.

[code]
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
//Model.ResetCounter();
            IInteraction interaction = Model.Case.MainInteraction;
            if(interaction is IInteractionInboundEmail)
            {
                IInteractionInboundEmail email = interaction as IInteractionInboundEmail;
                string subject = email.EntrepriseEmailInteractionCurrent.Subject;
                string from = email.EntrepriseEmailInteractionCurrent.From;
                string to = "";
                foreach(string s in email.EntrepriseEmailInteractionCurrent.To)
                {
                    to += " " + s;
                }
                to = to.Trim();
                string text = email.EntrepriseEmailInteractionCurrent.MessageText;
                MessageBox.Show(email.InteractionId + " Subject: " + subject);
            }
}
[/code]

Offline fabus

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: WDE 8.5 - Get Interaction ID or all message properties
« Reply #4 on: October 06, 2015, 07:03:38 AM »
Thanks a lot for your help ;) Of course it works :D

Offline fabus

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: WDE 8.5 - Get Interaction ID or all message properties
« Reply #5 on: October 06, 2015, 09:59:35 AM »
Now I have another problem, because I cannot find content of attachments. It looks that content is empty "null". Is there any other option to save all attachments to disk?

[code]Genesyslab.Desktop.Modules.Core.Model.Interactions.IInteraction interaction = Model.Case.MainInteraction;
           
            if (interaction is IInteractionInboundEmail)
            {
                IInteractionInboundEmail email = interaction as IInteractionInboundEmail;
               
                foreach (var attachment in email.EntrepriseEmailAttachments)
                {
                    //Save to disk
                }[/code]

attachment values during debbuging
[img width=640 height=132]http://i57.tinypic.com/jahyxi.jpg[/img]

Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 126
  • Karma: 13
Re: WDE 8.5 - Get Interaction ID or all message properties
« Reply #6 on: October 08, 2015, 02:58:56 PM »
[quote author=fabus link=topic=9139.msg41102#msg41102 date=1444125575]
Now I have another problem, because I cannot find content of attachments. It looks that content is empty "null". Is there any other option to save all attachments to disk?

[code]Genesyslab.Desktop.Modules.Core.Model.Interactions.IInteraction interaction = Model.Case.MainInteraction;
           
            if (interaction is IInteractionInboundEmail)
            {
                IInteractionInboundEmail email = interaction as IInteractionInboundEmail;
               
                foreach (var attachment in email.EntrepriseEmailAttachments)
                {
                    //Save to disk
                }[/code]

attachment values during debbuging
[img width=640 height=132]http://i57.tinypic.com/jahyxi.jpg[/img]
[/quote]

One way to get the Attachments if like this:

[code]                ICollection<IAttachment> attachments = email.EntrepriseEmailAttachments;
                foreach(IAttachment attachment in attachments)
                {
                    String id = attachment.Id;
                    String name = attachment.Name;
                }[/code]

But for performance reasons the content of the attachments is not retrieved, to get the content you would need to use something like:

IContactService.GetAttachment
or
Drop down to Platform SDK level and use the ContactServer RequestGetInteractionContent request.

But I have not done either of those before.

Why do you want to save the attachments locally?

Offline fabus

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: WDE 8.5 - Get Interaction ID or all message properties
« Reply #7 on: October 12, 2015, 12:04:42 PM »
The reason is that in some cases I need to export email to eml file which could be opened in Outlook/Thunderbird etc...

Could you give me some tips how to use IContactService? I cannot found it in API refference. Is there any document regarding Enterprise SDK 8.5 framework?

Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 126
  • Karma: 13
Re: WDE 8.5 - Get Interaction ID or all message properties
« Reply #8 on: October 15, 2015, 02:23:01 PM »
I haven't used it before either, but here is what I just put together..

[code]        private IAttachment GetAttachment(string attachmentId, DataSourceType dataSourceType)
        {
            Genesyslab.Enterprise.Services.IContactService contactService = container.Resolve<IEnterpriseServiceProvider>().Resolve<Genesyslab.Enterprise.Services.IContactService>("contactService");
            Genesyslab.Desktop.Modules.Core.SDK.Protocol.IChannelManager channelManager = container.Resolve<Genesyslab.Desktop.Modules.Core.SDK.Protocol.IChannelManager>();
            IClientChannel channel = channelManager.Register(container.Resolve<Genesyslab.Desktop.Modules.Core.SDK.Contact.IContactService>().UCSApp, "My@ContactService");
            if (channel != null && channel.State == ChannelState.Opened)
            {
                IAttachment attachment = contactService.GetAttachment(channel, attachmentId, dataSourceType, 20000);
                return attachment;
            }
            else
            {
                return (IAttachment)null;
            }

        }[/code]