/// <summary> /// GetScheduleJob /// </summary> /// <param name="jobInfo"></param> private void GetDelBackUpFilesJob(Model.ConfigInfo configInfo) { _QuartzManager.ScheduleDelBackUpFiles(_LogAppendToForms, configInfo.LogRetentionDays); string logMessage = string.Format("【{0}_{1}】 加入调度器成功!", "DelBackUplogFiles", "清除日志计划"); Log4netUtil.Log4NetHelper.Info(logMessage, "QuartzManager"); Log4netUtil.LogDisplayHelper.LogMessage(_LogAppendToForms, logMessage); }
private Model.ConfigInfo getModel(DataTable dt) { if (dt.Rows.Count <= 0) { return(null); } if (dt.Rows.Count > 1) { throw new Exception("查找数据不唯一,无法实例化配置信息!"); } Model.ConfigInfo cfg = new Model.ConfigInfo(); if (dt.Rows[0][COLUMN_DBID] != null) { cfg.DBID = long.Parse(dt.Rows[0][COLUMN_DBID].ToString()); } if (dt.Rows[0][COLUMN_DEVID] != null) { cfg.DEVID = dt.Rows[0][COLUMN_DEVID].ToString(); } if (dt.Rows[0][COLUMN_FRAMECONTENT] != null) { cfg.FRAMECONTENT = (string)dt.Rows[0][COLUMN_FRAMECONTENT].ToString(); } if (dt.Rows[0][COLUMN_WRITETIME] != null) { cfg.WRITETIME = (DateTime)dt.Rows[0][COLUMN_WRITETIME]; } if (dt.Rows[0][COLUMN_SENDTIME] != null) { cfg.SENDTIME = (DateTime)dt.Rows[0][COLUMN_SENDTIME]; } if (dt.Rows[0][COLUMN_STATUS] != null) { if ("1".Equals(dt.Rows[0][COLUMN_STATUS].ToString())) { cfg.STATUS = true; } if ("0".Equals(dt.Rows[0][COLUMN_STATUS].ToString())) { cfg.STATUS = false; } } return(cfg); }
/// <summary> /// frmMain_Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmMain_Load(object sender, EventArgs e) { System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer(); this.timer1.Tick += new System.EventHandler(this.timer1_Tick); this.timer3.Interval = 30 * 1000; this.timer3.Tick += new System.EventHandler(this.timer3_Tick); this.timer3.Start(); string isClearFaceLogStr = string.IsNullOrEmpty(Util.INIOperationClass.INIGetStringValue(Util.DalConst._ConfigFile, "Login", "IsClearFaceLog", null)) ? "否" : Util.INIOperationClass.INIGetStringValue(Util.DalConst._ConfigFile, "Login", "IsClearFaceLog", null); bool isClearFaceLog = string.Equals(isClearFaceLogStr, "是") ? true : false; if (isClearFaceLog) { string clearFaceLogIntervalStr = string.IsNullOrEmpty(Util.INIOperationClass.INIGetStringValue(Util.DalConst._ConfigFile, "Login", "ClearFaceLogInterval", null)) ? "60" : Util.INIOperationClass.INIGetStringValue(Util.DalConst._ConfigFile, "Login", "ClearFaceLogInterval", null); int clearFaceLogInterval = Util.Common.IsInt(clearFaceLogIntervalStr) ? Convert.ToInt32(clearFaceLogIntervalStr) : 60; this.timer2.Interval = 60 * 1000; this.timer2.Tick += new System.EventHandler(this.timer2_Tick); this.timer2.Start(); } _ConfigInfo = Util.ConfigInfoLoad.GetConfigInfo(); _LogAppendToForms = new Log4netUtil.LogAppendToForms(); // _LogAppendToForms._LogAppendDelegate = DisplayJobtimes; rtxLog.Visible = false; _EnterpriseName = Util.INIOperationClass.INIGetStringValue(Util.DalConst._ConfigFile, "EnterpriseConfig", "EnterpriseName", null); _EnterpriseId = Util.INIOperationClass.INIGetStringValue(Util.DalConst._ConfigFile, "EnterpriseConfig", "EnterpriseId", null); _B2bPlatformName = Util.INIOperationClass.INIGetStringValue(Util.DalConst._ConfigFile, "EnterpriseConfig", "B2bPlatformName", null); _AutReg = string.Format("{0}{1}", _B2bPlatformName, _AutReg); this.Text = _AutReg; HideLog(); this.tsbtnStop.Enabled = false; if (!_ConfigInfo.IsShowServiceAndSupport) { //ToptsmServiceAndSupport.Enabled = false; //ToptsmServiceAndSupport.Visible = false; } }
/// <summary> /// GetConfigInfo /// </summary> private Model.ConfigInfo GetConfigInfo() { Model.ConfigInfo configInfo = new Model.ConfigInfo(); configInfo = Util.ConfigInfoLoad.GetConfigInfo(); return(configInfo); }
/// <summary> /// StartQuartzManager 启动任务管理器 /// </summary> public void StartQuartzManager() { try { string logMessage = string.Empty; ShowLog(); _QuartzManager = new Util.QuartzManager(); int r = _QuartzManager.StartAllJobs(); _ConfigInfo = GetConfigInfo(); if (_ConfigInfo == null) { logMessage = string.Format("【{0}】 初始化ConfigInfo失败.....任务管理器启动失败!", "QuartzManagerJob", string.Empty); Log4netUtil.LogDisplayHelper.LogWarning(_LogAppendToForms, logMessage); this.tsbtnStart.Enabled = true; return; } switch (r) { case -1: logMessage = string.Format("【{0}】 启动任务调度器失败,原因详见日志!", "InterfaceJob"); Log4netUtil.Log4NetHelper.Info(logMessage, "QuartzManager"); Log4netUtil.LogDisplayHelper.LogError(_LogAppendToForms, logMessage); break; case 1: logMessage = string.Format("【{0}】 任务调度器启动成功!{1}", _AutReg, false ? "(调式模式)" : string.Empty); Log4netUtil.Log4NetHelper.Info(logMessage, "QuartzManager"); Log4netUtil.LogDisplayHelper.LogMessage(_LogAppendToForms, logMessage); IList <Model.JobEntity> jobInfoList = new List <Model.JobEntity>(); jobInfoList = GetJobEntityListAll(); GetDelBackUpFilesJob(_ConfigInfo); foreach (var item in jobInfoList) { item.EnterpriseId = _ConfigInfo.EnterpriseId; item.EnterpriseName = _ConfigInfo.EnterpriseName; //item.IsDebug = _ConfigInfo.IsDebug; var configInfo = _ConfigInfo; var jobinfoItem = new List <Model.JobEntity>(); jobinfoItem.Add(item); configInfo.JobEntityList = jobinfoItem; item.StrConfigInfo = Util.NewtonsoftCommon.SerializeObjToJson(configInfo); GetScheduleJob(item); } this.tsmiStop.Enabled = true; this.tsbtnStop.Enabled = true; this.tsbtnStart.Enabled = false; this.tsmiStart.Enabled = false; break; case 2: logMessage = string.Format("【{0}】 启动任务调度器已在运行中,不能重复启动!", "InterfaceJob"); Log4netUtil.Log4NetHelper.Info(logMessage, "QuartzManager"); Log4netUtil.LogDisplayHelper.LogWarning(_LogAppendToForms, logMessage); break; default: break; } } catch (Exception ex) { string logMessage = string.Format("【{0}】 所有任务启动失败,失败原因{1}", "InterfaceJob", ex.Message); Log4netUtil.LogDisplayHelper.LogWarning(_LogAppendToForms, logMessage); } }
private static Model.ConfigInfo getConfigInfo() { Model.ConfigInfo configInfo = new Model.ConfigInfo(); string ConfigFile = System.Windows.Forms.Application.StartupPath.ToString() + "\\Config.ini"; configInfo.ModuleCode = "C13"; configInfo.WebApiUrl = Util.INIOperationClass.INIGetStringValue(ConfigFile, "WebApi", "WebApiUrl", null); configInfo.SignKey = Util.INIOperationClass.INIGetStringValue(ConfigFile, "WebApi", "SignKey", null); configInfo.EncryptKey = Util.INIOperationClass.INIGetStringValue(ConfigFile, "WebApi", "EncryptKey", null); configInfo.FtpHostIP = Util.INIOperationClass.INIGetStringValue(ConfigFile, "FTP", "IP", null); string ftpPort = Util.INIOperationClass.INIGetStringValue(ConfigFile, "FTP", "PORT", null); configInfo.FtpPort = Util.Common.IsInt(ftpPort) ? Convert.ToInt32(ftpPort) : 21; configInfo.FtpUserName = Util.INIOperationClass.INIGetStringValue(ConfigFile, "FTP", "USER", null); string ftpPasswordEncrypt = Util.INIOperationClass.INIGetStringValue(ConfigFile, "FTP", "PWD", null); configInfo.FtpPassword = Util.EncAndDec.DESDecrypt(ftpPasswordEncrypt); //解密 configInfo.FtpRootPath = Util.INIOperationClass.INIGetStringValue(ConfigFile, "FTP", "RootPath", null); string ftpBuffLength = Util.INIOperationClass.INIGetStringValue(ConfigFile, "FTP", "BuffLength", null); configInfo.FtpBuffLength = string.IsNullOrEmpty(ftpBuffLength) ? 2048 : Convert.ToInt32(ftpBuffLength); string FtpUsePassiveStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, "FTP", "UsePassive", null); FtpUsePassiveStr = string.IsNullOrEmpty(FtpUsePassiveStr) ? "否" : FtpUsePassiveStr; configInfo.FtpUsePassive = string.Equals(FtpUsePassiveStr, "是") ? true : false; configInfo.LastLoginName = Util.INIOperationClass.INIGetStringValue(ConfigFile, "Login", "LastLoginName", null); string b2bPlatformNameStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, "EnterpriseConfig", "B2bPlatformName", null); configInfo.B2bPlatformName = string.IsNullOrEmpty(b2bPlatformNameStr) ? "药药购 " : b2bPlatformNameStr; configInfo.EnterpriseName = Util.INIOperationClass.INIGetStringValue(ConfigFile, "EnterpriseConfig", "EnterpriseName", null); configInfo.EnterpriseLicenseNo = Util.INIOperationClass.INIGetStringValue(ConfigFile, "EnterpriseConfig", "EnterpriseLicenseNo", null); configInfo.EnterpriseId = Util.INIOperationClass.INIGetStringValue(ConfigFile, "EnterpriseConfig", "EnterpriseId", null); configInfo.LoginName = Util.INIOperationClass.INIGetStringValue(ConfigFile, "EnterpriseConfig", "LoginName", null); configInfo.Password = Util.INIOperationClass.INIGetStringValue(ConfigFile, "EnterpriseConfig", "Password", null); configInfo.LogRetentionDays = Util.Common.IsInt(Util.INIOperationClass.INIGetStringValue(ConfigFile, "Login", "LogRetentionDays", null)) ? Convert.ToInt32(Util.INIOperationClass.INIGetStringValue(ConfigFile, "Login", "LogRetentionDays", null)) : 15; string autoAdvanceDaysStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, "Login", "AutoAdvanceDays", null); autoAdvanceDaysStr = string.IsNullOrEmpty(autoAdvanceDaysStr) ? "3" : autoAdvanceDaysStr; configInfo.AutoAdvanceDays = Util.Common.IsInt(autoAdvanceDaysStr) ? Convert.ToInt32(autoAdvanceDaysStr) : 3; string orderCodePrefix = Util.INIOperationClass.INIGetStringValue(ConfigFile, "Login", "OrderCodePrefix", null); configInfo.OrderCodePrefix = string.IsNullOrEmpty(orderCodePrefix) ? "FYYK" : orderCodePrefix; //订单前缀 string serviceAndSupport = Util.INIOperationClass.INIGetStringValue(ConfigFile, "Login", "ServiceAndSupport", null); configInfo.ServiceAndSupport = string.IsNullOrEmpty(serviceAndSupport) ? "武汉飞宇益克科技有限公司" : serviceAndSupport; string isShowServiceAndSupportStr = string.IsNullOrEmpty(Util.INIOperationClass.INIGetStringValue(ConfigFile, "Login", "IsShowServiceAndSupport", null)) ? "Y" : Util.INIOperationClass.INIGetStringValue(ConfigFile, "Login", "IsShowServiceAndSupport", null); configInfo.IsShowServiceAndSupport = string.Equals(isShowServiceAndSupportStr, "N") ? false:true; string xmlFileMaxSizeStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, "Login", "XmlFileMaxSize", null); xmlFileMaxSizeStr = string.IsNullOrEmpty(xmlFileMaxSizeStr) ? "2.0" : xmlFileMaxSizeStr; configInfo.XmlFileMaxSize = Util.Common.IsDouble(xmlFileMaxSizeStr) ? Convert.ToDouble(xmlFileMaxSizeStr):2.0; configInfo.JobEnable = Util.INIOperationClass.INIGetStringValue(ConfigFile, "JobConfig", "JobEnable", null); List <Model.JobEntity> JobEntityList = new List <Model.JobEntity>(); if (!String.IsNullOrEmpty(configInfo.JobEnable)) { string[] array = configInfo.JobEnable.Split(','); for (int i = 0; i < array.Count(); i++) { string jobCode = array[i].ToString().Trim(); if (string.IsNullOrEmpty(jobCode)) { continue; } Model.JobEntity jobEntity = new Model.JobEntity(); jobEntity.JobCode = jobCode; jobEntity.JobName = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "JobName", null); jobEntity.CronExpression = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "CronExpression", null); jobEntity.CronExpressionDescription = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "CronExpressionDescription", null); string isDebugJob = string.IsNullOrEmpty(Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "IsDebug", null)) ? "否" : Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "IsDebug", null); jobEntity.IsDebug = string.Equals(isDebugJob, "是") ? true : false; string domainNameStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "DomainName", null); jobEntity.DomainName = string.IsNullOrEmpty(domainNameStr) ? "tsm.fyyk.com" : domainNameStr; //Api 域名 string serviceNameStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "ServiceName", null); jobEntity.ServiceName = string.IsNullOrEmpty(serviceNameStr) ? "fyyk" : serviceNameStr;//Api 服务器 string interfacePrefixStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "InterfacePrefix", null); jobEntity.InterfacePrefix = string.IsNullOrEmpty(interfacePrefixStr) ? "dev-api" : interfacePrefixStr;//Api 接口前缀 string moduleTypeStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "ModuleType", null); jobEntity.ApiModuleType = string.IsNullOrEmpty(moduleTypeStr) ? "dataApi" : moduleTypeStr;//Api 模块 string requestTypeStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "RequestType", null); jobEntity.ApiRequestType = string.IsNullOrEmpty(requestTypeStr) ? string.Empty : requestTypeStr;//Api 请求名称 string targetDatabaseStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "TargetDatabase", null); jobEntity.TargetDatabase = string.IsNullOrEmpty(targetDatabaseStr) ? "Erp" : targetDatabaseStr; string procedureNameStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "ProcedureName", null); jobEntity.ProcedureName = string.IsNullOrEmpty(procedureNameStr) ? "Fyyk_B2b_SqlView" : procedureNameStr; string moduleIDStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "ModuleID", null); jobEntity.ModuleID = string.IsNullOrEmpty(moduleIDStr) ? string.Empty : moduleIDStr; string filterBillTypeStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "FilterBillType", null); filterBillTypeStr = string.IsNullOrEmpty(filterBillTypeStr) ? "1" : filterBillTypeStr; jobEntity.FilterBillType = Util.Common.IsInt(filterBillTypeStr) ? Convert.ToInt32(filterBillTypeStr) : 1; string writebackProcedureNameStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "WritebackProcedureName", null); jobEntity.WritebackProcedureName = string.IsNullOrEmpty(writebackProcedureNameStr) ? "Fyyk_B2b_Writeback" : writebackProcedureNameStr; string writebackTypeStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "WritebackType", null); jobEntity.WritebackType = string.IsNullOrEmpty(writebackTypeStr) ? string.Empty : writebackTypeStr; string insertTableNameStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "InsertTableName", null); jobEntity.InsertTableName = string.IsNullOrEmpty(insertTableNameStr) ? string.Empty : insertTableNameStr; string pagesSizeStr = Util.INIOperationClass.INIGetStringValue(ConfigFile, jobCode, "PageSize", null); pagesSizeStr = string.IsNullOrEmpty(pagesSizeStr) ? "0" : pagesSizeStr; jobEntity.PageSize = Util.Common.IsInt(pagesSizeStr) ? Convert.ToInt32(pagesSizeStr) : 0; //分页上传 JobEntityList.Add(jobEntity); } } configInfo.JobEntityList = JobEntityList; return(configInfo); }