基线 SVN r240
SVN-Revision: r240
This commit is contained in:
+228
@@ -0,0 +1,228 @@
|
||||
|
||||
namespace Lskj.SmsSending2
|
||||
{
|
||||
partial class FrmMain
|
||||
{
|
||||
/// <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.txtLog = new System.Windows.Forms.TextBox();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.txtTimeInterval = new System.Windows.Forms.TextBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.txtName = new System.Windows.Forms.TextBox();
|
||||
this.txtDataBase = new System.Windows.Forms.TextBox();
|
||||
this.txtPassword = new System.Windows.Forms.TextBox();
|
||||
this.txtSeverId = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.btnBegin = new System.Windows.Forms.Button();
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtLog
|
||||
//
|
||||
this.txtLog.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtLog.Location = new System.Drawing.Point(0, 90);
|
||||
this.txtLog.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txtLog.Multiline = true;
|
||||
this.txtLog.Name = "txtLog";
|
||||
this.txtLog.Size = new System.Drawing.Size(800, 360);
|
||||
this.txtLog.TabIndex = 4;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.label6);
|
||||
this.panel1.Controls.Add(this.txtTimeInterval);
|
||||
this.panel1.Controls.Add(this.label5);
|
||||
this.panel1.Controls.Add(this.txtName);
|
||||
this.panel1.Controls.Add(this.txtDataBase);
|
||||
this.panel1.Controls.Add(this.txtPassword);
|
||||
this.panel1.Controls.Add(this.txtSeverId);
|
||||
this.panel1.Controls.Add(this.label4);
|
||||
this.panel1.Controls.Add(this.label3);
|
||||
this.panel1.Controls.Add(this.label2);
|
||||
this.panel1.Controls.Add(this.label1);
|
||||
this.panel1.Controls.Add(this.btnBegin);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
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(800, 90);
|
||||
this.panel1.TabIndex = 3;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.Location = new System.Drawing.Point(687, 11);
|
||||
this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(104, 29);
|
||||
this.label6.TabIndex = 11;
|
||||
this.label6.Text = "秒(最短30秒)";
|
||||
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// txtTimeInterval
|
||||
//
|
||||
this.txtTimeInterval.Location = new System.Drawing.Point(560, 11);
|
||||
this.txtTimeInterval.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txtTimeInterval.Name = "txtTimeInterval";
|
||||
this.txtTimeInterval.Size = new System.Drawing.Size(117, 25);
|
||||
this.txtTimeInterval.TabIndex = 10;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.Location = new System.Drawing.Point(448, 11);
|
||||
this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(117, 29);
|
||||
this.label5.TabIndex = 9;
|
||||
this.label5.Text = "间隔时间设置";
|
||||
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// txtName
|
||||
//
|
||||
this.txtName.Location = new System.Drawing.Point(108, 50);
|
||||
this.txtName.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txtName.Name = "txtName";
|
||||
this.txtName.Size = new System.Drawing.Size(129, 25);
|
||||
this.txtName.TabIndex = 8;
|
||||
//
|
||||
// txtDataBase
|
||||
//
|
||||
this.txtDataBase.Location = new System.Drawing.Point(323, 11);
|
||||
this.txtDataBase.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txtDataBase.Name = "txtDataBase";
|
||||
this.txtDataBase.Size = new System.Drawing.Size(116, 25);
|
||||
this.txtDataBase.TabIndex = 7;
|
||||
//
|
||||
// txtPassword
|
||||
//
|
||||
this.txtPassword.Location = new System.Drawing.Point(323, 50);
|
||||
this.txtPassword.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txtPassword.Name = "txtPassword";
|
||||
this.txtPassword.PasswordChar = '*';
|
||||
this.txtPassword.Size = new System.Drawing.Size(116, 25);
|
||||
this.txtPassword.TabIndex = 6;
|
||||
//
|
||||
// txtSeverId
|
||||
//
|
||||
this.txtSeverId.Location = new System.Drawing.Point(108, 11);
|
||||
this.txtSeverId.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.txtSeverId.Name = "txtSeverId";
|
||||
this.txtSeverId.Size = new System.Drawing.Size(129, 25);
|
||||
this.txtSeverId.TabIndex = 5;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.Location = new System.Drawing.Point(232, 11);
|
||||
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(95, 29);
|
||||
this.label4.TabIndex = 4;
|
||||
this.label4.Text = "数据库";
|
||||
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.Location = new System.Drawing.Point(16, 50);
|
||||
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(95, 29);
|
||||
this.label3.TabIndex = 3;
|
||||
this.label3.Text = "登录名称";
|
||||
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.Location = new System.Drawing.Point(232, 50);
|
||||
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(95, 29);
|
||||
this.label2.TabIndex = 2;
|
||||
this.label2.Text = "登录密码";
|
||||
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Location = new System.Drawing.Point(16, 11);
|
||||
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(95, 29);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "服务器地址";
|
||||
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// btnBegin
|
||||
//
|
||||
this.btnBegin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnBegin.Location = new System.Drawing.Point(679, 48);
|
||||
this.btnBegin.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.btnBegin.Name = "btnBegin";
|
||||
this.btnBegin.Size = new System.Drawing.Size(105, 29);
|
||||
this.btnBegin.TabIndex = 0;
|
||||
this.btnBegin.Text = "开始发送";
|
||||
this.btnBegin.UseVisualStyleBackColor = true;
|
||||
this.btnBegin.Click += new System.EventHandler(this.btnBegin_Click);
|
||||
//
|
||||
// FrmMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.txtLog);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Name = "FrmMain";
|
||||
this.Text = "Form1";
|
||||
this.Load += new System.EventHandler(this.FrmMain_Load);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox txtLog;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.TextBox txtTimeInterval;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.TextBox txtName;
|
||||
private System.Windows.Forms.TextBox txtDataBase;
|
||||
private System.Windows.Forms.TextBox txtPassword;
|
||||
private System.Windows.Forms.TextBox txtSeverId;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button btnBegin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,429 @@
|
||||
using Lskj.Control;
|
||||
using Lskj.Core;
|
||||
using Lskj.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using static Lskj.SmsSending2.NewEmp;
|
||||
|
||||
namespace Lskj.SmsSending2
|
||||
{
|
||||
public partial class FrmMain : Form
|
||||
{
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ini文件内段落名
|
||||
/// </summary>
|
||||
public string company = "短信发送工具";
|
||||
/// <summary>
|
||||
/// 初始时间间隔
|
||||
/// </summary>
|
||||
public int second = 30;
|
||||
/// <summary>
|
||||
/// 账号
|
||||
/// </summary>
|
||||
public string SMSID;
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public string SMSPwd;
|
||||
/// <summary>
|
||||
/// post接口地址
|
||||
/// </summary>
|
||||
public string postUrl = "https://sdk3.028lk.com:9988/BatchSend2.aspx";
|
||||
|
||||
public System.Timers.Timer timer1 = new System.Timers.Timer();
|
||||
|
||||
|
||||
private void FrmMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
txtSeverId.Text = IniUtil.IniReadValue(company, "serverName");
|
||||
txtDataBase.Text = IniUtil.IniReadValue(company, "dbName");
|
||||
txtName.Text = IniUtil.IniReadValue(company, "user");
|
||||
txtPassword.Text = IniUtil.IniReadValue(company, "password");
|
||||
txtTimeInterval.Text = IniUtil.IniReadValue(company, "interval");
|
||||
if (string.IsNullOrEmpty(txtTimeInterval.Text)) txtTimeInterval.Text = "30";
|
||||
txtTimeInterval.LostFocus += new EventHandler(txtTimeInterval_LostFocus);
|
||||
|
||||
this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(timer1_Tick);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 时间间隔TextBox失去焦点事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void txtTimeInterval_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
string checkStr = txtTimeInterval.Text.ToString();
|
||||
if (string.IsNullOrEmpty(checkStr)) txtTimeInterval.Text = "30";
|
||||
int check = Convert.ToInt32(txtTimeInterval.Text.ToString());
|
||||
if (check < 30)
|
||||
{
|
||||
txtTimeInterval.Text = "30";
|
||||
}
|
||||
second = Convert.ToInt32(txtTimeInterval.Text.ToString());
|
||||
IniUtil.IniWriteValue(company, "interval", txtTimeInterval.Text.ToString());
|
||||
}
|
||||
|
||||
//点击发送
|
||||
private void btnBegin_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ConnectServer())
|
||||
{
|
||||
//检测并创建表
|
||||
UpdateMsgTab();
|
||||
|
||||
SMSID = IniUtil.IniReadValue(company, "SMSID");
|
||||
SMSPwd = IniUtil.IniReadValue(company, "SMSPwd");
|
||||
if (string.IsNullOrEmpty(SMSID) || string.IsNullOrEmpty(SMSPwd))
|
||||
{
|
||||
RefreshLogUIThread("短信消息发送错误:未配置账号信息\r\n");
|
||||
return;
|
||||
}
|
||||
SendData();
|
||||
timer1.Interval = second * 1000;
|
||||
timer1.Enabled = true;
|
||||
this.timer1.Start();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RefreshLogUIThread(DateTime.Now + string.Format("失败.原因:{0}.\r\n", ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//发送数据
|
||||
private void SendData()
|
||||
{
|
||||
int success = 0, failed = 0, tot = 0;
|
||||
try
|
||||
{
|
||||
DataTable dataTable = SqlHelper.ExecuteDataTable("select id, phonestr as Mobile, msgstr as Content from lk_apidatatab where isnull(sendFlag, '') = 0 and isnull(phonestr, '') <> ''");
|
||||
tot = dataTable.Rows.Count;
|
||||
RefreshLogUIThread(string.Format("开始新一轮短信消息推送,本次将推送{0}条消息=========\r\n", tot));
|
||||
DataTable dtcopy = dataTable.Copy();
|
||||
//dtcopy.Columns["phonestr"].ColumnName = "Mobile";
|
||||
//dtcopy.Columns["msgstr"].ColumnName = "Content";
|
||||
//if (!dataTable.Columns.Contains("Cell")) dtcopy.Columns.Add("Cell");
|
||||
//if (!dataTable.Columns.Contains("SendTime ")) dtcopy.Columns.Add("SendTime ");
|
||||
dtcopy.Columns.Remove("id");
|
||||
|
||||
for (int i = 0; i < dataTable.Rows.Count; i++)
|
||||
{
|
||||
|
||||
//SMSID = "222";
|
||||
//string jsonObj = JsonUtil.ToJsonObject(dtcopy.Rows[i]);
|
||||
//string deljson = jsonObj.Substring(1, jsonObj.Length - 2);
|
||||
//deljson = deljson.Insert(1, string.Format("\"CorpID\":\"{0}\",\"Pwd\":\"{1}\",", SMSID, SMSPwd));
|
||||
//deljson = deljson.Insert(deljson.Length-1, ",\"Cell\"=, \"SendTime\"=");
|
||||
//deljson="{ \"Mobile\":\"15008278310\",\"Content\":\"测试数据\",\"Cell\":\"1\",\"SendTime \":\"\",\"CorpID\":\"CDJT001634\",\"Pwd\":\"426F7A\"}";
|
||||
//ResponseMode mode = NewEmp.PostMethodToObj(postUrl, deljson);
|
||||
|
||||
|
||||
HttpTools.setting("application/x-www-form-urlencoded;charset=utf-8", null, null);
|
||||
Dictionary<string, string> dataDic = new Dictionary<string, string>();
|
||||
dataDic.Add("CorpID", SMSID);
|
||||
dataDic.Add("Pwd", SMSPwd);
|
||||
dataDic.Add("Mobile", dataTable.Rows[i]["Mobile"]+"");
|
||||
dataDic.Add("Content", dataTable.Rows[i]["Content"]+"");
|
||||
dataDic.Add("Cell", "");
|
||||
dataDic.Add("SendTime", "");
|
||||
string mode = HttpTools.Post(postUrl, "", dataDic, HttpTools.Method.POST);
|
||||
//string mode = NewEmp.PostMethodToObj(postUrl, deljson);
|
||||
//string url = string.Format("https://sdk3.028lk.com:9988/BatchSend2.aspx?CorpID={0}&Pwd={1}&Mobile={2}&Content={3}&Cell=&SendTime=", SMSID, SMSPwd, dataTable.Rows[i]["Mobile"], dataTable.Rows[i]["Content"]);
|
||||
//string mode = NewEmp.GetUrl(url);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(mode))
|
||||
{
|
||||
if (Convert.ToInt32(mode) > 0) success++;
|
||||
string sql = string.Format(@"update lk_apidatatab set sendFlag=1,sendResult='{0}' where id='{1}'", mode, dataTable.Rows[i]["id"]);
|
||||
SqlHelper.ExecuteNonQuery(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RefreshLogUIThread(DateTime.Now + string.Format("失败.原因:{0}.\r\n", ex.Message));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (tot > 0) RefreshLogUIThread(string.Format("本轮短信消息发送{0}条消息,成功{1}条,失败{2}条=========", tot, success, tot - success));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// timer事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
timer1.Enabled = false;
|
||||
//txtLog.Text = null;
|
||||
SendData();
|
||||
timer1.Enabled = true;
|
||||
}
|
||||
|
||||
//判断是否有表,没有则创建
|
||||
private void UpdateMsgTab()
|
||||
{
|
||||
|
||||
string sql = string.Format(@"if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[{0}]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
|
||||
exec('CREATE TABLE [dbo].[{0}](
|
||||
[id] [int] primary key IDENTITY(1,1) NOT NULL,
|
||||
[phonestr] [varchar](8000) NULL,
|
||||
[msgstr] [varchar](8000) NULL,
|
||||
[createdate] [datetime] NULL default getdate(),
|
||||
[cltig] [int] NULL,
|
||||
[cldate] [datetime] NULL default 0,
|
||||
[sendFlag] int not null default 0,
|
||||
[sendResult] varchar(1000) null
|
||||
)
|
||||
');
|
||||
", "lk_apidatatab");
|
||||
SqlHelper.ExecuteNonQuery(sql);
|
||||
}
|
||||
|
||||
|
||||
/// <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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#region 连接服务器
|
||||
/// <summary>
|
||||
/// <para>说明:连接服务器</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-09 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="isSave">if set to <c>true</c> [is save].</param>
|
||||
public bool ConnectServer(bool isSave = false)
|
||||
{
|
||||
string serverName = this.txtSeverId.Text.Trim();
|
||||
string dbName = this.txtDataBase.Text.Trim();
|
||||
string user = this.txtName.Text.Trim();
|
||||
string password = this.txtPassword.Text.Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(serverName))
|
||||
{
|
||||
MessageUtil.Show(ResourceKeys.ServerNameIsNull);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dbName))
|
||||
{
|
||||
MessageUtil.Show(ResourceKeys.ServerDBIsNull);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(user))
|
||||
{
|
||||
MessageUtil.Show("请重新输入用户名");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 测试数据库连接
|
||||
try
|
||||
{
|
||||
if (CreateConnection())
|
||||
{
|
||||
if (isSave)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
IniUtil.IniWriteValue(company, "serverName", serverName);
|
||||
IniUtil.IniWriteValue(company, "dbName", dbName);
|
||||
IniUtil.IniWriteValue(company, "user", user);
|
||||
IniUtil.IniWriteValue(company, "password", password);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show(ResourceKeys.ConnectFault);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageUtil.Show(ResourceKeys.ConnectFault);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <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 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)
|
||||
{
|
||||
// LogHelper.Instance.WriteLog(ex.Message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取连接服务器的字符串
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetConnection()
|
||||
{
|
||||
return string.Format("Server={0};Database={1};Persist Security Info=True;User ID={2};Password={3};Connection Timeout=5;MultipleActiveResultSets=true", txtSeverId.Text.ToString(), txtDataBase.Text.ToString(), txtName.Text.ToString(), txtPassword.Text.ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
public static class HttpTools
|
||||
{
|
||||
public static CookieContainer cookie = new CookieContainer(); // 用于记录访问网页时cookie数据
|
||||
public static CookieCollection cookieCollection;
|
||||
|
||||
private static string ContentType = string.Empty;// "application/x-www-form-urlencoded";
|
||||
private static string Accept = string.Empty;//"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
|
||||
private static string UserAgent = string.Empty;//"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14";
|
||||
public enum Method
|
||||
{
|
||||
POST = 0,
|
||||
GET = 1
|
||||
}
|
||||
public static void setting(string contentType, string accept, string userAgent)
|
||||
{
|
||||
ContentType = contentType;
|
||||
Accept = accept;
|
||||
UserAgent = userAgent;
|
||||
}
|
||||
/// <summary>
|
||||
/// post数据到指定的网址,获取cookie数据,和返回页
|
||||
/// </summary>
|
||||
public static string Post(string url, string postData, Dictionary<string, string> dic, Method method)
|
||||
{
|
||||
return Post(url, postData, dic, method, out cookieCollection);
|
||||
}
|
||||
/// <summary>
|
||||
/// post数据到指定的网址,获取cookie数据,和返回页
|
||||
/// </summary>
|
||||
public static string Post(string url, string postData, Dictionary<string, string> dic, Method method, out CookieCollection cookieCollection)
|
||||
{
|
||||
HttpWebResponse httpWebResponse = null;
|
||||
try
|
||||
{
|
||||
HttpWebRequest httpWebRequest;
|
||||
httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||
|
||||
httpWebRequest.CookieContainer = cookie;
|
||||
httpWebRequest.ContentType = ContentType;
|
||||
httpWebRequest.Referer = url;
|
||||
httpWebRequest.Accept = Accept;
|
||||
httpWebRequest.UserAgent = UserAgent;
|
||||
httpWebRequest.Method = method == Method.POST ? "POST" : "GET";
|
||||
byte[] byteRequest = null;
|
||||
if (!string.IsNullOrEmpty(postData))
|
||||
{
|
||||
byteRequest = Encoding.Default.GetBytes(postData);
|
||||
httpWebRequest.ContentLength = byteRequest.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int i = 0;
|
||||
foreach (var item in dic)
|
||||
{
|
||||
if (i > 0)
|
||||
builder.Append("&");
|
||||
builder.AppendFormat("{0}={1}", item.Key, item.Value);
|
||||
i++;
|
||||
}
|
||||
byteRequest = Encoding.UTF8.GetBytes(builder.ToString());
|
||||
httpWebRequest.ContentLength = byteRequest.Length;
|
||||
}
|
||||
Stream stream = httpWebRequest.GetRequestStream();
|
||||
stream.Write(byteRequest, 0, byteRequest.Length);
|
||||
stream.Close();
|
||||
|
||||
httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
|
||||
Stream responseStream = httpWebResponse.GetResponseStream();
|
||||
StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8);
|
||||
string result = streamReader.ReadToEnd();
|
||||
streamReader.Close();
|
||||
responseStream.Close();
|
||||
|
||||
cookieCollection = cookie.GetCookies(new Uri(url));
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
cookieCollection = null;
|
||||
return "错误,请求失败";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
namespace SynchronousOven.HttpUtil
|
||||
{
|
||||
public static class GetUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>说明:获取Response Html</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-08-24 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string Get(string url)
|
||||
{
|
||||
return RequestUtil.HttpGet(url);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取JSON数据</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <returns>T.</returns>
|
||||
public static T GetJson<T>(string url)
|
||||
{
|
||||
string returnText = RequestUtil.HttpGet(url);
|
||||
JavaScriptSerializer js = new JavaScriptSerializer();
|
||||
T result = js.Deserialize<T>(returnText);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取JSON数据</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="header">The header.</param>
|
||||
/// <returns>T.</returns>
|
||||
public static T GetJson<T>(string url, WebHeaderCollection header)
|
||||
{
|
||||
string returnText = RequestUtil.HttpGet(url, header);
|
||||
JavaScriptSerializer js = new JavaScriptSerializer();
|
||||
T result = js.Deserialize<T>(returnText);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SynchronousOven.HttpUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// Request请求枚举
|
||||
/// </summary>
|
||||
public enum MethodEnum
|
||||
{
|
||||
POST,
|
||||
GET,
|
||||
PUT,
|
||||
DELETE
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
namespace SynchronousOven.HttpUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// Post帮助类
|
||||
/// </summary>
|
||||
public static class PostUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>说明:获取Post结果</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="returnText">The return text.</param>
|
||||
/// <returns>T.</returns>
|
||||
public static T GetResult<T>(string returnText)
|
||||
{
|
||||
JavaScriptSerializer js = new JavaScriptSerializer();
|
||||
T result = js.Deserialize<T>(returnText);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:发起Post请求</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">返回数据类型(Json对应的实体)</typeparam>
|
||||
/// <param name="url">请求Url</param>
|
||||
/// <param name="content">The content.</param>
|
||||
/// <returns>T.</returns>
|
||||
public static T PostUrl<T>(string url, string content)
|
||||
{
|
||||
string returnText = RequestUtil.HttpPost(url, content);
|
||||
var result = GetResult<T>(returnText);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:发起Post请求</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="content">The content.</param>
|
||||
/// <param name="header">The header.</param>
|
||||
/// <returns>T.</returns>
|
||||
public static T PostUrl<T>(string url, string content, WebHeaderCollection header)
|
||||
{
|
||||
string returnText = RequestUtil.HttpPost(url, content, header);
|
||||
var result = GetResult<T>(returnText);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:发起Post请求</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="content">The content.</param>
|
||||
/// <param name="header">The header.</param>
|
||||
/// <param name="method">The method.</param>
|
||||
/// <returns>T.</returns>
|
||||
public static T PostUrl<T>(string url, string content, WebHeaderCollection header, MethodEnum method)
|
||||
{
|
||||
string returnText = RequestUtil.HttpPost(url, content, header, method);
|
||||
var result = GetResult<T>(returnText);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:发起Post请求</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">返回数据类型(Json对应的实体)</typeparam>
|
||||
/// <param name="url">请求Url</param>
|
||||
/// <param name="cookieContainer">CookieContainer,如果不需要则设为null</param>
|
||||
/// <param name="fileName">要发送的文件名,如果不需要上传则设为null</param>
|
||||
/// <returns>T.</returns>
|
||||
public static T PostGetJson<T>(string url, CookieContainer cookieContainer, string fileName)
|
||||
{
|
||||
string returnText = RequestUtil.HttpPost(url, cookieContainer, fileName);
|
||||
var result = GetResult<T>(returnText);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:发起Post请求</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">返回数据类型(Json对应的实体)</typeparam>
|
||||
/// <param name="url">请求Url</param>
|
||||
/// <param name="cookieContainer">CookieContainer,如果不需要则设为null</param>
|
||||
/// <param name="fileStream">文件流</param>
|
||||
/// <returns>T.</returns>
|
||||
public static T PostGetJson<T>(string url, CookieContainer cookieContainer, Stream fileStream)
|
||||
{
|
||||
string returnText = RequestUtil.HttpPost(url, cookieContainer, fileStream);
|
||||
var result = GetResult<T>(returnText);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
namespace SynchronousOven.HttpUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// Request请求帮助类
|
||||
/// </summary>
|
||||
public static class RequestUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>说明:使用Get方法获取字符串结果(暂时没有加入Cookie)</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string HttpGet(string url)
|
||||
{
|
||||
WebClient wc = new WebClient();
|
||||
wc.Encoding = Encoding.UTF8;
|
||||
return wc.DownloadString(url);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:使用Get方法获取字符串结果(暂时没有加入Cookie)</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="header">The header.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string HttpGet(string url, WebHeaderCollection header)
|
||||
{
|
||||
WebClient wc = new WebClient();
|
||||
if (header != null)
|
||||
{
|
||||
wc.Headers = header;
|
||||
}
|
||||
wc.Encoding = Encoding.UTF8;
|
||||
return wc.DownloadString(url);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:使用Post方法获取字符串结果</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="cookieContainer">The cookie container.</param>
|
||||
/// <param name="fileName">Name of the file.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string HttpPost(string url, CookieContainer cookieContainer, string fileName)
|
||||
{
|
||||
FileStream fileStream = null;
|
||||
if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName))
|
||||
{
|
||||
//读取文件
|
||||
fileStream = new FileStream(fileName, FileMode.Open);
|
||||
}
|
||||
return HttpPost(url, cookieContainer, fileStream);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:使用Post方法获取字符串结果</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="content">The content.</param>
|
||||
/// <param name="timeout">The timeout.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string HttpPost(string url, string content, int timeout = 5000)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = "POST";
|
||||
request.ServicePoint.Expect100Continue = false;
|
||||
request.ContentType = "application/json;charset=utf8";
|
||||
request.Timeout = timeout;
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(content);
|
||||
request.ContentLength = buffer.Length;
|
||||
request.GetRequestStream().Write(buffer, 0, buffer.Length);
|
||||
HttpWebResponse response = null;
|
||||
try
|
||||
{
|
||||
response = (HttpWebResponse)request.GetResponse();
|
||||
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
response = (HttpWebResponse)ex.Response;
|
||||
Console.WriteLine(ex.Message);
|
||||
return "";
|
||||
}
|
||||
using (Stream responseStream = response.GetResponseStream())
|
||||
{
|
||||
using (StreamReader myStreamReader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8")))
|
||||
{
|
||||
string retString = myStreamReader.ReadToEnd();
|
||||
return retString;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:使用Post方法获取字符串结果</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="content">The content.</param>
|
||||
/// <param name="header">The header.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string HttpPost(string url, string content, WebHeaderCollection header)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = "POST";
|
||||
if (header != null)
|
||||
{
|
||||
request.Headers = header;
|
||||
}
|
||||
request.ServicePoint.Expect100Continue = false;
|
||||
request.ContentType = "application/json;charset=utf8";
|
||||
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(content);
|
||||
request.ContentLength = buffer.Length;
|
||||
request.GetRequestStream().Write(buffer, 0, buffer.Length);
|
||||
HttpWebResponse response = null;
|
||||
try
|
||||
{
|
||||
response = (HttpWebResponse)request.GetResponse();
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
response = (HttpWebResponse)ex.Response;
|
||||
Console.WriteLine(ex.Message);
|
||||
return "";
|
||||
}
|
||||
using (Stream responseStream = response.GetResponseStream())
|
||||
{
|
||||
using (StreamReader myStreamReader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8")))
|
||||
{
|
||||
string retString = myStreamReader.ReadToEnd();
|
||||
return retString;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:使用Post方法获取字符串结果</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="content">The content.</param>
|
||||
/// <param name="header">The header.</param>
|
||||
/// <param name="method">The method.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string HttpPost(string url, string content, WebHeaderCollection header, MethodEnum method)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = method.ToString();
|
||||
if (header != null)
|
||||
{
|
||||
request.Headers = header;
|
||||
}
|
||||
request.ServicePoint.Expect100Continue = false;
|
||||
request.ContentType = "application/json;charset=utf8";
|
||||
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(content);
|
||||
request.ContentLength = buffer.Length;
|
||||
request.GetRequestStream().Write(buffer, 0, buffer.Length);
|
||||
HttpWebResponse response = null;
|
||||
try
|
||||
{
|
||||
response = (HttpWebResponse)request.GetResponse();
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
response = (HttpWebResponse)ex.Response;
|
||||
Console.WriteLine(ex.Message);
|
||||
return "";
|
||||
}
|
||||
using (Stream responseStream = response.GetResponseStream())
|
||||
{
|
||||
using (StreamReader myStreamReader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8")))
|
||||
{
|
||||
string retString = myStreamReader.ReadToEnd();
|
||||
return retString;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:使用Post方法获取字符串结果</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="cookieContainer">The cookie container.</param>
|
||||
/// <param name="fileStream">The file stream.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string HttpPost(string url, CookieContainer cookieContainer, Stream fileStream)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = "POST";
|
||||
//request.ContentType = "application/x-www-form-urlencoded";
|
||||
request.ContentType = "application/json;charset=utf8";
|
||||
request.ContentLength = fileStream != null ? fileStream.Length : 0;
|
||||
|
||||
if (cookieContainer != null)
|
||||
{
|
||||
request.CookieContainer = cookieContainer;
|
||||
}
|
||||
if (fileStream != null)
|
||||
{
|
||||
Stream requestStream = request.GetRequestStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead = 0;
|
||||
while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
|
||||
{
|
||||
requestStream.Write(buffer, 0, bytesRead);
|
||||
}
|
||||
fileStream.Close();//关闭文件访问
|
||||
}
|
||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
if (cookieContainer != null)
|
||||
{
|
||||
response.Cookies = cookieContainer.GetCookies(response.ResponseUri);
|
||||
}
|
||||
using (Stream responseStream = response.GetResponseStream())
|
||||
{
|
||||
using (StreamReader myStreamReader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8")))
|
||||
{
|
||||
string retString = myStreamReader.ReadToEnd();
|
||||
return retString;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:请求是否发起自客户端的浏览器</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2019-07-30 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="httpContext">The HTTP context.</param>
|
||||
/// <returns><c>true</c> if [is sogou client request] [the specified HTTP context]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsSogouClientRequest(HttpContext httpContext)
|
||||
{
|
||||
return !string.IsNullOrEmpty(httpContext.Request.UserAgent) &&
|
||||
httpContext.Request.UserAgent.Contains("MicroMessenger");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Lskj.SmsSending2
|
||||
{
|
||||
public static class IniUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// ini文件目录
|
||||
/// </summary>
|
||||
static string Path = System.IO.Directory.GetCurrentDirectory() + "\\" + "Setting.ini";
|
||||
|
||||
/// <summary>
|
||||
/// ini文件获取数据
|
||||
/// </summary>
|
||||
/// <param name="section"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defVal"></param>
|
||||
/// <param name="retVal"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("kernel32")]
|
||||
private static extern int GetPrivateProfileString(string section, string key, string defVal, StringBuilder retVal, int size, string filePath);
|
||||
|
||||
/// <summary>
|
||||
/// ini文件写入数据
|
||||
/// </summary>
|
||||
/// <param name="section"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="val"></param>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("kernel32")]
|
||||
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
|
||||
|
||||
/// <summary>
|
||||
/// 写INI文件
|
||||
/// </summary>
|
||||
/// <param name="section">段落</param>
|
||||
/// <param name="key">键</param>
|
||||
/// <param name="iValue">值</param>
|
||||
public static void IniWriteValue(string section, string key, string iValue)
|
||||
{
|
||||
WritePrivateProfileString(section, key, iValue, Path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取INI文件
|
||||
/// </summary>
|
||||
/// <param name="section">段落</param>
|
||||
/// <param name="key">键</param>
|
||||
/// <returns>返回的键值</returns>
|
||||
public static string IniReadValue(string section, string key)
|
||||
{
|
||||
StringBuilder temp = new StringBuilder(255);
|
||||
int i = GetPrivateProfileString(section, key, "", temp, 255, Path);
|
||||
return temp.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
|
||||
namespace Lskj.SmsSending2
|
||||
{
|
||||
public static class JsonUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>说明:json 字符串转换为DataTable</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-10-23 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="json">The json.</param>
|
||||
/// <returns>DataTable.</returns>
|
||||
public static DataTable ToDataTable(this string json)
|
||||
{
|
||||
DataTable dataTable = new DataTable(); //实例化
|
||||
DataTable result;
|
||||
try
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
javaScriptSerializer.MaxJsonLength = Int32.MaxValue; //取得最大数值
|
||||
ArrayList arrayList = javaScriptSerializer.Deserialize<ArrayList>(json);
|
||||
if (arrayList.Count > 0)
|
||||
{
|
||||
foreach (Dictionary<string, object> dictionary in arrayList)
|
||||
{
|
||||
if (dictionary.Keys.Count<string>() == 0)
|
||||
{
|
||||
result = dataTable;
|
||||
return result;
|
||||
}
|
||||
if (dataTable.Columns.Count == 0)
|
||||
{
|
||||
foreach (string current in dictionary.Keys)
|
||||
{
|
||||
dataTable.Columns.Add(current, dictionary[current].GetType());
|
||||
}
|
||||
}
|
||||
DataRow dataRow = dataTable.NewRow();
|
||||
foreach (string current in dictionary.Keys)
|
||||
{
|
||||
dataRow[current] = dictionary[current];
|
||||
}
|
||||
|
||||
dataTable.Rows.Add(dataRow); //循环添加行到DataTable中
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
result = dataTable;
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-10-23 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="json">The json.</param>
|
||||
/// <returns>DataRow.</returns>
|
||||
public static DataRow ToDataRow(this string json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json)) return null;
|
||||
|
||||
return ToDataTable(json).Rows[0];
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:DataTable To JsonArray</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-10-23 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="dtTable">The dt table.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string ToJsonArray(this DataTable dtTable)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
javaScriptSerializer.MaxJsonLength = Int32.MaxValue; //取得最大数值
|
||||
ArrayList arrayList = new ArrayList();
|
||||
foreach (DataRow dataRow in dtTable.Rows)
|
||||
{
|
||||
Dictionary<string, object> dictionary = new Dictionary<string, object>(); //实例化一个参数集合
|
||||
foreach (DataColumn dataColumn in dtTable.Columns)
|
||||
{
|
||||
dictionary.Add(dataColumn.ColumnName, dataRow[dataColumn.ColumnName].ToStr());
|
||||
}
|
||||
arrayList.Add(dictionary); //ArrayList集合中添加键值
|
||||
}
|
||||
|
||||
return javaScriptSerializer.Serialize(arrayList); //返回一个json字符串
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:DataRow To Json</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-10-23 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="row">The row.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string ToJsonObject(this DataRow row)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
javaScriptSerializer.MaxJsonLength = Int32.MaxValue; //取得最大数值
|
||||
ArrayList arrayList = new ArrayList();
|
||||
|
||||
Dictionary<string, object> dictionary = new Dictionary<string, object>(); //实例化一个参数集合
|
||||
foreach (DataColumn dataColumn in row.Table.Columns)
|
||||
{
|
||||
dictionary.Add(dataColumn.ColumnName, row[dataColumn.ColumnName].ToStr());
|
||||
}
|
||||
arrayList.Add(dictionary); //ArrayList集合中添加键值
|
||||
return javaScriptSerializer.Serialize(arrayList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-10-23 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="s">The s.</param>
|
||||
/// <param name="format">The format.</param>
|
||||
/// <returns>A <see cref="System.String" /> that represents this instance.</returns>
|
||||
public static string ToStr(this object s, string format = "")
|
||||
{
|
||||
string result = string.Empty;
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(format))
|
||||
{
|
||||
result = s.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = string.Format("{0:" + format + "}", s);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" 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>{85476C79-8411-46B0-9E70-70CC7DD8DDF0}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Lskj.SmsSending2</RootNamespace>
|
||||
<AssemblyName>Lskj.SmsSending2</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</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>logo.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Lskj.Business">
|
||||
<HintPath>引用dll\Lskj.Business.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Lskj.Control">
|
||||
<HintPath>引用dll\Lskj.Control.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Lskj.Core">
|
||||
<HintPath>引用dll\Lskj.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Lskj.Data">
|
||||
<HintPath>引用dll\Lskj.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>引用dll\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<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="FrmMain.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FrmMain.Designer.cs">
|
||||
<DependentUpon>FrmMain.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="HttpUtil\GetUtil.cs" />
|
||||
<Compile Include="HttpUtil\MethodEnum.cs" />
|
||||
<Compile Include="HttpUtil\PostUtil.cs" />
|
||||
<Compile Include="HttpUtil\RequestUtil.cs" />
|
||||
<Compile Include="IniUtil.cs" />
|
||||
<Compile Include="JsonUtil.cs" />
|
||||
<Compile Include="MsgInfo.cs" />
|
||||
<Compile Include="NewEmp.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="FrmMain.resx">
|
||||
<DependentUpon>FrmMain.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>
|
||||
</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>
|
||||
<Content Include="logo.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31613.86
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lskj.SmsSending2", "Lskj.SmsSending2.csproj", "{85476C79-8411-46B0-9E70-70CC7DD8DDF0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{85476C79-8411-46B0-9E70-70CC7DD8DDF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{85476C79-8411-46B0-9E70-70CC7DD8DDF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{85476C79-8411-46B0-9E70-70CC7DD8DDF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{85476C79-8411-46B0-9E70-70CC7DD8DDF0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {204D78FA-AF41-423E-A423-927C1CDC3171}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Lskj.SmsSending2
|
||||
{
|
||||
//消息信息类
|
||||
public class MsgInfo
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Lskj.SmsSending2
|
||||
{
|
||||
public sealed class NewEmp
|
||||
{
|
||||
/// <summary>
|
||||
/// 同步数据
|
||||
/// </summary>
|
||||
/// <param name="
|
||||
/// ">没有特殊说明,传入</param>
|
||||
public static string PostMethodToObj(string url, string jsonObj)
|
||||
{
|
||||
try
|
||||
{
|
||||
return SynchronousOven.HttpUtil.PostUtil.PostUrl<string>(url, jsonObj);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
//return JsonConvert.SerializeObject(new ResponseMode{ code = "-1", errorMsg = "非法操作." });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步数据
|
||||
/// </summary>
|
||||
public static string GetUrl(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
return SynchronousOven.HttpUtil.GetUtil.GetJson<string>(url);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
//return JsonConvert.SerializeObject(new ResponseMode{ code = "-1", errorMsg = "非法操作." });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class ResponseMode
|
||||
{
|
||||
public int ret;
|
||||
public string msg;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.SmsSending2
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new FrmMain());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("Lskj.SmsSending2")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Lskj.SmsSending2")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("85476c79-8411-46b0-9e70-70cc7dd8ddf0")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,70 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本: 4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Lskj.SmsSending2.Properties
|
||||
{
|
||||
/// <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 ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lskj.SmsSending2.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,29 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Lskj.SmsSending2.Properties
|
||||
{
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.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 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user