Ejemplo n.º 1
0
        public ActionResult Checkin(MainPageViewModel model)
        {
            CheckinModel newCheckin = new CheckinModel();
            var          UserId     = System.Web.HttpContext.Current.User.Identity.GetUserId();

            newCheckin.UserId      = UserId;
            newCheckin.Active      = true;
            newCheckin.CheckinTime = DateTime.Now;
            newCheckin.Latitude    = model.Checkin.Latitude;
            newCheckin.Longitude   = model.Checkin.Longitude;
            //Only one active checkin per user at a time
            try
            {
                foreach (var row in db.Checkin)
                {
                    if (row.UserId == UserId && row.Active == true)
                    {
                        row.Active = false;
                    }
                }
            }
            catch
            { }
            db.Checkin.Add(newCheckin);
            db.SaveChanges();
            return(RedirectToAction("ViewActivities"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CheckIn(long venueId, CheckinModel model)
        {
            var venue = await _dbContext.Venues.SingleOrDefaultAsync(x => x.Id == venueId);

            ViewBag.VenueName = venue.DisplayName;

            if (string.IsNullOrWhiteSpace(model.Name) && string.IsNullOrWhiteSpace(model.Email) && string.IsNullOrWhiteSpace(model.PhoneNumber))
            {
                ModelState.AddModelError(nameof(model.Name), "At least one detail must be provided");
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var checkin = new Checkin
            {
                CheckinAtUtc        = DateTime.UtcNow,
                VenueId             = venueId,
                IpAddress           = Request.HttpContext.Connection.RemoteIpAddress.ToString(),
                UserAgent           = Request.Headers["user-agent"],
                SuppliedEmail       = model.Email,
                SuppliedName        = model.Name,
                SuppliedPhoneNumber = model.PhoneNumber
            };

            _dbContext.Checkins.Add(checkin);

            await _dbContext.SaveChangesAsync();

            return(RedirectToAction("Thanks", new{ venueId, checkinId = checkin.Id }));
        }
Ejemplo n.º 3
0
        public IActionResult ProfileDetails()
        {
            var userId = Convert.ToInt32(HttpContext.User.FindFirstValue("ID"));
            List <CheckinModel> checkinModels = new List <CheckinModel>();
            List <Checkin>      checkins      = _checkinService.GetAllByUserID(userId);

            foreach (Checkin checkin in checkins)
            {
                Beer         beer         = _beerService.GetOne(checkin.BeerID);
                CheckinModel checkinModel = new CheckinModel(checkin, beer);
                checkinModels.Add(checkinModel);
            }
            return(View(checkinModels));
        }
Ejemplo n.º 4
0
        public void CheckinRG_HappyPath()
        {
            //Arrange
            var rgEquip = TestData.Data.RgTestRg4Checkin();
            Assert.IsTrue(rgEquip.Any());
            var serialNumber = rgEquip.First().SerialNumber.Substring(0, rgEquip.First().SerialNumber.Length - 3);
            var checkinModel = new CheckinModel { SerialNumber = serialNumber };

            //Act
            var result = CheckinController.CheckinItem(checkinModel) as PartialViewResult ?? new PartialViewResult();

            //Assert 1
            Assert.IsNotNull(result, "Result is null.");

            //Assert 2
            Assert.IsNotNull(result.Model, "Result.Model is null.");

            //Assert 3
            Assert.AreEqual(string.Format("Successfully checked in device {0}", checkinModel.SerialNumber), ((TransactionListModel) result.Model).ResultMessage.Message);
        }
Ejemplo n.º 5
0
        public async Task <Response <int> > CheckinAsync([FromBody] CheckinModel model)
        {
            var user = await userManager.GetUserAsync(User);

            if (user is null)
            {
                return(new Response <int> .Error.Unauthorized("未登录账户"));
            }

            var workPlan = await dbContext.Plans.FirstOrDefaultAsync(i => i.Id == model.WorkPlanId);

            if (workPlan is null)
            {
                return(new Response <int> .Error.NotFound("不存在此项工作"));
            }

            if (await dbContext.Records.AnyAsync(i => i.WorkPlanId == model.WorkPlanId && i.UserId == user.Id))
            {
                return(new Response <int> .Error.BadRequest("已存在签到记录"));
            }

            if (workPlan.MaxUsers is > 0 && await dbContext.Records.CountAsync(i => i.WorkPlanId == model.WorkPlanId) > workPlan.MaxUsers)
            {
                return(new Response <int> .Error.BadRequest("超过最大允许的签到人数"));
            }

            var record = new CheckinRecord
            {
                Note            = model.Note,
                UserId          = user.Id,
                WorkPlanId      = model.WorkPlanId,
                Overtime        = model.Overtime,
                OvertimeMinutes = model.OvertimeMinutes
            };

            await dbContext.Records.AddAsync(record);

            await dbContext.SaveChangesAsync();

            return(record.Id);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> PostCheckInTransactionAsync([FromBody] CheckinModel obj)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var response = await _transactionService.AddCheckInTransactionAsync(obj);

            _responseModel.Status  = response.Status;
            _responseModel.Message = response.Message;

            if (_responseModel.Status)
            {
                return(Ok(_responseModel));
            }
            else
            {
                return(BadRequest(_responseModel));
            }
        }
Ejemplo n.º 7
0
        public void ParseInfo()
        {
            DialogResult pwarming = MessageBox.Show("Do you want to load new model?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (pwarming == DialogResult.Yes)
            {
                //code for Yes
            }
            else if (pwarming == DialogResult.No)
            {
                return;
            }

            pif.ClearAll();
            JObject results = JObject.Parse(contents);

            foreach (var result in results["haftpoints"])
            {
                string Name   = (string )result["Name"];
                string label  = (string )result["Label"];
                double Width  = (double)result["Width"];
                double Height = (double)result["Width"];
                int    posx   = (int)result["posX"];
                int    posy   = (int)result["posY"];
                loadpoint(Name, label, new Point(posx, posy), Width, Height);
            }
            foreach (var result in results["stations"])
            {
                string       Name        = (string )result["Name"];
                string       label       = (string )result["Label"];
                string       _type       = (string )result["Type"];
                int          posx        = (int)result["posX"];
                int          posy        = (int)result["posY"];
                string       stationID   = (string )result["stationID"];
                string       stationIP   = (string )result["stationIP"];
                string       stationPORT = (string )result["stationPort"];
                string       stationAREA = (string )result["stationArea"];
                StationModel pstation    = new StationModel(pif.content, _type);
                pstation.SetNameID(Name);
                pstation.SetPosition(posx, posy);
                pstation.SetKeyAndLabel(label);
                pstation.SetLabel(label);
                pstation.Load_StationProperties(result);
                pstation.lineInfo.loadparams(result["lineInfo"]);
                if (_type.Equals("DOCKING"))
                {
                    pstation.CreateCameraAgentD();
                }
                else if (_type.Equals("PUTAWAY"))
                {
                    pstation.CreateCameraAgentP();
                }
                else if (_type.Equals("MIXED"))
                {
                    pstation.CreateCameraAgentM();
                }
                RegistrationAgent.stationRegistrationList.Add(pstation);
                pif.updateTreeviewStations(pstation.properties.NameKey);
            }
            foreach (var result in results["checkins"])
            {
                string       Name     = (string)result["Name"];
                string       label    = (string)result["Label"];
                string       _type    = (string)result["Type"];
                int          posx     = (int)result["posX"];
                int          posy     = (int)result["posY"];
                CheckinModel pcheckin = new CheckinModel(pif.content, _type);
                pcheckin.setName(Name);
                pcheckin.setCheckin(posx, posy);
                pcheckin.setText(label);
                pcheckin.lineInfo.loadparams(result["lineInfo"]);
                //pstation.SetCamParam(stationID, stationIP, stationPORT, stationAREA);
                RegistrationAgent.checkinRegistrationList.Add(pcheckin);
                pif.updateTreeviewStations(pcheckin.props.NameKey);
            }
            foreach (var result in results["checkouts"])
            {
                string        Name      = (string)result["Name"];
                string        label     = (string)result["Label"];
                string        _type     = (string)result["Type"];
                int           posx      = (int)result["posX"];
                int           posy      = (int)result["posY"];
                CheckoutModel pcheckout = new CheckoutModel(pif.content, _type);
                pcheckout.setName(Name);
                pcheckout.setCheckout(posx, posy);
                pcheckout.setText(label);
                pcheckout.lineInfo.loadparams(result["lineInfo"]);
                //pstation.SetCamParam(stationID, stationIP, stationPORT, stationAREA);
                RegistrationAgent.checkoutRegistrationList.Add(pcheckout);
                pif.updateTreeviewStations(pcheckout.props.NameKey);
            }
            foreach (var result in results["robotconfig"])
            {
                string Name             = (string )result["NameObj"];
                string IpAddress        = (string )result["IpAddress"];
                string Hostname         = (string )result["Hostname"];
                double CriticalEnergyAt = (double)result["CriticalEnergyAt"];
                double GoodEnergyAt     = (double)result["GoodEnergyAt"];
                int    Port             = (int)result["Port"];
                double px = (double)result["InitialPosX"];
                double py = (double)result["InitialPosY"];
                double initialheadingangle = (double)result["InitialPosY"];
                loadrobotconfig(IpAddress, Hostname, Name, Port, CriticalEnergyAt, GoodEnergyAt, new System.Windows.Point(px, py), initialheadingangle);
            }
            foreach (var result in results["paths"])
            {
                string Name     = (string )result["Name"];
                int    typepath = (int)result["Type"];

                dynamic startPoint = result["startPoint"];
                string  Name_sp    = startPoint.Name;
                double  posx_sp    = startPoint.X;
                double  posy_sp    = startPoint.Y;

                double posx_mp = 0;
                double posy_mp = 0;
                if (typepath == PathModel.PATH_TYPE_BEZIERSEGMENT)
                {
                    dynamic middlePoint = result["middlepoint"];
                    string  Name_mp     = middlePoint.Name;
                    posx_mp = middlePoint.X;
                    posy_mp = middlePoint.Y;
                }
                dynamic endPoint = result["endPoint"];
                string  Name_ep  = endPoint.Name;
                double  posx_ep  = endPoint.X;
                double  posy_ep  = endPoint.Y;
                if (typepath == PathModel.PATH_TYPE_BEZIERSEGMENT)
                {
                    loadpath_bezier(Name, Name_sp, Name_ep, new System.Windows.Point(posx_sp, posy_sp), new System.Windows.Point(posx_mp, posy_mp), new System.Windows.Point(posx_ep, posy_ep));
                }
                if (typepath == PathModel.PATH_TYPE_DIRECT)
                {
                    loadpath_direct(Name, Name_sp, Name_ep, new System.Windows.Point(posx_sp, posy_sp), new System.Windows.Point(posx_ep, posy_ep));
                }
            }
        }