/// <summary>
        /// Executes the WorkFlow.
        /// </summary>
        /// <param name="crmWorkflowContext">The <see cref="WorkFlowActivityBase.LocalWorkflowContext"/> which contains the
        /// <param name="executionContext" > <see cref="CodeActivityContext"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics 365 caches WorkFlow instances.
        /// The WorkFlow's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the WorkFlow. Also, multiple system threads
        /// could execute the WorkFlow at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in WorkFlows.
        /// </remarks>
        public override void ExecuteCRMWorkFlowActivity(CodeActivityContext executionContext, LocalWorkflowContext crmWorkflowContext)
        {
            if (crmWorkflowContext == null)
            {
                throw new ArgumentNullException("crmWorkflowContext");
            }

            TracingService = executionContext.GetExtension <ITracingService>();
            Service        = crmWorkflowContext.OrganizationService;
            Context        = crmWorkflowContext.WorkflowExecutionContext;

            var application = Application.Get(executionContext);
            var permit      = Permit.Get(executionContext);

            if (application == null && permit == null)
            {
                return;
            }

            string returnData;

            if (application != null)
            {
                TracingService.Trace("Getting Standard Rules for application: {0}", application.Id.ToString());
                returnData = Service.GetStandardRules(application);
            }
            else
            {
                TracingService.Trace("Getting Standard Rules for permit: {0}", permit.Id.ToString());
                returnData = Service.GetStandardRules(permit, defra_permit.EntityLogicalName, defra_permit.Fields.defra_permitId, defra_permit_lines.EntityLogicalName);
            }

            ReturnData.Set(executionContext, returnData);
            TracingService.Trace("Returning data: {0}", returnData);
        }
예제 #2
0
        /// <summary>
        /// Executes the WorkFlow.
        /// </summary>
        /// <param name="crmWorkflowContext">The <see cref="LocalWorkflowContext"/> which contains the
        /// <param name="executionContext" > <see cref="CodeActivityContext"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics 365 caches WorkFlow instances.
        /// The WorkFlow's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the WorkFlow. Also, multiple system threads
        /// could execute the WorkFlow at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in WorkFlows.
        /// </remarks>
        public override void ExecuteCRMWorkFlowActivity(CodeActivityContext executionContext, LocalWorkflowContext crmWorkflowContext)
        {
            if (crmWorkflowContext == null)
            {
                throw new ArgumentNullException("crmWorkflowContext");
            }

            TracingService = executionContext.GetExtension <ITracingService>();
            Service        = crmWorkflowContext.OrganizationService;
            Context        = crmWorkflowContext.WorkflowExecutionContext;

            var application = Application.Get(executionContext);
            var permit      = Permit.Get(executionContext);

            if (application == null && permit == null)
            {
                return;
            }

            var returnData = string.Empty;

            if (application != null)
            {
                TracingService.Trace("Getting site name and address for application: {0}", application.Id.ToString());
                returnData = Service.GetSiteDetails(application);
            }
            else if (permit != null)
            {
                TracingService.Trace("Getting site name and address for permit: {0}", permit.Id.ToString());
                returnData = Service.GetSiteDetails(permit, "defra_permit", "defra_permitid");
            }
            if (string.IsNullOrEmpty(returnData))
            {
                returnData = "not applicable";
            }
            this.SiteDetails.Set(executionContext, returnData);
            TracingService.Trace("Site name and address: {0}", returnData);
        }
        public IHttpActionResult Get(string PermitNumber)
        {
            if (PermitNumber == null)
            {
                return(Ok());                // Let's just not do anything if they post a null.
            }
            var           ua = new UserAccess(User.Identity.Name);
            List <Permit> lp =
                Permit.Get(
                    PermitNumber,
                    ua.current_access,
                    $@"Permit Controller: Get(string PermitNumber); 
               PermitNumber: {PermitNumber}; 
               user: {ua.user_name}");

            if (lp == null)
            {
                return(InternalServerError());
            }
            else
            {
                return(Ok(lp));
            }
        }