/// <summary>
        ///     功能:批量获取缓存
        /// </summary>
        /// <typeparam name="T">结果类型</typeparam>
        /// <param name="keys">缓存键数组</param>
        /// <returns>缓存对像集合</returns>
        public static List <T> Get <T>(IEnumerable <string> keys)
        {
            var lstReturn = new List <T>();

            if (null != s_cacheStrategy)
            {
                List <string> lstKeys = new List <string>();
                if (null != keys)
                {
                    keys.Any(key =>
                    {
                        string strKey = GlobalHelper.GetLowerString(key);
                        lstKeys.Add(strKey);
                        return(false);
                    });
                }

                try
                {
                    lstReturn = s_cacheStrategy.Get <T>(lstKeys);
                }
                catch (Exception ex)
                {
                    SysLogHelper.LogMessage("CacheHelper.Get", ex.Message, LogLevel.Error, WriteLogType.FileLog);
                }
            }

            return(lstReturn);
        }
        /// <summary>
        /// 功能:创建对象实例
        /// </summary>
        /// <typeparam name="T">实例的接口类型</typeparam>
        /// <param name="strClassFullName">实例的类全名称(命名空间.类型名,程序集)</param>
        /// <param name="ignoreCase">类全名是否区分大小写</param>
        /// <returns>对象实例</returns>
        public static T CreateTypeInstance <T>(string strClassFullName, bool ignoreCase = false)
        {
            if (!string.IsNullOrWhiteSpace(strClassFullName))
            {
                object objTemp = null;

                try
                {
                    //加载类型
                    Type typTemp = Type.GetType(strClassFullName, true, ignoreCase);

                    //根据类型创建实例
                    objTemp = Activator.CreateInstance(typTemp, true);
                    //objTemp = typTemp.Assembly.CreateInstance(strClassFullName, ignoreCase);
                    return((T)objTemp);
                }
                catch (Exception ex)
                {
                    string strMessage = SysLogHelper.GetErrorLogInfo(ex, true);
                    SysLogHelper.LogMessage("ObjectFactoryHelper.CreateTypeInstance", strMessage, LogLevel.Error);
                    return(default(T));
                }
            }
            else
            {
                return(default(T));
            }
        }
        /// <summary>
        /// 功能:创建对象实例
        /// </summary>
        /// <typeparam name="T">实例的接口类型</typeparam>
        /// <param name="strAssemblyName">类型所在程序集名称</param>
        /// <param name="strClassNameSpace">类型所在命名空间</param>
        /// <param name="strClassName">类型名称</param>
        /// <param name="ignoreCase">类名是否区分大小写</param>
        /// <returns>对象实例</returns>
        public static T CreateTypeInstance <T>(string strAssemblyName, string strClassNameSpace, string strClassName, bool ignoreCase = false)
        {
            if (string.IsNullOrWhiteSpace(strAssemblyName) || string.IsNullOrWhiteSpace(strClassNameSpace) || string.IsNullOrWhiteSpace(strClassName))
            {
                return(default(T));
            }
            else
            {
                object objTemp = null;

                try
                {
                    //命名空间.类型名
                    string fullName = strClassNameSpace + "." + strClassName;

                    //加载程序集,创建程序集里面的 命名空间.类型名 实例
                    objTemp = Assembly.Load(strAssemblyName).CreateInstance(fullName, ignoreCase);

                    //类型转换并返回
                    return((T)objTemp);
                }
                catch (Exception ex)
                {
                    string strMessage = SysLogHelper.GetErrorLogInfo(ex, true);
                    SysLogHelper.LogMessage("ObjectFactoryHelper.CreateTypeInstance", strMessage, LogLevel.Error);
                    return(default(T));
                }
            }
        }
        /// <summary>
        ///     功能:静态构造函数,创建默认的缓存实例
        /// </summary>
        static CacheHelper()
        {
            try
            {
                //获取缓存策略类别
                string strCacheStrategyType = ConfigurationManager.AppSettings["CacheStrategyType"];
                if (!string.IsNullOrWhiteSpace(strCacheStrategyType))
                {
                    //获取缓存过期时间
                    string strCacheExpiration = ConfigurationManager.AppSettings["CacheExpiration"];
                    double value;
                    if (!string.IsNullOrWhiteSpace(strCacheExpiration))
                    {
                        double.TryParse(strCacheExpiration, out value);
                        s_cacheExpiration = TimeSpan.FromMinutes(value);
                    }

                    //创建缓存策略类实例
                    var redisConfigInfo = JsonConfigInfo.LoadFromFile("cache.json");
                    s_cacheStrategy = ComponentLoader.Load <ICacheStrategy>(redisConfigInfo);
                }
            }
            catch (Exception ex)
            {
                string strMessage = SysLogHelper.GetErrorLogInfo(ex, true);
                SysLogHelper.LogMessage("CacheHelper.Static", strMessage, LogLevel.Error);
            }
        }
        /// <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);
        }
