示例#1
0
        public void Delete(int id)
        {
            UserActionLog UserActionLog = context.UserActionLogs.Find(id);

            context.UserActionLogs.Remove(UserActionLog);
            context.SaveChanges();
        }
        /// <inheritdoc />
        /// <summary>
        /// Add a user log entry &lt;b&gt;Permissions Needed:&lt;/b&gt; owner
        /// </summary>
        /// <param name="logEntry">The user log entry to be added</param>
        public void AddUserLog(UserActionLog logEntry)
        {
            mWebCallEvent.WebPath = "/audit/logs";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            mWebCallEvent.PostBody = KnetikClient.Serialize(logEntry); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mAddUserLogStartTime      = DateTime.Now;
            mWebCallEvent.Context     = mAddUserLogResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mAddUserLogStartTime, "AddUserLog", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
示例#3
0
        public void AddLog(string applicationUserId, string actionType, string description)
        {
            UserActionLog log = new UserActionLog();

            log.ActionType      = actionType;
            log.Description     = description;
            log.ApplicationUser = context.Users.Single(x => x.Id == applicationUserId);

            context.UserActionLogs.Add(log);
            context.SaveChanges();
        }
        /// <summary>
        /// SaveAsync
        /// </summary>
        /// <param name="userActionLogInput"></param>
        /// <param name="modelState"></param>
        /// <returns></returns>
        public async Task <bool> SaveAsync(UserActionLogInput userActionLogInput, ModelStateDictionary modelState)
        {
            var newUserActionLog = new UserActionLog();

            _mapper.Map(userActionLogInput, newUserActionLog);
            newUserActionLog.CreationTime = DateTime.Now;

            _context.UserActionLog.Add(newUserActionLog);
            await _context.SaveChangesAsync();

            return(true);
        }
示例#5
0
        /// <summary>
        /// get action log user
        /// </summary>
        /// <param name="description"></param>
        /// <param name="idUser"></param>
        /// <param name="actionLog"></param>
        /// <param name="ip"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public ReturnObject AddActionLog(string description, string idUser, string actionLog, string ip,
                                         string source = "web")
        {
            try
            {
                //get location for ip
                var location =
                    IpGeographicalLocation.QueryGeographicalLocationAsync(ip);

                var log = new UserActionLog
                {
                    ActionName  = actionLog,
                    Description = description,
                    Ip          = ip,
                    UserId      = idUser,
                    Location    = !string.IsNullOrEmpty(location.Result.CountryName)
                        ? location.Result.City + "," + location.Result.CountryName
                        : "localhost",
                    Id        = CommonHelper.GenerateUuid(),
                    Source    = source,
                    CreatedAt = (int)CommonHelper.GetUnixTimestamp()
                };

                using (var userRepository = _vakapayRepositoryFactory.GetUserRepository(_connectionDb))
                {
                    var userCheck = userRepository.FindById(log.UserId);
                    if (userCheck == null)
                    {
                        return(new ReturnObject
                        {
                            Status = Status.STATUS_ERROR,
                            Message = "Can't User"
                        });
                    }

                    var logRepository = _vakapayRepositoryFactory.GetUserActionLogRepository(_connectionDb);

                    return(logRepository.Insert(log));
                }
            }
            catch (Exception e)
            {
                return(new ReturnObject
                {
                    Status = Status.STATUS_ERROR,
                    Message = e.Message
                });
            }
        }
