Author Topic: mutimedia  (Read 6912 times)

kay

  • Guest
mutimedia
« on: October 12, 2009, 05:15:32 PM »
hello
   
    When i develop the part of e-mail in mutimedia with the language VC#, i meet a problem that i don't know how to get the test of email?  can you tell me how i can get the email text in what interface ?

    Thank you!

Marked as best answer by on Yesterday at 06:05:55 AM

Offline YevgeniyP

  • Jr. Member
  • **
  • Posts: 70
  • Karma: 0
Re: mutimedia
« Reply #1 on: October 13, 2009, 05:29:30 PM »
  • Undo Best Answer
  • You should use Platform SDK for .Net. There is a special part of it to work with UCS (Universal Contact Server).

    kay

    • Guest
    mutimedia development
    « Reply #2 on: October 22, 2009, 02:24:48 PM »
    hi
       Can you give me a instruction in detail? Now I use [b][i]Genesyslab.Platform.contacts.Protocals [/i] [/b] to connect to contact server,but I met a problem and the erroe message is  [b] [i]exception occured during channel opening[/i].[/b].Thank you very much!

    Alex R

    • Guest
    Re: mutimedia
    « Reply #3 on: October 27, 2009, 05:16:50 PM »
    You may get this exception in a lot of cases. Do you use loadbalancer to get the host and port of UCS? In case you enter rhis information manually you may connect to the wrong port of UCS. For example you have to enter the port number from "ports/ucsapi" option to connect to UCS from the Web.

    Alex R

    • Guest
    Re: mutimedia
    « Reply #4 on: October 27, 2009, 05:26:22 PM »
    Below is a sniplet of my code I am using to get access from the Web to the UCS. You may use it as an example with some modifications:
    [code]
       protected void Search_onClick()
       {

           try
           {
               Uri ucsURI = new Uri("tcp:" + strHost + ":" + iPort.ToString());
               Endpoint ucsEndPoint = new Endpoint(ucsURI);

               ucsp = new UniversalContactServerProtocol(ucsEndPoint);
               ucsp.EnableLogging(new TraceLogger(TraceLogger.LevelDebug));
               ucsp.Opened += new EventHandler(conn_Opened);
               ucsp.Closed += new EventHandler(conn_Closed);
               ucsp.Error += new EventHandler(conn_Error);
               ucsp.ClientName = "YourClientNameHere";
               ucsp.Open();

               IMessage msg = ucsp.Request(CreateGetContacts(true));
               if (msg != null && msg.GetType() == typeof(EventGetContacts))
               {
                   EventGetContacts eventGC = msg as EventGetContacts;
                   ContactDataList cdl = eventGC.ContactData;
                   if (cdl != null && (int)eventGC.CurrentCount > 0)
                   {
                       Contact contact = cdl.Get(0);
                       strContactID = contact.Id;

                       msg = ucsp.Request(CreateGetInteractions(strContactID));
                       if (msg != null && msg.GetType() == typeof(EventError))
                       {
                           EventError error = msg as EventError;
                           strTableContent = error.FaultString;
                       }
                       else if (msg != null && msg.GetType() == typeof(EventGetInteractionsForContact))
                       {
                           EventGetInteractionsForContact egifc = msg as EventGetInteractionsForContact;
                           ContactInteractionList cil = egifc.ContactInteractions;
                           if (cil != null)
                           {
                               cil.Sort(new ContactInteractionsComparer());
                               strTableContent = BuildInteractionTable(cil);
                           }
                           else
                           {
                               strTableContent = "Can't find interactions for contact by provided information. Please try to search with different parameters.";
                           }
                       }
                       else if (msg == null)
                       {
                           strTableContent = "Can't find interactions for contact by provided information. Please try to search with different parameters.";
                       }
                   }
                   else
                   {
                       strTableContent = "Can't find a contact by provided information. Please try to search with different parameters.";
                   }
               }
               else
               {
                   strTableContent = "Invalid reply from server. Please try to search with different parameters.";
               }
               ucsp.Close();
               ResultData.Text = strTableContent;
           }
           catch (ProtocolException pe)
           {
               ResultData.Text = "Error occured during request. " + pe.Message;
           }
           catch (System.UriFormatException ufe)
           {
               ResultData.Text = "Error occured during request. Invalid hostname/port specified.";
           }
           catch (Exception e1)
           {
               ResultData.Text = "Error occured during request. " + e1.ToString();
           }
       }

       public class ContactInteractionsComparer : IComparer
       {
           public int Compare(object x, object y)
           {
               ContactInteraction cix = (ContactInteraction)x;
               ContactInteraction ciy = (ContactInteraction)y;
               return (int)ciy.InteractionIndex - (int)cix.InteractionIndex;
           }
       }

       private IMessage CreateGetInteractions(string strContactID)
       {
           RequestGetInteractionsForContact rgifc  = new RequestGetInteractionsForContact();
           rgifc.ContactId                         = strContactID;
           rgifc.AttributeList                     = new StringList();
           rgifc.AttributeList.Add(InteractionAttributeListConstants.Id);
           rgifc.AttributeList.Add(InteractionAttributeListConstants.TypeId);
           rgifc.AttributeList.Add(InteractionAttributeListConstants.SubtypeId);
           rgifc.AttributeList.Add(InteractionAttributeListConstants.MediaTypeId);
           rgifc.AttributeList.Add(InteractionAttributeListConstants.Subject);
           rgifc.AttributeList.Add(InteractionAttributeListConstants.Text);
           rgifc.AttributeList.Add(InteractionAttributeListConstants.ThreadId);
           rgifc.AttributeList.Add(InteractionAttributeListConstants.WebSafeEmailStatus);
           rgifc.AttributeList.Add(InteractionAttributeListConstants.StartDate);
           //rgifc.AttributeList.Add(InteractionAttributeListConstants.);

           rgifc.SearchCriteria = new SearchCriteriaCollection();
           SimpleSearchCriteria searchByMediaType = new SimpleSearchCriteria();
           searchByMediaType.Operator = Operators.Equal;

           searchByMediaType.AttrName  = InteractionSearchCriteriaConstants.MediaTypeId;
           searchByMediaType.AttrValue = "email";
           rgifc.SearchCriteria.Add(searchByMediaType);

           rgifc.SortCriteria = new SortCriteriaCollection();

           SortCriteria srt1 = new SortCriteria();
           srt1.AttrName = InteractionSortCriteriaConstants.ThreadId;
           srt1.SortIndex = 0;
           srt1.SortOperator = SortMode.Ascending;
           rgifc.SortCriteria.Add(srt1);

           SortCriteria srt2 = new SortCriteria();
           srt2.AttrName = InteractionSortCriteriaConstants.StartDate;
           srt2.SortIndex = 1;
           srt2.SortOperator = SortMode.Descending;
           rgifc.SortCriteria.Add(srt2);

           /*
           //Another one example of ComplexSearchCriteria.
           //Here search formula: search where ( (LastName like "Ivanov") AND (AccountNumber >= 1234) )
           rgifc.SearchCriterions = new SearchCriteriaCollection();
           ComplexSearchCriteria cplx = new ComplexSearchCriteria();
           cplx.Prefix = Prefixes.And;
           cplx.Criterias = new SearchCriteriaCollection();
           SimpleSearchCriteria simple1 = new SimpleSearchCriteria();
           simple1.Operator = Operators.Like;
           simple1.AttrName = SearchCriterionsConstants.LastName;
           simple1.AttrValue = "Ivanov";
           cplx.Criterias.Add(simple1);
           SimpleSearchCriteria simple2 = new SimpleSearchCriteria();
           simple2.Operator = Operators.GreaterOrEqual;
           simple2.AttrName = SearchCriterionsConstants.AccountNumber;
           simple2.AttrValue = "1234";
           cplx.Criterias.Add(simple2);
           rgifc.SearchCriterions.Add(cplx);
           */
           return rgifc;
       }

       private IMessage CreateGetContacts(bool whisSort)
       {
           RequestGetContacts gcr      = new RequestGetContacts();
           ComplexSearchCriteria csc   = null;
           gcr.TenantId                = int.Parse(LoadBalancer.getTenantId(ssc.TenantName));
           gcr.MaxCount                = 5;
           gcr.Restricted              = false;
           gcr.SearchCriteria        = new SearchCriteriaCollection();

           if (strFirstName != "")
           {
               SimpleSearchCriteria simple1 = new SimpleSearchCriteria();
               simple1.AttrName = ContactSearchCriteriaConstants.FirstName;
               simple1.AttrValue = strFirstName;
               simple1.Operator = Operators.Equal;

               csc = new ComplexSearchCriteria();
               csc.Prefix = Prefixes.And;
               csc.Criterias = new SearchCriteriaCollection();
               csc.Criterias.Add(simple1);
               gcr.SearchCriteria.Add(csc);
           }

           if (strLastName != "")
           {
               SimpleSearchCriteria simple2 = new SimpleSearchCriteria();
               simple2.AttrName = ContactSearchCriteriaConstants.LastName;
               simple2.AttrValue = strLastName;
               simple2.Operator = Operators.Equal;
               csc = new ComplexSearchCriteria();
               csc.Prefix = Prefixes.And;
               csc.Criterias = new SearchCriteriaCollection();
               csc.Criterias.Add(simple2);
               gcr.SearchCriteria.Add(csc);
           }

           if (strEMail != "")
           {
               SimpleSearchCriteria simple3 = new SimpleSearchCriteria();
               simple3.AttrName = ContactSearchCriteriaConstants.EmailAddress;
               simple3.AttrValue = strEMail;
               simple3.Operator = Operators.Equal;
               csc = new ComplexSearchCriteria();
               csc.Prefix = Prefixes.And;
               csc.Criterias = new SearchCriteriaCollection();
               csc.Criterias.Add(simple3);
               gcr.SearchCriteria.Add(csc);
           }

           if (whisSort)
           {
               gcr.SortCriteria = new SortCriteriaCollection();
               SortCriteria srt = new SortCriteria();
               srt.SortIndex = 0;
               srt.AttrName = ContactSortCriteriaConstants.FirstName;
               srt.SortOperator = SortMode.Ascending;
               gcr.SortCriteria.Add(srt);
           }

           return gcr;
       }

       private void conn_Opened(object sender, EventArgs e)
       {
           //bConnected = true;
       }

       private void conn_Closed(object sender, EventArgs e)
       {
           //bConnected = false;
       }

       private void conn_Error(object sender, EventArgs e)
       {
           /* remove comments when ErrorEventArgs could be resolved
           ErrorEventArgs e1 = null;
           if (e is ErrorEventArgs)
               e1 = (ErrorEventArgs)e;
           Trace.WriteLine("event Error for mediaServer");
           if (e1 != null)
               Trace.WriteLine(e1.Cause.StackTrace);
           */
       }

    [/code]

    Alex R

    • Guest
    Re: mutimedia
    « Reply #5 on: October 27, 2009, 05:27:46 PM »
    Add a bouble "/" after "tcp:" in the code - forum recognize it as a link and i can't post the correct code.

    Offline Naveen Kancharla

    • Newbie
    • *
    • Posts: 26
    • Karma: -1
    Re: mutimedia
    « Reply #6 on: May 19, 2016, 06:37:27 AM »
    Alex will you help me with SimpleSamplesConstants method???? i'm trying to implement same code.

    Offline Kubig

    • Hero Member
    • *****
    • Posts: 2752
    • Karma: 44
    Re: mutimedia
    « Reply #7 on: May 19, 2016, 08:32:25 AM »
    What is not clear for you within that?

    Offline Naveen Kancharla

    • Newbie
    • *
    • Posts: 26
    • Karma: -1
    Re: mutimedia
    « Reply #8 on: May 20, 2016, 10:00:59 AM »
    below is the out which i got while retrieving data from ucs, can you help or refer some guide with which i can convert it into tabular format:

    O/P
    collection: element[0] = Index=0 InteractionId=000XDaBKNYPU000W InteractionAttributes=collection: element[0] = AttributeName=Status AttributeValue=1 element[1] = AttributeName=Text AttributeValue=Dear Naveen K Thank you for contacting us. We have recieved your enquiry, we will get back to you soon on this. Request ID : 000XDaBKNYPU000T Thank You Support Team Moksa Technologies Pvt. Ltd. element[2] = AttributeName=TenantId AttributeValue=1 element[3] = AttributeName=StartDate AttributeValue=2016-05-17T11:49:00.973Z element[4] = AttributeName=Subject AttributeValue=Project Change Request element[1] = Index=1 InteractionId=000XDaBKNYPU000T InteractionAttributes=collection: element[0] = AttributeName=Status AttributeValue=2 element[1] = AttributeName=Text AttributeValue=test 17.05.16 element[2] = AttributeName=TenantId AttributeValue=1 element[3] = AttributeName=StartDate AttributeValue=2016-05-17T11:48:42.793Z element[4] = AttributeName=Subject AttributeValue=Project Change Request element[2] = Index=2 InteractionId=000XNaBKU7B30016 InteractionAttributes=collection: element[0] = AttributeName=Status AttributeValue=2 element[1] = AttributeName=Text AttributeValue=test 10.25 20.05.16 element[2] = AttributeName=TenantId AttributeValue=1 element[3] = AttributeName=StartDate AttributeValue=2016-05-20T04:55:49.493Z element[4] = AttributeName=Subject AttributeValue=Project Change Request element[3] = Index=3 InteractionId=000XNaBKU7B30021 InteractionAttributes=collection: element[0] = AttributeName=Status AttributeValue=2 element[1] = AttributeName=Text AttributeValue=test 20.05.16 10.48 element[2] = AttributeName=TenantId AttributeValue=1 element[3] = AttributeName=StartDate AttributeValue=2016-05-20T05:18:29.253Z element[4] = AttributeName=Subject AttributeValue=Project Change Request element[4] = Index=4 InteractionId=000XNaBKU7B30025 InteractionAttributes=collection: element[0] = AttributeName=Status AttributeValue=2 element[1] = AttributeName=Text AttributeValue=Dear Naveen K Thank you for contacting us. We have recieved your enquiry, we will get back to you soon on this. Request ID : 000XNaBKU7B30021 Thank You Support Team Moksa Technologies Pvt. Ltd. element[2] = AttributeName=TenantId AttributeValue=1 element[3] = AttributeName=StartDate AttributeValue=2016-05-20T05:18:47.190Z element[4] = AttributeName=Subject AttributeValue=Achnowledgement