C#语言实例源码系列-实现IC卡的读写

news2024/10/5 13:38:42
专栏分享
  • 点击跳转=>Unity3D特效百例
  • 点击跳转=>案例项目实战源码
  • 点击跳转=>游戏脚本-辅助自动化
  • 点击跳转=>Android控件全解手册

👉关于作者

众所周知,人生是一个漫长的流程,不断克服困难,不断反思前进的过程。在这个过程中会产生很多对于人生的质疑和思考,于是我决定将自己的思考,经验和故事全部分享出来,以此寻找共鸣 !!!
专注于Android/Unity和各种游戏开发技巧,以及各种资源分享(网站、工具、素材、源码、游戏等)
有什么需要欢迎私我,交流群让学习不再孤单

在这里插入图片描述

👉实践过程

😜效果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

😜代码

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        lblTime.Text = DateTime.Now.ToString();//当进行考勤的时候在窗体中显示当前时间
        tsslTime.Text = DateTime.Now.ToString();//在任务栏中显示当前时间
    }

    private void 添加员工ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Form2 frm2 = new Form2();
        frm2.ShowDialog();
    }

    private void 系统信息ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        System.Diagnostics.Process.Start("MSINFO32.EXE");
    }

    private void 开始考勤ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        timer1.Start();//开始考勤
        panel1.Visible = true;//显示考勤界面
        timer2.Start();//开始显示当前时间
        开始考勤ToolStripMenuItem.Enabled = false;//禁用开始考勤菜单
    }

    int flag = -1;//设置的一个变量,用于控制一张IC卡只读取一次以及向数据库中只添加一次内容
    int flag2 = -1;//设置的一个变量,用于控制当某个IC卡已经参加考勤后,弹出一次错误提示
    private void timer1_Tick(object sender, EventArgs e)
    {
        int i = baseClass.ReadIC(txtICCard);//调用公共类中的ReadIC方法开始循环读取IC卡
        if (i == -1)//如果返回值是-1说明没有IC卡
        {
            //清空显示员工信息的文本框
            txtDept.Text = "";
            txtFolk.Text = "";
            txtICCard.Text = "";
            txtJob.Text = "";
            txtName.Text = "";
            txtSex.Text = "";
            groupBox1.Text = "考勤进行中";
            flag = -1;//初始化标记
            flag2 = -1;//初始化标记
        }
        else//如果有IC卡进行考勤
        {
            if (flag ==-1)//只有当flag为-1的时候执行
            {
                string icID = txtICCard.Text.Trim();//获取读取的IC卡编号
                if (baseClass.isCheck(icID))//isCheck方法判断是否参加过考勤
                {
                    if (flag2 == -1)//只有当flag2为-1的时候执行
                    {
                        flag2 = 0;//改变标记的值从而实现只弹出一次警告对话框
                        MessageBox.Show("已经参加过考勤!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //清空文本框
                        txtDept.Text = "";
                        txtFolk.Text = "";
                        txtICCard.Text = "";
                        txtJob.Text = "";
                        txtName.Text = "";
                        txtSex.Text = "";
                        txtICCard.Text = "";
                        groupBox1.Text = "考勤进行中";
                    }
                }
                else//如果没有参加过考勤
                {
                    //调用GetInfo方法获取IC卡对应的员工信息
                    baseClass.GetInfo(txtICCard.Text.Trim(), txtName, txtSex, txtJob, txtFolk, txtDept, groupBox1);
                    string name = txtName.Text.Trim();//员工姓名
                    string sex = txtSex.Text.Trim();//员工性别
                    string job = txtJob.Text.Trim();//员工职位
                    string folk = this.txtFolk.Text.Trim();//员工民族
                    string dept = txtDept.Text.Trim();//员工部门
                    //声明一个字符串,用于存储一条插入语句,实现将考勤信息插入到数据表中
                    string str = "insert into CheckNote(C_CardID,C_Name,C_Sex,C_Job,C_Folk,C_Dept,C_Time) values('" + icID + "','" + name + "','" + sex + "','" + job + "','" + folk + "','" + dept + "','" + DateTime.Now.ToShortDateString() + "')";
                    baseClass.ExecuteSQL(str);//ExecuteSQL方法执行SQL语句
                    tsslEinfo.Text = "已经有"+baseClass.GetNum(DateTime.Now.ToShortDateString())+"人参加考勤";
                }
            }
            flag = 0;//改变flag的值实现一张IC卡只存储一次信息

        }
    }

    private void 退出系统ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Application.Exit();
    }

    private void timer2_Tick(object sender, EventArgs e)
    {
        lblTime.Text = DateTime.Now.ToString();
    }

    private void 考勤结束ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        开始考勤ToolStripMenuItem.Enabled = true;
        panel1.Visible = false;
        timer1.Stop();
        timer2.Stop();
        tsslEinfo.Text = "";
    }

    private void 考勤记录ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Form3 frm3 = new Form3();
        frm3.ShowDialog();
    }

    private void timer3_Tick(object sender, EventArgs e)
    {
        tsslTime.Text = DateTime.Now.ToString();
    }

    private void 关于ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        AboutBox1 ab = new AboutBox1();
        ab.ShowDialog();
    }
}
 public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void Form2_Load(object sender, EventArgs e)
        {
            cbFolk.SelectedIndex = 0;//民族选项默认第一项被选中
            cbSex.SelectedIndex = 0;//性别选项默认第一项被选中
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (txtDept.Text == "" || txtICCard.Text == "" || txtJob.Text == "" || txtName.Text == "")
            {
                MessageBox.Show("请将信息输入完整!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string icID = txtICCard.Text.Trim();//要写入IC卡的数据
                string name = txtName.Text.Trim();//员工姓名
                string sex = cbSex.Text.Trim();//员工性别
                string job = txtJob.Text.Trim();//员工职位
                string folk= cbFolk.Text.Trim();//员工民族
                string dept = txtDept.Text.Trim();//员工部门
                if (baseClass.CheckID(icID))//CheckID方法检查编号是否存在
                {
                    MessageBox.Show("IC卡编号已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (baseClass.WriteIC(icID) == 0)//WriteIC方法将编号写入IC卡,如果成功则返回0
                    {
                        //声明一条语句,用于将员工其他信息插入到数据表中
                        string strSQL = "insert into Employee(CardID,E_Name,E_Sex,E_Job,E_Folk,E_Dept,E_Time) values('" + icID + "','" + name + "','" + sex + "','" + job + "','" + folk + "','" + dept + "','"+DateTime.Now.ToShortDateString()+"')";
                        if (baseClass.ExecuteSQL(strSQL))//ExecuteSQL方法执行这条语句
                        {
                            MessageBox.Show("IC卡注册完毕!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
        }

        private void txtICCard_TextChanged(object sender, EventArgs e)
        {
            if (Regex.IsMatch(txtICCard.Text.Trim(), "[\u4e00-\u9fa5]"))
            {
                MessageBox.Show("禁止输入汉字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
#region 使用动态链接库,声明方法
[StructLayout(LayoutKind.Sequential)]
public unsafe class IC
{
    //对设备进行初始化
    [DllImport("Mwic_32.dll", EntryPoint = "auto_init", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
    public static extern int auto_init(int port, int baud);
    //设备密码格式
    [DllImport("Mwic_32.dll", EntryPoint = "setsc_md", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
    public static extern int setsc_md(int icdev, int mode);
    //获取设备当前状态
    [DllImport("Mwic_32.dll", EntryPoint = "get_status", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
    public static extern Int16 get_status(int icdev, Int16* state);
    //关闭设备通讯接口
    [DllImport("Mwic_32.dll", EntryPoint = "ic_exit", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
    public static extern int ic_exit(int icdev);
    //使设备发出蜂鸣声
    [DllImport("Mwic_32.dll", EntryPoint = "dv_beep", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
    public static extern int dv_beep(int icdev, int time);
    //向IC卡中写数据
    [DllImport("Mwic_32.dll", EntryPoint = "swr_4442", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
    public static extern int swr_4442(int icdev, int offset, int len, char* w_string);
    //读取IC卡中数据
    [DllImport("Mwic_32.dll", EntryPoint = "srd_4442", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
    public static extern int srd_4442(int icdev, int offset, int len, char* r_string);
    //核对卡密码  
    [DllImport("Mwic_32.dll", EntryPoint = "csc_4442", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
    public static extern Int16 Csc_4442(int icdev, int len, [MarshalAs(UnmanagedType.LPArray)] byte[] p_string);
}
#endregion

class baseClass
{
    public static int WriteIC(string id)//写入IC卡的方法
    {
        int flag = -1;
        //初始化
        int icdev = IC.auto_init(0, 9600);
        if (icdev < 0)
            MessageBox.Show("端口初始化失败,请检查接口线是否连接正确。", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        int md = IC.setsc_md(icdev, 1); //设备密码格式
        unsafe
        {
            Int16 status = 0;
            Int16 result = 0;
            result = IC.get_status(icdev, &status);
            if (result != 0)
            {
                MessageBox.Show("设备当前状态错误!");
                int d1 = IC.ic_exit(icdev);   //关闭设备
            }
            if (status != 1)
            {
                MessageBox.Show("请插入IC卡");
                int d2 = IC.ic_exit(icdev);   //关闭设备
            }
        }
        unsafe
        {
            //卡的密码默认为6个F(密码为:ffffff),1个F的16进制是15,2个F的16进制是255。
            byte[] pwd = new byte[3] { 0xff, 0xff, 0xff };
            Int16 checkIC_pwd = IC.Csc_4442(icdev, 3, pwd);
            if (checkIC_pwd < 0)
            {
                MessageBox.Show("IC卡密码错误!");
            }
            char str = 'a';
            int write = -1;
            for (int j = 0; j < id.Length; j++)
            {
                str = Convert.ToChar(id.Substring(j, 1));
                write = IC.swr_4442(icdev, 33 + j, id.Length, &str);
            }
            if (write == 0)
            {
                flag = write;
                int beep = IC.dv_beep(icdev, 20);  //发出蜂鸣声
            }
            else
                MessageBox.Show("数据写入IC卡失败!");
        }
        int d = IC.ic_exit(icdev);  //关闭设备
        return flag;
    }

    public static int ff = -1;
    public static int ReadIC(TextBox tb)//读取IC卡
    {
        int flag = -1;
        //初始化
        int icdev = IC.auto_init(0, 9600);
        if (icdev < 0)
            MessageBox.Show("端口初始化失败,请检查接口线是否连接正确。", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        int md = IC.setsc_md(icdev, 1); //设备密码格式
        unsafe
        {
            Int16 status = 0;
            Int16 result = 0;
            result = IC.get_status(icdev, &status);
            if (result != 0)
            {
                MessageBox.Show("设备当前状态错误!");
                int d1 = IC.ic_exit(icdev);   //关闭设备
            }

            if (status != 1)
            {
                ff = -1;
                int d2 = IC.ic_exit(icdev);   //关闭设备
            }
        }
        unsafe
        {
            char str;
            int read = -1;
            string ic = "";
            for (int j = 0; j < 6; j++)
            {
                read = IC.srd_4442(icdev, 33 + j, 1, &str);
                ic = ic + Convert.ToString(str);
            }
            tb.Text = ic;
            if (ff == -1)
            {
                int i = IC.dv_beep(icdev, 10);  //发出蜂鸣声
            }
            if (read == 0)
            {
                ff = 0;
                flag = read;
            }
        }
        int d = IC.ic_exit(icdev);  //关闭设备
        return flag;
    }

    public static bool ExecuteSQL(string sql)//执行SQL语句
    {
        bool flag = false;
        string strg = Application.StartupPath.ToString();
        strg = strg.Substring(0, strg.LastIndexOf("\\"));
        strg = strg.Substring(0, strg.LastIndexOf("\\"));
        strg += @"\db1.mdb";
        OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + strg);
        conn.Open();
        OleDbCommand cmd = new OleDbCommand(sql, conn);
        int i = cmd.ExecuteNonQuery();
        if (i > 0)
        {
            flag = true;
            conn.Close();
        }
        return flag;
    }

    public static bool CheckID(string id)//判断输入的IC卡号是否已经存在
    {
        bool flag = false;
        string strg = Application.StartupPath.ToString();
        strg = strg.Substring(0, strg.LastIndexOf("\\"));
        strg = strg.Substring(0, strg.LastIndexOf("\\"));
        strg += @"\db1.mdb";
        OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + strg);
        conn.Open();
        OleDbCommand cmd = new OleDbCommand("select Count(*) from Employee where CardID='"+id+"'", conn);
        int i = Convert.ToInt32(cmd.ExecuteScalar());
        conn.Close();
        if (i > 0)
        {
            flag = true;
        }
        return flag;
    }

    public static void GetInfo(string id,TextBox name,TextBox sex,TextBox job,TextBox folk,TextBox dept,GroupBox gb)//根据IC卡号获取相应的信息
    {
        if (CheckID(id))
        {
            string strg = Application.StartupPath.ToString();
            strg = strg.Substring(0, strg.LastIndexOf("\\"));
            strg = strg.Substring(0, strg.LastIndexOf("\\"));
            strg += @"\db1.mdb";
            OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + strg);
            conn.Open();
            OleDbCommand cmd = new OleDbCommand("select * from Employee where CardID='" + id + "'", conn);
            OleDbDataReader sdr = cmd.ExecuteReader();
            sdr.Read();
            name.Text = sdr["E_Name"].ToString();
            sex.Text = sdr["E_Sex"].ToString();
            job.Text = sdr["E_Job"].ToString();
            folk.Text = sdr["E_Folk"].ToString();
            dept.Text = sdr["E_Dept"].ToString();
            gb.Text = "考勤进行中(考勤成功)";
            sdr.Close();
            conn.Close();
        }
        else
        {
            gb.Text = "考勤进行中(此IC卡未被注册!)";
        }
    }

    public static void ExportData(DataGridView srcDgv, string fileName)//导出数据,传入一个datagridview和一个文件路径
    {

        string type = fileName.Substring(fileName.IndexOf(".") + 1);//获得数据类型
        if (type.Equals("xls", StringComparison.CurrentCultureIgnoreCase))//Excel文档
        {
            Excel.Application excel = new Excel.Application();
            try
            {
                excel.DisplayAlerts = false;
                excel.Workbooks.Add(true);
                excel.Visible = false;

                for (int i = 0; i < srcDgv.Columns.Count; i++)//设置标题
                {
                    excel.Cells[2, i + 1] = srcDgv.Columns[i].HeaderText;
                }

                for (int i = 0; i < srcDgv.Rows.Count; i++)//填充数据
                {
                    for (int j = 0; j < srcDgv.Columns.Count; j++)
                    {
                        if (srcDgv[j, i].ValueType.ToString() == "System.Byte[]")
                        {
                            excel.Cells[i + 3, j + 1] = "System.Byte[]";
                        }
                        else
                        {
                            excel.Cells[i + 3, j + 1] = srcDgv[j, i].Value;
                        }
                    }
                }

                excel.Workbooks[1].SaveCopyAs(fileName);//保存
            }
            finally
            {
                excel.Quit();
            }
            return;
        }
        //保存Word文件
        if (type.Equals("doc", StringComparison.CurrentCultureIgnoreCase))
        {

            object path = fileName;
            Object none = System.Reflection.Missing.Value;
            Word.Application wordApp = new Word.Application();
            Word.Document document = wordApp.Documents.Add(ref none, ref none, ref none, ref none);
            //建立表格
            Word.Table table = document.Tables.Add(document.Paragraphs.Last.Range, srcDgv.Rows.Count + 1, srcDgv.Columns.Count, ref none, ref none);
            try
            {

                for (int i = 0; i < srcDgv.Columns.Count; i++)//设置标题
                {
                    table.Cell(1, i + 1).Range.Text = srcDgv.Columns[i].HeaderText;
                }

                for (int i = 0; i < srcDgv.Rows.Count; i++)//填充数据
                {
                    for (int j = 0; j < srcDgv.Columns.Count; j++)
                    {
                        string a = srcDgv[j, i].ValueType.ToString();
                        if (a == "System.Byte[]")
                        {
                            PictureBox pp = new PictureBox();
                            byte[] pic = (byte[])(srcDgv[j, i].Value); //将数据库中的图片转换成二进制流
                            MemoryStream ms = new MemoryStream(pic);	//将字节数组存入到二进制流中
                            pp.Image = Image.FromStream(ms);           //二进制流Image控件中显示
                            pp.Image.Save(@"C:\22.bmp");               //将图片存入到指定的路径
                            object aaa = table.Cell(i + 2, j + 1).Range;
                            wordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            wordApp.Selection.InlineShapes.AddPicture(@"C:\22.bmp", ref none, ref none, ref aaa);
                            pp.Dispose();
                        }
                        else
                        {
                            table.Cell(i + 2, j + 1).Range.Text = srcDgv[j, i].Value.ToString();
                        }
                    }
                }
                document.SaveAs(ref path, ref none, ref none, ref none, ref none, ref none, ref none, ref none, ref none, ref none, ref none);
                document.Close(ref none, ref none, ref none);
                if (File.Exists(@"C:\22.bmp"))
                {
                    File.Delete(@"C:\22.bmp");
                }
            }
            finally
            {
                wordApp.Quit(ref none, ref none, ref none);
            }
        }
    }

    public static void BinddataGridView(DataGridView dg, string datetime)
    {
        string strg = Application.StartupPath.ToString();
        strg = strg.Substring(0, strg.LastIndexOf("\\"));
        strg = strg.Substring(0, strg.LastIndexOf("\\"));
        strg += @"\db1.mdb";
        OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + strg);
        conn.Open();
        string str = "select C_CardID as IC卡编号,C_Name as 员工姓名,C_Sex as 性别,C_Job as 职位,C_Folk as 民族,C_Dept as 员工部门,C_Time as 考勤日期 from CheckNote where C_Time='" + datetime + "'";
        OleDbDataAdapter da = new OleDbDataAdapter(str, conn);
        System.Data.DataTable dt = new System.Data.DataTable();
        da.Fill(dt);
        dg.DataSource = dt;
        dg.Columns[0].Width = 80;
        dg.Columns[1].Width = 80;
        dg.Columns[2].Width = 60;
        dg.Columns[3].Width = 60;
        dg.Columns[4].Width = 60;
        dg.Columns[5].Width = 80;
        dg.Columns[6].Width = 80;
        conn.Close();
    }

    public static bool isCheck(string id)//检查是否已经参加过考勤
    {
        bool flag = false;
        string strg = Application.StartupPath.ToString();
        strg = strg.Substring(0, strg.LastIndexOf("\\"));
        strg = strg.Substring(0, strg.LastIndexOf("\\"));
        strg += @"\db1.mdb";
        OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + strg);
        conn.Open();
        OleDbCommand cmd = new OleDbCommand("select Count(*) from CheckNote where C_CardID='" + id + "'", conn);
        int i = Convert.ToInt32(cmd.ExecuteScalar());
        conn.Close();
        if (i > 0)
        {
            flag = true;
        }
        return flag;
    }

    public static int GetNum(string datetime)//获取所有参加考勤的人数
    {
        string strg = Application.StartupPath.ToString();
        strg = strg.Substring(0, strg.LastIndexOf("\\"));
        strg = strg.Substring(0, strg.LastIndexOf("\\"));
        strg += @"\db1.mdb";
        OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + strg);
        conn.Open();
        OleDbCommand cmd = new OleDbCommand("select Count(*) from CheckNote where C_Time='" + datetime + "'", conn);
        int i = Convert.ToInt32(cmd.ExecuteScalar());
        conn.Close();
        return i;
    }
}

需要的再直接Call我下方卡片,直接发。

👉其他

📢作者:小空和小芝中的小空
📢转载说明-务必注明来源:https://zhima.blog.csdn.net/
📢这位道友请留步☁️,我观你气度不凡,谈吐间隐隐有王者霸气💚,日后定有一番大作为📝!!!旁边有点赞👍收藏🌟今日传你,点了吧,未来你成功☀️,我分文不取,若不成功⚡️,也好回来找我。

温馨提示点击下方卡片获取更多意想不到的资源。
空名先生

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/135486.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

机器学习:通俗理解马尔科夫随机场(MRF)及其应用(附例题)

目录0 写在前面1 无向概率图2 马尔科夫随机场3 马尔科夫独立性4 例题分析0 写在前面 机器学习强基计划聚焦深度和广度&#xff0c;加深对机器学习模型的理解与应用。“深”在详细推导算法模型背后的数学原理&#xff1b;“广”在分析多个机器学习模型&#xff1a;决策树、支持…

Git使用,在github中创建仓库

一.本地生成密钥&#xff1a; ssh-keygen //生成密钥 cat id_rsa.pub # 查看公钥 查看公钥&#xff0c;并将公钥添加到github的服务器上 二.创建文件&#xff0c;并且将文件上传到GitHub 设置全局用户信息&#xff1a; git config --global user.name dwerrwgit config…

LabVIEW NI数字万用表与开关握手扫描速率

LabVIEW NI数字万用表与开关握手扫描速率 在决定需要哪些设备来满足系统要求时&#xff0c;对扫描速率数据进行基准测试非常有用。数字万用表&#xff08;DMM&#xff09;和开关系统也是如此&#xff0c;因为扫描速率取决于数字万用表、开关和它们之间的触发器的速度。本文包含…

高并发系统设计 -- 抢红包设计

抢红包的业务分析 可以明显的看到打开了红包不一定可以抢到。这样做的好处是&#xff1a; 符合现实生活逻辑&#xff0c;有仪式感防止误领&#xff0c;发现不对劲可以马上退出流程拆的长一些&#xff0c;平摊高并发下的压力 预拆包&#xff1a;我在发红包的时候&#xff0c;就…

ansible的静态清单配置文件

清单文件 定义主机清单文件 清单中定义ansible将要管理的一批主机&#xff0c;这些主机也可以分配到组中&#xff0c;以进行集中管理。组中也可以包含子组&#xff0c;一台主机也可以是多个组中的成员。清单还可以设置应用到它所定义的主机和组的变量。 编写主机清单文件 主机…

归置归置,我的 2022

J3code杂文&#xff08;程序人生 # 年终总结&#xff09; 记得 2021 年我没有进行年终总结&#xff0c;也就没有发出过相关的内容出来。总结原因就是一个&#xff0c;躺平了&#xff0c;自毕业换工作之后&#xff0c;就一直在适应工作环境与生活环境中默默的度过了 2021 年。 …

你真的懂树吗?二叉树、AVL平衡二叉树、伸展树、B-树和B+树原理和实现代码详解...

树&#xff08;Tree&#xff09;是一种相当灵活的数据结构&#xff08;上一节已经详细讲解了基本的数据结构&#xff1a;线性表、栈和队列&#xff09;&#xff0c;你可能接触过二叉树&#xff0c;但是树的使用并不限于此&#xff0c;从简单的使用二叉树进行数据排序&#xff0…

(深度学习快速入门)第三章第一节:多层感知器简介

文章目录一&#xff1a;引入二&#xff1a;定义三&#xff1a;反向传播算法四&#xff1a;构建多层感知器完成波士顿房价预测一&#xff1a;引入 前文所讲到的波士顿房价预测案例中&#xff0c;涉及到的仅仅是一个非常简单的神经网络&#xff0c;它只含有输入层和输出层 但观…

vue3 antd项目实战——Form表单的重置与清空【resetFields重置表单未生效(手写重置函数)】

vue3 antd项目实战——resetFields重置表单无效【手写重置函数重置表单数据】关于form表单的文章合集场景复现原因分析解决方案(手写清空函数)关于form表单的文章合集 文章内容文章链接Form表单提交和校验https://blog.csdn.net/XSL_HR/article/details/128495087?spm1001.20…

面向对象定义一个hero类

问题定义一个hero类&#xff0c;属性有power&#xff0c;name&#xff0c;分别代表体力值和英雄的名字&#xff0c;体力值默认为100&#xff1b;方法有&#xff1a;1.行走的方法如果体力值为0&#xff0c;则输出不能行走&#xff0c;此英雌已死亡的信息&#xff1b;2.吃的方法&…

双非二本、已获HCIA认证的大二学生与C站相遇的2022

目录 前言 2022年1月、2月——迷茫 2022年3月~6月——调整规划 ​2022年7月——在CSDN发布第一篇博客 2022年8月——步入正轨&#xff0c;获得2022谷歌开发者大会入场名额 2022年9月~10月——开学季&#xff0c;收获季 2022年11月——第一次接触项目并去公司学习实践&…

01通信/协议一些简要概念

通信的目的 将一个设备的数据传送到另一个设备&#xff0c;扩展硬件系统。 通信协议 制定通信的规则&#xff0c;通信双方按照协议规则进行数据收发。 每一种通讯协议都有硬件与软件上的要求。 常见的协议 USART TX、RX 全双工 异步 单端 点对点 I2C SCL、SDA 半双…

百度大规模知识图谱构建及技术应用实践

省时查报告-专业、及时、全面的行研报告库省时查方案-专业、及时、全面的营销策划方案库【免费下载】2022年11月份热门报告盘点罗振宇2023年跨年演讲PPT原稿2023年&#xff0c;如何科学制定年度规划&#xff1f;《底层逻辑》高清配图‍基于深度学习的个性化推荐系统实时化改造与…

【Node.js实战】一文带你开发博客项目之登录(对接完毕,cookie、session、redis各司其职)

个人简介 &#x1f440;个人主页&#xff1a; 前端杂货铺 &#x1f64b;‍♂️学习方向&#xff1a; 主攻前端方向&#xff0c;也会涉及到服务端 &#x1f4c3;个人状态&#xff1a; 在校大学生一枚&#xff0c;已拿多个前端 offer&#xff08;秋招&#xff09; &#x1f680;未…

【蓝桥杯选拔赛真题54】Scratch小猫钓鱼 少儿编程scratch图形化编程 蓝桥杯选拔赛真题讲解

目录 scratch小猫钓鱼 一、题目要求 编程实现 二、案例分析 1、角色分析

河道船只识别系统 yolov5

河道船只识别系统通过Python基于YOLOv5深度学习框架模型技术对画面中船只进行监测&#xff0c;如识别到有船只违规行为&#xff0c;立即抓拍告警同步回传给平台。YOLOv5是一种单阶段目标检测算法&#xff0c;该算法在YOLOv4的基础上添加了一些新的改进思路&#xff0c;使其速度…

写了个自动巡检多个接口地址的脚本!

作者&#xff1a;JackTian 来源&#xff1a;公众号「杰哥的IT之旅」 ID&#xff1a;Jake_Internet 转载请联系授权&#xff08;微信ID&#xff1a;Hc220088&#xff09; 原文链接&#xff1a;写了个自动巡检多个接口地址的脚本&#xff01; 没错&#xff0c;这次我结合工作运用…

【C语言】你对动态内存分配有多少了解呢

&#x1f3d6;️作者&#xff1a;malloc不出对象 ⛺专栏&#xff1a;《初识C语言》 &#x1f466;个人简介&#xff1a;一名双非本科院校大二在读的科班编程菜鸟&#xff0c;努力编程只为赶上各位大佬的步伐&#x1f648;&#x1f648; 目录前言一、什么是动态内存分配二、为什…

SpringBoot(二)【学习笔记】

SpringBoot的配置文件 之前SSM项目: 每一个框架都有自己的配置文件, 每一个配置文件头文件不一样, 需要找到每个框架的头文件 SpringBoot的配置文件: 所有的框架的配置项,都可以在application.properties文件配置, 如果自定义一些配置, 修改SpringBoot默认的配置项, 可以在appl…

JAVA语言程序设计基础入门技术教程

JAVA语言程序设计基础 第一章&#xff1a;JAVA入门基础–开山篇 视频&#xff1a;https://edu.csdn.net/course/detail/8034 前言&#xff1a;什么是java 是咖啡飘香的清晨是斯坦福校园意浓情深是James的思想睿智是剁手党双十一挥舞的利刃是大数据服务的平台是春运时节那期…