C#上位机软件支持中英文多语言切换MultiLanguage

news2024/11/26 0:33:16

最近遇到一个项目,客户是国外的,开发上位机程序是在中国。需支持中英文多语言切换。

多语言切换思路:

使用不同的xml配置文件来映射不同的语言,窗体加载时从默认语言DefaultLanguage.xml中读取配置,比如中文语言 对应Chinese.xml
英文语言 对应English.xml
比如一个Button控件 btnLogin,因某个窗体的某一个控件的变量名是绝对唯一的
我们可以通过键值对字典来进行处理,键名都是控件的变量名称,值为控件的文本内容
中文语言在Chinese.xml 设置Name="btnLogin" Text="登录"
英文语言在English.xml 设置Name="btnLogin" Text="Login"

我们以登录窗体FormLogin和主窗体FormMain为例,来进行多语言切换显示。

新建windows窗体应用程序MultiLanguageDemo,将默认的Form1修改为FormLogin

第一步,Language配置文件

在项目MultiLanguageDemo上新建文件夹Language,在Language文件夹下新建三个xml配置文件Chinese.xml,DefaultLanguage.xml,English.xml并将其【复制到输出目录】设置为【始终复制】

 ①Chinese.xml文件内容

<?xml version="1.0" encoding="utf-8" ?>
<Root Language="Chinese">
	<Form>
		<FormName Name="MultiLanguageDemo.FormLogin" Text="登录"></FormName>
		<Controls>
			<Control Name="label1" Text="语言"/>
			<Control Name="label2" Text="账号"/>
			<Control Name="label3" Text="密码"/>
			<Control Name="chkRememberUserName" Text="记住账号"/>
			<Control Name="chkDisplayPassword" Text="显示密码"/>
			<Control Name="btnLogin" Text="登录"/>
			<Control Name="btnClose" Text="关闭"/>
		</Controls>
	</Form>
	<Form>
		<FormName Name="MultiLanguageDemo.FormMain" Text="主页"></FormName>
		<Controls>
			<Control Name="label1" Text="这是主界面"/>
			<Control Name="groupBox1" Text="操作按钮"/>
			<Control Name="btnRun" Text="运行"/>
			<Control Name="btnStop" Text="停止"/>
		</Controls>
	</Form>
</Root>

 ②DefaultLanguage.xml文件内容

<?xml version="1.0" standalone="yes"?>
<Root Language="Default Language">
  <DefaultLanguage>Chinese</DefaultLanguage>
</Root>

 ③English.xml文件内容

<?xml version="1.0" encoding="utf-8" ?>
<Root Language="English">
	<Form>
		<FormName Name="MultiLanguageDemo.FormLogin" Text="Login Page"></FormName>
		<Controls>
			<Control Name="label1" Text="Language"/>
			<Control Name="label2" Text="UserName"/>
			<Control Name="label3" Text="Password"/>
			<Control Name="chkRememberUserName" Text="Remember User Name"/>
			<Control Name="chkDisplayPassword" Text="Show Password"/>
			<Control Name="btnLogin" Text="Login"/>
			<Control Name="btnClose" Text="Close"/>
		</Controls>
	</Form>
	<Form>
		<FormName Name="MultiLanguageDemo.FormMain" Text="Main Page"></FormName>
		<Controls>
			<Control Name="label1" Text="This is the homepage"/>
			<Control Name="groupBox1" Text="operating button"/>
			<Control Name="btnRun" Text="Run"/>
			<Control Name="btnStop" Text="Stop"/>
		</Controls>
	</Form>
</Root>

第二步,关键辅助类MultiLanguageUtil

用于读取默认语言并根据选择的语言设置窗体以及该窗体的所有控件的文本内容

MultiLanguageUtil.cs源程序如下

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;

