Ejemplo n.º 1
0
        public async Task<bool> WriteLogDB_SMSReceiveList(ReceiveMsgStruct logContent)
        {

            AbstractWorker theWorker = GetWorker("ReceiveDBLogWorker", "ReceiveDBLogWorker");
            var result = await theWorker.PushAsync(logContent);
            return result;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 向文件日志写日志内容
        /// </summary>
        /// <param name="fileName">日志文件名</param>
        /// <param name="logContent">日志内容</param>
        public async Task<bool> WriteLogFile(string logContent, Exception ex)
        {
            string filePath = "";
            if (string.IsNullOrEmpty(ep.ErrorPath))
            {
                filePath = System.AppDomain.CurrentDomain.BaseDirectory;
            }
            else
            {
                filePath = ep.ErrorPath;
            }

            StringBuilder builder = new StringBuilder();
            builder.AppendLine("------------------- " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " BEGIN -------------------");
            builder.AppendLine(logContent);
            builder.AppendFormat("ex.Message:{0}", ex.Message).AppendLine();
            builder.AppendFormat("ex.Source:{0}", ex.Source).AppendLine();
            builder.AppendFormat("ex.StackTrace:{0}", ex.StackTrace).AppendLine();
            builder.AppendLine("\n----------------------------- END -------------------------------");


            AbstractWorker theWorker = GetWorker("FileLogWorker", filePath + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
            var result = await theWorker.PushAsync(builder.ToString());
            return result;
        }
Ejemplo n.º 3
0
        public async Task<bool> WriteLogFile(string logContent)
        {
            string filePath = "";
            if (string.IsNullOrEmpty(ep.ErrorPath))
            {
                filePath = System.AppDomain.CurrentDomain.BaseDirectory;
            }
            else
            {
                filePath = ep.ErrorPath;
            }

            AbstractWorker theWorker = GetWorker("FileLogWorker", filePath + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
            var result = await theWorker.PushAsync(logContent);
            return result;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 使用list来保存活动logworker,并且使用另外的线程来close niut
        /// 以此来实现动态管理
        /// </summary>
        /// <param name="createParam"></param>
        /// <returns></returns>
        private AbstractWorker GetWorker(string type, string createParam)
        {
            try
            {
                return _Workers[createParam];
            }
            catch
            {
                lock (typeof(LocalLockObject))
                {
                    if (_Workers.ContainsKey(createParam) == false)
                    {
                        AbstractWorker theWorker = null;
                        if (type == "FileLogWorker")
                        {
                            theWorker = new FileLogWorker(createParam);
                        }
                        else if (type == "ReceiveDBLogWorker")
                        {
                            theWorker = new ReceiveDBLogWorker();
                        }
                        else if (type == "SendDBLogWorker")
                        {
                            theWorker = new SendDBLogWorker();
                        }
                        else if (type == "SMSOperationWorker")
                        {
                            theWorker = new SMSOperationWorker();
                        }
                        else
                        {
                            return null;
                        }

                        _Workers.Add(createParam, theWorker);
                        return theWorker;
                    }
                    else
                    {
                        return _Workers[createParam];
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public async Task<bool> WriteSendQueue(ReceiveMsgStruct logContent)
 {
     AbstractWorker theWorker = GetWorker("SMSOperationWorker", "SMSOperationWorker");
     var result = await theWorker.PushAsync(logContent);
     return result;
 }
Ejemplo n.º 6
0
 public async Task<bool> WriteLogDB_SMSSendList(SendMsgStruct logContent)
 {
     AbstractWorker theWorker = GetWorker("SendDBLogWorker", "SendDBLogWorker");
     var result = await theWorker.PushAsync(logContent);
     return result;
 }