Пример #1
0
        /// <summary>
        /// Starts this instance.
        /// </summary>
        public void Start()
        {
            try
            {
                LogHelper <JobHelper> .Info("作业框架启动中");

                if (null == _scheduler)
                {
                    ISchedulerFactory sf = new StdSchedulerFactory();
                    _scheduler = sf.GetScheduler();
                }
                _scheduler.Start();

                string msg = string.Format(assemblyName + "已经启动{0}。", IsDebug ? "DEBUG" : "RELEASE");

                string mailSubject = "服务启动IP:" + NetUtil.GetHostIp() + " " + msg;



                LogHelper <JobHelper> .Info(mailSubject, true);
            }
            catch (Exception ex)
            {
                string title = assemblyName + "启动失败";
                LogHelper <JobHelper> .Error(title, ex, true);
            }
        }
Пример #2
0
 /// <summary>
 /// 写入错误信息
 /// </summary>
 /// <param name="message">消息</param>
 /// <param name="ex">异常</param>
 public static void Error(string message, Exception ex, bool eamil = false)
 {
     RecordLog(Logger.Error, message, ex);
     if (eamil)
     {
         var ip      = NetUtil.GetHostIp();
         var mailLog = message + " Ip:" + ip;
         RecordLog(LoggerMail.Error, message, ex);
     }
 }
Пример #3
0
 /// <summary>
 /// 写入普通信息
 /// </summary>
 /// <param name="message">消息</param>
 public static void Info(string message, bool eamil = false)
 {
     RecordLog(Logger.Info, message);
     if (eamil)
     {
         var ip      = NetUtil.GetHostIp();
         var mailLog = message + " Ip:" + ip;
         RecordLog(LoggerMail.Info, message);
     }
 }
Пример #4
0
        /// <summary>
        /// Checks the server.
        /// </summary>
        /// <param name="serviceName">Name of the service.</param>
        /// <param name="second">The second.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public static bool CheckServer(string serviceName, double second)
        {
            try
            {
                int passMinute = 5;
                int.TryParse(AppConfigHelper.PassMinute, out passMinute);
                string serviceIp = NetUtil.GetHostIp();
                second = Math.Ceiling(second);

                var serverConfigBll  = new ServerConfigBll();
                var severConfigModel = serverConfigBll.GetModel(new ServerConfigModel()
                {
                    SERVICENAME = serviceName
                });
                //不存在记录,插入记录返回false
                if (severConfigModel == null)
                {
                    ServerConfigModel model = new ServerConfigModel();
                    model.SERVICENAME = serviceName;
                    model.SERVICEIP   = serviceIp;
                    model.PASSMINUTE  = passMinute;
                    model.SECOND      = second;
                    var bak = serverConfigBll.Add(model);
                    TextLog.Append("无服务配制,插入记录,返回F");
                    return(false);
                }
                else
                {
                    if (severConfigModel.PASSMINUTE > 0)
                    {
                        passMinute = severConfigModel.PASSMINUTE;
                    }
                    else
                    {
                        severConfigModel.PASSMINUTE = passMinute;
                    }
                    //存在记录IP相同
                    if (severConfigModel.SERVICEIP == serviceIp)
                    {
                        //存在记录IP相同,5分种内更新,返回true;
                        if (severConfigModel.SYSDATETIME < severConfigModel.LASTTIME.AddMinutes(passMinute).AddSeconds(severConfigModel.SECOND))
                        {
                            severConfigModel.SECOND = second;
                            var bak = serverConfigBll.UpdateLastTime(severConfigModel);
                            if (bolWriteLogFlag)
                            {
                                TextLog.Append(string.Format("IP相同,{0}分内,有权,返回T", passMinute));
                                bolWriteLogFlag = false;
                            }
                            return(bak);
                        }
                        else
                        {
                            severConfigModel.SECOND = second;
                            var bak = serverConfigBll.UpdateLastTime(severConfigModel);
                            //存在记录IP相同,5分种后主服务器收回权限,返回更新true;
                            TextLog.Append(string.Format("IP相同,{0}分后,获权,返回F", passMinute));
                            bolWriteLogFlag = true;
                            return(false);
                        }
                    }
                    else
                    {
                        //IP不同,5分种后返回true
                        if (severConfigModel.SYSDATETIME > severConfigModel.LASTTIME.AddMinutes(passMinute).AddSeconds(severConfigModel.SECOND))
                        {
                            TextLog.Append(string.Format("IP不同,{0}分种后,获权,返回F", passMinute));
                            bolWriteLogFlag = true;
                            severConfigModel.SERVICEIPPER = severConfigModel.SERVICEIP;
                            severConfigModel.SERVICEIP    = serviceIp;
                            severConfigModel.SECOND       = second;
                            var bak = serverConfigBll.UpdateLastIp(severConfigModel);
                            return(false);
                        }
                        else
                        {
                            //IP不同,5分种内返回false
                            TextLog.Append(string.Format("IP不同,{0}分种内,无权,返回F", passMinute));
                            bolWriteLogFlag = true;
                            return(false);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TextLog.Append(String.Format("检查服务配制失败: " + ex.Message));
                return(false);
            }
        }