/// <summary>Initializes a new instance of the <see cref="T:Microsoft.Crm.Sdk.Messages.RollupRequest"></see> class.</summary> public RollupRequest() { this.RequestName = "Rollup"; this.Target = (EntityReference)null; this.Query = (QueryBase)null; this.RollupType = RollupType.None; }
public LookupRollup(string recordTypeWithRollup, string rollupField, string recordTypeRolledup, string fieldRolledUp, RollupType rollupType, string lookupName, Type objectType) { LookupName = lookupName; ObjectType = objectType; RecordTypeWithRollup = recordTypeWithRollup; RollupField = rollupField; RecordTypeRolledup = recordTypeRolledup; RollupType = rollupType; FieldRolledup = fieldRolledUp; Filters = new ConditionExpression[] { }; AddFilter("statecode", ConditionOperator.Equal, 0); LinkEntity = null; if (ObjectType != null) { if (ObjectType == typeof(decimal)) { NullAmount = (decimal)0; } else if (ObjectType == typeof(int)) { NullAmount = (int)0; } else if (ObjectType == typeof(Money)) { NullAmount = new Money(0); } else if (ObjectType == typeof(bool)) { NullAmount = false; } } }
private void LoadSettings() { RollupType rollupType = RollupType.ClonePercentage; try { using (RegistryKey rootKey = VSPackage.Instance.UserRegistryRoot) using (RegistryKey ourKey = rootKey.OpenSubKey(VSPackage.ProductName)) { if (ourKey != null) { object value = ourKey.GetValue("CloneExplorerRollup"); if (value != null) { string rollupTypeAsString = Convert.ToString(value, CultureInfo.InvariantCulture); RollupType parsedRollupType = (RollupType)Enum.Parse(typeof(RollupType), rollupTypeAsString); if (Enum.IsDefined(typeof(RollupType), parsedRollupType)) { rollupType = parsedRollupType; } } } } } catch { // Ignore any errors since it's not a big deal if we can't read // this setting. Not catching it would cause ugly error messages // in Visual Studio. } SelectedRollupType = rollupType; }
public RollupCenterUnit(string caption, long?accountid, int?jobid, bool isactive, bool isapproved, long?organizationunitid, RollupType rolluptypeid) { Caption = caption; AccountId = accountid; JobId = jobid; IsActive = isactive; IsApproved = isapproved; OrganizationUnitId = organizationunitid; RollupTypeId = rolluptypeid; }
private static string FormatRollupValue(SourceNode node, RollupType rollupType) { switch (rollupType) { case RollupType.None: return(String.Empty); case RollupType.NumberOfClones: if (node.NumberOfClones == 0) { return(String.Empty); } return(FormattingHelper.FormatInteger(node.NumberOfClones)); case RollupType.NumberOfCloneClasses: if (node.NumberOfCloneClasses == 0) { return(String.Empty); } return(FormattingHelper.FormatInteger(node.NumberOfCloneClasses)); case RollupType.NumberOfClonedLines: if (node.NumberOfClonedLines == 0) { return(String.Empty); } return(FormattingHelper.FormatInteger(node.NumberOfClonedLines)); case RollupType.NumberOfLines: if (node.LinesOfCode == 0) { return(String.Empty); } return(FormattingHelper.FormatInteger(node.LinesOfCode)); case RollupType.ClonePercentage: if (Math.Abs(node.ClonePercentage - Double.Epsilon) <= Double.Epsilon) { return(String.Empty); } return(FormattingHelper.FormatPercentage(node.ClonePercentage)); default: throw ExceptionBuilder.UnhandledCaseLabel(rollupType); } }
public LookupRollup(string recordTypeWithRollup, string rollupField, string recordTypeRolledup, string fieldRolledUp, RollupType rollupType, string lookupName, Type objectType, string separatorString, string orderByField, OrderType orderType) { LookupName = lookupName; ObjectType = objectType; SeparatorString = separatorString; OrderByField = orderByField ?? fieldRolledUp; OrderType = orderType; RecordTypeWithRollup = recordTypeWithRollup; RollupField = rollupField; RecordTypeRolledup = recordTypeRolledup; RollupType = rollupType; FieldRolledup = fieldRolledUp; if (ObjectType != null) { if (rollupType == RollupType.Count || rollupType == RollupType.Exists || rollupType == RollupType.Sum) { if (ObjectType == typeof(decimal)) { NullAmount = (decimal)0; } else if (ObjectType == typeof(int)) { NullAmount = (int)0; } else if (ObjectType == typeof(Money)) { NullAmount = new Money(0); } else if (ObjectType == typeof(bool)) { NullAmount = false; } } } }
private bool AllowsDifferenceChange(RollupType type) { return(new[] { RollupType.Count, RollupType.Sum }.Contains(type)); }
/// <summary> /// Retrieve all the entity records that are related to the specified record. /// <para> /// For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.rolluprequest(v=crm.8).aspx /// </para> /// </summary> /// <param name="recordId">Record Id</param> /// <param name="entityLogicalName">Record's entity logical name</param> /// <param name="query"> /// <see cref="QueryExpression"/> query for related records.</param> /// <param name="rollupTypeCode"> /// The <c>Rollup Type</c> (<see cref="RollupType"/> ) for the supported entities depends on the target entity type. /// <c>0 : None</c>, a rollup record is not requested. This member only retrieves the records that are directly related to a parent record. /// <c>1 : Related</c>, a rollup record is not requested. This member only retrieves the records that are directly related to a parent record /// <c>2 : Extended</c>, a rollup record that is directly related to a parent record and to any descendent record of a parent record, for example, children, grandchildren, and great-grandchildren records. /// <para> /// For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.rolluptype(v=crm.8).aspx /// </para> /// </param>. /// <returns> /// <seealso cref="EntityCollection"/> for related rollup data /// </returns> public EntityCollection Rollup(Guid recordId, string entityLogicalName, QueryExpression query, RollupType rollupTypeCode) { ExceptionThrow.IfGuidEmpty(recordId, "recordId"); ExceptionThrow.IfNullOrEmpty(entityLogicalName, "entityLogicalName"); ExceptionThrow.IfNull(query, "query"); ExceptionThrow.IfNullOrEmpty(query.EntityName, "query.EntityName"); string queryEntity = query.EntityName.ToLower().Trim(); List <string> supportedTargetList = new List <string>() { "account", "contact", "opportunity" }; if (!supportedTargetList.Contains(entityLogicalName.ToLower().Trim())) { ExceptionThrow.IfNotExpectedValue(entityLogicalName, "entityLogicalName", "", string.Format("'{0}' is not supported for this operation. For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.rolluprequest(v=crm.8).aspx", entityLogicalName)); } if (!RollupRequestSupportedEntityList().Contains(queryEntity)) { ExceptionThrow.IfNotExpectedValue(queryEntity, "Query.EntityName", "", string.Format("'{0}' is not supported for this operation. For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.rolluprequest(v=crm.8).aspx", queryEntity)); } if (!RollupRequestSupportedRollupCombinationList().Contains(new Tuple <string, string, RollupType>(queryEntity, entityLogicalName, rollupTypeCode))) { ExceptionThrow.IfNotExpectedValue(entityLogicalName, "entityLogicalName", "", string.Format("Target entity ('{0}') - Supported Entity ('{1}') - Rollup Type ('{2}') combination is not supported for this operation. For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.rolluprequest(v=crm.8).aspx", entityLogicalName, queryEntity, rollupTypeCode.ToString())); } RollupRequest request = new RollupRequest() { Target = new EntityReference(entityLogicalName, recordId), Query = query, RollupType = rollupTypeCode }; RollupResponse serviceResponse = (RollupResponse)this.OrganizationService.Execute(request); return(serviceResponse.EntityCollection); }