コード例 #1
0
        public LmsProviderDTO(LmsProvider p)
        {
            if (p == null)
            {
                throw new ArgumentNullException(nameof(p));
            }

            lmsProviderId   = p.Id;
            lmsProviderName = p.LmsProviderName;
            shortName       = p.ShortName;
        }
コード例 #2
0
        private FileDownloadDTO BuildUserGuide(LmsProviderEnum lms)
        {
            LmsProvider provider = LmsProviderModel.GetById((int)lms);
            var         result   = new FileDownloadDTO();

            result.downloadUrl = new Uri(new Uri((string)Settings.PortalUrl, UriKind.Absolute), $"content/lti-instructions/{provider.LmsProviderName}.pdf").ToString();

            result.fileName = string.Format("{0}.pdf", provider.LmsProviderName);
            result.title    = "User Guide";

            string path = HttpContext.Current.Server.MapPath($"~/../Content/lti-instructions/{provider.LmsProviderName}.pdf");
            var    file = new FileInfo(path);

            result.lastModifyDate = file.CreationTimeUtc;
            result.sizeInBytes    = file.Length;

            return(result);
        }
コード例 #3
0
        private string GetMeetingFolder(LmsCompany lmsCompany, IAdobeConnectProxy provider, Principal user, bool useLmsUserEmailForSearch)
        {
            string adobeConnectScoId = null;

            if (lmsCompany.UseUserFolder.GetValueOrDefault() && user != null)
            {
                ////TODO Think about user folders + renaming directory
                adobeConnectScoId = SetupUserMeetingsFolder(lmsCompany, provider, user, useLmsUserEmailForSearch);
            }

            if (adobeConnectScoId == null)
            {
                LmsProvider lmsProvider = LmsProviderModel.GetById(lmsCompany.LmsProviderId);
                adobeConnectScoId = SetupSharedMeetingsFolder(lmsCompany, lmsProvider, provider);
                this.LmsСompanyModel.RegisterSave(lmsCompany);
                this.LmsСompanyModel.Flush();
            }

            return(adobeConnectScoId);
        }
コード例 #4
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);
            }
        }
コード例 #5
0
        public LmsUserParametersDTO(LmsUserParameters param, LmsProvider lmsProvider)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (lmsProvider == null)
            {
                throw new ArgumentNullException(nameof(lmsProvider));
            }

            LmsUserParametersId = param.Id;
            AcId       = param.AcId;
            Course     = param.Course;
            Domain     = param.CompanyLms.LmsDomain;
            provider   = lmsProvider.ShortName;
            WsToken    = param.Wstoken;
            LmsUserId  = param.LmsUser.Return(x => x.Id, (int?)null);
            CourseName = param.CourseName;
            UserEmail  = param.UserEmail;
        }
