gyhlw_dotnet/网站项目/VRS/Management/ZTest.aspx.cs

519 lines
18 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using Telerik.Web.UI;
namespace VRS.Management
{
public partial class ZTest : System.Web.UI.Page
{
DataService.BLL.pro_result bll = new DataService.BLL.pro_result();
DataService.BLL.pro_result_detail bll_result_detail = new DataService.BLL.pro_result_detail();
DataService.BLL.pro_subject_proc bll_subject_proc = new DataService.BLL.pro_subject_proc();
DataService.BLL.admin_user bll_user = new DataService.BLL.admin_user();
DataService.BLL.exam_result bll_exam_result = new DataService.BLL.exam_result();
DataService.BLL.exam_result_detail bll_exam_result_detail = new DataService.BLL.exam_result_detail();
public void read_ydpz_wgpz()
{
var savePath = @"E:\工作项目\2023项目\工业互联网网络互联项目_四个场景版\文档\竞赛答案配置表 - 测试.xlsx";
var sheet = "云端配置-网关配置";
var dt =BasePage.ExcelToDataTable(savePath, sheet, 0, true, true);
}
public void read_ydpz2()
{
}
private void test()
{
var result = new DataService.Model.exam_result();
result.total = 100;
result.score = 97;
result.sjms = "1";
result.subject = "科目";
result.user_id = "USER202304231453328503";
var json_str = JsonConvert.SerializeObject(result);
List<DataService.Model.exam_result_detail_shixun> list = new List<DataService.Model.exam_result_detail_shixun>();
var item1 = new DataService.Model.exam_result_detail_shixun();
item1.no = 1;
item1.score = 50;
item1.total = 48;
item1.description = "步骤1";
list.Add(item1);
item1 = new DataService.Model.exam_result_detail_shixun();
item1.no = 2;
item1.score = 50;
item1.total = 49;
item1.description = "步骤2";
list.Add(item1);
var json_str2 = JsonConvert.SerializeObject(list);
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//save_xml();
test();
var result = new DataService.Model.exam_result();
result.total = 100;
result.score = 90;
result.sjms = "考核";
result.subject = "科目";
result.user_id = "USER202304231453328503";
var json_str = JsonConvert.SerializeObject(result);
List<DataService.Model.exam_result_detail> list = new List<DataService.Model.exam_result_detail>();
var item1 = new DataService.Model.exam_result_detail();
item1.no = 1;
item1.questionType = "选择题";
item1.rightAnswer = "rightAnswer1";
item1.yourAnswer = "yourAnswer1";
item1.allSpace = 11;
item1.rightSpace = 12;
item1.score = 50;
item1.total = 44;
item1.result = 1;
list.Add(item1);
item1 = new DataService.Model.exam_result_detail();
item1.no = 2;
item1.questionType = "填空题";
item1.rightAnswer = "rightAnswer2";
item1.yourAnswer = "yourAnswer2";
item1.allSpace = 22;
item1.rightSpace = 24;
item1.score = 50;
item1.total = 46;
item1.result = 0;
list.Add(item1);
var json_str2 = JsonConvert.SerializeObject(list);
//身份证校验
var val = id_card("320123198211243039");
var val1 = id_card("320123198706203020");
var val2 = id_card("320111201106053224");
//获取json_str
//var model = bll_user.GetModelList("").First();
//var json_str = JsonConvert.SerializeObject(model);
#region guid获取
var guid = Guid.NewGuid().ToString("N");
var len = guid.Length;
var vv = BasePage.GetNewId();
var ll = BasePage.GetLongId();
var dic = new Dictionary<string, int>();
Stopwatch sw = new Stopwatch();
//开始计时
sw.Start();
for (int z = 0; z < 100000; z++)
{
dic.Add(BasePage.GetLongId(), 0);
}
//结束计时
sw.Stop();
//获取运行时间[毫秒]
long times1 = sw.ElapsedMilliseconds;
/*
//重新设置并开始计时
sw.Restart();
//获取运行时间间隔
TimeSpan ts = sw.Elapsed;
var dic2 = new Dictionary<string, int>();
Parallel.For(0, 1000000, p =>
{
dic2.Add(BasePage.GetLongId(), p);
});
long times2 = sw.ElapsedMilliseconds;
*/
var qqzz = 0;
#endregion
int weekNo = 0;
double secondOfweek = 0;
var now = DateTime.Now.AddHours(-8);
UTC2GPS(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, ref weekNo, ref secondOfweek);
var a = weekNo;
var b = secondOfweek;
//RadWindow1.Visible = true;
//loan 2_guitar
//deposit 2_yuan
//main 28_marquis + 28_deluxe
//practice slg200 + a3r
// solo 95 strum 85 28_marquis
// solo 90 strum 85 28_deluxe
// solo 80 strum 90 j45 out
// solo 80 strum 80 a3r practice
// solo 85 strum 75 fg3 out
// solo 85 strum 75 ll16 out
// solo 75 strum 75 fg830 out
//3月份
// 3,5 4,6 5,5 6,5
// 7,5 8,5 9,5 0,5
//4月份
// 3,0 4,0 5,5 6,5
// 7,5 8,5 9,5 0,5
//单位 管理员
return;
}
}
void UTC2GPS(int year, int month, int day, int hour, int minute, double second, ref int weekNo, ref double miniSencondOfweek)
{
/*****协调世界时转换为GPS的周秒表示*****///输入时间应为协调世界时,即当地时间-8返回时间为GPS周和周秒
int DayofYear = 0;
int DayofMonth = 0;
for (int i = 1980; i < year; i++) //从1980年到当前年的上一年经过的天数
{
if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
DayofYear += 366;
else
DayofYear += 365;
}
for (int i = 1; i < month; i++) //从一月到当前月的上一月经历的天数
{
if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
DayofMonth += 31;
else if (i == 4 || i == 6 || i == 9 || i == 11)
DayofMonth += 30;
else
{
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
DayofMonth += 29;
else
DayofMonth += 28;
}
}
int Day;
Day = DayofMonth + day + DayofYear - 6;
weekNo = Day / 7;
var secondOfweek = Day % 7 * 86400 + hour * 3600 + minute * 60 + second + 18;//18表示跳秒
miniSencondOfweek = secondOfweek * 1000;
}
public bool id_card(string str)
{
//从第一位到第十七位的系数分别为7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2
if (str.Length == 18)
{
var sum = int.Parse(str.Substring(0, 1)) * 7 + int.Parse(str.Substring(1, 1)) * 9 + int.Parse(str.Substring(2, 1)) * 10 + int.Parse(str.Substring(3, 1)) * 5
+ int.Parse(str.Substring(4, 1)) * 8 + int.Parse(str.Substring(5, 1)) * 4 + int.Parse(str.Substring(6, 1)) * 2 + int.Parse(str.Substring(7, 1)) * 1
+ int.Parse(str.Substring(8, 1)) * 6 + int.Parse(str.Substring(9, 1)) * 3 + int.Parse(str.Substring(10, 1)) * 7 + int.Parse(str.Substring(11, 1)) * 9
+ int.Parse(str.Substring(12, 1)) * 10 + int.Parse(str.Substring(13, 1)) * 5 + int.Parse(str.Substring(14, 1)) * 8 + int.Parse(str.Substring(15, 1)) * 4
+ int.Parse(str.Substring(16, 1)) * 2;
var mod = sum % 11;
//余数只可能有0 1 2 3 4 5 6 7 8 9 10这11个数字。其分别对应的最后一位身份证的号码为1 0 X 9 8 7 6 5 4 3 2
var dic = new Dictionary<int, string>();
dic.Add(0, "1");
dic.Add(1, "0");
dic.Add(2, "X");
dic.Add(3, "9");
dic.Add(4, "8");
dic.Add(5, "7");
dic.Add(6, "6");
dic.Add(7, "5");
dic.Add(8, "4");
dic.Add(9, "3");
dic.Add(10, "2");
var compute = dic[mod];
var last_str = str.Substring(17, 1);
if (compute == last_str.ToUpper())
{
return true;
}
else
{
return false;
}
}
return false;
}
public void get_data()
{
#region
var FilePath = @"E:\工作项目\内河船舶船员培训系统二期\文档\IDS.json";
string fileData = System.IO.File.ReadAllText(FilePath);
var ids = Newtonsoft.Json.JsonConvert.DeserializeObject<IDS>(fileData);
#endregion
foreach (var subject in ids.subjects)
{
if (subject.name == "油船洗舱作业") //$$$$
{
var list = subject.nodes.OrderBy(s => s.nid).ToList();
List<string> listBoatType = new List<string>();
listBoatType.Add("b1");
listBoatType.Add("b2");
listBoatType.Add("b3");
listBoatType.Add("b4");
int total = 0;
foreach (var boatId in listBoatType)
{
for (int i = 0; i < list.Count; i++)
{
var node = list[i];
var proc = new DataService.Model.pro_subject_proc();
proc.proc_id = BasePage.GetNewId("proc");
proc.subject_id = "1006"; //$$$$
proc.step = node.nid;
proc.tip = node.tip;
proc.dsc = node.explain;
proc.score = node.score;
proc.boatId = boatId;
proc.is_op = 1;
proc.deviceId = node.deviceId;
proc.type = node.type;
proc.seat = node.seat;
proc.state = node.state;
proc.enable = node.enable ? 1 : 0;
proc.seconds = node.seconds;
proc.ddl = node.ddl;
if (bll_subject_proc.Add(proc))
{
total++;
}
}
}
var count = total;
}
/*
Console.WriteLine("===" + subject.name + "===");
foreach (var proc in subject.nodes)
{
Console.WriteLine(proc.tip);
}
Console.WriteLine("======");
*/
}
}
public static List<PersonOM> GetResult()
{
List<PersonOM> lstPs = new List<PersonOM>();
PersonOM ps = null;
for (int i = 1; i <= 10; i++)
{
ps = new PersonOM();
ps.Name = "Name" + i;
ps.Age = 20 + i;
lstPs.Add(ps);
}
return lstPs;
}
public List<PersonOM> GetResult2()
{
return ZTest.GetResult();
}
public class PersonOM
{
public string Name { get; set; }
public int Age { get; set; }
}
/*
public void save_xml()
{
string path = @"D:\Temp\test.xml";
if (!File.Exists(path))
{
var stream = File.Create(path);
stream.Close();
}
XmlDocument xmlDoc = new XmlDocument();//新建XML文件
xmlDoc.Load(path);//加载XML文件
//XmlNode xm = xmlDoc.SelectSingleNode("RFI");
//XmlElement xelKey = xmlDoc.CreateElement("RFIID");
//XmlAttribute xelType = xmlDoc.CreateAttribute("Type");
//xelType.InnerText = "data";
//xelKey.SetAttributeNode(xelType);
//XmlElement xelAuthor = xmlDoc.CreateElement("author");
//xelKey.InnerText = "dfdsa";
//xm.AppendChild(xelKey);
//xmlDoc.Save(path);
var temp = xmlDoc.GetElementsByTagName("RFI");
//var element =xmlDoc.CreateElement("RFIID2");
var element = xmlDoc.GetElementById("id_rfid");
if (null == element)
{
XmlAttribute xelType = xmlDoc.CreateAttribute("Type");
xelType.InnerText = "data";
element.SetAttributeNode(xelType);
XmlAttribute xelType2 = xmlDoc.CreateAttribute("Flag");
xelType.InnerText = "1";
element.SetAttributeNode(xelType2);
}
element.InnerText = DateTime.Now.ToString("yyyyMMddHHmmss");
xmlDoc.DocumentElement.AppendChild(element);
xmlDoc.Save(path);
}
*/
/// <summary>
/// 步骤类
/// </summary>
public class NodesItem
{
/// <summary>
///
/// </summary>
public int nid { get; set; }
/// <summary>
///
/// </summary>
public string deviceId { get; set; }
/// <summary>
/// 拟进入密闭空间前进行通风
/// </summary>
public string tip { get; set; }
/// <summary>
/// 船员正在进行进入密闭空间前的通风操作
/// </summary>
public string explain { get; set; }
/// <summary>
/// 检查
/// </summary>
public string type { get; set; }
/// <summary>
///
/// </summary>
public int score { get; set; }
/// <summary>
/// 消防员
/// </summary>
public string seat { get; set; }
/// <summary>
/// 未完成
/// </summary>
public string state { get; set; }
/// <summary>
///
/// </summary>
public bool enable { get; set; }
/// <summary>
///
/// </summary>
public int seconds { get; set; }
/// <summary>
///
/// </summary>
public int ddl { get; set; }
}
/// <summary>
/// 科目类
/// </summary>
public class SubjectsItem
{
/// <summary>
///
/// </summary>
public string id { get; set; }
/// <summary>
/// 进入密闭空间作业
/// </summary>
public string name { get; set; }
/// <summary>
/// 内河油船常见的密闭空间包括但不限于:货油舱、压载舱、干隔舱、泵舱、锚链舱、淡水柜、燃油舱等...
/// </summary>
public string note { get; set; }
/// <summary>
/// GameScene_IDS进入密闭空间作业
/// </summary>
public string scene { get; set; }
/// <summary>
///
/// </summary>
public int deadline { get; set; }
/// <summary>
///
/// </summary>
public int scorePerStep { get; set; }
/// <summary>
///
/// </summary>
public List<NodesItem> nodes { get; set; }
}
/// <summary>
/// IDS根节点
/// </summary>
public class IDS
{
/// <summary>
///
/// </summary>
public List<SubjectsItem> subjects { get; set; }
}
}
}