Example #6
0
        /// <summary>
        /// 获取统计数据
        /// </summary>
        private void GetStatistics()
        {
            WebSiteDataInfo websitedatemodel = new WebSiteDataBLL().GetWebSiteData();

            if (websitedatemodel != null)
            {
                this.UserCount = websitedatemodel.TotalUser.ToString();
                this.UserName  = Tool.CookieHelper.GetCookie("TDWUserName");
                TuanDai.PortalSystem.BLL.UserBLL userBll = new TuanDai.PortalSystem.BLL.UserBLL();
                userBasicObj = userBll.GetUserBasicInfoModelById(WebUserAuth.UserId.Value);
                if (this.UserName.IsEmpty())
                {
                    if (userBasicObj != null)
                    {
                        this.UserName = userBasicObj.UserName;
                    }
                }
                this.returnUrl = Tool.WEBRequest.GetString("ReturnUrl");
                if (!string.IsNullOrEmpty(returnUrl) && returnUrl.ToLower().Contains(TuanDai.WXApiWeb.GlobalUtils.ActivityWebsiteUrl.ToLower()))//跳转回ReturnUrl
                {
                    try
                    {
                        Response.Redirect(returnUrl, false);
                    }
                    catch (Exception ex)
                    {
                        SysLogHelper.WriteErrorLog("注册成功页面跳转异常", Tool.ExceptionHelper.GetExceptionMessage(ex));
                    }
                    finally {
                        Response.End();
                    }
                }
            }
        }
        /// <summary>
        /// 接收日志消息
        /// </summary>
        /// <param name="sender">事件源</param>
        /// <param name="e">消息参数</param>
        private static void m_messageReceiver_Received(object sender, MessageEventArgs e)
        {
            try
            {
                //写入日志服务
                var clmTemp = e.Message as CustomLogMessage;
                if (null != clmTemp)
                {
                    if (m_enableFileLog)
                    {
                        if (clmTemp.WriteLogType == WriteLogType.AllLog ||
                            clmTemp.WriteLogType == WriteLogType.FileDataBaseLog ||
                            clmTemp.WriteLogType == WriteLogType.FileLog)
                        {
                            SysLogHelper.LogMessage("Q:" + clmTemp.LogSource, clmTemp.LogMessage, clmTemp.LogLevel, WriteLogType.FileLog, clmTemp.LogAddition);
                        }
                    }

                    if (m_enableDataBaseLog)
                    {
                        if (clmTemp.WriteLogType == WriteLogType.AllLog ||
                            clmTemp.WriteLogType == WriteLogType.FileDataBaseLog ||
                            clmTemp.WriteLogType == WriteLogType.DataBaseLog)
                        {
                            SysLogHelper.LogMessage("Q:" + clmTemp.LogSource, clmTemp.LogMessage, clmTemp.LogLevel, WriteLogType.DataBaseLog, clmTemp.LogAddition);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SysLogHelper.LogMessage("LogMQConsumerHelper.messageReceiver_Received", ex.Message);
            }
        }
Example #8
0
        /// <summary>
        /// 刷新八金社用户token
        /// </summary>
        /// <param name="bjsUserToken"></param>
        /// <returns></returns>
        private Tuple <string, string> RefreshBjsUserToken(string bjsUserToken)
        {
            try
            {
                RefreshBjsUserTokenRequest request = new RefreshBjsUserTokenRequest {
                    platformCode     = BjsPlatformCode,
                    requestId        = Guid.NewGuid().ToString(),
                    requestTimeMills = DateTimeToTimestamp().ToString(),
                    refreshUserToken = bjsUserToken,
                    ext = ""
                };
                request.signature = Cryptography.GetMd5(request.platformCode + "-" + BjsKey + "-" + request.requestId);

                string url  = "http://api2.bajinshe.com/json/v2/external/UserService/refreshUserToken/gzip";
                string resp = HttpUtils.HttpPostJson(url, JsonConvert.SerializeObject(request));

                RefreshBjsUserTokenResponse response = JsonConvert.DeserializeObject <RefreshBjsUserTokenResponse>(resp);
                if (response == null)
                {
                    return(null);
                }
                if (response.code == "10000")
                {
                    return(new Tuple <string, string>(response.bjsUserId, response.phoneNumber));
                }
            }
            catch (Exception ex)
            {
                SysLogHelper.WriteErrorLog("刷新八青社用户信息接口时出错", Tool.ExceptionHelper.GetExceptionMessage(ex));
            }
            return(null);
        }
Example #9
0
        static void Main(string[] args)
        {
            try
            {
                XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("log4net.config"));
                //运行服务
                HostFactory.Run(cf =>
                {
                    cf.SetServiceName("Lx.Service.LogHost");
                    cf.SetDisplayName("Lx.Service.LogHost");
                    cf.SetDescription("日志服务");
                    cf.Service <TopshelfWrapper>(sv =>
                    {
                        sv.ConstructUsing(b => new TopshelfWrapper());
                        sv.WhenStarted(o => o.Start());
                        sv.WhenStopped(o => o.Stop());
                    });

                    cf.RunAsLocalSystem();
                    cf.StartAutomatically();
                    cf.EnablePauseAndContinue();
                });
            }
            catch (Exception ex)
            {
                string strMessage = $"服务启动失败,原因:{SysLogHelper.GetErrorLogInfo(ex, true)}";
                SysLogHelper.LogMessage("LogHost.Main", strMessage);
            }

            Console.ReadLine();
        }
Example #10
0
        /// <summary>
        /// 增加 角色
        /// </summary>
        public static AjaxResult AddRole(NameValueCollection form)
        {
            var entity = new CFRole();

            entity.Load(form);
            SysLogHelper.AddLog(SysContext.CurrentUserName, "添加权限ID:" + entity.RoleName, "添加-权限");
            return(DB.InsertEntity <CFRole>(entity));
        }
Example #11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         string postString = string.Empty;
         string action     = Tool.WEBRequest.GetQueryString("action");
         if (string.IsNullOrEmpty(action))
         {
             if (HttpContext.Current.Request.HttpMethod.ToUpper() == "POST")
             {
                 using (Stream stream = HttpContext.Current.Request.InputStream)
                 {
                     Byte[] postBytes = new Byte[stream.Length];
                     stream.Read(postBytes, 0, (Int32)stream.Length);
                     postString = Encoding.UTF8.GetString(postBytes);
                     string msg = new EventHandle().ReturnMessage(postString);
                     Response.Write(msg);
                 }
             }
             if (HttpContext.Current.Request.HttpMethod.ToUpper() == "GET")
             {
                 new WeiXin().Auth();
             }
         }
         else if (action.ToLower() == "clearcache")
         {
             string user_Ip = Tool.WEBRequest.GetIP();
             if (IsValidIp(user_Ip))
             {
                 //清理客户端WCF缓存
                 //TuanDai.BalancedSystem.Client.BalancedSystemClient client = new TuanDai.BalancedSystem.Client.BalancedSystemClient();
                 //client.ClearCacheByClient();
                 Response.Write("1");
                 Response.End();
             }
             else
             {
                 Response.Write("非法的来访IP");
                 Response.End();
             }
         }
         else if (action.ToLower() == "cleartoken")
         {
             string strValidatePass = Tool.WEBRequest.GetQueryString("ValidatePass");
             if (strValidatePass == "tuandaiisgood")
             {
                 //  TuanDai.WXApiWeb.Common.WeiXinApi.removeCache("WeiXinTicket");
                 //请求完检测DB中Token状态 Allen 2015-08-12
                 ThirdLoginSDK.CheckDBTokenDelegate chkStatus = new ThirdLoginSDK.CheckDBTokenDelegate(ThirdLoginSDK.CheckDBTokenStatus);
                 chkStatus.BeginInvoke(GlobalUtils.AppId, null, null);
             }
         }
     }
     catch (Exception ex)
     {
         SysLogHelper.WriteErrorLog("微信请求", "错误详细信息:" + ex.Message + "|" + ex.StackTrace);
     }
 }
        /// <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);
        }
