Beispiel #1
0
        public static void NowProcess()
        {
            //获取当前进程
            string path = LogPrepare.GetLogPath();

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            Process cur = Process.GetCurrentProcess();
            string  pn  = cur.ProcessName;//当前运行进程 w3wp/iisexpress

            sb.AppendLine("ProcessName=" + pn);
            string site = cur.Site != null? cur.Site.Name:string.Empty;

            sb.AppendLine("Site=" + site);
            string maiche = cur.MachineName;

            sb.AppendLine("MachineName{.=local}=" + maiche);
            string window = cur.MainWindowTitle;

            sb.AppendLine("MainWindowTitle=" + window);
            string poolName = Environment.GetEnvironmentVariable("APP_POOL_ID", EnvironmentVariableTarget.Process);//应用程序池名称 HrApp/Clr4IntegratedAppPool

            sb.AppendLine("APP_POOL_ID=" + poolName);
            // string json = Newtonsoft.Json.JsonConvert.SerializeObject(cur);
            ELogType lt = ELogType.BackgroundProcess;

            LoggerWriter.CreateLogFile(sb.ToString(), path, lt, LogPrepare.GetLogName(lt), true);
        }
Beispiel #2
0
        static void EveryDayDo()
        {
            string path = LogPrepare.GetLogPath();

            try
            {
                StringBuilder text = new StringBuilder();
                text.AppendFormat("Background process【{0}】,index={1} ,time ={2}", GetStartWebOfProcess(), BackRunNumber, DateTime.Now.ToString(Common.Data.CommonFormat.DateTimeFormat));
                ELogType el = ELogType.BackgroundProcess;
                LoggerWriter.CreateLogFile(text.ToString(), path, el, LogPrepare.GetLogName(el), true);
                DoSomeInitEventFacadeFactory dosome = new DoSomeInitEventFacadeFactory();
                dosome.ActiveEmailSmtp();
                //读取xml配置
                string xmlFile = InitAppSetting.DefaultLogPath + "/XmlConfig/AppConfig.xml";
                //执行成功时间写入到xml中
                UiCfgNode.NodeKeyValue = typeof(AppEmailAccount).Name;
                AppEmailAccount appEmail = xmlFile.GetNodeSpecialeAttribute <AppEmailAccount>(UiCfgNode, nodeCfgFormat);
                appEmail.EmailLastActiveTime = DateTime.Now.ToString(Common.Data.CommonFormat.DateTimeFormat);
                appEmail.EmailAccount        = InitAppSetting.AppSettingItemsInDB[EAppSetting.SystemEmailSendBy.ToString()];
                xmlFile.UpdateXmlNode(appEmail, UiCfgNode, nodeCfgFormat);
                LoggerWriter.CreateLogFile(Newtonsoft.Json.JsonConvert.SerializeObject(appEmail), path, el, LogPrepare.GetLogName(el), false);
            }
            catch (Exception ex)
            {
                ELogType el = ELogType.BackgroundProcess;
                LoggerWriter.CreateLogFile("【Error】" + ex.Message.ToString(), path, el, LogPrepare.GetLogName(el), true);
            }
        }
Beispiel #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            GlobalNotifyHandle handle = new GlobalNotifyHandle();
            string             format = Common.Data.CommonFormat.DateTimeMilFormat;
            string             time   = DateTime.Now.ToString(format);
            string             path   = LogPrepare.GetLogPath();
            ELogType           heart  = ELogType.DebugData;
            string             file   = LogPrepare.GetLogName(heart);

            LoggerWriter.CreateLogFile(string.Format("begin init Data  {0}", time), path, heart, file, true);
            Domain.GlobalModel.AppRunData.InitAppData();
            time = DateTime.Now.ToString(format);
            LoggerWriter.CreateLogFile(string.Format("end init Data {0}", time), path, heart, file, true);
            Domain.GlobalModel.AppRunData.AppName = this.GetType().Name;
            time = DateTime.Now.ToString(format);
            LoggerWriter.CreateLogFile(string.Format("begin init ioc {0}", time), path, heart, file, true);
            IocMvcFactoryHelper.GetIocDict(true);
            time = DateTime.Now.ToString(format);
            LoggerWriter.CreateLogFile(string.Format("end init ioc {0}", time), path, heart, file, true);
            InitAppSetting.AppSettingItemsInDB = RefreshAppSetting.QueryAllAppSetting(IocMvcFactoryHelper.GetInterface <IAppSettingService>());
            RefreshAppSetting.RefreshFileVersion();
            AppProcess.GlobalXmlManage();
            AppProcess.CallTodo();
        }
Beispiel #4
0
        public static bool WriteLogProcess(string log, ELogType logType)
        {
            string   logDir = LogPrepare.GetLogPath();
            DateTime time   = DateTime.Now;
            string   file   = LogPrepare.GetLogName(logType);

            LoggerWriter.CreateLogFile(log + time.ToString(Common.Data.CommonFormat.DateTimeMilFormat), logDir, logType, file, true);
            if (logType == ELogType.HeartBeatLine)
            {//心跳线检测不计入数据库
                return(true);
            }
            //这里调用日志数据库存储
            return(true);
        }
Beispiel #5
0
        static void BackProcessDoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            ELogType el = ELogType.BackgroundProcess;

            while (true)
            {
                string path = LogPrepare.GetLogPath();
                if (StopBackProcess)
                {
                    LoggerWriter.CreateLogFile("Stop Background process =" + DateTime.Now.ToString(Common.Data.CommonFormat.DateTimeFormat), path, el, LogPrepare.GetLogName(el), true);
                    return;
                }
                BackRunNumber++;
                EveryDayDo();
                System.Threading.Thread.Sleep(1000 * 60 * 15);//15 分钟触发一次
            }
        }