123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace parkMonitor.LOG
- {
- /// <summary>
- /// 凭证
- /// </summary>
- public class Credence
- {
- private static List<string> digitCredence = new List<string>();
- /// <summary>
- /// 获取一个凭证
- /// </summary>
- /// <param name="terminalFlag">终端机标识</param>
- /// <param name="num">随机码位数</param>
- /// <returns></returns>
- public static string GetOneCredence()
- {
- string context = "";
- //digitCredence = CredentialsGenerator.GetCredential(terminalFlag,num);
- if (digitCredence.Count != 0)
- {
- context = digitCredence[0];
- digitCredence.RemoveAt(0);
- }
- return context;
- }
- /// <summary>
- /// 读取所有凭证
- /// </summary>
- /// <returns></returns>
- public static bool ReadCredence()
- {
- digitCredence.Clear();
- //string date = System.DateTime.Now.ToString("yyyy-MM-dd");
- //string filePath = logAddress + "\\\\" + date + "\\\\" + "CREDENCES.log";
- string filePath = LogManager.logAddress + "\\\\" + "CREDENCES.log";
- try
- {
- List<string> logLines = null;
- if (File.Exists(filePath))
- {
- logLines = new List<string>(File.ReadAllLines(filePath));
- File.Delete(filePath);
- }
- if (logLines != null)
- {
- for (int i = 0; i < 300; i++)
- {
- string logLine = logLines[i];
- digitCredence.Add(logLine);
- logLines.RemoveAt(i);
- }
- File.WriteAllLines(filePath, logLines.ToArray());
- }
- }
- catch (Exception e) { Console.WriteLine(e.Message); Log.WriteLog(LogType.process, LogFile.ERROR, "凭证获取失败");return false; }
- return true;
- }
- }
- }
|