Example #13
0
        static void Main(string[] args)
        {
            try
            {
                XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("log4net.config"));
                //获取配置的服务名称列表
                List <string> lstConfigServices = ServiceHelper.GetConfigServices();
                //启动服务
                if (null != lstConfigServices && lstConfigServices.Count > 0)
                {
                    //获取Windows服务信息
                    JsonConfigInfo winServiceInfo = ConfigHelper.LoadFromFile("WinServiceInfo.json");

                    //获取待启动的Windows服务的名称
                    string strServiceInfo = lstConfigServices[0];
                    int    intPosition    = strServiceInfo.LastIndexOf(".");
                    string strServiceName = strServiceInfo.Substring(intPosition + 1);

                    //获取服务配置
                    JObject joServiceInfo = winServiceInfo.GetValue <JObject>(strServiceName);

                    //运行服务
                    HostFactory.Run(cf =>
                    {
                        cf.SetServiceName(joServiceInfo["ServiceName"].Value <string>());
                        cf.SetDisplayName(joServiceInfo["DisplayName"].Value <string>());
                        cf.SetDescription(joServiceInfo["Description"].Value <string>());

                        cf.Service <TopshelfWrapper>(sv =>
                        {
                            sv.ConstructUsing(b => new TopshelfWrapper());
                            sv.WhenStarted(o => o.Start());
                            sv.WhenStopped(o => o.Stop());
                        });

                        cf.RunAsLocalSystem();
                        cf.StartAutomatically();
                        cf.EnablePauseAndContinue();
                    });
                }
                else
                {
                    Console.WriteLine("没有配置服务,无服务可启动!");
                }
            }
            catch (Exception ex)
            {
                string strMessage = $"服务启动失败,原因:{SysLogHelper.GetErrorLogInfo(ex, true)}";
                SysLogHelper.LogMessage("Lx.Service.WinServiceHost.Main", strMessage);
            }

            Console.ReadLine();
        }
