private void GetTracker(int trackerId) { try { RequestTracker requestTracker = new RequestTracker() { RequestTrackerID = trackerId }; var responseTracker = client.getTracker(requestTracker); if (responseTracker.Id != 0) { this.trackerId = responseTracker.Id; trackerVRPosition.x = responseTracker.TrackerPhysicalPosition.X + v3.x; trackerVRPosition.y = responseTracker.TrackerPhysicalPosition.Y + v3.y; trackerVRPosition.z = responseTracker.TrackerPhysicalPosition.Z + v3.z; trackerRotation.x = responseTracker.TrackerRotation.X; trackerRotation.y = responseTracker.TrackerRotation.Y; trackerRotation.z = responseTracker.TrackerRotation.Z; trackerRotation.w = responseTracker.TrackerRotation.W; } } catch (RpcException e) { Debug.Log("RPC failed in method \"getUser\" " + e); } }
public RequestControlResult(RequestTracker globalTracker, RequestTracker tracker, ILoggerFactory loggerFactory, string errorCategoryName) { _globalTracker = globalTracker; _tracker = tracker; _loggerFactory = loggerFactory; _errorCategoryName = errorCategoryName; }
public ServiceProxy(IPEndPoint endPoint, IJsonSerializer jsonSerializer) { this.jsonSerializer = jsonSerializer; var requestTracker = new RequestTracker(new GuidFactory()); remoteHttpServer = new IpRemoteHttpServerWithLogger(endPoint, 1000, requestTracker, new OuterHttpMethodsLogger(requestTracker)); }
public async void Get_One_Twice_Ok() { // Arrange int instanceOwnerPartyId = 1337; string instanceGuid = "377efa97-80ee-4cc6-8d48-09de12cc273d"; string requestUri = $"{BasePath}/{instanceOwnerPartyId}/{instanceGuid}"; HttpClient client = GetTestClient(); string token = PrincipalUtil.GetToken(3, 1337, 3); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); // Act RequestTracker.Clear(); HttpResponseMessage response = await client.GetAsync(requestUri); HttpResponseMessage response2 = await client.GetAsync(requestUri); // Assert Assert.Equal(1, RequestTracker.GetRequestCount("GetDecisionForRequest1337/377efa97-80ee-4cc6-8d48-09de12cc273d")); Assert.Equal(HttpStatusCode.OK, response.StatusCode); string responseContent = await response.Content.ReadAsStringAsync(); Instance instance = (Instance)JsonConvert.DeserializeObject(responseContent, typeof(Instance)); Assert.Equal("1337", instance.InstanceOwner.PartyId); Assert.Equal(HttpStatusCode.OK, response2.StatusCode); }
private void btnAReq_Click(object sender, EventArgs e) { DataTable table = new RequestTracker().GetRequests(); dgvRequests.AutoGenerateColumns = true; dgvRequests.DataSource = table; }
public CreateUserResponse ResetPassword([FromBody] ResetPasswordRequest pwResetRequest) { CreateUserResponse response = new CreateUserResponse(); if (string.IsNullOrEmpty(pwResetRequest.User.Email) || string.IsNullOrEmpty(pwResetRequest.User.Password) || string.IsNullOrEmpty(pwResetRequest.Token)) { response.Error = "Missing necessary data"; } User user = pwResetRequest.User; using (RequestTracker request = new RequestTracker(Constant.RequestAPI.ResetPW.ToString(), user.Email)) { try { user.Init(); if (string.IsNullOrEmpty(user.Password) || user.Password.Length < 8) { request.response = RequestTracker.RequestResponse.UserError; response.Error = "Password must be at least 8 characters"; return(response); } User retrievedUser; TableStore.Get <User>(TableStore.TableName.users, user.PartitionKey, user.Email, out retrievedUser); if (retrievedUser == null) { request.response = RequestTracker.RequestResponse.UserError; response.Error = "Invalid user"; return(response); } // Confirm token if (retrievedUser.PWResetTokenWithExpiry == null || retrievedUser.PWResetTokenWithExpiry.Item1 != pwResetRequest.Token || DateTime.Compare(DateTime.UtcNow, retrievedUser.PWResetTokenWithExpiry.Item2) > 0) { request.response = RequestTracker.RequestResponse.UserError; response.Error = "Invalid or expired token"; return(response); } retrievedUser.Password = user.Password; retrievedUser.EncryptPassword(); retrievedUser.PWResetTokenWithExpiry = null; retrievedUser.ClearAuthTokens(); string token = retrievedUser.GetAuthToken(); TableStore.Update(TableStore.TableName.users, retrievedUser); response.Token = token; response.Error = "Success"; return(response); } catch (Exception e) { request.response = RequestTracker.RequestResponse.ServerError; ExceptionTracker.LogException(e); response.Error = "Oops, something went wrong. Initiating developer punishment."; return(response); } } }
public ActionResult DeleteConfirmed(int id) { RequestTracker requestTracker = db.RequestTrackers.Find(id); db.RequestTrackers.Remove(requestTracker); db.SaveChanges(); return(RedirectToAction("Index")); }
public override void OnActionExecuting(HttpActionContext actionContext) { var log = CreateRequestLog(actionContext); var tracker = new RequestTracker(log); actionContext.Request.Properties.Add(Constants.RequestLogId, log.LogId); actionContext.Request.Properties.Add(this.GetType().FullName, tracker); tracker.ProcessActionStart(); }
//Button clicks #region //Data Views #region private void btnROD_Click(object sender, EventArgs e) { //Request on date DateTime date = dtpDate.Value; DataTable table = new RequestTracker().GetRequestsOnDate(date); dgvRequests.AutoGenerateColumns = true; dgvRequests.DataSource = table; }
public CreateUpdateNoteResponse UpdateNote([FromBody] UpdateNoteAction updateNote) { CreateUpdateNoteResponse response = new CreateUpdateNoteResponse(); response.Status = string.Empty; if (string.IsNullOrEmpty(updateNote.Email)) { return(response); } using (RequestTracker request = new RequestTracker(Constant.RequestAPI.UpdateNote.ToString(), updateNote.Email)) { try { if (string.IsNullOrEmpty(updateNote.Email) || string.IsNullOrEmpty(updateNote.AuthToken) || string.IsNullOrEmpty(updateNote.NoteContents) || string.IsNullOrEmpty(updateNote.RowKey)) { request.response = RequestTracker.RequestResponse.UserError; return(response); } if (updateNote.NoteContents.Length > Constant.MaxNoteLength) { request.response = RequestTracker.RequestResponse.UserError; response.Status = "TooLong"; return(response); } // Use the email and authToken to get the userId string userId = UserController.GetUserId(updateNote.Email, updateNote.AuthToken); if (string.IsNullOrEmpty(userId)) { request.response = RequestTracker.RequestResponse.UserError; // Expired AuthToken response.Status = "Expired"; return(response); } response.Note = NoteModel.UpdateNote(userId, updateNote.RowKey, updateNote.NoteContents, updateNote.City, updateNote.Latitude, updateNote.Longitude, updateNote.Completed); if (response.Note == null) { request.response = RequestTracker.RequestResponse.UserError; // Expired AuthToken response.Status = "Invalid"; return(response); } LastUpdateModel.SetLastUpdate(userId); response.Status = "Success"; return(response); } catch (Exception e) { request.response = RequestTracker.RequestResponse.ServerError; ExceptionTracker.LogException(e); return(response); } } }
private void btnCReq_Click(object sender, EventArgs e) { //CLient Req string clientID = cmbAllClients.Text.Split(' ')[0]; DataTable table = new RequestTracker().GetRequestsByClient(clientID); dgvRequests.AutoGenerateColumns = true; dgvRequests.DataSource = table; }
public ActionResult Edit([Bind(Include = "RequestTrackerID,RequestID,Assignee,Status,Priority,DateUpdated,UpdatedBy,DateCreated,CreatedBy,RequestDesc,DeveloperNotes")] RequestTracker requestTracker) { if (ModelState.IsValid) { db.Entry(requestTracker).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(requestTracker)); }
public FluentMiddlewareHttpHandler( IFluentHttpMiddlewareRunner middlewareRunner, FluentHttpClient httpClient, RequestTracker requestTracker, HttpMessageHandler messageHandler = null ) : base(messageHandler ?? new HttpClientHandler()) { _middlewareRunner = middlewareRunner; _httpClient = httpClient; _requestTracker = requestTracker; }
public void Test() { var tracker = new RequestTracker("test"); // A new tracker should have no incomplete RPCs. Assert.Equal(RequestTracker.NoSeqNo, tracker.FirstIncomplete); int max = 10; for (int i = 0; i < max; i++) { tracker.GetNewSeqNo(); } // The first RPC is the incomplete one. Assert.Equal(1, tracker.FirstIncomplete); // Mark the first as complete, incomplete should advance by 1. tracker.CompleteRpc(1); Assert.Equal(2, tracker.FirstIncomplete); // Mark the RPC in the middle as complete, first incomplete doesn't change. tracker.CompleteRpc(5); Assert.Equal(2, tracker.FirstIncomplete); // Mark 2-4 inclusive as complete. for (int i = 2; i <= 4; i++) { tracker.CompleteRpc(i); } Assert.Equal(6, tracker.FirstIncomplete); // Get a few more sequence numbers. long lastSeqNo = 0; for (int i = max / 2; i <= max; i++) { lastSeqNo = tracker.GetNewSeqNo(); } // Mark them all as complete except the last one. while (tracker.FirstIncomplete != lastSeqNo) { tracker.CompleteRpc(tracker.FirstIncomplete); } Assert.Equal(lastSeqNo, tracker.FirstIncomplete); tracker.CompleteRpc(lastSeqNo); // Test that we get back to NO_SEQ_NO after marking them all. Assert.Equal(RequestTracker.NoSeqNo, tracker.FirstIncomplete); }
public override void OnActionExecuting(HttpActionContext actionContext) { if (actionContext.IsUseAttributeOf <DoNotTrackAttribute>()) { return; } var tracker = new RequestTracker(); actionContext.Request.Properties["Tracker"] = tracker; tracker.Start(actionContext); }
private void RegisterRequestTracker(IServiceCollection services, DiagnosticFeaturesSettings settings) { if (environment.HostExtensions.TryGet <IVostokApplicationDiagnostics>(out var diagnostics) && settings.AddCurrentRequestsInfoProvider) { var requestTracker = new RequestTracker(); services.AddSingleton <IRequestTracker>(requestTracker); var infoEntry = new DiagnosticEntry(DiagnosticConstants.Component, "requests-in-progress"); var infoProvider = new CurrentRequestsInfoProvider(requestTracker); disposables.Add(diagnostics.Info.RegisterProvider(infoEntry, infoProvider)); }
// GET: RequestTrackers/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RequestTracker requestTracker = db.RequestTrackers.Find(id); if (requestTracker == null) { return(HttpNotFound()); } return(View(requestTracker)); }
public async Task Exit(RequestTracker tracker) { if (GetExecute(tracker.ID)) { if (tracker.Extensions.TryGetValue(_name, out object objNumber)) { Number number = (Number)objNumber; lock (number) { number.Value--; } } } await Task.FromResult(0); }
public async Task <ValidateResult> Access(RequestTracker tracker) { ValidateResult result = new ValidateResult() { Result = true }; if (!tracker.Extensions.TryGetValue(_name, out object objNumber)) { lock (tracker.Extensions) { if (!tracker.Extensions.TryGetValue(_name, out objNumber)) { objNumber = new Number(); tracker.Extensions.Add(_name, objNumber); } } } Number number = (Number)objNumber; if (number.Value + 1 > tracker.MaxNumber) { result.Result = false; result.Description = StringLanguageTranslate.Translate(TextCodes.TokenBucketOverflow.ToString(), string.Format("令牌桶超出最大阈值{0}", tracker.MaxNumber)); } else { lock (number) { if (number.Value + 1 > tracker.MaxNumber) { result.Result = false; result.Description = StringLanguageTranslate.Translate(TextCodes.TokenBucketOverflow.ToString(), string.Format("令牌桶超出最大阈值{0}", tracker.MaxNumber)); } else { SetExecute(tracker.ID); number.Value++; } } } return(await Task.FromResult(result)); }
public string SetPWResetToken([FromBody] UserModel tokenRequest) { if (string.IsNullOrEmpty(tokenRequest.Email)) { return(string.Empty); } using (RequestTracker request = new RequestTracker(Constant.RequestAPI.SetPWReset.ToString(), tokenRequest.Email)) { try { UserModel retrievedUser; UserModel.GetUser(tokenRequest.Email, out retrievedUser); if (retrievedUser == null) { request.response = RequestTracker.RequestResponse.UserError; return(string.Empty); } // Generate token with expiry Tuple <string, DateTime> resetToken = new Tuple <string, DateTime>(Utils.Rand().ToString(), DateTime.UtcNow.AddDays(1)); retrievedUser.PWResetTokenWithExpiry = resetToken; retrievedUser.Save(); // Send email Utils.SendMail(retrievedUser.Email, "Notegami.com Password Reset", string.Format(@"<p>Please use this link to create your new password.</p> <a href='https://notegami.com/views/passwordreset.html?email={0}&token={1}'>Create Password</a>", retrievedUser.Email, resetToken.Item1)).Wait(); return("Success"); } catch (Exception e) { request.response = RequestTracker.RequestResponse.ServerError; ExceptionTracker.LogException(e); return(string.Empty); } } }
public string DeleteNote([FromBody] DeleteNoteAction deleteNote) { if (string.IsNullOrEmpty(deleteNote.Email)) { return(string.Empty); } using (RequestTracker request = new RequestTracker(Constant.RequestAPI.DeleteNote.ToString(), deleteNote.Email)) { try { if (string.IsNullOrEmpty(deleteNote.Email) || string.IsNullOrEmpty(deleteNote.AuthToken) || string.IsNullOrEmpty(deleteNote.RowKey)) { request.response = RequestTracker.RequestResponse.UserError; return(string.Empty); } // Use the email and authToken to get the userId string userId = UserController.GetUserId(deleteNote.Email, deleteNote.AuthToken); if (string.IsNullOrEmpty(userId)) { request.response = RequestTracker.RequestResponse.UserError; // Expired AuthToken return("Expired"); } if (!NoteModel.DeleteNote(userId, deleteNote.RowKey)) { return("Invalid"); } LastUpdateModel.SetLastUpdate(userId); return("Success"); } catch (Exception e) { request.response = RequestTracker.RequestResponse.ServerError; ExceptionTracker.LogException(e); return(string.Empty); } } }
public async Task TestMultiThreaded() { var rt = new RequestTracker("fake id"); var checker = new Checker(); var tasks = new Task[16]; for (int i = 0; i < tasks.Length; i++) { tasks[i] = Task.Run(() => { for (int n = 0; n < 1000; n++) { long seqNo = rt.GetNewSeqNo(); long incomplete = rt.FirstIncomplete; checker.Check(seqNo, incomplete); rt.CompleteRpc(seqNo); } }); } await Task.WhenAll(tasks); }
public string AuthUser([FromBody] CreateUserRequest authRequest) { if (string.IsNullOrEmpty(authRequest.Email)) { return(string.Empty); } using (RequestTracker request = new RequestTracker(Constant.RequestAPI.AuthUser.ToString(), authRequest.Email)) { try { if (authRequest == null || string.IsNullOrEmpty(authRequest.Email) || string.IsNullOrEmpty(authRequest.Password)) { request.response = RequestTracker.RequestResponse.UserError; return(string.Empty); } UserModel retrievedUser; UserModel.GetUser(authRequest.Email, out retrievedUser); if (retrievedUser == null || !retrievedUser.AuthCheck(authRequest.Password)) { request.response = RequestTracker.RequestResponse.UserError; return(string.Empty); } // Generate temporary auth token string token = retrievedUser.GetAuthToken(); // Store with updated auth table UserModel.UpdateUser(retrievedUser); return(token); } catch (Exception e) { request.response = RequestTracker.RequestResponse.ServerError; ExceptionTracker.LogException(e); return(string.Empty); } } }
public async Task <XacmlJsonResponse> GetDecisionForRequest(XacmlJsonRequestRoot xacmlJsonRequest) { RequestTracker.AddRequest("GetDecisionForRequest" + GetInstanceID(xacmlJsonRequest), xacmlJsonRequest); return(await Authorize(xacmlJsonRequest.Request)); }
public async Task <Unit> Handle(CreateOverTimeRequest_Request request, CancellationToken cancellationToken) { var employee = await dbContext.Employees.AsNoTracking().FirstOrDefaultAsync(i => i.CompanyEmail.ToLower() == request.Requestor.ToLower()); if (employee == null) { throw new NotFoundException(nameof(domain.RequestTracker), request.Requestor); } if (string.IsNullOrWhiteSpace(employee.ReportsTo)) { throw new Exception("Cannot process. User must be assigned a supervisor."); } var approvers = await dbContext.Approvers.Include(i => i.Employee).AsNoTracking().ToArrayAsync(); if (!approvers.ToList().Any()) { throw new Exception("Cannot process. Cannot find approver."); } var supervisor = approvers.FirstOrDefault(i => i.Employee.CompanyEmail.ToLower() == employee.ReportsTo.ToLower()); var limit = approvers.Where(i => i.TypeOfRequest == domain.RequestType.Overtime).Max(i => i.Level); var finalApprover = approvers.FirstOrDefault(i => i.TypeOfRequest == domain.RequestType.Overtime && i.Level == limit); var requestTracker = new RequestTracker { RequestorID = employee.ID, IsActive = true, TypeOfRequest = domain.RequestType.Overtime, }; requestTracker.ApproverList.Add(new ApprovalTracker { ApproverID = supervisor.ID, ApproverEmail = supervisor.Employee.CompanyEmail, IsActive = true, Status = null, CreatedBy = request.Requestor, ModifiedBy = request.Requestor }); requestTracker.ApproverList.Add(new ApprovalTracker { ApproverID = finalApprover.ID, ApproverEmail = finalApprover.Employee.CompanyEmail, IsActive = true, Status = null, CreatedBy = request.Requestor, ModifiedBy = request.Requestor }); var otRequest = new OverTimeRequest { Classification = request.Classification, EmployeeID = employee.ID, IsActive = true, Purpose = request.Purpose, ShiftDate = request.ShiftDate, TimeStart = request.TimeStart, TimeEnd = request.TimeEnd, Tracker = requestTracker }; dbContext.OverTimeRequests.Add(otRequest); await dbContext.SaveChangesAsync(cancellationToken); return(Unit.Value); }
public CreateUserResponse CreateUser([FromBody] CreateUserRequest userRequest) { CreateUserResponse response = new CreateUserResponse(); if (string.IsNullOrEmpty(userRequest.Email)) { response.Error = "Invalid Input"; return(response); } using (RequestTracker request = new RequestTracker(Constant.RequestAPI.CreateUser.ToString(), userRequest.Email)) { try { if (userRequest == null) { request.response = RequestTracker.RequestResponse.UserError; response.Error = "Invalid Input"; return(response); } if (string.IsNullOrEmpty(userRequest.Password) || userRequest.Password.Length < 8) { request.response = RequestTracker.RequestResponse.UserError; response.Error = "Password must be at least 8 characters"; return(response); } if (string.IsNullOrEmpty(userRequest.Email) || !userRequest.Email.Contains("@") || !userRequest.Email.Contains(".")) { request.response = RequestTracker.RequestResponse.UserError; response.Error = "Invalid email address"; return(response); } UserModel retrievedUser; if (UserModel.GetUser(userRequest.Email, out retrievedUser)) { if (!retrievedUser.AuthCheck(userRequest.Password)) { // User exists and pw is wrong request.response = RequestTracker.RequestResponse.UserError; response.Error = "User already exists"; return(response); } else { // Just let user login // Generate temporary auth token string loginToken = retrievedUser.GetAuthToken(); // Store with updated auth table UserModel.UpdateUser(retrievedUser); request.response = RequestTracker.RequestResponse.LoginOnSignup; response.Token = loginToken; response.Error = "Success"; return(response); } } UserModel user = new UserModel(userRequest.Email, userRequest.Password); LastUpdateModel.SetLastUpdate(user.UserId); // Generate temporary auth token string token = user.GetAuthToken(); user.Save(); // Create the tutorial notes foreach (string note in Constant.TutorialNotes) { NoteModel.AddNote(note, string.Empty, 0F, 0F, user.Email, user.UserId); } response.Token = token; response.Error = "Success"; return(response); } catch (Exception e) { request.response = RequestTracker.RequestResponse.ServerError; ExceptionTracker.LogException(e); response.Error = "Server Error"; return(response); } } }
public Requestor(Reception reception, RequestTracker requestTracker, int requestorId) { myReception = reception; this.requestTracker = requestTracker; this.requestorId = requestorId; }