protected override void OnActionExecuted(ActionExecutedContext filterContext) { base.OnActionExecuted(filterContext); string controllerName = filterContext.RouteData.Values["controller"].ToString().ToLower(); string actionName = filterContext.RouteData.Values["action"].ToString().ToLower(); var admin = PersonalFramework.Service.AdminLoginHelper.CurrentUser(); //记录操作日志,写进操作日志中 var log = new ActionLog(); log.ActionContent = ""; log.CreateTime = DateTime.Now; log.IP = IPHelper.GetClientIp(); log.Location = controllerName + "/" + actionName; log.RequestData = Request.Form.ToString(); log.Platform = "后台"; log.Source = Request.HttpMethod; log.RequestUrl = Request.Url.AbsoluteUri; if (admin != null) { log.UID = admin.ID; log.UserName = admin.AdminName; } context.ActionLog.Add(log); //context.SaveChanges(); if (Request.UrlReferrer != null) { ViewBag.FormUrl = Request.UrlReferrer.ToString(); } }
public void SetupEvents() { if (_client.LoginState != LoginState.LoggedIn) { return; } _client.Ready += OnReady; ActionLog log = new ActionLog(); _client.MessageUpdated += OnMessageEdited; _client.UserJoined += log.AnnounceUserJoined; _client.UserLeft += log.AnnounceUserLeft; _client.UserBanned += log.AnnounceUserBanned; _client.UserUnbanned += log.AnnounceUserUnbanned; _client.MessageDeleted += log.AnnounceMessageDeleted; _client.MessagesBulkDeleted += log.AnnounceBulkDelete; _client.GuildMemberUpdated += log.AnnounceGuildMemberUpdated; _client.ChannelCreated += log.AnnounceChannelCreated; _client.ChannelDestroyed += log.AnnounceChannelDestroyed; _client.ChannelUpdated += log.AnnounceChannelUpdated; _client.RoleCreated += log.AnnounceRoleCreated; _client.RoleDeleted += log.AnnounceRoleDeleted; _client.RoleUpdated += log.AnnounceRoleUpdated; _client.JoinedGuild += log.OnGuildJoin; }
public SaveResult Create(POSs pos, int userId, string userName) { bool isExists = FiiiPayDB.DB.Queryable <POSs>().Where(t => t.Sn == pos.Sn).First() == null; if (pos != null && isExists) { pos.Timestamp = DateTime.UtcNow; pos.Status = false; var posId = FiiiPayDB.POSDb.InsertReturnIdentity(pos); bool saveSuccess = posId > 0; if (saveSuccess) { ActionLog actionLog = new ActionLog(); actionLog.IPAddress = GetClientIPAddress(); actionLog.AccountId = userId; actionLog.CreateTime = DateTime.UtcNow; actionLog.ModuleCode = typeof(POSBLL).FullName + ".Create"; actionLog.Username = userName; actionLog.LogContent = "Create POS " + posId; new ActionLogBLL().Create(actionLog); } return(new SaveResult(saveSuccess)); } return(new SaveResult(false)); }
void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext) { // TODO: Add your acction filter's tasks here // Log Action Filter Call DomainModels db = new DomainModels(); <<<<<<< HEAD ======= >>>>>>> 6bef4ea7199f182f1dcc5a1156a157494ff9f29c //var result = (ApoliceCreationViewModel)filterContext.ActionParameters[ParameterName]; /*var context = new UsersContext(); var username = filterContext.HttpContext.User.Identity.Name; var user = context.UserProfiles.SingleOrDefault(u => u.UserName == username); user.RandomString = "Random1"; */ ActionLog log = new ActionLog() { Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName, Action = filterContext.ActionDescriptor.ActionName, IP = filterContext.HttpContext.Request.UserHostAddress, DateTime = filterContext.HttpContext.Timestamp, //Message = "" + username +" injected string " + user.RandomString }; /* db.ActionLogs.Add(log); db.SaveChanges(); context.SaveChanges(); */ this.OnActionExecuting(filterContext); }
public void UploadToServer(ActionLog log) { var list = new List <ActionLog>(); var request = WebRequest.Create(_path); request.Method = WebRequestMethods.Ftp.DownloadFile; using (WebResponse tmpRes = request.GetResponse()) { using (Stream tmpStream = tmpRes.GetResponseStream()) { using (TextReader tmpReader = new StreamReader(tmpStream)) { string fileContents = tmpReader.ReadToEnd(); list = JsonConvert.DeserializeObject <List <ActionLog> >(fileContents); list.Add(log); } } } request = WebRequest.Create(_path); request.Method = WebRequestMethods.Ftp.UploadFile; var buffer = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(list)); using (var str = request.GetRequestStream()) { str.Write(buffer, 0, buffer.Length); } request.GetResponse(); request = null; }
/// <summary> /// this function will update a given specific menu item into the database /// </summary> /// <param name="user">the given user</param> /// <param name="menuItem">the specific menu item</param> public static void UpdateSpecificMenuSettingForUser(User user, MenuItem menuItem) { #region ActionLog //the main log display String logAction = $"S-a actualizat starea setari {menuItem.MenuDisplay} pentru utilizatorul {user.DisplayName}"; String logCommand = $"UPDATE settings.meniu_utilizator SET activ = {menuItem.IsActive} " + $"WHERE utilizator_id = {user.ID} AND inregistrare_meniu = {menuItem.MenuItemID}"; //the local element IP String IP = MentorBilling.Miscellaneous.IPFunctions.GetWANIp(); #endregion //the update command for the query String queryCommand = "UPDATE settings.meniu_utilizator SET activ = :p_activ " + "WHERE utilizator_id = :p_user_id AND inregistrare_meniu = :p_record_id"; //we instantiate the query parameter NpgsqlParameter[] queryParameters = { new NpgsqlParameter("p_user_id", user.ID), new NpgsqlParameter("p_record_id", menuItem.MenuItemID), new NpgsqlParameter("p_activ", menuItem.IsActive) }; //if we are unable to connect to the server we abandon execution if (!PgSqlConnection.OpenConnection()) { return; } //else we call the execution of the procedure PgSqlConnection.ExecuteScalar(queryCommand, queryParameters); //we also log the current action ActionLog.LogAction(logAction, IP, user, logCommand, PgSqlConnection); //lets have happy functions without forgetting to close the Miscellaneous.NormalConnectionClose(PgSqlConnection); }
public JsonResult Delete(int id) { try { // find deleted user var deletedUser = db.Users.Where(u => u.UserId == id).FirstOrDefault(); if (deletedUser != null) { if (String.Compare(deletedUser.Username, "admin", true) == 0) { return(Json(new { Error = 1, Message = "Tài khoản " + deletedUser.Username + " là tài khoản hệ thống. Bạn không thể xóa tài khoản này." })); } // remove user roles deletedUser.Roles.Clear(); // delete user db.Users.Remove(deletedUser); db.SaveChanges(); // Write action log string actionLogData = "username="******"REMOTE_ADDR"]); } return(Json(new { Error = 0, Message = "Delete user success!!!" })); } catch (Exception ex) { return(Json(new { Error = 1, Message = ex.Message })); } }
/// <summary> /// this function will generate the Initial Settings for the user /// </summary> /// <param name="user">the given user</param> public static void GenerateInitialUserSettings(User user) { #region ActionLog //we format the log action for the element String logAction = $"S-au generat setarile initiale pentru utilizatorul {user.DisplayName}"; //we generate the log Command String logCommand = "INSERT INTO setari_utilizatori(utilizator_id, setare_id, valoare_setare) " + $"SELECT {user.ID}, id, valoare_initiala FROM setari"; //we generate the Computer IP String IP = MentorBilling.Miscellaneous.IPFunctions.GetWANIp(); #endregion //we write the sqlQuery String QueryCommand = "INSERT INTO settings.setari_utilizatori(utilizator_id, setare_id, valoare_setare) " + "SELECT :p_user_id, id, valoare_initiala FROM settings.setari"; //we instantiate the query parameter NpgsqlParameter QueryParameter = new NpgsqlParameter("p_user_id", user.ID); //if we are unable to connect to the server we abandon execution if (!PgSqlConnection.OpenConnection()) { return; } //else we call the execution of the procedure PgSqlConnection.ExecuteNonQuery(QueryCommand, QueryParameter); //and log the action ActionLog.LogAction(logAction, IP, user, logCommand, PgSqlConnection); //and as always never forget to close the connection Miscellaneous.NormalConnectionClose(PgSqlConnection); }
/// <summary> /// this function will update a solitary setting with the new setting value for a given user /// </summary> /// <param name="user">the given user</param> /// <param name="setting">the setting</param> public static void UpdateSettingValueForUser(User user, Setting setting) { #region Log Action //the specific log action String logAction = $"Actualizat valoarea setarii {setting.SettingDisplay} pentru utilizatorul {user.DisplayName}"; //we generate the log Command String logCommand = "UPDATE setari_utilizatori " + $"SET valoare_setare = {setting.GetStringValue} " + $"WHERE utilizator_id = {user.ID} AND setare_id = {setting.ID}"; //we generate the Computer IP String IP = MentorBilling.Miscellaneous.IPFunctions.GetWANIp(); #endregion //the update command for a single setting String QueryCommand = "UPDATE settings.setari_utilizatori " + "SET valoare_setare = :p_value " + "WHERE utilizator_id = :p_user_id AND setare_id = :p_setting_id"; //the query parameters for a single setting List <NpgsqlParameter> QueryParameters = new List <NpgsqlParameter>() { new NpgsqlParameter(":p_value", setting.GetStringValue), new NpgsqlParameter(":p_user_id", user.ID), new NpgsqlParameter(":p_setting_id", setting.ID) }; //if we are unable to connect to the server we abandon execution if (!PgSqlConnection.OpenConnection()) { return; } //else we call the execution of the procedure PgSqlConnection.ExecuteScalar(QueryCommand, QueryParameters); //we will log the multi-insert ActionLog.LogAction(logAction, IP, user, logCommand, PgSqlConnection); //and as always never forget to close the connection Miscellaneous.NormalConnectionClose(PgSqlConnection); }
/// <summary> /// this function will add a new bank account to a given seller by piggy-backing on an already active connection /// </summary> /// <param name="seller">the given seller</param> /// <param name="bankAccount">the bank account controller</param> /// <param name="posgreSqlConnection">the active connection</param> public static void AddNewBankAccountForSeller(ObjectStructures.Invoice.Seller seller, BankAccount bankAccount, PostgreSqlConnection posgreSqlConnection) { #region ActionLog //we generate the log Action String LogAction = $"Adaugat un nou cont bancar la banca {bankAccount.Bank} pentru societatea {seller.Name}"; //we also generate the command String LogCommand = "INSERT INTO seller.conturi_bancare_furnizori(furnizor_id,cont,banca) " + $"VALUES({seller.ID}, {bankAccount.Account}, {bankAccount.Bank}) " + "ON CONFLICT(cont) " + $"DO UPDATE SET banca= {bankAccount.Bank} RETURNING id"; //and get the instance IP String IP = MentorBilling.Miscellaneous.IPFunctions.GetWANIp(); #endregion //we generate the query command string String QueryCommand = "INSERT INTO seller.conturi_bancare_furnizori(furnizor_id,cont,banca) " + "VALUES(:p_seller_id, :p_account, :p_bank) " + "ON CONFLICT(cont) " + "DO UPDATE SET banca= :p_bank, activ = true " + "RETURNING id"; //and then set the parameters for the query List <NpgsqlParameter> QueryParameters = new List <NpgsqlParameter>() { new NpgsqlParameter(":p_seller_id", seller.ID), new NpgsqlParameter(":p_account", bankAccount.Account), new NpgsqlParameter(":p_bank", bankAccount.Bank) }; //we execute the command returning the ID over an already active connection bankAccount.ID = (Int32)posgreSqlConnection.ExecuteScalar(QueryCommand, QueryParameters); //and log the command ActionLog.LogAction(LogAction, LogCommand, IP, PgSqlConnection); }
/// <summary> /// this function will update a bank account /// </summary> /// <param name="bankAccount">the given bank account</param> public static void UpdateBankAccountByAccount(BankAccount bankAccount) { #region ActionLog //we initialy generate the action log and command String LogAction = $"S-a actualizat contul bancar cu ID: {bankAccount.ID}"; String LogCommand = "UPDATE seller.conturi_bancare_furnizori " + $"SET banca = {bankAccount.Bank} " + $"WHERE cont = {bankAccount.Account}"; //before retrieving the ip of the current instance String IP = MentorBilling.Miscellaneous.IPFunctions.GetWANIp(); #endregion //we generate the query command String QueryCommand = "UPDATE seller.conturi_bancare_furnizori " + "SET banca = :p_bank, activ = true " + "WHERE cont = :p_account"; //and set the query parameters. List <NpgsqlParameter> QueryParameters = new List <NpgsqlParameter>() { new NpgsqlParameter(":p_account", bankAccount.Account), new NpgsqlParameter(":p_bank", bankAccount.Bank) }; //before checking if we can open the connection if (!PgSqlConnection.OpenConnection()) { return; } //we execute the non-query PgSqlConnection.ExecuteNonQuery(QueryCommand, QueryParameters); //and log the action ActionLog.LogAction(LogAction, LogCommand, IP, PgSqlConnection); //before closing the connection Miscellaneous.NormalConnectionClose(PgSqlConnection); }
/// <summary>Activate an item in database</summary> /// <param name="itemId">Item identifier</param> /// <param name="userId">Identifier of user that performs action</param> /// <param name="userDescription">User description for trace purposses</param> /// <param name="itemName">Item name</param> /// <param name="instanceName">Name of actual instance</param> /// <param name="connectionString">String connection to database</param> /// <returns>Result of action</returns> public static ActionResult Active(long itemId, long userId, string userDescription, string itemName, string instanceName, string connectionString) { var res = ActionResult.NoAction; string query = SqlServerWrapper.ActiveQuery(itemId, userId, itemName, instanceName); using (var cmd = new SqlCommand(query)) { using (var cnn = new SqlConnection(connectionString)) { cmd.Connection = cnn; try { cmd.Connection.Open(); cmd.ExecuteNonQuery(); ActionLog.Trace(itemName + "_", itemId, "ACTIVE", instanceName, userDescription); res.SetSuccess(); } catch (Exception ex) { res.SetFail(ex); } } } return(res); }
/*/// <summary> * /// Updates item data in database * /// </summary> * /// <param name="itemBuilder">Item instance</param> * /// <param name="fromImport">Indicates if update is from import (not required)</param> * /// <returns>Result of action</returns> * public static ActionResult Update(ItemBuilder itemBuilder,long userId, bool fromImport = false) * { * return Update(itemBuilder, Basics.ActualInstance.Config.ConnectionString, userId, fromImport); * }*/ /// <summary>Updates item data in database</summary> /// <param name="itemBuilder">Item instance</param> /// <param name="instanceName">Name of instance</param> /// <param name="userId">User identifier</param> /// <param name="fromImport">Indicates if update is from import (not required)</param> /// <returns>Result of action</returns> public static ActionResult Update(ItemBuilder itemBuilder, string instanceName, long userId, bool fromImport = false) { var res = ActionResult.NoAction; if (itemBuilder == null) { res.SetFail("No itemBuilder defined"); return(res); } if (string.IsNullOrEmpty(instanceName)) { res.SetFail("No instance specified"); return(res); } string query = SqlServerWrapper.UpdateQuery(itemBuilder, userId); using (var cmd = new SqlCommand(query)) { try { if (string.IsNullOrEmpty(query)) { return(ActionResult.NoAction); } var instance = CustomerFramework.Load(instanceName); using (var cnn = new SqlConnection(instance.Config.ConnectionString)) { var old = Read.ById(itemBuilder.Id, itemBuilder.Definition, instanceName); cmd.Connection = cnn; cmd.Connection.Open(); cmd.ExecuteNonQuery(); res.SetSuccess(); string differences = ItemBuilder.Differences(old, itemBuilder); if (res.Success) { var user = ApplicationUser.GetById(userId, instance.Config.ConnectionString); ActionLog.Trace(itemBuilder.ItemName + "_", itemBuilder.Id, differences, itemBuilder.ItemName, user.TraceDescription); res.ReturnValue = "UPDATE"; } } } catch (Exception ex) { ExceptionManager.LogException(ex as Exception, "Update:" + query); res.SetFail(query + "<br />" + ex); } finally { if (cmd.Connection.State != ConnectionState.Closed) { cmd.Connection.Close(); } } } return(res); }
/// <summary> /// Logs the user action. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="theAction">The action.</param> /// <param name="isGranted">if set to <c>true</c> [is granted].</param> public void LogUserAction(string userId, string theAction, bool isGranted) { if (string.IsNullOrEmpty(userId)) { throw new ArgumentNullException("userId"); } if (string.IsNullOrEmpty(theAction)) { throw new ArgumentNullException("theAction"); } try { using ( var dbContext = (PitalyticsEntities)dbContextFactory.GetDbContext()) { var actionLog = new ActionLog { Action = theAction, Granted = isGranted, LogDate = DateTime.Now, UserEmail = userId, DateStamp = DateTime.Now }; dbContext.ActionLogs.Add(actionLog); dbContext.SaveChanges(); } } catch (Exception e) { throw new Exception($"LogUserAction - {e.Message} , {(e.InnerException != null ? e.InnerException.Message : "")}"); } }
public LogEditForm(EditFormMode mode, ActionLog actionLog) : base(mode, actionLog) { CheckHelper.ArgumentWithinCondition(mode == EditFormMode.View, "Form is readonly."); InitializeComponent(); }
public static void AddActionLog(ActionLog log) { lock (actionLogLock) { actionLogs.Add(log); } }
public void SetUp() { this.logger = new ActionLog(); GlobalConstants.ActionLog = this.logger; this.target = new CombatEngine(Mock.Of <IRollable>( roller => roller.RollSuccesses( It.IsAny <int>(), It.IsIn <int>(7)) == 1 && roller.RollSuccesses( It.IsAny <int>(), It.IsNotIn(7)) == 2)); this.statisticHandler = new EntityStatisticHandler(); this.skillHandler = new EntitySkillHandler(); this.derivedValueHandler = new DerivedValueHandler(this.statisticHandler, this.skillHandler); this.abilityHandler = new AbilityHandler(); this.materialHandler = new MaterialHandler(); this.objectIconHandler = new ObjectIconHandler(new RNG()); this.itemHandler = new LiveItemHandler(new RNG()); GlobalConstants.GameManager = Mock.Of <IGameManager>( manager => manager.ItemHandler == this.itemHandler && manager.ObjectIconHandler == this.objectIconHandler); this.needHandler = new NeedHandler(); }
void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext) { HttpContext ctx = HttpContext.Current; if (ctx.Session["User"] == null) { filterContext.Result = new RedirectResult("~/Login/Index"); return; } var sessionEntity = ctx.Session["User"] as SessionEntity; using (YCEntities ycDb = new YCEntities()) { ActionLog log = new ActionLog() { ControllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName, Action = string.Concat(filterContext.ActionDescriptor.ActionName, " (Logged By: Custom Action Filter)"), IPAddress = GetLocalIPAddress(), CreatedDate = filterContext.HttpContext.Timestamp, UserId = sessionEntity.UserID }; ycDb.ActionLogs.Add(log); ycDb.SaveChanges(); base.OnActionExecuting(filterContext); } }
public void CreateActionLogTest_AssertFalse() { var actionLogRepo = GetActionLogRepo("ActionLog_ProdTestDb", "ActionLog_ArchTestDb"); var sourceRepo = GetSourceRepo("ActionLog_ProdTestDb"); var typeRepo = GetTypeRepo("ActionLog_ProdTestDb"); var stateRepo = GetStateRepo("ActionLog_ProdTestDb"); var eventRepo = GetEventRepo("ActionLog_ProdTestDb", "ActionLog_ArchTestDb"); var checkType = CheckType.Mock(); typeRepo.CreateType(checkType); var state = State.Mock(); stateRepo.CreateState(state); var source = Source.Mock(checkType, state); sourceRepo.CreateSource(source); var @event = Event.Mock(checkType, state, source); eventRepo.CreateEvent(@event); var result = actionLogRepo.CreateActionLog(ActionLog.Mock(@event, state)); Assert.False(result == null, "ID should not be null"); }
/// <summary> /// update a given seller by id /// </summary> /// <param name="seller">the given seller</param> public static void UpdateSellerByID(ObjectStructures.Invoice.Seller seller) { #region ActionLog //the log action detailing the event String LogAction = $"S-au actualizat datele societatii cu denumirea {seller.Name}"; //the formatted log command //for safety reasons it does not contain the image String LogCommand = "UPDATE seller.furnizori " + $"SET denumire = {seller.Name}, " + $"nr_registru_comert = {seller.CommercialRegistryNumber}, " + $"capital_social = {seller.JointStock}, " + $"sediul = {seller.Headquarters}, " + $"punct_lucru = {seller.WorkPoint}, " + $"telefon = {seller.Phone}, " + $"email = {seller.Email}, " + $"WHERE id = {seller.ID}"; //the ip of the instance user String IP = MentorBilling.Miscellaneous.IPFunctions.GetWANIp(); #endregion //the query update command string String QueryCommand = "UPDATE seller.furnizori " + "SET denumire = :p_name, " + "nr_registru_comert = :p_registry, " + "capital_social = :p_joint_stock, " + "sediul = :p_headquarters, " + "punct_lucru = :p_adress, " + "telefon = :p_phone, " + "email = :p_email, " + "sigla = :p_logo" + "WHERE id = :p_seller_id"; //the complete list of query parameters List <NpgsqlParameter> QueryParameters = new List <NpgsqlParameter> { new NpgsqlParameter("p_name", seller.Name), new NpgsqlParameter("p_registry", seller.CommercialRegistryNumber), new NpgsqlParameter("p_joint_stock", seller.JointStock), new NpgsqlParameter("p_headquarters", seller.Headquarters), new NpgsqlParameter("p_adress", seller.WorkPoint), new NpgsqlParameter("p_phone", seller.Phone), new NpgsqlParameter("p_email", seller.Email), new NpgsqlParameter("p_seller_id", seller.ID), new NpgsqlParameter() { ParameterName = "p_logo", NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Bytea, Value = seller.Logo.LogoBase } }; //we check the connection if (!PgSqlConnection.OpenConnection()) { return; } //and execute the non-query PgSqlConnection.ExecuteNonQuery(QueryCommand, QueryParameters); //then also log the action on the same query ActionLog.LogAction(LogAction, LogCommand, IP, PgSqlConnection); //then close the connection Miscellaneous.NormalConnectionClose(PgSqlConnection); }
public static bool RunAction(string appName, string actionName) { var success = false; var app = GetApp(appName); if (app != null) { var action = app.Actions.FirstOrDefault(a => a.ActionName == actionName); var actionLog = new ActionLog(action.ActionName); actionLog.StartRunDate = DateTime.UtcNow; string actionMessage; try { success = action.Execute(out actionMessage); } catch (Exception e) { actionMessage = e.Message; } actionLog.Success = success; actionLog.EndRunDate = DateTime.UtcNow; actionLog.LogMessage = actionMessage; ActionLogRepository.SaveActionLog(appName, actionLog); } return(success); }
public ActionResult ReportFinance() { // Write action log ActionLog.WriteLog(ActionLog.VIEW_BOAT_REPORT, "", User.Identity.Name, Request.ServerVariables["REMOTE_ADDR"]); return(View()); }
/// <summary> /// update the seller with the given logo /// </summary> /// <param name="logo">the given logo</param> /// <param name="seller">the seller</param> public static void AddLogoToSeller(Logo logo, ObjectStructures.Invoice.Seller seller) { #region Action Log //the log action detailing the event String LogAction = $"S-a adaugat/modificat logo-ul la societatea cu denumirea {seller.Name}"; //the query formatted command String LogCommand = $"UPDATE seller.furnizori SET sigla = {logo.LogoBase.Take(10)} WHERE id = {seller.ID}"; //the IP of the user instance String IP = MentorBilling.Miscellaneous.IPFunctions.GetWANIp(); #endregion //the update command String QueryCommand = "UPDATE seller.furnizori SET sigla = :p_logo WHERE id = :p_seller_id"; //the command parameters List <NpgsqlParameter> QueryParameters = new List <NpgsqlParameter> { new NpgsqlParameter("p_seller_id", seller.ID), new NpgsqlParameter() { ParameterName = "p_logo", NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Bytea, Value = logo.LogoBase } }; //we check the connection if (!PgSqlConnection.OpenConnection()) { return; } //and execute the update command PgSqlConnection.ExecuteNonQuery(QueryCommand, QueryParameters); //before logging the command ActionLog.LogAction(LogAction, LogCommand, IP, PgSqlConnection); //and closing the connection Miscellaneous.NormalConnectionClose(PgSqlConnection); }
public void InvalidActionLogValuesShouldReturnBadRequest() { var controller = GetFunctionalEventController("ActionLog", "ActionLog"); var result = controller.CreateActionLog(ActionLog.Mock(Event.Mock(CheckType.Mock(), State.Mock(), Source.Mock(CheckType.Mock(), State.Mock())), State.Mock()), Event.Mock(CheckType.Mock(), State.Mock(), Source.Mock(CheckType.Mock(), State.Mock())).Id); Assert.IsType <BadRequestResult>(result); }
public ActionLog Edit(ActionLog entry) { ActionLog entity = null; if (entry.Id > 0) { entity = repository.Get(entry.Id); if (entity != null) { repository.Add(entity); } else { throw new NullReferenceException("entry not found!"); } } entity.Name = entry.Name; entity.Alias = entry.Alias; entity.Data = entry.Data; entity.DateCreate = entry.DateCreate; entity.DateUpdate = entry.DateUpdate; entity.EntityName = entry.EntityName; entity.InnerReferralUrl = entry.InnerReferralUrl; entity.IsActive = entry.IsActive; entity.IsDelete = entry.IsDelete; unitOfWork.Save(); return(entity); }
public bool SetToInactive(int activityID) { bizMessage biz = new bizMessage(); try { enGageDataContext db = new enGageDataContext(); Activity ea = db.Activities.Single(act => act.ActivityID == activityID); ea.Inactive = true; ea.ModifiedBy = bizUser.GetCurrentUserName(); ea.Modified = DateTime.Now; ActionLog al = new ActionLog(); al.ID = activityID; al.TableName = "Activity"; al.Action = "Inactivate"; al.Detail = ""; al.ActionDate = DateTime.Now; al.ActionedBy = bizUser.GetCurrentUserName(); db.ActionLogs.InsertOnSubmit(al); db.SubmitChanges(); this.MSGS.AddMessage(biz.GetMessageText("UpdateSuccess"), Enums.enMsgType.OK); return(true); } catch (Exception ex) { this.MSGS.AddMessage(biz.GetMessageText("Exception"), Enums.enMsgType.Err); bizLog.InsertExceptionLog(ex); return(false); } }
protected void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs) { NotifySkillUse(new List <Player>()); int answer; if (Game.CurrentGame.UiProxies[Owner].AskForMultipleChoice( new MultipleChoicePrompt(Prompt.SkillUseYewNoPrompt, new BaGuaZhen.BaGuaZhenSkill()), Prompt.YesNoChoices, out answer) && answer == 1) { ReadOnlyCard c = Game.CurrentGame.Judge(Owner, null, new Card() { Type = new BaGuaZhen() }, (judgeResultCard) => { return(judgeResultCard.SuitColor == SuitColorType.Red); }); if (c.SuitColor == SuitColorType.Red) { eventArgs.Cards = new List <Card>(); eventArgs.Skill = new CardWrapper(Owner, new Shan(), false); ActionLog log = new ActionLog(); log.Source = Owner; log.SkillAction = new BaGuaZhen().EquipmentSkill; log.GameAction = GameAction.None; Game.CurrentGame.NotificationProxy.NotifySkillUse(log); throw new TriggerResultException(TriggerResult.Success); } } }
private void Start() { player = Player.instance; inventory = Inventory.instance; action = ActionLog.instance; rockHP = 20; }
public JsonResult Delete(int id) { try { var deletedBarge = db.Barges.Where(b => b.BargeId == id).FirstOrDefault(); if (deletedBarge != null) { // barge existed in any orders? var order = db.Orders.Where(o => o.BargeId == deletedBarge.BargeId).FirstOrDefault(); if (order != null) { return(Json(new { Error = 1, Message = "Xóa sà lan thất bại! Bạn không thể xóa sà lan đã được lập chuyến." })); } // delete barge db.Barges.Remove(deletedBarge); db.SaveChanges(); // write action log var log_data = "id=" + deletedBarge.BargeId + ", code=" + deletedBarge.BargeCode + ", v1=" + deletedBarge.VolumeRevenue + ", v2=" + deletedBarge.VolumePurchaseFillingSand + ", v3=" + deletedBarge.VolumePurchaseGoldSand; ActionLog.WriteLog(ActionLog.DELETE_BARGE_INFO, log_data, User.Identity.Name, Request.ServerVariables["REMOTE_ADDR"]); } return(Json(new { Error = 0, Message = "Xóa sà làn " + deletedBarge.BargeCode + " thành công!" })); } catch (Exception ex) { return(Json(new { Error = 1, Message = ex.Message })); } }
public ActionResult Add(AddBoatViewModel model) { try { if (ModelState.IsValid) { // create new boat info var newBoat = new Boat(); newBoat.BoatCode = model.BoatCode; newBoat.BoatOwner = model.BoatOwner; newBoat.BoatVolume = model.BoatVolume; // save boat info db.Boats.Add(newBoat); db.SaveChanges(); // Write action log string actionLogData = "boat:" + newBoat.BoatId + ", boatCode:" + newBoat.BoatCode; ActionLog.WriteLog(ActionLog.ADD_BOAT_INFO, actionLogData, User.Identity.Name, Request.ServerVariables["REMOTE_ADDR"]); return(RedirectToAction("Index")); } // invalid boat info ModelState.AddModelError("", "Thông tin Ghe không hợp lệ!"); } catch (Exception ex) { // error ModelState.AddModelError("", ex.Message); } return(View(model)); }
public SaveResult <int> Create(Currency cur, List <PriceInfos> list, int userId, string userName) { Currency tmp = FoundationDB.DB.Queryable <Currency>().Where(t => t.Name.Equals(cur.Name)).First(); if (tmp != null) { return(new SaveResult <int>(false, "The name already exists.", tmp.ID)); } if (cur.IsFixedPrice) { FoundationDB.PriceInfoDb.InsertRange(list.ToArray()); } // Create ActionLog ActionLog actionLog = new ActionLog(); actionLog.IPAddress = GetClientIPAddress(); actionLog.AccountId = userId; actionLog.CreateTime = DateTime.UtcNow; actionLog.ModuleCode = typeof(CryptocurrenciesBLL).FullName + ".Create"; actionLog.Username = userName; actionLog.LogContent = "Create Currency " + cur.ID; ActionLogBLL ab = new ActionLogBLL(); ab.Create(actionLog); return(new SaveResult <int>(true, FoundationDB.CurrencyDb.InsertReturnIdentity(cur))); }
public ActionLog ToBase() { ActionLog log = new ActionLog(); log.UserId = this.UserId; log.TableName = this.TableName; log.FullTableName = this.FullTableName; log.On = this.On; log.ActionTypeId = this.ActionTypeId; log.TableNameBg = this.TableNameBg; foreach (var propLog in this.LogProperties) { log.ActionLogProperties.Add(propLog); } return log; }
/// <summary> /// /// </summary> /// <returns></returns> internal List<ActionLog> getActionLog(int days) { NMOOracleDatabase database = new NMOOracleDatabase(dbConn); string spname = "PKG_MM_LOGS.GET_ACTION_LOGS"; NMOParameterDirection pin = NMOParameterDirection.Input; NMOParameterDirection pout = NMOParameterDirection.Output; using (var conn = new OracleConnection(dbConn)) using (var command = new OracleCommand(spname, conn) { CommandType = CommandType.StoredProcedure }) { NMOOracleParameter[] parameters = new NMOOracleParameter[2]; parameters[0] = new NMOOracleParameter(); parameters[0].ParameterName = "P_ACTIONDATE"; parameters[0].OracleDbType = NMOOracleDbType.Date; parameters[0].Direction = pin;// NMOParameterDirection.Input; parameters[0].Value = DateTime.Now.AddDays(days); parameters[1] = new NMOOracleParameter(); parameters[1].ParameterName = "P_ACTIONDATE"; parameters[1].OracleDbType = NMOOracleDbType.RefCursor; parameters[1].Direction = pout;// NMOParameterDirection.Output; // conn.Open(); DataSet ds = dbmm.GetDataSet(spname, parameters); List<ActionLog> actionLogList = new List<ActionLog>(); IEnumerable<DataRow> zz = ds.Tables[0].AsEnumerable(); //List<ActionLog> rows = ds.Tables[0].Rows.Cast<ActionLog>().ToList(); foreach (DataRow dr in zz) { ActionLog al = new ActionLog(); al.action_id = Convert.ToInt32(dr["ACTION_ID"]); al.action_note = dr["ACTION_NOTE"].ToString(); al.action_type = dr["ACTION_TYPE"].ToString(); DateTime dtCreated = DateTime.Parse(dr["DT_CREATED"].ToString()); al.dt_created = dtCreated.ToString("yyy/M/dd HHmm"); // al.dt_created = dr["DT_CREATED"].ToString(); al.user_id = dr["USER_ID"].ToString(); al.actionBy = dr["ACTIONBY"].ToString(); al.actionFor = dr["ACTIONFOR"].ToString(); al.midnId = dr["MIDN_ID"].ToString(); actionLogList.Add(al); } return actionLogList; } }
public ValidateState(string[] referenceLines, string[] resultLines) { Reference = new ActionLog ("Reference", referenceLines); Result = new ActionLog ("Result", resultLines); }
public static long SendComment(long comment_id_parent, string content, Account commenter, Account receiver, string objectType, long objectID, string target_link, string target_object_name, int objecttypeID, string userAgent, string status, string UserHostName, bool for_group) { long commentID = 0; if (for_group) { AccountCollection listReceiver = new AccountCollection(); CommentCollection listOldComment = CommentDA.SelectByPerformOnObjectID(objectID); if (receiver.ID != commenter.ID) listReceiver.Add(receiver); foreach (Comment cm in listOldComment) { if (cm.AccountID != commenter.ID && cm.AccountID != receiver.ID) { Account a = AccountDA.SelectByID(cm.AccountID); if (a != null && (listReceiver.Find(l=>l.ID == a.ID)==null)) listReceiver.Add(a); } } content = content.Replace("\n", "<br />"); Comment c = new Comment(); c.AccountID = commenter.ID; c.Author_IP = UserHostName; c.Content = content; c.ObjID = objectID; c.ObjectType = objectType; c.ObjectType = objectType; c.Agent = userAgent; c.Status = status; c.ReceiverID = receiver.ID; //owner c.ReceiverUsername = receiver.Username; c.ParentID = comment_id_parent; c.Target_link = target_link; c.Target_object_name = target_object_name; c.Username = commenter.Username; commentID = CommentDA.Insert(c); List<long> emailed_accounts = new List<long>(); //Account commenter = AccountDA.SelectByID(senderID);//((Account)S-ession["Account"]); string emailcontent = commenter.Username + " đã viết lời bình luận <b>" + target_object_name + "</b><br/> " + "<br/><br/> \"" + c.Content + "\" <br/><br/>" + "Bạn có thể xem chi tiết và trả lời bằng cách sử dụng link dưới đây: <br/> <a href='" + target_link + " '> " + target_link + "</a>" + "<br/>" + DateTime.Now.ToString(); foreach (Account r in listReceiver) { //ActionLogDA.Add(receiver.ID, receiver.Username, // objecttypeID, // objectID, // "viết bình luận <a href='" + target_link + "'>" + target_object_name + "</a> của nhóm <a href='" + target_link + "'>" + team.Name + "</a>" // , r.ID // , "" // , "" // , ""//Request.RawUrl // , c.ObjectID.ToString() + "+" + ObjectTypeID.Goal.ToString() // ); ActionLog acl = new ActionLog(); acl.AuthorID = commentID; acl.Date = DateTime.Now; acl.TargetAccount = r.ID; acl.PerformOnObjectID = objectID; acl.Username = r.Username; acl.Href = " viết bình luận trên <a href='" + target_link + "' target='_blank'>" + target_object_name + "</a>"; acl.XCommentID = c.ObjID + "+" + objectType; acl.ShortDescription = "Bạn <a href='" + LinkBuilder.getLinkProfile(commenter) + "' target='_blank'>" + commenter.Username + "</a> vừa" + acl.Href; acl.ToUser = r.Username; ActionLogDA.Insert(acl); emailed_accounts.Add(r.ID); //notify to if (commenter.ID != r.ID) //SendMail.sendMail(emailcontent, commenter.Username + " viết lời bình luận " + target_object_name, commenter.Email, commenter.FirstName + " " + commenter.LastName, r.Email, r.FirstName + " " + r.LastName, email_type.goal_comment, r.ID); SendMail.SendNotification(emailcontent, commenter.Username + " viết lời bình luận " + target_object_name, commenter.Email, commenter.FullName, r.Email, r.FullName, email_type.goal_comment, r.ID); } } return commentID; }