Latest article

Unit 10 Indexes and Views

Unit 10 Indexes and Views 1. Common data structures 1. Stack Features: first in, last out, last in, first out 2. Queue Features: first in, first out 3. Array Fast query speed: data can be quickly located through address values ​​and indexes Low deletion efficiency: after deleting data, each data must be moved forward The addition efficiency is extremely low: after adding the position, each data is moved back and then the data is added. 4. Linked list The data in the link is stored free, and each element node contains the element value and the address of the next element The query speed is slow because each query must be queried sequentially through the head pointer Addition and deletion are relatively efficient, because you only need to re-point the pointer to the newly added element and the location of other elements No need to move. 5. Binary tree Binary tree, the full name is binary search tree. The stored data is based on the first piece of data. If it is smaller, it will be placed on the left, if it is greater, it will be placed on the right. There can only be one root node, and each…

Identify the text of the specified window

Identify the text of the specified window 1. Simple requirements Read the text of a specified window through image and text recognition. Get the window handle, save the screenshot as bitmap, and call the image and text recognition library. The test result is that the recognition of Chinese is not particularly good. It should be noted that tessdata must be downloaded from the specified directory page. 2. Reference package a. Reference tesseract4.1 b. Emgu.CV component 3. Upload the code using System; using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; using Emgu.CV; using Emgu.CV.OCR; using Emgu.CV.Structure; using Tesseract; using System.Windows.Forms; using Pix = Tesseract.Pix; using PageSegMode = Tesseract.PageSegMode; public class Program { [DllImport(“user32.dll”, SetLastError = true)] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport(“user32.dll”)] public static extern IntPtr GetWindowDC(IntPtr hWnd); [DllImport(“user32.dll”)] public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC); [DllImport(“gdi32.dll”)] public static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos); [DllImport(“user32.dll”, SetLastError = true)] public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect); [DllImport(“user32.dll”)] public static extern bool SetForegroundWindow(IntPtr hWnd); [StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left; public int Top; public int Right; public int Bottom; } [DllImport(“user32.dll”, CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)] public static extern void…

Accurately master .NET dependency injection: DI automatic registration service is easily handled

Accurately master .NET dependency injection: DI automatic registration service is easily handled Overview:.NET Dependency Injection (DI) automatically registers services through reflection. The example shows the registration of specified classes, classes with characteristics, and classes implemented by all interfaces under the project. Simplify configuration and improve maintainability. In .NET, automatic registration of dependency injection (DI) can be done through reflection mechanism and assembly scanning to fulfill. The following are detailed steps and corresponding C# source code examples, including registering specified classes, registering classes with custom attributes, and registering all classes with interface implementations under the project (all interfaces under the project): Step 1: Create interface and implementation classes //Interface 1 public interface IService1 { void PerformService1(); } //Interface 2 public interface IService2 { void PerformService2(); } // Implement class 1, implement IService1 public class MyService1 : IService1 { public void PerformService1() { Console.WriteLine(“Service 1 performed.”); } } // Implement class 2, implement IService2 [CustomRegistration] // With custom attributes public class MyService2 : IService2 { public void PerformService2() { Console.WriteLine(“Service 2 performed.”); } } // Implement class 3, implement IService1 and IService2 public class MyService3 : IService1, IService2 { public void PerformService1() { Console.WriteLine(“Service 3 (Service 1 part) performed.”); } public void…

Unit 11 Transactions and Locks

Unit 11 Transactions and Locks create database step2_unit13; go use step2_unit13; go — Create data table CREATE TABLE account ( id INT PRIMARY KEY identity, NAME VARCHAR(10 ), balance decimal(10 ,2) ); — Add data INSERT INTO account (NAME, balance) VALUES (‘Zhang San’, 1000), (‘李思’, 1000); 1. Application scenario description What is a transaction: In the actual development process, a business operation such as transfer often requires multiple access to the database can be completed. Transfer The account is that one user deducts money and another user adds money. If an exception occurs in one of the SQL statements, this SQL may fail to execute. Transaction execution is a whole, allSQL statements must be executed successfully. If an exception occurs in one SQL statement, all SQL statements must be rolled back , the entire business execution fails. Simulate Zhang San to transfer 500 yuan to Li Si. A transfer business operation requires at least the following 2 statements: Zhang San account number-500 Lee Si account +500 — Zhang San account-500 update account set balance = balance – 500 where name=’Zhang San’; –Li Si account +500 update account set balance = balance + 500 where name=’李思’; Suppose that when Zhang San’s…

