示例#1
0
        static void Main(string[] args)
        {
            IoCStart.Init();

            _testConnectionService = IoC.Resolve <TestConnectionService>();
            _lmsProviderModel      = IoC.Resolve <LmsProviderModel>();
            ILogger logger = IoC.Resolve <ILogger>();

            try
            {
                logger.InfoFormat("===== ConnectionTest Starts. DateTime:{0} =====", DateTime.Now);

                var lmsCompanyModel = IoC.Resolve <LmsCompanyModel>();
                var licenses        = lmsCompanyModel.GetAll();
                foreach (var lmsCompany in licenses)
                {
                    try
                    {
                        LmsProvider lmsProvider = LmsProviderModel.GetById(lmsCompany.LmsProviderId);
                        var         dto         = new CompanyLmsDTO(lmsCompany, lmsProvider);
                        Test(lmsCompany, dto);
                        lmsCompanyModel.RegisterSave(lmsCompany);
                    }
                    catch (Exception ex)
                    {
                        logger.ErrorFormat(ex, "Unexpected error during execution for LmsCompanyId: {0}.", lmsCompany.Id);
                    }
                }

                lmsCompanyModel.Flush();
            }
            catch (Exception ex)
            {
                string msg = "Unexpected error during execution ConnectionTest with message: " + ex.Message;
                logger.Error(msg, ex);
            }
            finally
            {
                logger.InfoFormat("===== ConnectionTest stops. DateTime:{0} =====", DateTime.Now);
            }
        }
