CRM 2011中的silverlight应用程序不存在SearchRequest和SearchReponse类?

时间:2013-09-21 16:29:19

标签: dynamics-crm-2011 dynamics-crm dynamics-crm-4

我想在CRM 2011中搜索给定资源的所有可用时间段。现在,CRM 2011 sdk在控制台应用程序中提供了一个很好的例子,它工作正常,但我想在silverlight applciation中做同样的事情。在我的silverlight应用程序中,我无法找到SearchRequest和SearchReponse类。

任何人都可以帮我在silverlight applciation中做到这一点吗?

1 个答案:

答案 0 :(得分:0)

首先准备AppointmentRequest对象

     private void checkButton_Click(object sender, RoutedEventArgs e)
        {           
            AppointmentRequest appReq = new AppointmentRequest
            {
                Objectives = new ObservableCollection<ObjectiveRelation>(),
                RequiredResources = new ObservableCollection<RequiredResource>(),
                AppointmentsToIgnore = new ObservableCollection<AppointmentsToIgnore>(),
                Constraints = new ObservableCollection<ConstraintRelation>(),
                Sites = new ObservableCollection<Guid>(),
        Duration = 60,
        Direction = SearchDirection.Forward,
        NumberOfResults = 5,
        ServiceId = new Guid("DD535FD0-F84B-E111-8F2F-00505688095F"),
        SearchWindowStart = DateTime.UtcNow,
        SearchWindowEnd = DateTime.UtcNow.AddDays(7.0),
        AnchorOffset = 300
    };

    OrganizationRequest req = new OrganizationRequest() { RequestName = "Search" };

    req["AppointmentRequest"] = appReq;

    IOrganizationService service = SilverlightUtility.GetSoapService();

    service.BeginExecute(req, new AsyncCallback(GetAppReqResult), service);
}

Following is the Asynchromus callback function

private void GetAppReqResult(IAsyncResult res)
{
   try
   {
     OrganizationResponse resp = 
                          ((IOrganizationService)res.AsyncState).EndExecute(res);

     SearchResults results = (SearchResults)resp["SearchResults"];

     this.Dispatcher.BeginInvoke(() => ProcessAppointments(results));        

   }
   catch (Exception)
   {
       MessageBox.Show("Error Occurred");
   }
}

结果对象将包含传递的约会请求对象的所有可能时隙。 希望这对像我这样的人有帮助