コード例 #1
0
		protected void AddResource_Click(object sender, ImageClickEventArgs e)
		{
            try
            {
                if (Session["KenticoUserInfo"] == null) return;

                var kenticoUserInfo = (UserInfo)Session["KenticoUserInfo"];

                var userInfo = UserInfoProvider.GetUserInfo(kenticoUserInfo.UserName);
                var currentUser = new CurrentUserInfo(userInfo, true);

			if (!currentUser.IsAuthorizedPerUIElement("CMS.Content", "EditForm"))
			{
				return;
			}

			var theImageButton = sender as ImageButton;
			if (theImageButton == null)
			{
				return;
			}

			string[] row = null;
			if (!string.IsNullOrEmpty(theImageButton.CommandArgument))
			{
				row = theImageButton.CommandArgument.Split(new[] { "|@|" }, StringSplitOptions.None);
			}
                var theResource = new Resource();

			if (row == null || row.Length <= 0) return;

		    theResource.Source = row[0];
            theResource.URL = theResource.Source == PBSLearningMedia ? row[5] : row[1];
                theResource.ResourceName = row[3];
                theResource.Description = row[4];

			var clientId = DistrictParms.LoadDistrictParms().ClientID;
                var userAliasPath = String.Concat(FORWARD_SLASH, KenticoHelper.GetKenticoMainFolderName(clientId), FORWARD_SLASH,
                    "Users");
                var provider = new TreeProvider(currentUser);

                var parent = provider.SelectSingleNode(CMSContext.CurrentSiteName,
                    userAliasPath + FORWARD_SLASH + kenticoUserInfo.UserName, "en-us");
            var webLink = theResource.Source == PBSLearningMedia
                    ? Request.Url.GetLeftPart(UriPartial.Authority) +
                  ResolveUrl("~/Services/KenticoServices/KenticoWebServices.aspx?resource=PBSLearningMedia&url=" +
                             theResource.URL)
                : theResource.URL;

                if (parent == null) return;

                var ci = DataClassInfoProvider.GetDataClass(ResourceClassName);

				var node = CMS.DocumentEngine.TreeNode.New(ResourceClassName, provider);
				node.SetValue("Type", 84); // static Resource ID
				node.SetValue("SubType", 97); // static Resource Web-Based ID
				node.SetValue("Name", theResource.ResourceName);
				node.SetValue("DocumentName", theResource.ResourceName);
				node.SetValue("Description", theResource.Description);
				node.SetValue("DocumentCulture", "en-us");
				node.SetValue("CreateDate", DateTime.Now);
                node.SetValue("CreatedBy", kenticoUserInfo.UserName);
				node.SetValue("Category", 0);
				node.SetValue("AttachmentName", null);
				node.SetValue("Grade", null);
				node.SetValue("Subject", null);
				node.SetValue("Courses", null);
				node.SetValue("DocRecordID", null);
                node.SetValue("WebLink", webLink);
				node.SetValue("DocumentPageTemplateID", ci.ClassDefaultPageTemplateID);
				node.Insert(parent.NodeID);

				theImageButton.ImageUrl = "~/Images/Check.png";
				theImageButton.ToolTip = "Resource Added to My Docs";
				theImageButton.Enabled = false;
			}
            catch (Exception ex)
            {
                throw ex;
            }

		}
コード例 #2
0
		private List<Resource> BuildLearningRegistryResultList(EsQueryResult esQuerySearchResults)
		{

			List<EsQueryResultRow> searchResults = esQuerySearchResults.QueryResults;

			var list = new List<Resource>();
			foreach (EsQueryResultRow row in searchResults)
			{
				var resource = new Resource
				{
					Source = NationalLearningRegistry,
					//ID = DataIntegrity.ConvertToInt(row.IntID),
					ResourceName = row.Title,
					Type = row.Type,
					ID_Encrypted = row.URL,
					ViewLink = String.Empty,
					Description = row.Description,

					Publisher = row.Publisher,
					URL = row.URL,
					Creator = row.Author + "<br>" + row.Creator,
					Created = row.Created,
					UsageRightsURL = row.UsageRightsURL,
					ViewsCount = row.ViewsCount
				};
				list.Add(resource);
			}

			return list;
		}
コード例 #3
0
		/// <summary>
		///  AddResource
		/// </summary>
		/// <param name="list"></param>
		/// <param name="resource"></param>
		private void AddResource(List<Resource> list, Resource resource)
		{
			if (list.SingleOrDefault(r => r.DocumentNodeID == resource.DocumentNodeID) == null)
			{
				list.Add(resource);
			}
		}
コード例 #4
0
		private List<Resource> BuildResourceMediaList(IEnumerable<LearningMediaSearchResult> learningMediaSearchResults)
		{
			var list = new List<Resource>();
			foreach (LearningMediaSearchResult row in learningMediaSearchResults)
			{
				var resource = new Resource
				{
					Source = PBSLearningMedia,
					ID = DataIntegrity.ConvertToInt(row.UniqueIdentifier),
					ResourceName = row.Title,
					Type = row.MediaType,
					URL = row.Url,
					ViewLink = String.Empty,
					Description = row.ShortDescription
				};
				list.Add(resource);
			}

			return list;
		}