/// <summary> /// /// </summary> /// <param name="areaCode"></param> /// <param name="csId"></param> /// <param name="dt"></param> /// <returns></returns> public static List <JObject> DataTableConvertList(string areaCode, string csId, DataTable dt) { List <JObject> list = new List <JObject>(); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { try { JObject item = new JObject(); item["DataID"] = dr["DID"].ToString(); item["AreaCode"] = areaCode; item["CsId"] = csId; item["DeviceInnerID"] = dr["SID"].ToString(); item["DacTime"] = Convert.ToDateTime(dr["DataTime"]); item["V1"] = (dr["R1"] == null ? null : dr["R1"].ToString()); item["V2"] = (dr["R2"] == null ? null : dr["R2"].ToString()); list.Add(item); } catch (Exception e) { //日志处理 Loghelper.WriteErrorLog("基康应力应变数据转换失败", e); lr.AddLogInfo(e.ToString(), areaCode, "基康应力应变数据转换失败", "Error"); //throw e; } } } return(list); }
/// <summary> /// 发送数据 /// </summary> /// <param name="bts">发送内容</param> /// <param name="comm">命令结构</param> protected void Send(byte[] bts, Record comm) { Thread.Sleep(1); if (Client == null) { return; } if (Client.IsOnlineRead()) { try { lock (Stream) { Stream.BeginWrite(bts, 0, bts.Length, WriteComplete, new NetModel(Stream, comm)); } } catch (Exception ex) { Loghelper.Error(ex); } Loghelper.Debug(string.Format("发送命令:{0} 数据长度:{1}", comm.Type, bts.Length)); } else { OnClientDisconnect(this); } }
/// <summary> /// 查询空气质量站点对应区域数据 /// </summary> /// <param name="cityCode"></param> /// <returns></returns> public DataTable AirAreaInfoQuery(string cityCode = "*") { DataTable dt = new DataTable(); string cityCodeFilter = ""; if (!string.IsNullOrEmpty(cityCode) && cityCode != "*") { cityCodeFilter = " and \"CityCode\" like '" + cityCode + "%'"; } try { StringBuilder sb = new StringBuilder(); sb.AppendFormat("select distinct(CityCode),Area from \"t_air_station\" where 1=1 {0} " + " order by \"CityCode\" asc", cityCodeFilter); SQLiteConnection conn = SQLiteHelper.GetConnection(dataBaseName); DataSet datasetTemp = SQLiteHelper.ExecuteDataSet(conn, sb.ToString(), null); if (datasetTemp != null) { dt = datasetTemp.Tables[0]; } } catch (Exception e) { //日志处理 Loghelper.WriteErrorLog("查询空气质量站点对应区域数据失败", e); lr.AddLogInfo(e.ToString(), "查询空气质量站点对应区域数据失败", "t_area", "Error"); //throw e; } return(dt); }
/// <summary> /// 查询配置信息 /// </summary> /// <param name="areaCode"></param> /// <param name="csCode"></param> /// <returns></returns> public ConnectionStringSettings ConnnectConfigQuery(string areaCode, string csCode) { ConnectionStringSettings conn = null; try { DataTable dt = DataConfigInfoQuery(areaCode, csCode); if (dt != null && dt.Rows.Count > 0) { string bzkSQLServerDbServerIP = dt.Rows[0]["DBIPAddress"].ToString(); string bzkSQLServerDbServerPort = dt.Rows[0]["DBPort"].ToString(); string bzkSQLServerDbServerUserId = dt.Rows[0]["DBUserName"].ToString(); string bzkSQLServerDbServerUserPassword = dt.Rows[0]["DBPassword"].ToString(); string bzkSQLServerProviderName = dt.Rows[0]["DBType"].ToString(); string bzkSQLServerDbName = dt.Rows[0]["DBName"].ToString(); DBHelper dbHelper = new DBHelper(); //conn = dbHelper.GetCustomSQLServerConnection(bzkSQLServerDbServerIP, bzkSQLServerDbServerPort, bzkSQLServerDbServerUserId, bzkSQLServerDbServerUserPassword, bzkSQLServerProviderName, bzkSQLServerDbName); } } catch (Exception e) { //日志处理 Loghelper.WriteErrorLog("查询配置信息失败", e); //throw e; } return(conn); }
/// <summary> /// 查询数据表中最新数据时间 /// </summary> /// <returns></returns> public bool IsCompeletCollect(string tableName, string stationCode, DateTime monitorTime) { bool result = false; try { this.dbHelper = new DBHelper(tempSQLCoonectStr); StringBuilder sb = new StringBuilder(); sb.AppendFormat("select * from {0} where 1=1 and SITE_CODE = '{1}' and MONITOR_TIME = '{2}' ", tableName, stationCode, monitorTime.ToString("yyyy-MM-dd HH:mm:ss.fff")); string sql = SQLUtils.genarateSQL(sb.ToString(), this.dbHelper.sqlConnectionType); DataSet datasetTemp = dbHelper.DataAdapter(CommandType.Text, sql); if (datasetTemp != null) { DataTable dt = datasetTemp.Tables[0]; if (dt != null && dt.Rows.Count > 0) { result = true; } } } catch (Exception e) { //日志处理 Loghelper.WriteErrorLog("查询数据表中最新数据时间失败", e); lr.AddLogInfo(e.ToString(), "查询数据表中最新数据时间失败", tableName, "Error"); //throw e; } return(result); }
//设置菜单对应内容面板显示 private void setTabContentShow(Form form) { try { if (groupBoxRightMenu.Controls != null) { for (int i = 0; i < groupBoxRightMenu.Controls.Count; i++) { if (groupBoxRightMenu.Controls[i] == form) { groupBoxRightMenu.Controls[i].Show(); } else { groupBoxRightMenu.Controls[i].Hide(); } } } } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("捕获异常信息", ex); lr.AddLogInfo(ex.ToString(), "捕获异常信息", "捕获异常信息", "Error"); } }
/// <summary> /// 查询日志信息 /// </summary> /// <param name="startTimeStr"></param> /// <param name="endTimeStr"></param> /// <returns></returns> public DataTable LogInfoQuery(string startTimeStr = "*", string endTimeStr = "*") { DataTable dt = new DataTable(); try { StringBuilder sb = new StringBuilder(); sb.AppendFormat("select * from \"t_log_info\" where 1=1 and CreateTime between '{0}' and '{1}' " + " order by \"CreateTime\" desc", DateTime.Parse(startTimeStr).ToString("yyyy-MM-dd 00:00:00.000"), Convert.ToDateTime(endTimeStr).ToString("yyyy-MM-dd 23:59:59.999")); SQLiteConnection conn = SQLiteHelper.GetConnection(dataBaseName); DataSet datasetTemp = SQLiteHelper.ExecuteDataSet(conn, sb.ToString(), null); if (datasetTemp != null) { dt = datasetTemp.Tables[0]; } } catch (Exception e) { //日志处理 Loghelper.WriteErrorLog("查询日志信息失败", e); //throw e; } return(dt); }
/// <summary> /// 删除空气质量站点数据 /// </summary> /// <returns></returns> public bool DeleteAirStationInfo() { bool result = false; try { StringBuilder sb = new StringBuilder(); sb.AppendFormat("delete from \"t_air_station\" where 1=1 "); SQLiteConnection conn = SQLiteHelper.GetConnection(dataBaseName); int count = SQLiteHelper.ExecuteNonQuery(conn, sb.ToString(), null); if (count > 0) { result = true; } } catch (Exception e) { //日志处理 Loghelper.WriteErrorLog("删除空气质量站点数据失败", e); lr.AddLogInfo(e.ToString(), "删除空气质量站点数据失败", "t_air_station", "Error"); //throw e; } return(result); }
/// <summary> /// 删除配置信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool DeleteDataConfigInfo(string id) { bool result = false; try { StringBuilder sb = new StringBuilder(); sb.AppendFormat("delete from \"t_data_config\" where 1=1 and Id ={0}", id); SQLiteConnection conn = SQLiteHelper.GetConnection(dataBaseName); int count = SQLiteHelper.ExecuteNonQuery(conn, sb.ToString(), null); if (count > 0) { result = true; } } catch (Exception e) { //日志处理 Loghelper.WriteErrorLog("删除配置信息失败", e); lr.AddLogInfo(e.ToString(), "删除配置信息失败", "t_data_config", "Error"); //throw e; } return(result); }
private void proviceComboBox_SelectedIndexChanged(object sender, EventArgs e) { try { cityComboBox.Items.Clear(); Area areaDefail = new Area(); areaDefail.AreaCode = "*"; areaDefail.AreaName = "请选择"; cityComboBox.Items.Add(areaDefail); if (proviceComboBox.SelectedItem != null) { Area areaObj = (Area)(proviceComboBox.SelectedItem); DataTable cityTable = ar.AreaInfoQuery(areaObj.AreaCode.Substring(0, 2), "2"); if (cityTable != null && cityTable.Rows.Count > 0) { List <Dictionary <string, string> > list = Utility.DataTableToList(cityTable); for (int i = 0; i < list.Count; i++) { Area area = Utility.ParseDictionaryToModel <Area>(list[i]); cityComboBox.Items.Add(area); cityComboBox.DisplayMember = "AreaName"; } } } } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("查询级联城市失败", ex); lr.AddLogInfo(ex.ToString(), "查询级联城市失败", "", "Error"); //throw e; } }
private void FrDataConfig_Load(object sender, EventArgs e) { try { DataTable proviceTable = ar.AreaInfoQuery("*", "1"); Area areaDefail = new Area(); areaDefail.AreaCode = "*"; areaDefail.AreaName = "请选择"; proviceComboBox.Items.Add(areaDefail); if (proviceTable != null && proviceTable.Rows.Count > 0) { List <Dictionary <string, string> > list = Utility.DataTableToList(proviceTable); for (int i = 0; i < list.Count; i++) { Area area = Utility.ParseDictionaryToModel <Area>(list[i]); proviceComboBox.Items.Add(area); proviceComboBox.DisplayMember = "AreaName"; } } stationQueryBtn_Click(null, null); } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("初始化空气质量站点页面失败", ex); lr.AddLogInfo(ex.ToString(), "初始化空气质量站点页面失败", "", "Error"); //throw e; } }
private void stationQueryBtn_Click(object sender, EventArgs e) { try { string cityCodeFilter = "*"; if (cityComboBox.SelectedItem != null) { Area areaCityObj = (Area)(cityComboBox.SelectedItem); cityCodeFilter = areaCityObj.AreaCode; } if (cityCodeFilter == "*" || String.IsNullOrEmpty(cityCodeFilter)) { if (proviceComboBox.SelectedItem != null) { Area areaProviceObj = (Area)(proviceComboBox.SelectedItem); cityCodeFilter = areaProviceObj.AreaCode.Substring(0, 2); } } DataTable dt = asr.AirStationInfoQuery(cityCodeFilter); if (dt != null) { dataGridView1.DataSource = dt; } } catch (Exception ex) { load_lb.Visible = false; //日志处理 Loghelper.WriteErrorLog("查询空气质量站点数据失败", ex); lr.AddLogInfo(ex.ToString(), "查询空气质量站点数据失败", "", "Error"); //throw e; } }
public Fr_Main() { InitializeComponent(); try { Form[] forms = { frDataSourceConfig, frDataConfig, frDataCollect, frLookLog, frAboutAs }; for (int i = 0; i < forms.Length; i++) { forms[i].TopLevel = false; forms[i].Dock = DockStyle.Fill;//把子窗体设置为控件 forms[i].Hide(); forms[i].FormBorderStyle = FormBorderStyle.None; groupBoxRightMenu.Controls.Add(forms[i]); } dataSourceConfigBtn_Click(null, null); } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("捕获异常信息", ex); lr.AddLogInfo(ex.ToString(), "捕获异常信息", "捕获异常信息", "Error"); } }
public static int initManager() { bool bb = AppCommon.Log.UMCLog.Enable;//使用静态变量触发类的静态构造函数(get√) #region 务注册 GalaSoft.MvvmLight.Ioc.SimpleIoc.Default.Register <FunctionService>(true);//注入ioc,并立即实例化 #endregion DirectoryInfo AppFolder = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); foreach (FileInfo NextFile in AppFolder.GetFiles()) { bool b = NextFile.Name.StartsWith("UMC"); if (NextFile.Extension.ToUpper() == ".DLL" && NextFile.Name.StartsWith("UMC")) { Loghelper.WriteLogTrace("正在加载:" + NextFile.FullName.ToString()); System.Reflection.Assembly assemblyInfo = null; try { assemblyInfo = System.Reflection.Assembly.LoadFrom(NextFile.FullName); } catch { assemblyInfo = null; } if (assemblyInfo == null) { continue; } //获取所有公开类型 Type[] TempTArray = assemblyInfo.GetExportedTypes(); foreach (Type type in TempTArray) { object[] TypeAttributes = type.GetCustomAttributes(typeof(AppModel.UMCAttributes.UMCAttribute), false); if (TypeAttributes != null && TypeAttributes.Length > 0) { //程序集里面不是所有的公共类型都是自定义特性的,所以在此做个判断 try { //特性只有一个,所以是0 AppModel.UMCAttributes.UMCAttribute temp = TypeAttributes[0] as AppModel.UMCAttributes.UMCAttribute; switch (temp.CurrentType) { case AppModel.UMCAttributes.FuncType.Func: //↓先从容器中获取Service实例,然后调用service的自定义注入方法 GalaSoft.MvvmLight.Ioc.SimpleIoc.Default.GetInstance <FunctionService>().RegisterFunction(temp.ClassType, temp.Key); break; default: break; } } catch (Exception ex) { Loghelper.WriteLogException(ex); } } } } } return(-1); }
//切换菜单时修改菜单样式 private void setMenuStyle(string selectedBtnName) { try { switch (selectedBtnName) { case "dataSourceConfigBtn": dataSourceConfigBtn.BackColor = Color.FromArgb(191, 205, 219); dataConfigBtn.BackColor = Color.FromArgb(240, 240, 240); dataCollectBtn.BackColor = Color.FromArgb(240, 240, 240); lookLogBtn.BackColor = Color.FromArgb(240, 240, 240); aboutUsBtn.BackColor = Color.FromArgb(240, 240, 240); break; case "dataConfigBtn": dataSourceConfigBtn.BackColor = Color.FromArgb(240, 240, 240); dataConfigBtn.BackColor = Color.FromArgb(191, 205, 219); dataCollectBtn.BackColor = Color.FromArgb(240, 240, 240); lookLogBtn.BackColor = Color.FromArgb(240, 240, 240); aboutUsBtn.BackColor = Color.FromArgb(240, 240, 240); break; case "dataCollectBtn": dataSourceConfigBtn.BackColor = Color.FromArgb(240, 240, 240); dataCollectBtn.BackColor = Color.FromArgb(191, 205, 219); dataConfigBtn.BackColor = Color.FromArgb(240, 240, 240); lookLogBtn.BackColor = Color.FromArgb(240, 240, 240); aboutUsBtn.BackColor = Color.FromArgb(240, 240, 240); break; case "lookLogBtn": dataSourceConfigBtn.BackColor = Color.FromArgb(240, 240, 240); lookLogBtn.BackColor = Color.FromArgb(191, 205, 219); dataConfigBtn.BackColor = Color.FromArgb(240, 240, 240); dataCollectBtn.BackColor = Color.FromArgb(240, 240, 240); aboutUsBtn.BackColor = Color.FromArgb(240, 240, 240); break; case "aboutUsBtn": dataSourceConfigBtn.BackColor = Color.FromArgb(240, 240, 240); aboutUsBtn.BackColor = Color.FromArgb(191, 205, 219); dataConfigBtn.BackColor = Color.FromArgb(240, 240, 240); dataCollectBtn.BackColor = Color.FromArgb(240, 240, 240); lookLogBtn.BackColor = Color.FromArgb(240, 240, 240); break; } } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("捕获异常信息", ex); lr.AddLogInfo(ex.ToString(), "捕获异常信息", "捕获异常信息", "Error"); } }
private void Fr_Main_Load(object sender, EventArgs e) { try { timer1.Start(); } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("捕获异常信息", ex); lr.AddLogInfo(ex.ToString(), "捕获异常信息", "捕获异常信息", "Error"); } }
//计时器 private void timer1_Tick(object sender, EventArgs e) { try { toolStripStatusLabel1.Text = "当前系统时间:" + System.DateTime.Now.ToString(); } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("捕获异常信息", ex); lr.AddLogInfo(ex.ToString(), "捕获异常信息", "捕获异常信息", "Error"); } }
private void cancleDataConfigBtn_Click(object sender, EventArgs e) { try { this.Dispose(); this.Close(); } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("捕获异常信息", ex); lr.AddLogInfo(ex.ToString(), "捕获异常信息", "捕获异常信息", "Error"); } }
private void airStationLoadBtn_Click(object sender, EventArgs e) { try { airStationLoadTask(); } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("同步空气质量站点数据失败", ex); lr.AddLogInfo(ex.ToString(), "同步空气质量站点数据失败", "提示", "Error"); //throw e; } }
private void WriteComplete(IAsyncResult ar) { var netmodel = (NetModel)ar.AsyncState; try { netmodel.NetStream.EndWrite(ar); } catch (Exception ex) { Loghelper.Error(ex); } OnMsgSend(this, netmodel.Record); }
//切换到同步基础 private void dataConfigBtn_Click(object sender, EventArgs e) { try { setMenuStyle("dataConfigBtn"); setTabContentShow(frDataConfig); } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("捕获异常信息", ex); lr.AddLogInfo(ex.ToString(), "捕获异常信息", "捕获异常信息", "Error"); } }
/// <summary> /// 查询统计信息 /// </summary> /// <returns></returns> public JObject GetCollectInfo() { string startTimeStr = DateTime.Now.ToString("yyyy-MM-dd 00:00:00.000"); string endTimeStr = DateTime.Now.ToString("yyyy-MM-dd 23:59:59.999"); JObject objItem = new JObject(); objItem["allTotal"] = 0; objItem["todayTotal"] = 0; objItem["lastTime"] = '-'; try { StringBuilder sb = new StringBuilder(); sb.AppendFormat("select * from ( " + "(select sum(CollectTotal) as allTotal,max(CollectTime) as lastTime from t_collect_static) a " + "left join " + "(select sum(CollectTotal) as todayTotal from t_collect_static where CollectTime between '{0}' and '{1}') b " + "on 1 = 1 " + ")" , startTimeStr, endTimeStr); SQLiteConnection conn = SQLiteHelper.GetConnection(dataBaseName); DataSet datasetTemp = SQLiteHelper.ExecuteDataSet(conn, sb.ToString(), null); if (datasetTemp != null) { DataTable dt = datasetTemp.Tables[0]; if (dt != null && dt.Rows.Count > 0) { objItem["allTotal"] = (string.IsNullOrEmpty(dt.Rows[0]["allTotal"].ToString()) ? "0" : dt.Rows[0]["allTotal"].ToString()); objItem["todayTotal"] = (string.IsNullOrEmpty(dt.Rows[0]["todayTotal"].ToString()) ? "0" : dt.Rows[0]["todayTotal"].ToString()); objItem["lastTime"] = (dt.Rows[0]["lastTime"] == null || string.IsNullOrEmpty(dt.Rows[0]["lastTime"].ToString()) ? "-" : Convert.ToDateTime(dt.Rows[0]["lastTime"]).ToString("yyyy-MM-dd HH:mm:ss.fff")); } } } catch (Exception e) { //日志处理 Loghelper.WriteErrorLog("查询统计信息失败", e); lr.AddLogInfo(e.ToString(), "查询统计信息失败", "t_collect_static", "Error"); //throw e; } return(objItem); }
/// <summary> /// 查询配置信息 /// </summary> /// <param name="dbIP"></param> /// <param name="dbPort"></param> /// <returns></returns> public DataTable DataConfigInfoQuery(string dbIP = "*", string dbPort = "*", string dbType = "*") { DataTable dt = new DataTable(); string dbIPFilter = ""; if (!string.IsNullOrEmpty(dbIP) && dbIP != "*") { dbIPFilter = " and \"DBIPAddress\" in(" + Utility.ConvertFieldValue(dbIP) + ")"; } string dbPortFilter = ""; if (!string.IsNullOrEmpty(dbPort) && dbPort != "*") { dbPortFilter = " and \"DBPort\" in(" + Utility.ConvertFieldValue(dbPort) + ")"; } string dbTypeFilter = ""; if (!string.IsNullOrEmpty(dbType) && dbType != "*") { dbTypeFilter = " and \"DBType\" in(" + Utility.ConvertFieldValue(dbType) + ")"; } try { StringBuilder sb = new StringBuilder(); sb.AppendFormat("select * from \"t_data_config\" where 1=1 {0} {1} {2}" + " order by \"CreateTime\" desc", dbIPFilter, dbPortFilter, dbTypeFilter); SQLiteConnection conn = SQLiteHelper.GetConnection(dataBaseName); DataSet datasetTemp = SQLiteHelper.ExecuteDataSet(conn, sb.ToString(), null); if (datasetTemp != null) { dt = datasetTemp.Tables[0]; } } catch (Exception e) { //日志处理 Loghelper.WriteErrorLog("查询配置信息失败", e); lr.AddLogInfo(e.ToString(), "查询配置信息失败", "t_data_config", "Error"); //throw e; } return(dt); }
private void 显示ToolStripMenuItem_Click(object sender, EventArgs e) { try { //还原窗体显示 WindowState = FormWindowState.Normal; //激活窗体并给予它焦点 this.Activate(); //任务栏区显示图标 this.ShowInTaskbar = true; //托盘区图标隐藏 notifyIcon1.Visible = false; } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("捕获异常信息", ex); lr.AddLogInfo(ex.ToString(), "捕获异常信息", "捕获异常信息", "Error"); } }
private void Fr_Main_FormClosing(object sender, FormClosingEventArgs e) { try { if (this.WindowState != FormWindowState.Minimized) { e.Cancel = true;//不关闭程序 //最小化到托盘的时候显示图标提示信息,提示用户并未关闭程序 this.WindowState = FormWindowState.Minimized; notifyIcon1.ShowBalloonTip(2000, "", "最小到托盘", ToolTipIcon.None); } } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("捕获异常信息", ex); lr.AddLogInfo(ex.ToString(), "捕获异常信息", "捕获异常信息", "Error"); } }
private void Fr_Main_SizeChanged(object sender, EventArgs e) { try { // 判断是否选择的是最小化按钮 if (WindowState == FormWindowState.Minimized) { //隐藏任务栏区图标 this.ShowInTaskbar = false; //图标显示在托盘区 notifyIcon1.Visible = true; } } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("捕获异常信息", ex); lr.AddLogInfo(ex.ToString(), "捕获异常信息", "捕获异常信息", "Error"); } }
/// <summary> /// 命令相关执行内容 /// </summary> /// <param name="obj"></param> protected void HandleProtocol(object obj) { Record comm = (Record)obj; switch (comm.Type) { case ComdType.Identity: ClientType = (ClientType)int.Parse(comm.Data); break; case ComdType.IdentityC: Id = new Guid(comm.Bytes); OnClientConnected(this, true, "连接成功"); break; default: Loghelper.Debug(string.Format("执行{0}命令", comm.Type)); OnMsgRead(this, comm); break; } }
private void FrDataConfigAdd_Load(object sender, EventArgs e) { try { Dictionary <string, string> dir = DBType.GetDBTypes(); foreach (var item in dir) { DataBaseType dataBaseType = new DataBaseType(); dataBaseType.dataBaseName = item.Key; dataBaseType.dataBsseValue = item.Value; dBTypeComboBox.Items.Add(dataBaseType); dBTypeComboBox.DisplayMember = "dataBaseName"; } } catch (Exception ex) { //日志处理 Loghelper.WriteErrorLog("捕获异常信息", ex); lr.AddLogInfo(ex.ToString(), "捕获异常信息", "捕获异常信息", "Error"); } }
public void WriteLogTest() { //Log.LogFactory.DataLog.Info(new LogMessage() { UserId = "UserId4", Message = DateTime.Now.ToString(),AreaName="area1",ControllerName="con2",ActionName="action3" }); var log = new LogMessage() { UserId = "UserId4", Message = DateTime.Now.ToString(), AreaName = "area1", ControllerName = "con2", ActionName = "action3", }; log.ExtendPropety.Add("ou", "testou"); Log.LogFactory.WebBusinessLog.Info(log); Log.LogFactory.WebDataLog.Info(new LogMessage() { UserId = "UserId4", Message = DateTime.Now.ToString(), AreaName = "area1", ControllerName = "con2", ActionName = "action3" }); //Log.LogFactory.RunningLog.Info(new LogMessage() { UserId = "UserId4", Message = DateTime.Now.ToString(),AreaName="area1",ControllerName="con2",ActionName="action3" }); Loghelper.WriteLog("today"); }
/// <summary> /// 执行 /// </summary> /// <param name="context"></param> public void Execute(IJobExecutionContext context) { Task.Run(() => { try { JobDataMap dataMap = context.JobDetail.JobDataMap; string key = dataMap.GetString("key");//获取参数 //1.绑定需要执行的操作方法 //var act = new Action(FrDataCollect.frDataCollect.collectHourDataTool); //act.BeginInvoke(ar => act.EndInvoke(ar), null); //参数null可以作为回调函数的返回参数 _ = FrDataCollect.frDataCollect.collectHourDataTool(); } catch (Exception e) { Loghelper.WriteErrorLog("定时任务调用窗体函数采集数据失败", e); lr.AddLogInfo(e.ToString(), "定时任务调用窗体函数采集数据失败", "定时任务调用窗体函数采集数据失败", "Error"); //throw e; } }); }