private List <Group> fillGroupList() { GroupBusiness _GroupBusiness = new GroupBusiness(); GroupList _GroupList = _GroupBusiness.SelectRows(null, null); return(_GroupList); }
private StringBuilder addGroupToXML(string uid) { #region GroupBusiness groupbusiness = new GroupBusiness(); GroupData groupdata = groupbusiness.GetGroupByUid(uid); StringBuilder FriendInf = new StringBuilder(); FriendInf.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); FriendInf.Append("<root>"); if (groupdata == null) { FriendInf.Append("<FriendGroup groupName=\"没有分组\"></FriendGroup>"); } else { for (int i = 0; i < groupdata.Tables[0].Rows.Count; i++) { FriendInf.Append("<FriendGroup groupName=\""); FriendInf.Append(groupdata.Tables[0].Rows[i][GroupData.groupName].ToString().Trim()); FriendInf.Append("\"></FriendGroup>"); } } FriendInf.Append("</root>"); return(FriendInf); #endregion }
/// <summary> /// 根据指定分组代码查找包含部门 /// </summary> /// <param name="groupCode">分组代码</param> /// <param name="include">是否包含子分组</param> /// <returns></returns> public IEnumerable <Department> FindInGroup(string groupCode, bool include) { var dal = this.baseDal as IDepartmentRepository; List <Department> data = new List <Department>(); GroupBusiness groupBusiness = new GroupBusiness(); var group = groupBusiness.FindByCode(groupCode); if (group == null) { return(data); } List <GroupItem> groupItems = new List <GroupItem>(); if (include) { groupItems.AddRange(groupBusiness.FindAllItems(group.Id)); } else { groupItems.AddRange(group.Items); } var departments = dal.FindWithIds(groupItems.Select(r => r.EntityId).ToList()); foreach (var item in groupItems.OrderBy(r => r.Sort)) { data.Add(departments.Single(r => r.Id == item.EntityId)); } return(data); }
public bool DeleteGroupfromDB(int id) { bool result = default(bool); BaseDataAccess _db = new BaseDataAccess(); using (DbTransaction dbTransaction = _db.CreateTransaction()) { try { // 1- Select User From DB by ID GroupBusiness groupBusiness = new GroupBusiness(); GroupList groupList = groupBusiness.SelectRows(id, null); if (groupList != null && groupList.Count > 0) { // 2- Select Group Functions From DB by Group ID GroupFunctionBusiness _GroupFunctionBusiness = new GroupFunctionBusiness(); GroupFunctionList groupFunctionList = _GroupFunctionBusiness.SelectRows(null, null, id); if (groupFunctionList != null && groupFunctionList.Count > 0) { // 3- Delete Group Functions first (we must remove children first because of DB relation) foreach (GroupFunction groupFunction in groupFunctionList) { _GroupFunctionBusiness = new GroupFunctionBusiness(); _GroupFunctionBusiness.DeleteRow(dbTransaction, groupFunction); } } // 4- Then Delete The Group itself groupBusiness = new GroupBusiness(); if (groupBusiness.DeleteRow(dbTransaction, groupList[0]) > 0) { dbTransaction.Commit(); result = true; } else { dbTransaction.Rollback(); throw new Exception("DataBase Operation Failure"); } } else { dbTransaction.Rollback(); throw new Exception("Group Id Not Found in DB"); } } catch (Exception) { dbTransaction.Rollback(); throw new Exception("DataBase Operation Failure"); } } return(result); }
public void GroupGetTest() { Guid userId = new Guid("1538694e-12f2-e111-a89d-00155d02e702"); int systemId = 219; var actual = GroupBusiness.Get(userId, systemId); Assert.IsTrue(actual.Count() > 0); }
public void GroupGetGroupDownTest() { Guid userId = new Guid("1538694e-12f2-e111-a89d-00155d02e702"); Guid groupSid = new Guid("aeab580d-df16-42d5-9714-e4e581fc8134"); int systemId = 102; var actual = GroupBusiness.GetGroupDown(userId, systemId, groupSid); Assert.IsTrue(actual.Count() > 0); }
public static IResultResponse GroupUpdete(SysParameter para) { try { int result = new GroupBusiness(para.dapperFactory).Update(para.Properties); return(ResultResponse.GetSuccessResult(result)); } catch (Exception ex) { return(ResultResponse.ExceptionResult(ex, 500)); } }
public static IResultResponse GroupDelete(SysParameter para) { try { int id = para.ToInt("Id"); int result = new GroupBusiness(para.dapperFactory).Delete(id); return(ResultResponse.GetSuccessResult(result)); } catch (Exception ex) { return(ResultResponse.ExceptionResult(ex, 500)); } }
public static IResultResponse GetGroupList(SysParameter para) { try { PagingQuery query = para.ToPagingQuery(); PagingResult result = new GroupBusiness(para.dapperFactory).GetGroupList(query); return(ResultResponse.GetSuccessResult(result)); } catch (Exception ex) { return(ResultResponse.ExceptionResult(ex, 500)); } }
public HttpResponseMessage Get(int systemId) { try { var result = GroupBusiness.GetGroupDown(claimData.UserId, systemId, claimData.GroupId); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception exc) { var logId = LogBusiness.Error(exc); return(Request.CreateResponse(HttpStatusCode.InternalServerError, logId)); } }
public List <string> SaveGroups(List <Groups> groups) { List <string> ErrorMessage = new List <string>(); DataTable dtCreateGroups = CollectionHelper.ConvertTo(groups, "MSNo,RefNo,Active,CreatedUser,UpdatedUser,MultiCity,Text_CloneGroupSNo,Text_UserTypeSNo,Text_PenaltyType"); GroupBusiness groupBusiness = new GroupBusiness(); if (!groupBusiness.ValidateBaseBusiness("Groups", dtCreateGroups, "SAVE")) { ErrorMessage = groupBusiness.ErrorMessage; return(ErrorMessage); } SqlParameter param = new SqlParameter(); param.ParameterName = "@GroupsTable"; param.SqlDbType = System.Data.SqlDbType.Structured; param.Value = dtCreateGroups; SqlParameter[] Parameters = { param }; DataSet ds = SqlHelper.ExecuteDataset(DMLConnectionString.WebConfigConnectionString, "CreateGroups", Parameters); int ret = Convert.ToInt32(ds.Tables[0].Rows[0]["ErrorNumber"]); int groupSNo = Convert.ToInt32(ds.Tables[0].Rows[0]["GroupSNo"]); GroupBusiness.GroupSNo = groupSNo; if (ret > 0) { if (ret > 1000) { string serverErrorMessage = groupBusiness.ReadServerErrorMessages(ret, "Groups"); if (!string.IsNullOrEmpty(serverErrorMessage)) { ErrorMessage.Add(serverErrorMessage); } } else { //For DataBase Exceptions like 'Foreign Key refrence Errors' etc string dataBaseExceptionMessage = groupBusiness.ReadServerErrorMessages(ret, groupBusiness.DatabaseExceptionFileName); if (!string.IsNullOrEmpty(dataBaseExceptionMessage)) { ErrorMessage.Add(dataBaseExceptionMessage); } } } return(ErrorMessage); }
public GroupDTO GetGroupByIDfromDB(int id) { ICollection <GroupDTO> outputList = default(ICollection <GroupDTO>); GroupDTO output = new GroupDTO(); try { GroupBusiness _GroupBusiness = new GroupBusiness(); GroupList _GroupList = _GroupBusiness.SelectRows(id, null); if (_GroupList != null && _GroupList.Count > 0) //outputList = Mapper.MapUserAsOutput(); { // 2- Prepare Mapping Obects (Fill Values from DB) Mapper._GroupList = fillGroupList(); //default(List<Group>); Mapper._FunctionList = fillFunctionList(); //default(List<Function>); //Mapper._UserList = _UserList; //Mapper._UserGroupList = new List<UserGroup>(); //default(List<UserGroup>); Mapper._GroupFunctionList = fillGroupFunctionList(); //default(List<GroupFunction>); //UserGroupBusiness _UserGroupBusiness = new UserGroupBusiness(); //UserGroupList _UserGroupList = default(UserGroupList); //foreach (User _User in _UserList) //{ // _UserGroupList = _UserGroupBusiness.SelectRows(null, _User.Id, null); // if (_UserGroupList != null && _UserGroupList.Count > 0) // foreach (UserGroup _UserGroup in _UserGroupList) // Mapper._UserGroupList.Add(Copier.copyUserGroup(_UserGroup)); //} // 3- Perform Mapping to Output outputList = Mapper.MapGroupAsOutput(); if (outputList != null && outputList.Count > 0) { output = outputList.First(); } } } catch (Exception ex) { // Log Exception Here throw; //new Exception(ex.Message); } return(output); }
public HttpResponseMessage GetAll() { try { int systemId = Convert.ToInt32(ConfigurationManager.AppSettings[CHAVE_ID_SISTEMA]); var result = GroupBusiness.Get(claimData.UserId, systemId); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception exc) { var logId = LogBusiness.Error(exc); return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorModel(logId))); } }
public List <string> DeleteGroups(List <string> listID) { //validate Business Rule List <string> ErrorMessage = new List <string>(); GroupBusiness groupBusiness = new GroupBusiness(); if (listID.Count > 1) { string RecordID = listID[0].ToString(); string UserID = listID[1].ToString(); SqlParameter[] Parameters = { new SqlParameter("@SNo", Convert.ToInt32(RecordID)), new SqlParameter("@UserID", Convert.ToInt32(UserID)) }; int ret = (int)SqlHelper.ExecuteScalar(DMLConnectionString.WebConfigConnectionString, "DeleteGroups", Parameters); if (ret > 0) { if (ret > 1000) { string serverErrorMessage = groupBusiness.ReadServerErrorMessages(ret, "Groups"); if (!string.IsNullOrEmpty(serverErrorMessage)) { ErrorMessage.Add(serverErrorMessage); } } else { //For DataBase Exceptions like 'Foreign Key refrence Errors' etc string dataBaseExceptionMessage = groupBusiness.ReadServerErrorMessages(ret, groupBusiness.DatabaseExceptionFileName); if (!string.IsNullOrEmpty(dataBaseExceptionMessage)) { ErrorMessage.Add(dataBaseExceptionMessage); } } } } else { //For DataBase Exceptions like 'Foreign Key refrence Errors' etc string dataBaseExceptionMessage = groupBusiness.ReadServerErrorMessages(9001, groupBusiness.DatabaseExceptionFileName); if (!string.IsNullOrEmpty(dataBaseExceptionMessage)) { ErrorMessage.Add(dataBaseExceptionMessage); } //Error } return(ErrorMessage); }
/// <summary> /// Constructor /// </summary> /// <param name="configuration">configuration object</param> /// <param name="logger">loggin object</param> public GroupController(IOptions <ConfigurationModel> configuration, ILogger <GroupController> logger) { _configurations = configuration; _groupBusiness = new GroupBusiness(_configurations.Value); _logger = logger; }
public GroupDTO AddGrouptoDB(GroupDTO groupDTO) { BaseDataAccess _db = new BaseDataAccess(); using (DbTransaction dbTransaction = _db.CreateTransaction()) { try { // 1- Perform Mapping to Input (for Saving in DB) if (Mapper.MapGroupAsInput(groupDTO)) { ////User user = Mapper._User; ////List<UserGroup> userGroups = Mapper._UserGroupListInput; //Mapper._User.createDate = DateTime.Now; // 2- Insert Group in DB GroupBusiness groupBusiness = new GroupBusiness(); if (groupBusiness.InsertRow(dbTransaction, Mapper._Group) > 0) { groupDTO.Id = Mapper._Group.Id; if (Mapper._GroupFunctionListInput != null && Mapper._GroupFunctionListInput.Count > 0) { GroupFunctionBusiness groupFunctionBusiness = new GroupFunctionBusiness(); // 3- Insert Group Functions in DB foreach (GroupFunction groupFunction in Mapper._GroupFunctionListInput) { groupFunction.groupId = Mapper._Group.Id; groupFunctionBusiness = new GroupFunctionBusiness(); groupFunctionBusiness.InsertRow(dbTransaction, groupFunction); } dbTransaction.Commit(); } else { dbTransaction.Rollback(); throw new Exception("DataBase Operation Failure"); } } else { throw new Exception("Group Id Not Found in DB"); } } else { throw new ArgumentNullException("groupDTO"); } } catch (Exception ex) { dbTransaction.Rollback(); throw new Exception("DataBase Operation Failure"); } } return(groupDTO); }
public GroupDTO UpdateGroupinDB(GroupDTO groupDTO) { BaseDataAccess _db = new BaseDataAccess(); using (DbTransaction dbTransaction = _db.CreateTransaction()) { try { // 1- Perform Mapping to Input (for Saving in DB) if (Mapper.MapGroupAsInput(groupDTO)) { // 2- Select Group to be updated GroupBusiness groupBusiness = new GroupBusiness(); GroupList groupList = groupBusiness.SelectRows(Mapper._Group.Id, null); if (groupList != null && groupList.Count > 0) { groupList[0].name = Mapper._Group.name; groupList[0].status = Mapper._Group.status; // 3- Update Group Data by Input Values groupBusiness = new GroupBusiness(); if (groupBusiness.UpdateRow(dbTransaction, groupList[0]) > 0) { // 4- Remove Group Functions Already Saved for that Group in DB GroupFunctionBusiness groupFunctionBusiness = new GroupFunctionBusiness(); GroupFunctionList groupFunctionList = groupFunctionBusiness.SelectRows(null, null, Mapper._Group.Id); if (groupFunctionList != null && groupFunctionList.Count > 0) { foreach (GroupFunction groupFunction in groupFunctionList) { groupFunctionBusiness = new GroupFunctionBusiness(); groupFunctionBusiness.DeleteRow(dbTransaction, groupFunction); } } // 5- Add New Group Functions from Input if (Mapper._GroupFunctionListInput != null && Mapper._GroupFunctionListInput.Count > 0) { foreach (GroupFunction groupFunction in Mapper._GroupFunctionListInput) { groupFunctionBusiness = new GroupFunctionBusiness(); groupFunctionBusiness.InsertRow(dbTransaction, groupFunction); } dbTransaction.Commit(); } } else { dbTransaction.Rollback(); throw new Exception("DataBase Operation Failure"); } } else { throw new Exception("Group Id Not Found in DB"); } } else { throw new ArgumentNullException("groupDTO"); } } catch (Exception ex) { dbTransaction.Rollback(); throw new Exception("DataBase Operation Failure"); } } return(groupDTO); }