基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -0,0 +1,397 @@
|
||||
namespace lserp_UpdateDepart
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <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.panel1 = new System.Windows.Forms.Panel();
|
||||
this.panel3 = new System.Windows.Forms.Panel();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.txt_DataBase = new System.Windows.Forms.TextBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.txt_serverName = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.suspendedButton = new System.Windows.Forms.Button();
|
||||
this.startButton = new System.Windows.Forms.Button();
|
||||
this.btn_ToConfig = new System.Windows.Forms.Button();
|
||||
this.txt_Key = new System.Windows.Forms.TextBox();
|
||||
this.label9 = new System.Windows.Forms.Label();
|
||||
this.txt_Deptnumber = new System.Windows.Forms.TextBox();
|
||||
this.txt_timer = new System.Windows.Forms.TextBox();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.txt_port = new System.Windows.Forms.TextBox();
|
||||
this.txt_domainN = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.txtLog = new System.Windows.Forms.TextBox();
|
||||
this.txt_LoginAccount = new System.Windows.Forms.TextBox();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.label10 = new System.Windows.Forms.Label();
|
||||
this.txt_EmployeeName = new System.Windows.Forms.TextBox();
|
||||
this.panel1.SuspendLayout();
|
||||
this.panel3.SuspendLayout();
|
||||
this.panel2.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.panel3);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(1037, 615);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
this.panel3.Controls.Add(this.panel2);
|
||||
this.panel3.Controls.Add(this.txtLog);
|
||||
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel3.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel3.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.panel3.Name = "panel3";
|
||||
this.panel3.Size = new System.Drawing.Size(1037, 615);
|
||||
this.panel3.TabIndex = 1;
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.Controls.Add(this.groupBox1);
|
||||
this.panel2.Controls.Add(this.label7);
|
||||
this.panel2.Controls.Add(this.txt_DataBase);
|
||||
this.panel2.Controls.Add(this.label5);
|
||||
this.panel2.Controls.Add(this.txt_serverName);
|
||||
this.panel2.Controls.Add(this.label1);
|
||||
this.panel2.Controls.Add(this.suspendedButton);
|
||||
this.panel2.Controls.Add(this.startButton);
|
||||
this.panel2.Controls.Add(this.btn_ToConfig);
|
||||
this.panel2.Controls.Add(this.txt_Key);
|
||||
this.panel2.Controls.Add(this.label9);
|
||||
this.panel2.Controls.Add(this.txt_Deptnumber);
|
||||
this.panel2.Controls.Add(this.txt_timer);
|
||||
this.panel2.Controls.Add(this.label8);
|
||||
this.panel2.Controls.Add(this.label4);
|
||||
this.panel2.Controls.Add(this.txt_port);
|
||||
this.panel2.Controls.Add(this.txt_domainN);
|
||||
this.panel2.Controls.Add(this.label3);
|
||||
this.panel2.Controls.Add(this.label2);
|
||||
this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panel2.Location = new System.Drawing.Point(0, 1);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(1037, 163);
|
||||
this.panel2.TabIndex = 4;
|
||||
//
|
||||
// txt_DataBase
|
||||
//
|
||||
this.txt_DataBase.Location = new System.Drawing.Point(313, 124);
|
||||
this.txt_DataBase.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txt_DataBase.Name = "txt_DataBase";
|
||||
this.txt_DataBase.Size = new System.Drawing.Size(132, 25);
|
||||
this.txt_DataBase.TabIndex = 22;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(232, 128);
|
||||
this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(82, 15);
|
||||
this.label5.TabIndex = 21;
|
||||
this.label5.Text = "数据库名:";
|
||||
//
|
||||
// txt_serverName
|
||||
//
|
||||
this.txt_serverName.Location = new System.Drawing.Point(91, 124);
|
||||
this.txt_serverName.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txt_serverName.Name = "txt_serverName";
|
||||
this.txt_serverName.Size = new System.Drawing.Size(132, 25);
|
||||
this.txt_serverName.TabIndex = 20;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(10, 128);
|
||||
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(82, 15);
|
||||
this.label1.TabIndex = 19;
|
||||
this.label1.Text = "服务器名:";
|
||||
//
|
||||
// suspendedButton
|
||||
//
|
||||
this.suspendedButton.Location = new System.Drawing.Point(906, 124);
|
||||
this.suspendedButton.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.suspendedButton.Name = "suspendedButton";
|
||||
this.suspendedButton.Size = new System.Drawing.Size(100, 34);
|
||||
this.suspendedButton.TabIndex = 18;
|
||||
this.suspendedButton.Text = "暂 停";
|
||||
this.suspendedButton.UseVisualStyleBackColor = true;
|
||||
this.suspendedButton.Click += new System.EventHandler(this.suspendedButton_Click);
|
||||
//
|
||||
// startButton
|
||||
//
|
||||
this.startButton.Location = new System.Drawing.Point(906, 74);
|
||||
this.startButton.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.startButton.Name = "startButton";
|
||||
this.startButton.Size = new System.Drawing.Size(100, 34);
|
||||
this.startButton.TabIndex = 17;
|
||||
this.startButton.Text = "开始同步";
|
||||
this.startButton.UseVisualStyleBackColor = true;
|
||||
this.startButton.Click += new System.EventHandler(this.startButton_Click);
|
||||
//
|
||||
// btn_ToConfig
|
||||
//
|
||||
this.btn_ToConfig.Location = new System.Drawing.Point(906, 24);
|
||||
this.btn_ToConfig.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.btn_ToConfig.Name = "btn_ToConfig";
|
||||
this.btn_ToConfig.Size = new System.Drawing.Size(100, 34);
|
||||
this.btn_ToConfig.TabIndex = 16;
|
||||
this.btn_ToConfig.Text = "配 置";
|
||||
this.btn_ToConfig.UseVisualStyleBackColor = true;
|
||||
this.btn_ToConfig.Click += new System.EventHandler(this.btn_ToConfig_Click);
|
||||
//
|
||||
// txt_Key
|
||||
//
|
||||
this.txt_Key.Location = new System.Drawing.Point(636, 35);
|
||||
this.txt_Key.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txt_Key.Name = "txt_Key";
|
||||
this.txt_Key.Size = new System.Drawing.Size(218, 25);
|
||||
this.txt_Key.TabIndex = 15;
|
||||
//
|
||||
// label9
|
||||
//
|
||||
this.label9.AutoSize = true;
|
||||
this.label9.Location = new System.Drawing.Point(549, 38);
|
||||
this.label9.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label9.Name = "label9";
|
||||
this.label9.Size = new System.Drawing.Size(91, 15);
|
||||
this.label9.TabIndex = 14;
|
||||
this.label9.Text = "配置key值:";
|
||||
//
|
||||
// txt_Deptnumber
|
||||
//
|
||||
this.txt_Deptnumber.Location = new System.Drawing.Point(373, 80);
|
||||
this.txt_Deptnumber.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txt_Deptnumber.Name = "txt_Deptnumber";
|
||||
this.txt_Deptnumber.Size = new System.Drawing.Size(133, 25);
|
||||
this.txt_Deptnumber.TabIndex = 12;
|
||||
//
|
||||
// txt_timer
|
||||
//
|
||||
this.txt_timer.Location = new System.Drawing.Point(373, 31);
|
||||
this.txt_timer.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txt_timer.Name = "txt_timer";
|
||||
this.txt_timer.Size = new System.Drawing.Size(80, 25);
|
||||
this.txt_timer.TabIndex = 13;
|
||||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.AutoSize = true;
|
||||
this.label8.Location = new System.Drawing.Point(231, 83);
|
||||
this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(142, 15);
|
||||
this.label8.TabIndex = 9;
|
||||
this.label8.Text = "配置查询的部门列:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(231, 34);
|
||||
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(142, 15);
|
||||
this.label4.TabIndex = 10;
|
||||
this.label4.Text = "配置同步刷新时间:";
|
||||
//
|
||||
// txt_port
|
||||
//
|
||||
this.txt_port.Location = new System.Drawing.Point(91, 80);
|
||||
this.txt_port.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txt_port.Name = "txt_port";
|
||||
this.txt_port.Size = new System.Drawing.Size(132, 25);
|
||||
this.txt_port.TabIndex = 7;
|
||||
//
|
||||
// txt_domainN
|
||||
//
|
||||
this.txt_domainN.Location = new System.Drawing.Point(91, 30);
|
||||
this.txt_domainN.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txt_domainN.Name = "txt_domainN";
|
||||
this.txt_domainN.Size = new System.Drawing.Size(132, 25);
|
||||
this.txt_domainN.TabIndex = 8;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(10, 84);
|
||||
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(82, 15);
|
||||
this.label3.TabIndex = 3;
|
||||
this.label3.Text = "配置端口:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(10, 34);
|
||||
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(82, 15);
|
||||
this.label2.TabIndex = 6;
|
||||
this.label2.Text = "配置域名:";
|
||||
//
|
||||
// txtLog
|
||||
//
|
||||
this.txtLog.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.txtLog.Location = new System.Drawing.Point(0, 164);
|
||||
this.txtLog.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txtLog.Multiline = true;
|
||||
this.txtLog.Name = "txtLog";
|
||||
this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.txtLog.Size = new System.Drawing.Size(1037, 451);
|
||||
this.txtLog.TabIndex = 3;
|
||||
//
|
||||
// txt_LoginAccount
|
||||
//
|
||||
this.txt_LoginAccount.Location = new System.Drawing.Point(98, 56);
|
||||
this.txt_LoginAccount.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txt_LoginAccount.Name = "txt_LoginAccount";
|
||||
this.txt_LoginAccount.Size = new System.Drawing.Size(151, 25);
|
||||
this.txt_LoginAccount.TabIndex = 24;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(11, 60);
|
||||
this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(82, 15);
|
||||
this.label6.TabIndex = 23;
|
||||
this.label6.Text = "部门编号:";
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.ForeColor = System.Drawing.Color.Red;
|
||||
this.label7.Location = new System.Drawing.Point(460, 38);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(83, 15);
|
||||
this.label7.TabIndex = 25;
|
||||
this.label7.Text = "(单位为秒)";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.txt_EmployeeName);
|
||||
this.groupBox1.Controls.Add(this.label10);
|
||||
this.groupBox1.Controls.Add(this.txt_LoginAccount);
|
||||
this.groupBox1.Controls.Add(this.label6);
|
||||
this.groupBox1.Location = new System.Drawing.Point(552, 67);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(302, 93);
|
||||
this.groupBox1.TabIndex = 27;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "验证信息";
|
||||
//
|
||||
// label10
|
||||
//
|
||||
this.label10.AutoSize = true;
|
||||
this.label10.Location = new System.Drawing.Point(11, 26);
|
||||
this.label10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label10.Name = "label10";
|
||||
this.label10.Size = new System.Drawing.Size(82, 15);
|
||||
this.label10.TabIndex = 25;
|
||||
this.label10.Text = "人员名称:";
|
||||
//
|
||||
// txt_EmployeeName
|
||||
//
|
||||
this.txt_EmployeeName.Location = new System.Drawing.Point(98, 23);
|
||||
this.txt_EmployeeName.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txt_EmployeeName.Name = "txt_EmployeeName";
|
||||
this.txt_EmployeeName.Size = new System.Drawing.Size(151, 25);
|
||||
this.txt_EmployeeName.TabIndex = 26;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1037, 615);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "Form1";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "更新人员信息";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel3.ResumeLayout(false);
|
||||
this.panel3.PerformLayout();
|
||||
this.panel2.ResumeLayout(false);
|
||||
this.panel2.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Panel panel3;
|
||||
private System.Windows.Forms.TextBox txtLog;
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
private System.Windows.Forms.TextBox txt_port;
|
||||
private System.Windows.Forms.TextBox txt_domainN;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox txt_Deptnumber;
|
||||
private System.Windows.Forms.TextBox txt_timer;
|
||||
private System.Windows.Forms.Label label8;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.TextBox txt_Key;
|
||||
private System.Windows.Forms.Label label9;
|
||||
private System.Windows.Forms.Button suspendedButton;
|
||||
private System.Windows.Forms.Button startButton;
|
||||
private System.Windows.Forms.Button btn_ToConfig;
|
||||
private System.Windows.Forms.TextBox txt_DataBase;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.TextBox txt_serverName;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox txt_LoginAccount;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.TextBox txt_EmployeeName;
|
||||
private System.Windows.Forms.Label label10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,416 @@
|
||||
using Lskj.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Lserp_UpdateServer;
|
||||
|
||||
|
||||
namespace lserp_UpdateDepart
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private string DomainN, Port, Timer, Deptnumber, Key,serverName,DataBase, LoginAccount, EmployeeName;
|
||||
private bool NewInitSuccess = false;
|
||||
private Int64 NewTxtMaxLength = 10000;
|
||||
private IniFiles ini = new IniFiles(Application.StartupPath + @"\MyConfig.INI");
|
||||
String jsonObj = "";
|
||||
bool flog = false;//用于判断是否加载完成就刷新
|
||||
|
||||
bool Pause = false;//是否暂停 true为暂停
|
||||
public System.Timers.Timer timer1 = new System.Timers.Timer();
|
||||
public System.Timers.Timer timer2 = new System.Timers.Timer();
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
if (ini.ExistINIFile())
|
||||
{
|
||||
txt_domainN.Text = ini.IniReadValue("同步人员", "DomainN");
|
||||
txt_port.Text = ini.IniReadValue("同步人员", "Port");
|
||||
txt_timer.Text = ini.IniReadValue("同步人员", "Timer");
|
||||
txt_Deptnumber.Text = ini.IniReadValue("同步人员", "Deptnumber");
|
||||
txt_Key.Text = ini.IniReadValue("同步人员", "Key");
|
||||
txt_serverName.Text = ini.IniReadValue("同步人员", "serverName");
|
||||
txt_DataBase.Text = ini.IniReadValue("同步人员", "DataBase");
|
||||
txt_LoginAccount.Text = ini.IniReadValue("同步人员", "LoginAccount");
|
||||
txt_EmployeeName.Text = ini.IniReadValue("同步人员", "EmployeeName ");
|
||||
}
|
||||
this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(timer1_Tick);
|
||||
this.timer2.Elapsed += new System.Timers.ElapsedEventHandler(timer2_Tick);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//点击配置,修改配置信息
|
||||
private void btn_ToConfig_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DBConfig.Instance.CreateConnection(txt_serverName.Text, txt_DataBase.Text))
|
||||
{
|
||||
//将ini文件清空
|
||||
ini.IniWriteValue(null, null, null);
|
||||
//判断是否输入的值是否为空
|
||||
if (string.IsNullOrEmpty(txt_domainN.Text) || string.IsNullOrEmpty(txt_port.Text) || string.IsNullOrEmpty(txt_timer.Text) || string.IsNullOrEmpty(txt_Deptnumber.Text) || string.IsNullOrEmpty(txt_Key.Text))
|
||||
{
|
||||
MessageBox.Show("数据有空值请重新输入!");
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txt_LoginAccount.Text) || string.IsNullOrEmpty(txt_EmployeeName.Text))
|
||||
{
|
||||
MessageBox.Show("请输入验证信息");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//判断数据库是否有该配置列
|
||||
DataTable DT = SqlHelper.ExecuteDataTable(string.Format("select name from syscolumns where id=object_id('P_EmployeeTab') and name='{0}'", txt_Deptnumber.Text));
|
||||
bool flag = DT.Rows.Count > 0;
|
||||
if (!flag)
|
||||
{
|
||||
MessageBox.Show("保存失败,原因:数据库内无配置的列!");
|
||||
return;
|
||||
}
|
||||
//调用添加接口添加管理员验证配置信息是否可用
|
||||
DataTable datable = SqlHelper.ExecuteDataTable(string.Format("select LoginAccount as pin,p_emp_EmployeeName as name,SpeciesNo as deptnumber from P_EmployeeTab where p_emp_EmployeeName='{1}' and LoginAccount='{0}'", txt_LoginAccount.Text,txt_EmployeeName.Text));
|
||||
string jsonObj = JsonUtil.ToJsonArray(datable);
|
||||
string url = string.Format("http://" + txt_domainN.Text + ":" + txt_port.Text + "/api/v2/employee/update/?key={0}", txt_Key.Text);
|
||||
ResponseMode mode = NewEmp.PostMethodToObj(url, jsonObj);
|
||||
if (mode.ret != 0)
|
||||
{
|
||||
MessageBox.Show("保存失败,原因:请检查域名、端口、key值、部门编号是否输入正确!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//成功后调用删除接口删除管理员并将SyncFlag初始化为0
|
||||
string Delsql = string.Format("select LoginAccount as pin from P_EmployeeTab where p_emp_EmployeeName='{1}' and LoginAccount='{0}'", txt_LoginAccount.Text, txt_EmployeeName.Text);
|
||||
DataTable delTable = SqlHelper.ExecuteDataTable(Delsql);
|
||||
string delurl = string.Format("http://" + txt_domainN.Text + ":" + txt_port.Text + "/api/v2/employee/delete/?key={0}", txt_Key.Text);
|
||||
jsonObj = JsonUtil.ToJsonArray(delTable);
|
||||
string deljson = jsonObj.Substring(1, jsonObj.Length - 2);
|
||||
NewEmp.PostMethodToObj(delurl, deljson);
|
||||
SqlHelper.ExecuteNonQuery(string.Format("update P_EmployeeTab set SyncFlag = {0}", 0));
|
||||
}
|
||||
|
||||
MessageBox.Show("保存成功!");
|
||||
ini.IniWriteValue("同步人员", "DomainN", txt_domainN.Text);
|
||||
ini.IniWriteValue("同步人员", "Port", txt_port.Text);
|
||||
ini.IniWriteValue("同步人员", "Timer", txt_timer.Text);
|
||||
ini.IniWriteValue("同步人员", "Deptnumber", txt_Deptnumber.Text);
|
||||
ini.IniWriteValue("同步人员", "Key", txt_Key.Text);
|
||||
ini.IniWriteValue("同步人员", "serverName", txt_serverName.Text);
|
||||
ini.IniWriteValue("同步人员", "DataBase", txt_DataBase.Text);
|
||||
ini.IniWriteValue("同步人员", "LoginAccount", txt_LoginAccount.Text);
|
||||
ini.IniWriteValue("同步人员", "EmployeeName ", txt_EmployeeName.Text);
|
||||
//this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//点击开始
|
||||
private void startButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Initialization(); // 初始化同步平台
|
||||
// 创建后台线程
|
||||
Thread backThread = new Thread(UpdateEmp);
|
||||
backThread.IsBackground = true;
|
||||
backThread.Start();
|
||||
}
|
||||
|
||||
//点击暂停
|
||||
private void suspendedButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Pause)
|
||||
{
|
||||
//暂停状态改继续
|
||||
Pause = false;
|
||||
suspendedButton.Text = "暂 停";
|
||||
}
|
||||
else
|
||||
{
|
||||
//继续状态改暂停
|
||||
Pause = true;
|
||||
suspendedButton.Text = "继 续";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求更新地址
|
||||
/// </summary>
|
||||
public static string GetPostUpdUrl(string DomainN, string Port, string Key)
|
||||
{
|
||||
string url = string.Format("http://" + DomainN + ":" + Port + "/api/v2/employee/update/?key={0}", Key);
|
||||
return url;
|
||||
}
|
||||
/// <summary>
|
||||
/// 请求离职地址
|
||||
/// </summary>
|
||||
public static string GetPostDelUrl(string DomainN, string Port, string Key)
|
||||
{
|
||||
string url = string.Format("http://" + DomainN + ":" + Port + "/api/v2/employee/delete/?key={0}", Key);
|
||||
return url;
|
||||
}
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
//this.Initialization(); // 初始化同步平台
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除离职员工方法
|
||||
/// </summary>
|
||||
public void DelEmp()
|
||||
{
|
||||
string Delsql = string.Format("select LoginAccount as pin from P_EmployeeTab where sign=1 and SyncFlag=1");
|
||||
DataTable delTable = SqlHelper.ExecuteDataTable(Delsql);
|
||||
if (delTable.Rows.Count > 0)
|
||||
{
|
||||
string url = GetPostDelUrl(DomainN, Port, Key);
|
||||
foreach (DataRow item in delTable.Rows)
|
||||
{
|
||||
jsonObj = JsonUtil.ToJsonObject(item);
|
||||
string deljson = jsonObj.Substring(1, jsonObj.Length - 2);
|
||||
ResponseMode mode = NewEmp.PostMethodToObj(url, deljson);
|
||||
if (0 == mode.ret)
|
||||
{
|
||||
string delareabak = DateTime.Now + string.Format(" 离职人员{0} 信息删除成功.\r\n", item["pin"]);
|
||||
RefreshLogUIThread(delareabak);
|
||||
SqlHelper.ExecuteNonQuery(string.Format("update P_EmployeeTab set p_emp_areabak = '{1}' where LoginAccount='{0}'", item["pin"], delareabak));
|
||||
SqlHelper.ExecuteNonQuery(string.Format("update P_EmployeeTab set SyncFlag = {1} where LoginAccount='{0}'", item["pin"], 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMsg = mode != null ? mode.msg : "未知原因.";
|
||||
RefreshLogUIThread(DateTime.Now + string.Format(" 信息删除失败,错误原因:{0}.\r\n", errorMsg));
|
||||
SqlHelper.ExecuteNonQuery(string.Format("update P_EmployeeTab set p_emp_areabak = '{1}' where LoginAccount='{0}'", item["pin"], errorMsg));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 同步人员方法
|
||||
/// </summary>
|
||||
public void UpdateEmp()
|
||||
{
|
||||
if (!NewInitSuccess) return;
|
||||
DataTable DT = SqlHelper.ExecuteDataTable("select name from syscolumns where id=object_id('P_EmployeeTab') and name='SyncFlag'");
|
||||
bool flag = DT.Rows.Count > 0;
|
||||
if (!flag)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery("ALTER TABLE P_EmployeeTab ADD SyncFlag INT DEFAULT(0)");
|
||||
}
|
||||
DataTable DT2 = SqlHelper.ExecuteDataTable("select name from syscolumns where id=object_id('P_EmployeeTab') and name='p_emp_areabak'");
|
||||
bool fg = DT2.Rows.Count > 0;
|
||||
if (!fg)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery("ALTER TABLE P_EmployeeTab ADD p_emp_areabak varchar(5000) DEFAULT(0)");
|
||||
}
|
||||
RefreshLogUIThread(DateTime.Now + " 开始同步.\r\n");
|
||||
this.timer1.Enabled = false;
|
||||
//string sqlValue = string.Format("select LoginAccount as pin,p_emp_EmployeeName as name,{0} as deptnumber from P_EmployeeTab where ISNULL(SyncFlag,0)=0 and {0}!='null' and {0}!='' and sign=0", Deptnumber);
|
||||
//string sqlValue = string.Format("select LoginAccount as pin,p_emp_EmployeeName as name,{0} as deptnumber from P_EmployeeTab where ISNULL(SyncFlag,0)=0", Deptnumber);
|
||||
string sqlValue = string.Format("select LoginAccount as pin,p_emp_EmployeeName as name,{0} as deptnumber from P_EmployeeTab where ISNULL(SyncFlag,0)=0 and isnull(sign,0)=0", Deptnumber);
|
||||
flog = false;
|
||||
DataTable dtTable = SqlHelper.ExecuteDataTable(sqlValue);
|
||||
|
||||
try
|
||||
{
|
||||
//删除离职员工方法
|
||||
DelEmp();
|
||||
|
||||
//同步在职员工方法
|
||||
foreach (DataRow item in dtTable.Rows)
|
||||
{
|
||||
if (Pause)
|
||||
{
|
||||
//RefreshLogUIThread(string.Format("暂停同步……\r\n"));
|
||||
StopMethod();
|
||||
}
|
||||
|
||||
string url = GetPostUpdUrl(DomainN, Port, Key);
|
||||
string Str = item["deptnumber"].ToString();
|
||||
String[] result = Str.Split(',');
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
{
|
||||
item["deptnumber"] = result[i];
|
||||
jsonObj = JsonUtil.ToJsonObject(item);
|
||||
ResponseMode mode = NewEmp.PostMethodToObj(url, jsonObj);
|
||||
if (0 == mode.ret)
|
||||
{
|
||||
|
||||
sqlValue = string.Format("update P_EmployeeTab set SyncFlag = 1 where LoginAccount='{0}'", item["pin"]);
|
||||
SqlHelper.ExecuteNonQuery(sqlValue);
|
||||
string updareabak = DateTime.Now + string.Format(" {0} 信息读取成功.\r\n", item["name"]);
|
||||
RefreshLogUIThread(updareabak);
|
||||
SqlHelper.ExecuteNonQuery(string.Format("update P_EmployeeTab set p_emp_areabak = '{1}' where LoginAccount='{0}'", item["pin"], updareabak));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMsg = mode != null ? mode.msg : "未知原因.";
|
||||
RefreshLogUIThread(DateTime.Now + string.Format(" 信息读取失败,错误原因:{0}.\r\n", errorMsg));
|
||||
SqlHelper.ExecuteNonQuery(string.Format("update P_EmployeeTab set p_emp_areabak = '{1}' where LoginAccount='{0}'", item["pin"], errorMsg));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RefreshLogUIThread(DateTime.Now + string.Format(" 信息读取失败.\r\n" + " 原因:" + ex.Message + Environment.NewLine + ex.InnerException.ToString()));
|
||||
}
|
||||
flog = true;
|
||||
RefreshLogUIThread(DateTime.Now + " 本轮人员更新完成.\r\n");
|
||||
RefreshLogUIThread("--------------------分割线------------------------\r\n");
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化同步平台
|
||||
/// </summary>
|
||||
private void Initialization()
|
||||
{
|
||||
try
|
||||
{
|
||||
RefreshLog(DateTime.Now + " 正在初始化平台.\r\n");
|
||||
if (DBConfig.Instance.CreateConnection(txt_serverName.Text, txt_DataBase.Text))
|
||||
{
|
||||
|
||||
DataTable DT = SqlHelper.ExecuteDataTable("SELECT Name FROM SysObjects Where XType='U' and Name='P_EmployeeTab' ORDER BY Name");
|
||||
// select name from syscolumns where id=object_id('P_EmployeeTab') and name='SyncFlag'
|
||||
bool flag = DT.Rows.Count > 0;
|
||||
if (flag)
|
||||
{
|
||||
//获取ini配置的值
|
||||
DomainN = ini.IniReadValue("同步人员", "DomainN");
|
||||
Port = ini.IniReadValue("同步人员", "Port");
|
||||
Timer = ini.IniReadValue("同步人员", "Timer");
|
||||
Deptnumber = ini.IniReadValue("同步人员", "Deptnumber");
|
||||
Key = ini.IniReadValue("同步人员", "Key");
|
||||
serverName = ini.IniReadValue("同步人员", "serverName");
|
||||
DataBase = ini.IniReadValue("同步人员", "DataBase");
|
||||
LoginAccount = ini.IniReadValue("同步人员", "LoginAccount");
|
||||
EmployeeName = ini.IniReadValue("同步人员", "EmployeeName ");
|
||||
|
||||
if (string.IsNullOrEmpty(DomainN) || string.IsNullOrEmpty(Port) || string.IsNullOrEmpty(Timer) || string.IsNullOrEmpty(Deptnumber) || string.IsNullOrEmpty(Key))
|
||||
{
|
||||
RefreshLog(DateTime.Now + " 初始化平台失败.\r\n" + "原因:配置文件不全请重新配置.");
|
||||
MessageBox.Show(" 初始化平台失败.\r\n" + "原因:配置文件不全请重新配置.");
|
||||
config c = new config();
|
||||
c.ShowDialog();
|
||||
Initialization();
|
||||
}
|
||||
else
|
||||
{
|
||||
NewInitSuccess = true;
|
||||
RefreshLog(DateTime.Now + " 初始化平台成功.\r\n");
|
||||
this.timer1.Interval = int.Parse(Timer) * 1000;
|
||||
this.timer1.Start();
|
||||
this.timer2.Interval = 100;
|
||||
this.timer2.Start();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("此数据库内无'P_EmployeeTab'表!请配置好注册表后重新打开!");
|
||||
this.Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RefreshLog(DateTime.Now + " 初始化平台失败.\r\n");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RefreshLog(DateTime.Now + string.Format(" 初始化失败.原因:{0}.\r\n", ex.Message));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 后台线程刷新数据
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
public void RefreshLogUIThread(string msg)
|
||||
{
|
||||
if (this.IsHandleCreated)
|
||||
{
|
||||
Invoke((EventHandler)delegate
|
||||
{
|
||||
txtLog.Text += msg;
|
||||
txtLog.Select(txtLog.TextLength, 0);
|
||||
txtLog.ScrollToCaret();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 主线程刷新数据
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
public void RefreshLog(string msg)
|
||||
{
|
||||
txtLog.Text += msg;
|
||||
txtLog.Select(txtLog.TextLength, 0);
|
||||
txtLog.ScrollToCaret();
|
||||
}
|
||||
|
||||
private void txtLog_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (this.txtLog.Text.Length > NewTxtMaxLength)
|
||||
{
|
||||
if (this.IsHandleCreated)
|
||||
{
|
||||
Invoke((EventHandler)delegate
|
||||
{
|
||||
txtLog.Text = "";
|
||||
txtLog.Select(txtLog.TextLength, 0);
|
||||
txtLog.ScrollToCaret();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
UpdateEmp();
|
||||
}
|
||||
|
||||
private void timer2_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (flog && !Pause)
|
||||
{
|
||||
this.timer1.Enabled = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 暂停方法监测
|
||||
/// </summary>
|
||||
public void StopMethod()
|
||||
{
|
||||
if (Pause)
|
||||
{
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
StopMethod();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace lserp_UpdateDepart
|
||||
{
|
||||
public class IniFiles
|
||||
{
|
||||
public string inipath;
|
||||
|
||||
//声明API函数
|
||||
|
||||
[DllImport("kernel32")]
|
||||
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
|
||||
[DllImport("kernel32")]
|
||||
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
|
||||
/// <summary>
|
||||
/// 构造方法
|
||||
/// </summary>
|
||||
/// <param name="INIPath">文件路径</param>
|
||||
public IniFiles(string INIPath)
|
||||
{
|
||||
inipath = INIPath;
|
||||
}
|
||||
|
||||
public IniFiles() { }
|
||||
|
||||
/// <summary>
|
||||
/// 写入INI文件
|
||||
/// </summary>
|
||||
/// <param name="Section">项目名称(如 [TypeName] )</param>
|
||||
/// <param name="Key">键</param>
|
||||
/// <param name="Value">值</param>
|
||||
public void IniWriteValue(string Section, string Key, string Value)
|
||||
{
|
||||
WritePrivateProfileString(Section, Key, Value, this.inipath);
|
||||
}
|
||||
/// <summary>
|
||||
/// 读出INI文件
|
||||
/// </summary>
|
||||
/// <param name="Section">项目名称(如 [TypeName] )</param>
|
||||
/// <param name="Key">键</param>
|
||||
public string IniReadValue(string Section, string Key)
|
||||
{
|
||||
StringBuilder temp = new StringBuilder(500);
|
||||
int i = GetPrivateProfileString(Section, Key, "", temp, 500, this.inipath);
|
||||
return temp.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// 验证文件是否存在
|
||||
/// </summary>
|
||||
/// <returns>布尔值</returns>
|
||||
public bool ExistINIFile()
|
||||
{
|
||||
return File.Exists(inipath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{4B218104-16EB-48ED-B7E9-645AC7B982E3}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>lserp_UpdateDepart</RootNamespace>
|
||||
<AssemblyName>Lserp_UpdateEmp</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>a.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="config.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="config.Designer.cs">
|
||||
<DependentUpon>config.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="IniFiles.cs" />
|
||||
<Compile Include="Model\DBConfig.cs" />
|
||||
<Compile Include="Model\SqlHelper.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="config.resx">
|
||||
<DependentUpon>config.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Lserp_UpdateServer\Lserp_UpdateServer.csproj">
|
||||
<Project>{64cdad33-d53e-4aa8-bf1c-ac6828a44fd8}</Project>
|
||||
<Name>Lserp_UpdateServer</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="a.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,215 @@
|
||||
/******************************
|
||||
* 说明:数据库连接参数配置类
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2017-07-24
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Win32;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Lskj.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库连接参数配置类
|
||||
/// </summary>
|
||||
public sealed class DBConfig
|
||||
{
|
||||
private static string _regKey = "AA_LS_Erp V2.0";
|
||||
private static DBConfig _instance = null;
|
||||
/// <summary>
|
||||
/// DBConfig静态单例对象
|
||||
/// </summary>
|
||||
/// <value>The instance.</value>
|
||||
public static DBConfig Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new DBConfig();
|
||||
_instance.ReadConfig();
|
||||
|
||||
_instance.WriteConfig();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据库名
|
||||
/// </summary>
|
||||
public string DataBase;
|
||||
/// <summary>
|
||||
/// 帐套
|
||||
/// </summary>
|
||||
public string DataBook;
|
||||
/// <summary>
|
||||
/// 服务器名
|
||||
/// </summary>
|
||||
public string ServerName;
|
||||
/// <summary>
|
||||
/// 登录名
|
||||
/// </summary>
|
||||
public string LoginName;
|
||||
/// <summary>
|
||||
/// 文件升级标志
|
||||
/// </summary>
|
||||
public bool UpdateSet;
|
||||
///<summary>
|
||||
///智能客户端启动
|
||||
///</summary>
|
||||
public bool SmallClient;
|
||||
/// <summary>
|
||||
/// 内外外网标志
|
||||
/// </summary>
|
||||
public bool Internet;
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:读取注册表配置</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public void ReadConfig()
|
||||
{
|
||||
RegistryKey regKey = Registry.CurrentUser;
|
||||
RegistryKey subKey = regKey.OpenSubKey(_regKey);
|
||||
subKey = subKey.OpenSubKey("File");
|
||||
|
||||
DataBase = subKey.GetValue("datastr", "") + "";
|
||||
ServerName = subKey.GetValue("ServerName", "") + "";
|
||||
LoginName = subKey.GetValue("LoginName", "") + "";
|
||||
UpdateSet = subKey.GetValue("UpdateSet", "0") + "" == "1" || subKey.GetValue("UpdateSet", "0") + "" == "True" ? true : false;
|
||||
SmallClient = subKey.GetValue("SmallClient", "0") + "" == "1" || subKey.GetValue("SmallClient", "0") + "" == "True" ? true : false;
|
||||
Internet = subKey.GetValue("Internet", "1") + "" == "0" ? true : false;
|
||||
|
||||
try
|
||||
{
|
||||
DataBook = subKey.GetValue("DataBook", "") + "";
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:写配置</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public void WriteConfig()
|
||||
{
|
||||
RegistryKey regKey = Registry.CurrentUser;
|
||||
RegistryKey subKey = regKey.OpenSubKey(_regKey);
|
||||
subKey = subKey.OpenSubKey("File", true);
|
||||
subKey.SetValue("datastr", DataBase);
|
||||
subKey.SetValue("ServerName", ServerName);
|
||||
subKey.SetValue("LoginName", LoginName);
|
||||
subKey.SetValue("UpdateSet", UpdateSet);
|
||||
subKey.SetValue("SmallClient", SmallClient);
|
||||
subKey.SetValue("DataBook", DataBook);
|
||||
subKey.Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取C#连接字符串</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
public string GetConnection()
|
||||
{
|
||||
return string.Format("Server={0};Database={1};Persist Security Info=True;User ID=lserpAdmin;Password=lserp110;Connection Timeout=5", ServerName, DataBase);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取delphi连接字符串</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
public string GetDelphiConnection()
|
||||
{
|
||||
return string.Format("Provider=SQLOLEDB.1;Server={0};Database={1};Persist Security Info=True;User ID=lserpAdmin;Password=lserp110;Connection Timeout=5", ServerName, DataBase);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-03-28 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
public string GetLsCrmConnection()
|
||||
{
|
||||
return Internet ? "Server=192.168.0.10,14330;Database=lscrm;Persist Security Info=True;User ID=Lserp_crm;Password=lserp_ERP_@#$_123;Connection Timeout=5"
|
||||
: "Server=lsucrm.ticp.net,14330;Database=lscrm;Persist Security Info=True;User ID=Lserp_crm;Password=lserp_ERP_@#$_123;Connection Timeout=5";
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:创建数据库连接</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
public bool CreateConnection(string serverName,string dataBase)
|
||||
{
|
||||
ServerName = serverName;
|
||||
DataBase = dataBase;
|
||||
string connStr = GetConnection();
|
||||
if (SqlHelper._connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlHelper._connection.Close();
|
||||
SqlHelper._connection.Dispose();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
SqlHelper._connection = null;
|
||||
}
|
||||
try
|
||||
{
|
||||
SqlHelper._connection = new SqlConnection(connStr);
|
||||
SqlHelper._connection.Open();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,651 @@
|
||||
/******************************
|
||||
* 说明:数据库操作类
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2017-07-24
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
|
||||
namespace Lskj.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库操作类
|
||||
/// </summary>
|
||||
public static class SqlHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据连接
|
||||
/// </summary>
|
||||
public static SqlConnection _connection;
|
||||
|
||||
#region ExecuteAdapter
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:获取适配器</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>SqlDataAdapter.</returns>
|
||||
public static SqlDataAdapter ExecuteAdapter(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlDataAdapter adapter;
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, commandParameters);
|
||||
adapter = new SqlDataAdapter(cmd);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:获取适配器</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>SqlDataAdapter.</returns>
|
||||
public static SqlDataAdapter ExecuteAdapter(CommandType cmdType, string cmdText)
|
||||
{
|
||||
SqlDataAdapter adapter;
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, null);
|
||||
adapter = new SqlDataAdapter(cmd);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteDataTable
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回DataTable</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>DataTable.</returns>
|
||||
public static DataTable ExecuteDataTable(string cmdText)
|
||||
{
|
||||
return ExecuteDataSet(cmdText).Tables[0];
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回DataTable</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>DataTable.</returns>
|
||||
public static DataTable ExecuteDataTable(string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
return ExecuteDataSet(CommandType.Text, cmdText, "temp", commandParameters).Tables[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回指定字段值</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-15 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="fieldName">Name of the field.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteObject(string fieldName, string cmdText)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
result = ExecuteDataSet(cmdText).Tables[0].Rows[0][fieldName];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回指定字段值</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-11-27 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="fieldName">Name of the field.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteObject(string fieldName, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
result = ExecuteDataSet(CommandType.Text, cmdText, "temp", commandParameters).Tables[0].Rows[0][fieldName];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回指定字段值</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-15 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="fieldName">Name of the field.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static string ExecuteString(string fieldName, string cmdText)
|
||||
{
|
||||
object obj = ExecuteObject(fieldName, cmdText);
|
||||
return obj == null ? "" : obj.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql返回指定字段值</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-11-27 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="fieldName">Name of the field.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string ExecuteString(string fieldName, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
object obj = ExecuteObject(fieldName, cmdText, commandParameters);
|
||||
return obj == null ? "" : obj.ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteDataSet
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:查询结果集</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="tabName">Name of the tab.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>DataSet.</returns>
|
||||
public static DataSet ExecuteDataSet(int cmdType, string cmdText, string tabName, params SqlParameter[] commandParameters)
|
||||
{
|
||||
CommandType _cmdType = CommandType.Text;
|
||||
switch (cmdType)
|
||||
{
|
||||
case 4:
|
||||
_cmdType = CommandType.StoredProcedure;
|
||||
break;
|
||||
case 512:
|
||||
_cmdType = CommandType.TableDirect;
|
||||
break;
|
||||
}
|
||||
return ExecuteDataSet(_cmdType, cmdText, tabName, commandParameters);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:查询结果集</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">语句类型存储过程或者sql语句</param>
|
||||
/// <param name="cmdText">执行内容</param>
|
||||
/// <param name="tabName">表名</param>
|
||||
/// <param name="commandParameters">参数</param>
|
||||
/// <returns>DataSet.</returns>
|
||||
public static DataSet ExecuteDataSet(CommandType cmdType, string cmdText, string tabName, params SqlParameter[] commandParameters)
|
||||
{
|
||||
DataSet set2;
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, commandParameters);
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet, tabName);
|
||||
//adapter.FillSchema(dataSet, SchemaType.Mapped, tabName);
|
||||
set2 = dataSet;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Dispose();
|
||||
}
|
||||
|
||||
return set2;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:查询结果集</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">语句类型存储过程或者sql语句</param>
|
||||
/// <param name="cmdText">执行内容</param>
|
||||
/// <param name="tabName">表名</param>
|
||||
/// <returns>DataSet.</returns>
|
||||
public static DataSet ExecuteDataSet(CommandType cmdType, string cmdText, string tabName)
|
||||
{
|
||||
DataSet set2;
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, null);
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet, tabName);
|
||||
set2 = dataSet;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return set2;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:查询结果集</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdText">执行内容</param>
|
||||
/// <returns>DataSet.</returns>
|
||||
public static DataSet ExecuteDataSet(string cmdText)
|
||||
{
|
||||
DataSet set2;
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, CommandType.Text, cmdText, null);
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet, "temp");
|
||||
set2 = dataSet;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return set2;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:查询结果集</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="procedureName">Name of the procedure.</param>
|
||||
/// <param name="tabName">表名</param>
|
||||
/// <param name="parameterNames">The parameter names.</param>
|
||||
/// <param name="parameterValues">The parameter values.</param>
|
||||
/// <returns>DataSet.</returns>
|
||||
public static DataSet ExecuteDataSet(string procedureName, string tabName, string[] parameterNames, object[] parameterValues)
|
||||
{
|
||||
DataSet set2;
|
||||
try
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand(procedureName, _connection);
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
|
||||
if (parameterNames != null && parameterValues != null)
|
||||
{
|
||||
for (int i = 0; i < parameterNames.Length && i < parameterValues.Length; i++)
|
||||
{
|
||||
cmd.Parameters.AddWithValue(parameterNames[i], parameterValues[i]);
|
||||
}
|
||||
}
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet, tabName);
|
||||
set2 = dataSet;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return set2;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteNonQuery
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="Connectionection">The connectionection.</param>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
public static int ExecuteNonQuery(SqlConnection Connectionection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
PrepareCommand(cmd, Connectionection, null, cmdType, cmdText, commandParameters);
|
||||
int num = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
return num;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="trans">The trans.</param>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);
|
||||
int num = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
return num;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
public static int ExecuteNonQuery(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, commandParameters);
|
||||
int num = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
return num;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
public static int ExecuteNonQuery(CommandType cmdType, string cmdText)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, null);
|
||||
int num = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
return num;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
public static int ExecuteNonQuery(string cmdText)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
PrepareCommand(cmd, _connection, null, CommandType.Text, cmdText, null);
|
||||
int num = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
return num;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteReader
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回结果集(只读、只进)</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>SqlDataReader.</returns>
|
||||
public static SqlDataReader ExecuteReader(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlDataReader reader2;
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
try
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, commandParameters);
|
||||
SqlDataReader reader = cmd.ExecuteReader();
|
||||
cmd.Parameters.Clear();
|
||||
reader2 = reader;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return reader2;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExecuteScalar
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回结果集第一行第一列</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="Connectionection">The connectionection.</param>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteScalar(SqlConnection Connectionection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
PrepareCommand(cmd, Connectionection, null, cmdType, cmdText, commandParameters);
|
||||
object obj2 = cmd.ExecuteScalar();
|
||||
cmd.Parameters.Clear();
|
||||
return obj2;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回结果集第一行第一列</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="commandParameters">The command parameters.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteScalar(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, commandParameters);
|
||||
object obj2 = cmd.ExecuteScalar();
|
||||
cmd.Parameters.Clear();
|
||||
return obj2;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回结果集第一行第一列</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteScalar(CommandType cmdType, string cmdText)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, cmdType, cmdText, null);
|
||||
object obj2 = cmd.ExecuteScalar();
|
||||
cmd.Parameters.Clear();
|
||||
return obj2;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:执行sql语句或者存储过程并返回结果集第一行第一列</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-21 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public static object ExecuteScalar(string cmdText)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
{
|
||||
PrepareCommand(cmd, _connection, null, CommandType.Text, cmdText, null);
|
||||
object obj2 = cmd.ExecuteScalar();
|
||||
cmd.Parameters.Clear();
|
||||
return obj2;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PrepareCommand
|
||||
/// <summary>
|
||||
/// <para>说明: sql参数处理</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-07-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="cmd">The command.</param>
|
||||
/// <param name="Connection">The connection.</param>
|
||||
/// <param name="trans">The trans.</param>
|
||||
/// <param name="cmdType">Type of the command.</param>
|
||||
/// <param name="cmdText">The command text.</param>
|
||||
/// <param name="cmdParms">The command parms.</param>
|
||||
private static void PrepareCommand(SqlCommand cmd, SqlConnection Connection, SqlTransaction trans, CommandType cmdType, string cmdText, SqlParameter[] cmdParms)
|
||||
{
|
||||
if (Connection.State != ConnectionState.Open)
|
||||
{
|
||||
Connection.Open();
|
||||
}
|
||||
cmd.Connection = Connection;
|
||||
//cmd.CommandTimeout = CommandTimeout;
|
||||
cmd.CommandText = cmdText;
|
||||
if (trans != null)
|
||||
{
|
||||
cmd.Transaction = trans;
|
||||
}
|
||||
cmd.CommandType = cmdType;
|
||||
if (cmdParms != null)
|
||||
{
|
||||
foreach (SqlParameter parameter in cmdParms)
|
||||
{
|
||||
cmd.Parameters.Add(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace lserp_UpdateDepart
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的常规信息通过以下
|
||||
// 特性集控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("Lserp_UpdateEmp")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Lserp_UpdateEmp")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 使此程序集中的类型
|
||||
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
||||
// 则将该类型上的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("11671652-8f62-45f2-b621-e89155a69504")]
|
||||
|
||||
// 程序集的版本信息由下面四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace lserp_UpdateDepart.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("lserp_UpdateDepart.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用此强类型资源类,为所有资源查找
|
||||
/// 重写当前线程的 CurrentUICulture 属性。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace lserp_UpdateDepart.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
@@ -0,0 +1,241 @@
|
||||
namespace lserp_UpdateDepart
|
||||
{
|
||||
partial class config
|
||||
{
|
||||
/// <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.btn_Close = new System.Windows.Forms.Button();
|
||||
this.btn_ToConfig = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.txt_domainN = new System.Windows.Forms.TextBox();
|
||||
this.txt_port = new System.Windows.Forms.TextBox();
|
||||
this.txt_timer = new System.Windows.Forms.TextBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.txt_Deptnumber = new System.Windows.Forms.TextBox();
|
||||
this.txt_Key = new System.Windows.Forms.TextBox();
|
||||
this.label9 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btn_Close
|
||||
//
|
||||
this.btn_Close.Location = new System.Drawing.Point(302, 259);
|
||||
this.btn_Close.Name = "btn_Close";
|
||||
this.btn_Close.Size = new System.Drawing.Size(75, 26);
|
||||
this.btn_Close.TabIndex = 0;
|
||||
this.btn_Close.Text = "退出";
|
||||
this.btn_Close.UseVisualStyleBackColor = true;
|
||||
this.btn_Close.Click += new System.EventHandler(this.btn_Close_Click);
|
||||
//
|
||||
// btn_ToConfig
|
||||
//
|
||||
this.btn_ToConfig.Location = new System.Drawing.Point(78, 259);
|
||||
this.btn_ToConfig.Name = "btn_ToConfig";
|
||||
this.btn_ToConfig.Size = new System.Drawing.Size(75, 26);
|
||||
this.btn_ToConfig.TabIndex = 0;
|
||||
this.btn_ToConfig.Text = "配置";
|
||||
this.btn_ToConfig.UseVisualStyleBackColor = true;
|
||||
this.btn_ToConfig.Click += new System.EventHandler(this.btn_ToConfig_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("宋体", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label1.ForeColor = System.Drawing.Color.Red;
|
||||
this.label1.Location = new System.Drawing.Point(124, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(193, 29);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "配置信息工具";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(101, 78);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(65, 12);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "配置域名:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(101, 118);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(65, 12);
|
||||
this.label3.TabIndex = 1;
|
||||
this.label3.Text = "配置端口:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(101, 158);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(113, 12);
|
||||
this.label4.TabIndex = 1;
|
||||
this.label4.Text = "配置同步刷新时间:";
|
||||
//
|
||||
// txt_domainN
|
||||
//
|
||||
this.txt_domainN.Location = new System.Drawing.Point(162, 75);
|
||||
this.txt_domainN.Name = "txt_domainN";
|
||||
this.txt_domainN.Size = new System.Drawing.Size(100, 21);
|
||||
this.txt_domainN.TabIndex = 2;
|
||||
//
|
||||
// txt_port
|
||||
//
|
||||
this.txt_port.Location = new System.Drawing.Point(162, 115);
|
||||
this.txt_port.Name = "txt_port";
|
||||
this.txt_port.Size = new System.Drawing.Size(100, 21);
|
||||
this.txt_port.TabIndex = 2;
|
||||
//
|
||||
// txt_timer
|
||||
//
|
||||
this.txt_timer.Location = new System.Drawing.Point(208, 155);
|
||||
this.txt_timer.Name = "txt_timer";
|
||||
this.txt_timer.Size = new System.Drawing.Size(54, 21);
|
||||
this.txt_timer.TabIndex = 2;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.ForeColor = System.Drawing.Color.Red;
|
||||
this.label5.Location = new System.Drawing.Point(268, 78);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(155, 12);
|
||||
this.label5.TabIndex = 1;
|
||||
this.label5.Text = "(格式如:114.116.135.188)";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.ForeColor = System.Drawing.Color.Red;
|
||||
this.label6.Location = new System.Drawing.Point(268, 118);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(89, 12);
|
||||
this.label6.TabIndex = 1;
|
||||
this.label6.Text = "(格式如:8000)";
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.ForeColor = System.Drawing.Color.Red;
|
||||
this.label7.Location = new System.Drawing.Point(268, 158);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(65, 12);
|
||||
this.label7.TabIndex = 1;
|
||||
this.label7.Text = "(单位为秒)";
|
||||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.AutoSize = true;
|
||||
this.label8.Location = new System.Drawing.Point(101, 192);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(113, 12);
|
||||
this.label8.TabIndex = 1;
|
||||
this.label8.Text = "配置查询的部门列:";
|
||||
//
|
||||
// txt_Deptnumber
|
||||
//
|
||||
this.txt_Deptnumber.Location = new System.Drawing.Point(208, 189);
|
||||
this.txt_Deptnumber.Name = "txt_Deptnumber";
|
||||
this.txt_Deptnumber.Size = new System.Drawing.Size(101, 21);
|
||||
this.txt_Deptnumber.TabIndex = 2;
|
||||
//
|
||||
// txt_Key
|
||||
//
|
||||
this.txt_Key.Location = new System.Drawing.Point(162, 222);
|
||||
this.txt_Key.Name = "txt_Key";
|
||||
this.txt_Key.Size = new System.Drawing.Size(261, 21);
|
||||
this.txt_Key.TabIndex = 2;
|
||||
//
|
||||
// label9
|
||||
//
|
||||
this.label9.AutoSize = true;
|
||||
this.label9.Location = new System.Drawing.Point(101, 225);
|
||||
this.label9.Name = "label9";
|
||||
this.label9.Size = new System.Drawing.Size(71, 12);
|
||||
this.label9.TabIndex = 1;
|
||||
this.label9.Text = "配置key值:";
|
||||
//
|
||||
// config
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(455, 329);
|
||||
this.Controls.Add(this.txt_Key);
|
||||
this.Controls.Add(this.txt_Deptnumber);
|
||||
this.Controls.Add(this.txt_timer);
|
||||
this.Controls.Add(this.txt_port);
|
||||
this.Controls.Add(this.txt_domainN);
|
||||
this.Controls.Add(this.label9);
|
||||
this.Controls.Add(this.label8);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label7);
|
||||
this.Controls.Add(this.label6);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.btn_ToConfig);
|
||||
this.Controls.Add(this.btn_Close);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "config";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "config";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.config_FormClosing);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btn_Close;
|
||||
private System.Windows.Forms.Button btn_ToConfig;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.TextBox txt_domainN;
|
||||
private System.Windows.Forms.TextBox txt_port;
|
||||
private System.Windows.Forms.TextBox txt_timer;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.Label label8;
|
||||
private System.Windows.Forms.TextBox txt_Deptnumber;
|
||||
private System.Windows.Forms.TextBox txt_Key;
|
||||
private System.Windows.Forms.Label label9;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using Lserp_UpdateServer;
|
||||
using Lskj.Core;
|
||||
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 lserp_UpdateDepart
|
||||
{
|
||||
public partial class config : Form
|
||||
{
|
||||
IniFiles ini = new IniFiles(Application.StartupPath + @"\MyConfig.INI");
|
||||
bool fg = false;
|
||||
public config()
|
||||
{
|
||||
InitializeComponent();
|
||||
if (ini.ExistINIFile())
|
||||
{
|
||||
txt_domainN.Text = ini.IniReadValue("同步人员", "DomainN");
|
||||
txt_port.Text = ini.IniReadValue("同步人员", "Port");
|
||||
txt_timer.Text = ini.IniReadValue("同步人员", "Timer");
|
||||
txt_Deptnumber.Text = ini.IniReadValue("同步人员", "Deptnumber");
|
||||
txt_Key.Text = ini.IniReadValue("同步人员", "Key");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_ToConfig_Click(object sender, EventArgs e)
|
||||
{
|
||||
//将ini文件清空
|
||||
ini.IniWriteValue(null, null, null);
|
||||
//判断是否输入的值是否为空
|
||||
if (string.IsNullOrEmpty(txt_domainN.Text) || string.IsNullOrEmpty(txt_port.Text) || string.IsNullOrEmpty(txt_timer.Text) || string.IsNullOrEmpty(txt_Deptnumber.Text) || string.IsNullOrEmpty(txt_Key.Text))
|
||||
{
|
||||
MessageBox.Show("数据有空值请重新输入!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//判断数据库是否有该配置列
|
||||
DataTable DT = SqlHelper.ExecuteDataTable(string.Format("select name from syscolumns where id=object_id('P_EmployeeTab') and name='{0}'", txt_Deptnumber.Text));
|
||||
bool flag = DT.Rows.Count > 0;
|
||||
if (!flag)
|
||||
{
|
||||
MessageBox.Show("保存失败,原因:数据库内无配置的列!");
|
||||
fg = false;
|
||||
return;
|
||||
}
|
||||
//调用添加接口添加管理员验证配置信息是否可用
|
||||
DataTable datable = SqlHelper.ExecuteDataTable(string.Format("select LoginAccount as pin,p_emp_EmployeeName as name,SpeciesNo as deptnumber from P_EmployeeTab where p_emp_EmployeeName='管理员'"));
|
||||
string jsonObj = JsonUtil.ToJsonArray(datable);
|
||||
string url = string.Format("http://" + txt_domainN.Text + ":" + txt_port.Text + "/api/v2/employee/update/?key={0}", txt_Key.Text);
|
||||
ResponseMode mode = NewEmp.PostMethodToObj(url, jsonObj);
|
||||
if (mode.ret != 0)
|
||||
{
|
||||
MessageBox.Show("保存失败,原因:请检查域名、端口、key值是否输入正确!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//成功后调用删除接口删除管理员并将SyncFlag初始化为0
|
||||
string Delsql = string.Format("select LoginAccount as pin from P_EmployeeTab where p_emp_EmployeeName='管理员'");
|
||||
DataTable delTable = SqlHelper.ExecuteDataTable(Delsql);
|
||||
string delurl = string.Format("http://" + txt_domainN.Text + ":" + txt_port.Text + "/api/v2/employee/delete/?key={0}", txt_Key.Text);
|
||||
jsonObj = JsonUtil.ToJsonArray(delTable);
|
||||
string deljson = jsonObj.Substring(1, jsonObj.Length - 2);
|
||||
NewEmp.PostMethodToObj(delurl, deljson);
|
||||
SqlHelper.ExecuteNonQuery(string.Format("update P_EmployeeTab set SyncFlag = {0}", 0));
|
||||
}
|
||||
|
||||
MessageBox.Show("保存成功!");
|
||||
ini.IniWriteValue("同步人员", "DomainN", txt_domainN.Text);
|
||||
ini.IniWriteValue("同步人员", "Port", txt_port.Text);
|
||||
ini.IniWriteValue("同步人员", "Timer", txt_timer.Text);
|
||||
ini.IniWriteValue("同步人员", "Deptnumber", txt_Deptnumber.Text);
|
||||
ini.IniWriteValue("同步人员", "Key", txt_Key.Text);
|
||||
fg = true;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_Close_Click(object sender, EventArgs e)
|
||||
{
|
||||
System.Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void config_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (fg)
|
||||
{
|
||||
e.Cancel = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("请点击配置检测是否输入正确!");
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in New Issue
Block a user