示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
            }
        }
示例#4
0
 /// <summary>
 /// 获取文件绝对路径
 /// </summary>
 /// <param name="path">文件路径</param>
 /// <returns></returns>
 protected string MapPath(string path)
 {
     return(MyHostingEnvironment.MapPath(path));
 }