当前位置:网站首页>C import Xls data method summary IV (upload file de duplication and database data De duplication)
C import Xls data method summary IV (upload file de duplication and database data De duplication)
2022-07-04 01:11:00 【Xiao Zhong wants to learn!!!】
C# Import .xls Data method summary IV ( Upload file and database data deduplication )
One 、 Imported data De duplication
1.1、 Redeclare a studentVo Object list records data
// Place data in myListStudentVo China and listStudentVo Compare the data in
List<studentVo> myListStudentVo = new List<studentVo>();
1.2、 Cycle the total number of uploaded data for de duplication
listStudentVo The data has been written in the previous article , Get the object of each piece of data circularly and connect it with the newly created myListStudentVo Object for a comparison , You can achieve a weight removal effect
// Judge whether there are duplicates in the information imported into students
for (int i = 0; i < listStudentVo.Count; i++)
{
if (i != 0)
{
for (int j = 0; j < myListStudentVo.Count; j++)
{
if (listStudentVo[i].StudentIDNum.Trim() == myListStudentVo[j].StudentIDNum.Trim() ||
listStudentVo[i].StudentNumber.Trim() == myListStudentVo[j].StudentNumber.Trim() ||
listStudentVo[i].UniformAuthenticationCode.Trim() == myListStudentVo[j].UniformAuthenticationCode.Trim())
{
returnJson.Text = string.Format("Excel Page in the table {0} Duplicate data with other data ,<br> Please check the ID number. 、 Student number and unified authentication code !", i + 1);
return Json(returnJson, JsonRequestBehavior.AllowGet);
}
}
myListStudentVo.Add(listStudentVo[i]);
}
else
{
// The first data is directly put into myListStudentVo in
myListStudentVo.Add(listStudentVo[0]);
}
}
Two 、 De duplication with the data in the database
2.1、 First go back to the data list in the database
// Query student table & Data from user tables
List<PW_Student> dbListStudent = myModel.PW_Student.ToList();
List<PW_User> dbListUser = myModel.PW_User.ToList();
2.2、 Circularly processed listStudentVo Total times
The main i The idea is to make a list of the above query database, such as the list of files to be added 【 equal 】 operation , The same return true If it is repeated, it will prompt the uploader where the data is repeated
// Judge whether the imported data is duplicate with the data in the database
// Traverse imported data
for (int n = 0; n < listStudentVo.Count; n++)
{
// Traverse database student data
for (int m = 0; m < dbListStudent.Count; m++)
{
if (listStudentVo[n].StudentIDNum == dbListStudent[m].StudentIDNum ||
listStudentVo[n].StudentNumber == dbListStudent[m].StudentNumber)
{
returnJson.Text = string.Format("Excel Page in the table {0} Duplicate student data and database data ,<br> Please check the ID card number and student ID number. !", n + 1);
return Json(returnJson, JsonRequestBehavior.AllowGet);
}
}
// Traverse database user data
for (int k = 0; k < dbListUser.Count; k++)
{
if (listStudentVo[n].UniformAuthenticationCode == dbListUser[k].UniformAuthenticationCode)
{
returnJson.Text = string.Format("Excel Page in the table {0} Student authentication codes already exist , Please check !", n + 1);
return Json(returnJson, JsonRequestBehavior.AllowGet);
}
}
}
边栏推荐
- MPLS experiment
- Analysis and solution of lazyinitializationexception
- Luogu p1309 Swiss wheel
- [common error] custom IP instantiation error
- The first training of wechat applet
- Function: store the strings entered in the main function in reverse order. For example, if you input the string "ABCDEFG", you should output "gfedcba".
- 2-redis architecture design to use scenarios - four deployment and operation modes (Part 2)
- 不得不会的Oracle数据库知识点(二)
- It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction
- 手机异步发送短信验证码解决方案-Celery+redis
猜你喜欢

Huawei BFD and NQA

MySQL - use of aggregate functions and group by groups

中电资讯-信贷业务数字化转型如何从星空到指尖?

Technical practice online fault analysis and solutions (Part 1)
![[error record] configure NDK header file path in Visual Studio](/img/9f/89f68c037dcf68a31a2de064dd8471.jpg)
[error record] configure NDK header file path in Visual Studio

It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction

Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing

CLP information - how does the digital transformation of credit business change from star to finger?

Analysis and solution of lazyinitializationexception

Since the "epidemic", we have adhered to the "no closing" of data middle office services
随机推荐
打印菱形图案
Is it really possible that the monthly salary is 3K and the monthly salary is 15K?
OS interrupt mechanism and interrupt handler
数据库表外键的设计
Future源码一观-JUC系列
gslb(global server load balance)技术的一点理解
12. Go implementation of integer to Roman numeral and leetcode
Swagger2 quick start and use
A dichotomy of Valentine's Day
AI helps make new breakthroughs in art design plagiarism retrieval! Professor Liu Fang's team paper was employed by ACM mm, a multimedia top-level conference
中电资讯-信贷业务数字化转型如何从星空到指尖?
Since the "epidemic", we have adhered to the "no closing" of data middle office services
技術實踐|線上故障分析及解决方法(上)
【.NET+MQTT】.NET6 环境下实现MQTT通信,以及服务端、客户端的双边消息订阅与发布的代码演示
Leetcode 121 best time to buy and sell stock (simple)
Release and visualization of related data
我管你什么okr还是kpi,PPT轻松交给你
1-Redis架构设计到使用场景-四种部署运行模式(上)
MySQL - use of aggregate functions and group by groups
PMP 考试常见工具与技术点总结