Example #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         PrizeId = WEBRequest.GetString("PrizeId", "");
         //Response.Redirect(GlobalUtils.WebURL + "/Member/UserPrize/Gift_Address.aspx?PrizeId="+PrizeId);
         BindInfo();
     }
     catch (Exception ex)
     {
         SysLogHelper.WriteErrorLog("获取商城默认地址失败", "异常:" + ex.Message);
     }
 }
 static ObjectFactoryHelper()
 {
     try
     {
         m_dictObject             = new Dictionary <int, object>();
         m_queryImplementAssembly = Assembly.Load(m_queryImplementAssemblyName);
     }
     catch (Exception ex)
     {
         string strMessage = SysLogHelper.GetErrorLogInfo(ex, true);
         SysLogHelper.LogMessage("ObjectFactoryHelper.Static", strMessage, LogLevel.Error);
     }
 }
Example #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IsInWeiXin = GlobalUtils.IsWeiXinBrowser ? 1 : 0;
            try
            {
                string postString = string.Empty;
                string action     = Tool.WEBRequest.GetQueryString("action").ToLower();

                string strValidatePass = Tool.WEBRequest.GetQueryString("validatePass");
                if (strValidatePass == "tuandaiisgood")
                {
                    string openId = WEBRequest.GetQueryString("openid");
                    if (openId.IsEmpty())
                    {
                        openId = GlobalUtils.OpenId;
                    }
                    string weburl = GlobalUtils.MTuanDaiURL;
                    if (action == "newhand")
                    {
                        List <WeiXinApi.PicTextArticleItemInfo> newsList = new List <WeiXinApi.PicTextArticleItemInfo>();
                        newsList.Add(new WeiXinApi.PicTextArticleItemInfo {
                            title = "新手福利-518红包,体验金等好礼", description = "新手福利-518红包,体验金等好礼", picurl = weburl + "/imgs/push/banner_newhand.png?v=20160831003", url = "https://mvip.tdw.cn/pages/invest/invest_newHand.aspx"
                        });
                        newsList.Add(new WeiXinApi.PicTextArticleItemInfo {
                            title = "平台的安全保障", description = "平台的安全保障", picurl = weburl + "/imgs/push/icon_safety.png?v=20160831003", url = "http://info.tdw.cn/wap/help/second-question.html?cid=20"
                        });
                        newsList.Add(new WeiXinApi.PicTextArticleItemInfo {
                            title = "如何投资", description = "如何投资", picurl = weburl + "/imgs/push/icon_invest.png?v=20160831003", url = "http://info.tdw.cn/wap/help/second-question.html?cid=15"
                        });
                        newsList.Add(new WeiXinApi.PicTextArticleItemInfo {
                            title = "关于提现和管理费", description = "关于提现和管理费", picurl = weburl + "/imgs/push/icon_withdraw.png?v=20160831003", url = "http://info.tdw.cn/wap/help/second-question.html?cid=16"
                        });
                        WeiXinApi.SendPicTextMessageToUser(openId, newsList);
                    }
                    else if (action == "hotrecommend")
                    {
                        List <WeiXinApi.PicTextArticleItemInfo> newsList = new List <WeiXinApi.PicTextArticleItemInfo>();
                        newsList.Add(new WeiXinApi.PicTextArticleItemInfo {
                            title = "智能投标-We计划", description = "智能投标-We计划", picurl = weburl + "/imgs/push/banner_we.png?v=20160831003", url = weburl + "/pages/invest/WE/WE_list.aspx"
                        });
                        newsList.Add(new WeiXinApi.PicTextArticleItemInfo {
                            title = "邀请有礼", description = "邀请有礼", picurl = weburl + "/imgs/push/icon_gift.png?v=20160831003", url = "https://hd.tdw.cn/weixin/Invite/InviteIndex.aspx"
                        });
                        WeiXinApi.SendPicTextMessageToUser(openId, newsList);
                    }
                }
            }
            catch (Exception ex) {
                SysLogHelper.WriteErrorLog("微信关注推送图文消息失败", "错误详细信息:" + ex.Message + "|" + ex.StackTrace);
            }
        }
        /// <summary>
        ///     功能:初始化计数器
        /// </summary>
        /// <param name="key">计数器名称</param>
        /// <param name="value">初始值</param>
        /// <returns>是否设置成功</returns>
        public static bool InitCounter(string key, long value)
        {
            string strKey = GlobalHelper.GetLowerString(key);

            try
            {
                return(s_cacheStrategy.InitCounter(strKey, value));
            }
            catch (Exception ex)
            {
                SysLogHelper.LogMessage("CacheHelper.InitCounter", ex.Message, LogLevel.Error, WriteLogType.FileLog);
                return(false);
            }
        }
 static LogServiceHelper()
 {
     try
     {
         JsonConfigInfo lsConfigInfo = ConfigHelper.LoadFromFile("LogService.json");
         m_enableFileLog     = lsConfigInfo.GetValue <bool>("EnableFileLog");
         m_enableDataBaseLog = lsConfigInfo.GetValue <bool>("EnableDataBaseLog");
     }
     catch (Exception ex)
     {
         string strMessage = SysLogHelper.GetErrorLogInfo(ex, true);
         SysLogHelper.LogMessage("LogServiceHelper.static", strMessage);
     }
 }
        /// <summary>
        ///     功能:获取计数器的当前值
        /// </summary>
        /// <param name="key">计数器名称</param>
        /// <returns>当前值</returns>
        public static async Task <double?> GetDoubleCounterAsync(string key)
        {
            string strKey = GlobalHelper.GetLowerString(key);

            try
            {
                return(await s_cacheStrategy.GetDoubleCounterAsync(strKey));
            }
            catch (Exception ex)
            {
                SysLogHelper.LogMessage("CacheHelper.GetDoubleCounterAsync", ex.Message, LogLevel.Error, WriteLogType.FileLog);
                return(null);
            }
        }
        /// <summary>
        ///     功能:初始化计数器
        /// </summary>
        /// <param name="key">计数器名称</param>
        /// <param name="value">初始值</param>
        /// <returns>是否设置成功</returns>
        public static async Task <bool> InitCounterAsync(string key, double value)
        {
            string strKey = GlobalHelper.GetLowerString(key);

            try
            {
                return(await s_cacheStrategy.InitCounterAsync(strKey, value));
            }
            catch (Exception ex)
            {
                SysLogHelper.LogMessage("CacheHelper.InitCounterAsync_double", ex.Message, LogLevel.Error, WriteLogType.FileLog);
                return(false);
            }
        }
        /// <summary>
        ///     功能:获取计数器的当前值
        /// </summary>
        /// <param name="key">计数器名称</param>
        /// <returns>当前值</returns>
        public static long?GetCounter(string key)
        {
            string strKey = GlobalHelper.GetLowerString(key);

            try
            {
                return(s_cacheStrategy.GetCounter(strKey));
            }
            catch (Exception ex)
            {
                SysLogHelper.LogMessage("CacheHelper.GetCounter", ex.Message, LogLevel.Error, WriteLogType.FileLog);
                return(null);
            }
        }