Unit 12 `T-SQL` Programming

Unit 12 `T-SQL` Programming create database step2_unit12; go use step2_unit12; go — Department table CREATE TABLE [dbo].[Department]( [Id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL, [Name] [varchar](20) NULL ); — Position list CREATE TABLE [dbo].[Job]( [Id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL, [Name] [varchar](20) NULL ); — Personnel table CREATE TABLE [dbo].[person]( [Id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL, [Name] [varchar](50) NULL, [Sex] [varchar](10) NULL, [Age] [int] NULL ); — Salary table CREATE TABLE [dbo].[Salary]( [Id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL, [Sal] [money] NULL, [Comm] [money] NULL, [StaffId] [int] NULL ); — Employee table CREATE TABLE [dbo].[Staff]( [Id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL, [Name] [varchar](20) NOT NULL, [Hiredate] [datetime] NOT NULL, [DepartmentId] [int] NULL, [JobId] [int] NULL ); SET IDENTITY_INSERT [dbo].[Department] ON ​ INSERT [dbo].[Department] ([Id], [Name]) VALUES (1, N’Technical Department’) INSERT [dbo].[Department] ([Id], [Name]) VALUES (2, N’Human Resources Department’) INSERT [dbo].[Department] ([Id], [Name]) VALUES (3, N’Marketing Department’) SET IDENTITY_INSERT [dbo].[Department] OFF SET IDENTITY_INSERT [dbo].[Job] ON ​ INSERT [dbo].[Job] ([Id], [Name]) VALUES (1, N’Manager’) INSERT [dbo].[Job] ([Id], [Name]) VALUES (2, N’Team leader’) INSERT [dbo].[Job] ([Id], [Name]) VALUES (3, N’Employees’) SET IDENTITY_INSERT [dbo].[Job] OFF SET IDENTITY_INSERT[dbo].[person] ON ​ INSERT [dbo].[person] ([Id], [Name], [Sex], [Age]) VALUES ( 1, N’ Gao Yuanyuan’,…

Unit 13 Process Control and Functions

Unit 13 Process Control and Functions 1. Select structure If(…) Begin ​ statement block ​ End ​ else if span>(…) Begin ​ statement block ​ End ​ Else ​ Begin ​ statement block ​ End; Notes The syntax of begin..end is equivalent to {} in C# When there is only one execution statement, begin..end can be omitted () can be omitted, but if the condition contains a select statement, () cannot be omitted Use = in the database to indicate equality 2. Case structure — This syntax can only be used when the condition is to judge equality. case field when condition 1 then result when condition 2 then result else results end or case when condition 1 then result when condition 2 then result else results end example: selectId,NickName ,Mobile Age, case Sex when 0 then ‘ Male’Male span> when 1 then ‘ Female’ span> when 2 then ‘ Confidential’ span> when 3 then ‘ Unknown’ span> end gender from UserInfo select *, case when Age<=10 then ‘Childhood ‘ when Age between 11 and 25 then ‘ Teenager’ when Age between 26 and 40 then ‘ Youth’ when Age between 41 and 59 then ‘ Middle-aged’ else ‘Number BigInt…

Explain in detail the application of some advanced functions of Quartz.NET through examples. How much have you used?

Explain in detail the application of some advanced functions of Quartz.NET through examples. How much have you used?

Explain in detail the application of some advanced functions of Quartz.NET through examples. How much have you used? Quartz.NET is a powerful open source job scheduling library that provides many advanced features. The following are common advanced features of Quartz.NET: Cron expression trigger: Use Cron expressions to define flexible scheduling rules and implement complex time scheduling strategies. Job dependencies:Allows you to define dependencies between jobs, ensuring that they are executed in a specific order. Data transfer during job execution: When scheduling a job, parameters and data can be passed so that the job can obtain execution context information as needed. Global job listener: Add a global listener to monitor job execution life cycle events, such as before and after job execution, etc. Global trigger listener: Add a global listener to listen for trigger life cycle events, such as trigger firing, trigger completion, etc. Custom calendar:Customized calendar logic can be implemented, such as excluding specific dates or time periods, to meet business needs. Cluster mode: Allows Quartz.NET instances to be configured as clusters to implement distributed job scheduling and ensure high availability and load balancing. Persistent jobs: Quartz.NET provides job persistence support, which can store jobs and triggers in the database…

EF Core helps Xinchuang domestic database

EF Core helps Xinchuang’s domestic database Foreword As an important link in localization substitution, domestic databases have accelerated development under the guidance of my country’s Xinchuang Industrial Policy. Our domestic databases have entered a period of rapid development where a hundred flowers are blooming. I believe I am especially familiar with children’s shoes that come into contact with government projects. At the same time, some of us are also using various open source ORMs that have already supported mainstream domestic databases. Some of us are also using official EF Core but do not have unified management and management of domestic databases. Support, last year I wrote an article on how to use EF Core to adapt and support Renmin University of Finance and Economics. In this case, I will use my spare time at work to adapt it and open source it, so that everyone can contribute together Introduction to Renmin University of Finance and Economics and Huawei Gaussian Database The bottom layer of Renmin University of Finance and Economics and Huawei’s Gaussian database are both based on PostgreSQL. There will be no further elaboration on the features that will be added based on the database itself. You can go…

image

How to implement high-precision timer in .NET

How to implement high-precision timer in .NET The article How many kinds of timers are there in .NET introduced at least 6 kinds of timers in .NET, but the accuracy is not particularly high, generally between 15ms~55ms. In some special scenarios, a high-precision timer may be required, which requires us to implement it ourselves. This article will discuss ideas for implementing high-precision timers. High-precision timer A timer needs to consider at least three functions: timing, waiting, and trigger mode. Timing is used to check the time and adjust the waiting time; waiting is used to skip the specified time interval. The trigger mode specifies whether the time of each tick of the timer is fixed or the time interval of each scheduled task is fixed. For example, if the timer interval is 10ms and the scheduled task takes 7ms, should the scheduled task be triggered every 10ms, or should the scheduled task be executed and wait 10ms before triggering the next scheduled task. timing Windows provides APIs that can be used to obtain high-precision timestamps or measure time intervals. The system’s native API is QueryPerformanceCounter (QPC). The System.Diagnostics.Stopwatch class is provided in .NET to obtain high-precision timestamps. It also uses…

Lock, Monitor thread lock

Lock, Monitor thread lock Lock, Monitor thread lock Official website use https://learn.microsoft.com/zh-cn/dotnet/api/system.threading.monitor?view=net-8.0 一. Lock 1.1 Introduction The Lock keyword is actually a syntactic sugar. It encapsulates the Monitor object and adds a mutex lock to the object. When process A enters this code segment, it will add a mutex lock to the object object. At this time, other When process B enters this code segment, check whether the object object has a lock? If there is a lock, continue to wait for process A to finish running the code segment and unlock the object object, then process B can obtain the object object, lock it, and access the code segment. lock is syntactic sugar for Monitor 1.2 example lock example: private static object obj = new object(); lock (obj) { // code logic } 二. Monitor 2.1 Introduction Provides a mechanism for synchronous access to objects. 2.2 example Monitor example: private static object obj = new object(); try { Monitor.Enter(obj); // code logic } catch(Exception ex) { } finally { Monitor.Exit(obj); } The above two paragraphs of code have the same meaning But I prefer the Monitor way of writing, because it can be more flexible. 2.3 Example Environment: .net…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索