protected override void Execute(CodeActivityContext executionContext)
        {
            var serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            var tracingService = executionContext.GetExtension <ITracingService>();

            WorkflowContext     = executionContext.GetExtension <IWorkflowContext>();
            OrganizationService = serviceFactory.CreateOrganizationService(WorkflowContext.UserId);

            try
            {
                using (DataAccessLayerFactory = new DataAccessLayerFactory(OrganizationService, tracingService))
                {
                    CustomTracingService = DataAccessLayerFactory.GetTracingService();

                    PostExecute(executionContext);
                }
            }
            catch (FaultException <OrganizationServiceFault> ex)
            {
                throw new InvalidPluginExecutionException("An error occurred in the UpdateActivities plug-in.", ex);
            }
            catch (Exception ex)
            {
                CustomTracingService.Trace("FollowupPlugin: {0}", ex.ToString());
                throw;
            }
        }
コード例 #2
0
        public void Execute(IServiceProvider serviceProvider)
        {
            var tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

            PluginContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

            if (!PluginContext.InputParameters.Contains("Target") || !(PluginContext.InputParameters["Target"] is Entity))
            {
                return;
            }

            Entity = (Entity)PluginContext.InputParameters["Target"];
            if (Entity.LogicalName != ExpectedEntityLogicalName)
            {
                return;
            }
            IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

            OrganizationService    = serviceFactory.CreateOrganizationService(PluginContext.UserId);
            DataAccessLayerFactory = new DataAccessLayerFactory(OrganizationService, tracingService);
            CustomTracingService   = DataAccessLayerFactory.GetTracingService();
            try
            {
                PostExecute(serviceProvider);
            }
            catch (FaultException <OrganizationServiceFault> ex)
            {
                throw new InvalidPluginExecutionException("An error occurred in this plug-in.", ex);
            }
            catch (Exception ex)
            {
                CustomTracingService.Trace("Plugin Exception: {0}", ex.ToString());
                throw;
            }
        }
コード例 #3
0
        public void UpdateAccountWorkOrders(Guid accountID)
        {
            var WorkOrders = _workOrderDataAccessLayer.GetRelatedWorkOrders(accountID, WorkOrder.Attributes.ServiceAccount);
            string accountNumber = _workOrderDataAccessLayer.GetServiceAccountAccountNumber(accountID);
            if (WorkOrders != null && WorkOrders.Entities.Count > 0 && accountNumber != string.Empty)
            {
                _tracingService.Trace("Related WorkOrders for Service Account : {0} is {1}", accountID, WorkOrders.Entities.Count);
                foreach (var WorkOrderEntity in WorkOrders.Entities)
                {
                   
                    Guid WorkOrderID = (Guid)WorkOrderEntity[WorkOrder.Attributes.WorkOrderId];
                    WorkOrderEntity.Attributes[WorkOrder.Attributes.AccountNumber] = accountNumber;
                    WorkOrderEntity.Id = WorkOrderID;
                    _workOrderDataAccessLayer.UpdateEntity(WorkOrderEntity);
                    _tracingService.Trace(" WorkOrder {0} updated with Account Number {1}", WorkOrderID.ToString(), accountNumber);

                }


            }

        }
        public void UpdateAccountsEmails(Guid accountId)
        {
            var emails        = _emailDataAccessLayer.GetEmails(accountId);
            int closedEmails  = 0;
            int updatedEmails = 0;

            foreach (var email in emails)
            {
                if (string.IsNullOrEmpty(email.Subject))
                {
                    _emailDataAccessLayer.CloseEmailAsCancelled(email);
                    closedEmails++;
                }
                else
                {
                    email.ScheduledStart = DateTime.Today.AddDays(10);
                    _emailDataAccessLayer.UpdateEntity(email);
                    updatedEmails++;
                }
            }
            _tracingService.Trace("{0} closed emails and {1} updated emails", closedEmails, updatedEmails);
            _emailDataAccessLayer.Commit();
        }