Exemplo n.º 1
0
        public void GetCameraFilters(EventHandler <AsyncWorkerCallbackEventArgs <IList <CameraFilter> > > callback)
        {
            try
            {
                AsyncWorkerHandle <IList <CameraFilter> > handle = AsyncWorkerHelper.DoWork <IList <CameraFilter> >(
                    delegate(object sender, DoWorkEventArgs e)
                {
                    List <CameraFilter> filters = new List <CameraFilter>();

                    GetCameraFiltersRequest request   = new GetCameraFiltersRequest();
                    GetCameraFiltersResponse response =
                        ServiceProvider.GetService <IDeviceConnectorService, IDeviceConnectorCallbackService>(
                            ViewModelLocator.ServiceClient,
                            ViewModelLocator.SelectedService.HostName,
                            ViewModelLocator.SelectedService.Uri.ToString()
                            ).GetCameraFilters(request);

                    if (response.Filters != null)
                    {
                        foreach (var item in response.Filters)
                        {
                            CameraFilter filter = new CameraFilter(item.Name, item.Uri);
                            filters.Add(filter);
                        }
                    }

                    e.Result = filters;
                },
                    null, callback);
            }
            catch (Exception ex)
            {
                ExceptionHandler.Handle(ex);
            }
        }
Exemplo n.º 2
0
        public GetCameraFiltersResponse GetCameraFilters(GetCameraFiltersRequest request)
        {
            try
            {
                if (request == null)
                {
                    throw new ArgumentNullException("request");
                }

                GetCameraFiltersResponse response = new GetCameraFiltersResponse();
                response.Filters = new CameraFilterDataCollection();

                IEnumerable <CameraFilter> filters = Locator.Get <IFilterManager>().GetCameraFilters();
                response.Filters.AddRange((from f in filters select CameraFilterTranslator.Translate(f)).ToList());

                return(response);
            }
            catch (Exception ex)
            {
                throw new FaultException <DeviceConnectorServiceFault>(new DeviceConnectorServiceFault(ex.Message, ex), ex.Message);
            }
        }