protected override void Execute(CodeActivityContext context)
        {
            if (context == null)
            {
                throw new InvalidPluginExecutionException("Context not found!");
            }
            ;

            var workflowContext = context.GetExtension <IWorkflowContext>();
            var serviceFactory  = context.GetExtension <IOrganizationServiceFactory>();
            var orgService      = serviceFactory.CreateOrganizationService(workflowContext.UserId);

            Guid recordId = Guid.Empty;

            if (Guid.TryParse(EntityId.Get <string>(context), out recordId))
            {
                DynamicsDAO             dynamicsDAO = new DynamicsDAO(orgService);
                List <AuditDetailModel> audits      = dynamicsDAO.RetrieveAuditHistory(EntityLogicalName.Get <string>(context), AttributeLogicalName.Get <string>(context), recordId);
                if (audits.Count > 0)
                {
                    if (audits.Where(w => w.Type == "optionsetvalue").ToList().Count > 0) //This is necessary because the audit log, capture all changes in attributes including 'clear'
                    {
                        OptionMetadataCollection optionMetadatas = dynamicsDAO.GetOptionsSetTextOnValue(EntityLogicalName.Get <string>(context), AttributeLogicalName.Get <string>(context));
                        audits.ReplaceOptionSetValuesByLabels(optionMetadatas);
                    }
                    else if (audits.Where(w => w.Type == "boolean").ToList().Count > 0)
                    {
                        BooleanOptionSetMetadata booleanOptionSetMetadata = dynamicsDAO.GetBooleanTextOnValue(EntityLogicalName.Get <string>(context), AttributeLogicalName.Get <string>(context));
                        audits.ReplaceBooleanValuesByLabels(booleanOptionSetMetadata);
                    }
                }
                ChangesCount.Set(context, audits.Count);
                History.Set(context, audits.ToJSON());
            }
        }
Exemple #2
0
        /// <summary>
        /// Principal method
        /// </summary>
        /// <param name="localContext"> Contexto de execução. </param>

        protected override void ExecuteCrmPlugin(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new InvalidPluginExecutionException("Context not found!");
            }
            ;

            //Language Code
            int languageCode = (int)localContext.PluginExecutionContext.InputParameters["LanguageCode"];
            //Record Logical Name
            string recordLogicalName = (string)localContext.PluginExecutionContext.InputParameters["RecordLogicalName"];
            //Record Id
            string recordId = (string)localContext.PluginExecutionContext.InputParameters["RecordId"];
            //Entity Logical Name
            string entityLogicalName = (string)localContext.PluginExecutionContext.InputParameters["EntityLogicalName"];
            //Atrribute Logical Name
            string attributeLogicalName = (string)localContext.PluginExecutionContext.InputParameters["AttributeLogicalName"];
            //Group By Atrribute Logical Name
            string groupByAttributeLogicalName = (string)localContext.PluginExecutionContext.InputParameters["GroupByAttributeLogicalName"];
            //Attribute Type
            string groupByAttributeType = (string)localContext.PluginExecutionContext.InputParameters["GroupByAttributeType"];
            //Intersect Entity Name
            string intersectEntityName = (string)localContext.PluginExecutionContext.InputParameters["IntersectEntityName"];
            //DAO
            var DAO = new DynamicsDAO(localContext.OrganizationService, localContext.OrganizationServiceAdmin, new EntityReference(recordLogicalName, new Guid(recordId)), languageCode);

            //Get additional details and entity count
            localContext.PluginExecutionContext.OutputParameters["GroupByResult"] = DAO.ExecuteGroupByQuery(entityLogicalName, attributeLogicalName, groupByAttributeType, groupByAttributeLogicalName, intersectEntityName).ToJSON();
        }
Exemple #3
0
        /// <summary>
        /// Principal method
        /// </summary>
        /// <param name="localContext"> Contexto de execução. </param>

        protected override void ExecuteCrmPlugin(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new InvalidPluginExecutionException("Context not found!");
            }
            ;

            //Language Code
            int languageCode = (int)localContext.PluginExecutionContext.InputParameters["LanguageCode"];
            //Record Id
            string recordId = (string)localContext.PluginExecutionContext.InputParameters["RecordId"];
            //Record Logical Name
            string recordLogicalName = (string)localContext.PluginExecutionContext.InputParameters["RecordLogicalName"];
            //One To Many Relationships
            string oneToManyRelationships = (string)localContext.PluginExecutionContext.InputParameters["OneToManyRelationships"];
            //Many to Many Relationships
            string manyToManyRelationships = (string)localContext.PluginExecutionContext.InputParameters["ManyToManyRelationships"];

            var DAO = new DynamicsDAO(localContext.OrganizationService, localContext.OrganizationServiceAdmin, new EntityReference(recordLogicalName, new Guid(recordId)), languageCode);

            localContext.PluginExecutionContext.OutputParameters["Relationships"] = DAO.RetrieveRelationships(oneToManyRelationships, manyToManyRelationships).ToJSON();
        }
Exemple #4
0
        protected override void Execute(CodeActivityContext context)
        {
            if (context == null)
            {
                throw new InvalidPluginExecutionException("Context not found!");
            }
            ;

            var workflowContext = context.GetExtension <IWorkflowContext>();
            var serviceFactory  = context.GetExtension <IOrganizationServiceFactory>();
            var orgService      = serviceFactory.CreateOrganizationService(workflowContext.UserId);

            DynamicsDAO dynamicsDAO = new DynamicsDAO(orgService);
            OptionMetadataCollection optionMetadata = dynamicsDAO.GetOptionsSet(EntityLogicalName.Get <string>(context), "statuscode");

            if (optionMetadata != null)
            {
                OptionSetMetadata.Set(context, optionMetadata.ConvertToModel());
            }
            else
            {
                OptionSetMetadata.Set(context, string.Empty);
            }
        }