public void CheckInNewStudentNoSID() { Unit unit = new Unit() { Code = AlphaNumericStringGenerator.GetString(8), IsDeleted = false, Name = AlphaNumericStringGenerator.GetString(10), }; using (helpdesksystemContext context = new helpdesksystemContext()) { context.Unit.Add(unit); context.SaveChanges(); } CheckInRequest request = new CheckInRequest() { UnitID = unit.UnitId, Nickname = AlphaNumericStringGenerator.GetString(10) }; CheckInFacade facade = new CheckInFacade(); CheckInResponse response = facade.CheckIn(request); Assert.AreEqual(HttpStatusCode.BadRequest, response.Status); }
public void CheckInNoUnit() { Nicknames nickname = new Nicknames() { NickName = AlphaNumericStringGenerator.GetString(10), Sid = AlphaNumericStringGenerator.GetStudentIDString() }; using (helpdesksystemContext context = new helpdesksystemContext()) { context.Nicknames.Add(nickname); context.SaveChanges(); } CheckInRequest request = new CheckInRequest() { SID = nickname.Sid }; CheckInFacade facade = new CheckInFacade(); CheckInResponse response = facade.CheckIn(request); Assert.AreEqual(HttpStatusCode.BadRequest, response.Status); }
public CheckInResponse CheckIn(CheckInRequest request) { var result = new CheckInResponse() { ResultMessage = "签到成功", Result = ResultCode.Success }; try { using (var con = new DbConnectionProvider(dbName).GetOpenConnection()) { var parms = new DynamicParameters(); parms.Add("P_UserID", request.UserID, DbType.Int32); con.ExecuteNoneQuery("sp_CheckIn" , parms , CommandType.StoredProcedure); } } catch (Exception ex) { result.ResultMessage = "签到异常"; result.Result = ResultCode.Error; result.Errors = new List <string>(); result.Errors.Add(ex.Message); LogHelper.WriteErrorLog(ex); } return(result); }
/// <summary> /// The Check In Response /// /// The Check-in Response is sent in response to the receipt of a Check-in command. The Check-in Response is used by the Poll Control Client to /// indicate whether it would like the device implementing the Poll Control Cluster Server to go into a fast poll mode and for how long. If the Poll /// Control Cluster Client indicates that it would like the device to go into a fast poll mode, it is responsible for telling the device to stop /// fast polling when it is done sending messages to the fast polling device. /// <br> /// If the Poll Control Server receives a Check-In Response from a client for which there is no binding (unbound), it SHOULD respond with a /// Default Response with a status value indicating ACTION_DENIED. /// <br> /// If the Poll Control Server receives a Check-In Response from a client for which there is a binding (bound) with an invalid fast poll interval /// it SHOULD respond with a Default Response with status INVALID_VALUE. /// <br> /// If the Poll Control Server receives a Check-In Response from a bound client after temporary fast poll mode is completed it SHOULD respond /// with a Default Response with a status value indicating TIMEOUT. /// <br> /// In all of the above cases, the Server SHALL respond with a Default Response not equal to ZCL_SUCCESS. /// /// <param name="startFastPolling"><see cref="bool"/> Start Fast Polling</param> /// <param name="fastPollTimeout"><see cref="ushort"/> Fast Poll Timeout</param> /// <returns>The Task<CommandResult> command result Task</returns> /// </summary> public Task <CommandResult> CheckInResponse(bool startFastPolling, ushort fastPollTimeout) { CheckInResponse command = new CheckInResponse(); // Set the fields command.StartFastPolling = startFastPolling; command.FastPollTimeout = fastPollTimeout; return(Send(command)); }
public void CheckOutForced() { Unit unit = new Unit() { Code = AlphaNumericStringGenerator.GetString(8), IsDeleted = false, Name = AlphaNumericStringGenerator.GetString(10), }; using (helpdesksystemContext context = new helpdesksystemContext()) { context.Unit.Add(unit); context.SaveChanges(); } CheckInRequest request = new CheckInRequest() { UnitID = unit.UnitId, Nickname = AlphaNumericStringGenerator.GetString(10), SID = AlphaNumericStringGenerator.GetStudentIDString() }; CheckInFacade facade = new CheckInFacade(); CheckInResponse response = facade.CheckIn(request); Assert.AreEqual(HttpStatusCode.OK, response.Status); Assert.IsTrue(response.CheckInID > 0); CheckOutRequest coRequest = new CheckOutRequest() { ForcedCheckout = true }; CheckOutResponse coResponse = facade.CheckOut(coRequest, response.CheckInID); Assert.AreEqual(HttpStatusCode.OK, coResponse.Status); Assert.IsTrue(coResponse.Result); using (helpdesksystemContext context = new helpdesksystemContext()) { Checkinhistory checkOut = context.Checkinhistory.FirstOrDefault(co => co.CheckInId == response.CheckInID); Assert.IsNotNull(checkOut); var baseTime = DateTime.Now.AddMinutes(-1); var addTime = checkOut.CheckoutTime; var timeDiff = baseTime.CompareTo(addTime); Assert.IsTrue(timeDiff == -1); Assert.AreEqual(coRequest.ForcedCheckout, checkOut.ForcedCheckout); } }
public void CheckInExistingStudent() { Unit unit = new Unit() { Code = AlphaNumericStringGenerator.GetString(8), IsDeleted = false, Name = AlphaNumericStringGenerator.GetString(10), }; Nicknames nickname = new Nicknames() { NickName = AlphaNumericStringGenerator.GetString(10), Sid = AlphaNumericStringGenerator.GetStudentIDString() }; using (helpdesksystemContext context = new helpdesksystemContext()) { context.Unit.Add(unit); context.Nicknames.Add(nickname); context.SaveChanges(); } CheckInRequest request = new CheckInRequest() { UnitID = unit.UnitId, StudentID = nickname.StudentId }; CheckInFacade facade = new CheckInFacade(); CheckInResponse response = facade.CheckIn(request); Assert.AreEqual(HttpStatusCode.OK, response.Status); Assert.IsTrue(response.CheckInID > 0); using (helpdesksystemContext context = new helpdesksystemContext()) { Checkinhistory checkInHistory = context.Checkinhistory.FirstOrDefault(cih => cih.CheckInId == response.CheckInID); var baseTime = DateTime.Now.AddMinutes(-1); var addTime = checkInHistory.CheckInTime; Assert.AreEqual(request.UnitID, checkInHistory.UnitId); var timeDiff = baseTime.CompareTo(addTime); Assert.IsTrue(timeDiff == -1); Assert.AreEqual(request.StudentID, checkInHistory.StudentId); } }
public CheckInResponse CheckIn(string systemid) { var result = new CheckInResponse(); var request = CreateCoreRequest("checkin"); request.Params.Add("systemid", systemid); request.Params.Add("session", SessionID); result.RequestTime = DateTime.Now; var response = request.GetResponse(); result.ResponseTime = DateTime.Now; result.Parse(response); return(result); }
public void CheckOutWithQueueItems() { Unit unit = new Unit() { Code = AlphaNumericStringGenerator.GetString(8), IsDeleted = false, Name = AlphaNumericStringGenerator.GetString(10), }; Topic topic = new Topic() { Name = AlphaNumericStringGenerator.GetString(10), IsDeleted = false }; using (helpdesksystemContext context = new helpdesksystemContext()) { context.Unit.Add(unit); topic.UnitId = unit.UnitId; context.Topic.Add(topic); context.SaveChanges(); } CheckInRequest request = new CheckInRequest() { UnitID = unit.UnitId, Nickname = AlphaNumericStringGenerator.GetString(10), SID = AlphaNumericStringGenerator.GetStudentIDString() }; CheckInFacade facade = new CheckInFacade(); CheckInResponse response = facade.CheckIn(request); Assert.AreEqual(HttpStatusCode.OK, response.Status); Assert.IsTrue(response.CheckInID > 0); Queueitem queueitem = new Queueitem() { StudentId = response.StudentID, TopicId = topic.TopicId, Description = "Check In Unit Test", TimeAdded = DateTime.Now }; using (helpdesksystemContext context = new helpdesksystemContext()) { context.Queueitem.Add(queueitem); Checkinqueueitem checkinqueueitem = new Checkinqueueitem() { CheckInId = response.CheckInID, QueueItemId = queueitem.ItemId }; context.Checkinqueueitem.Add(checkinqueueitem); context.SaveChanges(); } CheckOutRequest coRequest = new CheckOutRequest() { ForcedCheckout = false }; CheckOutResponse coResponse = facade.CheckOut(coRequest, response.CheckInID); Assert.AreEqual(HttpStatusCode.OK, coResponse.Status); Assert.IsTrue(coResponse.Result); using (helpdesksystemContext context = new helpdesksystemContext()) { Checkinhistory checkOut = context.Checkinhistory.FirstOrDefault(co => co.CheckInId == response.CheckInID); Queueitem item = context.Queueitem.FirstOrDefault(qi => qi.ItemId == queueitem.ItemId); Assert.IsNotNull(checkOut); var baseTime = DateTime.Now.AddMinutes(-1); var addTime = checkOut.CheckoutTime; var timeDiff = baseTime.CompareTo(addTime); Assert.IsTrue(timeDiff == -1); Assert.AreEqual(coRequest.ForcedCheckout, checkOut.ForcedCheckout); Assert.IsNotNull(item); var baseQueueTime = DateTime.Now.AddMinutes(-1); var removeQueueTime = item.TimeRemoved; var queueTimeDiff = baseQueueTime.CompareTo(removeQueueTime); Assert.IsTrue(queueTimeDiff == -1); } }
private void HandleCheckInResponse(CheckInResponse response) { }
/// <summary> /// This method is used to check in into the helpdesk system /// </summary> /// <param name="request">The request containing the specified UnitID</param> /// <returns>A response indicating success or failure</returns> public CheckInResponse CheckIn(CheckInRequest request) { CheckInResponse response = new CheckInResponse(); try { response = (CheckInResponse)request.CheckValidation(response); if (response.Status == HttpStatusCode.BadRequest) { return(response); } StudentFacade studentFacade = new StudentFacade(); if (!request.StudentID.HasValue) { if (studentFacade.GetStudentByNickname(request.Nickname).Status != HttpStatusCode.NotFound) { response.Status = HttpStatusCode.BadRequest; return(response); } AddStudentRequest addStudentRequest = new AddStudentRequest() { SID = request.SID, Nickname = request.Nickname }; AddStudentResponse addStudentResponse = studentFacade.AddStudentNickname(addStudentRequest); request.StudentID = addStudentResponse.StudentID; } using (helpdesksystemContext context = new helpdesksystemContext()) { if (context.Nicknames.FirstOrDefault(n => n.StudentId == request.StudentID) == null) { throw new NotFoundException("No student found for id " + request.StudentID); } } CheckInDataLayer dataLayer = new CheckInDataLayer(); int checkInID = dataLayer.CheckIn(request); response.StudentID = request.StudentID.Value; response.CheckInID = checkInID; response.Status = HttpStatusCode.OK; } catch (NotFoundException ex) { s_logger.Warn(ex, "No student found for id " + request.SID); response.Status = HttpStatusCode.NotFound; response.StatusMessages.Add(new StatusMessage(HttpStatusCode.NotFound, "No student found for id " + request.SID)); } catch (Exception ex) { s_logger.Error(ex, "Unable to check in"); response.Status = HttpStatusCode.InternalServerError; response.StatusMessages.Add(new StatusMessage(HttpStatusCode.InternalServerError, "Unable to check in")); } return(response); }
public TestDataCheckIn(CheckInRequest request, CheckInResponse response) { Request = request; Response = response; }
private void HandleRegistrationResponse(CheckInResponse mes) { var passId = mes.PassengerId; // if placed in terminal then he becomes completely passive if (mes.Status == CheckInStatus.Terminal) { if (waitingForResponsePassengers.TryRemove(passId, out var passenger)) { if (passivePassengers.TryAdd(passenger.PassengerId, passenger)) { passenger.Status = PassengerStatus.InStorage; Console.WriteLine($"{passId} is in terminal"); } } } // if came early then returns back to idle state else if (mes.Status == CheckInStatus.Early) { if (waitingForResponsePassengers.TryRemove(passId, out var passenger)) { Console.WriteLine($"{passId} has come too early for {passenger.FlightId} registration"); if (idlePassengers.TryAdd(passenger.PassengerId, passenger)) { Console.WriteLine($"{passId} goes away to come back later"); } } } // if registered then he waits for placing in terminal else if (mes.Status == CheckInStatus.Registered) { var passenger = waitingForResponsePassengers[passId]; passenger.Status = PassengerStatus.Registered; Console.WriteLine($"{passId} has been registered for {passenger.FlightId}"); } // else disappears else { if (waitingForResponsePassengers.TryRemove(passId, out var passenger)) { var action = ""; switch (mes.Status) { case CheckInStatus.Late: action = "is not really punctual"; break; case CheckInStatus.LateForTerminal: action = "loves duty free!!!!!!!!!"; break; case CheckInStatus.NoSuchFlight: action = "goes away puzzled forever"; break; case CheckInStatus.WrongTicket: action = "has missed something. Police will figure it out"; break; } Console.WriteLine($"{passId} {action} - {mes.Status}"); } } }