Commit faa65200 authored by 潘梓豪's avatar 潘梓豪

更新巡检

parent a75c82c6
using LitJson;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using TMPro;
using UnityEngine.UI;
public class ValManager : MonoBehaviour
{
public TMP_Text text;
public Button login_btn;
IEnumerator Start()
{
//string path = "C:\\Users\\Zeus_PC\\Desktop\\testval\\ReqData.json";
//string path = "ReqData.json";
login_btn.onClick.AddListener(()=>{
/*using (var rq = UnityWebRequest.Get(arg[4] + "/getRobotCode?productionid=" + arg[2] + "&code=" + code))
{
rq.SetRequestHeader("Authorization", arg[1]);
yield return rq.SendWebRequest();
if (string.IsNullOrEmpty(rq.error))
{
Dictionary<string, object> jsonData = JsonMapper.ToObject<Dictionary<string, object>>(rq.downloadHandler.text);
string scene = (string)jsonData.Where(S => S.Key == "LoadScene").Select(S => S.Value).First();
if (scene != null && !scene.Equals(""))
{
text.text = "验证成功,正在跳转。。。";
SceneManager.LoadScene(scene);
//删除参数配置文件
//File.Delete(path);
}
else
{
text.text = "没有注册码,请先注册";
}
}
}*/
});
string[] arg= Environment.GetCommandLineArgs();
if(arg!=null && arg.Length > 1)
{
valInit(arg);
//重定向项目路径
Directory.SetCurrentDirectory(arg[3]);
//获取本机code
string code = getMNum();
//通过机器码code、产品id判读是否已校验
using (var rq = UnityWebRequest.Get(arg[4] + "/getRobotCode?productionid=" + arg[2] + "&code=" + code))
{
rq.SetRequestHeader("Authorization", arg[1]);
yield return rq.SendWebRequest();
if (string.IsNullOrEmpty(rq.error))
{
Dictionary<string, object> jsonData = JsonMapper.ToObject<Dictionary<string, object>>(rq.downloadHandler.text);
string scene = (string)jsonData.Where(S => S.Key == "LoadScene").Select(S => S.Value).First();
if (scene != null && !scene.Equals(""))
{
text.text = "验证成功,正在跳转。。。";
SceneManager.LoadScene(scene);
//删除参数配置文件
//File.Delete(path);
}
else
{
text.text = "没有注册码,请先注册";
}
}
}
}
else
{
text.text = "丢失参数文件,请在ZeusHub中启动软件";
}
yield return null;
}
public bool valInit(string[] arg)
{
if (arg[4] == "" || arg[4].Equals(""))
{
text.text = "缺少验证地址,请联系技术人员";
return false;
}
else if (arg[2] == "" || arg[2].Equals(""))
{
text.text = "缺少产品id,请联系技术人员";
return false;
}
else
{
return true;
}
}
//生成机器码
public static string getMNum()
{
//string strNum = getCpu() + GetDiskVolumeSerialNumber();//获得24位Cpu和硬盘序列号
string strNum = SystemInfo.deviceUniqueIdentifier;
string strMNum = strNum.Substring(0, 24);//从生成的字符串中取出前24个字符做为机器码
return strMNum;
}
public static int[] intCode = new int[127];//存储密钥
public static int[] intNumber = new int[25];//存机器码的Ascii值
public static char[] Charcode = new char[25];//存储机器码字
public static void setIntCode()//给数组赋值小于10的数
{
for (int i = 1; i < intCode.Length; i++)
{
intCode[i] = i % 9;
}
}
public static string getRNum()
{
setIntCode();//初始化127位数组
for (int i = 1; i < Charcode.Length; i++)//把机器码存入数组中
{
Charcode[i] = Convert.ToChar(getMNum().Substring(i - 1, 1));
}
for (int j = 1; j < intNumber.Length; j++)//把字符的ASCII值存入一个整数组中。
{
intNumber[j] = intCode[Convert.ToInt32(Charcode[j])] + Convert.ToInt32(Charcode[j]);
}
string strAsciiName = "";//用于存储注册码
for (int j = 1; j < intNumber.Length; j++)
{
if (intNumber[j] >= 48 && intNumber[j] <= 57)//判断字符ASCII值是否0-9之间
{
strAsciiName += Convert.ToChar(intNumber[j]).ToString();
}
else if (intNumber[j] >= 65 && intNumber[j] <= 90)//判断字符ASCII值是否A-Z之间
{
strAsciiName += Convert.ToChar(intNumber[j]).ToString();
}
else if (intNumber[j] >= 97 && intNumber[j] <= 122)//判断字符ASCII值是否a-z之间
{
strAsciiName += Convert.ToChar(intNumber[j]).ToString();
}
else//判断字符ASCII值不在以上范围内
{
if (intNumber[j] > 122)//判断字符ASCII值是否大于z
{
strAsciiName += Convert.ToChar(intNumber[j] - 10).ToString();
}
else
{
strAsciiName += Convert.ToChar(intNumber[j] - 9).ToString();
}
}
}
return strAsciiName;
}
public void click_btn()
{
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
}
fileFormatVersion: 2
guid: 3645793e778ee4d43b802f5ff4b5939d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: 2fb874f12e51eac468ce370c58911cbf
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: 91b55352dd7722f489a1e4115408540f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment