public static void WriteToDb(Record record) { try { var logsRs = new IMRecordset(MD.SysLogs.TableName, IMRecordset.Mode.ReadWrite); using (var logsRsScope = logsRs.OpenForAdd( MD.SysLogs.Fields.Id, MD.SysLogs.Fields.Event, MD.SysLogs.Fields.TableName, MD.SysLogs.Fields.Count, MD.SysLogs.Fields.Info, MD.SysLogs.Fields.Who, MD.SysLogs.Fields.When )) { var currentTime = DateTime.Now; var currentUser = IM.ConnectedUser(); logsRs.AddNew(MD.SysLogs.TableName, MD.SysLogs.Fields.Id); logsRs.Put(MD.SysLogs.Fields.Event, record.Type.ToString()); logsRs.Put(MD.SysLogs.Fields.TableName, MD.SysLogs.TableName); logsRs.Put(MD.SysLogs.Fields.Count, 1); logsRs.Put(MD.SysLogs.Fields.Info, $"{record.Process}: {record.Message}"); logsRs.Put(MD.SysLogs.Fields.Who, currentUser); logsRs.Put(MD.SysLogs.Fields.When, currentTime); logsRs.Update(); if (record.Duration > 0) { logsRs.AddNew(MD.SysLogs.TableName, MD.SysLogs.Fields.Id); logsRs.Put(MD.SysLogs.Fields.Event, record.Type.ToString()); logsRs.Put(MD.SysLogs.Fields.TableName, MD.SysLogs.TableName); logsRs.Put(MD.SysLogs.Fields.Count, 1); logsRs.Put(MD.SysLogs.Fields.Info, $"{record.Process}: Duration {record.Duration}ms"); logsRs.Put(MD.SysLogs.Fields.Who, currentUser); logsRs.Put(MD.SysLogs.Fields.When, currentTime); logsRs.Update(); } if (!string.IsNullOrEmpty(record.Data)) { logsRs.AddNew(MD.SysLogs.TableName, MD.SysLogs.Fields.Id); logsRs.Put(MD.SysLogs.Fields.Event, record.Type.ToString()); logsRs.Put(MD.SysLogs.Fields.TableName, MD.SysLogs.TableName); logsRs.Put(MD.SysLogs.Fields.Count, 1); logsRs.Put(MD.SysLogs.Fields.Info, $"{record.Process}: {record.Data}"); logsRs.Put(MD.SysLogs.Fields.Who, currentUser); logsRs.Put(MD.SysLogs.Fields.When, currentTime); logsRs.Update(); } } } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString(), "Logger.WriteToDb", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }
private static SDR.MeasTask PreparedMeasTaskInfo(DM.Allotment allotment, DM.FreqPlanChan[] freqPlanChans) { var measTask = new SDR.MeasTask() { Name = allotment.CustText1, ExecutionMode = SDR.MeasTaskExecutionMode.Automatic, Task = SDR.MeasTaskType.Scan, DateCreated = DateTime.Now, CreatedBy = IM.ConnectedUser(), Stations = PreparedStations(allotment), MeasDtParam = PreparedDetectedParam(allotment), MeasFreqParam = PreparedFreqParam(allotment, freqPlanChans), MeasOther = PreparedOther(allotment), MeasTimeParamList = PreparedTimeParamList(allotment) }; return(measTask); }
private static SDR.MeasTask PreparedMeasTaskInfo(DM.Tour tour, DM.Inspection[] inspections) { var measTask = new SDR.MeasTask() { Name = tour.MeasTaskName, ExecutionMode = SDR.MeasTaskExecutionMode.Manual, DateCreated = DateTime.Now, CreatedBy = IM.ConnectedUser(), MeasDtParam = PreparedDetectedParam(tour), MeasTimeParamList = new SDR.MeasTimeParamList() { PerStart = tour.StartDate, PerStop = tour.StopDate }, Stations = PreparedStations(tour), // new SDR.MeasStation[] { } , StationsForMeasurements = PreparedStationDataForMeasurements(tour, inspections), }; return(measTask); }
public static int GetCurrentUserId() { var result = IM.NullI; string userName = IM.ConnectedUser(); var employeeRs = new IMRecordset(Employee.TableName, IMRecordset.Mode.ReadOnly); employeeRs.Select(Employee.Fields.Id); employeeRs.SetWhere(Employee.Fields.AppUser, IMRecordset.Operation.Eq, userName); using (employeeRs.OpenWithScope()) { if (!employeeRs.IsEOF()) { result = employeeRs.GetI(Employee.Fields.Id); } } return(result); }