public DCUser2 AuthenticateUser(string sessionid, string username, string pwd, string pwdattempts) { UserBiz m_ubiz = new UserBiz(); User2Detail dtuser = null; DCUser2 dcusr = null; GroupBiz m_gbiz = new GroupBiz(); try { dtuser = m_ubiz.AuthenticateUser(CryptoUtils.DecryptTripleDES(username), CryptoUtils.DecryptTripleDES(pwd), GMConvert.GetInt16(CryptoUtils.DecryptTripleDES(pwdattempts))); if (dtuser != null && dtuser.LastLogon.HasValue) { dtuser.Permissions = new List <int>(); List <Int32> groups = m_ubiz.GetGroups(dtuser.ID); foreach (int group in groups) { dtuser.Permissions.AddRange(m_gbiz.GetPermissions(group)); } dcusr = new DCUser2(); GMReflectionUtils.Copy(dtuser, dcusr); SetCache(sessionid, dcusr); } } catch (Exception exp) { throw exp; } finally { m_ubiz.Dispose(); m_gbiz.Dispose(); } return(dcusr); }
public void Get(DCUser2 dcusr) { GroupBiz gbiz = new GroupBiz(); try { GMUtilities.GMReflectionUtils.Copy(m_biz.Get(dcusr.ID), dcusr); dcusr.DSUNSelected = gbiz.Get(); dcusr.DSTypeID = m_optbiz.GetEmployeeTypes(GetCache(dcusr.SessionID).ID); dcusr.DSDepartmentID = m_optbiz.GetDeparmentTypes(); if (dcusr.ID.HasValue) { dcusr.DSSelected = GMUtilities.DataUtils.DetachSelection(dcusr.DSUNSelected, m_biz.GetGroups(dcusr.ID)); } } catch (Exception exp) { throw exp; } finally { gbiz.Dispose(); } }
public void Test_GroupBiz_Search() { //Init Data List <GroupMaster> groups = new List <GroupMaster>(); groups.Add(new GroupMaster() { Name = "Group A", Description = "Description A" }); groups.Add(new GroupMaster() { Name = "Group B", Description = "Description B" }); //Setup Mock Mock <IDataBox <GroupMaster> > mockGroups = new Mock <IDataBox <GroupMaster> >(); mockGroups.Setup(g => g.Queryable()).Returns(groups.AsQueryable()); Mock <IDataBoxes> mockDataBoxes = new Mock <IDataBoxes>(); mockDataBoxes.Setup(d => d.Groups).Returns(mockGroups.Object); //Arrange GroupBiz biz = new GroupBiz(mockDataBoxes.Object); //Act SearchResult result = biz.Search(new SearchInfo() { search = new DtSearch() { value = "B" }, start = 0, length = 10 }); //Assert Assert.AreEqual(1, result.data.Length); GroupInfo[] groupInfos = result.data as GroupInfo[]; Assert.AreEqual(groups.First().Name, groupInfos.First().Name); mockGroups.VerifyAll(); mockDataBoxes.VerifyAll(); }
public Group() : base() { m_biz = new GroupBiz(); }