Esempio n. 1
0
        public void SetCurrentWeek(DateTime date)
        {
            // Cancel new row
            _newRow = null;
            this.Sessions.SetCurrentWeek(date);

        }
Esempio n. 2
0
        private void AddDefaultSession(DayEntry activity)
        {
            // Clear the sessions from the previously selected row, and show a blank row
            Sessions.SetCurrentActivity(activity.Activity, 0);

            dev1_session session = new dev1_session();

            session.Account                           = activity.Account;
            session.dev1_ActivityId                   = activity.Activity.Id.ToString();
            session.dev1_ActivityTypeName             = activity.Activity.LogicalName;
            session.dev1_ActivityId                   = activity.Activity.Id.ToString();
            session.dev1_StartTime                    = Sessions.WeekStart;
            session.activitypointer_subject           = activity.Activity.Name;
            session.activitypointer_regardingobjectid = activity.RegardingObjectId;
            Sessions.SelectedActivity                 = activity.Activity;
            session.dev1_Row                          = this.Sessions.GetCurrentWeek().Count;
            // Has the account been set - if not we need to look it up from the selected activity
            if (session.Account == null || session.activitypointer_regardingobjectid == null)
            {
                SetAccountAndRegardingFromActivity(session);
            }


            Sessions.AddItem(session);
            _selectedRows = new SelectedRange[1] {
                new SelectedRange()
            };
            _selectedRows[0].FromRow = rows.Count + 1;
            _selectedRows[0].ToRow   = rows.Count + 1;
        }
Esempio n. 3
0
        public override void AddItem(object item)
        {
            DayEntry activity = (DayEntry)item;

            if ((activity.Activity != null) && (activity.Activity.Id != null))
            {
                AddDefaultSession(activity);
            }
            else
            {
                _newRow = activity;
                rows.Add(_newRow);
            }
            Refresh();
        }
Esempio n. 4
0
        public override void AddItem(object item)
        {
            dev1_session session  = new dev1_session();
            DayEntry     activity = (DayEntry)item;

            if ((activity.Activity != null) && (activity.Activity.Id != null))
            {
                session.dev1_ActivityId       = activity.Activity.Id.ToString();
                session.dev1_ActivityTypeName = activity.Activity.LogicalName;
                //session.activityName = activity.Activity.Name;
                session.dev1_ActivityId   = activity.Activity.Id.ToString();
                session.dev1_StartTime    = sessions.WeekStart;
                sessions.SelectedActivity = activity.Activity;
                sessions.AddItem(session);
                _selectedRows = new SelectedRange[1] {
                    new SelectedRange()
                };
                _selectedRows[0].FromRow = rows.Count + 1;
                _selectedRows[0].ToRow   = rows.Count + 1;
                Refresh();
            }
        }
Esempio n. 5
0
        public DaysViewModel(SessionsViewModel sessions)
        {
            this.Sessions = sessions;
            bool inHander = false;

            this.Sessions.OnRowsChanged.Subscribe(delegate(EventData args, object data){
                ReCalculate();
            });


            this.OnSelectedRowsChanged += delegate()
            {
                _newRow = null;
            };

            this.OnRowsChanged.Subscribe(delegate(EventData args, object data)
            {
                if (inHander)
                {
                    return;
                }
                inHander = true;
                // Ensure if we are in progress of adding a new row, we complete it once we've got the activity
                if (_newRow != null && _newRow.Activity != null)
                {
                    DayEntry day = _newRow;
                    _newRow      = null;

                    AddDefaultSession(day);
                }
                inHander = false;
            });

            sessions.OnRowsChanged.Subscribe(delegate(EventData args, object data)
            {
                // Ensure that when data has changed in the sessions, the days view is updated
                this.Refresh();
            });
        }
Esempio n. 6
0
        public DaysViewModel(SessionsViewModel sessions)
        {
            this.Sessions = sessions;
            bool inHander = false;
            this.Sessions.OnRowsChanged.Subscribe(delegate(EventData args, object data){
                ReCalculate();

            });

            this.OnSelectedRowsChanged += delegate()
            {
                _newRow=null;
            };

            this.OnRowsChanged.Subscribe(delegate(EventData args, object data)
            {
                if (inHander)
                    return;
                inHander = true;
                // Ensure if we are in progress of adding a new row, we complete it once we've got the activity
                if (_newRow != null && _newRow.Activity != null)
                {
                    DayEntry day = _newRow;
                    _newRow = null;

                    AddDefaultSession(day);
                }
                inHander = false;
            });

            sessions.OnRowsChanged.Subscribe(delegate(EventData args, object data)
            {

                // Ensure that when data has changed in the sessions, the days view is updated
                this.Refresh();

            });
        }
