protected void Page_Load(object sender, EventArgs e) { if (Request.HttpMethod == "GET") { ////if (LMSSession.IsInSession(Client.CLIENT_SESSION_ID)) //// hdnClientId.Value = EncryptionManager.Encrypt(Convert.ToString(LMSSession.GetValue(Client.CLIENT_SESSION_ID))); if (LMSSession.IsInSession(ContentKeys.SESSION_ACTIVITYID)) { hdnContentModuleId.Value = EncryptionManager.Encrypt(Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_ACTIVITYID))); courseId = Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_ACTIVITYID)); } if (LMSSession.IsInSession(ContentKeys.SESSION_LEARNER_ID)) { hdnUserId.Value = EncryptionManager.Encrypt(Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_LEARNER_ID))); learnerId = Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_LEARNER_ID)); } hdnCStartDate.Value = Convert.ToString(DateTime.UtcNow); return; } var requestXml = LoadRequestXml(); XMLLib xLib = new XMLLib(); if (requestXml == null) { Response.Redirect("DisplayError.aspx?error=SessionTimeout"); } //sClientId = CommonManager.DecodeAndDecrypt(xLib.fGetValue(requestXml, "/Root/ClientId")); sessionId = xLib.fGetValue(requestXml, "/Root/SessionId"); courseId = EncryptionManager.Decrypt(Convert.ToString(hdnContentModuleId.Value)); if (LMSSession.IsInSession(ContentKeys.SESSION_LEARNER_ID)) { hdnUserId.Value = EncryptionManager.Encrypt(Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_LEARNER_ID))); learnerId = Convert.ToString(LMSSession.GetValue(ContentKeys.SESSION_LEARNER_ID)); } if (requestXml != null) { XmlNode oRootNode = null; if (xLib.fCreateFirstContext(requestXml, "Root", ref oRootNode)) { string useCase = xLib.fGetValue(requestXml, "/Root/Case"); ProcessRequest(requestXml, useCase); } } }
public static short GetTotalPages(string clientId, string courseId) { string cacheKey = "PageCount-" + clientId + "-" + courseId; short TotalNoOfPages = 0; if (HttpContext.Current.Cache[cacheKey] == null) { string rootSharedPath = "root content path"; ContentModule entContent = new ContentModule(); ContentModuleManager entContentModuleManager = new ContentModuleManager(); entContent.ID = courseId; entContent.ClientId = clientId; entContent = entContentModuleManager.Execute(entContent, ContentModule.Method.GetByIDCoursePlayer); string sContentFolderPath = rootSharedPath + entContent.ContentModuleURL.Replace("/", @"\\"); string IMSManifestPath; if (String.IsNullOrEmpty(entContent.ImanifestUrl)) { IMSManifestPath = sContentFolderPath + "\\\\imsmanifest.xml"; } else { IMSManifestPath = rootSharedPath + entContent.ImanifestUrl.Replace("/", @"\"); } XmlNamespaceManager nsmanager; XMLLib xLib = new XMLLib(); XmlDocument oIMSXMLObj = null; XmlNodeList ScoNodeList = null; if (!xLib.fOpenFreeXMLDoc(ref oIMSXMLObj, IMSManifestPath)) { return(0); } nsmanager = new XmlNamespaceManager(oIMSXMLObj.NameTable); nsmanager.AddNamespace("adlcp", "http://www.adlnet.org/xsd/adlcp_rootv1p2"); oIMSXMLObj = xLib.StripDocumentNamespace(oIMSXMLObj); xLib.NSManager = nsmanager; XmlNode lRsrcNode = null; if (oIMSXMLObj != null) { xLib.fCreateContext(oIMSXMLObj, "/manifest/organizations/organization//item", ref ScoNodeList); foreach (XmlNode lItemNode in ScoNodeList) { string lIdentifierref = xLib.fDirectGetValue(lItemNode, "@identifierref"); if (lIdentifierref != "") { if (xLib.fCreateFirstContext(oIMSXMLObj, "/manifest/resources/resource[@identifier='" + lIdentifierref + "']", ref lRsrcNode)) { TotalNoOfPages++; } } } } HttpContext.Current.Cache.Insert(cacheKey, TotalNoOfPages, new CacheDependency(IMSManifestPath)); } else { TotalNoOfPages = Convert.ToInt16(HttpContext.Current.Cache[cacheKey]); } return(TotalNoOfPages); }