/// <summary> /// 服务器是否授权 /// </summary> /// <returns></returns> private static int CheckLisnese() { string file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "license.lck"); if (!File.Exists(file)) { return(-1); } StreamReader sr = new StreamReader(file); string lck = sr.ReadToEnd(); sr.Close(); if (string.IsNullOrEmpty(lck)) { return(-1); } //log.Fatal(lck); try { string decLck = Encrypt3DES.DecryptECB(lck); //log.Fatal(decLck); string[] strs = decLck.Split(new char[] { ';' }); if (strs.Length < 3) { return(-2); } //获取序列号 if (string.IsNullOrEmpty(serialN)) { var lst = MachineInfo.GetDiskVolumeSerialNumber().OrderBy(p => p.ToLower()); string vs = ""; foreach (string item in lst) { vs = vs + "|" + item; } serialN = vs.TrimStart('|'); } //log.Fatal(serialN); //验证硬盘序列号 if (serialN != strs[0]) { return(-3); } //验证有效日期 DateTime vildDt = DateTime.ParseExact(strs[1], "yyyyMMdd", null); if (vildDt.AddDays(1) < DateTime.Now) { return(-4); } return(0); } catch { return(-1); } }