Ejemplo n.º 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);
                agreementService.CreatePaymentSchedule(agreementRef);
            }
            catch (Exception ex)
            {
                throw new InvalidPluginExecutionException(ex.Message);
            }
        }
        public override void Executed(WorkflowData data)
        {
            try
            {
                EntityReference        agreementRef = AgreementReference.Get(data.Context);
                Entities.new_agreement entity       = data.Target.ToEntity <Entities.new_agreement>();

                AgreementService service = new AgreementService(data.OrganizationService);

                service.DeleteRelatedInvoicesWithAutoType(agreementRef);
                service.CreatePaymentSchedule(entity);
                service.UpdateAgreementScheduleDate(entity);
            }
            catch (Exception ex)
            {
                data.TracingService.Trace(ex.ToString());

                throw new InvalidWorkflowException(ex.Message);
            }
        }