コード例 #6
0
        public CompanyDTO Save(CompanyDTO dto)
        {
            ValidationResult validationResult;

            if (!this.IsValid(dto, out validationResult))
            {
                var error = this.GenerateValidationError(validationResult);
                this.LogError("Company.Save", error);
                throw new FaultException <Error>(error, error.errorMessage);
            }

            var companyModel        = this.CompanyModel;
            var companyLicenseModel = this.CompanyLicenseModel;
            var instance            = (dto.companyId == 0)
                ? null
                : companyModel.GetOneById(dto.companyId).Value;

            instance = this.Convert(dto, instance);
            var isTransient = instance.IsTransient();

            companyModel.RegisterSave(instance, true);

            if (isTransient && dto.licenseVO != null)
            {
                var user = this.UserModel.GetOneById(dto.licenseVO.createdBy).Value;

                var license = instance.CurrentLicense ?? new CompanyLicense();
                license.Company = instance;
                var licenseIsTransient = license.IsTransient();
                if (licenseIsTransient)
                {
                    license.CreatedBy   = user;
                    license.DateCreated = DateTime.Now;
                }

                license.ModifiedBy   = user;
                license.DateModified = DateTime.Now;
                var expiryDate = dto.licenseVO.expiryDate.ConvertFromUnixTimeStamp();
                license.ExpiryDate = expiryDate < DateTime.Now || expiryDate == DateTime.MinValue ? dto.licenseVO.isTrial ? DateTime.Now.AddDays(30) : DateTime.Now.AddYears(1) : expiryDate;
                var start = dto.licenseVO.startDate.ConvertFromUnixTimeStamp();
                license.DateStart          = start < DateTime.Now || start == SqlDateTime.MinValue.Value ? DateTime.Now : dto.licenseVO.startDate.ConvertFromUnixTimeStamp();
                license.LicenseStatus      = GetLicenseStatus(dto.licenseVO);
                license.TotalLicensesCount = dto.licenseVO.totalLicensesCount;

                license.TotalParticipantsCount = dto.licenseVO.totalParticipantsCount == 0 ? 100 : dto.licenseVO.totalParticipantsCount;
                license.Domain        = dto.licenseVO.domain;
                license.LicenseNumber = Guid.NewGuid().ToString();

                companyLicenseModel.RegisterSave(license);

                if (licenseIsTransient)
                {
                    instance.Licenses.Add(license);
                    companyModel.RegisterSave(instance, false);
                }
            }

            if ((!dto.primaryContactId.HasValue || dto.primaryContactId == default(int)) && dto.primaryContactVO != null)
            {
                bool passwordChanged, emailChanged;
                var  user            = this.ProcessPrimaryContact(dto, instance, out passwordChanged, out emailChanged);
                var  isUserTransient = user.IsTransient();
                user.Company = instance;
                UserModel.RegisterSave(user);
                //IoC.Resolve<RealTimeNotificationModel>().NotifyClientsAboutChangesInTable<User>(NotificationType.Update, user.Company.Id, user.Id);
                instance.PrimaryContact = user;
                companyModel.RegisterSave(instance, true);
                if (isUserTransient)
                {
                    UserActivationModel model = this.UserActivationModel;
                    UserActivation      userActivation;
                    if ((userActivation = model.GetLatestByUser(user.Id).Value) == null)
                    {
                        userActivation = UserActivation.Build(user);
                        model.RegisterSave(userActivation);
                    }

                    var license = instance.Licenses.FirstOrDefault();
                    if (license.Return(x => x.LicenseStatus == CompanyLicenseStatus.Trial, false))
                    {
                        user.Status = UserStatus.Active;
                        UserModel.RegisterSave(user);
                        this.SendTrialEmail(user, userActivation.ActivationCode, instance);
                    }
                    else if (license.Return(x => x.LicenseStatus == CompanyLicenseStatus.Enterprise, false))
                    {
                        user.Status = UserStatus.Active;
                        UserModel.RegisterSave(user);
                        this.SendEnterpriseEmail(user, userActivation.ActivationCode, instance);
                    }
                    else
                    {
                        this.SendActivation(user);
                    }
                }
                else if (passwordChanged || emailChanged)
                {
                    UserActivationModel model = this.UserActivationModel;
                    UserActivation      userActivation;
                    if ((userActivation = model.GetLatestByUser(user.Id).Value) == null)
                    {
                        userActivation = UserActivation.Build(user);
                        model.RegisterSave(userActivation);
                    }

                    this.SendActivationLinkEmail(user.FirstName, user.Email, userActivation.ActivationCode);
                }
            }
            else if (instance.PrimaryContact == null)
            {
                foreach (var companyLicense in instance.Licenses)
                {
                    companyLicenseModel.RegisterDelete(companyLicense);
                }

                companyModel.RegisterDelete(instance);
                companyModel.Flush();
                var errorRes = new Error(Errors.CODE_ERRORTYPE_GENERIC_ERROR, "CompanyWithoutContact", "Company was created without primary contact");
                throw new FaultException <Error>(errorRes, errorRes.errorMessage);
            }

            //IoC.Resolve<RealTimeNotificationModel>().NotifyClientsAboutChangesInTable<Company>(NotificationType.Update, instance.Id, instance.Id);
            var dtoResult = new CompanyDTO(instance);
            var lmses     = isTransient ? LmsCompanyModel.GetAllByCompanyId(instance.Id).ToList() : new List <LmsCompany>();

            var lms = lmses.FirstOrDefault();

            if (lms == null)
            {
                dtoResult.lmsVO = new CompanyLmsDTO();
            }
            else
            {
                LmsProvider lmsProvider = LmsProviderModel.GetById(lms.LmsProviderId);
                dtoResult.lmsVO = new CompanyLmsDTO(lms, lmsProvider, Settings);
            }
            return(dtoResult);
        }