Esempio n. 7
0
        private void SortData()
        {
            if (_sortCol == null)
            {
                return;
            }
            // Remove the total row
            DayEntry totalRow = rows[0];

            rows.RemoveAt(0);
            if (_sortCol.SortAsc == false)
            {
                rows.Reverse();
            }
            rows.Sort(delegate(DayEntry a, DayEntry b) { return(Entity.SortDelegate(_sortCol.SortCol.Field, a, b)); });

            if (_sortCol.SortAsc == false)
            {
                rows.Reverse();
            }

            // Add total row
            rows.Insert(0, totalRow);
        }
Esempio n. 8
0
        private void AddDefaultSession(DayEntry activity)
        {
            // Clear the sessions from the previously selected row, and show a blank row
            Sessions.SetCurrentActivity(activity.Activity, 0);

            dev1_session session = new dev1_session();
            session.Account = activity.Account;
            session.dev1_ActivityId = activity.Activity.Id.ToString();
            session.dev1_ActivityTypeName = activity.Activity.LogicalName;
            session.dev1_ActivityId = activity.Activity.Id.ToString();
            session.dev1_StartTime = Sessions.WeekStart;
            session.activitypointer_subject = activity.Activity.Name;
            session.activitypointer_regardingobjectid = activity.RegardingObjectId;
            Sessions.SelectedActivity = activity.Activity;
            session.dev1_Row = this.Sessions.GetCurrentWeek().Count;
            // Has the account been set - if not we need to look it up from the selected activity
            if (session.Account == null || session.activitypointer_regardingobjectid == null)
                SetAccountAndRegardingFromActivity(session);


            Sessions.AddItem(session);
            _selectedRows = new SelectedRange[1] { new SelectedRange() };
            _selectedRows[0].FromRow = rows.Count + 1;
            _selectedRows[0].ToRow = rows.Count + 1;
            
        }
Esempio n. 9
0
        public override void AddItem(object item)
        {

            DayEntry activity = (DayEntry)item;
            if ((activity.Activity != null) && (activity.Activity.Id != null))
            {
                AddDefaultSession(activity);
               
            }
            else
            {
                _newRow = activity;
                rows.Add(_newRow);
               
              
            }
            Refresh();
        }
Esempio n. 10
0
        public void ReCalculate()
        {
            if (_newRow != null)
                return;
            // Calculate Totals by Activity and Day

            // Show header row of totals

            List<dev1_session> sessionData = Sessions.GetCurrentWeek();
            DateTime weekStart = Sessions.WeekStart;

            days = new Dictionary<string,DayEntry>();
            totals = new DayEntry();
            totals.isTotalRow = true;
            totals.ActivityName = "Total";
            totals.Activity = new EntityReference(null,null,null);
            totals.Activity.Name = "Total";

           

            foreach (dev1_session session in sessionData)
            {
                // Accumulate hours by Activity
                if (session.dev1_StartTime == null)
                    continue;
                int dayOfWeek = session.dev1_StartTime.GetDay()-OrganizationServiceProxy.OrganizationSettings.WeekStartDayCode.Value.Value;
                if (dayOfWeek < 0) dayOfWeek = 7 + dayOfWeek;
                string activity = session.dev1_ActivityId;

                if (days[activity] == null)
                {
                    DayEntry day = new DayEntry();
                    days[activity] = day;
                    day.Activity = new EntityReference(new Guid(session.dev1_ActivityId),null,null);
                    day.Activity.Name = session.activitypointer_subject;
                    day.RegardingObjectId = session.activitypointer_regardingobjectid;
                    
                    // Set the account name 
                    if (session.Account != null && day.Account == null)
                        day.Account = session.Account;

                    day.Activity.LogicalName = session.dev1_ActivityTypeName;
 
                }

                if (session.dev1_Duration != null)
                {
                    if (days[activity].Hours[dayOfWeek] == null)
                        days[activity].Hours[dayOfWeek] = 0;

                    days[activity].Hours[dayOfWeek] = days[activity].Hours[dayOfWeek] + session.dev1_Duration;

                    // Accumulate total hours
                    if (totals.Hours[dayOfWeek] == null)
                        totals.Hours[dayOfWeek] = 0;

                    totals.Hours[dayOfWeek] = totals.Hours[dayOfWeek] + session.dev1_Duration;
                }
            }

            // Flattern
            rows.Clear();
            rows.Add(totals);
            foreach (KeyValuePair<string,DayEntry> day in days)
            {
                day.Value.FlatternDays();
                rows.Add(day.Value);
            }
            totals.FlatternDays();

            SortData();
            Refresh();
        }
