Microsoft.Xrm.Sdk.Entity.GetAttributeValue(string)

Here are the examples of the csharp api Microsoft.Xrm.Sdk.Entity.GetAttributeValue(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

748 Examples 7

19 Source : CrmSdkController.cs
with MIT License
from Adoxio

public IActionResult Index()
        {
            var idenreplacedy = (ClaimsIdenreplacedy)User.Idenreplacedy;
            var contacts = ServiceContext.CreateQuery("contact").ToList();
            return View(model: string.Join(",", contacts.Select(a => a.GetAttributeValue<string>("fullname"))));
        }

19 Source : CrmSdkController.cs
with MIT License
from Adoxio

public IActionResult MultipleCalls()
        {
            Trace.TraceInformation("Start MultipleCalls");

            WhoAmIResponse response = (WhoAmIResponse)OrgService.Execute(new WhoAmIRequest());
            Trace.TraceInformation("WhoAmI Executed");

            string responseText = $"{response.UserId} : ";

            List<string> contacts = null;
            contacts = ServiceContext.CreateQuery("contact").Select(a => a.GetAttributeValue<string>("fullname")).ToList();
            Trace.TraceInformation("Contact Query Executed");
            
            responseText += contacts != null ? string.Join(",", contacts) : "null";

            return View((object)responseText);
        }

19 Source : CrmSdkController.cs
with MIT License
from Adoxio

[Produces("application/json")]
        [Route("api/CrmSdk")]
        public IEnumerable<string> GetContacts()
        {
            var idenreplacedy = (ClaimsIdenreplacedy)User.Idenreplacedy;

            if (idenreplacedy.IsAuthenticated)
            {
                var contact = OrgService.GetContact(idenreplacedy);

                return new List<string> { contact.GetAttributeValue<string>("fullname") };
            }
            
            return ServiceContext.CreateQuery("contact").Select(a => a.GetAttributeValue<string>("fullname")).ToList();
        }

19 Source : ActivityMimeAttachmentDataAdapter.cs
with MIT License
from Adoxio

private static void SetResponseParameters(HttpResponseBase response, HttpCacheability defaultCacheability,
			Enreplacedy attachment, Enreplacedy webfile, ICollection<byte> data)
		{
			response.StatusCode = (int)HttpStatusCode.OK;
			response.ContentType = attachment.GetAttributeValue<string>("mimetype");

			var contentDispositionText = "inline";

			if (webfile != null)
			{
				var contentDispositionOptionSetValue = webfile.GetAttributeValue<OptionSetValue>("adx_contentdisposition");

				if (contentDispositionOptionSetValue != null)
				{
					switch (contentDispositionOptionSetValue.Value)
					{
						case 756150000: // inline
							contentDispositionText = "inline";
							break;
						case 756150001: // attachment
							contentDispositionText = "attachment";
							break;
						default:
							contentDispositionText = "inline";
							break;
					}
				}
			}

			if (string.Equals(response.ContentType, "text/html", StringComparison.OrdinalIgnoreCase) ||
				string.Equals(response.ContentType, "application/octet-stream", StringComparison.OrdinalIgnoreCase))
			{
				contentDispositionText = "attachment";
			}

			var contentDisposition = new StringBuilder(contentDispositionText);

			AppendFilenameToContentDisposition(attachment, contentDisposition);

			response.AppendHeader("Content-Disposition", contentDisposition.ToString());
			response.AppendHeader("Content-Length", data.Count.ToString(CultureInfo.InvariantCulture));

			var section = PortalCrmConfigurationManager.GetPortalCrmSection();
			var policy = section.CachePolicy.Annotation;

			Utility.SetResponseCachePolicy(policy, response, defaultCacheability);
		}

19 Source : CrmUser.cs
with MIT License
from Adoxio

public virtual void RemoveLogin(UserLoginInfo login)
		{
			if (!Enreplacedy.RelatedEnreplacedies.ContainsKey(UserConstants.ContactExternalIdenreplacedyRelationship)) return;

			var enreplacedies = Enreplacedy
				.RelatedEnreplacedies[UserConstants.ContactExternalIdenreplacedyRelationship].Enreplacedies
				.Where(e => e.GetAttributeValue<string>("adx_idenreplacedyprovidername") == login.LoginProvider && e.GetAttributeValue<string>("adx_username") == login.ProviderKey)
				.ToArray();

			foreach (var enreplacedy in enreplacedies)
			{
				Enreplacedy.RelatedEnreplacedies[UserConstants.ContactExternalIdenreplacedyRelationship].Enreplacedies.Remove(enreplacedy);
			}

			_logins = new Lazy<IEnumerable<CrmUserLogin>>(GetUserLogins);
		}

19 Source : ActivityMimeAttachmentDataAdapter.cs
with MIT License
from Adoxio

private IAttachment GetAttachmentFile(Enreplacedy activityMimeAttachment, Guid id)
		{
			ulong fileSize;
			if (!ulong.TryParse(activityMimeAttachment.GetAttributeValue<int>("filesize").ToString(), out fileSize))
			{
				fileSize = 0;
			}
			FileSize attachmentSize = new FileSize(fileSize);

			Enreplacedy attachment = null;
            if (activityMimeAttachment.Attributes.ContainsKey("attachmentid"))
			{
				attachment = new Enreplacedy("activitymimeattachment", activityMimeAttachment.GetAttributeValue<EnreplacedyReference>("attachmentid").Id);
			}

			return new Attachment
			{
				AttachmentContentType = activityMimeAttachment.GetAttributeValue<string>("mimetype"),
				AttachmentFileName = activityMimeAttachment.GetAttributeValue<string>("filename"),
				AttachmentIsImage =
					(new List<string> { "image/jpeg", "image/gif", "image/png" }).Contains(
						activityMimeAttachment.GetAttributeValue<string>("mimetype")),
				AttachmentSize = attachmentSize,
				AttachmentSizeDisplay = attachmentSize.ToString(),
				AttachmentUrl = attachment == null ? string.Empty : attachment.GetFileAttachmentUrl(_dependencies.GetWebsite()),
				AttachmentBody = GetAttachmentBody(activityMimeAttachment, activityMimeAttachment.Id),
				Enreplacedy = activityMimeAttachment
			};
		}

19 Source : BlogPostFactory.cs
with MIT License
from Adoxio

public IEnumerable<IBlogPost> Create(IEnumerable<Enreplacedy> blogPostEnreplacedies)
		{
			var posts = blogPostEnreplacedies.ToArray();
			var postIds = posts.Select(e => e.Id).ToArray();

			var extendedDatas = _serviceContext.FetchBlogPostExtendedData(postIds, BlogCommentPolicy.Closed, _website.Id);
			var commentCounts = _serviceContext.FetchBlogPostCommentCounts(postIds);

			return posts.Select(e =>
			{
				var path = _urlProvider.GetApplicationPath(_serviceContext, e);

				if (path == null)
				{
					return null;
				}

				Tuple<string, string, BlogCommentPolicy, string[], IRatingInfo> extendedDataValue;
				var extendedData = extendedDatas.TryGetValue(e.Id, out extendedDataValue)
					? extendedDataValue
					: new Tuple<string, string, BlogCommentPolicy, string[], IRatingInfo>(null, null, BlogCommentPolicy.Closed, new string[] { }, null);

				var authorReference = e.GetAttributeValue<EnreplacedyReference>("adx_authorid");
				var author = authorReference != null
					? new BlogAuthor(authorReference.Id, extendedData.Item1, extendedData.Item2, _archiveApplicationPathGenerator.GetAuthorPath(authorReference.Id, e.GetAttributeValue<EnreplacedyReference>("adx_blogid")))
					: new NullBlogAuthor() as IBlogAuthor;

				int commentCountValue;
				var commentCount = commentCounts.TryGetValue(e.Id, out commentCountValue) ? commentCountValue : 0;

				return new BlogPost(e, path, author, extendedData.Item3, commentCount, GetTags(e, extendedData.Item4), extendedData.Item5);
			})
			.Where(e => e != null)
			.ToArray();
		}

19 Source : BlogPostFactory.cs
with MIT License
from Adoxio

private IEnumerable<IBlogPostTag> GetTags(Enreplacedy post, IEnumerable<string> tagNames)
		{
			if (post == null) throw new ArgumentNullException("post");

			return tagNames == null
				? new IBlogPostTag[] { }
				: tagNames
					.Distinct(TagInfo.TagComparer)
					.OrderBy(name => name)
					.Select(name => new BlogPostTag(name, _archiveApplicationPathGenerator.GetTagPath(name, post.GetAttributeValue<EnreplacedyReference>("adx_blogid"))))
					.ToArray();
		}

19 Source : BlogSecurityProvider.cs
with MIT License
from Adoxio

private bool TryreplacedertBlog(OrganizationServiceContext serviceContext, Enreplacedy enreplacedy, CrmEnreplacedyRight right, CrmEnreplacedyCacheDependencyTrace dependencies, ContentMap map)
		{
			var pageReference = enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_parentpageid");
			if (pageReference == null)
			{
				return false;
			}

			var parentPage = serviceContext.RetrieveSingle(
				"adx_webpage",
				new[] { "adx_name" },
				new Condition("adx_webpageid", ConditionOperator.Equal, pageReference.Id));

			if (right == CrmEnreplacedyRight.Read)
			{
				return parentPage != null && this.WebPageSecurityProvider.Tryreplacedert(serviceContext, parentPage, right, dependencies);
			}

			if (!Roles.Enabled)
			{
				ADXTrace.Instance.TraceError(TraceCategory.Application, "Roles are not enabled for this application. Denying Change.");

				return false;
			}

			IEnumerable<Enreplacedy> authorRoles = new List<Enreplacedy>();
			EnreplacedyNode blogNode;
			if (!map.TryGetValue(enreplacedy, out blogNode))
			{
				return false;
			}

			if (blogNode is BlogNode)
			{
				authorRoles = ((BlogNode)blogNode).WebRoles.Select(wr => wr.ToEnreplacedy());
			}

			if (!authorRoles.Any())
			{
				return false;
			}

			dependencies.AddEnreplacedyDependencies(authorRoles);

			var userRoles = this.GetUserRoles();

			return authorRoles.Select(e => e.GetAttributeValue<string>("adx_name")).Intersect(userRoles, StringComparer.InvariantCulture).Any()
				|| (parentPage != null && this.WebPageSecurityProvider.Tryreplacedert(serviceContext, parentPage, right, dependencies));
		}

19 Source : BlogSecurityProvider.cs
with MIT License
from Adoxio

private bool TryreplacedertBlogPost(OrganizationServiceContext serviceContext, Enreplacedy enreplacedy, CrmEnreplacedyRight right, CrmEnreplacedyCacheDependencyTrace dependencies)
		{
			var blogReference = enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_blogid");

			if (blogReference == null)
			{
				return false;
			}

			var blog = serviceContext.RetrieveSingle(
				"adx_blog",
				new[] { "adx_parentpageid", "adx_websiteid" },
				new Condition("adx_blogid", ConditionOperator.Equal, blogReference.Id));

			if (blog == null)
			{
				return false;
			}

			var published = enreplacedy.GetAttributeValue<bool?>("adx_published").GetValueOrDefault(false);

			return this.Tryreplacedert(
				serviceContext,
				blog,
				(right == CrmEnreplacedyRight.Read && published ? CrmEnreplacedyRight.Read : CrmEnreplacedyRight.Change),
				dependencies);
		}

19 Source : BlogSecurityProvider.cs
with MIT License
from Adoxio

private bool TryreplacedertBlogPostComment(OrganizationServiceContext serviceContext, Enreplacedy enreplacedy, CrmEnreplacedyRight right, CrmEnreplacedyCacheDependencyTrace dependencies)
		{
			var blogPostReference = enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_blogpostid");

			if (blogPostReference == null)
			{
				return false;
			}

			var blogPost = serviceContext.RetrieveSingle(
				"adx_blogpost",
				new[] { "adx_blogid" },
				new Condition("adx_blogpostid", ConditionOperator.Equal, blogPostReference.Id));

			if (blogPost == null)
			{
				return false;
			}

			var approved = enreplacedy.GetAttributeValue<bool?>("adx_approved").GetValueOrDefault(false);

			return this.Tryreplacedert(
				serviceContext,
				blogPost,
				(right == CrmEnreplacedyRight.Read && approved ? CrmEnreplacedyRight.Read : CrmEnreplacedyRight.Change),
				dependencies);
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static IQueryable<Enreplacedy> GetAllBlogPostsInWebsite(this OrganizationServiceContext serviceContext, Guid websiteId)
		{
			// If multi-language is enabled, only select blog posts of blogs that are language-agnostic or match the current language.
			var contextLanguageInfo = HttpContext.Current.GetContextLanguageInfo();
			var query = contextLanguageInfo.IsCrmMultiLanguageEnabled ?
				from post in serviceContext.CreateQuery("adx_blogpost")
					join blog in serviceContext.CreateQuery("adx_blog") on post.GetAttributeValue<EnreplacedyReference>("adx_blogid").Id equals blog.GetAttributeValue<Guid>("adx_blogid")
					where blog.GetAttributeValue<EnreplacedyReference>("adx_websiteid") != null && blog.GetAttributeValue<EnreplacedyReference>("adx_websiteid").Id == websiteId 
					where blog.GetAttributeValue<EnreplacedyReference>("adx_websitelanguageid") == null || blog.GetAttributeValue<EnreplacedyReference>("adx_websitelanguageid").Id == contextLanguageInfo.ContextLanguage.EnreplacedyReference.Id
					where post.GetAttributeValue<EnreplacedyReference>("adx_blogid") != null && post.GetAttributeValue<bool?>("adx_published") == true
					orderby post.GetAttributeValue<DateTime?>("adx_date") descending
					select post 
				:
				from post in serviceContext.CreateQuery("adx_blogpost")
					join blog in serviceContext.CreateQuery("adx_blog") on post.GetAttributeValue<EnreplacedyReference>("adx_blogid").Id equals blog.GetAttributeValue<Guid>("adx_blogid")
					where blog.GetAttributeValue<EnreplacedyReference>("adx_websiteid") != null && blog.GetAttributeValue<EnreplacedyReference>("adx_websiteid").Id == websiteId
					where post.GetAttributeValue<EnreplacedyReference>("adx_blogid") != null && post.GetAttributeValue<bool?>("adx_published") == true
					orderby post.GetAttributeValue<DateTime?>("adx_date") descending
					select post;
			return query;
		}

19 Source : ActivityMimeAttachmentDataAdapter.cs
with MIT License
from Adoxio

private IAttachment GetAttachment(Enreplacedy enreplacedy)
		{
			return new Attachment(() => GetAttachmentFile(enreplacedy, enreplacedy.GetAttributeValue<EnreplacedyReference>("attachmentid").Id));
		}

19 Source : ActivityMimeAttachmentDataAdapter.cs
with MIT License
from Adoxio

private byte[] GetAttachmentBody(Enreplacedy attachment, Guid id)
		{
			if (!attachment.Attributes.ContainsKey("body"))
			{
				return null;
			}

			//Get the string representation of the attachment body
			var body = attachment.GetAttributeValue<string>("body");

			//Encode into a byte array and return
			return Convert.FromBase64String(body);
		}

19 Source : ActivityMimeAttachmentDataAdapter.cs
with MIT License
from Adoxio

private static void AppendFilenameToContentDisposition(Enreplacedy attachment, StringBuilder contentDisposition)
		{
			var filename = attachment.GetAttributeValue<string>("filename");

			if (string.IsNullOrEmpty(filename))
			{
				return;
			}

			// Escape any quotes in the filename. (There should rarely if ever be any, but still.)
			var escaped = filename.Replace(@"""", @"\""");

			// Quote the filename parameter value.
			contentDisposition.AppendFormat(@";filename=""{0}""", escaped);
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static IEnumerable<Tuple<int, int, int>> FetchBlogPostCountsGroupedByMonth(this OrganizationServiceContext serviceContext, Guid blogId)
		{
			var fetchXml = XDoreplacedent.Parse(@"
				<fetch mapping=""logical"" aggregate=""true"" distinct=""false"">
					<enreplacedy name=""adx_blogpost"">
						<attribute name=""adx_blogpostid"" alias=""count"" aggregate=""count"" />
						<attribute name=""adx_date"" groupby=""true"" dategrouping=""month"" alias=""month"" />
						<attribute name=""adx_date"" groupby=""true"" dategrouping=""year"" alias=""year"" />
						<filter type=""and"">
							<condition attribute=""adx_blogid"" operator=""eq"" />
							<condition attribute=""adx_published"" operator=""eq"" value=""true"" />
						</filter>
					</enreplacedy>
				</fetch>");

			var websiteIdCondition = fetchXml.XPathSelectElement("//filter/condition[@attribute='adx_blogid']");

			if (websiteIdCondition == null)
			{
				throw new InvalidOperationException(string.Format("Unable to select {0} element.", "adx_blogid filter condition"));
			}

			websiteIdCondition.SetAttributeValue("value", blogId.ToString());

			var response = (serviceContext as IOrganizationService).RetrieveMultiple(Fetch.Parse(fetchXml.ToString()));

			return response.Enreplacedies.Select(e =>
			{
				var year = (int)e.GetAttributeValue<AliasedValue>("year").Value;
				var month = (int)e.GetAttributeValue<AliasedValue>("month").Value;
				var count = (int)e.GetAttributeValue<AliasedValue>("count").Value;

				return new Tuple<int, int, int>(year, month, count);
			});
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static IEnumerable<Tuple<int, int, int>> FetchBlogPostCountsGroupedByMonthInWebsite(this OrganizationServiceContext serviceContext, Guid websiteId)
		{
			// If multi-language is enabled, only select blog posts of blogs that are language-agnostic or match the current language.
			var contextLanguageInfo = HttpContext.Current.GetContextLanguageInfo();
			string conditionalLanguageFilter = contextLanguageInfo.IsCrmMultiLanguageEnabled
				? string.Format(@"<filter type=""or"">
						<condition attribute=""adx_websitelanguageid"" operator=""null"" />
						<condition attribute=""adx_websitelanguageid"" operator=""eq"" value=""{0}"" />
					</filter>", contextLanguageInfo.ContextLanguage.EnreplacedyReference.Id.ToString("D"))
				: string.Empty;

			var fetchXml = XDoreplacedent.Parse(string.Format(@"
				<fetch mapping=""logical"" aggregate=""true"" distinct=""false"">
					<enreplacedy name=""adx_blogpost"">
						<attribute name=""adx_blogpostid"" alias=""count"" aggregate=""count"" />
						<attribute name=""adx_date"" groupby=""true"" dategrouping=""month"" alias=""month"" />
						<attribute name=""adx_date"" groupby=""true"" dategrouping=""year"" alias=""year"" />
						<filter type=""and"">
							<condition attribute=""adx_published"" operator=""eq"" value=""true"" />
						</filter>
						<link-enreplacedy name=""adx_blog"" from=""adx_blogid"" to=""adx_blogid"">
							<filter type=""and"">
								<condition attribute=""adx_websiteid"" operator=""eq"" />
								{0}
							</filter>
						</link-enreplacedy>
					</enreplacedy>
				</fetch>", conditionalLanguageFilter));

			var websiteIdCondition = fetchXml.XPathSelectElement("//link-enreplacedy[@name='adx_blog']/filter/condition[@attribute='adx_websiteid']");

			if (websiteIdCondition == null)
			{
				throw new InvalidOperationException("Unable to select the adx_websiteid filter condition element.");
			}

			websiteIdCondition.SetAttributeValue("value", websiteId.ToString());

			var response = (serviceContext as IOrganizationService).RetrieveMultiple(Fetch.Parse(fetchXml.ToString()));

			return response.Enreplacedies.Select(e =>
			{
				var year = (int)e.GetAttributeValue<AliasedValue>("year").Value;
				var month = (int)e.GetAttributeValue<AliasedValue>("month").Value;
				var count = (int)e.GetAttributeValue<AliasedValue>("count").Value;

				return new Tuple<int, int, int>(year, month, count);
			});
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static IEnumerable<Tuple<string, int>> FetchBlogPostTagCounts(this OrganizationServiceContext serviceContext, Guid blogId)
		{
			var fetchXml = XDoreplacedent.Parse(@"
				<fetch mapping=""logical"" aggregate=""true"" distinct=""false"">
					<enreplacedy name=""adx_blogpost_tag"">
						<attribute name=""adx_blogpostid"" alias=""count"" aggregate=""count"" />
						<link-enreplacedy name=""adx_tag"" from=""adx_tagid"" to=""adx_tagid"">
							<attribute name=""adx_name"" groupby=""true"" alias=""tag"" />
						</link-enreplacedy>
						<link-enreplacedy name=""adx_blogpost"" from=""adx_blogpostid"" to=""adx_blogpostid"">
							<filter type=""and"">
								<condition attribute=""adx_blogid"" operator=""eq"" />
								<condition attribute=""adx_published"" operator=""eq"" value=""true"" />
							</filter>
						</link-enreplacedy>
					</enreplacedy>
				</fetch>");

			var websiteIdCondition = fetchXml.XPathSelectElement("//link-enreplacedy[@name='adx_blogpost']/filter/condition[@attribute='adx_blogid']");

			if (websiteIdCondition == null)
			{
				throw new InvalidOperationException(string.Format("Unable to select {0} element.", "adx_blogid filter condition"));
			}

			websiteIdCondition.SetAttributeValue("value", blogId.ToString());

			var response = (serviceContext as IOrganizationService).RetrieveMultiple(Fetch.Parse(fetchXml.ToString()));

			return response.Enreplacedies.Select(e =>
			{
				var tag = (string)e.GetAttributeValue<AliasedValue>("tag").Value;
				var count = (int)e.GetAttributeValue<AliasedValue>("count").Value;

				return new Tuple<string, int>(tag, count);
			}).ToArray();
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static IEnumerable<Tuple<string, int>> FetchBlogPostTagCountsInWebsite(this OrganizationServiceContext serviceContext, Guid websiteId)
		{
			// If multi-language is enabled, only select blog posts of blogs that are language-agnostic or match the current language.
			var contextLanguageInfo = HttpContext.Current.GetContextLanguageInfo();
			string conditionalLanguageFilter = contextLanguageInfo.IsCrmMultiLanguageEnabled
				? string.Format(@"<filter type=""or"">
						<condition attribute=""adx_websitelanguageid"" operator=""null"" />
						<condition attribute=""adx_websitelanguageid"" operator=""eq"" value=""{0}"" />
					</filter>", contextLanguageInfo.ContextLanguage.EnreplacedyReference.Id.ToString("D"))
				: string.Empty;

			var fetchXml = XDoreplacedent.Parse(string.Format(@"
				<fetch mapping=""logical"" aggregate=""true"" distinct=""false"">
					<enreplacedy name=""adx_blogpost_tag"">
						<attribute name=""adx_blogpostid"" alias=""count"" aggregate=""count"" />
						<link-enreplacedy name=""adx_tag"" from=""adx_tagid"" to=""adx_tagid"">
							<attribute name=""adx_name"" groupby=""true"" alias=""tag"" />
						</link-enreplacedy>
						<link-enreplacedy name=""adx_blogpost"" from=""adx_blogpostid"" to=""adx_blogpostid"">
							<filter type=""and"">
								<condition attribute=""adx_published"" operator=""eq"" value=""true"" />
							</filter>
							<link-enreplacedy name=""adx_blog"" from=""adx_blogid"" to=""adx_blogid"">
								<filter type=""and"">
									<condition attribute=""adx_websiteid"" operator=""eq"" />
									{0}
								</filter>
							</link-enreplacedy>
						</link-enreplacedy>
					</enreplacedy>
				</fetch>", conditionalLanguageFilter));

			var websiteIdCondition = fetchXml.XPathSelectElement("//condition[@attribute='adx_websiteid']");

			if (websiteIdCondition == null)
			{
				throw new InvalidOperationException("Unable to select the adx_websiteid filter condition element.");
			}

			websiteIdCondition.SetAttributeValue("value", websiteId.ToString());

			var response = (serviceContext as IOrganizationService).RetrieveMultiple(Fetch.Parse(fetchXml.ToString()));

			return response.Enreplacedies.Select(e =>
			{
				var tag = (string)e.GetAttributeValue<AliasedValue>("tag").Value;
				var count = (int)e.GetAttributeValue<AliasedValue>("count").Value;

				return new Tuple<string, int>(tag, count);
			}).ToArray();
		}

19 Source : WebsiteBlogAggregationDataAdapter.cs
with MIT License
from Adoxio

public virtual IEnumerable<IBlog> SelectBlogs(int startRowIndex, int maximumRows = -1)
		{
			if (startRowIndex < 0)
			{
				throw new ArgumentException("Value must be a positive integer.", "startRowIndex");
			}

			if (maximumRows == 0)
			{
				return new IBlog[] { };
			}

			var serviceContext = Dependencies.GetServiceContext();
			var security = Dependencies.GetSecurityProvider();
			var urlProvider = Dependencies.GetUrlProvider();

			var query = SelectBlogEnreplacedies(serviceContext).ToList().OrderBy(blog => blog.GetAttributeValue<string>("adx_name"));

			if (maximumRows < 0)
			{
				return query.ToArray()
					.Where(e => security.Tryreplacedert(serviceContext, e, CrmEnreplacedyRight.Read))
					.Skip(startRowIndex)
					.Select(e => new Blog(e, urlProvider.GetApplicationPath(serviceContext, e), Dependencies.GetBlogFeedPath(e.Id)))
					.ToArray();
			}

			var pagedQuery = query;

			var paginator = new PostFilterPaginator<Enreplacedy>(
				(offset, limit) => pagedQuery.Skip(offset).Take(limit).ToArray(),
				e => security.Tryreplacedert(serviceContext, e, CrmEnreplacedyRight.Read),
				2);

			return paginator.Select(startRowIndex, maximumRows)
				.Select(e => new Blog(e, urlProvider.GetApplicationPath(serviceContext, e), Dependencies.GetBlogFeedPath(e.Id))).ToArray();
		}

19 Source : WebsiteBlogAggregationDataAdapter.cs
with MIT License
from Adoxio

public IBlog Select(Guid blogId)
		{
			ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Start: {0}", blogId));

			var blog = Select(e => e.GetAttributeValue<Guid>("adx_blogid") == blogId);

			if (blog == null)
			{
				ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Not Found");
			}

			ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("End: {0}", blogId));

			return blog;
		}

19 Source : WebsiteBlogAggregationDataAdapter.cs
with MIT License
from Adoxio

public IBlog Select(string blogName)
		{
			if (string.IsNullOrEmpty(blogName))
			{
				return null;
			}

            ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Start");

			var blog = Select(e => e.GetAttributeValue<string>("adx_name") == blogName);

			if (blog == null)
			{
				ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Not Found");
			}

			ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End");

			return blog;
		}

19 Source : WebsiteBlogAggregationDataAdapter.cs
with MIT License
from Adoxio

protected virtual bool TryreplacedertBlogPostRight(OrganizationServiceContext serviceContext, ICrmEnreplacedySecurityProvider securityProvider, Enreplacedy blogPost, CrmEnreplacedyRight right, IDictionary<Guid, bool> blogPermissionCache)
		{
			if (blogPost == null)
			{
				throw new ArgumentNullException("blogPost");
			}

			if (blogPost.LogicalName != "adx_blogpost")
			{
				throw new ArgumentException(string.Format("Value must have logical name {0}.", blogPost.LogicalName), "blogPost");
			}

			var blogReference = blogPost.GetAttributeValue<EnreplacedyReference>("adx_blogid");

			if (blogReference == null)
			{
				throw new ArgumentException(string.Format("Value must have enreplacedy reference attribute {0}.", "adx_blogid"), "blogPost");
			}

			bool cachedResult;

			if (blogPermissionCache.TryGetValue(blogReference.Id, out cachedResult))
			{
				return cachedResult;
			}
			
			var fetch = new Fetch
			{
				Enreplacedy = new FetchEnreplacedy("adx_blog")
				{
					Filters = new[]
					{
						new Filter
						{
							Conditions = new[]
							{
								new Condition("adx_blogid", ConditionOperator.Equal, blogReference.Id),
								new Condition("statecode", ConditionOperator.Equal, 0)
							}
						}
					}
				}
			};

			var blog = serviceContext.RetrieveSingle(fetch);
			var result = securityProvider.Tryreplacedert(serviceContext, blog, right);
			blogPermissionCache[blogReference.Id] = result;

			return result;
		}

19 Source : WebsiteBlogAggregationDataAdapter.cs
with MIT License
from Adoxio

private static bool IsActive(Enreplacedy enreplacedy)
		{
			if (enreplacedy == null)
			{
				return false;
			}

			var statecode = enreplacedy.GetAttributeValue<OptionSetValue>("statecode");

			return statecode != null && statecode.Value == 0;
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static IEnumerable<Enreplacedy> GetActiveCasesForContactByAccountId(this OrganizationServiceContext context, EnreplacedyReference contact, Guid accountid)
		{
			if (contact == null)
			{
				return Enumerable.Empty<Enreplacedy>();
			}

			// Get cases where the customer is the account of replacedigned to any caseaccess rule for the current contact that allows read and scoped to account
			var accountcases = from incident in context.CreateQuery("incident")
				join caseaccess in context.CreateQuery("adx_caseaccess")
				on incident.GetAttributeValue<EnreplacedyReference>("customerid") equals caseaccess.GetAttributeValue<EnreplacedyReference>("adx_accountid")
				where caseaccess.GetAttributeValue<EnreplacedyReference>("adx_contactid") == contact
					&& caseaccess.GetAttributeValue<bool?>("adx_read").GetValueOrDefault(false) && caseaccess.GetAttributeValue<OptionSetValue>("adx_scope") != null && caseaccess.GetAttributeValue<OptionSetValue>("adx_scope").Value == (int)CaseAccessScope.Account
					&& caseaccess.GetAttributeValue<EnreplacedyReference>("adx_accountid") == new EnreplacedyReference("account", accountid)
				where incident.GetAttributeValue<OptionSetValue>("statecode") != null && incident.GetAttributeValue<OptionSetValue>("statecode").Value == (int)IncidentState.Active
				select incident;

			// Get cases where the customer is a contact and where the parent customer of the contact is an account replacedigned to any caseaccess rule for the current contact that allows read and scoped to account
			var parentaccountcases = from incident in context.CreateQuery("incident")
				join c in context.CreateQuery("contact") on incident.GetAttributeValue<EnreplacedyReference>("customerid").Id equals c.GetAttributeValue<Guid>("contactid")
				join account in context.CreateQuery("account") on c.GetAttributeValue<EnreplacedyReference>("parentcustomerid").Id equals account.GetAttributeValue<Guid>("accountid")
				join caseaccess in context.CreateQuery("adx_caseaccess") on account.GetAttributeValue<Guid>("accountid") equals caseaccess.GetAttributeValue<EnreplacedyReference>("adx_accountid").Id
				where caseaccess.GetAttributeValue<EnreplacedyReference>("adx_contactid") == contact
					&& caseaccess.GetAttributeValue<bool?>("adx_read").GetValueOrDefault(false) && caseaccess.GetAttributeValue<OptionSetValue>("adx_scope") != null && caseaccess.GetAttributeValue<OptionSetValue>("adx_scope").Value == (int)CaseAccessScope.Account
					&& caseaccess.GetAttributeValue<EnreplacedyReference>("adx_accountid") == new EnreplacedyReference("account", accountid)
				where incident.GetAttributeValue<OptionSetValue>("statecode") != null && incident.GetAttributeValue<OptionSetValue>("statecode").Value == (int)IncidentState.Active
				select incident;

			var cases = accountcases.AsEnumerable().Union(parentaccountcases.AsEnumerable()).Distinct();

			return cases;
		}

19 Source : CmsCrmEntitySecurityProvider.cs
with MIT License
from Adoxio

protected virtual bool TestShortcutTarget(OrganizationServiceContext context, Enreplacedy enreplacedy, CrmEnreplacedyRight right, CrmEnreplacedyCacheDependencyTrace dependencies)
			{
				if (enreplacedy == null)
				{
					return false;
				}

				if (!string.IsNullOrEmpty(enreplacedy.GetAttributeValue<string>("adx_externalurl")))
				{
					return true;
				}

				if (enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_webpageid") != null)
				{
					return this.TestWebPage(context, enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_webpageid"), right, dependencies);
				}

				if (enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_webfileid") != null)
				{
					var reference = enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_webfileid");
					var webfile = context.RetrieveSingle(
						"adx_webfile",
						new[] { "adx_blogpostid", "adx_parentpageid" },
						new Condition("adx_webfileid", ConditionOperator.Equal, reference.Id));

					return this.TestWebFile(context, webfile, right, dependencies);
				}

				if (enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_forumid") != null)
				{
					return this.TestForum(context, enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_forumid"), right, dependencies);
				}

				// legacy enreplacedies
				if (enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_surveyid") != null)
				{
					return TestSurvey(context, enreplacedy.GetRelatedEnreplacedy(context, "adx_survey_shortcut"), right, dependencies);
				}

				if (enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_eventid") != null)
				{
					return TestEvent(context, enreplacedy.GetRelatedEnreplacedy(context, "adx_event_shortcut"), right, dependencies);
				}

				return false;
			}

19 Source : CmsCrmEntitySecurityProvider.cs
with MIT License
from Adoxio

protected virtual bool TestShortcutParent(OrganizationServiceContext context, Enreplacedy enreplacedy, CrmEnreplacedyRight right, CrmEnreplacedyCacheDependencyTrace dependencies)
			{
				return (enreplacedy != null) && TestWebPage(context, enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_webpageid"), right, dependencies);
			}

19 Source : CmsCrmEntitySecurityProvider.cs
with MIT License
from Adoxio

protected virtual bool TestParentWebPage(OrganizationServiceContext context, Enreplacedy enreplacedy, CrmEnreplacedyRight right, CrmEnreplacedyCacheDependencyTrace dependencies)
			{
				return (enreplacedy != null) && TestWebPage(context, enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_parentpageid"), right, dependencies);
			}

19 Source : CmsCrmEntitySecurityProvider.cs
with MIT License
from Adoxio

protected virtual bool TestWebFile(OrganizationServiceContext context, Enreplacedy enreplacedy, CrmEnreplacedyRight right, CrmEnreplacedyCacheDependencyTrace dependencies)
			{
				if (enreplacedy == null)
				{
					return false;
				}

				var parentBlogPostReference = enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_blogpostid");

				if (parentBlogPostReference != null)
				{
					var post = context.RetrieveSingle(parentBlogPostReference, new ColumnSet());
					return this.TestBlogPost(context, post, right, dependencies);
					}

				return TestParentWebPage(context, enreplacedy, right, dependencies);
			}

19 Source : CmsCrmEntitySecurityProvider.cs
with MIT License
from Adoxio

protected virtual bool TestFeedback(OrganizationServiceContext context, Enreplacedy enreplacedy, CrmEnreplacedyRight right, CrmEnreplacedyCacheDependencyTrace dependencies)
			{
				ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format(@"Testing right {0} on feedback ({1}).", right, enreplacedy.Id));

				dependencies.AddEnreplacedyDependency(enreplacedy);

				EnreplacedyReference relatedReference = enreplacedy.GetAttributeValue<EnreplacedyReference>("regardingobjectid");
				if (relatedReference == null)
				{
					return false;
				}

				// Determine the primary ID attribute of the regarding object
				var request = new RetrieveEnreplacedyRequest
				{
					LogicalName = relatedReference.LogicalName,
					EnreplacedyFilters = EnreplacedyFilters.Enreplacedy
				};

				var response = context.Execute(request) as RetrieveEnreplacedyResponse;
				if (response == null || response.EnreplacedyMetadata == null)
				{
					return false;
				}

				var primaryIdAttribute = response.EnreplacedyMetadata.PrimaryIdAttribute;

				// Retrieve the regarding object
				var relatedEnreplacedy = context.CreateQuery(relatedReference.LogicalName)
					.FirstOrDefault(e => e.GetAttributeValue<Guid>(primaryIdAttribute) == relatedReference.Id);

				if (relatedEnreplacedy == null)
				{
					return false;
				}

				var approved = enreplacedy.GetAttributeValue<bool?>("adx_approved").GetValueOrDefault(false);

				// If the right being replacederted is Read, and the comment is approved, replacedert whether the post is readable.
				if (right == CrmEnreplacedyRight.Read && approved)
				{
					return Tryreplacedert(context, relatedEnreplacedy, right, dependencies);
				}

				var author = enreplacedy.GetAttributeValue<EnreplacedyReference>("createdbycontact");

				// If there's no author on the post for some reason, only allow posts that are published, and preplaced the same replacedertion on the blog.
				if (author == null)
				{
					return approved && Tryreplacedert(context, relatedEnreplacedy, right, dependencies);
				}

				var portal = PortalCrmConfigurationManager.CreatePortalContext();

				// If we can't get a current portal user, only allow posts that are published, and preplaced the same replacedertion on the blog.
				if (portal == null || portal.User == null)
				{
					return approved && Tryreplacedert(context, relatedEnreplacedy, right, dependencies);
				}
				
				return Tryreplacedert(context, relatedEnreplacedy, right, dependencies);
			}

19 Source : CmsCrmEntitySecurityProvider.cs
with MIT License
from Adoxio

protected virtual bool TestServiceRequest(OrganizationServiceContext context, Enreplacedy enreplacedy)
			{
				return (enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_servicerequest") ?? enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_servicerequestid")) != null;
			}

19 Source : CmsCrmEntitySecurityProvider.cs
with MIT License
from Adoxio

protected virtual bool TryGetParentPermit(OrganizationServiceContext context, Enreplacedy enreplacedy, out Enreplacedy parentPermit)
			{
				var permitReference = enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_permit") ??
									  enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_permitid");

				if (permitReference != null)
				{
					parentPermit = context.CreateQuery("adx_permit").FirstOrDefault(
							p => p.GetAttributeValue<Guid>("adx_permitid") == permitReference.Id);
					return true;
				}
				parentPermit = null;
				return false;
			}

19 Source : CmsCrmEntitySecurityProvider.cs
with MIT License
from Adoxio

protected virtual bool TestParentPermit(OrganizationServiceContext context, Enreplacedy enreplacedy, CrmEnreplacedyRight right)
			{
				var contactid = enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_regardingcontact")
					?? enreplacedy.GetAttributeValue<EnreplacedyReference>("adx_regardingcontactid");

				var portalContext = PortalCrmConfigurationManager.CreatePortalContext(PortalName);

				return right == CrmEnreplacedyRight.Read
						&& contactid != null
						&& portalContext != null
						&& portalContext.User != null
						&& contactid.Equals(portalContext.User.ToEnreplacedyReference());
			}

19 Source : PublishingStateTransitionSecurityProvider.cs
with MIT License
from Adoxio

public void replacedert(OrganizationServiceContext context, Enreplacedy website, Enreplacedy fromState, Enreplacedy toState)
		{
			if (!Tryreplacedert(context, website, fromState, toState))
			{
				throw new SecurityException(string.Format("Security replacedertion for transition from state {0} to {1} failed.",
					fromState.GetAttributeValue<string>("adx_name"), toState.GetAttributeValue<string>("adx_name")));
			}
		}

19 Source : PublishingStateTransitionSecurityProvider.cs
with MIT License
from Adoxio

public bool Tryreplacedert(OrganizationServiceContext context, Enreplacedy website, Enreplacedy fromState, Enreplacedy toState)
		{
			var fromStateId = fromState.GetAttributeValue<Guid?>("adx_publishingstateid") ?? Guid.Empty;
			var toStateId = toState.GetAttributeValue<Guid?>("adx_publishingstateid") ?? Guid.Empty;

			return Tryreplacedert(context, website, fromStateId, toStateId);
		}

19 Source : PublishingStateTransitionSecurityProvider.cs
with MIT License
from Adoxio

public bool Tryreplacedert(OrganizationServiceContext context, Enreplacedy website, Guid fromStateId, Guid toStateId)
		{
			// Windows Live ID Server decided to return null for an unauthenticated user's name
			// A null username, however, breaks the Roles.GetRolesForUser() because it expects an empty string.
			var currentUsername = (HttpContext.Current.User != null && HttpContext.Current.User.Idenreplacedy != null)
				? HttpContext.Current.User.Idenreplacedy.Name ?? string.Empty
				: string.Empty;

			var userRoles = Roles.GetRolesForUser(currentUsername).ToLookup(role => role);

			//Get publshing state transitional rules 
			var publishingStateRulesApplicable = context.CreateQuery("adx_publishingstatetransitionrule").Where(psr =>
				psr.GetAttributeValue<EnreplacedyReference>("adx_fromstate_publishingstateid") == new EnreplacedyReference("adx_publishingstate", fromStateId) &&
				psr.GetAttributeValue<EnreplacedyReference>("adx_tostate_publishingstateid") == new EnreplacedyReference("adx_publishingstate", toStateId) &&
				psr.GetAttributeValue<EnreplacedyReference>("adx_websiteid") == website.ToEnreplacedyReference()).ToList();

			var webRoles = publishingStateRulesApplicable.SelectMany(rule => rule.GetRelatedEnreplacedies(context, "adx_publishingstatetransitionrule_webrole")
				.Where(role => role.GetAttributeValue<EnreplacedyReference>("adx_websiteid") != null && role.GetAttributeValue<EnreplacedyReference>("adx_websiteid").Id == website.Id))
					.ToList().Select(role => role.GetAttributeValue<string>("adx_name"));

			// Determine if the user belongs to any of the roles that apply to this rule grouping
			// If the user belongs to one of the roles... or if there are no rules applicable
			return (!publishingStateRulesApplicable.Any()) || webRoles.Any(role => userRoles.Contains(role));
		}

19 Source : ActivityEnabledEntityDataAdapter.cs
with MIT License
from Adoxio

private Enreplacedy CreateAlertEnreplacedy(EnreplacedyReference user, OrganizationServiceContext serviceContext)
		{
			if (user == null) throw new ArgumentNullException("user");

			if (user.LogicalName != "contact")
			{
                throw new ArgumentException(string.Format("Value must have logical name '{0}'", user.LogicalName), "user");
			}

            ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Start: {0}:{1}", user.LogicalName, user.Id));


			var existingAlert = SelectAlert(serviceContext, user);

			if (existingAlert != null)
			{
                ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("End: {0}:{1}, Alert Exists", user.LogicalName, user.Id));

				return null;
			}

			var metadataRequest = new RetrieveEnreplacedyRequest
									  {
										  LogicalName = RecordReference.LogicalName,
										  EnreplacedyFilters = EnreplacedyFilters.Attributes
									  };

			var metadataResponse = (RetrieveEnreplacedyResponse)serviceContext.Execute(metadataRequest);

			var primaryIdFieldName = metadataResponse.EnreplacedyMetadata.PrimaryIdAttribute;

			var primaryNameFieldName = metadataResponse.EnreplacedyMetadata.PrimaryNameAttribute;

			var record = serviceContext.CreateQuery(RecordReference.LogicalName).FirstOrDefault(
				r => r.GetAttributeValue<Guid>(primaryIdFieldName) == RecordReference.Id);

			var contact =
				serviceContext.CreateQuery("contact").FirstOrDefault(c => c.GetAttributeValue<Guid>("contactid") == user.Id);

			var alert = new Enreplacedy("adx_alertsubscription");

			alert["regardingobjectid"] = RecordReference;

			//replacedign the contact to the customer s list
			var activityparty = new Enreplacedy("activityparty");

			activityparty["partyid"] = user;

			var particpant = new EnreplacedyCollection(new List<Enreplacedy> { activityparty });

			alert["customers"] = particpant;

			alert["subject"] = string.Format(ResourceManager.GetString("Subscription_Added_Alert_Message"), contact.GetAttributeValue<string>("fullname"),
			                                 record.GetAttributeValue<string>(primaryNameFieldName));
			return alert;
		}

19 Source : AdDataAdapter.cs
with MIT License
from Adoxio

public IAd SelectAd(string adName)
		{
			if (string.IsNullOrEmpty(adName))
			{
				return null;
			}

            ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Start");

			var ad = SelectAd(e => e.GetAttributeValue<string>("adx_name") == adName);

			if (ad == null)
			{
                ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Not Found");
			}

            ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End");

			return ad;
		}

19 Source : AdDataAdapter.cs
with MIT License
from Adoxio

public IAdPlacement SelectAdPlacement(Guid adPlacementId)
		{
            ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Start: {0}",
				adPlacementId));

			var adPlacement = SelectAdPlacement(e => e.GetAttributeValue<Guid>("adx_adplacementid") == adPlacementId);

			if (adPlacement == null)
			{
                ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Not Found");
			}

            ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("End: {0}",
				adPlacementId));

			return adPlacement;
		}

19 Source : AdDataAdapter.cs
with MIT License
from Adoxio

public IAdPlacement SelectAdPlacement(string adPlacementName)
		{
			if (string.IsNullOrEmpty(adPlacementName))
			{
				return null;
			}

            ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Start");

			var adPlacement = SelectAdPlacement(e => e.GetAttributeValue<string>("adx_name") == adPlacementName);

			if (adPlacement == null)
			{
                ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Not Found");
			}

            ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End");

            return adPlacement;
		}

19 Source : ContentMapProvider.cs
with MIT License
from Adoxio

private static EnreplacedyNode Refresh(CrmDbContext context, ContentMap map, EnreplacedyReference reference)
		{
			reference.ThrowOnNull("reference");

			ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("LogicalName={0}, Id={1}", EnreplacedyNamePrivacy.GetEnreplacedyName(reference.LogicalName), reference.Id));

			EnreplacedyDefinition ed;

			if (map.Solution.Enreplacedies.TryGetValue(reference.LogicalName, out ed))
			{
				// retrieve a fresh enreplacedy which also acts as a backend validation

				var fetch = ed.CreateFetch();

				Enreplacedy enreplacedy = null;

				try
				{
					string primaryIdAttribute = EventHubBasedInvalidation.CrmChangeTrackingManager.Instance.TryGetPrimaryKey(reference.LogicalName);
					
					// The condition for the filter on primary key
					var primaryAttributeCondition = new Condition
					{
						Attribute = primaryIdAttribute,
						Operator = ConditionOperator.Equal,
						Value = reference.Id
					};

					var attributes = fetch.Enreplacedy.Attributes;
					var fQuery = new Fetch
					{
						Distinct = true,
						SkipCache = true,
						Enreplacedy = new FetchEnreplacedy
						{
							Name = reference.LogicalName,
							Attributes = attributes,
							Filters = new List<Filter>()
							{
								new Filter
								{
									Type = LogicalOperator.And,
									Conditions = new List<Condition>()
									{
										primaryAttributeCondition
									}
								}
							}
						}
					};

					enreplacedy = context.Service.RetrieveSingle(fQuery, true, true);
				}
				catch (FaultException<OrganizationServiceFault> fe)
				{
					// an exception occurs when trying to retrieve a non-existing enreplacedy

					if (!fe.Message.EndsWith("Does Not Exist"))
					{
						throw;
					}
				}

				// Check if the enreplacedy matches on the defined relationships.
				if (!ed.ShouldIncludeInContentMap(enreplacedy))
				{
					return null;
				}

				// check if the enreplacedy is inactive according to the definition
				var option = enreplacedy != null ? enreplacedy.GetAttributeValue<OptionSetValue>("statecode") : null;
				var isActive = ed.ActiveStateCode == null || (option != null && ed.ActiveStateCode.Value == option.Value);

				var node = map.Using(ContentMapLockType.Write, () => enreplacedy != null
					? (isActive
						? map.Replace(enreplacedy)
						: map.Deactivate(reference))
					: map.Remove(reference));

				return node;
			}

			ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Unknown: logicalName={0}", EnreplacedyNamePrivacy.GetEnreplacedyName(reference.LogicalName)));

			return null;
		}

19 Source : EntitySiteMapDisplayOrderComparer.cs
with MIT License
from Adoxio

public int Compare(Enreplacedy x, Enreplacedy y)
		{
			if (x == null && y == null)
			{
				return 0;
			}

			if (x == null)
			{
				return 1;
			}

			if (y == null)
			{
				return -1;
			}

			int? xDisplayOrder;
				
			// Try get a display order value for x.
			if (x.Attributes.Contains("adx_displayorder"))
			{
				try
				{
					xDisplayOrder = x.GetAttributeValue<int?>("adx_displayorder");
				}
				catch
				{
					xDisplayOrder = null;
				}
			}
			else
			{
				xDisplayOrder = null;
			}

			int? yDisplayOrder;
				
			// Try get a display order value for y.
			if (y.Attributes.Contains("adx_displayorder"))
			{
				try
				{
					yDisplayOrder = y.GetAttributeValue<int?>("adx_displayorder");
				}
				catch
				{
					yDisplayOrder = null;
				}
			}
			else
			{
				yDisplayOrder = null;
			}

			// If neither has a display order, they are ordered equally.
			if (!(xDisplayOrder.HasValue || yDisplayOrder.HasValue))
			{
				return 0;
			}

			// If x has no display order, and y does, order x after y.
			if (!xDisplayOrder.HasValue)
			{
				return 1;
			}

			// If x has a display order, and y does not, order y after x.
			if (!yDisplayOrder.HasValue)
			{
				return -1;
			}

			// If both have display orders, order by the comparison of that value.
			return xDisplayOrder.Value.CompareTo(yDisplayOrder.Value);
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

private static Enreplacedy GetPageTagByName(this OrganizationServiceContext context, string tagName)
		{
			return context.CreateQuery("adx_pagetag").ToList().Where(pt => TagName.Equals(pt.GetAttributeValue<string>("adx_name"), tagName)).FirstOrDefault();
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static void AddTagToWebPageAndSave(this OrganizationServiceContext context, Guid pageId, string tagName)
		{
			if (context.MergeOption == MergeOption.NoTracking)
			{
				throw new ArgumentException("The OrganizationServiceContext.MergeOption cannot be MergeOption.NoTracking.", "context");
			}

			if (string.IsNullOrEmpty(tagName))
			{
				throw new ArgumentException("Can't be null or empty.", "tagName");
			}

			if (pageId == Guid.Empty)
			{
				throw new ArgumentException("Argument must be a non-empty GUID.", "pageId");
			}

			var page = context.CreateQuery("adx_webpage").Single(p => p.GetAttributeValue<Guid>("adx_webpageid") == pageId);

			var tag = context.GetPageTagByName(tagName);

			// If the tag doesn't exist, create it
			if (tag == null)
			{
				tag = new Enreplacedy("adx_pagetag");
				tag["adx_name"] = tagName;

				context.AddObject(tag);
				context.SaveChanges();
				context.ReAttach(page);
				context.ReAttach(tag);
			}

			if (!page.GetRelatedEnreplacedies(context, "adx_pagetag_webpage").Any(t => t.GetAttributeValue<Guid>("adx_pagetagid") == tag.Id))
			{
				context.AddLink(page, new Relationship("adx_pagetag_webpage"), tag);

				context.SaveChanges();
			}
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static IEnumerable<Enreplacedy> GetVisibleChildPages(this OrganizationServiceContext context, Enreplacedy webPage)
		{
			webPage.replacedertEnreplacedyName("adx_webpage");

			var langContext = HttpContext.Current.GetContextLanguageInfo();
			var rootPage = langContext.GetRootWebPageEnreplacedy(context, webPage);
			var childPages = context.GetChildPages(rootPage);
			var visibleChildPages = childPages.Where(cp => !cp.GetAttributeValue<bool?>("adx_hiddenfromsitemap").GetValueOrDefault(false));
			return visibleChildPages;
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

private static Guid? GetId(Enreplacedy survey)
			{
				return survey.GetAttributeValue<Guid?>("adx_surveyid");
			}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static Enreplacedy GetLinkSetByName(this OrganizationServiceContext context, Enreplacedy website, string webLinkSetName)
		{
			var webLinkSets = context.GetLinkSets(website);
			return webLinkSets.FirstOrDefault(wls => wls.GetAttributeValue<string>("adx_name") == webLinkSetName);
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static Enreplacedy GetMembershipTypeByName(this OrganizationServiceContext context, Enreplacedy website, string membershipTypeName)
		{
			var membershipTypes = context.GetMembershipTypes(website);
			return membershipTypes.FirstOrDefault(mt => mt.GetAttributeValue<string>("adx_name") == membershipTypeName);
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static Enreplacedy GetSiteSettingByName(this OrganizationServiceContext context, Enreplacedy website, string siteSettingName)
		{
			var siteSettings = context.GetSiteSettings(website);
			return (from s in siteSettings where s.GetAttributeValue<string>("adx_name") == siteSettingName select s).FirstOrDefault();
		}

19 Source : OrganizationServiceContextExtensions.cs
with MIT License
from Adoxio

public static IOrderedEnumerable<Enreplacedy> GetOrderedWebLinks(this OrganizationServiceContext context, Enreplacedy webLinkSet)
		{
			webLinkSet.replacedertEnreplacedyName("adx_weblinkset");

			var webLinks = webLinkSet.GetRelatedEnreplacedies(context, "adx_weblinkset_weblink");
			return webLinks.OrderBy(wl => wl.GetAttributeValue<int?>("adx_displayorder"));
		}

See More Examples