namespace MultiLanguageDemo
{
    /// <summary>
    /// 多语言切换辅助类:
    /// 思路:使用不同的xml配置文件来映射不同的语言,窗体加载时从默认语言DefaultLanguage.xml中读取配置
    /// 中文语言 对应Chinese.xml
    /// 英文语言 对应English.xml
    /// 比如一个Button控件 btnLogin,因控件的变量名是绝对唯一的
    /// 我们可以通过键值对字典来进行处理,键名都是控件的变量名称,值为控件的文本内容
    /// 中文语言在Chinese.xml 设置Name="btnLogin" Text="登录"
    /// 英文语言在English.xml 设置Name="btnLogin" Text="Login"
    /// </summary>
    public class MultiLanguageUtil
    {
        /// <summary>
        /// 获取默认语言,从 Language\DefaultLanguage.xml 配置文件中读取
        /// </summary>
        /// <returns></returns>
        public static string GetDefaultLanguage()
        {
            string defaultLanguage = "English";
            XmlReader reader = new XmlTextReader($"{AppDomain.CurrentDomain.BaseDirectory}Language\\DefaultLanguage.xml");
            XmlDocument doc = new XmlDocument();
            doc.Load(reader);
            XmlNode root = doc.DocumentElement;
            //默认语言节点  
            XmlNode node = root.SelectSingleNode("DefaultLanguage");
            if (node != null)
            {
                defaultLanguage = node.InnerText;
            }
            reader.Close();
            reader.Dispose();
            return defaultLanguage;
        }

        /// <summary>
        /// 设置默认语言
        /// </summary>
        /// <param name="defaultLanguage"></param>
        public static void SetDefaultLanguage(string defaultLanguage)
        {
            DataSet ds = new DataSet();
            ds.ReadXml($"{AppDomain.CurrentDomain.BaseDirectory}Language\\DefaultLanguage.xml");
            DataTable dt = ds.Tables["Root"];
            dt.Rows[0]["DefaultLanguage"] = defaultLanguage;
            ds.AcceptChanges();
            ds.WriteXml($"{AppDomain.CurrentDomain.BaseDirectory}Language\\DefaultLanguage.xml");
        }

        /// <summary>
        /// 读取默认语言配置,将【key=控件名称,value=语言描述】添加到字典集合中
        /// </summary>
        /// <param name="formName"></param>
        /// <param name="language"></param>
        /// <returns></returns>
        public static Dictionary<string, string> ReadXMLText(Form form, string language)
        {
            string formName = form.GetType().ToString();
            try
            {
                Dictionary<string, string> dict = new Dictionary<string, string>();
                //判断是否存在该语言的配置文件
                if (!System.IO.File.Exists($"{AppDomain.CurrentDomain.BaseDirectory}Language\\{language}.xml"))
                {
                    return dict;
                }
                XmlReader reader = new XmlTextReader($"{AppDomain.CurrentDomain.BaseDirectory}Language\\{language}.xml");
                
                XmlDocument doc = new XmlDocument();
                doc.Load(reader);
                XmlNode root = doc.DocumentElement;
                //获取XML文件中对应该窗口的内容  
                XmlNode nodeFind = root.SelectSingleNode($"Form/FormName[@Name='{formName}']");
                if(nodeFind == null)
                {
                    //如果没有配置该窗体的语言描述,就返回空
                    return dict;
                }
                //添加窗体到字典中
                dict.Add(formName, nodeFind.SelectSingleNode("@Text").InnerText);
                XmlNodeList nodeList = nodeFind.ParentNode.SelectNodes("Controls/Control");
                foreach (XmlNode node in nodeList)
                {
                    //修改内容为控件的Text值  
                    XmlNode node1 = node.SelectSingleNode("@Name");
                    XmlNode node2 = node.SelectSingleNode("@Text");
                    if (node1 != null)
                    {
                        dict.Add(node1.InnerText, node2.InnerText);
                    }
                }
                reader.Close();
                reader.Dispose();
                return dict;
            }
            catch
            {
                return null;
            }
        }

        /// <summary>
        /// 设置窗体以及该窗体的所有控件的文本内容
        /// </summary>
        /// <param name="form">窗体</param>
        /// <param name="dict">键值对字典,键为控件名称,值为控件文本</param>
        public static void SetTextContentForAllControls(Form form, Dictionary<string, string> dict) 
        {
            string formName = form.GetType().FullName;
            if (dict.ContainsKey(formName)) 
            {
                //设置窗体的文本内容
                form.Text = dict[formName];
            }
            //设置所有控件的文本内容:只考虑已配置的控件 并且 在字典中存在的控件名称
            for (int i = 0; i < dict.Count; i++)
            {
                KeyValuePair<string, string> keyValuePair = dict.ElementAt(i);
                Control[] controls = form.Controls.Find(keyValuePair.Key, true);
                if (controls != null && controls.Length > 0)
                {
                    controls[0].Text = keyValuePair.Value;
                }
            }
        }

