我想在 CRM 2011 中搜索给定资源的所有可用时间段。现在 CRM 2011 sdk 在控制台应用程序中提供了一个示例,它工作正常,但我想在 Silverlight 应用程序中做同样的事情。在我的 silverlight 应用程序中,我找不到 SearchRequest 和 SearchReponse 类。
任何人都可以帮助我如何在 Silverlight 应用程序中做到这一点?
我想在 CRM 2011 中搜索给定资源的所有可用时间段。现在 CRM 2011 sdk 在控制台应用程序中提供了一个示例,它工作正常,但我想在 Silverlight 应用程序中做同样的事情。在我的 silverlight 应用程序中,我找不到 SearchRequest 和 SearchReponse 类。
任何人都可以帮助我如何在 Silverlight 应用程序中做到这一点?
首先准备 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");
}
}
结果对象将包含传递的约会请求对象的所有可能时隙。希望这对像我这样的人有所帮助