public IdentityGroup GetGroup(int groupId) { var identityGroup = new IdentityGroup(); if (groupId != 0) { var GroupDs = _masterGroupDataAccess.GetIdentityGroup(groupId); var GroupRightDs = _masterGroupDataAccess.GetIdentityGroupRights(groupId); identityGroup = GroupDs.Tables[0].ToModel <IdentityGroup>(); var GroupRightLlist = GroupRightDs.Tables[0].ToList <IdentityGroupRight>(); foreach (var item in GroupRightLlist) { item.SetBooleanRights(item.Action); } identityGroup.GroupRight = GroupRightLlist; } else { var RightDs = _masterGroupDataAccess.GetIdentityRightList(); var RightObj = RightDs.Tables[0].ToList <IdentityRight>(); foreach (var item in RightObj) { var temp = new IdentityGroupRight(); temp.Action = 4; //Set read right by default temp.IsValid = true; temp.RightId = item.Id; temp.RightTitle = item.RightTitle; temp.SetBooleanRights(temp.Action); identityGroup.GroupRight.Add(temp); } } return(identityGroup); }
public IHttpActionResult Post([FromBody] IdentityGroup identityGroup) { var userCtx = base.GetUserContext(); _masterGroup.Save(identityGroup, userCtx); return(Ok()); }
public async Task <bool> CreateAsync() { GroupStore <IdentityGroup> store = new GroupStore <IdentityGroup>(); var gm = new GroupManager <IdentityGroup>(store); var newGroup = new IdentityGroup("testgroup"); await gm.CreateAsync(newGroup); return(true); }
public void Save(IdentityGroup identityGroup, UserContext userCtx) { if (identityGroup.Id == 0) { _masterGroupRepository.SaveIdentityGroup(identityGroup, userCtx); } else { _masterGroupRepository.UpdateIdentityGroup(identityGroup, userCtx); } }
public void TestGroupStores() { GroupStore <IdentityGroup> store = new GroupStore <IdentityGroup>(); var gm = new GroupManager <IdentityGroup>(store); var newGroup = new IdentityGroup("testgroup"); gm.Create(newGroup); var result = CreateAsync().Result; Assert.AreEqual(true, result); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((null != context) && (null != provider)) { _editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); IdentityGroup idg = null; // Note - context.Instance may be either a DSL shape or the underlying domain class // so if we add a shape we need to look up the underlying domain class here idg = context.Instance as IdentityGroup; if (null == idg) { IdentityGroupGeometryShape idgs = null; idgs = context.Instance as IdentityGroupGeometryShape; if (null != idgs) { idg = idgs.ModelElement as IdentityGroup; } } if (null != idg) { // Create a listbox to hold all the identifier group names in the parent projection ListBox lb = new ListBox(); lb.SelectionMode = SelectionMode.One; lb.SelectedValueChanged += OnListBoxSelectedValueChanged; // Add an Empty item for an identifier group that has no parent lb.Items.Add(""); foreach (string idgName in idg.AggregateIdentifier.GetIdentityGroupNames()) { lb.Items.Add(idgName); } if (!lb.Items.Contains(@"All")) { // Add the global lb.Items.Add(@"All"); } _editorService.DropDownControl(lb); if (lb.SelectedItem == null) // no selection, return the passed-in value as is { return(value); } return(lb.SelectedItem); } } return(base.EditValue(context, provider, value)); }
public void TestFindGroup() { var gstore = new GroupStore <IdentityGroup>(); var gm = new GroupManager <IdentityGroup>(gstore); var gr = gm.FindByName("group3"); if (gr == null) { gr = new IdentityGroup("group3"); gm.Create(gr); } var res = gm.FindById(gr.Id); }
public void TestIdentityGroup() { // Arange var group = new IdentityGroup(); var group2 = new IdentityGroup("testGroup"); //var group3 = new IdentityGroup<string, IdentityGroupRole<string>>(); //group3.Id = "3"; Assert.IsNotNull(group); Assert.IsNotNull(group2); //Assert.IsNotNull(group3); }
public void TestGroupStores2() { var ctx = new IdentityDbContext(); //var store = new GroupStore<IdentityGroup<string, IdentityGroupRole<string>>, string, IdentityGroupRole<string>>(ctx); //IdentityGroup<string, IdentityGroupRole<string>>, string, IdentityUser, IdentityGroupRole<string>>(ctx); var gr = new IdentityGroupRole <string>(); //var group = new IdentityGroup<string, IdentityGroupRole<string>>(); //var gm = new GroupManager<IdentityGroup<string, IdentityGroupRole<string>>, string>(store); var newGroup = new IdentityGroup("testgroup2"); //gm.Create(group); var result = CreateAsync().Result; Assert.AreEqual(true, result); }
public void UpdateIdentityGroup(IdentityGroup identityGroup, UserContext userCtx) { identityGroup.UpdatedBy = userCtx.UserId; identityGroup.UpdatedOn = DateTime.Now.ToMySqlDateString(); _masterGroupDataAccess.UpdateIdentityGroup(identityGroup); foreach (var item in identityGroup.GroupRight) { item.UpdatedBy = userCtx.UserId; item.UpdatedOn = DateTime.Now.ToMySqlDateString(); item.SetDecimalRights(); } var XmlString = Helper.ObjectToXml(identityGroup.GroupRight); _masterGroupDataAccess.UpdateIdentityGroupRight(XmlString); }
public void UpdateIdentityGroup(IdentityGroup ObjIdentityGroup) { var sqlparam = new MySqlSpParam(); sqlparam.StoreProcedureName = AppConstants.StoreProcedure.spIdentityGroup_Update; sqlparam.StoreProcedureParam = new MySqlParameter[] { new MySqlParameter("@GroupId", ObjIdentityGroup.Id), new MySqlParameter("@grpn", ObjIdentityGroup.GroupName), new MySqlParameter("@groupdesc", ObjIdentityGroup.GroupDescription), new MySqlParameter("@valid", ObjIdentityGroup.IsValid), new MySqlParameter("@updatedby", ObjIdentityGroup.UpdatedBy), new MySqlParameter("@updatedon", ObjIdentityGroup.UpdatedOn) }; DataAccessHelper.ExecuteNonQuery(sqlparam.ToSqlCommand(), sqlparam.StoreProcedureParam); }
public DataSet InsertIdentityGroup(IdentityGroup ObjIdentityGroup) { var sqlparam = new MySqlSpParam(); sqlparam.StoreProcedureName = AppConstants.StoreProcedure.spIdentityGroup_Insert; sqlparam.StoreProcedureParam = new MySqlParameter[] { new MySqlParameter("@groupName", ObjIdentityGroup.GroupName), new MySqlParameter("@groupDesc", ObjIdentityGroup.GroupDescription), new MySqlParameter("@isValid", ObjIdentityGroup.IsValid), new MySqlParameter("@createdBy", ObjIdentityGroup.CreatedBy), new MySqlParameter("@createdOn", ObjIdentityGroup.CreatedOn) }; var ds = DataAccessHelper.ExecuteQuery(sqlparam.ToSqlCommand(), sqlparam.StoreProcedureParam); return(ds); }
public void SaveIdentityGroup(IdentityGroup identityGroup, UserContext userCtx) { identityGroup.CreatedBy = userCtx.UserId; identityGroup.CreatedOn = DateTime.Now.ToMySqlDateString(); var ds = _masterGroupDataAccess.InsertIdentityGroup(identityGroup); var LatestId = ds.Tables[0].ToId(); foreach (var item in identityGroup.GroupRight) { item.GroupId = LatestId; item.CreatedBy = userCtx.UserId;; item.CreatedOn = DateTime.Now.ToMySqlDateString(); item.IsValid = true; item.SetDecimalRights(); } var XmlString = Helper.ObjectToXml(identityGroup.GroupRight); _masterGroupDataAccess.InsertIdentityGroupRight(XmlString); }
/// <summary> /// Function to check Access on module /// </summary> /// <param name="moduleId">Id of the Module</param></param> public bool CheckModuleAccessOverLoad(eModule moduleId) { //GlobalConstants.cAccessPermissionKey is the access permission key for all the modules //PermissionEntity oPermissionEntity=new PermissionEntity((long)moduleId,-1,-1,-1); PermissionEntity oPermissionEntity = new PermissionEntity(); oPermissionEntity.Module = (long)moduleId; oPermissionEntity.Instance = -1; oPermissionEntity.Entity = -1; oPermissionEntity.SubEntity = -1; //IdentityGroup oIdentityGroup=new IdentityGroup(User.Profile.UserID,-1,IdentityType.User); IdentityGroup oIdentityGroup = new IdentityGroup(); oIdentityGroup.User = User.Profile.UserID; oIdentityGroup.Group = -1; oIdentityGroup.Type = IdentityType.User; return(FwkApplication.GetInstance().AuthorizationManager.CheckPermissionDetails(oPermissionEntity, oIdentityGroup, GlobalConstants.cAccessPermissionKey)); }
public void TestUser() { //var ctx = new IdentityDbContext(); var store = new UserStore <IdentityUser>(); var usr = new IdentityUser("usertest2"); var um = new UserManager <IdentityUser>(store); var gr = new IdentityGroup("group3"); var gstore = new GroupStore <IdentityGroup>(); var gm = new GroupManager <IdentityGroup>(gstore); if (!gm.Create(gr).Succeeded) { gm.FindByName("group3"); } if (!um.Create(usr).Succeeded) { usr = um.FindByName("usertest2"); } um.SetToGroup(usr.Id, "group3"); //um.Delete(usr); //gr.Name = "groupchange"; //gm.Update(gr); //gm.Delete(gr); }
public void TestGetGroupPerId() { var TestData = new IdentityGroup(); TestData.Id = 1; TestData.GroupName = "Super Admin"; TestData.GroupDescription = "Super Admin"; TestData.IsValid = true; TestData.CreatedBy = 1; TestData.CreatedOn = "2018-02-05"; TestData.UpdatedBy = 1; TestData.UpdatedOn = "2018-02-16"; TestData.CreatedByName = "Amol Wabale"; TestData.UpdatedByName = "Amol Wabale"; var TempIdentityGroupRight1 = new IdentityGroupRight(); TempIdentityGroupRight1.Id = 1; TempIdentityGroupRight1.GroupId = 1; TempIdentityGroupRight1.RightId = 1; TempIdentityGroupRight1.RightTitle = "Group"; TempIdentityGroupRight1.Action = 7; TempIdentityGroupRight1.IsValid = true; TempIdentityGroupRight1.CreatedBy = 1; TempIdentityGroupRight1.UpdatedBy = 1; TempIdentityGroupRight1.CreatedOn = "2018-02-02"; TempIdentityGroupRight1.UpdatedOn = "2018-02-16"; TempIdentityGroupRight1.CreatedByName = "Amol Wabale"; TempIdentityGroupRight1.UpdatedByName = "Amol Wabale"; TempIdentityGroupRight1.BooleanRight = new BooleanRights() { Delete = true, Read = true, Write = true }; TestData.GroupRight.Add(TempIdentityGroupRight1); var TempIdentityGroupRight2 = new IdentityGroupRight(); TempIdentityGroupRight2.Id = 14; TempIdentityGroupRight2.GroupId = 1; TempIdentityGroupRight2.RightId = 2; TempIdentityGroupRight2.RightTitle = "User Group"; TempIdentityGroupRight2.Action = 7; TempIdentityGroupRight2.IsValid = true; TempIdentityGroupRight2.CreatedBy = 1; TempIdentityGroupRight2.UpdatedBy = 1; TempIdentityGroupRight2.CreatedOn = "2018-02-02"; TempIdentityGroupRight2.UpdatedOn = "2018-02-16"; TempIdentityGroupRight2.CreatedByName = "Amol Wabale"; TempIdentityGroupRight2.UpdatedByName = "Amol Wabale"; TempIdentityGroupRight2.BooleanRight = new BooleanRights() { Delete = true, Read = true, Write = true }; TestData.GroupRight.Add(TempIdentityGroupRight2); var TempIdentityGroupRight3 = new IdentityGroupRight(); TempIdentityGroupRight3.Id = 15; TempIdentityGroupRight3.GroupId = 1; TempIdentityGroupRight3.RightId = 3; TempIdentityGroupRight3.RightTitle = "Employee"; TempIdentityGroupRight3.Action = 7; TempIdentityGroupRight3.IsValid = true; TempIdentityGroupRight3.CreatedBy = 1; TempIdentityGroupRight3.UpdatedBy = 1; TempIdentityGroupRight3.CreatedOn = "2018-02-02"; TempIdentityGroupRight3.UpdatedOn = "2018-02-16"; TempIdentityGroupRight3.CreatedByName = "Amol Wabale"; TempIdentityGroupRight3.UpdatedByName = "Amol Wabale"; TempIdentityGroupRight3.BooleanRight = new BooleanRights() { Delete = true, Read = true, Write = true }; TestData.GroupRight.Add(TempIdentityGroupRight3); MasterGroupController obj = new MasterGroupController(new MasterGroupService()); var ActualData = obj.Get(1); var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var expectedJson = serializer.Serialize(TestData); var actualJson = serializer.Serialize(ActualData); Assert.AreEqual(actualJson, expectedJson); }
/// <summary> /// 获取ID生成分组编码 /// </summary> /// <param name="group">分组信息</param> /// <returns></returns> public static string GetIdGroupCode(IdentityGroup group) { return(((int)group).ToString()); }