Beispiel #1
0
        public void Integration_TestEAWMLAutoNumberSuccess()
        {
            DataAccessAutoNumber dal = new DataAccessAutoNumber(OrganizationService, new MockTracingService());
            string nextNumber        = dal.GetNextAutoNumber("EAWML");

            Assert.IsTrue(nextNumber.Length == 11);
        }
Beispiel #2
0
        /// <summary>
        /// Executes the workflow activity.
        /// </summary>
        /// <param name="executionContext">The execution context.</param>
        protected override void Execute(CodeActivityContext executionContext)
        {
            // Create the services
            ITracingService tracingService = executionContext.GetExtension <ITracingService>();

            if (tracingService == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");
            }

            tracingService.Trace(
                "Entered GetNextAutoNumber.Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",
                executionContext.ActivityInstanceId,
                executionContext.WorkflowInstanceId);
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(null);

            // Call CRM
            DataAccessAutoNumber dal = new DataAccessAutoNumber(service, tracingService);
            string permitNumber      = dal.GetNextAutoNumber(AutoNumberName.Get(executionContext));

            // Return the auto-number
            GeneratedNumber.Set(executionContext, permitNumber);

            tracingService.Trace($"GetNextAutoNumber Done. Generated number: {permitNumber}, Activity Instance Id: {executionContext.ActivityInstanceId}, Workflow Instance Id: {executionContext.WorkflowInstanceId}");
        }
        private static string GetPermitNumber(ITracingService tracing, IPluginExecutionContext context,
                                              IOrganizationService service)
        {
            tracing.Trace("GetPermitNumber() start...");

            //Get the next permit number
            DataAccessAutoNumber permitAutoNumbering = new DataAccessAutoNumber(service, tracing);
            string permitNumber = permitAutoNumbering.GetNextAutoNumber("Waste");

            tracing.Trace("GetPermitNumber() Next permit number {0} hes been retrieved", permitNumber);
            return(permitNumber);
        }