Пример #1
0
        public void UpdateCamera(Camera camera, EventHandler<AsyncWorkerCallbackEventArgs<Camera>> callback)
        {
            if (camera == null)
            throw new ArgumentNullException("camera");

              try
              {
            AsyncWorkerHandle<Camera> handle = AsyncWorkerHelper.DoWork<Camera>(
              delegate(object sender, DoWorkEventArgs e)
              {
            UpdateCameraRequest request = new UpdateCameraRequest();
            request.CameraId = camera.Id;
            request.CameraName = camera.Name;
            request.Description = camera.Description;
            request.Tags = camera.Tags;

            UpdateCameraResponse response =
              ServiceProvider.GetService<IDeviceConnectorService, IDeviceConnectorCallbackService>(
              ViewModelLocator.ServiceClient,
              ViewModelLocator.SelectedService.HostName,
              ViewModelLocator.SelectedService.Uri.ToString()
              ).UpdateCamera(request);
            if (response.Camera != null)
            {
              e.Result = camera;
            }
              },
              null, callback);
              }
              catch (Exception ex)
              {
            ExceptionHandler.Handle(ex);
              }
        }
        public UpdateCameraResponse UpdateCamera(UpdateCameraRequest request)
        {
            try
              {
            if (request == null)
              throw new ArgumentNullException("request");

            UpdateCameraResponse response = new UpdateCameraResponse();

            response.Camera = CameraTranslator.Translate(
              Locator.Get<ICameraManager>().UpdateCamera(
              request.CameraId, request.CameraName, request.Description, request.Tags));

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