Пример #1
0
 internal UsfCasTicket(UsfFacultyProfileService service)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     Service = service;
 }
Пример #2
0
 internal UsfPerson(UsfFacultyProfileService service, string username)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     Service  = service;
     Username = username;
 }
Пример #3
0
 internal ImportUsfEstablishments(IPrincipal principal, UsfFacultyProfileService service, string lastUpdate)
 {
     if (principal == null)
     {
         throw new ArgumentNullException("principal");
     }
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     Principal  = principal;
     Service    = service;
     LastUpdate = lastUpdate;
 }
Пример #4
0
 internal ImportUsfPerson(IPrincipal principal, UsfFacultyProfileService service, int userId)
 {
     if (principal == null)
     {
         throw new ArgumentNullException("principal");
     }
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     Principal = principal;
     Service   = service;
     UserId    = userId;
 }
Пример #5
0
        public override void Handle(UserCreated e)
        {
            // is this a usf user?
            var usf    = _queryProcessor.Execute(new EstablishmentByUrl("www.usf.edu"));
            var tenant = _queryProcessor.Execute(new EstablishmentById(e.TenantId));

            if (tenant == null || usf == null || !usf.Equals(tenant))
            {
                return;
            }

            var reportBuilder = new WorkReportBuilder("Handle USF User Created Event");
            var logging       = UsfFacultyProfileAttribute.MailLog.ToString();

            try
            {
                // get the service integration
                var usfFacultyProfile = UsfFacultyProfileAttribute.UsfFacultyProfile.ToString();
                var integration       = _entities.Get <ServiceIntegration>()
                                        .EagerLoad(_entities, new Expression <Func <ServiceIntegration, object> >[]
                {
                    x => x.StringAttributes,
                })
                                        .SingleOrDefault(x => x.TenantId == e.TenantId &&
                                                         x.Name.Equals(usfFacultyProfile));
                if (integration == null)
                {
                    throw new InvalidOperationException(string.Format(
                                                            "Found no service integration for '{0}_{1}'.", usfFacultyProfile, e.TenantId));
                }

                reportBuilder.Report("Wrapping integration data into USF Faculty Profile Service object.");
                var service = new UsfFacultyProfileService(integration);
                logging = service.Logging;

                reportBuilder.Report("Invoking command to import USF person data.");
                _commandHandler.Handle(new ImportUsfPerson(e.Principal, service, e.UserId)
                {
                    ReportBuilder = reportBuilder,
                });
            }
            catch (Exception ex)
            {
                reportBuilder.Report("");
                reportBuilder.Report("JOB FAILED!");
                reportBuilder.Report(ex.GetType().Name);
                reportBuilder.Report(ex.Message);
                reportBuilder.Report(ex.StackTrace);
                _exceptionLogger.Log(ex);
            }
            finally
            {
                _entities.DiscardChanges();
                var usfFacultyProfile = UsfFacultyProfileAttribute.UsfFacultyProfile.ToString();
                var integration       = _entities.Get <ServiceIntegration>()
                                        .EagerLoad(_entities, new Expression <Func <ServiceIntegration, object> >[]
                {
                    x => x.StringAttributes,
                })
                                        .SingleOrDefault(x => x.TenantId == e.TenantId &&
                                                         x.Name.Equals(usfFacultyProfile));

                if (integration == null)
                {
                    reportBuilder.Report("Found no service integration for '{0}_{1}'.", usfFacultyProfile, e.TenantId);
                    reportBuilder.Send(_mailSender);
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(logging))
                    {
                        integration.LogEntries.Add(new ServiceLogEntry
                        {
                            IntegrationName = integration.Name,
                            TenantId        = integration.TenantId,
                            Subject         = reportBuilder.Subject,
                            Log             = reportBuilder.Message.ToString(),
                        });
                        _entities.SaveChanges();
                    }
                    if (logging == UsfFacultyProfileAttribute.MailLog.ToString())
                    {
                        reportBuilder.Send(_mailSender);
                    }
                }
            }
        }