//针对事件模糊查询 private void btn_Select_Click(object sender, EventArgs e) { string whereclause = ""; whereclause += (txt_select.Text == "") ? "" : "logEVENT like '%" + txt_select.Text + "%' AND "; if (whereclause.EndsWith(" AND ")) { whereclause = whereclause.Substring(0, whereclause.Length - 5); } if (whereclause != "") { whereclause = whereclause + " order by logTime desc "; //让日志按照时间顺序 升序排列 } listView.Items.Clear(); List <string[]> list = LogTable.SeachLog(whereclause); if (list.Count == 0) { return; } for (int i = 0; i < list.Count; i++) { string[] strRow = list[i]; listView.Items.Add(strRow[0]); listView.Items[i].SubItems.Add(strRow[1]); listView.Items[i].SubItems.Add(strRow[2]); listView.Items[i].SubItems.Add(strRow[3]); } }
public void ResetCloumns(LogTable lt) { this.dataGridView1.Rows.Clear(); this.dataGridView1.Columns.Clear(); m_lstColsSeq.Clear(); GC.Collect(); // 加一个序号列 DataGridViewColumn dgvc = CreateColumn("序号"); this.dataGridView1.Columns.Add(dgvc); foreach (LogTableItem lti in lt.Columns) { LogColumn lc = LogColumnService.Instance.GetLogColumn(lti.LogColumnIndex); dgvc = CreateColumn(string.IsNullOrWhiteSpace(lti.NickName) ? lc.Name : lti.NickName); dgvc.Visible = lti.Visible; dgvc.Tag = lc.Index; m_lstColsSeq.Add(lc.Index); this.dataGridView1.Columns.Add(dgvc); } }
public void RefreshLog() { //log = new LogFile(null, m_strLogFilePath); string whereclause = ""; whereclause += (dateTimePickerStart.Text == "") ? "" : "logTime > '" + Convert.ToDateTime(dateTimePickerStart.Text).ToString("yyyy-MM-dd HH:mm:ss") + "' AND "; whereclause += (dateTimePickerEnd.Text == "") ? "" : "logTime < '" + Convert.ToDateTime(dateTimePickerEnd.Text + " 23:59:59").ToString("yyyy-MM-dd HH:mm:ss") + "' AND "; whereclause += (cBoxUser.Text == "所有用户" || cBoxUser.Text == "") ? "" : "logUser = '******' AND "; whereclause += (cBoxAccessIP.Text == "" || cBoxAccessIP.Text == "所有IP") ? "" : "logIP = '" + cBoxAccessIP.Text + "'"; if (whereclause.EndsWith(" AND ")) { whereclause = whereclause.Substring(0, whereclause.Length - 5); } if (whereclause != "") { whereclause = whereclause + " order by logTime desc "; //让日志按照时间顺序 升序排列 } listView.Items.Clear(); List <string[]> list = LogTable.SeachLog(whereclause); if (list.Count == 0) { return; } for (int i = 0; i < list.Count; i++) { string[] strRow = list[i]; listView.Items.Add(strRow[0]); listView.Items[i].SubItems.Add(strRow[1]); listView.Items[i].SubItems.Add(strRow[2]); listView.Items[i].SubItems.Add(strRow[3]); } }
// TODO: upsert account details, tickets #endregion // Stored Procedures #endregion // Properties #region Methods #region No Parameters /// <summary> /// Gets the list of account details. /// </summary> /// <returns>A <see cref="Task{TResult}"/>.</returns> public async Task <LogTable> GetAccountDetailsAsync() { var resultTable = new LogTable(); using (var conn = new SqlConnection(this.connectionString)) { var cmd = new SqlCommand { CommandText = this.SpGetAccountDetails, CommandType = CommandType.StoredProcedure, Connection = conn }; try { await conn.OpenAsync().ConfigureAwait(false); var adapter = new SqlDataAdapter(cmd); adapter.Fill(resultTable); this.SetStatusConnected(); } catch (Exception error) { this.SetStatusDisconnected(error); } finally { conn.Close(); } } return(resultTable); }
private void menuNewLog_Click(object sender, EventArgs e) { try { string appGuid = Convert.ToString((this.tvApps.SelectedNode.Level == AppNodeLevel)? this.tvApps.SelectedNode.Tag : this.tvApps.SelectedNode.Parent.Tag); this.Cursor = Cursors.WaitCursor; frmEditTableProperty fe = new frmEditTableProperty(ConstTableValue.DefaultLogTableName); fe.Text = "编辑日志表名称"; if (CGeneralFuncion.ShowWindow(this, fe, true) == System.Windows.Forms.DialogResult.OK) { LogTable lt = LogTable.NewLogTable; lt.Name = fe.EditedName; CreateNewLogStructCommand cmd = new CreateNewLogStructCommand(appGuid, lt); cmd.UndoDone += new UndoRedoEventHandler(RemoveTableFromTree); cmd.RedoDone += new UndoRedoEventHandler(AddTable2Tree); cmd.Execute(); AddCommand(cmd); AddTable2Tree(appGuid, lt.GUID, lt.Name); } } catch (Exception ex) { MessageBox.Show("创建日志表失败,错误消息为:" + ex.Message); } }
private void ExchageTableItem(LogTable table, int firstIndex, int secondIndex) { LogTableItem lti = (LogTableItem)table.Columns[firstIndex].Clone(); table.Columns[firstIndex].CopyFrom(table.Columns[secondIndex]); table.Columns[secondIndex].CopyFrom(lti); }
public void AddLog(string appGuid, string tableGuid, List <LogRecord> records) { this.Cursor = Cursors.WaitCursor; try { LogTable table = AppService.Instance.GetAppTable(appGuid, tableGuid); LogShowTabPage tp = new LogShowTabPage(table.Name); tp.ResetCloumns(table); tp.SetLogs(records); tp.AppGuid = appGuid; tp.TableGuid = tableGuid; this.tabControl1.TabPages.Add(tp); UpdateLogInfo(); } catch (Exception ex) { MessageBox.Show("添加日志记录失败,错误消息为:" + ex.Message); } finally { this.Cursor = Cursors.Default; } }
private void InitLogTablePanel(LogTable table) { SetLogTablePanelButtonStatus(true); this.dataGridView1.Rows.Clear(); if (table.Columns.Count > 0) { this.dataGridView1.SuspendLayout(); try { foreach (LogTableItem item in table.Columns) { AddRow(item); } UpdatePreView(); } catch (Exception ex) { MessageBox.Show("初始化日志列项失败,错误消息为:" + ex.Message); } finally { this.dataGridView1.ResumeLayout(); } } }
private void RefreshLogHeader() { DateTime fromDate = (DateTime)rdbProcess.FromDate.Value; DateTime toDate = (DateTime)rdbProcess.ToDate.Value; dgvLog.DataSource = LogTable.GetLog(fromDate, toDate); }
protected void load_reservations() { myDAL obj = new myDAL(); LogTable.DataSource = obj.get_reservations(Session["Username"].ToString()); LogTable.DataBind(); }
private void SetRowContent(LogTable table, int rowIndex, bool isChecked) { LogTableItem item = GetLogTableItemRow(rowIndex); LogColumn lc = LogColumnService.Instance.GetLogColumn(item.LogColumnIndex); this.dataGridView1.Rows.RemoveAt(rowIndex); InsertRow(rowIndex, isChecked, item, lc); }
public bool setLogTable(string filePath) { try { lt = new LogTable(filePath); return(true); } catch { return(false); } }
public bool setLogTable() { try { lt = new LogTable(); return(true); } catch { return(false); } }
public static LogTablePuls ToLogTablePlus(LogTable t) { LogTablePuls p = new LogTablePuls(); p.GUID = t.GUID; p.Name = t.Name; return(p); }
protected void load_service_log() { myDAL obj = new myDAL(); LogTable.DataSource = obj.get_service_log(); LogTable.DataBind(); }
private void btn_Export_Click(object sender, EventArgs e) { //log = new LogFile(null, m_strLogFilePath); //FolderBrowserDialog dg=new FolderBrowserDialog(); //if (dg.ShowDialog() == DialogResult.OK) //{ // log.ExportLog(dg.SelectedPath + "\\log.txt"); // Stream pStream=File.op //} LogTable.ExportLog("日志记录", listView); }
private void btnSearch_Click(object sender, EventArgs e) { //log = new LogFile(null, m_strLogFilePath); List <string> listUsers = new List <string> (); string groupUser = ""; if (CBGroupUser.Checked == true && ComBoxGroupUsers.Text != "") { listUsers = LogTable.GetUsersByGroupUsers(ComBoxGroupUsers.Text); if (listUsers.Count > 0) { for (int i = 0; i < listUsers.Count; i++) { groupUser += "'" + listUsers[i] + "',"; } groupUser = groupUser.Substring(0, groupUser.Length - 1); } else { MessageBox.Show("该用户组不存在用户!", "错误", MessageBoxButtons.OK); return; } } string whereclause = ""; whereclause += (dateTimePickerStart.Text == "") ? "" : "logTime > '" + Convert.ToDateTime(dateTimePickerStart.Text).ToString("yyyy-MM-dd HH:mm:ss") + "' AND "; whereclause += (dateTimePickerEnd.Text == "") ? "" : "logTime < '" + Convert.ToDateTime(dateTimePickerEnd.Text + " 23:59:59").ToString("yyyy-MM-dd HH:mm:ss") + "' AND "; whereclause += (CBAllUsers.Checked == true) ? "" : ""; whereclause += (CBSingleUser.Checked == true) ? "logUser ='******' AND " : ""; whereclause += (CBGroupUser.Checked == true) ? "logUser in (" + groupUser + ") AND " : ""; whereclause += (cBoxAccessIP.Text == "" || cBoxAccessIP.Text == "所有IP") ? "" : "logIP = '" + cBoxAccessIP.Text + "' AND "; whereclause += (comBoxOperation.Text == "" || comBoxOperation.Text == "所有操作") ? "" : "logEVENT = '" + comBoxOperation.Text + "' AND "; if (whereclause.EndsWith(" AND ")) { whereclause = whereclause.Substring(0, whereclause.Length - 5); } listView.Items.Clear(); whereclause = whereclause + " order by logTime desc ";//让日志按照时间顺序 升序排列 List <string[]> list = LogTable.SeachLog(whereclause); if (list.Count == 0) { MessageBox.Show("没有符合条件的日志", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } for (int i = 0; i < list.Count; i++) { string[] strRow = list[i]; listView.Items.Add(strRow[0]); listView.Items[i].SubItems.Add(strRow[1]); listView.Items[i].SubItems.Add(strRow[2]); listView.Items[i].SubItems.Add(strRow[3]); } }
private void ExchangeDateGridRow(int firstRowIndex, int secondRowIndex) { string appGuid = Convert.ToString(tvApps.SelectedNode.Parent.Tag); string tableGuid = Convert.ToString(tvApps.SelectedNode.Tag); LogTable table = AppService.Instance.GetAppTable(appGuid, tableGuid); SetRowContent(table, firstRowIndex, false); SetRowContent(table, secondRowIndex, true); UpdatePreView(); }
private void WriteLog(string msg) { LogTable.BeginInvoke(new Action(() => { LogData.Add(new LogMessage { Time = DateTime.Now.ToString("dd MMM HH:mm"), Message = msg }); LogTable.Refresh(); LogTable.FirstDisplayedScrollingRowIndex = LogTable.RowCount - 1; })); }
//导出日志 20110810 xisheng private void 导出日志ToolStripMenuItem_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; string err = LogTable.ExportLog(); if (err != "") { MessageBox.Show(err, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.Cursor = Cursors.Default; }
/// <summary> /// Adds to the log table /// </summary> /// <param name="source">The source.</param> /// <param name="severity">The severity.</param> /// <param name="text">The description.</param> private void Add(string source, int severity, string text) { DataRow row = LogTable.NewRow(); SetRowValue(row, MandatoryLogField.Source, source, source); SetRowValue(row, MandatoryLogField.Severity, severity, source); SetRowValue(row, MandatoryLogField.Description, text, source); var windowsIdentity = WindowsIdentity.GetCurrent(); SetRowValue(row, MandatoryLogField.User, windowsIdentity.Name, source); SetRowValue(row, MandatoryLogField.LogDateTime, DateTime.UtcNow, source); LogTable.Rows.Add(row); }
private void btnDelete_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count == 0) { return; } if (MessageBox.Show("您确定要删除列表上所选择的日志吗?(删除后不可恢复)", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) != DialogResult.OK) { return; } LogTable.DeleteSelectedLog(listView); btnSearch_Click(sender, e); }
//刷新用户组下拉框 ygc 2012-9-3 private void RefreshComBoxGroupUsers() { List <string> DistinctGroupUsers = LogTable.GetGroupUser(); ComBoxGroupUsers.Items.Clear(); foreach (string groupUser in DistinctGroupUsers) { ComBoxGroupUsers.Items.Add(groupUser); } if (ComBoxGroupUsers.Items.Count > 0) { ComBoxGroupUsers.SelectedIndex = 0; } }
//刷新单用户下拉框 ygc 2012-9-3 private void RefreshComBoxSingleUser() { List <string> distinctUser = LogTable.SeachLog2("logUser"); cBoxUser.Items.Clear(); foreach (string user in distinctUser) { cBoxUser.Items.Add(user); } if (cBoxUser.Items.Count > 0) { cBoxUser.SelectedIndex = 0; } }
public TimestampVisibilityConfigurationSynchronizer(IConfigurationService configurationService, ILogTableService logTableService, ILogTableConfigurationService logTableConfigurationService) { Argument.IsNotNull(() => configurationService); Argument.IsNotNull(() => logTableService); Argument.IsNotNull(() => logTableConfigurationService); _logTableConfigurationService = logTableConfigurationService; _logTable = logTableService.LogTable; configurationService.ConfigurationChanged += OnConfigurationChanged; ApplyConfiguration(); }
public static SystemLogDTO Entity2SystemLogDto(this LogTable entity) { return(new SystemLogDTO { id = entity.id , AddOn = entity.CreateDate , Origin = entity.Origin , Exception = entity.Exception , StackTrace = entity.StackTrace , IntId = entity.RecordIntId , Module = entity.RecordObjectType , Level = entity.LogLevel , Message = entity.Message }); }
public bool AddTable(string appGuid, LogTable table) { if (!m_existingApps.ContainsKey(appGuid)) { throw new Exception("要添加的日志结构所属的应用程序不存在"); } if (DBService.Instance.AddTable(appGuid, table)) { m_existingApps[appGuid].AddTable((LogTable)table.Clone()); return(true); } return(false); }
private void btnClear_Click(object sender, EventArgs e) { //log = new LogFile(null, m_strLogFilePath); //log.ClearLog(this.listView); if (listView.Items.Count == 0) { return; } if (MessageBox.Show("您确定要清空所有日志吗?(清空后不可恢复)", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) != DialogResult.OK) { return; } LogTable.ClearLog(listView); btnSearch_Click(sender, e); }
public static LogTable FromLogTablePlus(LogTablePuls t) { LogTable p = new LogTable(t.GUID); p.Name = t.Name; if (t.Columns != null && t.Columns.Count > 0) { foreach (LogTableItemPlus lt in t.Columns) { p.Columns.Add(FromLogTableItemPlus(lt)); } } return(p); }
public List <CoetLogInfoEntity> GetLog(string startDateTime, string endDateTime, string logType) { try { string execSql = string.Empty; string typeWhereTemplate = string.Empty; string sqlTemplate = @"select Type, JsonInfo, SendIP, SendName, Createdt from {0} where Createdt between @startDateTime and @endDateTime"; if (logType == "ALL") { typeWhereTemplate = "and 1 = 1"; } else { typeWhereTemplate = string.Format("and Type = '{0}'", logType); } sqlTemplate = string.Format("{0} {1}", sqlTemplate, typeWhereTemplate); DateTime sDate = Convert.ToDateTime(startDateTime); DateTime eDate = Convert.ToDateTime(endDateTime); if (sDate.Year != eDate.Year || sDate.Month != eDate.Month) { string stableName = LogTable.GetLogTName(sDate); string etableName = LogTable.GetLogTName(eDate); execSql = string.Format("{0} union {1}", string.Format(sqlTemplate, stableName), string.Format(sqlTemplate, etableName)); } else { string tableName = LogTable.GetLogTName(sDate); execSql = string.Format(sqlTemplate, tableName); } return(DBOperate.ExecuteDataList <CoetLogInfoEntity>(execSql, new { startDateTime = startDateTime, endDateTime = endDateTime })); } catch (Exception ex) { CoetLocalLog.Error(ex.ToString()); return(new List <CoetLogInfoEntity>()); } }
/// <summary> /// Initializes the static properties that allow the class user to access the primary key data tables defined within the data dictionary. /// </summary> /// <param name="dataDictionary">The data dictionary containing the data tables.</param> public static void Initialize(DataDictionary dataDictionary) { m_DataDictionary = dataDictionary; m_WatchVariableTable = new WatchVariableTable(dataDictionary.WATCHVARIABLES, dataDictionary.WATCHENUMBIT); m_WatchVariableTableByOldIdentifier = new WatchVariableTableByOldIdentifier(dataDictionary.WATCHVARIABLES, dataDictionary.WATCHENUMBIT); m_EventVariableTable = new EventVariableTable(dataDictionary.EVENTVARIABLES, dataDictionary.EVENTENUMBIT); m_SelfTestVariableTable = new SelfTestVariableTable(dataDictionary.SELFTESTVARIABLES, dataDictionary.SELFTESTENUMBIT); m_EventTable = new EventTable(dataDictionary.EVENTS, dataDictionary.STRUCT); m_LogTable = new LogTable(dataDictionary.LOGS, dataDictionary.DataStreamTypes); m_SelfTestTable = new SelfTestTable(dataDictionary.SELFTEST, dataDictionary.SELFTESTIDS, dataDictionary.TESTMESSAGES); m_SelfTestTableBySelfTestNumber = new SelfTestTableBySelfTestNumber(dataDictionary.SELFTEST, dataDictionary.SELFTESTIDS, dataDictionary.TESTMESSAGES); m_GroupListTable = new GroupListTable(dataDictionary.GROUPLIST, dataDictionary.GROUPLISTIDS); m_TestListTable = new TestListTable(dataDictionary.TESTLIST, dataDictionary.TESTLISTIDS); }
public void Reload() { using (var connector = Connect()) { var connection = connector.Connection; var server = GetServer(connection); var database = GetDatabase(server); if (!database.Schemas.Contains(_tableConfiguration.Schema)) { var schema = new Schema(database, _tableConfiguration.Schema); database.Schemas.Add(schema); schema.Create(); } _partTable = new PartTable(connection, database, _tableConfiguration); _localeTable = new LocaleTable(connection, database, _tableConfiguration); _valueTable = new ValueTable(connection, database, _tableConfiguration); _logTable = new LogTable(database, _tableConfiguration); } }
/// <summary> /// Writes the event. /// </summary> /// <param name="storage">The storage.</param> /// <param name="message">The message.</param> /// <param name="type">The type.</param> private void WriteEvent(IAzManStorage storage, string message, EventLogEntryType type) { try { SqlAzManStorage typedStorage = storage as SqlAzManStorage; bool logOnDb = false; bool logOnEventLog = true; string connectionString = String.Empty; Guid instanceGuid = Guid.Empty; Guid transactionGuid = Guid.Empty; int operationCounter = 0; DateTime now = DateTime.Now; if (typedStorage != null) { logOnDb = typedStorage.LogOnDb; logOnEventLog = typedStorage.LogOnEventLog; connectionString = typedStorage.db.Connection.ConnectionString; instanceGuid = typedStorage.instanceGuid; transactionGuid = typedStorage.transactionGuid; operationCounter = ++typedStorage.operationCounter; } string originalMessage = message; if (logOnDb) { string ENSType = "User Log"; if (message.StartsWith("ENS Event: ", StringComparison.CurrentCultureIgnoreCase)) { ENSType = message.Substring(message.IndexOf("ENS Event: ") + 11); ENSType = ENSType.Substring(0, ENSType.IndexOf("\r\n")); message = message.Substring(message.IndexOf("\r\n") + 2); message = message.TrimStart('\r').TrimStart('\n'); } while (message.IndexOf("\r\n\r\n") != -1) { message = message.Replace("\r\n\r\n", "\r\n"); } message = message.Replace("\r\n", ";"); string logType; switch (type) { case EventLogEntryType.Error: logType = "E"; break; case EventLogEntryType.Warning: logType = "W"; break; default: logType = "I"; break; } NTAccount nta = new NTAccount(((System.Threading.Thread.CurrentPrincipal.Identity as WindowsIdentity) ?? WindowsIdentity.GetCurrent()).Name); SecurityIdentifier sid = (SecurityIdentifier)nta.Translate(typeof(SecurityIdentifier)); string winIdentity = String.Format("{0} ({1}", nta.Value, sid.Value); NetSqlAzManStorageDataContext db = new NetSqlAzManStorageDataContext(connectionString); NetSqlAzMan.LINQ.LogTable log = new LogTable(); log.LogDateTime = now; log.WindowsIdentity = winIdentity; log.MachineName = Environment.MachineName; log.InstanceGuid = instanceGuid; log.TransactionGuid = transactionGuid == Guid.Empty ? null : new Guid?(); log.OperationCounter = operationCounter; log.ENSType = ENSType; log.ENSDescription = message; log.LogType = logType; db.LogTables.InsertOnSubmit(log); db.SubmitChanges(); } if (logOnEventLog) { if (!EventLog.SourceExists(LoggingUtility.EVENTSOURCE)) { EventLog.CreateEventSource(LoggingUtility.EVENTSOURCE, "Application"); } originalMessage += String.Format("\r\nInstance Guid: {0}\r\nTransaction Guid: {1}\r\nOperation Counter: {2}", instanceGuid.ToString(), transactionGuid.ToString(), operationCounter); EventLog.WriteEntry(LoggingUtility.EVENTSOURCE, originalMessage, type); } } catch { //Ignore if error occur during logging } }
public LogTableService() { LogTable = new LogTable(); }