public static void BuildPrivateKey() { var path = MyHostingEnvironment.MapPath(_rsaPath); string privateKey; RsaUtil.CreateKey(out privateKey); System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path)); System.IO.File.WriteAllText(path, privateKey); RsaUtil.GetParams(privateKey, out string modulus, out string exponent); _exponent = exponent; _modulus = modulus; _privateKey = privateKey; //_timeout = DateTime.Now.AddSeconds(60); }
public override void WriteLog(string type, string content) { var Time = DateTime.Now; var filePath = new StringBuilder(File_Name); filePath.Replace("{time}", (Time.Ticks / 1000).ToString()); filePath.Replace("{yyyy}", Time.Year.ToString()); filePath.Replace("{yy}", (Time.Year % 100).ToString("D2")); filePath.Replace("{MM}", Time.Month.ToString("D2")); filePath.Replace("{dd}", Time.Day.ToString("D2")); filePath.Replace("{HH}", Time.Hour.ToString("D2")); filePath.Replace("{hh}", Time.Hour.ToString("D2")); filePath.Replace("{mm}", Time.Minute.ToString("D2")); filePath.Replace("{ss}", Time.Second.ToString("D2")); filePath.Replace("{type}", type); var file = MyHostingEnvironment.MapPath(filePath.ToString()); file = Path.GetFullPath(file); Directory.CreateDirectory(Path.GetDirectoryName(file)); fileLoggerQueue.EnqueueMessage(file, content); }
private static void GetPrivateKey() { if (_privateKey == null /*|| _timeout == null || _timeout.Value < DateTime.Now*/) { var path = MyHostingEnvironment.MapPath(_rsaPath); string privateKey; if (System.IO.File.Exists(path) == false) { RsaUtil.CreateKey(out privateKey); System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path)); System.IO.File.WriteAllText(path, privateKey); } else { privateKey = System.IO.File.ReadAllText(path); } RsaUtil.GetParams(privateKey, out string modulus, out string exponent); _exponent = exponent; _modulus = modulus; _privateKey = privateKey; //_timeout = DateTime.Now.AddSeconds(60); } }
/// <summary> /// 获取文件绝对路径 /// </summary> /// <param name="path">文件路径</param> /// <returns></returns> protected string MapPath(string path) { return(MyHostingEnvironment.MapPath(path)); }