Ejemplo n.º 1
0
        public void SaveRosterAsTemplate(ItemDataQuery query)
        {
            DisableCaching();

            try
            {
                // init source Roster
                var sourceRoster      = new RosterDataService().ListSingleRosterEvent(query.ListId, query.ItemId);
                var sourceRosterProps = sourceRoster.RosterEventDictionary;

                // create empty Template Roster
                RosterDataService _dataService = new RosterDataService();
                var newRosterTemplate          = _dataService.CreateRosterEvent(Roster.Common.TableIDs.TEMPLATE_ROSTERS, (int)RosterEventType.TemplateRosterEvent);

                // fill template Roster properties
                var rosterTemplateFields = new RosterConfigService().GetList(Roster.Common.TableIDs.TEMPLATE_ROSTERS).ListMetadataFields;
                foreach (var field in rosterTemplateFields)
                {
                    if (field.InternalName == FieldNames.ROSTER_EVENT_ID || field.InternalName == FieldNames.ID ||
                        !sourceRosterProps.ContainsKey(field.InternalName))
                    {
                        continue;
                    }

                    newRosterTemplate.RosterEventDictionary[field.InternalName] = sourceRosterProps[field.InternalName];
                }

                // save template Roster
                _dataService.SaveRosterEvent(newRosterTemplate, Roster.Common.TableIDs.TEMPLATE_ROSTERS);
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
Ejemplo n.º 2
0
        public ItemDataResult RosterItemData(ItemDataQuery query)
        {
            DisableCaching();
            var result = new ItemDataResult {
                Props = new List <ItemDataElem> ()
            };

            try
            {
                var roster = new RosterDataService().ListSingleRosterEvent(query.ListId, query.ItemId);

                if (roster != null)
                {
                    var origRosterProps = roster.RosterEventDictionary;
                    foreach (string fldKey in origRosterProps.Keys)
                    {
                        bool   isFilterByLookupId = false;
                        object val      = origRosterProps[fldKey];
                        string valAsStr = string.Empty;
                        if (val is DateTime)
                        {
                            valAsStr = ((DateTime)val).ToString("yyyy-MM-dd");
                        }
                        else if (val is Boolean)
                        {
                            valAsStr = (bool)val ? "1" : "0";
                        }
                        else if (val is int)
                        {
                            valAsStr = ((int)val).ToString("N" + 13);
                        }
                        else
                        {
                            valAsStr = val.ToSafeString();

                            if (valAsStr.StartsWith("<Items>"))
                            {
                                valAsStr = string.Join(";#", valAsStr.XmlToList()); // choice values
                            }

                            // LookupId ?
                            int dummy;
                            isFilterByLookupId = val.ToSafeString().Split(',').Where(x => Int32.TryParse(x, out dummy)).Any();
                        }

                        ((List <ItemDataElem>)result.Props).Add(new ItemDataElem {
                            FieldName      = fldKey,
                            FieldValue     = SPHttpUtility.UrlKeyValueEncode(valAsStr),
                            FilterLookupId = isFilterByLookupId
                        });
                    }
                }
            }
            catch (Exception ex) {
                HandleException(ex);
            }

            return(result);
        }
Ejemplo n.º 3
0
        public ExecuteActionResult CancelRoster(ItemDataQuery query)
        {
            DisableCaching();
            var result = new ExecuteActionResult();

            try
            {
                result.Message = new DataHelpers().CancelRoster(query.ItemId);
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
            return(result);
        }
Ejemplo n.º 4
0
        public ExecuteActionResult SubmitSingleTimesheet(ItemDataQuery query)
        {
            DisableCaching();
            var result = new ExecuteActionResult();

            try
            {
                result.Message = new DataHelpers().SubmitTimesheet(query.ListId, query.ItemId);
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }

            return(result);
        }
Ejemplo n.º 5
0
        public void RemoveRoster(ItemDataQuery query)
        {
            DisableCaching();
            try
            {
                if (!new RosterConfigService().HasRights(query.ItemId, query.ListId, AccessRight.Delete))
                {
                    throw new Exception("You do not have permissions to remove current roster!");
                }

                new RosterDataService().DeleteRosterEvent(query.ItemId);
            }
            catch (Exception ex) {
                HandleException(ex);
            }
        }