Exemplo n.º 1
0
 /// <summary>Construct a PersonIdent from simple data</summary>
 /// <param name="aName"></param>
 /// <param name="aEmailAddress"></param>
 /// <param name="aWhen">local time stamp</param>
 /// <param name="aTZ">time zone</param>
 public PersonIdent(string aName, string aEmailAddress, DateTime aWhen, TimeZoneInfo
                    aTZ)
 {
     name         = aName;
     emailAddress = aEmailAddress;
     when         = aWhen.GetTime();
     tzOffset     = aTZ.GetOffset(when) / (60 * 1000);
 }
Exemplo n.º 2
0
        public TodoWrapper Get(ITodo baseTodo, Guid userId, TimeZoneInfo timeZone)
        {
            var result = new TodoWrapper();

            _timeZone = timeZone;
            _baseTodo = baseTodo;

            result.Id          = _baseTodo.Id;
            result.Uid         = _baseTodo.Uid;
            result.CalendarId  = _baseTodo.CalendarId;
            result.Name        = _baseTodo.Name;
            result.Description = _baseTodo.Description;

            var startD = _utcStartDate != DateTime.MinValue ? _utcStartDate : _baseTodo.UtcStartDate;

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

            result.Start = new ApiDateTime(startD, _timeZone.GetOffset());

            var completedD = _utcCompletedDate != DateTime.MinValue ? _utcCompletedDate : _baseTodo.Completed;

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

            result.Completed = new ApiDateTime(completedD, _timeZone.GetOffset());

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

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

            result.Owner = owner;

            result.UserId = userId;

            return(result);
        }
Exemplo n.º 3
0
        public TimeZoneWrapper Get(TimeZoneInfo timeZone)
        {
            _timeZone = timeZone;

            var result = new TimeZoneWrapper();

            result.Name   = TimeZoneConverter.GetTimeZoneName(_timeZone);
            result.Id     = _timeZone.Id;
            result.Offset = (int)_timeZone.GetOffset().TotalMinutes;

            return(result);
        }
Exemplo n.º 4
0
 /// <summary>Construct a PersonIdent from simple data</summary>
 /// <param name="aName"></param>
 /// <param name="aEmailAddress"></param>
 /// <param name="aWhen">local time stamp</param>
 /// <param name="aTZ">time zone</param>
 public PersonIdent(string aName, string aEmailAddress, DateTime aWhen, TimeZoneInfo
                    aTZ) : this(aName, aEmailAddress, aWhen.GetTime(), aTZ.GetOffset(aWhen.GetTime(
                                                                                         )) / (60 * 1000))
 {
 }
Exemplo n.º 5
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);
        }