コード例 #7
0
        private string SetupSharedMeetingsFolder(LmsCompany lmsCompany, LmsProvider lmsProvider, IAdobeConnectProxy provider)
        {
            string ltiFolderSco = null;
            string name         = lmsCompany.UserFolderName ?? lmsProvider.LmsProviderName;

            name = name.TruncateIfMoreThen(60);
            bool useDbFolderId = MeetingTypeFactory.UseDbMeetingFolderId(_lmsMeetingType);

            if (useDbFolderId && !string.IsNullOrWhiteSpace(lmsCompany.ACScoId))
            {
                ScoInfoResult meetingsFolder = provider.GetScoInfo(lmsCompany.ACScoId);
                if (meetingsFolder.Success && meetingsFolder.ScoInfo != null)
                {
                    if (meetingsFolder.ScoInfo.Name.Equals(name, StringComparison.OrdinalIgnoreCase))
                    {
                        ltiFolderSco = meetingsFolder.ScoInfo.ScoId;
                    }
                    else
                    {
                        ScoInfoResult updatedSco =
                            provider.UpdateSco(
                                new FolderUpdateItem
                        {
                            ScoId    = meetingsFolder.ScoInfo.ScoId,
                            Name     = name,
                            FolderId = meetingsFolder.ScoInfo.FolderId,
                            Type     = ScoType.folder
                        });
                        if (updatedSco.Success && updatedSco.ScoInfo != null)
                        {
                            ltiFolderSco = updatedSco.ScoInfo.ScoId;
                        }
                    }
                }
            }

            if (ltiFolderSco == null)
            {
                var shortcutName = MeetingTypeFactory.GetMeetingFolderShortcut(_lmsMeetingType, false).GetACEnum();
                ScoContentCollectionResult sharedMeetings = provider.GetContentsByType(shortcutName);
                if (sharedMeetings.ScoId != null && sharedMeetings.Values != null)
                {
                    ScoContent existingFolder = sharedMeetings.Values.FirstOrDefault(v => v.Name.Equals(name, StringComparison.OrdinalIgnoreCase) && v.IsFolder);
                    if (existingFolder != null)
                    {
                        ltiFolderSco = existingFolder.ScoId;
                    }
                    else
                    {
                        ScoInfoResult newFolder = provider.CreateSco(new FolderUpdateItem {
                            Name = name, FolderId = sharedMeetings.ScoId, Type = ScoType.folder
                        });
                        if (newFolder.Success && newFolder.ScoInfo != null)
                        {
                            provider.UpdatePublicAccessPermissions(newFolder.ScoInfo.ScoId, SpecialPermissionId.denied);
                            ltiFolderSco = newFolder.ScoInfo.ScoId;
                        }
                    }
                }
                if (ltiFolderSco != null && useDbFolderId)
                {
                    lmsCompany.ACScoId = ltiFolderSco;
                }
            }

            return(ltiFolderSco);
        }
