示例#1
0
        public TelephonyProfileInfoResult TelephonyProfileUpdate(TelephonyProfileUpdateItem updateItem, bool isUpdate)
        {
            // act: "telephony-profile-update"
            if (updateItem == null)
            {
                throw new ArgumentNullException(nameof(updateItem));
            }

            var commandParams = QueryStringBuilder.EntityToQueryString(updateItem);

            if (updateItem.ProviderFields != null)
            {
                commandParams += updateItem.ProviderFields.ToQueryString();
            }

            StatusInfo status;
            var        doc = this.requestProcessor.Process(Commands.Telephony.ProfileUpdate, commandParams, out status);

            if (!ResponseIsOk(doc, status))
            {
                return(new TelephonyProfileInfoResult(status));
            }

            if (isUpdate)
            {
                return(this.TelephonyProfileInfo(updateItem.ProfileId));
            }

            // notice: no 'profile' will be returned during update!!
            //https://helpx.adobe.com/adobe-connect/webservices/telephony-provider-update.html
            var detailNode = doc.SelectSingleNode("results/telephony-profile");

            if (detailNode == null || detailNode.Attributes == null)
            {
                return(new TelephonyProfileInfoResult(status));
            }

            TelephonyProfile detail = null;

            try
            {
                detail = TelephonyProfileParser.Parse(detailNode);
            }
            catch (Exception ex)
            {
                TraceTool.TraceException(ex);
                status.Code    = StatusCodes.invalid;
                status.SubCode = StatusSubCodes.format;
                status.UnderlyingExceptionInfo = ex;
            }

            return(new TelephonyProfileInfoResult(status, detail));
        }
示例#2
0
        public TelephonyProfileInfoResult TelephonyProfileUpdate(TelephonyProfileUpdateItem updateItem, bool isUpdate)
        {
            if (updateItem == null)
            {
                throw new ArgumentNullException(nameof(updateItem));
            }

            TelephonyProfileInfoResult result;

            try
            {
                result = _provider.TelephonyProfileUpdate(updateItem, isUpdate);
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat(ex, "TelephonyProfileUpdate. ProfileName:{0}", updateItem.ProfileName);
                throw;
            }

            return(result);
        }
示例#3
0
        public TelephonyProfile CreateProfile(ILmsLicense lmsCompany, ILtiParam param, string profileName, IAdobeConnectProxy acProxy)
        {
            if (lmsCompany == null)
            {
                throw new ArgumentNullException(nameof(lmsCompany));
            }
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(profileName))
            {
                throw new ArgumentException("Non-empty value expected", nameof(profileName));
            }
            if (acProxy == null)
            {
                throw new ArgumentNullException(nameof(acProxy));
            }

            try
            {
                var    profiles   = acProxy.TelephonyProviderList(null);
                var    meetingOne = profiles.Values.FirstOrDefault(x => x.ClassName == ClassName);
                string providerId = meetingOne.ProviderId;

                if (meetingOne.ProviderStatus != "enabled")
                {
                    throw new InvalidOperationException("MeetingOne provider is not enabled");
                }

                var access = new AccessDetails
                {
                    UserName            = lmsCompany.GetSetting <string>(LmsLicenseSettingNames.Telephony.MeetingOne.UserName),
                    SecretHashKey       = lmsCompany.GetSetting <string>(LmsLicenseSettingNames.Telephony.MeetingOne.SecretHashKey),
                    OwningAccountNumber = lmsCompany.GetSetting <string>(LmsLicenseSettingNames.Telephony.MeetingOne.OwningAccountNumber),
                };

                var room = new RoomDto
                {
                    Host = new Host
                    {
                        Email          = param.lis_person_contact_email_primary,
                        FirstName      = param.PersonNameGiven,
                        LastName       = param.PersonNameFamily,
                        MailingAddress = param.lis_person_contact_email_primary,
                    },

                    RoomSettings = new RoomSettings
                    {
                        DialoutEnabled             = true,
                        AllowDomesticDialouts      = true,
                        AllowInternationalDialouts = true,
                    },
                };

                // TODO: DI
                RoomDto result = null;
                try
                {
                    var client = new MeetingOneClient(_baseAddress, _logger);
                    result = client.CreateRoom(access, room);
                }
                catch (Exception ex)
                {
                    _logger.Error("MeetingOneClient.CreateRoomAsync failed.", ex);
                    return(null);
                }

                var acProfile = new TelephonyProfileUpdateItem
                {
                    ProfileName = profileName,
                    // ProfileStatus = "enabled",
                    ProviderId = providerId,

                    ProviderFields = new MeetingOneProviderFields
                    {
                        ConferenceId = result.Number,
                        HostPin      = result.HostPIN,
                    },
                };

                TelephonyProfileInfoResult createdProfile = acProxy.TelephonyProfileUpdate(acProfile, false);
                return(createdProfile.TelephonyProfile);
            }
            catch (Exception ex)
            {
                _logger.Error($"CreateProfileAsync error. CompanyLicenseId: {lmsCompany.Id}.", ex);
                throw;
            }
        }