        /// <summary>
        /// 设置窗体以及该窗体的所有控件的文本内容
        /// </summary>
        /// <param name="form">窗体</param>
        /// <param name="language">语言标识:中文Chinese,英文English</param>
        public static void SetTextContentForAllControls(Form form, string language)
        {
            Dictionary<string, string> dict = ReadXMLText(form, language);
            SetTextContentForAllControls(form, dict);
        }
    }
}

第三步,登录窗体FormLogin和主窗体FormMain设计以及加载指定语言的文本

①窗体FormLogin设计器 FormLogin.Designer.cs代码如下:


namespace MultiLanguageDemo
{
    partial class FormLogin
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要修改
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.cboLanguage = new System.Windows.Forms.ComboBox();
            this.label2 = new System.Windows.Forms.Label();
            this.chkRememberUserName = new System.Windows.Forms.CheckBox();
            this.btnLogin = new System.Windows.Forms.Button();
            this.txtUserName = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.txtPassword = new System.Windows.Forms.TextBox();
            this.chkDisplayPassword = new System.Windows.Forms.CheckBox();
            this.btnClose = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(10, 16);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(29, 12);
            this.label1.TabIndex = 0;
            this.label1.Text = "语言";
            // 
            // cboLanguage
            // 
            this.cboLanguage.FormattingEnabled = true;
            this.cboLanguage.Location = new System.Drawing.Point(77, 13);
            this.cboLanguage.Name = "cboLanguage";
            this.cboLanguage.Size = new System.Drawing.Size(283, 20);
            this.cboLanguage.TabIndex = 1;
            this.cboLanguage.SelectedIndexChanged += new System.EventHandler(this.cboLanguage_SelectedIndexChanged);
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(10, 56);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(29, 12);
            this.label2.TabIndex = 2;
            this.label2.Text = "账号";
            // 
            // chkRememberUserName
            // 
            this.chkRememberUserName.AutoSize = true;
            this.chkRememberUserName.Location = new System.Drawing.Point(366, 58);
            this.chkRememberUserName.Name = "chkRememberUserName";
            this.chkRememberUserName.Size = new System.Drawing.Size(72, 16);
            this.chkRememberUserName.TabIndex = 3;
            this.chkRememberUserName.Text = "记住账号";
            this.chkRememberUserName.UseVisualStyleBackColor = true;
            // 
            // btnLogin
            // 
            this.btnLogin.Location = new System.Drawing.Point(207, 133);
            this.btnLogin.Name = "btnLogin";
            this.btnLogin.Size = new System.Drawing.Size(75, 23);
            this.btnLogin.TabIndex = 4;
            this.btnLogin.Text = "登录";
            this.btnLogin.UseVisualStyleBackColor = true;
            this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
            // 
            // txtUserName
            // 
            this.txtUserName.Location = new System.Drawing.Point(77, 53);
            this.txtUserName.Name = "txtUserName";
            this.txtUserName.Size = new System.Drawing.Size(283, 21);
            this.txtUserName.TabIndex = 5;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(10, 96);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(29, 12);
            this.label3.TabIndex = 6;
            this.label3.Text = "密码";
            // 
            // txtPassword
            // 
            this.txtPassword.Location = new System.Drawing.Point(77, 93);
            this.txtPassword.Name = "txtPassword";
            this.txtPassword.PasswordChar = '*';
            this.txtPassword.Size = new System.Drawing.Size(283, 21);
            this.txtPassword.TabIndex = 7;
            // 
            // chkDisplayPassword
            // 
            this.chkDisplayPassword.AutoSize = true;
            this.chkDisplayPassword.Location = new System.Drawing.Point(366, 98);
            this.chkDisplayPassword.Name = "chkDisplayPassword";
            this.chkDisplayPassword.Size = new System.Drawing.Size(72, 16);
            this.chkDisplayPassword.TabIndex = 8;
            this.chkDisplayPassword.Text = "显示密码";
            this.chkDisplayPassword.UseVisualStyleBackColor = true;
            this.chkDisplayPassword.CheckedChanged += new System.EventHandler(this.chkDisplayPassword_CheckedChanged);
            // 
            // btnClose
            // 
            this.btnClose.Location = new System.Drawing.Point(308, 133);
            this.btnClose.Name = "btnClose";
            this.btnClose.Size = new System.Drawing.Size(75, 23);
            this.btnClose.TabIndex = 9;
            this.btnClose.Text = "关闭";
            this.btnClose.UseVisualStyleBackColor = true;
            this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
            // 
            // FormLogin
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(562, 194);
            this.Controls.Add(this.btnClose);
            this.Controls.Add(this.chkDisplayPassword);
            this.Controls.Add(this.txtPassword);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.txtUserName);
            this.Controls.Add(this.btnLogin);
            this.Controls.Add(this.chkRememberUserName);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.cboLanguage);
            this.Controls.Add(this.label1);
            this.Name = "FormLogin";
            this.Text = "多语言切换示例";
            this.Load += new System.EventHandler(this.FormLogin_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.ComboBox cboLanguage;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.CheckBox chkRememberUserName;
        private System.Windows.Forms.Button btnLogin;
        private System.Windows.Forms.TextBox txtUserName;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.TextBox txtPassword;
        private System.Windows.Forms.CheckBox chkDisplayPassword;
        private System.Windows.Forms.Button btnClose;
    }
}

