Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Dec 25, 2025

Link issues

fixes #7413

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Add support in the HikVision sample component for capturing pictures either to the default local storage path or via direct download, with corresponding UI controls and user notifications.

New Features:

  • Introduce a separate capture-only picture method alongside the existing capture-and-download method in the HikVision sample component.
  • Expose a new UI button to trigger picture capture with immediate file download in the HikVision demo.

Enhancements:

  • Provide user-facing toast notifications indicating success or failure of HikVision picture capture actions.
  • Update the HikVision sample documentation to describe the two capture modes and default storage location.

Copilot AI review requested due to automatic review settings December 25, 2025 06:10
@bb-auto bb-auto bot added the enhancement New feature or request label Dec 25, 2025
@bb-auto bb-auto bot added this to the v10.1.0 milestone Dec 25, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 25, 2025

Reviewer's Guide

Adds a separate CapturePicture method usage in the HikVision sample, introduces a new Capture-and-Download button, and updates the demo documentation to explain the two capture modes and their behaviors with toast feedback.

Sequence diagram for HikVision capture and capture-download flows

sequenceDiagram
    actor User
    participant Browser
    participant HikVisionsComponent
    participant HikVisionService
    participant ToastService

    rect rgb(230,230,250)
    User->>Browser: Click Capture button
    Browser->>HikVisionsComponent: OnCapture()
    HikVisionsComponent->>HikVisionService: CapturePicture()
    HikVisionService-->>HikVisionsComponent: result bool
    alt capture success
        HikVisionsComponent->>ToastService: Success(消息通知, 抓图成功)
    else capture failed
        HikVisionsComponent->>ToastService: Error(消息通知, 抓图失败)
    end
    end

    rect rgb(220,245,255)
    User->>Browser: Click CaptureDownload button
    Browser->>HikVisionsComponent: OnCaptureAndDownload()
    HikVisionsComponent->>HikVisionService: CapturePictureAndDownload()
    HikVisionService-->>HikVisionsComponent: result bool
    alt capture download success
        HikVisionsComponent->>ToastService: Success(消息通知, 抓图成功)
    else capture download failed
        HikVisionsComponent->>ToastService: Error(消息通知, 抓图失败)
    end
    end
Loading

Class diagram for updated HikVisions component and HikVision service

classDiagram
    class HikVisions
    HikVisions : bool _stopRealPlayStatus
    HikVisions : Task OnCapture()
    HikVisions : Task OnCaptureAndDownload()
    HikVisions : Task OnStartRecord()
    HikVisions : Task OnStopRecord()

    class HikVisionService
    HikVisionService : Task~bool~ CapturePicture()
    HikVisionService : Task~bool~ CapturePictureAndDownload()

    class ToastService
    ToastService : Task Success(string title, string message)
    ToastService : Task Error(string title, string message)

    HikVisions --> HikVisionService : uses
    HikVisions --> ToastService : uses
Loading

File-Level Changes

Change Details Files
Wire OnCapture to use the new CapturePicture API and add toast-based success/failure feedback.
  • Change OnCapture to call CapturePicture instead of CapturePictureAndDownload
  • Evaluate the boolean result and show success or error toasts accordingly
src/BootstrapBlazor.Server/Components/Samples/HikVisions.razor.cs
Introduce a dedicated capture-and-download flow alongside the basic capture operation.
  • Add OnCaptureAndDownload handler that calls CapturePictureAndDownload and shows success/error toasts based on the result
  • Add a new '抓图下载' button bound to OnCaptureAndDownload and disabled with the same condition as the existing capture button
src/BootstrapBlazor.Server/Components/Samples/HikVisions.razor.cs
src/BootstrapBlazor.Server/Components/Samples/HikVisions.razor
Document the two capture modes and their storage behavior in the HikVision demo.
  • Add a short section describing capture prerequisites (login + preview)
  • Describe default local save path for captured images
  • Explain behavioral difference between CapturePicture and CapturePictureAndDownload methods
src/BootstrapBlazor.Server/Components/Samples/HikVisions.razor

Assessment against linked issues

Issue Objective Addressed Explanation
#7413 Add a CapturePicture method to the HikVision integration and use it instead of CapturePictureAndDownload for simple capture.
#7413 Expose the new CapturePicture behavior in the sample UI and documentation for the HikVision component.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ArgoZhang ArgoZhang merged commit de58e46 into main Dec 25, 2025
6 of 8 checks passed
@ArgoZhang ArgoZhang deleted the feat-hik branch December 25, 2025 06:10
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The success/error toast handling in OnCapture and OnCaptureAndDownload is duplicated; consider extracting a small helper or reusing a common method that accepts the capture delegate to reduce repetition and keep behavior consistent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The success/error toast handling in `OnCapture` and `OnCaptureAndDownload` is duplicated; consider extracting a small helper or reusing a common method that accepts the capture delegate to reduce repetition and keep behavior consistent.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Dec 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (d39741f) to head (68c4f54).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7414   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          748       748           
  Lines        32793     32793           
  Branches      4551      4551           
=========================================
  Hits         32793     32793           
Flag Coverage Δ
BB 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new CapturePicture method to the HikVision component, providing users with two distinct options for capturing images: saving directly to local storage or downloading immediately.

Key Changes:

  • Separated capture functionality into two methods: CapturePicture (local storage) and CapturePictureAndDownload (with download prompt)
  • Added comprehensive documentation explaining both capture methods and their behavior
  • Updated the HikVision package dependency to version 10.0.9

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/BootstrapBlazor.Server/Components/Samples/HikVisions.razor.cs Refactored OnCapture to use the new CapturePicture method and added OnCaptureAndDownload method with success/error notifications
src/BootstrapBlazor.Server/Components/Samples/HikVisions.razor Added documentation explaining the two capture methods and a new "抓图下载" button for the download functionality
src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj Updated BootstrapBlazor.HikVision package reference from version 10.0.8 to 10.0.9

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 96 to 120
private async Task OnCapture()
{
await _hikVision.CapturePictureAndDownload();
var result = await _hikVision.CapturePicture();
if (result)
{
await ToastService.Success("消息通知", "抓图成功");
}
else
{
await ToastService.Error("消息通知", "抓图失败");
}
}

private async Task OnCaptureAndDownload()
{
var result = await _hikVision.CapturePictureAndDownload();
if (result)
{
await ToastService.Success("消息通知", "抓图成功");
}
else
{
await ToastService.Error("消息通知", "抓图失败");
}
}
Copy link

Copilot AI Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The success and error handling logic is duplicated between OnCapture and OnCaptureAndDownload methods. Consider extracting this common logic into a helper method that takes the result and action name as parameters, which would improve maintainability and reduce code duplication.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(HikVision): add CapturePicture method

2 participants