嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 3 元微信扫码支付:3 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common.WinService;
using Common.Log;
using System.Threading;
using Common.Net;
using System.Text.RegularExpressions;
namespace Collection.AutoRunner
{
//获取学生信息
public class Service_Update_Data : IWindowsService
{
private ILogWriter _logWriter = null;
private const string logCategory = "Services.Info";
private string logInfoSource = "Update_Data";
private const string logErrorCategory = "Services.Error";
private const string logErrorSource = "Update_Data_Error";
private bool BeStop = true;
private System.Timers.Timer timer = null;
public void Start(Common.Log.ILogWriter logWriter, string gameCode)
{
gameCode = gameCode.ToUpper();
logInfoSource = gameCode;
_logWriter = logWriter;
BeStop = false;
StartRequestData();
}
int stata = 0;
private void StartRequestData()
{
try
{
#region 配置
//时间频率
var UpdateStudentSpan = ServiceHelper.GetInterval("UpdateData");
//更新学生开始时间
var studentbegintime = ServiceHelper.GetInterval("StudentBeginTime");
//更新学生结束时间
var studentendtime = ServiceHelper.GetInterval("StudentEndTime");
//是否更新学生基本信息:true为更新 false为不更新
var IsUpdateStudnet =Convert.ToBoolean(ServiceHelper.GetSystemConfig("IsUpdateStudnet"));
#endregion
timer = ServiceHelper.ExcuteByTimer(UpdateStudentSpan, () =>
{
int timeHour = DateTime.Now.Hour;
if (timeHour == 3)
stata = 0;
#region 更新学生基本信息
if (studentbegintime <= timeHour && timeHour < studentendtime && stata == 0 && IsUpdateStudnet)
{
stata = 1;
StudentInfo();
}
else
{
this.WriteLog("还未到获取学生基本信息的时间段内... ");
}
#endregion
StartRequestData();
});
}
catch (Exception ex)
{
this.WriteLog("获取学生信息数据出错 - " ex.Message);
}
}
private void StudentInfo()
{
int repeatTimes = 0;
try
{
this.WriteLog("开始获取学生信息数据....");
this.WriteLog("学生信息数据获取完成....");
}
catch (Exception ex)
{
this.WriteLog("获取学生信息数据出错 - DoWork -" ex.Message);
if (repeatTimes == 0)
{
repeatTimes ;
StudentInfo();
}
}
}
public void Stop()
{
BeStop = true;
if (timer != null)
timer.Stop();
}
public void WriteError(string log)
{
_logWriter.Write(logErrorCategory, logErrorSource, LogType.Error, "自动获取学生信息数据异常", log);
}
public void WriteLog(string log)
{
_logWriter.Write(logCategory, logInfoSource, LogType.Information, "自动获取学生信息数据", log);
}
}
}