i have a requirement This ‘if’ structure must be changed. As it is currently coded the agent version is only set when the policy GUID sent by RM matches a GUID of a policy on the server. We always want to set the version regardless of whether the GUIDs match.(what ever be the situation)
here is the coding
ResourcePolicy rp = null;
try
{
int rpindex = allObjects.Find(new Guid(policyGuid));
if (rpindex != -1)
{
rp = (ResourcePolicy)allObjects.GetAt(rpindex);
}
}
catch (System.Exception err)
{
SpoDebug.DebugTraceSevere(func, "Bad GUID: " + policyGuid + " Exception: " + err.Message);
rp = null;
}
if (rp == null) // this the if loop we need to concentrate
{
SpoDebug.DebugTraceSevere(func, "Unable to find ResourcePolicy with GUID: " + policyGuid);
}
else
{
// Search for the specified host
foreach (DataModelObject dmo in allObjects)
{
if (dmo is IResourcePolicy)
{
if (string.Compare(dmo.Name, hostName, true) == 0)
{
IResourcePolicy irp = (IResourcePolicy)dmo;
irp.ResourcePolicy = rp;
irp.AgentPolicyVersion.Version = Convert.ToInt64(policyVersion);
irp.ResourcePolicyEnabled = Convert.ToBoolean(enabled);
irp.AgentVersion = agentVersion;
so what i did i made the assignment (irp.AgentVersion = agentVersion;) outside if loop ( if (rp == null))
like this way but i am not getting version value
foreach (DataModelObject dmo in allObjects)
{
if (dmo is IResourcePolicy)
{
if (string.Compare(dmo.Name, hostName, true) == 0)
{
irp.AgentVersion = agentVersion;
}
Can any one suggest me what i have to do here