②窗体FormLogin.cs源程序如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MultiLanguageDemo
{
    public partial class FormLogin : Form
    {
        public FormLogin()
        {
            InitializeComponent();
            cboLanguage.Items.AddRange(new string[] 
            {
                "中文",
                "English"
            });
            cboLanguage.SelectedIndex = 0;
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        FormMain formMain;
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //设置默认语言
            MultiLanguageUtil.SetDefaultLanguage(cboLanguage.SelectedIndex == 0 ? "Chinese" : "English");
            if (formMain == null || formMain.IsDisposed)
            {
                formMain = new FormMain();
                formMain.Show();
            }
            else 
            {
                formMain.Activate();
            }
        }

        private void chkDisplayPassword_CheckedChanged(object sender, EventArgs e)
        {
            if (chkDisplayPassword.Checked)
            {
                txtPassword.PasswordChar = '\0';
            }
            else 
            {
                txtPassword.PasswordChar = '*';
            }
        }

        private void FormLogin_Load(object sender, EventArgs e)
        {
            string language = MultiLanguageUtil.GetDefaultLanguage();
            MultiLanguageUtil.SetTextContentForAllControls(this, language);
            if (language == "Chinese")
            {
                cboLanguage.SelectedIndex = 0;
            }
            else if (language == "English")
            {
                cboLanguage.SelectedIndex = 1;
            }
        }

        private void cboLanguage_SelectedIndexChanged(object sender, EventArgs e)
        {
            string language = string.Empty;
            if (cboLanguage.SelectedIndex == 0) 
            {
                language = "Chinese";
            }
            else if (cboLanguage.SelectedIndex == 1)
            {
                language = "English";
            }
            //过滤掉未选中语言
            if (cboLanguage.SelectedIndex >= 0) 
            {
                MultiLanguageUtil.SetTextContentForAllControls(this, language);
            }
        }
    }
}

③窗体设计器FormMain.Designer.cs源程序如下


namespace MultiLanguageDemo
{
    partial class FormMain
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.btnRun = new System.Windows.Forms.Button();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.btnStop = new System.Windows.Forms.Button();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font("宋体", 20F);
            this.label1.Location = new System.Drawing.Point(149, 52);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(147, 27);
            this.label1.TabIndex = 0;
            this.label1.Text = "这是主界面";
            // 
            // btnRun
            // 
            this.btnRun.Font = new System.Drawing.Font("宋体", 15F);
            this.btnRun.Location = new System.Drawing.Point(117, 29);
            this.btnRun.Name = "btnRun";
            this.btnRun.Size = new System.Drawing.Size(75, 50);
            this.btnRun.TabIndex = 1;
            this.btnRun.Text = "运行";
            this.btnRun.UseVisualStyleBackColor = true;
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.btnStop);
            this.groupBox1.Controls.Add(this.btnRun);
            this.groupBox1.Font = new System.Drawing.Font("宋体", 15F);
            this.groupBox1.Location = new System.Drawing.Point(75, 152);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(339, 100);
            this.groupBox1.TabIndex = 2;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "操作按钮";
            // 
            // btnStop
            // 
            this.btnStop.Font = new System.Drawing.Font("宋体", 15F);
            this.btnStop.Location = new System.Drawing.Point(229, 29);
            this.btnStop.Name = "btnStop";
            this.btnStop.Size = new System.Drawing.Size(75, 50);
            this.btnStop.TabIndex = 2;
            this.btnStop.Text = "停止";
            this.btnStop.UseVisualStyleBackColor = true;
            // 
            // FormMain
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(653, 382);
            this.Controls.Add(this.groupBox1);
            this.Controls.Add(this.label1);
            this.Name = "FormMain";
            this.Text = "主界面";
            this.Load += new System.EventHandler(this.FormMain_Load);
            this.groupBox1.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button btnRun;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.Button btnStop;
    }
}