Esempio n. 11
0
        public void ReCalculate()
        {
            // Calculate Totals by Activity and Day

            // Show header row of totals

            List <dev1_session> sessionData = sessions.GetCurrentWeek();
            DateTime            weekStart   = sessions.WeekStart;

            days                 = new Dictionary <string, DayEntry>();
            totals               = new DayEntry();
            totals.isTotalRow    = true;
            totals.ActivityName  = "Total";
            totals.Activity      = new EntityReference(null, null, null);
            totals.Activity.Name = "Total";
            foreach (dev1_session session in sessionData)
            {
                // Accumulate hours by Activity
                int    dayOfWeek = session.dev1_StartTime.GetDay();
                string activity  = session.dev1_ActivityId;

                if (days[activity] == null)
                {
                    DayEntry day = new DayEntry();
                    days[activity] = day;
                    day.Activity   = new EntityReference(new Guid(session.dev1_ActivityId), null, null);



                    if (session.dev1_TaskId != null)
                    {
                        day.Activity.Name = session.dev1_TaskId.Name;
                    }
                    else if (session.dev1_LetterId != null)
                    {
                        day.Activity.Name = session.dev1_LetterId.Name;
                    }
                    else if (session.dev1_EmailId != null)
                    {
                        day.Activity.Name = session.dev1_EmailId.Name;
                    }
                    else if (session.dev1_PhoneCallId != null)
                    {
                        day.Activity.Name = session.dev1_PhoneCallId.Name;
                    }

                    day.Activity.LogicalName = session.dev1_ActivityTypeName;
                }

                if (session.dev1_Duration != null)
                {
                    if (days[activity].Hours[dayOfWeek] == null)
                    {
                        days[activity].Hours[dayOfWeek] = 0;
                    }

                    days[activity].Hours[dayOfWeek] = days[activity].Hours[dayOfWeek] + session.dev1_Duration;

                    // Accumulate total hours
                    if (totals.Hours[dayOfWeek] == null)
                    {
                        totals.Hours[dayOfWeek] = 0;
                    }

                    totals.Hours[dayOfWeek] = totals.Hours[dayOfWeek] + session.dev1_Duration;
                }
            }

            // Flattern
            rows.Clear();
            rows.Add(totals);
            foreach (KeyValuePair <string, DayEntry> day in days)
            {
                day.Value.FlatternDays();
                rows.Add(day.Value);
            }
            totals.FlatternDays();


            Refresh();
        }
Esempio n. 12
0
        public void ReCalculate()
        {
            // Calculate Totals by Activity and Day

            // Show header row of totals

            List<dev1_session> sessionData = sessions.GetCurrentWeek();
            DateTime weekStart = sessions.WeekStart;

            days = new Dictionary<string,DayEntry>();
            totals = new DayEntry();
            totals.isTotalRow = true;
            totals.ActivityName = "Total";
            totals.Activity = new EntityReference(null,null,null);
            totals.Activity.Name = "Total";
            foreach (dev1_session session in sessionData)
            {
                // Accumulate hours by Activity
                int dayOfWeek = session.dev1_StartTime.GetDay();
                string activity = session.dev1_ActivityId;

                if (days[activity] == null)
                {
                    DayEntry day = new DayEntry();
                    days[activity] = day;
                    day.Activity = new EntityReference(new Guid(session.dev1_ActivityId),null,null);

                    if (session.dev1_TaskId != null)
                        day.Activity.Name = session.dev1_TaskId.Name;
                    else if (session.dev1_LetterId !=null)
                        day.Activity.Name = session.dev1_LetterId.Name;
                    else if (session.dev1_EmailId !=null)
                        day.Activity.Name = session.dev1_EmailId.Name;
                    else if (session.dev1_PhoneCallId != null)
                        day.Activity.Name = session.dev1_PhoneCallId.Name;

                    day.Activity.LogicalName = session.dev1_ActivityTypeName;

                }

                if (session.dev1_Duration != null)
                {
                    if (days[activity].Hours[dayOfWeek] == null)
                        days[activity].Hours[dayOfWeek] = 0;

                    days[activity].Hours[dayOfWeek] = days[activity].Hours[dayOfWeek] + session.dev1_Duration;

                    // Accumulate total hours
                    if (totals.Hours[dayOfWeek] == null)
                        totals.Hours[dayOfWeek] = 0;

                    totals.Hours[dayOfWeek] = totals.Hours[dayOfWeek] + session.dev1_Duration;
                }
            }

            // Flattern
            rows.Clear();
            rows.Add(totals);
            foreach (KeyValuePair<string,DayEntry> day in days)
            {
                day.Value.FlatternDays();
                rows.Add(day.Value);
            }
            totals.FlatternDays();

            Refresh();
        }
