资源简介
C#编写的Winform程序,可以丢在服务器定时调用接口,无需配置,比Win服务方便一点,源码开放可自行拓展
![](http://www.nz998.com/pic/31852.jpg)
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CallInter
{
public partial class Form1 : Form
{
int count = 0;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender EventArgs e)
{
count = count + 1;
label3.Text = “最新执行时间:“ + DateTime.Now + “ 总共执行了“ + count + “次“;
GetPost(this.textBox1.Text this.textBox2.Text);
}
private void button1_Click(object sender EventArgs e)
{
if (string.IsNullOrWhiteSpace(this.textBox1.Text))
{
MessageBox.Show(“执行前必须输入接口地址与参数“);
return;
}
label3.Text = “服务已启动...“;
saveCf(“reurl“ this.textBox1.Text);
if (!string.IsNullOrWhiteSpace(textBox2.Text))
{
saveCf(“repar“ this.textBox2.Text);
}
if (!string.IsNullOrWhiteSpace(textBox3.Text))
{
saveCf(“loaddate“ textBox3.Text);
}
timer1.Interval = Convert.ToInt32(textBox3.Text) * 1000;
this.button1.Enabled = true;
this.timer1.Enabled = true;
}
private void button2_Click(object sender EventArgs e)
{
this.timer1.Enabled = false;
this.button1.Enabled = true;
this.button2.Enabled = false;
}
public string GetPost(string url string par string token = ““)
{
try
{
var request = (HttpWebRequest)WebRequest.Create(url);
var data = Encoding.ASCII.GetBytes(par);
request.Method = “POST“;
request.ContentType = “application/x-www-form-urlencoded“;
request.ContentLength = data.Length;
if (!string.IsNullOrWhiteSpace(token))
request.Headers.Add(“ApiAuthorization“ token);
using (var stream = request.GetRequestStream())
{
stream.Write(data 0 data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
return new StreamReader(response.GetResponseStream()).ReadToEnd();
}
catch
{
return ““;
}
}
///
/// 获取配置文件中的路径
///
///
public static string GetFileUrl(string fileurl)
{
if (!string.IsNullOrWhiteSpace(fileurl))
{
return System.Configuration.Configuration
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-03-05 16:07 CallInter\
文件 917 2019-03-05 16:04 CallInter.sln
文件 288 2019-03-16 11:16 CallInter\App.config
目录 0 2019-03-05 16:04 CallInter\bin\
目录 0 2019-08-23 15:35 CallInter\bin\Debug\
文件 12800 2019-08-23 17:24 CallInter\bin\Debug\CallInter.exe
文件 346 2019-09-12 14:32 CallInter\bin\Debug\CallInter.exe.Config
文件 28160 2019-08-23 17:24 CallInter\bin\Debug\CallInter.pdb
文件 22984 2019-08-23 17:24 CallInter\bin\Debug\CallInter.vshost.exe
文件 347 2019-09-12 14:32 CallInter\bin\Debug\CallInter.vshost.exe.Config
文件 490 2012-06-06 02:06 CallInter\bin\Debug\CallInter.vshost.exe.manifest
文件 3847 2019-03-16 11:56 CallInter\CallInter.csproj
文件 4480 2019-08-23 17:24 CallInter\Form1.cs
文件 6654 2019-08-23 17:24 CallInter\Form1.Designer.cs
文件 6011 2019-08-23 17:24 CallInter\Form1.resx
目录 0 2019-03-05 16:04 CallInter\obj\
目录 0 2019-08-23 17:24 CallInter\obj\Debug\
文件 1443 2019-08-23 17:24 CallInter\obj\Debug\CallInter.csproj.FileListAbsolute.txt
文件 975 2019-08-23 17:24 CallInter\obj\Debug\CallInter.csproj.GenerateResource.Cache
文件 2364 2019-08-23 17:18 CallInter\obj\Debug\CallInter.csprojResolveAssemblyReference.cache
文件 12800 2019-08-23 17:24 CallInter\obj\Debug\CallInter.exe
文件 180 2019-08-23 17:24 CallInter\obj\Debug\CallInter.Form1.resources
文件 28160 2019-08-23 17:24 CallInter\obj\Debug\CallInter.pdb
文件 180 2019-08-23 15:25 CallInter\obj\Debug\CallInter.Properties.Resources.resources
文件 1308 2019-03-16 11:07 CallInter\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7088 2019-08-23 15:07 CallInter\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 0 2019-03-05 16:04 CallInter\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2019-03-05 16:04 CallInter\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2019-03-05 16:04 CallInter\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
目录 0 2019-03-05 16:04 CallInter\obj\Debug\TempPE\
文件 521 2019-03-05 16:04 CallInter\Program.cs
............此处省略6个文件信息
- 上一篇:基于RFID的员工考勤应用系统
- 下一篇:C# 计算机行为监控
相关资源
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
- c#向word文件插入图片
- C#左侧导航菜单(动态生成)
- C#TCP 通信(TCP发送16进制)
- C# sql实现批量导入数据到数据库
评论
共有 条评论