public listView <Entity> RosterEventList(string version, ICollection <abstractSearch> filter, QueryDisplayParams query) { DisableCaching(); var result = new listView <Entity>(); try { var listId = filter.filterTextValue("listId").ToGuid(); result.page = new pager <Entity>(); var service = new RosterDataService(); var content = service.ListRosterEvents(listId).ToList(); result.total = content.Count(); content.Take(query.currentPageSize).Skip(query.currentPageNum * query.currentPageSize).ToList().ForEach(item => { result.page.pageItems.Add(new Entity { Key = item.Id.ToSafeString(), Fields = item.RosterEventProperties.ExpandoToNamed() }); }); } catch (Exception ex) { result.message.message = ex.Message; result.message.messageLevel = messageLevelEnum.critical; //HandleException(ex); } return(result); }
private List <RosterEvent> GetTimesheetsByStatus(int statusId) { var dataService = new RosterDataService(); var query = new QueryParams(); var listFields = new RosterConfigService().GetList(TableIDs.TIMESHEET_ROSTERS).ListMetadataFields; // add filter by WorkerId var workerFld = listFields.FirstOrDefault(item => item.InternalName == FieldNames.WORKER_PERSON_ID); query.WhereCriteria.Add(new Tuple <ListMetadataField, CompareType, ConcateOperator, object, string>(workerFld, CompareType.Equal, ConcateOperator.And, this.WorkerId, null)); // add filter by StatusId var statusFld = listFields.FirstOrDefault(item => item.InternalName == FieldNames.STATUS_ID); query.WhereCriteria.Add(new Tuple <ListMetadataField, CompareType, ConcateOperator, object, string>(statusFld, CompareType.Equal, ConcateOperator.And, statusId, null)); // add filter according period displayed by Calendar var calendarPeriod = Utils.GetCalendarViewPeriod(SPContext.Current.Web.GetDateOptions(Request), "week"); var startDateFld = listFields.FirstOrDefault(item => item.InternalName == FieldNames.START_DATE); var endDateFld = listFields.FirstOrDefault(item => item.InternalName == FieldNames.END_DATE); query.WhereCriteria.Add(new Tuple <ListMetadataField, CompareType, ConcateOperator, object, string>(startDateFld, CompareType.LessOrEqual, ConcateOperator.And, calendarPeriod.Item2, null)); query.WhereCriteria.Add(new Tuple <ListMetadataField, CompareType, ConcateOperator, object, string>(endDateFld, CompareType.MoreOrEqual, ConcateOperator.And, calendarPeriod.Item1, null)); // get timesheets return(dataService.ListRosterEvents(TableIDs.TIMESHEET_ROSTERS, query)); }
public void SaveMasterAsTemplate(SaveAsTemplateQuery query) { DisableCaching(); try { // set flag IsTemplate for Master roster var _confService = new RosterConfigService(); var _dataService = new RosterDataService(); _dataService.SetAsTemplate(query.MasterId); // init filter by MasterRosterId var plannedRostersList = _confService.GetList(TableIDs.PLANNED_ROSTERS); var queryPar = new QueryParams(); var masterRosterFld = plannedRostersList.ListMetadataFields.FirstOrDefault(item => item.InternalName == FieldNames.MASTER_ROSTER_ID); queryPar.WhereCriteria.Add(new Tuple <ListMetadataField, CompareType, ConcateOperator, object, string>(masterRosterFld, CompareType.Equal, ConcateOperator.And, query.MasterId, null)); // get Planned rosters by MasterRosterId var plannedRosters = _dataService.ListRosterEvents(plannedRostersList.Id, queryPar); // limit access to Planned rosters inside Template int rosterAdminGroupId = new RoleService().GetGroupIdForRole(Roster.Presentation.Constants.Role.RosterAdmins, SPContext.Current.Web); foreach (RosterEvent re in plannedRosters) { List <AccessControlItem> reRights = _confService.GetItemAccessControls(re.Id); // clear old if (reRights != null && reRights.Any()) { reRights.ForEach(ipItm => _confService.DeleteAccessControlItem(ipItm.Id)); } // add 'Edit' to RosterAdmins _confService.SaveAccessControlItem(new AccessControlItem { AccessRight = (int)AccessRight.Write, Id = Guid.NewGuid(), ItemId = re.Id, ListMetadataId = plannedRostersList.Id, TrusteeId = rosterAdminGroupId }); // add 'Read' to Everyone _confService.SaveAccessControlItem(new AccessControlItem { AccessRight = (int)AccessRight.Read, Id = Guid.NewGuid(), ItemId = re.Id, ListMetadataId = plannedRostersList.Id, TrusteeId = RoleService.ACCOUNT_ID_EVERYONE }); } } catch (Exception ex) { HandleException(ex); } }