示例#1
0
        private CompanyEventDTO[] GetAllEventsFromAcServer(CompanyAcServer defaultAcDomain, bool isShowPastEvents = false, bool publishedOnly = false)
        {
            var acUri       = new Uri(defaultAcDomain.AcServer);
            var acProvider  = new AdobeConnectProvider(new ConnectionDetails(acUri));
            var acProxy     = new AdobeConnectProxy(acProvider, Logger, acUri);
            var loginResult = acProxy.Login(new UserCredentials(defaultAcDomain.Username, defaultAcDomain.Password));

            if (!loginResult.Success)
            {
                return(null);
            }

            var eventType    = acProxy.GetShortcutByType("events");
            var eventContent = acProxy.GetScoExpandedContent(eventType.ScoId);

            if (!eventContent.Success)
            {
                return(null);
            }

            var result     = new List <CompanyEventDTO>();
            var eventsOnly = eventContent.Values.Where(x => x.Type == "event");

            if (!isShowPastEvents)
            {
                eventsOnly = eventsOnly.Where(x => x.EndDateLocal >= DateTime.Now);
            }

            if (publishedOnly)
            {
                var publishedEvents = acProxy.GetEventList();
                if (!publishedEvents.Success)
                {
                    return(null); // TODO: may be write error message to log at least?
                }
                eventsOnly = eventsOnly.Where(x => publishedEvents.Values.Any(e => e.ScoId == x.ScoId));
            }

            foreach (var content in eventsOnly)
            {
                result.Add(new CompanyEventDTO
                {
                    companyId         = defaultAcDomain.Company.Id,
                    dateBegin         = DateTime.SpecifyKind(content.BeginDate, DateTimeKind.Utc),
                    dateEnd           = DateTime.SpecifyKind(content.EndDate, DateTimeKind.Utc),
                    name              = content.Name,
                    desc              = content.Description,
                    scoId             = content.ScoId,
                    urlPath           = content.UrlPath,
                    dateCreated       = DateTime.SpecifyKind(content.DateCreated, DateTimeKind.Utc),
                    dateModified      = DateTime.SpecifyKind(content.DateModified, DateTimeKind.Utc),
                    isSeminar         = content.IsSeminar,
                    isMappedToQuizzes = CompanyEventQuizMappingModel.GetAllByCompanyId(defaultAcDomain.Company.Id).Any(x => x.AcEventScoId == content.ScoId),
                    meetingUrl        = acProxy.GetScoInfo(content.ScoId).ScoInfo?.SourceSco?.UrlPath,
                });
            }

            return(result.ToArray());
        }
示例#2
0
        public CompanyQuizEventMappingDTO(CompanyEventQuizMapping entity, dynamic settings, CompanyEventDTO eventDto = null, CompanyAcServer acServer = null)
        {
            if (entity == null)
            {
                throw new InvalidOperationException($"Entity should not be null");
            }

            if (settings == null)
            {
                throw new InvalidOperationException($"Settings should not be null");
            }
            acEventScoId       = entity.AcEventScoId;
            guid               = entity.Guid;
            preQuizId          = entity.PreQuiz?.Id ?? 0;
            postQuizId         = entity.PostQuiz?.Id ?? 0;
            eventQuizMappingId = entity.Id;
            if (entity.CompanyAcDomain == null)
            {
                throw new InvalidOperationException($"entity.CompanyAcDomain should not be null");
            }
            companyAcDomainId = entity.CompanyAcDomain.Id;
            //companyAcDomain = new ACDomainDTO()
            //{
            //    companyId = entity.CompanyAcDomain.Company.Id,
            //    password = entity.CompanyAcDomain.Password,
            //    domainId = entity.CompanyAcDomain.Id,
            //    isDefault = entity.CompanyAcDomain.IsDefault,
            //    path = entity.CompanyAcDomain.AcServer,
            //    user = entity.CompanyAcDomain.Username
            //};
            if (acServer != null)
            {
                companyAcDomain = new ACDomainDTO()
                {
                    path      = acServer.AcServer,
                    isDefault = acServer.IsDefault,
                    domainId  = acServer.Id,
                    user      = acServer.Username
                };
            }
            if (eventDto != null)
            {
                acEventInfo = new CompanyEventDTO()
                {
                    companyId         = eventDto.companyId,
                    dateEnd           = eventDto.dateEnd,
                    desc              = eventDto.desc,
                    scoId             = eventDto.scoId,
                    name              = eventDto.name,
                    dateCreated       = eventDto.dateCreated,
                    dateBegin         = eventDto.dateBegin,
                    dateModified      = eventDto.dateModified,
                    urlPath           = eventDto.urlPath,
                    isMappedToQuizzes = eventDto.isMappedToQuizzes,
                    isSeminar         = eventDto.isSeminar,
                    meetingUrl        = eventDto.meetingUrl
                };
            }

            if (eventQuizMappingId != 0)
            {
                registrationUrl = settings.CertificatesUrl + "/" + entity.Guid;
            }
        }