コード例 #8
0
        public CompanyLmsDTO(LmsCompany instance, LmsProvider provider, dynamic settings)
        {
            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this.id     = instance.Id;
            this.useFLV = instance.UseFLV;
            this.useMP4 = instance.UseMP4;
            this.enableMultipleMeetings = instance.EnableMultipleMeetings;
            this.acServer     = instance.AcServer;
            this.acUsername   = instance.AcUsername;
            this.companyId    = instance.CompanyId.Return(x => x, 0);
            this.consumerKey  = instance.ConsumerKey;
            this.createdBy    = instance.CreatedBy.Return(x => x, 0);
            this.modifiedBy   = instance.ModifiedBy.Return(x => x.Value, 0);
            this.dateCreated  = instance.DateCreated.ConvertToUnixTimestamp();
            this.dateModified = instance.DateModified.ConvertToUnixTimestamp();

            this.lmsProvider           = provider.Return(x => x.ShortName, string.Empty);
            this.sharedSecret          = instance.SharedSecret;
            this.lmsAdmin              = instance.AdminUser.With(x => x.Username);
            this.lmsAdminToken         = instance.AdminUser.With(x => x.Token);
            this.lmsDomain             = instance.LmsDomain.AddHttpProtocol(instance.UseSSL.GetValueOrDefault());
            this.primaryColor          = instance.PrimaryColor;
            this.title                 = instance.Title;
            this.useUserFolder         = instance.UseUserFolder.GetValueOrDefault();
            this.canRemoveMeeting      = instance.CanRemoveMeeting.GetValueOrDefault();
            this.canEditMeeting        = instance.CanEditMeeting.GetValueOrDefault();
            canStudentCreateStudyGroup = instance.GetSetting <bool>(LmsLicenseSettingNames.CanStudentCreateStudyGroup, true);
            this.isSettingsVisible     = instance.IsSettingsVisible.GetValueOrDefault();
            this.enableOfficeHours     = instance.EnableOfficeHours.GetValueOrDefault();
            this.enableStudyGroups     = instance.EnableStudyGroups.GetValueOrDefault();
            this.enableCourseMeetings  = instance.EnableCourseMeetings.GetValueOrDefault();

            this.enableVirtualClassrooms      = instance.GetSetting <bool>(LmsLicenseSettingNames.EnableVirtualClassrooms, false);
            this.namedVirtualClassroomManager = instance.GetSetting <bool>(LmsLicenseSettingNames.NamedVirtualClassroomManager, true);
            this.labelVirtualClassroom        = instance.GetSetting <string>(LmsLicenseSettingNames.VirtualClassroomsLabel);

            this.showEGCHelp            = instance.ShowEGCHelp.GetValueOrDefault();
            this.showLmsHelp            = instance.ShowLmsHelp.GetValueOrDefault();
            this.addPrefixToMeetingName = instance.AddPrefixToMeetingName.GetValueOrDefault();
            this.userFolderName         = instance.UserFolderName;

            Uri portalUrl = new Uri((string)settings.PortalUrl, UriKind.Absolute);

            this.setupUrl = new Uri(portalUrl, $"content/lti-config/{provider.LmsProviderName}.xml").ToString();

            this.enableProxyToolMode = instance.EnableProxyToolMode ?? false;
            this.proxyToolPassword   = instance.ProxyToolSharedPassword;

            this.allowUserCreation      = !instance.DenyACUserCreation;
            this.showAuthToken          = !instance.LoginUsingCookie.GetValueOrDefault();
            this.acUsesEmailAsLogin     = instance.ACUsesEmailAsLogin.GetValueOrDefault();
            this.enableAnnouncements    = instance.ShowAnnouncements.GetValueOrDefault();
            this.useSynchronizedUsers   = instance.UseSynchronizedUsers;
            this.meetingNameFormatterId = instance.MeetingNameFormatterId;
            this.roleMapping            = instance.RoleMappings.Select(x =>
                                                                       new LmsCompanyRoleMappingDTO(x.LmsRoleName, x.AcRole, x.IsDefaultLmsRole, x.IsTeacherRole)).ToArray();
            this.isSandbox       = instance.GetSetting <bool>(LmsLicenseSettingNames.IsOAuthSandbox);
            this.oAuthAppId      = instance.GetSetting <string>(LmsLicenseSettingNames.OAuthAppId);
            this.oAuthAppKey     = instance.GetSetting <string>(LmsLicenseSettingNames.OAuthAppKey);
            this.supportPageHtml = instance.GetSetting <string>(LmsLicenseSettingNames.SupportPageHtml);
            this.isActive        = instance.IsActive;

            this.labelMeeting    = instance.GetSetting <string>(LmsLicenseSettingNames.LabelMeeting);
            this.labelOfficeHour = instance.GetSetting <string>(LmsLicenseSettingNames.LabelOfficeHour);
            this.labelStudyGroup = instance.GetSetting <string>(LmsLicenseSettingNames.LabelStudyGroup);

            this.enableMeetingReuse   = instance.EnableMeetingReuse;
            this.additionalLmsDomains = instance.AdditionalLmsDomains;

            this.showSummary  = instance.GetSetting <bool>(LmsLicenseSettingNames.ShowMeetingSummary);
            this.showTime     = instance.GetSetting <bool>(LmsLicenseSettingNames.ShowMeetingTime);
            this.showDuration = instance.GetSetting <bool>(LmsLicenseSettingNames.ShowMeetingDuration);

            this.canRemoveRecordings     = instance.CanRemoveRecordings;
            this.autoPublishRecordings   = instance.AutoPublishRecordings;
            this.forcedAddInInstallation = instance.GetSetting <bool>(LmsLicenseSettingNames.ForcedAddInInstallation);

            this.languageId = instance.LanguageId;

            this.mp4ServiceLicenseKey = instance.GetSetting <string>(LmsLicenseSettingNames.Mp4ServiceLicenseKey);
            this.mp4ServiceWithSubtitlesLicenseKey = instance.GetSetting <string>(LmsLicenseSettingNames.Mp4ServiceWithSubtitlesLicenseKey);

            this.showAudioProfile                 = instance.GetSetting <bool>(LmsLicenseSettingNames.ShowAudioProfile);
            this.audioProfileUnique               = instance.GetSetting <bool>(LmsLicenseSettingNames.AudioProfileUnique);
            this.enableSeminars                   = instance.GetSetting <bool>(LmsLicenseSettingNames.SeminarsEnable);
            this.labelSeminar                     = instance.GetSetting <string>(LmsLicenseSettingNames.SeminarsLabel);
            this.enableAuditGuestEntry            = instance.GetSetting <bool>(LmsLicenseSettingNames.EnableAuditGuestEntry);
            this.HidePrivateRecordingsForStudents = instance.GetSetting <bool>(LmsLicenseSettingNames.HidePrivateRecordingsForStudents);
            useSakaiEvents          = instance.GetSetting <bool>(LmsLicenseSettingNames.UseSakaiEvents);
            enableMeetingSessions   = instance.GetSetting <bool>(LmsLicenseSettingNames.EnableMeetingSessions);
            enableMyContent         = instance.GetSetting <bool>(LmsLicenseSettingNames.EnableMyContent);
            enableAddGuest          = instance.GetSetting <bool>(LmsLicenseSettingNames.EnableAddGuest, true);
            enableSetUserRole       = instance.GetSetting <bool>(LmsLicenseSettingNames.EnableSetUserRole, true);
            enableRemoveUser        = instance.GetSetting <bool>(LmsLicenseSettingNames.EnableRemoveUser, true);
            moodleCoreServiceToken  = instance.GetSetting <string>(LmsLicenseSettingNames.MoodleCoreServiceToken);
            moodleQuizServiceToken  = instance.GetSetting <string>(LmsLicenseSettingNames.MoodleQuizServiceToken);
            schoologyConsumerKey    = instance.GetSetting <string>(LmsLicenseSettingNames.SchoologyConsumerKey);
            schoologyConsumerSecret = instance.GetSetting <string>(LmsLicenseSettingNames.SchoologyConsumerSecret);
            haikuConsumerKey        = instance.GetSetting <string>(LmsLicenseSettingNames.HaikuConsumerKey);
            haikuConsumerSecret     = instance.GetSetting <string>(LmsLicenseSettingNames.HaikuConsumerSecret);
            haikuToken                    = instance.GetSetting <string>(LmsLicenseSettingNames.HaikuToken);
            haikuTokenSecret              = instance.GetSetting <string>(LmsLicenseSettingNames.HaikuTokenSecret);
            isPdfMeetingUrl               = instance.GetSetting <bool>(LmsLicenseSettingNames.IsPdfMeetingUrl);
            bridgeApiTokenKey             = instance.GetSetting <string>(LmsLicenseSettingNames.BridgeApiTokenKey);
            bridgeApiTokenSecret          = instance.GetSetting <string>(LmsLicenseSettingNames.BridgeApiTokenSecret);
            UseCourseSections             = instance.GetSetting <bool>(LmsLicenseSettingNames.UseCourseSections);
            UseCourseMeetingsCustomLayout = instance.GetSetting <bool>(LmsLicenseSettingNames.UseCourseMeetingsCustomLayout);
            EnableOfficeHoursSlots        = instance.GetSetting <bool>(LmsLicenseSettingNames.EnableOfficeHoursSlots);
            EnableCanvasExportToCalendar  = instance.GetSetting <bool>(LmsLicenseSettingNames.EnableCanvasExportToCalendar);
            Telephony = new TelephonyDTO(instance);
        }
