/// <summary> /// 功能:获取日志文件内容 /// </summary> /// <param name="strLogFileName">日志文件名称或路径</param> /// <returns>日志文件内容</returns> public static FeedBackResponse <string> GetLogFileContent(string strLogFileName) { FeedBackResponse <string> fbrReturn = new FeedBackResponse <string>(); string strFilePath = System.IO.Path.GetDirectoryName(strLogFileName); if (string.IsNullOrWhiteSpace(strFilePath)) { List <string> lstPath = SysLogHelper.GetLogPath(); if (lstPath.Count == 0) { fbrReturn.Message = "获取日志路径失败!"; } else { lstPath.ForEach(lp => { string strLogFilePath = System.IO.Path.Combine(lp, strLogFileName); if (FileHelper.IsFileExist(strLogFilePath)) { fbrReturn.ResultData = GetLogContent(strLogFilePath); return; } }); } } else { fbrReturn.ResultData = GetLogContent(strLogFileName); } return(fbrReturn); }
/// <summary> /// 功能:组合处理结果 /// </summary> /// <param name="fbrReturn">待返回的结果</param> /// <param name="fbrTemp01">相关结果01</param> /// <param name="fbrTemp02">相关结果02</param> /// <param name="fbrTemp03">相关结果03</param> private void CombineResponse(FeedBackResponse <string> fbrReturn, FeedBackResponse <string> fbrTemp01, FeedBackResponse <string> fbrTemp02, FeedBackResponse <string> fbrTemp03) { bool blnHasError = false; if (null != fbrTemp01 && !fbrTemp01.Result) { blnHasError = true; fbrReturn.Message += ";" + fbrTemp01.Message; } if (null != fbrTemp01 && !fbrTemp01.Result) { blnHasError = true; fbrReturn.Message += ";" + fbrTemp01.Message; } if (null != fbrTemp01 && !fbrTemp01.Result) { blnHasError = true; fbrReturn.Message += ";" + fbrTemp01.Message; } if (!blnHasError) { fbrReturn.Result = true; } }
/// <summary> /// 功能:记录日志消息 /// </summary> /// <param name="writeLogType">写日志类型</param> /// <param name="logLevel">日志级别</param> /// <param name="logSource">日志的来源</param> /// <param name="logValue">需记录的日志值</param> /// <param name="logAddition">日志附加信息</param> public FeedBackResponse <string> WriteLog(WriteLogType writeLogType, LogLevel logLevel, string logSource, string logValue, string logAddition) { FeedBackResponse <string> fbrTemp01 = null; FeedBackResponse <string> fbrTemp02 = null; FeedBackResponse <string> fbrTemp03 = null; FeedBackResponse <string> fbrReturn = new FeedBackResponse <string>(); switch (writeLogType) { case WriteLogType.FileLog: fbrReturn = LogServiceHelper.WriteFileLog(logLevel, logSource, logValue, logAddition); break; case WriteLogType.DataBaseLog: fbrReturn = LogServiceHelper.WriteDataBaseLog(logLevel, logSource, logValue, logAddition); break; case WriteLogType.FileDataBaseLog: fbrTemp01 = LogServiceHelper.WriteFileLog(logLevel, logSource, logValue, logAddition); fbrTemp02 = LogServiceHelper.WriteDataBaseLog(logLevel, logSource, logValue, logAddition); CombineResponse(fbrReturn, fbrTemp01, fbrTemp02, fbrTemp03); break; case WriteLogType.AllLog: fbrTemp01 = LogServiceHelper.WriteFileLog(logLevel, logSource, logValue, logAddition); fbrTemp02 = LogServiceHelper.WriteDataBaseLog(logLevel, logSource, logValue, logAddition); break; } return(fbrReturn); }
/// <summary> /// 功能:异步方法调用 /// </summary> /// <typeparam name="TResult">结果类型</typeparam> /// <param name="func">待执行的方法</param> /// <param name="endPointName">客户端终节点名称</param> /// <returns>调用结果</returns> protected static async Task <FeedBackResponse <TResult> > CallMethodAsync <TResult>(Func <TChannel, Task <FeedBackResponse <TResult> > > func, string endPointName = "") { TChannel clientTemp = default(TChannel); FeedBackResponse <TResult> fbrReturn = new FeedBackResponse <TResult>(); try { clientTemp = (TChannel)Activator.CreateInstance(typeof(TChannel), endPointName); return(await func(clientTemp)); } catch (AggregateException aex) { fbrReturn.SetClientErrorMsg(aex.InnerExceptions[0]); } catch (Exception ex) { fbrReturn.SetClientErrorMsg(ex); } finally { try { if (null != clientTemp && clientTemp.State != CommunicationState.Faulted) { clientTemp.Close(); } } catch { } } return(fbrReturn); }
/// <summary> /// 功能描述:获取代付订单列表 /// </summary> /// <param name="merchantCode">商户号</param> /// <param name="pageInfo">分页信息</param> /// <param name="status">订单状态</param> /// <returns></returns> public static FeedBackResponse <IList <TAutoTransfer> > GetTautoTransferInfoByMerchantCode(string merchantCode, PageInfoParam pageInfo, int?status = null) { var fbrReturn = new FeedBackResponse <IList <TAutoTransfer> >(); var strSqlBase = new StringBuilder(200); var strSqlCout = new StringBuilder(200); //参数字典 var parames = new Dictionary <string, object>(); strSqlBase.Append("SELECT FId,FMerchantCode,FMerchantOrderNumber,FMerchantAddTime,FAmount,FStatus,FHolders,FBankName,FCardNo,FOrderNumber,FAddTime from tautotransfer where FMerchantCode=@FMerchantCode"); strSqlCout.Append("select count(1) from tautotransfer where FMerchantCode=@FMerchantCode"); parames.Add("FMerchantCode", merchantCode); if (null != status) { strSqlBase.Append(" and FStatus=@FStatus"); strSqlCout.Append(" and FStatus=@FStatus"); parames.Add("FStatus", status.Value); } var sql = new StringBuilder(DBDataSourceHelper.GetPageSql(strSqlBase.ToString(), pageInfo)); sql.Append(";"); sql.Append(strSqlCout); var data = DBDataSourceHelper.GetOrmPageData <TAutoTransfer>(sql.ToString(), parames: parames); fbrReturn.ResultData = data.Item1; fbrReturn.TotalCount = data.Item2; return(fbrReturn); }
/// <summary> /// 功能:测试日志 /// </summary> public static FeedBackResponse <string> TestLog() { FeedBackResponse <string> fbrReturn = new FeedBackResponse <string>(); SysLogHelper.LogMessage("LogServiceHelper.TestLog", "Test log data!", LogLevel.Information); SysLogHelper.LogServiceMessage("LogServiceHelper.TestLog", "Test log data!", LogLevel.Information); fbrReturn.ResultData = "ok"; return(fbrReturn); }
/// <summary> /// 回复意见反馈 /// </summary> /// <param name="request">回复实体</param> /// <returns></returns> public bool Reply(FeedBackReplyRequest request) { string postData = JsonHelper.GetJson(request); FeedBackResponse response = client.Execute(request, reply, postData); if (response != null) { return(response.success); } return(false); }
/// <summary> /// 功能:搜索日志数据列表 /// </summary> /// <param name="strLevel">日志级别</param> /// <param name="strSource">日志来源</param> /// <param name="dtmStartTime">日志起始时间</param> /// <param name="dtmEndTime">日志结束时间</param> /// <param name="strMessage">日志信息</param> /// <param name="strAddition">附加信息</param> /// <returns>日志数据列表 </returns> public static FeedBackResponse <List <TCommonlog> > SearchLogData(string strLevel, string strSource, DateTime dtmStartTime, DateTime?dtmEndTime, string strMessage, string strAddition) { var fbrReturn = new FeedBackResponse <List <TCommonlog> >(); StringBuilder strSql = new StringBuilder(); strSql.Append("select * from tcommonlog "); strSql.Append("where 1=1 "); Dictionary <string, object> dictParameter = new Dictionary <string, object>(); if (!string.IsNullOrEmpty(strLevel)) { strSql.Append(" and lower(LogLevel) like ?LogLevel"); dictParameter["LogLevel"] = "%" + strLevel.ToLower() + "%"; } if (!string.IsNullOrEmpty(strSource)) { strSql.Append(" and lower(LogSource) like ?LogSource"); dictParameter["LogSource"] = "%" + strSource.ToLower() + "%"; } if (!string.IsNullOrEmpty(strMessage)) { strSql.Append(" and lower(LogMessage) like ?LogMessage"); dictParameter["LogMessage"] = "%" + strMessage.ToLower() + "%"; } if (!string.IsNullOrEmpty(strAddition)) { strSql.Append(" and lower(LogAddition) like ?LogAddition"); dictParameter["LogAddition"] = "%" + strAddition.ToLower() + "%"; } strSql.Append(" and LogDateTime >= ?SLogDateTime"); dictParameter["SLogDateTime"] = dtmStartTime; if (dtmEndTime.HasValue) { strSql.Append(" and LogDateTime <= ?ELogDateTime"); dictParameter["ELogDateTime"] = dtmEndTime; } strSql.Append(" order by LogDateTime desc"); fbrReturn.ResultData = DBDataSourceHelper.GetOrmCommonData <TCommonlog>(strSql.ToString(), parames: dictParameter); return(fbrReturn); }
/// <summary> /// 功能描述:添加代付订单到消息队列 /// </summary> /// <param name="orderMessage"></param> public static FeedBackResponse <bool> SendPayOrderMessageToMq(OrderMqMessage orderMessage) { var fbrReturn = new FeedBackResponse <bool>(); try { m_publisher.Put(orderMessage); } catch (Exception ex) { throw new Exception("Lx.Service.WcfHelper.SendPayOrderMessageToMq 添加代付订单到消息队列中失败。Ex:=" + ex.Source + ex.Message + ex.StackTrace); } return(fbrReturn); }
/// <summary> /// 功能:写日志到数据库 /// </summary> /// <param name="logLevel">日志级别(不同的级别的日志会存入对应的日志文件)</param> /// <param name="logSource">日志的来源</param> /// <param name="logValue">需记录的日志值</param> /// <param name="logAddition">日志附加信息</param> public static FeedBackResponse <string> WriteDataBaseLog(LogLevel logLevel, string logSource, string logValue, string logAddition) { FeedBackResponse <string> fbrReturn = new FeedBackResponse <string>(); if (m_enableDataBaseLog) { SysLogHelper.LogMessage(logSource, logValue, logLevel, WriteLogType.DataBaseLog, logAddition); } else { fbrReturn.Message = "记录数据日志开关关闭."; } return(fbrReturn); }
/// <summary> /// 查看意见反馈 /// </summary> /// <param name="feedBackId">ID</param> /// <returns></returns> public FeedBackInfo Get(int feedBackId) { FeedBackReplyRequest request = new FeedBackReplyRequest() { feedBackId = feedBackId, uid = 1 }; string postData = JsonHelper.GetJson(request); FeedBackResponse response = client.Execute(request, get, postData); if (response != null && response.dto != null) { return(response.dto); } return(null); }
/// <summary> /// 功能:搜索日志文件列表 /// </summary> /// <param name="strSearchName">搜索名称</param> /// <returns>日志文件列表</returns> public static FeedBackResponse <List <string> > SearchLogFiles(string strSearchName) { FeedBackResponse <List <string> > fbrReturn = new FeedBackResponse <List <string> >(); List <string> lstReturn = new List <string>(); List <string> lstPath = SysLogHelper.GetLogPath(); lstPath.ForEach(lp => { lstReturn.AddRange(System.IO.Directory.GetFiles(lp, "*" + strSearchName + "*")); }); fbrReturn.ResultData = lstReturn; return(fbrReturn); }
/// <summary> /// 删除意见反馈 /// </summary> /// <param name="feedBackId">ID</param> /// <param name="changUser">操作用户</param> /// <returns></returns> public bool Delete(int feedBackId, string changUser) { FeedBackReplyRequest request = new FeedBackReplyRequest() { feedBackId = feedBackId, uid = 1, userName = changUser }; string postData = JsonHelper.GetJson(request); FeedBackResponse response = client.Execute(request, delete, postData); if (response != null) { return(response.success); } return(false); }
/// <summary> /// 功能描述:根据用户Id获取用户信息 /// </summary> /// <param name="userId"></param> /// <returns></returns> public static FeedBackResponse <TAccounts> GetUserData(long userId) { var model = new TAccounts(); var fbrReturn = new FeedBackResponse <TAccounts>(); var cacheKey = CacheKeys.MakeUserLoginKey(userId); model = CacheHelper.Get <TAccounts>(cacheKey); if (null == model) { var predicate = Predicates.Field <TAccounts>(et => et.FID, Operator.Eq, userId); model = DBDataSourceHelper.GetSingleOrmData <TAccounts>(predicate); if (null != model) { CacheHelper.Set(CacheKeys.MakeUserLoginKey(userId), model); } } fbrReturn.ResultData = model; return(fbrReturn); }