protected override void ExecuteCrmPlugin(LocalPluginContext localContext)
        {
            if (localContext == null) throw new ArgumentNullException(nameof(localContext));
            IPluginExecutionContext context = localContext.PluginExecutionContext;
            const string target = PluginConstants.Target;
            if (!context.InputParameters.Contains(target) || !(context.InputParameters[target] is Entity)) return;
            Entity entity = (Entity)context.InputParameters[target];

            bru_jobapplication jobapplication = entity.ToEntity<bru_jobapplication>();

            Entity preImage = context.PreEntityImages.FirstOrDefault(i => i.Key == PluginConstants.PreImage).Value;

            if (!string.Equals(jobapplication.LogicalName, bru_jobapplication.EntityLogicalName, StringComparison.CurrentCultureIgnoreCase)) return;
            if (!string.Equals(context.MessageName, PluginConstants.Update, StringComparison.CurrentCultureIgnoreCase)) return;

            try
            {
                using (XrmSvc xrmContext = new XrmSvc(localContext.OrganizationService))
                {
                    var presenter = new JobApplicationPresenter(xrmContext, localContext.TracingService);
                    presenter.BlockDoubleApplication(xrmContext, preImage);
                }
            }
            catch (Exception exception)
            {
                string errorMessage = exception.InnerException != null ? $"{exception.Message} | {exception.InnerException.Message}" : exception.Message;
                throw new InvalidPluginExecutionException($"An error has occurred while executing the 'pre-operation contact create' plug-in. The exception thrown was: {errorMessage}");
            }
        }
Esempio n. 2
0
 public InterviewProcessPresenter(XrmSvc xrmContext, IOrganizationService service, ITracingService tracer)
 {
     if (xrmContext == null)
     {
         throw new ArgumentNullException(nameof(xrmContext));
     }
     _xrmContext = xrmContext;
     _service    = service;
     _tracer     = tracer;
 }
Esempio n. 3
0
        protected override void ExecuteCrmPlugin(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException(nameof(localContext));
            }
            IPluginExecutionContext context = localContext.PluginExecutionContext;

            const string target = PluginConstants.Target;

            if (!context.InputParameters.Contains(target) || !(context.InputParameters[target] is Entity))
            {
                return;
            }

            Entity entity = (Entity)context.InputParameters[target];

            bru_interview_process interview_process = entity.ToEntity <bru_interview_process>();

            if (!string.Equals(interview_process.LogicalName, bru_interview_process.EntityLogicalName, StringComparison.CurrentCultureIgnoreCase))
            {
                return;
            }
            if (!string.Equals(context.MessageName, PluginConstants.Create, StringComparison.CurrentCultureIgnoreCase))
            {
                return;
            }

            try
            {
                using (XrmSvc xrmContext = new XrmSvc(localContext.OrganizationService))
                {
                    var presenter = new InterviewProcessPresenter(xrmContext, localContext.OrganizationService, localContext.TracingService);
                    presenter.AddInterviewToInterviewProcess(interview_process);
                }
            }
            catch (Exception exception)
            {
                string errorMessage = exception.InnerException != null ? $"{exception.Message} | {exception.InnerException.Message}" : exception.Message;
                throw new InvalidPluginExecutionException($"An error has occurred while executing the 'pre-operation contact create' plug-in. The exception thrown was: {errorMessage}");
            }
        }
Esempio n. 4
0
        public void BlockDoubleApplication(XrmSvc xrmContext, Entity PreImage)
        {
            _tracer.Trace("Start application update");

            var applicant = ((EntityReference)PreImage.Attributes["bru_applicant"]).Id;

            var jobapplication = (from c in xrmContext.bru_jobapplicationSet
                                                 where c.bru_Applicant.Id == applicant
                                                 select c).ToList();

            //if (jobapplication.Count() > 1)
            //{

            //    throw new InvalidPluginExecutionException("This user has applied already");
            //}
            //else
            //{
            //    throw new InvalidPluginExecutionException("This user has NOT applied already");
            //}

        }
Esempio n. 5
0
 public JobApplicationPresenter(XrmSvc xrmContext, ITracingService tracer)
 {
     if (xrmContext == null) throw new ArgumentNullException(nameof(xrmContext));
     _xrmContext = xrmContext;
     _tracer = tracer;
 }