コード例 #9
0
        /// <summary>
        /// The save.
        /// </summary>
        /// <param name="resultDto">
        /// The result DTO.
        /// </param>
        /// <returns>
        /// The <see cref="CompanyLmsDTO"/>.
        /// </returns>
        public CompanyLmsOperationDTO Save(CompanyLmsDTO resultDto)
        {
            ValidationResult validationResult;

            if (!this.IsValid(resultDto, out validationResult))
            {
                var error = this.GenerateValidationError(validationResult);
                this.LogError("CompanyLMS.Save", error);
                throw new FaultException <Error>(error, error.errorMessage);
            }

            bool       isTransient = resultDto.id == 0;
            LmsCompany entity      = isTransient ? null : this.LmsCompanyModel.GetOneById(resultDto.id).Value;

            string lmsPassword = resultDto.lmsAdminPassword;

            if (!isTransient &&
                string.IsNullOrWhiteSpace(resultDto.lmsAdminPassword) &&
                ((entity.LmsProviderId == (int)LmsProviderEnum.Moodle &&
                  string.IsNullOrWhiteSpace(entity.GetSetting <string>(LmsLicenseSettingNames.MoodleCoreServiceToken))) ||
                 (entity.LmsProviderId == (int)LmsProviderEnum.Blackboard && !resultDto.enableProxyToolMode) ||
                 entity.LmsProviderId == (int)LmsProviderEnum.AgilixBuzz)
                )
            {
                lmsPassword = entity.AdminUser.Password;
            }

            if ((this.LmsProviderModel.GetByShortName(resultDto.lmsProvider).Id == (int)LmsProviderEnum.Blackboard) && resultDto.enableProxyToolMode)
            {
                lmsPassword = resultDto.proxyToolPassword;
            }

            if ((this.LmsProviderModel.GetByShortName(resultDto.lmsProvider).Id == (int)LmsProviderEnum.Schoology))
            {
                // TRICK: for test-connection only
                resultDto.lmsAdmin = resultDto.schoologyConsumerKey;
                lmsPassword        = resultDto.schoologyConsumerSecret;
            }

            ConnectionInfoDTO lmsConnectionTest;

            if (!string.IsNullOrWhiteSpace(resultDto.moodleCoreServiceToken))
            {
                lmsConnectionTest = new ConnectionInfoDTO {
                    status = OkMessage, info = "Test connection is not supported for Moodle Token mode"
                };
            }
            else
            {
                if (this.LmsProviderModel.GetByShortName(resultDto.lmsProvider).Id == (int)LmsProviderEnum.Haiku)
                {
                    lmsConnectionTest = TestConnection(new ConnectionTestDTO
                    {
                        domain = resultDto.lmsDomain,
                        enableProxyToolMode = resultDto.enableProxyToolMode,
                        login          = resultDto.lmsAdmin,
                        password       = lmsPassword,
                        type           = resultDto.lmsProvider,
                        consumerKey    = resultDto.haikuConsumerKey,
                        consumerSecret = resultDto.haikuConsumerSecret,
                        token          = resultDto.haikuToken,
                        tokenSecret    = resultDto.haikuTokenSecret
                    });
                }
                else
                {
                    lmsConnectionTest = TestConnection(new ConnectionTestDTO
                    {
                        domain = resultDto.lmsDomain,
                        enableProxyToolMode = resultDto.enableProxyToolMode,
                        login    = resultDto.lmsAdmin,
                        password = lmsPassword,
                        type     = resultDto.lmsProvider,
                    });
                }
            }

            string acPassword = (isTransient || !string.IsNullOrWhiteSpace(resultDto.acPassword))
                ? resultDto.acPassword
                : entity.AcPassword;

            string acConnectionInfo;
            bool   loginSameAsEmail;
            bool   acConnectionTest = TestConnectionService.TestACConnection(new ConnectionTestDTO
            {
                domain = resultDto.acServer,
                enableProxyToolMode = resultDto.enableProxyToolMode,
                login    = resultDto.acUsername,
                password = acPassword,
                type     = "ac",
            }, out acConnectionInfo, out loginSameAsEmail);

            string licenseTestResultMessage = null;

            if (lmsConnectionTest.status != OkMessage ||
                !acConnectionTest)
            {
                var message = new StringBuilder("LMS License is inactive due to following reasons: \r\n");
                if (lmsConnectionTest.status != OkMessage)
                {
                    message.AppendFormat("{0} connection failed. ({1}) \r\n",
                                         this.LmsProviderModel.GetByShortName(resultDto.lmsProvider).LmsProviderName,
                                         lmsConnectionTest.info);
                }

                if (!acConnectionTest)
                {
                    message.AppendFormat("Adobe Connect connection failed. ({0})",
                                         acConnectionInfo);
                }

                licenseTestResultMessage = message.ToString();
            }

            entity = ConvertDto(resultDto, entity);

            // NOTE: always use setting from AC not UI
            entity.ACUsesEmailAsLogin = loginSameAsEmail;
            entity.IsActive           = lmsConnectionTest.status == OkMessage && acConnectionTest;

            if (isTransient)
            {
                entity.ConsumerKey  = Guid.NewGuid().ToString();
                entity.SharedSecret = Guid.NewGuid().ToString();
            }

            this.LmsCompanyModel.RegisterSave(entity);
            this.LmsCompanyModel.ProcessLmsAdmin(entity, resultDto, LmsUserModel, LmsCompanyModel);

            LmsProvider lmsProvider = LmsProviderModel.GetById(entity.LmsProviderId);

            return(new CompanyLmsOperationDTO
            {
                companyLmsVO = new CompanyLmsDTO(entity, lmsProvider, Settings),
                message = licenseTestResultMessage,
            });
        }