コード例 #1
0
        public void ValidateForBdf()
        {
            // 72 bytes are available for:	patientname     patientcode     birthdate   patient_additional + 3 commas
            // 42 bytes are available for:	admincode       technician      equipment   recording_additional + 3 commas
            // Birthdate takes 10 bytes.
            // Recording additional is reserved 4 bytes

            if ((SubjectName.Length + SubjectCode.Length + SubjectAdditional.Length) > NumberSubjectCharsAvailable)
            {
                int count = NumberSubjectCharsAvailable;
                SubjectName       = SubjectName.Substring(0, count);
                count            -= SubjectName.Length;
                SubjectCode       = SubjectCode.Substring(0, count);
                count            -= SubjectCode.Length;
                SubjectAdditional = SubjectAdditional.Substring(0, count);
            }

            if (AdminCode.Length + Technician.Length + Device.Length > NumberTechnicianCharsAvailable)
            {
                int count = NumberTechnicianCharsAvailable;
                AdminCode  = AdminCode.Substring(0, count);
                count     -= AdminCode.Length;
                Technician = Technician.Substring(0, count);
                count     -= Technician.Length;
                Device     = Device.Substring(0, count);
            }
        }
コード例 #2
0
        private int Save(DeptEditVM.EditInput input, bool changeDeptFunc)
        {
            Dept dept;

            if (input.Id == 0)
            {
                dept       = new Dept();
                dept.Corp  = GetLoginCorp();
                dept.Funcs = new DomainList <Func>();
            }
            else
            {
                dept = DeptBD.Get(input.Id);
            }
            if (!AdminCode.Equals(dept.Code, StringComparison.OrdinalIgnoreCase))
            {
                dept.Code = input.Code;
            }
            dept.Name = input.Name;
            if (IsAdmin() && changeDeptFunc)
            {
                dept.Funcs.Clear();
                if (!string.IsNullOrEmpty(input.DeptFuncIds))
                {
                    Array.ForEach(input.DeptFuncIds.Split(','), o => dept.Funcs.Add(FuncBD.Get(int.Parse(o))));
                }
            }
            DeptBD.Save(dept);
            return(dept.Id);
        }
コード例 #3
0
 public void Delete(AdminCode delObj)
 {
     using (var session = GetSession())
     {
         using (var trans = session.BeginTransaction())
         {
             session.Delete(delObj);
             trans.Commit();
         }
     }
 }
コード例 #4
0
 public bool ValidateStrings()
 {
     if (SessionName.All(c => Char.IsLetterOrDigit(c) || c.Equals('_') || c.Equals(' ')) &&
         SubjectName.All(c => Char.IsLetterOrDigit(c) || c.Equals('_') || c.Equals(' ')) &&
         SubjectCode.All(c => Char.IsLetterOrDigit(c) || c.Equals('_') || c.Equals(' ')) &&
         SubjectAdditional.All(c => Char.IsLetterOrDigit(c) || c.Equals('_') || c.Equals(' ')) &&
         AdminCode.All(c => Char.IsLetterOrDigit(c) || c.Equals('_') || c.Equals(' ')) &&
         Technician.All(c => Char.IsLetterOrDigit(c) || c.Equals('_') || c.Equals(' ')))
     {
         return(true);
     }
     return(false);
 }
コード例 #5
0
        public IActionResult Authenticate([Bind("Code")] AdminCode adminCode)
        {
            if (ModelState.IsValid)
            {
                if (adminCode.Code == adminSecret)
                {
                    return(RedirectToAction("Index"));
                }
            }

            TempData["message"] = "Invalid admin code. Access denied";
            return(View(adminCode));
        }
コード例 #6
0
 public void Save(AdminCode saveObj)
 {
     using (var session = GetSession())
     {
         using (var trans = session.BeginTransaction())
         {
             session.FlushMode = FlushMode.Commit;
             session.SaveOrUpdate(saveObj);
             trans.Commit();
             session.Flush();
             //}
         }
     }
 }
コード例 #7
0
        private void Save(UserEditVM.EditInput input)
        {
            User user;

            if (input.Id == 0)
            {
                user          = new User();
                user.Corp     = GetLoginCorp();
                user.Password = DefaultPassword;
                user.Funcs    = new DomainList <Func>();
            }
            else
            {
                user = UserBD.Get(input.Id);
            }
            if (IsAdmin(user))
            {
                throw new AuthFailureException();
            }
            user.Dept = input.Dept.ToReferencedDO(DeptBD);
            if (!AdminCode.Equals(user.Code, StringComparison.OrdinalIgnoreCase))
            {
                user.Code = input.Code;
            }
            user.Name     = input.Name;
            user.IsActive = input.IsActive;
            if (user != GetLoginUser())
            {
                if (CanAccess("_ChangeUserFunc"))
                {
                    user.Funcs.Clear();
                    if (!string.IsNullOrEmpty(input.UserFuncIds))
                    {
                        Array.ForEach(input.UserFuncIds.Split(','), o => user.Funcs.Add(FuncBD.Get(int.Parse(o))));
                    }
                }
            }
            UserBD.Save(user);
        }