internal CheckInResult CheckIn(Workspace workspace, List <PendingChange> changes, string comment, Dictionary <int, WorkItemCheckinAction> workItems) { var invoker = new SoapInvoker(this); var msg = invoker.CreateEnvelope("CheckIn"); msg.Add(new XElement(MessageNs + "workspaceName", workspace.Name)); msg.Add(new XElement(MessageNs + "ownerName", workspace.OwnerName)); msg.Add(new XElement(MessageNs + "serverItems", changes.Select(x => x.ServerItem).Distinct().Select(s => new XElement(MessageNs + "string", s)))); msg.Add(new XElement(MessageNs + "info", new XAttribute("date", new DateTime(0).ToString("s")), new XAttribute("cset", 0), new XAttribute("owner", workspace.OwnerName), new XElement(MessageNs + "Comment", comment), new XElement(MessageNs + "CheckinNote", string.Empty), new XElement(MessageNs + "PolicyOverride", string.Empty))); if (workItems != null && workItems.Count > 0) { msg.Add(new XElement(MessageNs + "checkinNotificationInfo", new XElement(MessageNs + "WorkItemInfo", workItems.Select(wi => new XElement(MessageNs + "CheckinNotificationWorkItemInfo", new XElement(MessageNs + "Id", wi.Key), new XElement(MessageNs + "CheckinAction", wi.Value)))))); } var response = invoker.InvokeResponse(); var resultElement = invoker.MethodResultExtractor(response); var result = CheckInResult.FromXml(resultElement); result.Failures = FailuresExtractor(response); return(result); }
public ActionResult CheckIn(int itemId, int storeId, int count) { Store store = _StoreRepository.GetById(storeId); CheckInResult result = _InventoryItemRepository .GetById(itemId) .CheckInInventoryItemHandlindDifferentExceptions(store, count); return(result.Success ? Ok(result.Item) : BadRequest(result.Error) as ObjectResult); }
public string CheckIn([FromBody] CheckInInput input) { //getting the vehicle object according to its input Vehicle vehicle = VehicleFactory.GetVehicle(input.VehicleType, input.LicensePlateID, int.Parse(input.Width) , int.Parse(input.Height), int.Parse(input.Length)); bool rankIsValid = Enum.TryParse(input.TicketType, out TicketRank rank); //validate the rank and vehicle type if (vehicle == null || !rankIsValid) { return(ReturnBadRequest("Invalid Input")); } Driver driver = new Driver(input.Name, input.Phone); CheckInResult ticketInfo = garage.CheckIn(vehicle, rank, driver); return(System.Text.Json.JsonSerializer.Serialize(ticketInfo)); }
public CheckInResult CheckIn(string user, string token, string agencyId) { var log = new MongoHistoryAPI() { APIUrl = "/api/calendar/checkin", CreateTime = DateTime.Now, Sucess = 1 }; var result = new CheckInResult() { id = "1", msg = "success" }; try { if (!mongoHelper.checkLoginSession(user, token)) { throw new Exception(MRes.MSG_WRONG_TOKEN); } var checkStaff = db.MStaffs.Where(p => p.MUser == user).FirstOrDefault(); if (checkStaff == null) { throw new Exception("Sai thông tin"); } var checkAgency = db.MAgencies.Find(agencyId); if (checkAgency == null) { throw new Exception("Sai đại lý"); } var dateCode = DateTime.Now.ToString("ddMMyyyy"); var checkWork = db.CalendarWorks.Where(p => p.AgencyId == agencyId && p.StaffId == checkStaff.Id && p.CDate == dateCode).FirstOrDefault(); if (checkWork == null) { var work = new CalendarWork() { AgencyId = agencyId, CDate = dateCode, CDay = DateTime.Now.Day, ChangeTime = DateTime.Now, CMonth = DateTime.Now.Month, CountWork = 1, CYear = DateTime.Now.Year, FistTime = DateTime.Now, Id = Guid.NewGuid().ToString(), Perform = 0, StaffId = checkStaff.Id, DayOfWeek = mapDayOfWeeks[DateTime.Now.DayOfWeek] }; db.CalendarWorks.Add(work); db.SaveChanges(); result.perform = 0; result.workId = work.Id; result.des = "Ghé thăm lúc " + DateTime.Now.ToString("HH:mm") + " ngày " + DateTime.Now.ToString("dd/MM/yyyy"); } else { result.perform = checkWork.Perform; result.workId = checkWork.Id; result.des = "Ghé thăm giần nhất lúc " + checkWork.ChangeTime.Value.ToString("HH:mm") + " ngày " + checkWork.ChangeTime.Value.ToString("dd/MM/yyyy"); checkWork.ChangeTime = DateTime.Now; db.Entry(checkWork).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } catch (Exception e) { result.id = "0"; result.msg = e.Message; log.Sucess = 0; } log.ReturnInfo = new JavaScriptSerializer().Serialize(result); mongoHelper.createHistoryAPI(log); return(result); }
private void InitOrRestoreCheckInResult() { // 1. create new checkInResult from users.json CheckInResult newCheckInResult = null; List <User> users = LoadCheckInList(); if (users != null) { newCheckInResult = new CheckInResult(); foreach (User user in users) { if (newCheckInResult.Users == null) { newCheckInResult.Users = new UserCheckInList(); } if (!newCheckInResult.Users.ContainsKey(user.UserId)) { UserCheckIn userCheckIn = new UserCheckIn() { User = user, CheckInDateTime = DateTime.MinValue, CheckInStatus = false }; newCheckInResult.Users.Add(user.UserId, userCheckIn); } else { _logger.Warn(user.UserId + " is duplicate."); } } } // 2. recover data from history (if have). CheckInResult historyCheckInResult = null; if (System.IO.File.Exists(Configs.ConfigManager.CheckInResultFullPath)) { string json = System.IO.File.ReadAllText(Configs.ConfigManager.CheckInResultFullPath); if (string.IsNullOrEmpty(json)) { _logger.Warn(Configs.ConfigManager.CheckInResultFullPath + " is empty."); } else { try { historyCheckInResult = JsonConvert.DeserializeObject <CheckInResult>(json); _logger.Info(Configs.ConfigManager.CheckInResultFullPath + " loaded."); } catch (Exception ex) { _logger.Warn("load checkInResult with mistake. " + Configs.ConfigManager.CheckInResultFullPath + " " + ex.ToString()); } } } if (historyCheckInResult != null && historyCheckInResult.Users != null) { foreach (var userCheckInPair in historyCheckInResult.Users) { string userId = userCheckInPair.Key; if (newCheckInResult.Users.ContainsKey(userId)) { newCheckInResult.Users[userId] = historyCheckInResult.Users[userId]; } } } this.CheckInResult = newCheckInResult; }