Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix when copying form component #304

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,40 @@ protected override void ProcessRecord()
var toSolutionId = GetSolutionId(context, ToSolutionName);

var fromSolutionComponents = (from s in context.SolutionComponentSet
where s.SolutionId == new EntityReference(Solution.EntityLogicalName, fromSolutionId)
orderby s.RootSolutionComponentId descending
select new { s.Id, s.ComponentType, s.ObjectId, s.RootSolutionComponentId, s.IsMetadata }).ToList();
where s.SolutionId == new EntityReference(Solution.EntityLogicalName, fromSolutionId)
orderby s.RootSolutionComponentId descending
select new { s.Id, s.ComponentType, s.ObjectId, s.RootSolutionComponentId, s.IsMetadata, s.RootComponentBehavior }).ToList();
var toSolutionComponents = (from s in context.SolutionComponentSet
where s.SolutionId == new EntityReference(Solution.EntityLogicalName, toSolutionId)
select new { s.Id, s.ComponentType, s.ObjectId, s.RootSolutionComponentId }).ToList();
where s.SolutionId == new EntityReference(Solution.EntityLogicalName, toSolutionId)
select new { s.Id, s.ComponentType, s.ObjectId, s.RootSolutionComponentId, s.RootComponentBehavior }).ToList();

foreach (var solutionComponent in fromSolutionComponents)
{
if (toSolutionComponents.Exists(depen => depen.ObjectId == solutionComponent.ObjectId && depen.ComponentType.Value == solutionComponent.ComponentType.Value))
{
if (toSolutionComponents.Exists(depen => depen.ObjectId == solutionComponent.ObjectId
&& depen.ComponentType.Value == solutionComponent.ComponentType.Value
&& depen.RootComponentBehavior == solutionComponent.RootComponentBehavior))
{
continue;
}

var addReq = new AddSolutionComponentRequest()
{
ComponentId = (Guid)solutionComponent.ObjectId,
ComponentType = (int)solutionComponent.ComponentType.Value,
AddRequiredComponents = false,
ComponentType = solutionComponent.ComponentType.Value,
AddRequiredComponents = false,
SolutionUniqueName = ToSolutionName
};

if ((solutionComponent.IsMetadata ?? false) && fromSolutionComponents.Exists(depen => depen.RootSolutionComponentId == solutionComponent.Id))
if (solutionComponent.ComponentType.Value == (int)ComponentType.Entity && solutionComponent.RootComponentBehavior.Value == (int)SolutionComponent_RootComponentBehavior.IncludeSubcomponents)
{
addReq.DoNotIncludeSubcomponents = false;
base.WriteVerbose("DoNotIncludeSubcomponents set to false");
}
else if (solutionComponent.ComponentType.Value == (int)ComponentType.Entity || solutionComponent.RootSolutionComponentId != null) //when RootSolutionComponentId != null is an entity subcomponent
{
addReq.DoNotIncludeSubcomponents = true;
base.WriteVerbose("DoNotIncludeSubcomponents set to true");
}
}

OrganizationService.Execute(addReq);
base.WriteVerbose(string.Format("Moved component from solution with Id : {0} and Type : {1}", solutionComponent.ObjectId, solutionComponent.ComponentType.Value));
Expand All @@ -103,5 +110,5 @@ private Guid GetSolutionId(CIContext context, string solutionName)
}

#endregion
}
}
}