/// <summary> /// 添加记录操作 /// </summary> protected void AddRecord() { HttpContext context = HttpContext.Current; HttpRequest request = context.Request; HttpResponse response = context.Response; OperationLog operationLog = new OperationLog(); string addTime = request.Params["textAddTime"]; string conLogId = request.Params["textConLogId"]; string isSuccessId = request.Params["textIsSuccessId"]; string objectRecordId = request.Params["textObjectRecordId"]; string operationContent = request.Params["textOperationContent"]; string operationTable = request.Params["textOperationTable"]; string operationType = request.Params["textOperationType"]; string resultCode = request.Params["textResultCode"]; string resultMessage = request.Params["textResultMessage"]; string systemUserId = request.Params["textSystemUserId"]; string totalCount = request.Params["textTotalCount"]; operationLog.AddTime = DateTime.Now; if (!String.IsNullOrEmpty(conLogId)) operationLog.ConLogId = conLogId; if (!String.IsNullOrEmpty(isSuccessId)) operationLog.IsSuccessId = isSuccessId; operationLog.LogId = Guid.NewGuid().ToString("N"); if (!String.IsNullOrEmpty(objectRecordId)) operationLog.ObjectRecordId = objectRecordId; if (!String.IsNullOrEmpty(operationContent)) operationLog.OperationContent = operationContent; if (!String.IsNullOrEmpty(operationTable)) operationLog.OperationTable = operationTable; if (!String.IsNullOrEmpty(operationType)) operationLog.OperationTypeCode = operationType; if (!String.IsNullOrEmpty(resultCode)) operationLog.ResultCode = Convert.ToInt32(resultCode); if (!String.IsNullOrEmpty(resultMessage)) operationLog.ResultMessage = resultMessage; if (!String.IsNullOrEmpty(systemUserId)) operationLog.SystemUserId = systemUserId; if (!String.IsNullOrEmpty(totalCount)) operationLog.TotalCount = Convert.ToInt32(totalCount); ResultModel result = OperationLogBll.Insert(operationLog); string jsonString = JsonConvert.SerializeObject(result); response.Write(result); }
/// <summary> /// 根据记录主键,删除指定记录。 /// </summary> /// <param name="dictionaryId">记录主键</param> /// <returns>删除结果,包括是否删除成功、记录主键等信息</returns> public static ResultModel Delete(string dictionaryId) { OperationLog log = new OperationLog(); ResultModel result = new ResultModel(); try { log.LogId = System.Guid.NewGuid().ToString("N"); log.SystemUserId = CurrentSession.getUser().UserId; log.OperationTypeCode = SymbolicConstant.OPERATIONTYPE_DELETE; log.OperationContent = SymbolicConstant.OPERATIONCONTENT_DELETE; log.AddTime = DateTime.Now; log.ObjectRecordId = dictionaryId; log.OperationTable = typeof(Dictionary).Name; log.IsSuccessId = SymbolicConstant.ISSUCCESS_TRUE; log.ResultCode = SymbolicConstant.RESULTCODE_DELETE_SUCCESS; log.ResultMessage=SymbolicConstant.RESULTMESSAGE_DELETE_SUCCESS; Dictionary dictionary =(Dictionary)GetDictionaryById(dictionaryId).Data; DictionaryDal.Delete(dictionary); result.IsSuccess = true; result.ObjectRecordId = dictionaryId; result.ResultCode = SymbolicConstant.RESULTCODE_DELETE_SUCCESS; result.ResultMessage = SymbolicConstant.RESULTMESSAGE_DELETE_SUCCESS; return result; } catch (Exception exception) { log.IsSuccessId = SymbolicConstant.ISSUCCESS_FALSE; log.ResultCode = SymbolicConstant.RESULTCODE_DELETE_ERROR; log.ResultMessage=exception.Message; result.IsSuccess = false; result.ObjectRecordId = dictionaryId; result.ResultCode = SymbolicConstant.RESULTCODE_DELETE_ERROR; result.ResultMessage = exception.Message; return result; } finally { OperationLogBll.Insert(log); } }
public virtual OperationLog ToModel(OperationLog operation) { if (operation == null) { throw new ArgumentNullException(nameof(operation)); } operation.CreatedBy = CreatedBy; operation.CreatedDate = CreatedDate; operation.Detail = Detail; operation.Id = Id; operation.ModifiedBy = ModifiedBy; operation.ModifiedDate = ModifiedDate; operation.ObjectId = ObjectId; operation.ObjectType = ObjectType; operation.OperationType = EnumUtility.SafeParse(OperationType, EntryState.Unchanged); return(operation); }
public static List <OperationLog> SelectOperationlogAll() { List <OperationLog> custos = new List <OperationLog>(); string sql = "select * from operationlog"; SqlDataReader dr = DBHelper.ExecuteReader(sql); while (dr.Read()) { OperationLog cso = new OperationLog(); cso.OperationTime = DateTime.Parse(dr["OperationTime"].ToString()); cso.Operationlog = dr["Operationlog"].ToString(); cso.OperationAccount = (string)dr["OperationAccount"]; custos.Add(cso); } dr.Close(); DBHelper.Closecon(); return(custos); }
public override async void OnResultExecuted(ResultExecutedContext context) { LoginUser loginUser = context.HttpContext.GetLoginUser(); OperationLog operationLog = new OperationLog { IP = context.HttpContext.Connection.RemoteIpAddress.ToString(), RouteInfo = context.GetControllerAndAction(), Account = loginUser == null ? string.Empty : loginUser.Account, RequestInfo = await context.HttpContext.GetRequestBody(), }; if (context.Result is OkObjectResult okObjectResult) { object okValue = okObjectResult.Value; operationLog.ResponseInfo = okValue.ToJson(); } await _capBus.PublishAsync("OperationLog", operationLog); }
// データ更新 // in : M_Loginデータ // out : エラーメッセージ public string PutLogin(M_Employee regEmployee) { using (var db = new SalesManagement_DevContext()) { M_Employee employee; try { employee = db.M_Employees.Single(x => x.EmID == regEmployee.EmID); } catch { // throw new Exception(Messages.errorNotFoundItem, ex); // throw new Exception(_cm.GetMessage(110), ex); return(_msc.GetMessage(110)); } employee.EmID = regEmployee.EmID; employee.EmPassword = regEmployee.EmPassword; db.Entry(employee).State = EntityState.Modified; try { db.SaveChanges(); } catch { // throw new Exception(Messages.errorConflict, ex); // throw new Exception(_cm.GetMessage(100), ex); return(_msc.GetMessage(100)); } // ログ出力 var operationLog = new OperationLog() { EventRaisingTime = DateTime.Now, Operator = _logonUser, Table = "Login", Command = "Put", //Data = ProductLogData(regProduct), }; //StaticCommon.PostOperationLog(operationLog); return(string.Empty); } }
// 詳細データ更新 // in : T_OrderDetailデータ // out : エラーメッセージ public string PutOrderDetail(T_OrderDetail regOrderDetail) { using (var db = new SalesManagement_DevContext()) { T_OrderDetail orderdetail; try { orderdetail = db.T_OrderDetails.Single(x => x.OrDetailID == regOrderDetail.OrDetailID); } catch { return(_msc.GetMessage(110)); } orderdetail.OrDetailID = regOrderDetail.OrDetailID; orderdetail.OrID = regOrderDetail.OrID; orderdetail.PrID = regOrderDetail.PrID; orderdetail.OrQuantity = regOrderDetail.OrQuantity; orderdetail.OrTotalPrice = regOrderDetail.OrTotalPrice; db.Entry(orderdetail).State = EntityState.Modified; try { db.SaveChanges(); } catch { // throw new Exception(Messages.errorConflict, ex); // throw new Exception(_cm.GetMessage(100), ex); return(_msc.GetMessage(100)); } // ログ出力 var operationLog = new OperationLog() { EventRaisingTime = DateTime.Now, Operator = _logonUser, Table = "OrderDetail", Command = "Put", //Data = ProductLogData(regProduct), }; //StaticCommon.PostOperationLog(operationLog); return(string.Empty); } }
//删除机构 public void Delete_Click(object sender, EventArgs e) { int AgencyID = agen.SelectAgencyID(AgencyName2.Text.Trim()); int level = Convert.ToInt32(Session["SecrecyLevel"]); if (level == 5) { agen.Delete(AgencyID); BindData(); Clear(); BindPeople(); Delete.Enabled = false; Alert.ShowInTop("删除数据成功!"); return; } Common.Entities.Agency ag = new Common.Entities.Agency(); ag = agen.FindByName(AgencyName2.Text.Trim()); OperationLog op = new OperationLog(); BLHelper.BLLOperationLog blop = new BLLOperationLog(); if (ag.EntryPerson != Session["LoginName"].ToString()) { string str = "您无对此机构操作的权限!此机构信息为" + ag.EntryPerson + "录入,请与管理员联系!"; Alert.ShowInTop(str); return; } else { agen.UpdatePass(AgencyID, false); op.LoginIP = ""; op.LoginName = Session["LoginName"].ToString(); op.OperationContent = "Agency"; op.OperationDataID = AgencyID; op.OperationType = "删除"; op.OperationTime = DateTime.Now; blop.Insert(op); BindData(); Alert.ShowInTop("数据已提交,请等待管理员确认!"); } Clear(); }
public override object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request) { OperationLog log = null; if (LilacRequestContext.Current <LilacRequestContext>().CurrentUser != null) { log = new OperationLog() { UserID = LilacRequestContext.Current <LilacRequestContext>().CurrentUser.UserID, UserName = LilacRequestContext.Current <LilacRequestContext>().CurrentUser.UserName, OperationTime = DateTime.Now, Url = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri.AbsolutePath, RequestIP = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BaseUri.DnsSafeHost, UserAgent = WebOperationContext.Current.IncomingRequest.UserAgent, Endpoint = LilacRequestContext.Current <LilacRequestContext>().IsClient ? "Client" : "Mobile" }; } return(log); }
public async Task <IEnumerable <string> > UpdateProject(int currentUserId, int projectId) { var project = await ProjectRepository.GetProjectAsync(projectId); project.RequestMasterAccess(currentUserId, acl => acl.IsOwner); if (project.Details?.AllrpgId == null) { return(new[] { "Проект не ассоциирован с allrpg" }); } var reply = await _api.DownloadProject((int)project.Details.AllrpgId); switch (reply.Status) { case AllrpgApi.Status.Success: { var log = new OperationLog(); try { var importer = new AllrpgProjectImporter(project, UnitOfWork, log); await importer.Apply(reply.Result); } catch (Exception e) { log.Error($"EXCEPTION: {e}"); } return(log.Results); } case AllrpgApi.Status.NetworkError: return(new[] { "Сетевая ошибка" }); case AllrpgApi.Status.ParseError: return(new[] { "Не разобран ответ allrpg" }); case AllrpgApi.Status.WrongKey: return(new[] { "Ошибочный ключ" }); default: throw new ArgumentOutOfRangeException(nameof(reply.Status)); } }
private OperationLog CreateOpsLog(string className, string methodName, string logName, object[] arguments, UserContext userContext) { var log = new OperationLog { ClassName = className, CreateTime = DateTime.Now, LogName = logName, LogType = "操作日志", Message = JsonSerializer.Serialize(arguments, SystemTextJson.GetAdncDefaultOptions()), Method = methodName, Succeed = "false", UserId = userContext.Id, UserName = userContext.Name, Account = userContext.Account, RemoteIpAddress = userContext.RemoteIpAddress }; return(log); }
private void btnAdd_Click(object sender, EventArgs e) { if (RtbGBInfo.Text != null) { DialogResult dr = MessageBox.Show("确定录入?一旦录入后将无法修改及删除,或会影响员工的晋升!", "录入警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { WorkerGoodBad goodBad = new WorkerGoodBad(); goodBad.WorkNo = lblWorkerNo.Text; goodBad.GBType = CboType.SelectedIndex; goodBad.GBInfo = RtbGBInfo.Text; goodBad.GBOperation = AdminInfo.Account; goodBad.GBTime = DtpDate.Value; bool n = new WorkerGoodBadService().AddGoodBad(goodBad); if (n == true) { MessageBox.Show("新增成功!"); #region 获取添加操作日志所需的信息 OperationLog o = new OperationLog(); o.OperationTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd,HH:mm:ss")); o.Operationlog = AdminInfo.Account + AdminInfo.Name + "于" + DateTime.Now + "对员工:" + lblName.Text + "进行了奖罚情况录入!"; o.OperationAccount = LoginInfo.WorkerNo; o.datains_usr = LoginInfo.WorkerNo; o.datains_date = DateTime.Now; new OperationlogService().InsertOperationLog(o); #endregion DgvGoodBadList.DataSource = new WorkerGoodBadService().SelectAllGoodBadByWorkNo(lblWorkerNo.Text); } else { MessageBox.Show("或是服务器错误所致!"); } } else { MessageBox.Show("取消录入操作!"); } } else { MessageBox.Show("信息不能为空!"); } }
private static AppLog InitLogs(bool isSystem, OperationLog operationType, SystemLog systemType, string modifiedUserID) { var log = new AppLog(); log.IsSystem = isSystem; if (isSystem) { log.SystemType = systemType; } else { log.OperationType = operationType; } var currentDate = DateTime.Now; log.ModifiedDate = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, currentDate.Hour, currentDate.Minute, 0); log.ModifiedUserID = modifiedUserID; return(log); }
//更新 public void Update(OperationLog operationLog) { try { OperationLog AoperationLog = dbcontext.OperationLogContext.Find(operationLog.OperationLogID); AoperationLog.LoginName = operationLog.LoginName; AoperationLog.LoginIP = operationLog.LoginIP; AoperationLog.OperationType = operationLog.OperationType; AoperationLog.OperationContent = operationLog.OperationContent; AoperationLog.OperationDataID = operationLog.OperationDataID; AoperationLog.OperationTime = operationLog.OperationTime; AoperationLog.Remark = operationLog.Remark; dbcontext.SaveChanges(); } catch (System.Data.SqlClient.SqlException e) { throw e; } }
/// <summary> /// user change logs /// </summary> /// <param name="type"></param> /// <param name="db"></param> /// <param name="user"></param> /// <param name="modifiedUser"></param> public static void InsertUserLogs(OperationLog type, EFContext db, string userID, string modifiedUserID, int organizationID) { try { var log = InitLogs(false, type, 0, modifiedUserID); log.PersonID = userID; var user = db.Users.FirstOrDefault(x => x.Id == modifiedUserID); log.OrganizationID = organizationID; bool canSave = false; switch (type) { case OperationLog.UserInvitation: //todo rola i mail - after send save user in person if no chnage logic //log.PersonID = break; case OperationLog.UserDeleteBySelf: case OperationLog.UserDelete: case OperationLog.UserCreate: case OperationLog.UserEdit: canSave = true; break; } if (!canSave) { return; } db.Logs.Add(log); db.SaveChanges(); } catch (Exception ex) { } }
private void btnAdd_Click(object sender, EventArgs e) { if (rs == 1)//判断房间编号是否可消费 { if (CheckInput()) { SellThing st = SellThingManager.SelectSellThingByNo(txtSellNo.Text); Room r = RoomManager.SelectRoomByRoomNo(txtRoomNo.Text); Spend s = new Spend() { RoomNo = txtRoomNo.Text, SpendName = txtSellName.Text, SpendAmount = (int)nudNum.Value, CustoNo = r.CustoNo, SpendPrice = Convert.ToDecimal(txtPrice.Text), SpendMoney = Convert.ToDecimal(Convert.ToDouble(txtPrice.Text) * nudNum.Value), SpendTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), MoneyState = "未结算", }; int m = SpendManager.InsertSpendInfo(s); if (m > 0) { string Stock = (st.Stock - nudNum.Value).ToString(); int n = SellThingManager.UpdateSellThing(Stock, st.SellNo); MessageBox.Show("添加成功"); LoadSpendInfo(r.RoomNo); LoadSellThingInfo(); #region 获取添加操作日志所需的信息 OperationLog o = new OperationLog(); o.OperationTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd,HH:mm:ss")); o.Operationlog = LoginInfo.WorkerClub + LoginInfo.WorkerPosition + LoginInfo.WorkerName + "于" + DateTime.Now + "帮助" + s.CustoNo + "进行了消费商品:" + txtSellName.Text + "操作!"; o.OperationAccount = LoginInfo.WorkerClub + LoginInfo.WorkerPosition + LoginInfo.WorkerName; #endregion OperationManager.InsertOperationLog(o); } else { MessageBox.Show("添加失败"); } } } }
//删除选择行的点击事件 protected void btnDelete_Click(object sender, EventArgs e) { BLHelper.BLLOperationLog op = new BLHelper.BLLOperationLog(); OperationLog operate = new OperationLog(); BLHelper.BLLUser user = new BLHelper.BLLUser(); try { string username = user.FindByLoginName(Session["LoginName"].ToString()).UserName; if (Convert.ToInt32(Session["SecrecyLevel"]) == 5) { for (int i = 0; i < pm.GridCount(Grid_Equipment, CBoxSelect).Count(); i++) { bllequipment.Delete(Convert.ToInt32(Grid_Equipment.DataKeys[pm.GridCount(Grid_Equipment, CBoxSelect)[i]][0].ToString())); } InitData(); btnSelect_All.Text = "全选"; Alert.ShowInTop("删除数据成功!"); } else { for (int i = 0; i < pm.GridCount(Grid_Equipment, CBoxSelect).Count(); i++) { bllequipment.UpdateIsPass(Convert.ToInt32(Grid_Equipment.DataKeys[pm.GridCount(Grid_Equipment, CBoxSelect)[i]][0]), false); operate.LoginName = username; operate.OperationTime = DateTime.Now; operate.LoginIP = " "; operate.OperationContent = "Equipments"; operate.OperationType = "删除"; operate.OperationDataID = Convert.ToInt32(Grid_Equipment.DataKeys[pm.GridCount(Grid_Equipment, CBoxSelect)[i]][0]); op.Insert(operate); } InitData(); btnSelect_All.Text = "全选"; Alert.ShowInTop("您的数据已提交,请等待确认!"); } } catch (Exception ex) { pm.SaveError(ex, this.Request); } }
private OperationLog BuildData(DataRow dr) { OperationLog data = new OperationLog(); data.ID = (int)dr["serial"]; if (!string.IsNullOrEmpty(dr["dt"].ToString())) { data.Time = (DateTime)dr["dt"]; } if (!string.IsNullOrEmpty(dr["operator_id"].ToString())) { data.OperatorID = (int)dr["operator_id"]; } if (!string.IsNullOrEmpty(dr["content"].ToString())) { data.Content = (string)dr["content"]; } return(data); }
public override void BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState) { OperationLog log = correlationState as OperationLog; if (log != null) { ISession session = DBOperator.Instance.GetCurrentSession(); try { session.Clear();//先清除已被Session管理的其他在服务方法中操作完成的实体,防止这里的Flush对之前的实体数据及状态造成影响 session.Save(log); session.Flush(); } catch (Exception ex) { //操作日志出错不能影响功能 Logger.Log("操作日志insert出错。", ex); } } }
private void SaveSendResult(string msisdn, string text, sendMessageOneToManyResponse sendResult) { var entity = new OperationLog { BrokerResponse = JsonSerializer.Serialize(sendResult?.@return, _jsonSerializerOptions), Msisdn = msisdn, SentDate = DateTime.Now, Text = text }; try { _dbContext.OperationLogs.Add(entity); _dbContext.SaveChanges(); } catch (Exception ex) { _logger.LogError(ex, "Error saving send result: {entity}", JsonSerializer.Serialize(entity, _jsonSerializerOptions)); } }
//删除 protected void btnDelete_Click(object sender, EventArgs e) { try { List <int> selections = pm.GridCount(Grid_AchievementCA, CBoxSelect); if (Convert.ToInt32(Session["SecrecyLevel"]) == 5) { for (int i = 0; i < selections.Count(); i++) { ca.Delete(Convert.ToInt32(Grid_AchievementCA.DataKeys[selections[i]][0])); } InitData(); btnSelect_All.Text = "全选"; Alert.ShowInTop("删除数据成功!"); } else { for (int i = 0; i < selections.Count(); i++) { ca.UpdateIsPass(Convert.ToInt32(Grid_AchievementCA.DataKeys[selections[i]][0]), false); //向操作日志表中插入 OperationLog operate = new OperationLog(); operate.LoginName = user.FindByLoginName(Session["LoginName"].ToString()).UserName; operate.LoginIP = ""; operate.OperationType = "删除"; operate.OperationContent = "ProjectImportantNode"; operate.OperationDataID = Convert.ToInt32(Grid_AchievementCA.DataKeys[selections[i]][0]); operate.OperationTime = System.DateTime.Now; operate.Remark = ""; bllOperate.Insert(operate); } btnSelect_All.Text = "全选"; Alert.ShowInTop("您的操作已提交,请等待审核!"); InitData(); } } catch (Exception ex) { pm.SaveError(ex, this.Request); } }
private SetConfig config = new SetConfig(); //配置文件实例 //管理员,工程师,操作员,观察员 public MainWindow() { InitializeComponent(); dbIP = config.read_string("dbsetting", "dbip"); dbUser = config.read_string("dbsetting", "dbuser"); dbPassword = config.read_string("dbsetting", "dbpassword"); dbName = config.read_string("dbsetting", "dbname"); WinProgressBar dialog = new WinProgressBar() { MaxRespTime = 2, BgWork = dataConnect, BarTitle = "正在加载系统" }; //主界面进度条 dialog.ShowDialog(); deviceIP = getDeviceIP(); try { //MessageBoxX("Info", GetProcess.ProcessManager.IsRunning("MaritimeSecurityMonitoring") == true) if (ProcessManager.IsRunning("MaritimeSecurityMonitoring") == true) { MessageBoxX.Show("启动警告", "检测到软件已运行,请关闭后重启"); System.Windows.Application.Current.Shutdown(); Environment.Exit(0);//强制退出 GC.Collect(); } } catch (Exception ee) { } try { loginData = new LoginManager(); OperationLogData = new OperationLogWriter(); opeation = new OperationLog(); } catch (Exception ee) { } }
//删除 protected void btnDelete_Click(object sender, EventArgs e) { try { List <int> selections = publicmethod.GridCount(GridProjectAndPeople, CBoxSelect); if (Convert.ToInt32(Session["SecrecyLevel"]) == 5) { for (int i = 0; i < selections.Count(); i++) { bllStaffDevote.Delete(Convert.ToInt32(GridProjectAndPeople.DataKeys[selections[i]][0])); } BindData(); Alert.ShowInTop("删除数据成功!"); btnSelect_All.Text = "全选"; } else { for (int i = 0; i < selections.Count(); i++) { bllStaffDevote.ChangePass(Convert.ToInt32(GridProjectAndPeople.DataKeys[selections[i]][0]), false); //向操作日志表中插入 OperationLog operate = new OperationLog(); operate.LoginName = bllUser.FindByLoginName(Session["LoginName"].ToString()).UserName; operate.LoginIP = ""; operate.OperationType = "删除"; operate.OperationContent = "StaffDevote"; operate.OperationDataID = Convert.ToInt32(GridProjectAndPeople.DataKeys[selections[i]][0]); operate.OperationTime = System.DateTime.Now; operate.Remark = ""; bllOperate.Insert(operate); } Alert.ShowInTop("删除项目重大节点信息已提交待审核!"); BindData(); btnSelect_All.Text = "全选"; } } catch (Exception ex) { publicmethod.SaveError(ex, this.Request); } }
private void pictureBox3_Click(object sender, EventArgs e) { i++; if (i < 3) { } else if (i % 3 == 0) { FrmAdminEnter frm = new FrmAdminEnter(); frm.Show(); #region 获取添加操作日志所需的信息 OperationLog o = new OperationLog(); o.OperationTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd,HH:mm:ss")); o.Operationlog = LoginInfo.WorkerNo + LoginInfo.WorkerName + "于" + DateTime.Now + "尝试或成功登入了后台系统!"; o.OperationAccount = LoginInfo.WorkerNo; o.datains_usr = LoginInfo.WorkerNo; o.datains_date = DateTime.Now; #endregion new OperationlogService().InsertOperationLog(o); } }
/// <summary> /// 添加操作日志 /// </summary> /// <param name="logContent">日志内容</param> /// <param name="logModule">日志模块</param> /// <param name="operBy">操作人</param> /// <returns></returns> public static bool AddOperLog(string logContent, string logModule, string operBy) { try { var log = new OperationLog() { LogId = Guid.NewGuid(), LogContent = logContent, LogModule = logModule, IpAddress = HttpContext.Current.Request.UserHostAddress, OperBy = operBy, OperTime = DateTime.Now }; return(DependencyResolver.Current.GetService <IBLLOperationLog>().Add(log) == 1); } catch (Exception ex) { Logger.Error("添加操作日志失败", ex); } return(false); }
public OperationLog DeleteAhwalMapping([FromQuery] int ahwalMappingID, [FromQuery] int userid) { //string ol_label = ""; OperationLog ol = new OperationLog(); int ret = 0; string DelQry = ""; DelQry = "delete from AhwalMapping where ahwalMappingID = " + ahwalMappingID; ret = DAL.PostGre_ExNonQry(DelQry); if (ret > 0) { ol.userID = userid; ol.operationID = Handler_Operations.Opeartion_Mapping_Remove; ol.statusID = Handler_Operations.Opeartion_Status_Success; ol.text = "تم حذف الفرد "; return(ol); } ol.statusID = Handler_Operations.Opeartion_Status_Failed; ol.text = "Failed"; return(ol); }
public virtual OperationLogEntity FromModel(OperationLog operation, PrimaryKeyResolvingMap pkMap) { if (operation == null) { throw new ArgumentNullException(nameof(operation)); } pkMap.AddPair(operation, this); CreatedBy = operation.CreatedBy; CreatedDate = operation.CreatedDate; Detail = operation.Detail; Id = operation.Id; ModifiedBy = operation.ModifiedBy; ModifiedDate = operation.ModifiedDate; ObjectId = operation.ObjectId; ObjectType = operation.ObjectType; OperationType = operation.OperationType.ToString(); return(this); }
public void Add(string action, string userName = "", string message = "") { try { OperationLog log = new OperationLog(); if (string.IsNullOrEmpty(userName)) { userName = _httpContextAccessor.HttpContext.User.Identity.Name; } log.Action = action; log.Message = message; log.Guid = Guid.NewGuid().ToString(); log.CreatedOn = DateTime.Now; log.CreatedBy = userName; dbgp.Insertable(log).ExecuteCommand(); } catch (Exception ex) { _logger.LogError("添加日志失败:" + ex.ToString()); } }
public bool Delete(int[] operationLogID) { try { int count = operationLogID.Count(); for (int i = 0; i < count; i++) { OperationLog operationLog = new OperationLog { OperationLogID = operationLogID[i] }; dbcontext.OperationLogContext.Attach(operationLog); dbcontext.OperationLogContext.Remove(operationLog); } dbcontext.SaveChanges(); return(true); } catch { throw; } }
protected void IncidentTypesGrid_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { DataClassesDataContext db = new DataClassesDataContext(Handler_Global.connectString); var incident = db.IncidentsTypes.FirstOrDefault <IncidentsType>(a => a.IncidentTypeID == Convert.ToInt16(e.Keys["IncidentTypeID"])); if (incident != null) { incident.Name = e.NewValues["Name"].ToString(); var user = (User)Session["User"]; db.SubmitChanges(); OperationLog ol = new OperationLog(); ol.UserID = user.UserID; ol.OperationID = Core.Handler_Operations.Opeartion_IncidentsTypes_Edit; ol.StatusID = Core.Handler_Operations.Opeartion_Status_Success; ol.Text = "قام بتغيير نص نوع البلاغ: " + e.OldValues["Name"].ToString() + " بالرقم: " + e.Keys["IncidentTypeID"].ToString() + " الى النص: " + e.NewValues["Name"].ToString(); Core.Handler_Operations.Add_New_Operation_Log(ol); db.SubmitChanges(); } IncidentTypesGrid.CancelEdit(); e.Cancel = true; }
/// <summary> /// States the entry2 operation log. /// </summary> /// <param name="entitySet">The entity set.</param> /// <param name="objectType">Type of the object.</param> /// <param name="now">The now.</param> /// <param name="keyValue">The key value.</param> /// <param name="state">The state.</param> /// <returns> /// OperationLog object /// </returns> private OperationLog StateEntry2OperationLog(string entitySet, string objectType, DateTime now, string keyValue, EntityState state) { var userName = Thread.CurrentPrincipal.Identity.Name; if (String.IsNullOrEmpty(userName)) { userName = "******"; } var retVal = new OperationLog { LastModified = now, ObjectId = keyValue, ObjectType = objectType, TableName = entitySet, ModifiedBy = userName, OperationType = state.ToString() }; return(retVal); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string op = Request.QueryString["op"]; if (op != null && op.Equals("logout")) { var user = GetUser(); if (user != null) { var log = OperationLog.GetLatestLoginop(user.UserID); if (log != null) { log.LogoutTime = DateTime.Now; log.Save(); } } } Web.APPCode.CacheHelper.ClearCache(); FormsAuthentication.SignOut(); } }
public static ResultModel Delete(string logId) { OperationLog log = new OperationLog(); ResultModel result = new ResultModel(); try { log = (OperationLog)GetOperationLogById(logId).Data; OperationLogDal.Delete(log); result.IsSuccess = true; result.ObjectRecordId = log.LogId; result.ResultCode = SymbolicConstant.RESULTCODE_DELETE_SUCCESS; return result; } catch (Exception e) { System.Console.Write(e.Message); result.ResultCode = SymbolicConstant.RESULTCODE_DELETE_ERROR; result.IsSuccess = false; return result; } }
public static ResultModel GetOperationLogById(string logId) { OperationLog log = new OperationLog(); ResultModel result = new ResultModel(); try { log = OperationLogDal.GetModel(logId); result.Data = log; result.DataSize = 1; result.IsSuccess = true; result.ResultCode = SymbolicConstant.RESULTCODE_GETMODEL_SUCCESS; return result; } catch (Exception exception) { result.Data = log; result.DataSize = 1; result.IsSuccess = false; result.ResultCode = SymbolicConstant.RESULTCODE_GETMODEL_ERROR; result.ResultMessage = exception.Message; return result; } }
/// <summary> /// 删除OperationLog表中的某条记录 /// </summary> /// <param name="user">要删除记录的对应的实体</param> public static void Delete(OperationLog operationLog) { DataAccessUtility.Delete<OperationLog>(operationLog); }
public ActionResult operationlogview(int sn) { dynamic data = new System.Dynamic.ExpandoObject(); ReturnValue r = new ReturnValue(); OperationLog one = new OperationLog(); #region 读取 try { one = managementService.GetOneOperationLog(Masterpage.CurrUser.client_code, sn); if (one == null) { r = new ReturnValue { status = "error", message = "日志不存在" }; LogHelper.Info(Masterpage.CurrUser.alias, "604014:客户," + Masterpage.CurrUser.client_code + ",查看操作日志失败,操作日志sn:" + sn + "日志不存在"); } else { r = new ReturnValue { status = "ok" }; LogHelper.Info(Masterpage.CurrUser.alias, "604014:客户," + Masterpage.CurrUser.client_code + ",查看操作日志,操作日志sn:" + sn); } } catch (Exception ex) { LogHelper.Info(Masterpage.CurrUser.alias, "604014:客户," + Masterpage.CurrUser.client_code + ",查看操作日志失败,操作日志sn:" + sn + ex.Message); r = new ReturnValue { status = "error", message = "日志不存在" }; } #endregion data.one = one; data.r = r; return View(data); }
public static ResultModel Update(OperationLog log) { ResultModel result = new ResultModel(); object id = new object(); try { OperationLogDal.Update(log); result.IsSuccess = true; result.ObjectRecordId = log.LogId; result.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_SUCCESS; return result; } catch (Exception exception) { result.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_ERROR; result.IsSuccess = false; result.ResultMessage = exception.Message; return result; } }
/// <summary> /// 添加一条新记录 /// </summary> /// <param name="dictionary">Dictionary实体</param> /// <returns>添加结果,包括是否插入成功、记录主键等信息</returns> public static ResultModel Insert(Dictionary dictionary) { OperationLog log = new OperationLog(); ResultModel result = new ResultModel(); object id = ""; try { log.LogId = Guid.NewGuid().ToString("N"); log.SystemUserId = CurrentSession.getUser().UserId; log.OperationTypeCode = SymbolicConstant.OPERATIONTYPE_INSERT; log.OperationContent = SymbolicConstant.OPERATIONCONTENT_INSERT; log.AddTime = DateTime.Now; log.OperationTable = typeof(Dictionary).Name; id = DictionaryDal.Insert(dictionary); log.ObjectRecordId = Convert.ToString(id); log.ResultCode = SymbolicConstant.RESULTCODE_INSERT_SUCCESS; log.IsSuccessId = SymbolicConstant.ISSUCCESS_TRUE; log.ResultMessage=SymbolicConstant.RESULTMESSAGE_INSERT_SUCCESS; result.IsSuccess = true; result.ObjectRecordId = id.ToString(); result.ResultCode = SymbolicConstant.RESULTCODE_INSERT_SUCCESS; result.ResultMessage = SymbolicConstant.RESULTMESSAGE_INSERT_SUCCESS; return result; } catch (Exception exception) { log.IsSuccessId = SymbolicConstant.ISSUCCESS_FALSE; log.ObjectRecordId = Convert.ToString(id); log.ResultCode = SymbolicConstant.RESULTCODE_INSERT_ERROR; log.ResultMessage=exception.Message; result.IsSuccess = false; result.ObjectRecordId = id.ToString(); result.ResultCode = SymbolicConstant.RESULTCODE_INSERT_ERROR; result.ResultMessage = exception.Message; return result; } finally { OperationLogBll.Insert(log); } }
/// <summary> /// 根据查询条件获取Dictionary表中符合查询条件的记录 /// </summary> /// <param name="queryTerms">自定义查询条件</param> /// <returns>查询结果,封装了查询的数据信息</returns> public static ResultModel GetDictionaryList(QueryTerms queryTerms) { List<Dictionary> dictionaryList = new List<Dictionary>(); OperationLog log = new OperationLog(); int totalCount = 0; ResultModel result = new ResultModel(); try { log.AddTime = DateTime.Now; log.IsSuccessId = SymbolicConstant.ISSUCCESS_TRUE; log.LogId = System.Guid.NewGuid().ToString("N"); log.OperationContent = SymbolicConstant.OPERATIONCONTENT_GETLIST; log.OperationTable = typeof(Dictionary).Name; log.OperationTypeCode =SymbolicConstant.OPERATIONTYPE_GETLIST; log.ResultCode = SymbolicConstant.RESULTCODE_GETLIST_SUCCESS; log.ResultMessage=SymbolicConstant.RESULTMESSAGE_GETLIST_SUCCESS; log.SystemUserId = CurrentSession.getUser().UserId; dictionaryList = (List<Dictionary>)(DictionaryDal.GetList(queryTerms)); totalCount=Convert.ToInt32(SystemUserDal.GetTotalCount(queryTerms)); log.TotalCount = totalCount; result.Data = dictionaryList; result.DataSize = totalCount; result.IsSuccess = true; result.ResultCode = SymbolicConstant.RESULTCODE_GETLIST_SUCCESS; result.ResultMessage = SymbolicConstant.RESULTMESSAGE_GETLIST_SUCCESS; return result; } catch (Exception exception) { log.ResultCode = SymbolicConstant.RESULTCODE_GETLIST_ERROR; log.IsSuccessId = SymbolicConstant.ISSUCCESS_FALSE; log.ResultMessage=exception.Message; result.IsSuccess = false; result.ResultCode = SymbolicConstant.RESULTCODE_GETLIST_ERROR; result.ResultMessage = exception.Message; return result; } finally { OperationLogBll.Insert(log); } }
/// <summary> /// 删除数据库Dictionary表中的所有记录 /// </summary> /// <returns>删除结果,包括是删除成功、删除的记录数等信息</returns> public static ResultModel DeleteAll() { OperationLog log = new OperationLog(); ResultModel result = new ResultModel(); try { log.AddTime = DateTime.Now; log.IsSuccessId = SymbolicConstant.ISSUCCESS_TRUE; log.LogId = System.Guid.NewGuid().ToString("N"); log.OperationContent = SymbolicConstant.OPERATIONCONTENT_DELETEALL; log.OperationTable = typeof(Dictionary).Name; log.OperationTypeCode = SymbolicConstant.OPERATIONTYPE_DELETEALL; log.ResultCode = SymbolicConstant.RESULTCODE_DELETEALL_SUCCESS; log.ResultMessage=SymbolicConstant.RESULTMESSAGE_DELETEALL_SUCCESS; log.SystemUserId = CurrentSession.getUser().UserId; //删除的记录数 int count=(int)WebPageDal.DeleteAll(); log.TotalCount = count; result.DataSize = count; result.IsSuccess = true; result.ResultCode = SymbolicConstant.RESULTCODE_DELETEALL_SUCCESS; result.ResultMessage=SymbolicConstant.RESULTMESSAGE_DELETEALL_SUCCESS; return result; } catch (Exception exception) { log.IsSuccessId = SymbolicConstant.ISSUCCESS_FALSE; log.ResultCode = SymbolicConstant.RESULTCODE_DELETEALL_ERROR; log.ResultMessage=exception.Message; result.IsSuccess = false; result.ResultCode = SymbolicConstant.RESULTCODE_DELETEALL_ERROR; result.ResultMessage = exception.Message; return result; } finally { OperationLogBll.Insert(log); } }
/// <summary> /// 根据主键查询指定记录 /// </summary> /// <param name="userId">主键</param> /// <returns>查询结果,封装了查询出的实体</returns> public static ResultModel GetLinkMenuById(string linkMenuId) { OperationLog log = new OperationLog(); LinkMenu linkMenu = new LinkMenu(); ResultModel result = new ResultModel(); try { linkMenu = LinkMenuDal.GetModel(linkMenuId); log.AddTime = DateTime.Now; log.LogId = System.Guid.NewGuid().ToString("N"); log.OperationTypeCode = SymbolicConstant.OPERATIONTYPE_GETMODEL; log.OperationContent = SymbolicConstant.OPERATIONCONTENT_GETMODEL; log.OperationTable = typeof(LinkMenu).Name; log.ObjectRecordId = linkMenuId; log.ResultCode = SymbolicConstant.RESULTCODE_GETMODEL_SUCCESS; log.ResultMessage=SymbolicConstant.RESULTMESSAGE_GETMODEL_SUCCESS; log.SystemUserId = CurrentSession.getUser().UserId; log.IsSuccessId = SymbolicConstant.ISSUCCESS_TRUE; result.Data = linkMenu; result.IsSuccess = true; result.ResultCode = SymbolicConstant.RESULTCODE_GETMODEL_SUCCESS; result.ResultMessage=SymbolicConstant.RESULTMESSAGE_GETMODEL_SUCCESS; return result; } catch (Exception exception) { log.ResultCode = SymbolicConstant.RESULTCODE_GETMODEL_ERROR; log.IsSuccessId = SymbolicConstant.ISSUCCESS_FALSE; log.ResultMessage=exception.Message; result.IsSuccess = false; result.ResultCode = SymbolicConstant.RESULTCODE_GETMODEL_ERROR; result.ResultMessage = exception.Message; return result; } finally { OperationLogBll.Insert(log); } }
/// <summary> /// 修改某条记录 /// </summary> /// <param name="user">要修改记录对应的实体</param> /// <returns>修改结果,包括是否修改成功、记录主键等信息</returns> public static ResultModel Update(WebPage webPage) { OperationLog log = new OperationLog(); ResultModel result = new ResultModel(); try { log.AddTime = DateTime.Now; log.IsSuccessId = SymbolicConstant.ISSUCCESS_TRUE; log.LogId = System.Guid.NewGuid().ToString("N"); log.OperationContent = SymbolicConstant.OPERATIONCONTENT_UPDATE; log.OperationTable = typeof(WebPage).Name; log.OperationTypeCode = SymbolicConstant.OPERATIONTYPE_UPDATE; log.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_SUCCESS; log.ResultMessage=SymbolicConstant.RESULTMESSAGE_UPDATE_SUCCESS; log.SystemUserId = CurrentSession.getUser().UserId; log.ObjectRecordId = webPage.PageId; WebPageDal.Update(webPage); result.IsSuccess = true; result.ObjectRecordId = webPage.PageId; result.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_SUCCESS; result.ResultMessage = SymbolicConstant.RESULTMESSAGE_UPDATE_SUCCESS; return result; } catch (Exception exception) { log.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_ERROR; log.IsSuccessId = SymbolicConstant.ISSUCCESS_FALSE; log.ResultMessage=exception.Message; result.IsSuccess = false; result.ObjectRecordId =webPage.PageId; result.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_ERROR; result.ResultMessage = exception.Message; return result; } finally { OperationLogBll.Insert(log); } }
/// <summary> /// 修改OperationLog表中的某条记录 /// </summary> /// <param name="user">要修改记录对应的实体</param> public static void Update(OperationLog operationLog) { DataAccessUtility.Update<OperationLog>(operationLog); }
/// <summary> /// 插入一条新记录 /// </summary> /// <param name="operationLog">OperationLog实体</param> /// <returns>插入记录的主键</returns> public static object Insert(OperationLog operationLog) { Object id = DataAccessUtility.Insert<OperationLog>(operationLog); return id; }
public static ResultModel Insert(OperationLog log) { ResultModel result = new ResultModel(); object id = ""; try { OperationLogDal.Insert(log); result.IsSuccess = true; result.ObjectRecordId = id.ToString(); result.ResultCode = SymbolicConstant.RESULTCODE_INSERT_SUCCESS; return result; } catch (Exception exception) { result.ResultCode = SymbolicConstant.RESULTCODE_INSERT_ERROR; result.IsSuccess = false; result.ResultMessage = exception.Message; return result; } }