private void AddSolutionComponentToMergedSolution( SolutionComponentBase component, List <MergedInSolutionComponent> mergedComponents) { MergedInSolutionComponent newItem = new MergedInSolutionComponent(component); MergedInSolutionComponent reasonWhyIsNotIn = null; newItem.IsIn = true; if (newItem.IsChild && newItem.ParentSolutionComponent == null) { newItem.ReasonWhyIsNot = MergedInSolutionComponent.ReasonWhyIsNotType.ParentIsNot; newItem.IsIn = false; } else { reasonWhyIsNotIn = GetReasonWhyIsNotIn(component, mergedComponents); } if (reasonWhyIsNotIn != null) { newItem.IsIn = false; newItem.RemovedByComponent = reasonWhyIsNotIn; newItem.ReasonWhyIsNot = MergedInSolutionComponent.ReasonWhyIsNotType.OverComponent; reasonWhyIsNotIn.HasRemovedComponents.Add(newItem); } mergedComponents.Add(newItem); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { SolutionComponentType type = (SolutionComponentType)value; string color = SolutionComponentBase.GetTypeColor(type); var brush = (SolidColorBrush)(new BrushConverter().ConvertFrom(color)); return(brush); }
public static SolutionComponentBase GetComponentDefinition(IOrganizationService service, Guid solutionComponentId) { SolutionComponentBase item = service.Retrieve(SolutionComponentBase.EntityLogicalName, solutionComponentId, new ColumnSet(true)) .ToSolutionComponent(); item.ObjectDefinition = CrmProvider.RetrieveObjectDefinition(service, item); return(item); }
public static void AddComponentToSolution( IOrganizationService service, Guid solutionId, SolutionComponentBase component) { var solution = service.Retrieve(Solution.EntityLogicalName, solutionId, new ColumnSet(true)) .ToSolution(); AddComponentToSolution(service, solution.UniqueName, component); }
public static void AddComponentToSolution( IOrganizationService service, string solutionUniqueName, SolutionComponentBase component) { AddSolutionComponentRequest addReq = new AddSolutionComponentRequest() { ComponentType = (int)component.Type, ComponentId = component.ObjectId, SolutionUniqueName = solutionUniqueName, AddRequiredComponents = false }; if (component.Type == SolutionComponentType.Entity) { addReq.DoNotIncludeSubcomponents = component.RootComponentBehavior == SolutionComponentBase.RootComponentBehaviorType.DoNotIncludeSubcomponents || component.RootComponentBehavior == SolutionComponentBase.RootComponentBehaviorType.IncludeAsShellOnly; } service.Execute(addReq); }
private MergedInSolutionComponent GetReasonWhyIsNotIn( SolutionComponentBase component, List <MergedInSolutionComponent> mergedComponents) { if (component.Type == SolutionComponentType.Entity && component.RootComponentBehavior != null) { MergedInSolutionComponent sameObjectId = mergedComponents.FirstOrDefault(k => k.ObjectId == component.ObjectId && component.RootComponentBehavior.Value > k.RootComponentBehavior.Value); return(sameObjectId); } else if (component.IsChild) { MergedInSolutionComponent sameObjectId = mergedComponents.FirstOrDefault(k => k.ObjectId == component.ObjectId); if (sameObjectId == null) { var parentComponent = mergedComponents .FirstOrDefault(k => k.Id == component.ParentSolutionComponent?.Id); if (parentComponent != null) { if (!parentComponent.IsIn) { return(parentComponent.RemovedByComponent); } return(null); } return(null); } return(sameObjectId); } return(null); }
public static SolutionComponentBase ToSolutionComponent(this Entity e) { if (e.LogicalName != SolutionComponentBase.EntityLogicalName) { throw new InvalidCastException(); } SolutionComponentBase s = new SolutionComponentBase(); s.Id = e.GetParameter <Guid>(SolutionComponentBase.AttributeDefinitions.Id); s.CreatedBy = e.GetParameter <EntityReference>(SolutionComponentBase.AttributeDefinitions.CreatedBy); s.CreatedOn = e.GetParameter <DateTime>(SolutionComponentBase.AttributeDefinitions.CreatedOn); s.IsMetadata = e.GetParameter <bool>(SolutionComponentBase.AttributeDefinitions.IsMetadata); s.ModifiedBy = e.GetParameter <EntityReference>(SolutionComponentBase.AttributeDefinitions.ModifiedBy); s.ModifiedOn = e.GetParameter <DateTime>(SolutionComponentBase.AttributeDefinitions.ModifiedOn); s.ObjectId = e.GetParameter <Guid>(SolutionComponentBase.AttributeDefinitions.ObjectId); s.RootSolutionComponentId = e.GetParameter <Guid>(SolutionComponentBase.AttributeDefinitions.RootSolutionComponentId); s.SolutionId = e.GetParameter <EntityReference>(SolutionComponentBase.AttributeDefinitions.SolutionId); s.Type = (SolutionComponentType)e.GetParameter <OptionSetValue>(SolutionComponentBase.AttributeDefinitions.Type).Value; if (e.Attributes.Contains(SolutionComponentBase.AttributeDefinitions.RootComponentBehavior)) { s.RootComponentBehavior = (SolutionComponentBase.RootComponentBehaviorType)e.GetParameter <OptionSetValue>(SolutionComponentBase.AttributeDefinitions.RootComponentBehavior).Value; } return(s); }
public static object RetrieveObjectDefinition(IOrganizationService service, SolutionComponentBase component) { var componentId = component.ObjectId; if (component.Type == SolutionComponentType.Entity) { return(GetEntityMetadata(service, componentId)); } else if (component.Type == SolutionComponentType.Field) { return(GetAttributeMetadata(service, component.ParentSolutionComponent.LogicalName, componentId)); } else if (component.Type == SolutionComponentType.Relationship) { return(GetRelationshipMetadata(service, componentId)); } else if (component.Type == SolutionComponentType.OptionSet) { return(GetOptionSetMetadata(service, componentId)); } else if (component.Type == SolutionComponentType.EntityKey) { return(GetEntityKeyMetadata(service, component.ParentSolutionComponent.LogicalName, componentId)); } else if (component.Type == SolutionComponentType.Role) { var logicalName = new RoleData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToRoleData()); } else if (component.Type == SolutionComponentType.RolePrivilege) { var logicalName = new RolePrivilegeData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToRolePrivilegeData()); } else if (component.Type == SolutionComponentType.View) { var logicalName = new ViewData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToViewData()); } else if (component.Type == SolutionComponentType.Workflow) { var logicalName = new WorkflowData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToWorkflowData()); } else if (component.Type == SolutionComponentType.EmailTemplate) { var logicalName = new EmailTemplateData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToEmailTemplateData()); } else if (component.Type == SolutionComponentType.Ribbon) { var logicalName = new RibbonData().EntityLogicalName; var data = GetRibbonData(service, componentId); return(data.ToRibbonData()); } else if (component.Type == SolutionComponentType.Chart) { var logicalName = new ChartData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToChartData()); } else if (component.Type == SolutionComponentType.Form) { var logicalName = new FormData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToFormData()); } else if (component.Type == SolutionComponentType.WebResource) { var logicalName = new WebResourceData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToWebResourceData()); } else if (component.Type == SolutionComponentType.Sitemap) { var logicalName = new SiteMapData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToSiteMap()); } else if (component.Type == SolutionComponentType.ConnectionRole) { var logicalName = new ConnectionRoleData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToConnectionRoleData()); } else if (component.Type == SolutionComponentType.HierarchyRule) { var logicalName = new HierarchyRuleData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToHierarchyRuleData()); } else if (component.Type == SolutionComponentType.App) { var logicalName = new AppData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToAppData()); } else if (component.Type == SolutionComponentType.PluginAssembly) { var logicalName = new PluginAssemblyData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToPluginAssemblyData()); } else if (component.Type == SolutionComponentType.PluginStep) { var logicalName = new PluginStepData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToPluginStepData()); } else if (component.Type == SolutionComponentType.RoutingRule) { var logicalName = new RoutingRuleData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToRoutingRuleData()); } else if (component.Type == SolutionComponentType.ConvertRule) { var logicalName = new ConvertRuleData().EntityLogicalName; return(GetGenericData(service, logicalName, componentId) .ToConvertRuleData()); } return(null); }