public Task StartAsync(CancellationToken cancellationToken)
        {
            TkDebug.ThrowIfNoAppSetting();
            var interval = WebAppSetting.WebCurrent.TimingInterval;

            fTimer = new Timer(DoWork, null, StartDelay, interval);

            return(Task.CompletedTask);
        }
Exemple #2
0
        public static void WriteFileUseWorkThread(string fileName, string content)
        {
            TkDebug.ThrowIfNoAppSetting();
            if (!BaseAppSetting.Current.UseWorkThread)
            {
                return;
            }

            TkDebug.ThrowIfNoGlobalVariable();

            BaseGlobalVariable.Current.BeginInvoke(new Action <string, string>(FileUtil.VerifySaveFile),
                                                   fileName, content);
        }
Exemple #3
0
        internal static void HandleStartExecption(string startName, Type errorType, Exception ex)
        {
            string type = errorType != null?errorType.ToString() : string.Empty;

            ExceptionData exData = new ExceptionData(null, type, null, ex);

            TkDebug.ThrowIfNoAppSetting();
            if (!BaseAppSetting.Current.UseWorkThread)
            {
                return;
            }

            TkDebug.ThrowIfNoGlobalVariable();
            string   fileName = WebAppSetting.WebCurrent.GetStartLogName(startName, exData.Exception);
            string   content  = exData.WriteXml();
            Encoding encoding = WriteSettings.Default.Encoding;

            SaveFile(fileName, content, encoding);
            //BaseGlobalVariable.Current.BeginInvoke(new Action<string, string, Encoding>(SaveFile),
            //    fileName, content, encoding);
        }
Exemple #4
0
        public ExceptionIndexer()
        {
            TkDebug.ThrowIfNoAppSetting();

            fFileName = Path.Combine(BaseAppSetting.Current.ErrorPath, "seed.ini");
            if (File.Exists(fFileName))
            {
                try
                {
                    this.ReadXmlFromFile(fFileName);
                }
                catch
                {
                    Index = 0;
                }
            }
            else
            {
                Index = 0;
            }
        }
        public Task HandleException(IWebHandler handler, WebBasePage page, Exception ex)
        {
            TkDebug.AssertArgument(ex is ReLogOnException, "ex", string.Format(ObjectUtil.SysCulture,
                                                                               "此Handler只处理ReLogonException,当前的Exception类型为{0}", ex.GetType()), this);
            TkDebug.ThrowIfNoAppSetting();

            string     logOnUrl = WebAppSetting.WebCurrent.LogOnPath;
            UriBuilder builder  = new UriBuilder(logOnUrl);
            string     retUrl   = "RetUrl=" + HttpUtility.UrlEncode(ex.Message);

            if (builder.Query != null && builder.Query.Length > 1)
            {
                builder.Query = builder.Query.Substring(1) + "&" + retUrl;
            }
            else
            {
                builder.Query = retUrl;
            }
            handler.Response.Redirect(builder.Uri.ToString(), false);

            return(Task.FromResult(0));
        }
Exemple #6
0
        public static string LogException(ExceptionData logData)
        {
            if (logData == null)
            {
                return(null);
            }

            TkDebug.ThrowIfNoAppSetting();
            if (!BaseAppSetting.Current.UseWorkThread)
            {
                return(null);
            }

            TkDebug.ThrowIfNoGlobalVariable();
            string   fileName = WebAppSetting.WebCurrent.GetExceptionLogName(logData.Exception);
            string   content  = logData.WriteXml();
            Encoding encoding = BaseAppSetting.Current.WriteSettings.Encoding;

            BaseGlobalVariable.Current.BeginInvoke(new Action <string, string, Encoding>(SaveFile),
                                                   fileName, content, encoding);

            return(fileName);
        }
Exemple #7
0
        public static string GetRealFileName(string fileName, FilePathPosition position)
        {
            TkDebug.ThrowIfNoAppSetting();
            switch (position)
            {
            case FilePathPosition.Application:
                fileName = Path.Combine(BaseAppSetting.Current.AppPath, fileName);
                break;

            case FilePathPosition.Error:
                fileName = Path.Combine(BaseAppSetting.Current.ErrorPath, fileName);
                break;

            case FilePathPosition.Solution:
                fileName = Path.Combine(BaseAppSetting.Current.SolutionPath, fileName);
                break;

            case FilePathPosition.Xml:
                fileName = Path.Combine(BaseAppSetting.Current.XmlPath, fileName);
                break;
            }
            return(fileName);
        }
Exemple #8
0
        public static string Decrypt(string source)
        {
            TkDebug.ThrowIfNoAppSetting();

            return(Decrypt(BaseAppSetting.Current.SecretKey, source));
        }
Exemple #9
0
        public static byte[] Encrypt(byte[] source)
        {
            TkDebug.ThrowIfNoAppSetting();

            return(Encrypt(BaseAppSetting.Current.SecretKey, source));
        }