Answered Component One Scheduler

  • Thursday, April 05, 2012 6:46 PM
     
     

    I am strruggling to get an answer from componentone so I am kind of hoping someone on here can answer.

    When using the Scheduler , it appears to insert all the data into a properties field  even though you link it to Categories/Resources table.

    Is there anyone on here been able to capture data ie the Resource Id when iserting the appointment ?

    Thanks

    Martin

All Replies

  • Friday, April 06, 2012 4:16 PM
     
     

    To grab the contact at the time of appointment creation, the AppointmentActionEventArgs has an Appointment property,

    which has a Links property that returns a ContactsList.  

    Found a hint I dont suppose anyone can explain how to go about doing it ?

    Martin

  • Monday, April 09, 2012 8:23 AM
    Moderator
     
     Answered

    After researching this issue, sorry for cannot reach the solution.

    For I don't know how the control works, I suggest you to try to ask in the componentone'forums again for more information.

    http://our.componentone.com/groups/lightswitch/scheduler-for-lightswitch/forum/

  • Monday, April 09, 2012 12:16 PM
     
     

    thanks Otomii , I will try again but as up to now I have asked them 3 times without getting an answer :(

    Martin


    Martin

  • Friday, April 13, 2012 10:11 AM
     
     

    Just incase anyone else has this issue.

    The answer was there all along just in a post I didnt pick up on.

    http://our.componentone.com/groups/lightswitch/scheduler-for-lightswitch/forum/topic/relationships-between-appointment-contact-and-resource-entity/

    Basically you have to parse the xml properties field and pull the data from there.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml;
    using System.Xml.Linq;
    using Microsoft.LightSwitch;
     
    namespace LightSwitchApplication
    {
        public partial class Appointment
        {
            partial void Contacts_Compute(ref string result)
            {
                XDocument properties = XDocument.Parse(this.Properties);
                IEnumerable<XElement> rows = properties.Root.Descendants("Links");
                List<string> names = new List<string>();
     
                if (rows.Any())
                {
                    XElement links = rows.First();
     
                    foreach (XElement obj in links.Elements())
                    {
                        string id = obj.Attribute("Id").Value;
                        Guid g = new Guid(id);
                        var contacts = this.DataWorkspace.ApplicationData.Contacts.Where(c => c.Guid.Equals(g));
                        names.Add(contacts.Single().DisplayName);
                    }
                }
     
                result = String.Join(", ", names);
            }
        }
    }

    Martin


    Martin


    • Edited by martin05 Friday, April 13, 2012 10:11 AM
    •