public frmStaffGroup() { InitializeComponent(); //Load Load += (sender, e) => { if (staffGroup == null) { staffGroup = new StaffGroup(); } }; //Save button click ucActionResultButton.SaveButtonClick += (sender, e) => { if (dxValidationProvider.Validate()) { OnSaved(staffGroup); } }; //Cancel button click ucActionResultButton.CancelButtonClick += (sender, e) => { this.Close(); }; }
private static void UpdateStaffGroups(StaffDetail detail, Staff staff, Predicate <StaffGroupSummary> p1, Predicate <StaffGroup> p2, IPersistenceContext context) { // create a helper to sync staff group membership CollectionSynchronizeHelper <StaffGroup, StaffGroupSummary> helper = new CollectionSynchronizeHelper <StaffGroup, StaffGroupSummary>( delegate(StaffGroup group, StaffGroupSummary summary) { return(group.GetRef().Equals(summary.StaffGroupRef, true)); }, delegate(StaffGroupSummary groupSummary, ICollection <StaffGroup> groups) { StaffGroup group = context.Load <StaffGroup>(groupSummary.StaffGroupRef, EntityLoadFlags.Proxy); group.AddMember(staff); }, delegate { // do nothing }, delegate(StaffGroup group, ICollection <StaffGroup> groups) { group.RemoveMember(staff); } ); helper.Synchronize( CollectionUtils.Select(staff.Groups, p2), CollectionUtils.Select(detail.Groups, p1)); }
public StaffGroupDetail CreateDetail(StaffGroup staffGroup, IPersistenceContext context) { StaffAssembler staffAssembler = new StaffAssembler(); WorklistAssembler worklistAssembler = new WorklistAssembler(); IList <Worklist> worklists = context.GetBroker <IWorklistBroker>().Find(staffGroup); return(new StaffGroupDetail( staffGroup.GetRef(), staffGroup.Name, staffGroup.Description, staffGroup.Elective, CollectionUtils.Map <Staff, StaffSummary>(staffGroup.Members, delegate(Staff staff) { return staffAssembler.CreateStaffSummary(staff, context); }), CollectionUtils.Map <Worklist, WorklistSummary>(worklists, delegate(Worklist worklist) { return worklistAssembler.GetWorklistSummary(worklist, context); }), staffGroup.Deactivated )); }
/// <summary> /// Возвращает сотрудника по группе или его заместителя. /// </summary> /// <param name="Context"></param> /// <param name="GroupName">Название группы.</param> /// <param name="GetDeputy">Возвращать заместителя при неактивности сотрудника в необходимой должности.</param> /// <returns></returns> public StaffEmployee GetEmployeeByGroup(ObjectContext Context, String GroupName, Boolean GetDeputy = true) { Staff staff = Context.GetObject <Staff>(RefStaff.ID); StaffGroup Group = staff.Groups.FirstOrDefault <StaffGroup>(r => r.Name == GroupName); if (!Group.IsNull()) { List <StaffEmployee> FindedEmployees = Group.Employees.ToList(); //Context.FindObjects<StaffEmployee>(new QueryObject(RefStaff.Employees.Position, Context.GetObjectRef<StaffPosition>(Position).Id)).ToList(); if (FindedEmployees.Any()) { List <StaffEmployee> Employees = FindedEmployees.Where(emp => emp.Status != StaffEmployeeStatus.Discharged && emp.Status != StaffEmployeeStatus.Transfered && emp.Status != StaffEmployeeStatus.DischargedNoRestoration).ToList(); if (Employees.Any()) { StaffEmployee Employee = Employees.FirstOrDefault(emp => emp.Status == StaffEmployeeStatus.Active); if (!Employee.IsNull()) { return(Employee); } else if (GetDeputy) { return(Employees.Select(emp => emp.GetDeputy()).FirstOrDefault(emp => !emp.IsNull())); } } } } return(null); }
public IActionResult Get(Guid id) { try { using (var db = new AllInOneContext.AllInOneContext()) { StaffGroup data = db.StaffGroup .Include(t => t.Staffs).Include(t => t.Application) .Include(t => t.Organization) .FirstOrDefault(p => p.StaffGroupId.Equals(id)); if (data == null) { return(NoContent()); } return(new ObjectResult(data)); } } catch (Exception ex) { _logger.LogError("Get:Message:{0}\r\n,StackTrace:{1}", ex.Message, ex.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } }
public IActionResult Delete(Guid id) { try { using (var db = new AllInOneContext.AllInOneContext()) { StaffGroup data = db.StaffGroup.FirstOrDefault(p => p.StaffGroupId == id); if (data == null) { return(NoContent()); } db.StaffGroup.Remove(data); db.SaveChanges(); return(new NoContentResult()); } } catch (DbUpdateException dbEx) { _logger.LogError("Delete:Message:{0}\r\n,StackTrace:{1}", dbEx.Message, dbEx.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "DBUpdate", ErrorMessage = "数据保存异常:" + dbEx.Message })); } catch (System.Exception ex) { _logger.LogError("Delete:Message:{0}\r\n,StackTrace:{1}", ex.Message, ex.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } }
public IActionResult Update([FromBody] StaffGroup model) { try { if (model == null) { return(BadRequest()); } using (var db = new AllInOneContext.AllInOneContext()) { db.StaffGroup.Update(model); db.SaveChanges(); return(new NoContentResult()); } } catch (DbUpdateException dbEx) { _logger.LogError("Update:Message:{0}\r\n,StackTrace:{1}", dbEx.Message, dbEx.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "DBUpdate", ErrorMessage = "数据保存异常:" + dbEx.Message })); } catch (System.Exception ex) { _logger.LogError("Update:Message:{0}\r\n,StackTrace:{1}", ex.Message, ex.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } }
public List <CaseAssignmentVM> GetListByGroup(StaffGroup oStaffGroup, string companyId) { var oCaseAssignmentList = _caseAssignmentRepo.All(GetType().Name).Where(x => x.CompanyId == companyId && x.AssignedStaffGroup == oStaffGroup).ToList(); var ocaVMList = _mappingHelper.Map <List <CaseAssignmentVM> >(oCaseAssignmentList); return(ocaVMList); }
public IList <Worklist> Find(StaffGroup staffGroup) { var query = GetBaseQuery(); AddStaffGroupConditions(query, staffGroup); return(ExecuteHql <Worklist>(query)); }
public IList<Player> GetStaffGroupMembers(Player staff, StaffGroup staffGroup, ISession session) { ServicesList.SecurityService.CheckPermission(staff, JobEnum.StaffGroupManagement.ToString(), "read"); return (from player in session.Linq<Player>() where player.StaffGroups.Contains(staffGroup) select player).ToList<Player>(); }
private void CompareStaffGroups(StaffGroup one, StaffGroup two) { Assert.AreEqual(one.Id, two.Id); Assert.AreEqual(one.IsAdmin, two.IsAdmin); Assert.AreEqual(one.Title, two.Title); AssertObjectXmlEqual <StaffGroup>(one, two); }
public StaffGroupSummary CreateSummary(StaffGroup staffGroup) { return(new StaffGroupSummary( staffGroup.GetRef(), staffGroup.Name, staffGroup.Description, staffGroup.Elective, staffGroup.Deactivated)); }
private void CollectGroups(List <StaffGroup> staffGroups, StaffGroup currentStaffGroup) { staffGroups.Add(currentStaffGroup); foreach (var group in currentStaffGroup.Groups) { CollectGroups(staffGroups, group); } }
public void CreateStaffGroup(Player staff, string name, IList<Permission> permissions, ISession session) { ServicesList.SecurityService.CheckPermission(staff, JobEnum.StaffGroupManagement.ToString(), "write"); StaffGroup staffGroup = new StaffGroup(); staffGroup.Name = name; staffGroup.Permissions = permissions; session.Save(staffGroup); }
public void AddMemberToStaffGroup(Player currentStaff, Player member, StaffGroup group, ISession session) { ServicesList.SecurityService.CheckPermission(currentStaff, JobEnum.MemberManagement.ToString(), "write"); if (member.StaffGroups.Contains(group)) return; member.StaffGroups.Add(group); session.Update(member); }
private static void AddStaffGroupConditions(HqlProjectionQuery query, StaffGroup staffGroup) { query.Froms.Add(new HqlFrom("StaffGroup", "sg")); query.Conditions.Add(new HqlCondition("sg = ?", staffGroup)); var staffGroupOr = new HqlOr(); staffGroupOr.Conditions.Add(new HqlCondition("sg in elements(w.GroupSubscribers)")); query.Conditions.Add(staffGroupOr); }
private OrderNoteDetail.GroupRecipientDetail CreateGroupRecipientDetail(StaffGroup group, bool acknowledged, NoteAcknowledgement acknowledgement, IPersistenceContext context) { StaffAssembler staffAssembler = new StaffAssembler(); StaffGroupAssembler staffGroupAssembler = new StaffGroupAssembler(); return(new OrderNoteDetail.GroupRecipientDetail( staffGroupAssembler.CreateSummary(group), acknowledged, acknowledged ? acknowledgement.Time : null, acknowledged ? staffAssembler.CreateStaffSummary(acknowledgement.Staff, context) : null)); }
public void AddMemberToStaffGroup(Player currentStaff, string username, StaffGroup group, ISession session) { Player newStaff = (from player in session.Linq<Player>() where player.Username == username select player).SingleOrDefault<Player>(); if (newStaff == null) return; this.AddMemberToStaffGroup(currentStaff, newStaff, group, session); }
public void GetStaffGroup() { StaffGroupCollection staffGroups = TestSetup.KayakoApiService.Staff.GetStaffGroups(); Assert.IsNotNull(staffGroups, "No staff groups were returned"); Assert.IsNotEmpty(staffGroups, "No staff groups were returned"); StaffGroup staffGroupToGet = staffGroups[new Random().Next(staffGroups.Count)]; Trace.WriteLine("GetStaffGroup using staff group id: " + staffGroupToGet.Id); StaffGroup staffGroup = TestSetup.KayakoApiService.Staff.GetStaffGroup(staffGroupToGet.Id); CompareStaffGroups(staffGroup, staffGroupToGet); }
/// <summary> /// Creates a new <see cref="OrderNote"/> based on the information provided in the specified detail object. /// </summary> /// <param name="detail"></param> /// <param name="order"></param> /// <param name="author"></param> /// <param name="post"></param> /// <param name="context"></param> /// <returns></returns> public OrderNote CreateOrderNote(OrderNoteDetail detail, Order order, Staff author, bool post, IPersistenceContext context) { List <Staff> staffRecipients = new List <Staff>(); staffRecipients.AddRange( CollectionUtils.Map <OrderNoteDetail.StaffRecipientDetail, Staff>(detail.StaffRecipients ?? new List <OrderNoteDetail.StaffRecipientDetail>(), delegate(OrderNoteDetail.StaffRecipientDetail item) { return(context.Load <Staff>(item.Staff.StaffRef, EntityLoadFlags.Proxy)); })); List <StaffGroup> groupRecipients = new List <StaffGroup>(); groupRecipients.AddRange( CollectionUtils.Map <OrderNoteDetail.GroupRecipientDetail, StaffGroup>(detail.GroupRecipients ?? new List <OrderNoteDetail.GroupRecipientDetail>(), delegate(OrderNoteDetail.GroupRecipientDetail item) { return(context.Load <StaffGroup>(item.Group.StaffGroupRef, EntityLoadFlags.Proxy)); })); StaffGroup onBehalfOf = detail.OnBehalfOfGroup == null ? null : context.Load <StaffGroup>(detail.OnBehalfOfGroup.StaffGroupRef, EntityLoadFlags.Proxy); // Bug #3717: If an author is supplied in the OrderNoteDetail use it instead. if (detail.Author != null) { author = context.Load <Staff>(detail.Author.StaffRef, EntityLoadFlags.Proxy); } OrderNote note = new OrderNote(order, detail.Category, author, onBehalfOf, detail.NoteBody, detail.Urgent); if (post) { note.Post(staffRecipients, groupRecipients); } // Bug #3717: If a post time is supplied in the OrderNoteDetail assume it and the CreationTime are correct. if (detail.PostTime.HasValue) { note.PostTime = detail.PostTime; note.CreationTime = detail.CreationTime; } // bug #3467: since we removed the Notes collection from Order, need to lock this manually context.Lock(note, DirtyState.New); return(note); }
public AddStaffGroupResponse AddStaffGroup(AddStaffGroupRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.StaffGroup, "request.StaffGroup"); var item = new StaffGroup(); var assembler = new StaffGroupAssembler(); var worklistEditable = Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Admin.Data.Worklist); assembler.UpdateStaffGroup(item, request.StaffGroup, worklistEditable, true, PersistenceContext); PersistenceContext.Lock(item, DirtyState.New); PersistenceContext.SynchState(); return(new AddStaffGroupResponse(assembler.CreateSummary(item))); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (StaffGroup != null) { hashCode = hashCode * 59 + StaffGroup.GetHashCode(); } if (Grade != null) { hashCode = hashCode * 59 + Grade.GetHashCode(); } if (_Contract != null) { hashCode = hashCode * 59 + _Contract.GetHashCode(); } if (Payscale != null) { hashCode = hashCode * 59 + Payscale.GetHashCode(); } if (ContractType != null) { hashCode = hashCode * 59 + ContractType.GetHashCode(); } if (ContractedTime != null) { hashCode = hashCode * 59 + ContractedTime.GetHashCode(); } if (DefaultUnavailabilityHours != null) { hashCode = hashCode * 59 + DefaultUnavailabilityHours.GetHashCode(); } hashCode = hashCode * 59 + WtdOptOut.GetHashCode(); if (SalaryFrequency != null) { hashCode = hashCode * 59 + SalaryFrequency.GetHashCode(); } hashCode = hashCode * 59 + SalaryAmount.GetHashCode(); return(hashCode); } }
public void CreateUpdateDeleteStaffGroup() { StaffGroup dummyStaffGroup = TestData; StaffGroup createdStaffGroup = TestSetup.KayakoApiService.Staff.CreateStaffGroup(StaffGroupRequest.FromResponseData(dummyStaffGroup)); Assert.IsNotNull(createdStaffGroup); dummyStaffGroup.Id = createdStaffGroup.Id; CompareStaffGroups(dummyStaffGroup, createdStaffGroup); dummyStaffGroup.IsAdmin = true; dummyStaffGroup.Title = "UPDATED: Staff Group Test"; StaffGroup updatedStaffGroup = TestSetup.KayakoApiService.Staff.UpdateStaffGroup(StaffGroupRequest.FromResponseData(dummyStaffGroup)); Assert.IsNotNull(updatedStaffGroup); CompareStaffGroups(dummyStaffGroup, updatedStaffGroup); bool success = TestSetup.KayakoApiService.Staff.DeleteStaffGroup(updatedStaffGroup.Id); Assert.IsTrue(success); }
public void UpdateStaffGroup(StaffGroup group, StaffGroupDetail detail, bool updateWorklist, bool isNewStaffGroup, IPersistenceContext context) { group.Name = detail.Name; group.Description = detail.Description; group.Elective = detail.IsElective; group.Deactivated = detail.Deactivated; group.Members.Clear(); CollectionUtils.ForEach(detail.Members, delegate(StaffSummary summary) { group.AddMember(context.Load <Staff>(summary.StaffRef, EntityLoadFlags.Proxy)); }); if (updateWorklist) { StaffGroupWorklistCollectionSynchronizeHelper helper = new StaffGroupWorklistCollectionSynchronizeHelper(group, context); IList <Worklist> originalWorklists = isNewStaffGroup ? new List <Worklist>() : context.GetBroker <IWorklistBroker>().Find(group); helper.Synchronize(originalWorklists, detail.Worklists); } }
private static void CreateOrUpdateCannedText( string name, string category, string staffId, string staffGroupName, string text, IPersistenceContext context) { try { // At least one of these should be populated if (staffId == null && staffGroupName == null) { throw new Exception("A canned text has a staff or a staff group. They cannot both be empty"); } if (staffId != null && staffGroupName != null) { throw new Exception("A canned text has a staff or a staff group. They cannot both exist"); } CannedTextSearchCriteria criteria = new CannedTextSearchCriteria(); // We must search all these criteria because the combination of them form a unique key criteria.Name.EqualTo(name); criteria.Category.EqualTo(category); if (!string.IsNullOrEmpty(staffId)) { criteria.Staff.Id.EqualTo(staffId); } if (!string.IsNullOrEmpty(staffGroupName)) { criteria.StaffGroup.Name.EqualTo(staffGroupName); } ICannedTextBroker broker = context.GetBroker <ICannedTextBroker>(); CannedText cannedText = broker.FindOne(criteria); cannedText.Text = text; } catch (EntityNotFoundException) { Staff staff = FindStaff(staffId, context); StaffGroup staffGroup = FindStaffGroup(staffGroupName, context); if (!string.IsNullOrEmpty(staffId) && staff == null) { throw new Exception("The requested staff does not exist."); } if (!string.IsNullOrEmpty(staffGroupName) && staffGroup == null) { throw new Exception("The requested staff group does not exist."); } CannedText cannedText = new CannedText(); cannedText.Name = name; cannedText.Category = category; cannedText.Staff = staff; cannedText.StaffGroup = staffGroup; cannedText.Text = text; context.Lock(cannedText, DirtyState.New); } }
/// <summary> /// Constructor. /// </summary> /// <param name="service"></param> /// <param name="page"></param> /// <param name="staffGroup"></param> public NoteboxQueryContext(ApplicationServiceBase service, SearchResultPage page, StaffGroup staffGroup) { _applicationService = service; _page = page; _staffGroup = staffGroup; }
public StaffGroupWorklistCollectionSynchronizeHelper(StaffGroup group, IPersistenceContext context) : base(false, true) { _group = group; _context = context; }
/// <summary> /// Returns true if Contract instances are equal /// </summary> /// <param name="other">Instance of Contract to be compared</param> /// <returns>Boolean</returns> public bool Equals(Contract other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( StaffGroup == other.StaffGroup || StaffGroup != null && StaffGroup.Equals(other.StaffGroup) ) && ( Grade == other.Grade || Grade != null && Grade.Equals(other.Grade) ) && ( _Contract == other._Contract || _Contract != null && _Contract.Equals(other._Contract) ) && ( Payscale == other.Payscale || Payscale != null && Payscale.Equals(other.Payscale) ) && ( ContractType == other.ContractType || ContractType != null && ContractType.Equals(other.ContractType) ) && ( ContractedTime == other.ContractedTime || ContractedTime != null && ContractedTime.Equals(other.ContractedTime) ) && ( DefaultUnavailabilityHours == other.DefaultUnavailabilityHours || DefaultUnavailabilityHours != null && DefaultUnavailabilityHours.Equals(other.DefaultUnavailabilityHours) ) && ( WtdOptOut == other.WtdOptOut || WtdOptOut.Equals(other.WtdOptOut) ) && ( SalaryFrequency == other.SalaryFrequency || SalaryFrequency != null && SalaryFrequency.Equals(other.SalaryFrequency) ) && ( SalaryAmount == other.SalaryAmount || SalaryAmount.Equals(other.SalaryAmount) )); }
private static StaffGroup GetStaffMembers() { var bob = new Person { Name = "Bob" }; var dave = new Person { Name = "Dave" }; var suzie = new Person { Name = "Suzie" }; var mary = new Person { Name = "Mary" }; var debbie = new Person { Name = "Debbie" }; var brian = new Person { Name = "Brian" }; var rafa = new Person { Name = "Rafa" }; var roger = new Person { Name = "Roger" }; var novak = new Person { Name = "Novak" }; var andy = new Person { Name = "Andy" }; var steffi = new DeliveryStaff { Person = new Person { Name = "Steffi" } }; var andre = new DeliveryStaff { Person = new Person { Name = "Andre" } }; var pete = new DeliveryStaff { Person = new Person { Name = "Pete" } }; var dishWashers = new StaffGroup { Name = "Dishwashers", Members = { roger, novak, andy } }; var kitchenStaff = new StaffGroup { Name = "Kitchen Staff", Members = { bob, dave, suzie, dishWashers } }; var supportStaff = new StaffGroup { Name = "Support Staff", Members = { mary, debbie, brian, rafa } }; var staffMembers = new StaffGroup { Members = { kitchenStaff, supportStaff, steffi, andre, pete } }; return(staffMembers); }