示例#6
0
 public ActionResult Edit(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add update logic here
         var model = UserActionLog.GetById(id);
         TryUpdateModel(model);
         model.SaveOrUpDate();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#7
0
 public ActionResult Create(FormCollection collection)
 {
     try
     {
         // TODO: Add insert logic here
         var model = new UserActionLog();
         TryUpdateModel(model);
         model.Insert();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#8
0
        public bool Insert(UserActionLog item)
        {
            bool result = true;

            try
            {
                db.UserActionLogs.InsertOnSubmit(item);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Log.EnsureInitialized();
                Log.Error(typeof(ProjectEventRepository), "-------------User Action Logs- Insert-------------------------", ex);
                result = false;
            }
            return(result);
        }
        public TestBuilder actionUser()
        {
            var actionRequest = new ActionRequest()
            {
                broadcast = false,
                action    = new ActionData()
                {
                    actionerUserId = this.user.id,
                    actioneeUserId = this.user.id,
                    expiry         = (this.userAction.temporal.Value) ? DateTimeOffset.Now.AddHours(1) : (DateTimeOffset?)null,
                    userActionId   = this.userAction.id
                }
            };
            var actionResponse = client.ActionUser(actionRequest);

            assertSuccess(actionResponse);
            this.userActionLog = actionResponse.successResponse.action;
            return(this);
        }
示例#10
0
        public void UserLog()
        {
            Console.WriteLine("start");
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            Console.WriteLine("New Address");
            PersistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var userBus = new UserBusiness.UserBusiness(PersistenceFactory);

            var log = new UserActionLog
            {
                Description = "aaaa",
                Ip          = "192.168.1.157",
                ActionName  = "loggin",
                UserId      = "aaaaaaaaaa",
            };
            var resultCreated = userBus.AddActionLog(log.Description, log.UserId, log.ActionName, log.Ip);

            Console.WriteLine(JsonHelper.SerializeObject(resultCreated));
            Assert.IsNotNull(resultCreated);
        }
示例#11
0
 // GET: UserActionLog/Edit/5
 public ActionResult Edit(int id)
 {
     return(View(UserActionLog.GetById(id)));
 }
示例#12
0
 // GET: UserActionLog/Details/5
 public ActionResult Details(int id)
 {
     return(View(UserActionLog.GetById(id)));
 }
示例#13
0
 // GET: UserActionLog
 public ActionResult Index()
 {
     return(View(UserActionLog.GetAll()));
 }
示例#14
0
 public bool Insert(UserActionLog item)
 {
     return(LogRep.Insert(item));
 }
示例#15
0
 public void Insert(UserActionLog entity)
 {
     context.UserActionLogs.Add(entity);
     context.SaveChanges();
 }
示例#16
0
 public void Update(UserActionLog entity)
 {
     context.Entry(entity).State = EntityState.Modified;
     context.SaveChanges();
 }
示例#17
0
 public static UserActionLog Audit(this ApplicationContext db, UserActionLog userActionLog)
 {
     db.AU_USER_LOG.Add(userActionLog);
     db.SaveChanges();
     return(userActionLog);
 }
        public ActionResult LogsDetails2(int?id)
        {
            UserActionLog ulogsingle = ulog.getUlogByID(id.Value);

            return(View(ulogsingle));
        }
示例#19
0
        public ActionResult UpdateFinCat(List <ReportPeriodR> repper, List <FinArticleCategoryR> finartcat,
                                         List <FinArtCatListR> FinArtCatListR, int?id, string infoBox, string Cancellation, string Returned)
        {
            Decimal CancellationInt = 0;
            Decimal ReturnedInt     = 0;

            Decimal.TryParse(Cancellation, out CancellationInt);
            Decimal.TryParse(Returned, out ReturnedInt);

            //trim it all and get only 50 chars. Limit!
            infoBox = infoBox.Trim();

            if (infoBox.Length > 50)
            {
                infoBox = infoBox.Substring(0, 50);
            }

            //get project.
            Project propinfo = null;

            if (session != null)
            {
                if (session.ProjectID > 0)
                {
                    propinfo = ps.GetProjectByID(session.ProjectID);


                    //rule! check if project is not closed.
                    if (propinfo.ProposalStatus.ProposalStatusList.ProposalStatusText == "Active" ||
                        propinfo.ProposalStatus.ProposalStatusList.ProposalStatusText == "Inquire" ||
                        propinfo.ProposalStatus.ProposalStatusList.ProposalStatusText == "Proposal")
                    {
                        //Needed FinArticleCatID, BudgetID
                        try
                        {
                            budservice.UpdateCategoriesValues(finartcat);
                        }
                        catch (Exception ex)
                        {
                            return(RedirectToAction("Index", "Error", new { error = ex.ToString() }));
                        }

                        try
                        {
                            budservice.UpdateReportPeriodTrans(repper);
                        }
                        catch (Exception ex)
                        {
                            return(RedirectToAction("Index", "Error", new { error = ex.ToString() }));
                        }


                        try
                        {
                            budservice.UpdateBudget(id.Value, infoBox, CancellationInt, ReturnedInt);
                        }
                        catch (Exception ex)
                        {
                            return(RedirectToAction("Index", "Error", new { error = ex.ToString() }));
                        }



                        //Log Action.
                        try
                        {
                            UserActionLog ulogact = new UserActionLog();
                            ulogact.Action = "Update";
                            ulogact.Date   = DateTime.Now;
                            string output = null;
                            //JavaScriptSerializer jss = new JavaScriptSerializer();
                            //foreach (ReportPeriodR rr in repper)
                            //{
                            //    output = output + jss.Serialize(finartcat);
                            //}

                            foreach (ReportPeriodR rr in repper)
                            {
                                output = output + " amount: " + rr.Amount;
                            }

                            ulogact.ProjectLabel = session.ProjectLabel;
                            ulogact.ProjectID    = session.ProjectID;
                            ulogact.Data         = output;
                            ulogact.Section      = "Budget";
                            ulogact.UserName     = session.CurrentUser.username;
                            ulog.Insert(ulogact);
                        }
                        catch (Exception ex)
                        {
                            return(RedirectToAction("Index", "Error", new { error = ex.ToString() }));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Error", new { error = "Project is not active, therefore bugdet can't be changed." }));
                    }
                }
            }

            return(RedirectToAction("View", new { id = id }));
        }