Example #22
0
        public static AjaxResult RemoveCorps(string ID)
        {
            CorporationHelper helper = new CorporationHelper();

            if (helper.IsCorporationInUsed(ID))
            {
                return(AjaxResult.Error("该使用单位已经注册印章,无法删除!"));
            }
            else
            {
                helper.DeleteCorporation(ID);
                SysLogHelper.AddLog(SysContext.CurrentUserName, "删除企业信息ID:" + ID, "删除-企业信息");
                return(AjaxResult.Success());
            }
        }
Example #23
0
        public static AjaxResult RemoveRent(string ID)
        {
            RentInfoHelper helper = new RentInfoHelper();

            if (helper.IsExists(ID))
            {
                return(AjaxResult.Error("该房源已经有租赁信息,无法删除!"));
            }
            else
            {
                helper.DeleteCorporation(ID);
                SysLogHelper.AddLog(SysContext.CurrentUserName, "删除房源信息ID:" + ID, "删除-房源信息");
                return(AjaxResult.Success());
            }
        }
 //保存编辑
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         ICommand m_saveEditCom = new SaveEditCommandClass();
         m_saveEditCom.OnCreate(pMapControl.Object);
         m_saveEditCom.OnClick();
         SysLogHelper.WriteOperationLog("数据管理-数据编辑", "保存编辑", "数据管理");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         PS.Plot.Common.LogHelper.WriteLog(typeof(Form_Editor), ex, "保存编辑");
     }
 }
        /// <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>
        ///     功能:设置永久缓存项(服务器上key存在就替换,不存在就添加)
        /// </summary>
        /// <param name="key">缓存键值</param>
        /// <param name="value">缓存值</param>
        /// <returns>是否设置成功</returns>
        public static bool Set(string key, object value)
        {
            bool   blnSuccess = false;
            string strKey     = GlobalHelper.GetLowerString(key);

            try
            {
                blnSuccess = s_cacheStrategy.Set(strKey, value, s_cacheExpiration);
            }
            catch (Exception ex)
            {
                SysLogHelper.LogMessage("CacheHelper.Set", ex.Message, LogLevel.Error, WriteLogType.FileLog);
            }
            return(blnSuccess);
        }
 /// <summary>
 /// 功能:初始化
 /// </summary>
 public static void Initalize()
 {
     try
     {
         m_messageReceiver           = MessageQueueHelper.GetMessageQueueFromPool().GetMessageReceiver(QueueName.LxLogQueue.ToString(), "");
         m_messageReceiver.Received += m_messageReceiver_Received;
         m_messageReceiver.Start();
         Console.WriteLine("日志消息队列消费者已启动!");
     }
     catch (Exception ex)
     {
         string strErrorMessage = SysLogHelper.GetErrorLogInfo(ex, true);
         SysLogHelper.LogMessage("LogMQConsumerHelper.Static", strErrorMessage);
     }
 }
Example #28
0
 /// <summary>
 /// 功能:初始化
 /// </summary>
 public static void Initalize()
 {
     try
     {
         m_messageReceiver           = MessageQueueHelper.GetMessageQueueFromPool().GetMessageReceiver(QueueName.AutoPayQueue.ToString(), "");
         m_messageReceiver.Received += m_messageReceiver_Received;
         m_messageReceiver.Start();
         Console.WriteLine("订单服务已启动!");
     }
     catch (Exception ex)
     {
         string strMessage = $"初始化,原因:{SysLogHelper.GetErrorLogInfo(ex, true)}";
         SysLogHelper.LogMessage("Lx.Service.Initalize", strMessage);
     }
 }
Example #29
0
 /// <summary>
 /// 功能:停止服务
 /// </summary>
 public void Stop()
 {
     try
     {
         //关闭服务
         OrderMQConsumerHelper.Release();
         //调用垃圾回收
         GC.Collect();
         GC.WaitForPendingFinalizers();
     }
     catch (Exception ex)
     {
         string strMessage = $"服务停止失败,原因:{SysLogHelper.GetErrorLogInfo(ex, true)}";
         SysLogHelper.LogMessage("Lx.Service.Order", strMessage);
     }
 }
        /// <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);
        }