计算机后台服务-更新下载,重启————未来之窗行业应用跨平台架构
一在教育中应用
1. 提高效率:能够快速收集大量学生的卷子,节省了传统人工收集和整理的时间。
2. 准确性:减少了人工收卷过程中可能出现的错漏和混乱,确保每份卷子都能准确无误地被收集和记录。
3. 即时性:可以实时接收学生提交的卷子,老师能够更快地开始批改和评估。
4. 自动化处理:自动对卷子进行初步分类、编号等处理,方便后续的管理和查找。
5. 数据安全:卷子以电子形式存储在后台服务器,相对更安全,降低了丢失或损坏的风险。
6. 便于统计分析:可以对收卷情况进行统计,例如提交时间、未提交人数等,为教学管理提供数据支持。
7. 环保节能:减少了纸张的使用,有利于环保。
8. 远程操作:支持学生在不同地点远程提交卷子,适应在线教育和混合教学模式。
二、代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Net;
using System.IO;
using System.Web;
using System.Collections.Specialized;
using System.Threading;
using System.Web;
using System.Net.Sockets;
using System.IO;
using System;
namespace CyberWin.Work.Qjcx.CloudDeploymentClientSvr
{
public partial class Service1 : ServiceBase
{
private int Cyber_Port = 23415;
private Thread CyberThread;
private Thread CyberThread_bordcast_client;
EndPoint ep;
string receiveData;
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
CyberThread = new Thread(new ThreadStart(cy_web));
CyberThread_bordcast_client = new Thread(new ThreadStart(AcceptMessage));
// Process.Start("CyberWin.Work.Qjcx.Cloudonline.exe");
CyberThread.Start();
CyberThread_bordcast_client.Start();
// CyberThread_bordcast_client = new Thread(new ThreadStart(AcceptMessage));
// CyberThread_bordcast_client.Start();
}
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to stop your service.
CyberThread.Abort();
CyberThread_bordcast_client.Abort();
}
//接受广播并回传数据
#region
//接收信息
private void AcceptMessage()
{
try
{
//d定义socket对象
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint iep = new IPEndPoint(IPAddress.Any, 1244);
socket.Bind(iep);
ep = (EndPoint)iep;
byte[] bytes = new byte[1024];
while (true)
{
socket.ReceiveFrom(bytes, ref ep);
receiveData = System.Text.Encoding.Unicode.GetString(bytes);
receiveData = receiveData.TrimEnd('\u0000');
Thread th = new Thread(new ThreadStart(Acc));
th.Start();
//th.Abort();
}
socket.Close();
}catch(Exception ex){}
}
private void Acc()
{
try
{
//string message = "来自" + ep.ToString() + "的消息";
//DialogResult result = MessageBox.Show(receiveData, message, MessageBoxButtons.AbortRetryIgnore);
string ip = ep.ToString();
int pos = ip.IndexOf(":");
string ip_add = ip.Substring(0, pos);
OpenReadWithHttps("http://" + ip_add + ":1214/未来之窗?client=" + cls_computer_operator.GetLocalIP(), "", "GB2312");
}catch (Exception ex){
}
}
///<summary>
///采用https协议访问网络
///</summary>
///<param name="URL">url地址</param>
///<param name="strPostdata">发送的数据</param>
///<returns></returns>
private static string OpenReadWithHttps(string URL, string strPostdata, string strEncoding)
{
try
{
Encoding encoding = Encoding.Default;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = "post";
request.Accept = "text/html, application/xhtml+xml, */*";
request.ContentType = "application/x-www-form-urlencoded";
byte[] buffer = encoding.GetBytes(strPostdata);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding(strEncoding)))
{
return reader.ReadToEnd();
}
}
catch (Exception ex)
{
return "cyber_empty";
}
}
#endregion
//
private void cy_web()
{
//AcceptMessage();
using (HttpListener hl = new HttpListener())
{
hl.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
hl.Prefixes.Add("http://*:" + Cyber_Port + "/cyberwinsvr/");
hl.Start();
while (true)
{
HttpListenerContext ctx = hl.GetContext();
ctx.Response.StatusCode = 200;
//ctx.Request.
string l = ctx.Request.QueryString["like"];
string m = ctx.Request.QueryString["m"];
using (StreamWriter w = new StreamWriter(ctx.Response.OutputStream, Encoding.UTF8))
{
string responseBody = cls_Cloud_Deployment_client.cyber_cmd(ctx.Request);
w.WriteLine(responseBody);
//w.WriteLine("hello2222刘7777" + System.Web.HttpUtility.UrlDecode(l, Encoding.ASCII) + "郭荣华第二:" + System.Web.HttpUtility.UrlDecode(ctx.Request.Url.ToString(), Encoding.ASCII) + "<br>mm==" + m);
w.Flush();
w.Close();
}
}
}
}
}
}
三、阿雪技术观
拥抱开源与共享,见证科技进步奇迹,畅享人类幸福时光!
让我们积极投身于技术共享的浪潮中,不仅仅是作为受益者,更要成为贡献者。无论是分享自己的代码、撰写技术博客,还是参与开源项目的维护和改进,每一个小小的举动都可能成为推动技术进步的巨大力量