④窗体FormMain.cs源程序如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MultiLanguageDemo
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void FormMain_Load(object sender, EventArgs e)
        {
            string language = MultiLanguageUtil.GetDefaultLanguage();
            MultiLanguageUtil.SetTextContentForAllControls(this, language);
        }
    }
}

第四步,程序运行多语言切换如图:

 

 

 

 

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

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

相关文章

计算机网络 day11 tcpdump - 传输层 - netstat - socket - nc - TCP/UDP头部

目录 故障排查 tcpdump抓包工具 传输层&#xff08;TCP和UDP协议&#xff09; 传输层的作用 应用程序和端口号有什么关系&#xff1f; 传输层端对端连接实现拓扑图 如何查看自己的linux机器开放了哪些端口&#xff1f; 1、netstat(network status 网络的状态) netsta…

CKE和RippleNet阅读

这两篇文章都是把KGC和推荐任务联合训练的。 CKE知识库嵌入向量COLLABORATIVE JOINT LEARNING RippleNetRipple Set偏好传播 CKE 作者提出了一种将协同过滤和知识库相结合的推荐系统。作者设计了三个组件&#xff0c;利用异构网络嵌入和深度学习嵌入方法&#xff0c;分别从知…

Java版Spring Cloud+Spring Boot+Mybatis+uniapp知识付费平台讲解

Java版知识付费-轻松拥有知识付费平台 多种直播形式&#xff0c;全面满足直播场景需求 公开课、小班课、独立直播间等类型&#xff0c;满足讲师个性化直播场景需求&#xff1b;低延迟、双向视频&#xff0c;亲密互动&#xff0c;无论是互动、答疑&#xff0c;还是打赏、带货、…

三菱PLC 单按钮启停

方法一思路&#xff1a;使用 ALT 交替输出指令交替输出 NO/OFF。 方法二思路&#xff1a;C0 计数器没计满时 Y1 ON&#xff0c;计满时 OFF。 方法三思路&#xff1a;使用 DIV 除法指令&#xff0c;将 DO 中的数据除以二取余数&#xff0c;余数等于0时 OFF&#xff0c;不等于0时…

【tio-websocket】7、什么是半包和粘包?

粘包和半包问题是数据传输中比较常见的问题,所谓的粘包问题是指数据在传输时,在一条消息中读取到了另一条消息的部分数据,这种现象就叫做粘包。比如发送了两条消息,分别为 “ABC” 和 “DEF”,那么正常情况下接收端也应该收到两条消息 “ABC” 和 “DEF”,但接收端却收到…

MySQL—变量、存储过程和函数(十一)

一、变量 1 变量的种类 1.1 系统变量 系统变量一共分为两种&#xff1a; 1&#xff09;全局变量 2&#xff09;会话变量 系统变量&#xff1a;变量由系统定义&#xff0c;不是用户定义&#xff0…

API 接口是什么?怎么对接 API?

一、API接口是什么&#xff1f; API接口即应用编程接口&#xff0c;是一些预先定义的函数&#xff0c;可以提供应用程序与开发人员基于某软件或硬件以访问一组例程的能力。简单来说&#xff0c;API接口相当于信息的桥梁&#xff0c;它可以让不同平台、应用程序或系统共享数据&…

【JavaEE】Spring的开发要点总结(1)

Spring的开发要点总结 文章目录 【JavaEE】Spring的开发要点总结&#xff08;1&#xff09;1. DI 和 DL1.1 DI 依赖注入1.2 DL 依赖查询1.3 DI 与 DL的区别1.4 IoC 与 DI/DL 的区别 2. Spring项目的创建2.1 创建Maven项目2.2 设置国内源2.2.1 勾选2.2.2 删除本地jar包2.2.3 re…

战略、组织、人才和生态,数字化转型如何破局?

导语 |在数字科技时代&#xff0c;企业在进行数字化转型时&#xff0c;面对快速变化的市场环境&#xff0c;在顶层设计、组织模式、人才模型以及合作生态等方面应如何调整以突出重围&#xff0c;获得长远发展&#xff1f;今天&#xff0c;我们特邀了旭辉集团副总裁兼首席数字官…

zabbix 企业级级监控(2) 监控linux主机