示例#2
0
        public virtual ActionResult MeetingHostReport(int lmsCompanyId, string format = "PDF")
        {
            var license = this.lmsCompanyModel.GetOneById(lmsCompanyId).Value;

            if (license == null)
            {
                return(this.HttpNotFound());
            }

            var lmsCompanyName = LmsProviderModel.GetById(license.LmsProviderId).LmsProviderName;

            var provider = adobeConnectAccountService.GetProvider(license);

            var meetingHosts = adobeConnectAccountService.GetMeetingHostReport(provider).ToArray();

            var results = new List <MeetingHostReportItemDTO>();

            if (meetingHosts.Any())
            {
                results = meetingHosts.Select(x => new MeetingHostReportItemDTO(x)).ToList().OrderByDescending(x => x.LastMeetingAttend).ToList();
            }

            format = format.ToUpper();
            if (!this.SupportedReportFormats().Contains(format))
            {
                format = "PDF";
            }

            string mimeType;
            var    localReport = new LocalReport {
                EnableHyperlinks = true
            };

            var reportPath   = string.Format("EdugameCloud.MVC.Reports.{0}.rdlc", "MeetingHostReport");
            var reportSource = Assembly.GetExecutingAssembly().GetManifestResourceStream(reportPath);

            localReport.LoadReportDefinition(reportSource);

            localReport.DataSources.Clear();

            var reportParameters = new ReportParameterCollection
            {
                new ReportParameter("AccountUrl", license.AcServer),
                new ReportParameter("LmsCompanyName", lmsCompanyName)
            };

            localReport.SetParameters(reportParameters);

            localReport.DataSources.Add(new ReportDataSource("ItemDataSet", new MeetingHostReportDto(results)));
            string encoding;
            string fileNameExtension;

            Warning[] warnings;
            string[]  streams;
            var       renderedBytes = localReport.Render(
                format,
                this.GetDeviceInfo(format),
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);

            if (renderedBytes != null)
            {
                return(this.File(
                           renderedBytes,
                           mimeType,
                           string.Format("{0}.{1}", "meeting-host-report", this.GetFileExtensions(format))));
            }

            return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompanyLmsValidator"/> class.
        /// </summary>
        /// <param name="lmsProviderModel">
        /// The LMS Provider Model.
        /// </param>
        public CompanyLmsValidator(LmsProviderModel lmsProviderModel)
        {
            this.CascadeMode = CascadeMode.StopOnFirstFailure;
            this.RuleFor(x => x.acUsername).NotEmpty().WithError(Errors.CODE_ERRORTYPE_INVALID_OBJECT, "Adobe Connect username is empty");
            this.RuleFor(x => x.acServer).NotEmpty().WithError(Errors.CODE_ERRORTYPE_INVALID_OBJECT, "Adobe Connect server is empty");
            this.RuleFor(x => x.lmsProvider)
            .NotEmpty()
            .WithError(Errors.CODE_ERRORTYPE_INVALID_OBJECT, "Lms provider is empty")
            .Must(x => lmsProviderModel.GetByShortName(x) != null)
            .WithError(Errors.CODE_ERRORTYPE_INVALID_OBJECT, "Invalid LMS Provider Name")
            .Must(
                (model, x) =>
                LmsProvidersWithoutAdmin.Contains(x.ToLower()) ||
                model.enableProxyToolMode ||
                !string.IsNullOrWhiteSpace(model.lmsAdmin))
            .WithError(
                Errors.CODE_ERRORTYPE_INVALID_OBJECT,
                "Invalid LMS Setup. Please provide with administrative Username and Password");

            this.RuleFor(x => x.lmsProvider)
            .Must((model, x) =>
                  !string.IsNullOrWhiteSpace(model.lmsDomain) &&
                  (
                      (model.enableProxyToolMode && !string.IsNullOrWhiteSpace(model.moodleCoreServiceToken)) ||
                      !string.IsNullOrWhiteSpace(model.lmsAdmin)
                  )
                  )
            .When(model => model.lmsProvider == LmsProviderNames.Moodle)
            .WithError(
                Errors.CODE_ERRORTYPE_INVALID_OBJECT,
                "Invalid LMS Setup. Either Admin Credentials or Core Service Token are required.");

            this.RuleFor(x => x.lmsProvider)
            .Must((model, x) =>
                  !string.IsNullOrWhiteSpace(model.schoologyConsumerKey) && !string.IsNullOrWhiteSpace(model.schoologyConsumerSecret)
                  )
            .When(model => model.lmsProvider == LmsProviderNames.Schoology)
            .WithError(
                Errors.CODE_ERRORTYPE_INVALID_OBJECT,
                "Invalid LMS Setup. Please provide ConsumerKey and ConsumerSecret");

            this.RuleFor(x => x.lmsProvider)
            .Must((model, x) =>
                  !string.IsNullOrWhiteSpace(model.haikuConsumerKey) &&
                  !string.IsNullOrWhiteSpace(model.haikuConsumerSecret) &&
                  !string.IsNullOrWhiteSpace(model.haikuToken) &&
                  !string.IsNullOrWhiteSpace(model.haikuTokenSecret)
                  )
            .When(model => model.lmsProvider == LmsProviderNames.Haiku)
            .WithError(
                Errors.CODE_ERRORTYPE_INVALID_OBJECT,
                "Invalid LMS Setup. Please provide ConsumerKey, ConsumerSecret, Token and TokenSecret");

            this.RuleFor(x => x.lmsProvider)
            .Must((model, x) =>
                  !string.IsNullOrWhiteSpace(model.bridgeApiTokenKey) &&
                  !string.IsNullOrWhiteSpace(model.bridgeApiTokenSecret)
                  )
            .When(model => model.lmsProvider == LmsProviderNames.Bridge)
            .WithError(
                Errors.CODE_ERRORTYPE_INVALID_OBJECT,
                "Invalid LMS Setup. Please provide Api Token Key, Api Token Secret");

            this.RuleFor(model => model.additionalLmsDomains)
            .Must((model, x) => UniqueLmsDomains(model.lmsDomain, x))
            .WithError(Errors.CODE_ERRORTYPE_INVALID_OBJECT, "LMS domains should be unique.");

            this.RuleFor(model => model.additionalLmsDomains)
            .Must((model, x) => ValidLmsDomains(model.lmsDomain, x))
            .WithError(Errors.CODE_ERRORTYPE_INVALID_OBJECT, "LMS domains should be valid absolute URI addressess.");
        }