Exemplo n.º 1
0
 public static CalendarWrapper GetSample()
 {
     return(new CalendarWrapper
     {
         CanEditTimeZone = false,
         TimeZoneInfo = TimeZoneWrapper.GetSample(),
         DefaultAlertType = EventAlertWrapper.GetSample(),
         Events = new List <EventWrapper>()
         {
             EventWrapper.GetSample()
         },
         Owner = UserParams.GetSample(),
         Id = "1",
         Title = "Calendar Name",
         Description = "Calendar Description",
         BackgroundColor = "#000000",
         TextColor = "#ffffff",
         IsEditable = true,
         Permissions = CalendarPermissions.GetSample(),
         IsShared = true,
         CanAlertModify = true,
         IsHidden = false,
         IsiCalStream = false,
         IsSubscription = false
     });
 }
Exemplo n.º 2
0
 public static object GetSample()
 {
     return(new
     {
         canEditTimeZone = false,
         timeZone = TimeZoneWrapper.GetSample(),
         defaultAlert = EventAlertWrapper.GetSample(),
         events = new List <object>()
         {
             EventWrapper.GetSample()
         },
         owner = UserParams.GetSample(),
         objectId = "1",
         title = "Calendar Name",
         description = "Calendar Description",
         backgroundColor = "#000000",
         textColor = "#ffffff",
         isEditable = true,
         permissions = CalendarPermissions.GetSample(),
         isShared = true,
         canAlertModify = true,
         isHidden = false,
         isiCalStream = false,
         isSubscription = false
     });
 }
Exemplo n.º 3
0
        public EventWrapper Get(IEvent baseEvent, Guid userId, TimeZoneInfo timeZone)
        {
            var eventWraper = new EventWrapper();

            _timeZone = timeZone;
            var _baseEvent = baseEvent;

            eventWraper.UserId      = userId;
            eventWraper.Id          = _baseEvent.Id;
            eventWraper.Uid         = _baseEvent.Uid;
            eventWraper.CalendarId  = _baseEvent.CalendarId;
            eventWraper.Name        = _baseEvent.Name;
            eventWraper.Description = _baseEvent.Description;
            eventWraper.AllDayLong  = _baseEvent.AllDayLong;;

            var icalendar = new iCalendar(AuthContext, TimeZoneConverter, TenantManager);
            //---
            var startD = _utcStartDate != DateTime.MinValue ? _utcStartDate : _baseEvent.UtcStartDate;

            startD = new DateTime(startD.Ticks, DateTimeKind.Utc);

            var updateD = _utcUpdateDate != DateTime.MinValue ? _utcUpdateDate : _baseEvent.UtcStartDate;

            if (_baseEvent.AllDayLong && _baseEvent.GetType().GetCustomAttributes(typeof(AllDayLongUTCAttribute), true).Length > 0)
            {
                eventWraper.Start = new ApiDateTime(startD, TimeZoneInfo.Utc.GetOffset());
            }
            else if (_baseEvent.GetType().Namespace == new BusinessObjects.Event(AuthContext, TimeZoneConverter, icalendar, DataProvider).GetType().Namespace)
            {
                eventWraper.Start = new ApiDateTime(startD, _timeZone.GetOffset(false, updateD));
            }
            else
            {
                eventWraper.Start = new ApiDateTime(startD, _timeZone.GetOffset());
            }

            //---
            var endD = _utcEndDate != DateTime.MinValue ? _utcEndDate : _baseEvent.UtcEndDate;

            endD = new DateTime(endD.Ticks, DateTimeKind.Utc);

            updateD = _utcUpdateDate != DateTime.MinValue ? _utcUpdateDate : _baseEvent.UtcStartDate;


            if (_baseEvent.AllDayLong && _baseEvent.GetType().GetCustomAttributes(typeof(AllDayLongUTCAttribute), true).Length > 0)
            {
                eventWraper.End = new ApiDateTime(endD, TimeZoneInfo.Utc.GetOffset());
            }
            else if (_baseEvent.GetType().Namespace == new BusinessObjects.Event(AuthContext, TimeZoneConverter, icalendar, DataProvider).GetType().Namespace)
            {
                eventWraper.End = new ApiDateTime(endD, _timeZone.GetOffset(false, updateD));
            }
            else
            {
                eventWraper.End = new ApiDateTime(endD, _timeZone.GetOffset());
            }

            eventWraper.RepeatRule = _baseEvent.RecurrenceRule.ToString();

            eventWraper.Alert          = EventAlertWrapper.ConvertToTypeSurrogated(_baseEvent.AlertType);
            eventWraper.IsShared       = _baseEvent.SharingOptions.SharedForAll || _baseEvent.SharingOptions.PublicItems.Count > 0;
            eventWraper.CanUnsubscribe = String.Equals(_baseEvent.CalendarId, SharedEventsCalendar.CalendarId, StringComparison.InvariantCultureIgnoreCase);

            if (_baseEvent is ISecurityObject)
            {
                eventWraper.IsEditable = PermissionContext.PermissionResolver.Check(Authentication.GetAccountByID(TenantManager.GetCurrentTenant().TenantId, userId), (ISecurityObject)_baseEvent, null, CalendarAccessRights.FullAccessAction);
            }
            else
            {
                eventWraper.IsEditable = false;
            }

            var p = new CalendarPermissions()
            {
                Data = PublicItemCollectionHelper.GetForEvent(_baseEvent)
            };

            foreach (var item in _baseEvent.SharingOptions.PublicItems)
            {
                if (item.IsGroup)
                {
                    p.UserParams.Add(new UserParams()
                    {
                        Id = item.Id, Name = UserManager.GetGroupInfo(item.Id).Name
                    });
                }
                else
                {
                    p.UserParams.Add(new UserParams()
                    {
                        Id = item.Id, Name = UserManager.GetUsers(item.Id).DisplayUserName(DisplayUserSettingsHelper)
                    });
                }
            }
            eventWraper.Permissions = p;

            var owner = new UserParams()
            {
                Id = _baseEvent.OwnerId, Name = ""
            };

            if (_baseEvent.OwnerId != Guid.Empty)
            {
                owner.Name = UserManager.GetUsers(_baseEvent.OwnerId).DisplayUserName(DisplayUserSettingsHelper);
            }

            eventWraper.Owner  = owner;
            eventWraper.Status = _baseEvent.Status;
            eventWraper.UserId = userId;


            return(eventWraper);
        }