private UserStatusDocument(Guid userId, AccessAction action, Guid siteId) { UserId = userId; CurrentState = action; Updated = DateTime.Now; SiteId = siteId; }
private AccessRecordDocument(Guid userId, Guid siteId, AccessAction action, Guid businessId) { UserId = userId; SiteId = siteId; Action = action; BusinessId = businessId; TimeStamp = DateTime.UtcNow; Id = Guid.NewGuid(); }
public static void WriteEntry(string userName, AccessAction action, string entityName, string data) { string msg = string.Format("{0:yyyyMMdd HH:mm:ss} {1} {2} {3} {4}\r\n", DateTime.Now, userName, action, entityName, data); //寫入Log File.AppendAllText(getLogPath(), msg); }
public static void WriteEntry(string userName, AccessAction action, string entityName, string data) { string msg = string.Format("{0:yyyyMMdd HH:mm:ss} {1} {2} {3} {4}\r\n", DateTime.Now, userName, action, entityName, data); //寫入Log File.AppendAllText(getLogPath(), msg); }
public async Task HandleAsync_Always_CreatesRecordIfUserValid(AccessAction action) { //Arrange var sut = CreateSut(); _userRepo.Setup(o => o.GetAsync(It.IsAny <Guid>())).Returns(Task.FromResult(_user.Object)); _accessFactory.Setup(o => o.Create(It.IsAny <Guid>(), It.IsAny <Guid>(), action, It.IsAny <Guid>())) .Returns(_record.Object); //Act await sut.HandleAsync(new CreateAccessRecord(It.IsAny <int>(), action, It.IsAny <Guid>()), _requestInfo.Object); //Assert _publisher.Verify(o => o.PublishEvent(It.IsAny <AccessRecordCreated>(), _requestInfo.Object)); _accessRecordRepo.Verify(o => o.AddAsync(_record.Object)); }
/// <summary> /// Activity heavy lifting. /// </summary> /// <param name="context"></param> protected override void DoWork(CodeActivityContext context) { //Get Argument Values AccessAction action = (Action.Expression != null) ? Action.Get(context) : AccessAction.AccessNotAllowed; string caption = Caption.Get(context) ?? String.Empty; //Heavy Lifting if (String.IsNullOrWhiteSpace(caption)) { XlateMessageBox.AccessDenied(action); } else { XlateMessageBox.AccessDenied(action, caption); } }
public async Task Update(Guid userId, AccessAction action, Guid siteId) { var status = await repository.GetStatusForUserAsync(userId); if (status is null) { logger.LogInformation("No status found creating one now for user: "******"Updated users status {userId} to: {action}"); status.Update(action, siteId); await repository.UpdateAsync(status); }
private object GetResponse(AccessAction action, bool shouldReturnView = false) { if (shouldReturnView) { return(View["index"]); } if (isFromBrowser()) { string requestPath = this.Request.Url.Path; string queryString = this.Request.Url.Query.ToString(); string hashTag = viewPath + "#" + requestPath + queryString; return(Response.AsRedirect(hashTag, Nancy.Responses.RedirectResponse.RedirectType.Permanent)); } else { ResourceRequest request = new ResourceRequest(this.Request.Url.Path + this.Request.Url.Query.ToString(), action, null, null, null); ISample result; try { result = NancyServer.TheHub.TryAccessResourceSampleWithUri(request); } catch (ResourceDoesNotExistException e) { var response = new NotFoundResponse(); response.StatusCode = HttpStatusCode.NotFound; return(response); } catch (Exception e) { var response = new NotFoundResponse(); response.StatusCode = HttpStatusCode.BadRequest; return(response); } var rightResponse = JsonConvert.SerializeObject(result.Context); return(Response.AsText(rightResponse)); } }
public async Task HandleAsync_Always_PublishesAccessRejectedIfUsersCannotBeFound(AccessAction action) { //Arrange var sut = CreateSut(); //Act await sut.HandleAsync(new CreateAccessRecord(It.IsAny <int>(), action, It.IsAny <Guid>()), _requestInfo.Object); //Assert _publisher.Verify(o => o.PublishEvent(It.IsAny <AccessRecordRejected>(), _requestInfo.Object)); }
public CreateAccessRecord(int code, AccessAction action, Guid siteId) { Code = code; Action = action; SiteId = siteId; }
public void Update(AccessAction action, Guid siteId) { SiteId = siteId; CurrentState = action; Updated = DateTime.Now; }
public IUserStatusDocument Create(Guid userId, AccessAction action, Guid siteId) { return(new UserStatusDocument(userId, action, siteId)); }
public IAccessRecordDocument Create(Guid userId, Guid siteId, AccessAction action, Guid businessId) { return(new AccessRecordDocument(userId, siteId, action, businessId)); }