Beispiel #1
0
        protected override void Execute(CodeActivityContext context)
        {
            var wfContext      = context.GetExtension <IWorkflowContext>();
            var servicefactory = context.GetExtension <IOrganizationServiceFactory>();
            var service        = servicefactory.CreateOrganizationService(null);
            var agreementRef   = AgreementReference.Get(context);

            try
            {
                AgreementService agreementService = new AgreementService(service);
                bool             hasInvoices      = agreementService.HasPayedInvoicesByAgreementId(agreementRef);
                if (hasInvoices)
                {
                    HasInvoice.Set(context, true);
                }
                else
                {
                    HasInvoice.Set(context, false);
                }
            }
            catch (Exception ex)
            {
                throw new InvalidPluginExecutionException(ex.Message);
            }
        }