Ejemplo n.º 1
0
        public ActionResult GetVttFileViaPost(string fileScoId)
        {
            try
            {
                string    breezeToken;
                var       ac        = this.GetAdminProvider();
                Principal principal = GetPrincipal(LmsCompany, Session.LtiSession.LtiParam, fileScoId, ac, out breezeToken);

                //return new SubtitleUtility(ac, Logger).GetVttFile(principal.PrincipalId, fileScoId);

                ScoInfo   sco  = DoGetSco(fileScoId, ac, principal.PrincipalId);
                FileEntry file = GetOriginalFileContent(sco, ac);
                if (file == null)
                {
                    return(NotFound());
                }
                //string contentType;
                //new FileExtensionContentTypeProvider().TryGetContentType(FileName, out contentType);
                //return contentType ?? "application/octet-stream";

                return(File(file.Content, "text/html", file.FileName));
            }
            catch (Exception ex)
            {
                Logger.Error("GetVttFile", ex);
                return(StatusCode(500));
            }
        }
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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses the specified XML.
        /// </summary>
        /// <param name="xml">The XML.</param>
        /// <returns>SCO Info.</returns>
        public static ScoInfo Parse(XmlNode xml)
        {
            if (xml == null || xml.Attributes == null)
            {
                return(null);
            }

            var item = new ScoInfo();

            Parse(xml, item);
            return(item);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates metadata for a SCO, or updates existing metadata describing a SCO.
        /// Call SCO-update to create metadata only for SCOs that represent content, including
        /// meetings. You also need to upload content files with either SCO-upload or Connect Enterprise Manager.
        /// You must provide a folder-id or a SCO id, but not both. If you pass a folder-id, SCO-update
        /// creates a new SCO and returns a SCO id. If the SCO already exists and you pass a
        /// SCO-id, SCO-update updates the metadata describing the SCO.
        /// After you create a new SCO with SCO-update, call permissions-update to specify which
        /// users and groups can access it.
        /// </summary>
        /// <typeparam name="T">
        /// Base update item.
        /// </typeparam>
        /// <param name="meetingUpdateItem">
        /// The meeting item.
        /// </param>
        /// <param name="isUpdate">
        /// Is Update.
        /// </param>
        /// <returns>
        /// Save Meeting Result.
        /// </returns>
        private ScoInfoResult ScoUpdate <T>(T meetingUpdateItem, bool isUpdate)
            where T : ScoUpdateItemBase
        {
            if (meetingUpdateItem == null)
            {
                return(null);
            }

            //if (string.IsNullOrEmpty(scoUpdateItem.FolderId))
            //{
            //    return new ScoInfoResult(CreateStatusInfo(StatusCodes.invalid, StatusSubCodes.format, new ArgumentNullException("scoUpdateItem", "FolderId must be set to create new item")));
            //}

            var commandParams = QueryStringBuilder.EntityToQueryString(meetingUpdateItem, isUpdate);

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

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

            if (isUpdate)
            {
                return(this.GetScoInfo(meetingUpdateItem.ScoId));
            }

            // notice: no '/sco' will be returned during update
            var detailNode = doc.SelectSingleNode(ScoHome);

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

            ScoInfo meetingDetail = null;

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

            return(new ScoInfoResult(status, meetingDetail));
        }
Ejemplo n.º 5
0
        public static void Parse(XmlNode xml, ScoInfo info)
        {
            if (xml == null || xml.Attributes == null)
            {
                return;
            }

            info.AccountId   = xml.SelectAttributeValue("account-id");
            info.ScoId       = xml.SelectAttributeValue("sco-id");
            info.FolderId    = xml.SelectAttributeValue("folder-id");
            info.Icon        = xml.SelectAttributeValue("icon");
            info.SourceScoId = xml.SelectAttributeValue("source-sco-id");
            info.Language    = xml.SelectAttributeValue("lang");
            info.Type        = xml.ParseAttributeEnum("type", ScoType.not_set);

            info.BeginDate = xml.ParseNodeDateTime("date-begin/text()", default(DateTime));

            info.BeginDateOffset = xml.ParseNodeDateTimeOffset("date-begin/text()");

            info.EndDate            = xml.ParseNodeDateTime("date-end/text()", default(DateTime));
            info.DateCreated        = xml.ParseNodeDateTime("date-created/text()", DateTime.Now);
            info.DateModified       = xml.ParseNodeDateTime("date-modified/text()", DateTime.Now);
            info.Name               = xml.SelectSingleNodeValue("name/text()");
            info.Description        = xml.SelectSingleNodeValue("description/text()");
            info.UrlPath            = xml.SelectSingleNodeValue("url-path/text()");
            info.PassingScore       = xml.ParseNodeInt("passing-score/text()");
            info.Duration           = xml.ParseNodeInt("duration/text()");
            info.SectionCount       = xml.ParseNodeInt("section-count/text()");
            info.ExternalUrl        = xml.SelectSingleNodeValue("external-url/text()");
            info.MaxScore           = xml.ParseNodeInt("max-score/text()");
            info.TelephonyProfile   = xml.SelectSingleNodeValue("telephony-profile/text()");
            info.ScoTag             = xml.SelectSingleNodeValue("sco-tag/text()");
            info.MeetingPasscode    = xml.SelectSingleNodeValue("meeting-passcode/text()");
            info.EventGuestPolicy   = xml.SelectSingleNodeValue("event-guest-policy/text()");
            info.UpdateLinkedItem   = xml.ParseNodeBool("update-linked-item/text()");
            info.EventTemplateScoId = xml.SelectSingleNodeValue("event-template/text()");
            info.Chargebacks        = xml.SelectSingleNodeValue("chargebacks/text()");

            info.MeetingHtmlLaunch = bool.TryParse(xml.SelectSingleNodeValue("meetingHTMLLaunch/text()"), out bool meetingHtmlLaunch)
                ? meetingHtmlLaunch
                : (bool?)null;
            info.TrainingHtmlLaunch = bool.TryParse(xml.SelectSingleNodeValue("trainingHTMLLaunch/text()"), out bool trainingHtmlLaunch)
                ? trainingHtmlLaunch
                : (bool?)null;
            info.WebinarHtmlLaunch = bool.TryParse(xml.SelectSingleNodeValue("webinarHTMLLaunch/text()"), out bool webinarHtmlLaunch)
                ? webinarHtmlLaunch
                : (bool?)null;
        }
Ejemplo n.º 6
0
 private MeetingDTO GetMeetingDTOByScoInfo(ScoInfo result, IEnumerable <PermissionInfo> permission)
 {
     return(new MeetingDTO()
     {
         id = result.ScoId,
         ac_room_url = result.UrlPath.Trim("/".ToCharArray()),
         name = result.Name.Substring(result.Name.IndexOf("]") < 0 ? 0 : result.Name.IndexOf("]") + 2),
         summary = result.Description,
         template = result.SourceScoId,
         start_date = result.BeginDate.ToString("yyyy-MM-dd"),
         start_time = result.BeginDate.ToString("h:mm tt", CultureInfo.InvariantCulture),
         duration = (result.EndDate - result.BeginDate).ToString(@"h\:mm"),
         connect_server = Credentials.ACDomain,
         access_level = permission != null && permission.FirstOrDefault() != null?
                        permission.FirstOrDefault().PermissionId.ToString() : ""
     });
 }
Ejemplo n.º 7
0
 public static EventDetailModel ToEventUpdateModel(this ScoInfo entity)
 {
     return(new EventDetailModel
     {
         ScoId = entity.ScoId,
         FolderId = entity.FolderId,
         Name = entity.Name,
         Description = entity.Description,
         UrlPath = entity.UrlPath,
         BeginDate = entity.BeginDate,
         EndDate = entity.EndDate,
         Language = entity.Language,
         DateCreated = entity.DateCreated,
         DateModified = entity.DateModified,
         MeetingId = entity.SourceScoId
     });
 }
Ejemplo n.º 8
0
 /// <summary>
 /// The to model.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <param name="permissionId">The permission id.</param>
 /// <returns>
 /// The <see cref="ScoContentModel" />.
 /// </returns>
 public static MeetingDetailModel ToMeetingUpdateModel(this ScoInfo entity, string permissionId = null)
 {
     return(new MeetingDetailModel
     {
         ScoId = entity.ScoId,
         FolderId = entity.FolderId,
         Name = entity.Name,
         Description = entity.Description,
         UrlPath = entity.UrlPath,
         BeginDate = entity.BeginDate,
         EndDate = entity.EndDate,
         Language = entity.Language,
         DateCreated = entity.DateCreated,
         DateModified = entity.DateModified,
         PermissionId = permissionId
     });
 }
Ejemplo n.º 9
0
        private static FileEntry GetOriginalFileContent(ScoInfo file, IAdobeConnectProxy provider)
        {
            string error;

            byte[] content = provider.GetContentByUrlPath(file.UrlPath, "zip", out error);

            var             archive   = new ZipArchive(new MemoryStream(content));
            ZipArchiveEntry fileEntry = archive.Entries[0];

            byte[] fileContent;
            using (var memoryStream = new MemoryStream())
            {
                fileEntry.Open().CopyTo(memoryStream);
                fileContent = memoryStream.ToArray();
            }

            return(new FileEntry(fileContent, fileEntry.Name));
        }
Ejemplo n.º 10
0
        public string GetDownloadAsZipLink(string scoId, string breezeToken)
        {
            if (string.IsNullOrWhiteSpace(scoId))
            {
                throw new ArgumentException("Non-empty value expected", nameof(scoId));
            }
            if (string.IsNullOrWhiteSpace(breezeToken))
            {
                throw new ArgumentException("Non-empty value expected", nameof(breezeToken));
            }

            ScoInfo scoInfo = DoGetSco(scoId);

            string acDomain      = _provider.AdobeConnectRoot.ToString().TrimEnd('/');
            string cleanUrlPath  = scoInfo.UrlPath.Trim('/');
            string fileExtention = "zip";// $".{scoInfo.Icon}"; ppt\pptx?

            return($"{acDomain}/{cleanUrlPath}/output/{cleanUrlPath}.{fileExtention}?download={fileExtention}&session={breezeToken}");
        }
Ejemplo n.º 11
0
            public MeetingDTOInput Build(LmsCourseMeeting existed,
                                         ScoInfo sco)
            {
                if (existed == null)
                {
                    throw new ArgumentNullException(nameof(existed));
                }
                if (sco == null)
                {
                    throw new ArgumentNullException(nameof(sco));
                }

                if (string.IsNullOrWhiteSpace(Duration))
                {
                    Duration = null;
                }
                if (string.IsNullOrWhiteSpace(Name))
                {
                    Name = null;
                }
                if (string.IsNullOrWhiteSpace(StartDate))
                {
                    StartDate = null;
                }
                if (string.IsNullOrWhiteSpace(StartTime))
                {
                    StartTime = null;
                }
                if (string.IsNullOrWhiteSpace(Summary))
                {
                    Summary = null;
                }

                MeetingNameInfo nameInfo =
                    IoC.Resolve <IJsonDeserializer>().JsonDeserialize <MeetingNameInfo>(existed.MeetingNameJson);
                // NOTE: it is reused meeting or source of reusing
                string meetingName = string.IsNullOrWhiteSpace(nameInfo.reusedMeetingName) ? nameInfo.meetingName : nameInfo.reusedMeetingName;

                var start = sco.BeginDateOffset.Value;
                //string format = sco.Language == "es" ? "dd/MM/yy" : "MM/dd/yy";
                string format = "MM-dd-yyyy";

                return(new MeetingDTOInput
                {
                    AccessLevel = "view_hidden", // TODO???
                    AcRoomUrl = sco.UrlPath.Trim('/'),
                    //AudioProfileId = existed.AudioProfileId,
                    //AudioProfileName
                    //CanJoin
                    //ClassRoomId
                    Duration = Duration ?? (sco.EndDate - sco.BeginDate).ToString(@"h\:mm"),
                    Id = Id,
                    //IsDisabledForThisCourse
                    //IsEditable
                    Name = Name ?? meetingName,
                    //OfficeHours
                    //Reused
                    //ReusedByAnotherMeeting
                    //SectionIds
                    //Sessions
                    StartDate = StartDate ?? start.ToString(format),
                    StartTime = StartTime ?? start.ToString("hh:mm tt"),
                    //StartTimeStamp
                    Summary = Summary ?? sco.Description,
                    //TelephonyProfileFields
                    //Template = Template,
                    Type = (int)LmsMeetingType.Meeting,
                });
            }
Ejemplo n.º 12
0
 public ScoInfoResult(StatusInfo status, ScoInfo scoInfo)
     : base(status)
 {
     ScoInfo = scoInfo;
 }