示例#3
0
        public ACDomainDTO Save(ACDomainDTO acDomain)
        {
            //if (acDomain.isDefault)
            //{
            //    var defaultDomain =
            //        CompanyAcServerModel.GetAllByCompany(acDomain.companyId).FirstOrDefault(x => x.IsDefault);
            //    if (defaultDomain != null)
            //    {
            //        defaultDomain.IsDefault = false;
            //        CompanyAcServerModel.RegisterSave(defaultDomain, true);
            //    }
            //}
            //else
            //{
            //    // for update
            //    if (acDomain.domainId != 0)
            //    {
            //        // you can't uncheck default if there is only one record
            //        if (CompanyAcServerModel.GetAllByCompany(acDomain.companyId).Count() == 1)
            //            return acDomain;

            //        if (CompanyAcServerModel.GetAllByCompany(acDomain.companyId).Count() > 1)
            //        {
            //            var firstAcServer =
            //                CompanyAcServerModel.GetAllByCompany(acDomain.companyId)
            //                    .FirstOrDefault(x => x.Id != acDomain.domainId);
            //            if (firstAcServer != null)
            //            {
            //                firstAcServer.IsDefault = true;
            //                CompanyAcServerModel.RegisterSave(firstAcServer, true);
            //            }
            //        }
            //    }
            //    else
            //    {
            //        var existing = CompanyAcServerModel.GetAllByCompany(acDomain.companyId).FirstOrDefault();
            //        if (existing != null)
            //        {
            //            existing.IsDefault = true;
            //            CompanyAcServerModel.RegisterSave(existing, true);
            //        }
            //    }
            //}
            var             company = CompanyModel.GetOneById(acDomain.companyId).Value;
            CompanyAcServer companyAcServer;

            if (acDomain.domainId != 0)
            {
                companyAcServer = CompanyAcServerModel.GetOneById(acDomain.domainId).Value;
            }
            else
            {
                companyAcServer = new CompanyAcServer()
                {
                };
            }
            companyAcServer.Company   = company;
            companyAcServer.IsDefault = acDomain.isDefault;
            companyAcServer.Username  = acDomain.user;
            companyAcServer.AcServer  = acDomain.path;

            if (!string.IsNullOrEmpty(acDomain.password))
            {
                companyAcServer.Password = acDomain.password;
            }
            CompanyAcServerModel.RegisterSave(companyAcServer, true);

            //uncheck if another isDefault=true exists
            if (acDomain.isDefault)
            {
                var otherDefaultServers =
                    CompanyAcServerModel.GetAllByCompany(acDomain.companyId)
                    .Where(x => x.Id != acDomain.domainId && x.IsDefault).ToList();
                foreach (var acServer in otherDefaultServers)
                {
                    acServer.IsDefault = false;
                    CompanyAcServerModel.RegisterSave(acServer, true);
                }
            }

            //select first isDefault if no default at all
            if (!acDomain.isDefault)
            {
                var firstAcServer =
                    CompanyAcServerModel.GetAllByCompany(acDomain.companyId)
                    .FirstOrDefault(x => x.IsDefault);
                if (firstAcServer == null)
                {
                    companyAcServer.IsDefault = true;
                    CompanyAcServerModel.RegisterSave(companyAcServer, true);
                }
            }
            return(acDomain);
        }