目录 配置开始 Zabbix添加linux主机 4.为agent.zabbix.com添加模板 环境&#xff1a; &#xff08;隔天做的更换了IP&#xff0c;不影响实际操作&#xff09; IP 192.168.50.50 关闭防火墙规则 更改主机名 [rootlocalhost ~]# vim /etc/hostname agent.zabbix.com [rootloca…

C 知识积累 替换gets函数 Linux C 语法分析 switch和if else的比较

目录 替换gets函数gets()用处gets()的危险之处gets()的几种替代方法一、用%c循环输入直到遇到换行结束二、用getchar()循环输入直到遇到换行结束三、scanf的另一种用法四、c中的getline()方法五、解决方案使用fgets代替 回车与换行一.知其然二.知其所以然 关键字&#xff0c;操…

餐饮业油烟在线监测系统的具体应用 安科瑞 许敏

摘要&#xff1a;本文利用物联网技术&#xff0c;构建了一套餐饮企业智能油烟在线监测系统&#xff0c;该系统前台由厨房端和管道端组成&#xff0c;通过网关接入云平台管理系统&#xff0c;实时监控烟道阀门的启闭、变频风机的启停与风速及功率调节、油烟浓度数据等。结合动态…

SpringAMQP使用

说明&#xff1a;SpringAMQP&#xff08;官网&#xff1a;https://spring.io/projects/spring-amqp&#xff09;是基于RabbitMQ封装的一套模板&#xff0c;并利用了SpringBoot对其实现了自动装配&#xff0c;使用起来非常方便。安装和原始使用参考&#xff1a;http://t.csdn.cn…

Python(二十二)运算符——算术运算符

❤️ 专栏简介&#xff1a;本专栏记录了我个人从零开始学习Python编程的过程。在这个专栏中&#xff0c;我将分享我在学习Python的过程中的学习笔记、学习路线以及各个知识点。 ☀️ 专栏适用人群 &#xff1a;本专栏适用于希望学习Python编程的初学者和有一定编程基础的人。无…

centos7.6下安装mysql

1.下载yum源&#xff1a; wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm2.执行安装&#xff1a; rpm -ivh mysql80-community-release-el7-5.noarch.rpm3.开始安装 yum install -y mysql-server4.启动mysql服务 systemctl start mysqld5.查看…

JavaWeb课程设计项目实战(03)——开发准备工作

版权声明 本文原创作者&#xff1a;谷哥的小弟作者博客地址&#xff1a;http://blog.csdn.net/lfdfhl 在正式进入项目开发之前请先完成以下准备工作。 数据库语句 请创建数据库和表并完成数据初始化工作。 初始化数据库 请在MySQL数据库中创建名为studentinformationmanag…

Vue-组件基础(下)

一、目标 能够知道如何对props进行验证能够知道如何使用计算属性能够知道如何为组件自定义事件能够知道如何在组件上使用v-model 二、目录 props验证计算属性自定义事件组件上的v-model任务列表案例 props验证 1.什么是props验证 指的是&#xff1a;在封装组件时对外界传递…

关于GPT、AI绘画、AI提词器等AI技术的探讨

目前的AI潮流非常火热&#xff0c;CHATGPT可谓是目前大模型人工智能的代表&#xff0c;刚开始听说chatGPT可以写代码&#xff0c;写作&#xff0c;写方案&#xff0c;无所不能。还有AI绘画也很&#xff2e;&#xff22;作为一个程序员&#xff0c;为了体验这些&#xff21;&…

医院检验科LIS系统源码 检验申请、标本编号、联机采集、中文报告单的生成与打印、质控图的绘制和数据的检索与备份

LIS通过将所有仪器自身提供的端口与科室LIS系统中的工作站点连接&#xff0c;通过LIS实现与医院HIS系统的联网。是一套符合医院检验科实际需要的管理系统&#xff0c;实现检验业务全流程的计算机管理。从检验申请、标本编号、联机采集、中文报告单的生成与打印、质控图的绘制和…

基于微信小程序的求职招聘系统设计与实现(Java+spring boot+MySQL+微信小程序)

获取源码或者论文请私信博主 演示视频&#xff1a; 基于微信小程序的求职招聘系统设计与实现&#xff08;Javaspring bootMySQL微信小程序&#xff09; 使用技术&#xff1a; 前端&#xff1a;html css javascript jQuery ajax thymeleaf 微信小程序 后端&#xff1a;Java s…