public virtual void Reset(ResetLocation resetLocation = ResetLocation.Start)
 {
     LastTriggerID        = new Guid();
     GetProgress          = resetLocation == ResetLocation.Start ? 0f : 1f;
     _CurrentTriggerIndex = 0;
 }
示例#2
0
        public ResultInfo RequireResetLocation(string user, string token, string agency, string address)
        {
            var result = new ResultInfo()
            {
                id  = "0",
                msg = ""
            };

            try
            {
                if (!mongoHelper.checkLoginSession(user, token))
                {
                    throw new Exception("Tài khoản đã có người đăng nhập");
                }

                var checkAgency = db.CInfoCommons.Where(p => p.CCode == agency).FirstOrDefault();

                if (checkAgency == null)
                {
                    throw new Exception("Sai thông tin");
                }

                var checkStaff = db.HaiStaffs.Where(p => p.UserLogin == user).FirstOrDefault();

                if (checkStaff == null)
                {
                    throw new Exception("Sai thông tin");
                }

                var checkExsit = db.ResetLocations.Where(p => p.AgencyCode == agency && p.UserLogin == user && p.IsAppove == 0).FirstOrDefault();

                if (checkExsit != null)
                {
                    throw new Exception("Đã gửi yêu cầu, đang đợi hệ thống xác nhận");
                }

                var locationReset = new ResetLocation()
                {
                    Id          = Guid.NewGuid().ToString(),
                    AgencyCode  = checkAgency.CCode,
                    UserLogin   = user,
                    CreateDate  = DateTime.Now,
                    IsAppove    = 0,
                    NewLocation = address,
                    StaffId     = checkStaff.Id
                };

                var checkLastUpdate = db.ResetLocations.Where(p => p.AgencyCode == agency).OrderByDescending(p => p.CreateDate).FirstOrDefault();

                if (checkLastUpdate != null)
                {
                    locationReset.OldLocation = checkLastUpdate.NewLocation;
                }
                else
                {
                    locationReset.OldLocation = checkAgency.AddressInfo;
                }

                db.ResetLocations.Add(locationReset);

                db.SaveChanges();
            }
            catch (Exception e)
            {
                result.id  = "0";
                result.msg = e.Message;
            }

            result.id = "1";

            return(result);
        }