//<snippetBasicFilteringService>
using System;
using Microsoft.Crm.Services.Utility;
using Microsoft.Xrm.Sdk.Metadata;
using System.Collections.Generic;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Discovery;
using Microsoft.Xrm.Client;
using System.Xml;
using System.Xml.Linq;
namespace CRMExtensions
{
/// <summary>
/// Sample extension for the CrmSvcUtil.exe tool that generates early-bound
/// classes for custom entities.
/// </summary>
public sealed class BasicFilteringService : ICodeWriterFilterService
{
//To store the guids belongs to a specified
public List<Guid> li = new List<Guid>();
//Put the uniquename of the solution here
public string sSolution = "ActivityFeeds";
public BasicFilteringService(ICodeWriterFilterService defaultService)
{
this.DefaultService = defaultService;
// Call the function to generate the the guids for the solution
getDefaultEntities();
}
private ICodeWriterFilterService DefaultService { get; set; }
bool ICodeWriterFilterService.GenerateAttribute(AttributeMetadata attributeMetadata, IServiceProvider services)
{
return this.DefaultService.GenerateAttribute(attributeMetadata, services);
}
bool ICodeWriterFilterService.GenerateEntity(EntityMetadata entityMetadata, IServiceProvider services)
{
//if (!entityMetadata.IsCustomEntity.GetValueOrDefault()) { return false; }
//if (entityMetadata.LogicalName!="account") { return false; }
if (li.Contains(entityMetadata.MetadataId.Value)==false) { return false; }
return this.DefaultService.GenerateEntity(entityMetadata, services);
}
bool ICodeWriterFilterService.GenerateOption(OptionMetadata optionMetadata, IServiceProvider services)
{
return this.DefaultService.GenerateOption(optionMetadata, services);
}
bool ICodeWriterFilterService.GenerateOptionSet(OptionSetMetadataBase optionSetMetadata, IServiceProvider services)
{
return this.DefaultService.GenerateOptionSet(optionSetMetadata, services);
}
bool ICodeWriterFilterService.GenerateRelationship(RelationshipMetadataBase relationshipMetadata, EntityMetadata otherEntityMetadata,
IServiceProvider services)
{
return this.DefaultService.GenerateRelationship(relationshipMetadata, otherEntityMetadata, services);
}
bool ICodeWriterFilterService.GenerateServiceContext(IServiceProvider services)
{
return this.DefaultService.GenerateServiceContext(services);
}
// This function will add guids of solution entities
public void getDefaultEntities()
{
//you can put this in the config file
//change the connection details with your crm details
var connection = CrmConnection.Parse("Url=https://org.crm5.dynamics.com; Username=user@live.com; Password=password; DeviceID=deviceid; DevicePassword=password");
var context = new CrmOrganizationServiceContext(connection);
QueryExpression query = new QueryExpression()
{
Distinct = false,
EntityName = "solutioncomponent",
ColumnSet = new ColumnSet(true),
LinkEntities =
{
new LinkEntity
{
JoinOperator = JoinOperator.Inner,
LinkFromAttributeName = "solutionid",
LinkFromEntityName = "solutioncomponent",
LinkToAttributeName = "solutionid",
LinkToEntityName = "solution",
LinkCriteria =
{
Conditions =
{
new ConditionExpression("uniquename", ConditionOperator.Equal, sSolution)
}
}
}
},
Criteria =
{
Filters =
{
new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("componenttype", ConditionOperator.Equal, 1)
},
}
}
}
};
EntityCollection ec = context.RetrieveMultiple(query);
foreach (Entity entity in ec.Entities)
{
Guid id = (Guid)entity.Attributes["objectid"];
li.Add(id);
}
}//end function
}
//</snippetBasicFilteringService>
}
Please provide some feedback.
Microsoft Dynamics CRM training will help you manage and prioritize your business goals, customize.we teach MS Dynamics CRM training and class available at Hyderabad.
ReplyDeleteA locked and restricted crypto account but that did not stop me from the recovery of my crypto assets. I was locked out of my wallet, and restricted for reasons they couldn’t explain to me properly. I thought I had lost everything but a friend of mine recommended MorphoHack to me. A team of cyber security experts, crypto recovery specialists and ethical hackers who helped my case. In my situation, I was about to swindled by the crypto holding company, but MorphoHack helped me recover my crypto assets, gained access to my wallet and helped me regained my confidence. I’m truly thankful for their service and I highly recommend them to everyone out there. Contact them directly at Morphohack@cyberservices.com
ReplyDeleteMany people are afraid to pursue it further once they lose access to their crypto wallet and assets, but I put it to you that the longer you wait, the more complicated it becomes. Morphohack can help you act faster and more efficiently, you will be glad that you stumbled upon their services.