Ejemplo n.º 1
0
        //public bool CheckEditPermissions(string licenseId, LtiParamDTO param, IAdobeConnectProxy acProxy, LmsUser lmsUser)
        //{
        //    if (!UsersSetup.IsTeacher(param))
        //    {
        //        return false;
        //    }

        //    return GetSharedSeminarLicenses(acProxy).Any(x => !x.IsExpired && x.ScoId == licenseId)
        //           ||
        //           GetUserSeminarLicenses(acProxy)
        //               .Any(x => x.PrincipalId == lmsUser.PrincipalId && x.ScoId == licenseId && x.LicenseQuota > 0);
        //}

        public OperationResultWithData <Esynctraining.AdobeConnect.Api.Seminar.Dto.SeminarSessionDto> SaveSeminarSession(SeminarSessionInputDto seminarSessionDto,
                                                                                                                         string seminarScoId,
                                                                                                                         IAdobeConnectProxy provider
                                                                                                                         //,TimeZoneInfo timeZone
                                                                                                                         )
        {
            FixDateTimeFields(seminarSessionDto);

            var updateItem = new Esynctraining.AdobeConnect.SeminarSessionDto
            {
                Name         = seminarSessionDto.Name,
                Summary      = seminarSessionDto.Summary,
                SeminarScoId = seminarScoId,
                ExpectedLoad = seminarSessionDto.ExpectedLoad,
            };

            if (string.IsNullOrEmpty(seminarSessionDto.StartDate) || string.IsNullOrEmpty(seminarSessionDto.StartTime))
            {
                updateItem.DateBegin = DateTime.Now;
                updateItem.DateEnd   = DateTime.Now.AddDays(1);
            }

            bool isNewSeminar = string.IsNullOrEmpty(seminarSessionDto.Id);

            if (!isNewSeminar)
            {
                updateItem.SeminarSessionScoId = seminarSessionDto.Id;
            }

            DateTime dateBegin;

            if (DateTime.TryParse(seminarSessionDto.StartDate + " " + seminarSessionDto.StartTime, out dateBegin))
            {
                updateItem.DateBegin = dateBegin;
                TimeSpan duration;
                if (TimeSpan.TryParse(seminarSessionDto.Duration, out duration))
                {
                    updateItem.DateEnd =
                        dateBegin.AddMinutes((int)duration.TotalMinutes);
                }
            }

            var scoInfo       = SaveSession(updateItem, provider);
            var newSessionDto = new Esynctraining.AdobeConnect.Api.Seminar.Dto.SeminarSessionDto
            {
                Id             = scoInfo.ScoId,
                Name           = scoInfo.Name,
                StartTimeStamp = (long)scoInfo.BeginDate.ConvertToUnixTimestamp(), // + (long)GetTimezoneShift(timeZone, scoInfo.BeginDate),
                Duration       = (scoInfo.EndDate - scoInfo.BeginDate).ToString(@"h\:mm"),
                Summary        = scoInfo.Description,
                AcRoomUrl      = scoInfo.UrlPath.Trim('/'),
                IsEditable     = scoInfo.BeginDate.ToUniversalTime() > DateTime.UtcNow,
                SeminarRoomId  = seminarSessionDto.SeminarRoomId,
            };

            return(newSessionDto.ToSuccessResult());
        }
Ejemplo n.º 2
0
        public ScoInfo SaveSession(SeminarSessionDto sessionItem, IAdobeConnectProxy provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }
            if (sessionItem == null)
            {
                throw new ArgumentNullException(nameof(sessionItem));
            }
            if (sessionItem.ExpectedLoad <= 0)
            {
                throw new ArgumentException("ExpectedLoad should have positive value", nameof(sessionItem));
            }

            var isNewSession = string.IsNullOrWhiteSpace(sessionItem.SeminarSessionScoId);
            var session      = new SeminarSessionUpdateItem
            {
                ScoId       = sessionItem.SeminarSessionScoId,
                FolderId    = sessionItem.SeminarScoId,
                Type        = ScoType.seminarsession,
                Name        = sessionItem.Name,
                Description = sessionItem.Summary
            };

            ScoInfoResult sessionScoResult = isNewSession ? provider.CreateSco(session) : provider.UpdateSco(session);
            ScoInfo       sessionSco       = ProcessResult(sessionScoResult);

            var sessionSettingsResult = provider.SeminarSessionScoUpdate(new SeminarSessionScoUpdateItem
            {
                ScoId       = sessionSco.ScoId,
                Name        = sessionSco.Name,
                DateBegin   = sessionItem.DateBegin.ToString(AcDateFormat),
                DateEnd     = sessionItem.DateEnd.ToString(AcDateFormat),
                ParentAclId = sessionItem.SeminarScoId,
                SourceScoId = sessionItem.SeminarScoId,
            });

            // if session was not updated correctly, it's sco would appear in the list anyway
            // with wrong parameters(dates) => deleting just created session in case of unsuccessful update
            if (!sessionSettingsResult.Success && isNewSession)
            {
                provider.DeleteSco(sessionSco.ScoId);
            }

            var result = ProcessResult(sessionSettingsResult);

            StatusInfo loadResult = provider.UpdateAclField(result.ScoId, AclFieldId.seminar_expected_load, sessionItem.ExpectedLoad.ToString());

            if ((loadResult.Code != StatusCodes.ok) && isNewSession)
            {
                provider.DeleteSco(sessionSco.ScoId);
            }

            return(result);
        }