Esempio n. 13
0
 public void SetCurrentWeek(DateTime date)
 {
     // Cancel new row
     _newRow = null;
     this.Sessions.SetCurrentWeek(date);
 }
Esempio n. 14
0
        public void ReCalculate()
        {
            if (_newRow != null)
            {
                return;
            }
            // Calculate Totals by Activity and Day

            // Show header row of totals

            List <dev1_session> sessionData = Sessions.GetCurrentWeek();
            DateTime            weekStart   = Sessions.WeekStart;

            days                 = new Dictionary <string, DayEntry>();
            totals               = new DayEntry();
            totals.isTotalRow    = true;
            totals.ActivityName  = "Total";
            totals.Activity      = new EntityReference(null, null, null);
            totals.Activity.Name = "Total";



            foreach (dev1_session session in sessionData)
            {
                // Accumulate hours by Activity
                if (session.dev1_StartTime == null)
                {
                    continue;
                }
                int dayOfWeek = session.dev1_StartTime.GetDay() - OrganizationServiceProxy.OrganizationSettings.WeekStartDayCode.Value.Value;
                if (dayOfWeek < 0)
                {
                    dayOfWeek = 7 + dayOfWeek;
                }
                string activity = session.dev1_ActivityId;

                if (days[activity] == null)
                {
                    DayEntry day = new DayEntry();
                    days[activity]        = day;
                    day.Activity          = new EntityReference(new Guid(session.dev1_ActivityId), null, null);
                    day.Activity.Name     = session.activitypointer_subject;
                    day.RegardingObjectId = session.activitypointer_regardingobjectid;

                    // Set the account name
                    if (session.Account != null && day.Account == null)
                    {
                        day.Account = session.Account;
                    }

                    day.Activity.LogicalName = session.dev1_ActivityTypeName;
                }

                if (session.dev1_Duration != null)
                {
                    if (days[activity].Hours[dayOfWeek] == null)
                    {
                        days[activity].Hours[dayOfWeek] = 0;
                    }

                    days[activity].Hours[dayOfWeek] = days[activity].Hours[dayOfWeek] + session.dev1_Duration;

                    // Accumulate total hours
                    if (totals.Hours[dayOfWeek] == null)
                    {
                        totals.Hours[dayOfWeek] = 0;
                    }

                    totals.Hours[dayOfWeek] = totals.Hours[dayOfWeek] + session.dev1_Duration;
                }
            }

            // Flattern
            rows.Clear();
            rows.Add(totals);
            foreach (KeyValuePair <string, DayEntry> day in days)
            {
                day.Value.FlatternDays();
                rows.Add(day.Value);
            }
            totals.FlatternDays();

            SortData();
            Refresh();
        }
        public void RegardingObjectSearchCommand(string term, Action <EntityCollection> callback)
        {
            string regardingAccountFetchXml     = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                  <entity name='account'>
                                    <attribute name='name' />
                                    <attribute name='accountid' />
                                    <order attribute='name' descending='false' />
                                    <filter type='and'>
                                      <condition attribute='statecode' operator='eq' value='0' />
                                      <condition attribute='name' operator='like' value='%{0}%' />
                                      {1}
                                    </filter>
                                   </entity>
                                </fetch>";
            string regardingOpportunityFetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                                  <entity name='opportunity'>
                                                    <attribute name='name' />
                                                    <attribute name='opportunityid' />
                                                    <order attribute='name' descending='false' />
                                                    <filter type='and'>
                                                      <condition attribute='statecode' operator='eq' value='0' />
                                                      <condition attribute='name' operator='like' value='%{0}%' />
                                                     {1}
                                                    </filter>
                                                  </entity>
                                                </fetch>";

            string regardingIncidentFetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                              <entity name='incident'>
                                                <attribute name='title' />
                                                <attribute name='incidentid' />
                                                <order attribute='title' descending='false' />
                                                <filter type='and'>
                                                  <condition attribute='title' operator='like' value='%{0}%' />
                                                  {1}
                                                </filter>
                                              </entity>
                                            </fetch>";

            string   accountCriteriaFetchXml = @"<condition attribute='{0}' operator='eq' value='{1}' />";
            DayEntry selectedItem            = this.Days.SelectedItems[0];


            List <Entity> unionedResults = new List <Entity>();

            // We need to union the activities regarding the account directly with those that are regarding related records
            Action <string, string, string, Action, Action> unionSearch = delegate(string fetchXml, string nameAttribute, string accountAttribute, Action completeCallBack, Action errorCallBack)
            {
                // Add Account filter if an account is selected
                string additionalCriteria = "";
                if (selectedItem != null && selectedItem.Account != null)
                {
                    additionalCriteria = string.Format(accountCriteriaFetchXml, accountAttribute, selectedItem.Account.Id.Value);
                }
                string queryFetchXml = string.Format(fetchXml, XmlHelper.Encode(term), additionalCriteria);
                OrganizationServiceProxy.BeginRetrieveMultiple(queryFetchXml, delegate(object result)
                {
                    EntityCollection fetchResult = OrganizationServiceProxy.EndRetrieveMultiple(result, typeof(ActivityPointer));
                    // Adjust the entity types
                    foreach (Entity a in fetchResult.Entities)
                    {
                        // Set name
                        a.SetAttributeValue("displayName", a.GetAttributeValueString(nameAttribute));
                        unionedResults.Add(a);
                    }

                    completeCallBack();
                });
            };

            TaskIterrator tasks = new TaskIterrator();

            // Add Searches
            tasks.AddTask(delegate(Action completeCallBack, Action errorCallBack) { unionSearch(regardingAccountFetchXml, "name", "accountid", completeCallBack, errorCallBack); });
            tasks.AddTask(delegate(Action completeCallBack, Action errorCallBack) { unionSearch(regardingOpportunityFetchXml, "name", "customerid", completeCallBack, errorCallBack); });
            tasks.AddTask(delegate(Action completeCallBack, Action errorCallBack) { unionSearch(regardingIncidentFetchXml, "title", "customerid", completeCallBack, errorCallBack); });

            Action queryComplete = delegate()
            {
                //  Sort Alphabetically
                unionedResults.Sort(delegate(Entity a, Entity b) { return(Entity.SortDelegate("displayName", a, b)); });
                // Completed the queryies, so sort then and add to Entity Collection
                EntityCollection results = new EntityCollection(unionedResults);

                callback(results);
            };

            // Start processing queue
            tasks.Start(queryComplete, null);
        }
        public void ActivitySearchCommand(string term, Action <EntityCollection> callback)
        {
            // Get the option set values

            string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                  <entity name='activitypointer'>
                                    <attribute name='activitytypecode' />
                                    <attribute name='subject' />
                                    <attribute name='activityid' />
                                    <attribute name='instancetypecode' />
                                    <attribute name='regardingobjectid' />
                                    <order attribute='modifiedon' descending='false' />
                                    <filter type='and'>
                                      <condition attribute='ownerid' operator='eq-userid' />
                                        <condition attribute='subject' operator='like' value='%{0}%' />
                                          <condition attribute='activitytypecode' operator='in'>
                                            <value>4202</value>
                                            <value>4207</value>
                                            <value>4210</value>
                                            <value>4212</value>
                                          </condition>
                                            {2}
                                    </filter>
                                    {1}
                                  </entity>
                                </fetch>";
            // Get the account to filter on if there is one
            string regardingObjectIdFilterFetchXml = @"<condition attribute='regardingobjectid' operator='eq' value='{0}'/>";

            string opportunityAccountFilterFetchXml = @"<link-entity name='opportunity' from='opportunityid' to='regardingobjectid' visible='false' link-type='inner' alias='opportunity' >
                                        <attribute name='customerid' />
                                        <filter type='and' >
                                            <condition attribute='customerid' operator='eq' value='{0}' />
                                        </filter>
                                        </link-entity>";

            string incidentAccountFilterFetchXml = @" <link-entity name='incident' from='incidentid' to='regardingobjectid' visible='false' link-type='inner' alias='incident' >
                                        <attribute name='customerid' />
                                        <filter type='and' >
                                            <condition attribute='customerid' operator='eq' value='{0}' />
                                        </filter>
                                        </link-entity>";

            string contractAccountFilterFetchXml = @" <link-entity name='contract' from='contractid' to='regardingobjectid' visible='false' link-type='inner' alias='contract' >
                                        <attribute name='customerid' />
                                        <filter type='and' >
                                            <condition attribute='customerid' operator='eq' value='{0}' />
                                        </filter>
                                        </link-entity>";

            string regardingAccountFilterFetchXml = @" <link-entity name='account' from='accountid' to='regardingobjectid' visible='false' link-type='inner' alias='account' >
                                        <attribute name='accountid'/>
                                        <attribute name='name'/>
                                        <filter type='and' >
                                            <condition attribute='accountid' operator='eq' value='{0}' />
                                        </filter>
                                        </link-entity>";

            DayEntry selectedItem             = this.Days.SelectedItems[0];
            string   regardingObjectFilter    = String.Empty;
            string   regardingAccountFilter   = String.Empty;
            string   opportunityAccountFilter = String.Empty;
            string   incidentAccountFilter    = String.Empty;
            string   contractAccountFilter    = String.Empty;

            if (selectedItem != null && selectedItem.RegardingObjectId != null)
            {
                regardingObjectFilter = string.Format(regardingObjectIdFilterFetchXml, selectedItem.RegardingObjectId.Id.Value);
            }

            if (selectedItem != null && selectedItem.Account != null)
            {
                // Add in the regarding account filter
                regardingAccountFilter   = string.Format(regardingAccountFilterFetchXml, selectedItem.Account.Id.Value);
                opportunityAccountFilter = string.Format(opportunityAccountFilterFetchXml, selectedItem.Account.Id.Value);
                incidentAccountFilter    = string.Format(incidentAccountFilterFetchXml, selectedItem.Account.Id.Value);
                contractAccountFilter    = string.Format(contractAccountFilterFetchXml, selectedItem.Account.Id.Value);
            }

            List <Entity> unionedResults = new List <Entity>();

            // We need to union the activities regarding the account directly with those that are regarding related records
            Action <string, string, Action, Action> unionSearch = delegate(string additionalFilter, string additionalCriteria, Action completeCallBack, Action errorCallBack)
            {
                string queryFetchXml = string.Format(fetchXml, XmlHelper.Encode(term), additionalFilter, additionalCriteria);
                OrganizationServiceProxy.BeginRetrieveMultiple(queryFetchXml, delegate(object result)
                {
                    EntityCollection fetchResult = OrganizationServiceProxy.EndRetrieveMultiple(result, typeof(ActivityPointer));
                    // Adjust the entity types
                    foreach (ActivityPointer a in fetchResult.Entities)
                    {
                        a.UpdateCalculatedFields();
                        unionedResults.Add(a);
                    }

                    completeCallBack();
                });
            };

            TaskIterrator tasks = new TaskIterrator();

            // Default Search
            tasks.AddTask(delegate(Action completeCallBack, Action errorCallBack) { unionSearch(regardingAccountFilter, regardingObjectFilter, completeCallBack, errorCallBack); });

            // Associated record searches
            if (opportunityAccountFilter != String.Empty)
            {
                tasks.AddTask(delegate(Action completeCallBack, Action errorCallBack) { unionSearch(opportunityAccountFilter, String.Empty, completeCallBack, errorCallBack); });
            }
            if (incidentAccountFilter != String.Empty)
            {
                tasks.AddTask(delegate(Action completeCallBack, Action errorCallBack) { unionSearch(incidentAccountFilter, String.Empty, completeCallBack, errorCallBack); });
            }
            if (contractAccountFilter != String.Empty)
            {
                tasks.AddTask(delegate(Action completeCallBack, Action errorCallBack) { unionSearch(contractAccountFilter, String.Empty, completeCallBack, errorCallBack); });
            }


            Action queryComplete = delegate()
            {
                // Sort
                unionedResults.Sort(delegate(Entity a, Entity b) { return(Entity.SortDelegate("subject", a, b)); });
                // Completed the queryies, so sort then and add to Entity Collection
                EntityCollection results = new EntityCollection(unionedResults);

                callback(results);
            };

            // Start processing queue
            tasks.Start(queryComplete, null);
        }