Exemple #1
0
        public void Handle(UpdateMyPhoto command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            var person = _entities.Get <Person>()
                         .EagerLoad(_entities, new Expression <Func <Person, object> >[]
            {
                x => x.Photo,
            })
                         .ByUserName(command.Principal.Identity.Name);

            // delete previous file
            _photoDeleteHandler.Handle(new DeleteMyPhoto(command.Principal)
            {
                NoCommit = true,
            });

            // create new file
            var path         = string.Format(Person.PhotoPathFormat, person.RevisionId, Guid.NewGuid());
            var externalFile = new ExternalFile
            {
                Name     = command.Name,
                Path     = path,
                Length   = command.Content.Length,
                MimeType = command.MimeType,
            };

            person.Photo = externalFile;
            _binaryData.Put(path, command.Content);

            // log audit
            var audit = new CommandEvent
            {
                RaisedBy = command.Principal.Identity.Name,
                Name     = command.GetType().FullName,
                Value    = JsonConvert.SerializeObject(new
                {
                    User = command.Principal.Identity.Name,
                    command.Content,
                    command.Name,
                    command.MimeType,
                }),
                NewState = externalFile.ToJsonAudit(),
            };

            // push to database
            _entities.Create(externalFile);
            _entities.Update(person);
            _entities.Create(audit);
            if (!command.NoCommit)
            {
                _unitOfWork.SaveChanges();
            }
        }
        protected EmployeeModuleSettings Seed(CreateEmployeeModuleSettings command)
        {
            // make sure entity does not already exist
            var employeeModuleSettings = _queryProcessor.Execute(
                new EmployeeModuleSettingsByEstablishmentId(command.EstablishmentId, true));

            if (employeeModuleSettings != null)
            {
                return(employeeModuleSettings);
            }

            var iconsBinaryPath = string.Format("{0}/{1}/", EmployeeConsts.SettingsBinaryStoreBasePath,
                                                EmployeeConsts.IconsBinaryStorePath);

            foreach (var icon in UsfEmployeeModuleSettingsSeeder.UsfEmployeeModuleSettingIcons)
            {
                var iconPath = Path.Combine(iconsBinaryPath, icon.Value.Third.ToString());
                if (!_binaryStore.Exists(iconPath))
                {
                    var filePath = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory,
                                                 @"..\UCosmic.Infrastructure\SeedData\SeedMediaFiles\",
                                                 icon.Key);

                    using (var fileStream = File.OpenRead(filePath))
                        _binaryStore.Put(iconPath, fileStream.ReadFully());
                }

                if (string.IsNullOrEmpty(command.GlobalViewIconPath) && icon.Value.First == "Global")
                {
                    command.GlobalViewIconFileName = icon.Value.Third.ToString();
                    command.GlobalViewIconLength   = _binaryStore.Get(iconPath).Length;
                    command.GlobalViewIconMimeType = "image/png";
                    command.GlobalViewIconName     = icon.Value.Second;
                    command.GlobalViewIconPath     = iconsBinaryPath;
                }

                if (string.IsNullOrEmpty(command.FindAnExpertIconPath) && icon.Value.First == "Expert")
                {
                    command.FindAnExpertIconFileName = icon.Value.Third.ToString();
                    command.FindAnExpertIconLength   = _binaryStore.Get(iconPath).Length;
                    command.FindAnExpertIconMimeType = "image/svg+xml";
                    command.FindAnExpertIconName     = icon.Value.Second;
                    command.FindAnExpertIconPath     = iconsBinaryPath;
                }
            }

            _createEmployeeModuleSettings.Handle(command);

            _unitOfWork.SaveChanges();

            return(command.CreatedEmployeeModuleSettings);
        }
        private void CopyFile(string fileName, string filePath)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            var basePath = string.Format("{0}{1}",
                                         AppDomain.CurrentDomain.BaseDirectory,
                                         @"..\UCosmic.Infrastructure\SeedData\SeedMediaFiles\");

            using (var fileStream = File.OpenRead(string.Format("{0}{1}", basePath, fileName)))
                _binaryData.Put(filePath, fileStream.ReadFully());
        }
Exemple #4
0
        public void Handle(AttachFileToAgreementCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            var agreement = command.Agreement ??
                            _entities.Get <InstitutionalAgreement>()
                            .EagerLoad(_entities, new Expression <Func <InstitutionalAgreement, object> >[]
            {
                r => r.Files,
            })
                            .By(command.AgreementGuid);

            var file = agreement.Files.SingleOrDefault(g => g.EntityId == command.FileGuid);

            if (file != null)
            {
                return;
            }

            var looseFile = _entities.Get <LooseFile>().By(command.FileGuid);

            if (looseFile == null)
            {
                return;
            }

            // also store in binary data
            var path = string.Format(InstitutionalAgreementFile.PathFormat, agreement.RevisionId, Guid.NewGuid());

            _binaryData.Put(path, looseFile.Content);

            file = new InstitutionalAgreementFile
            {
                Agreement = agreement,
                //Content = looseFile.Content,
                Length   = looseFile.Length,
                MimeType = looseFile.MimeType,
                Name     = looseFile.Name,
                Path     = path,
            };

            _entities.Create(file);
            _entities.Purge(looseFile);
            command.IsNewlyAttached = true;
        }
        public void Handle(CreateUpload command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            var entity = new Upload
            {
                Length             = command.Content.Length,
                MimeType           = command.MimeType,
                FileName           = command.FileName,
                CreatedByPrincipal = command.Principal.Identity.Name,
            };

            entity.Path = string.Format(Upload.PathFormat, entity.Guid);
            _binaryData.Put(entity.Path, command.Content, true);

            _entities.Create(entity);
            _unitOfWork.SaveChanges();
            command.CreatedGuid = entity.Guid;
        }
Exemple #6
0
        public void Handle(CreateFile command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            // create the initial entity
            var entity = new AgreementFile
            {
                AgreementId = command.AgreementId,
                Visibility  = command.Visibility.AsEnum <AgreementVisibility>(),
                Path        = string.Format(AgreementFile.PathFormat, command.AgreementId, Guid.NewGuid()),
            };

            _entities.Create(entity);

            // will we be moving an upload or creating a new file from scratch?
            var upload = command.UploadGuid.HasValue
                ? _entities.Get <Upload>().Single(x => x.Guid.Equals(command.UploadGuid.Value)) : null;

            // populate other entity properties and store binary data
            if (upload != null)
            {
                entity.FileName = upload.FileName;
                entity.Length   = (int)upload.Length;
                entity.MimeType = upload.MimeType;
                entity.Name     = GetExtensionedCustomName(command.CustomName, upload.FileName);
                _binaryData.Move(upload.Path, entity.Path);
                _purgeUpload.Handle(new PurgeUpload(upload.Guid)
                {
                    NoCommit = true
                });
            }
            else
            {
                entity.FileName = command.FileData.FileName;
                entity.Length   = command.FileData.Content.Length;
                entity.MimeType = command.FileData.MimeType;
                entity.Name     = GetExtensionedCustomName(command.CustomName, command.FileData.FileName);
                _binaryData.Put(entity.Path, command.FileData.Content, true);
            }

            // log audit
            var audit = new CommandEvent
            {
                RaisedBy = command.Principal.Identity.Name,
                Name     = command.GetType().FullName,
                Value    = JsonConvert.SerializeObject(new
                {
                    command.AgreementId,
                    command.CustomName,
                    command.Visibility,
                    command.UploadGuid,
                    FileData = command.FileData == null ? null : new
                    {
                        command.FileData.FileName,
                        ContentType   = command.FileData.MimeType,
                        ContentLength = command.FileData.Content.Length,
                    }
                }),
                NewState = entity.ToJsonAudit(),
            };

            _entities.Create(audit);

            try
            {
                _unitOfWork.SaveChanges();
                command.CreatedFileId = entity.Id;
            }
            catch
            {
                // restore binary data state when the db save fails
                if (_binaryData.Exists(entity.Path))
                {
                    if (upload != null)
                    {
                        _binaryData.Move(entity.Path, upload.Path);
                    }
                    else
                    {
                        _binaryData.Delete(entity.Path);
                    }
                }
            }
        }
        public void Handle(ApplicationStarted @event)
        {
            /* One time to get icons in blob storage */
#if false
            {
                /* ----- Global View and Find an Expert Icons ----- */

                var iconsBinaryPath = string.Format("{0}/{1}/", EmployeeConsts.SettingsBinaryStoreBasePath,
                                                    EmployeeConsts.IconsBinaryStorePath);

                //* Create default Global View icon */
                if (_binaryStore.Get(iconsBinaryPath + EmployeeConsts.DefaultGlobalViewIconGuid) == null)
                {
                    string filePath = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory,
                                                    @"..\UCosmic.Web.Mvc\images\icons\global\",
                                                    "global_24_black.png");

                    using (var fileStream = File.OpenRead(filePath))
                    {
                        var content = fileStream.ReadFully();
                        _binaryStore.Put(iconsBinaryPath + EmployeeConsts.DefaultGlobalViewIconGuid, content);
                    }
                }

                //* Create default Find an Expert icon */
                if (_binaryStore.Get(iconsBinaryPath + EmployeeConsts.DefaultFindAnExpertIconGuid) == null)
                {
                    var filePath = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory,
                                                 @"..\UCosmic.Web.Mvc\images\icons\nounproject\",
                                                 "noun_project_5795_compass.svg");
                    using (var fileStream = File.OpenRead(filePath))
                    {
                        var content = fileStream.ReadFully();
                        _binaryStore.Put(iconsBinaryPath + EmployeeConsts.DefaultFindAnExpertIconGuid, content);
                    }
                }

                /* ----- Activity Type icons for USF ----- */
                var activityTypeFilenames = new string[]
                {
                    "noun_project_762_idea.svg",
                    "noun_project_14888_teacher.svg",
                    "noun_project_17372_medal.svg",
                    "noun_project_16986_podium.svg",
                    "noun_project_401_briefcase.svg"
                };

                var activityTypeFilenameMap = new Dictionary <string, string>
                {
                    { "noun_project_762_idea.svg", "5117FFC4-C3CD-42F8-9C68-6B4362930A99" },
                    { "noun_project_14888_teacher.svg", "0033E48C-95CD-487B-8B0D-571E71EFF844" },
                    { "noun_project_17372_medal.svg", "8C746B8A-6B24-4881-9D4D-D830FBCD723A" },
                    { "noun_project_16986_podium.svg", "E44978F8-3664-4F7A-A2AF-6A0446D38099" },
                    { "noun_project_401_briefcase.svg", "586DDDBB-DE01-429B-8428-57A9D03189CB" }
                };

                var activityTypeIconBinaryPath = string.Format("{0}/{1}/{2}/", EmployeeConsts.SettingsBinaryStoreBasePath,
                                                               1, // USF
                                                               EmployeeConsts.IconsBinaryStorePath);


                for (var i = 0; i < activityTypeFilenames.Length; i += 1)
                {
                    string iconBinaryFilePath =
                        String.Format("{0}{1}", activityTypeIconBinaryPath,
                                      activityTypeFilenameMap[activityTypeFilenames[i]]);

                    if (_binaryStore.Get(iconBinaryFilePath) == null)
                    {
                        string filePath = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory,
                                                        @"..\UCosmic.Web.MVC\images\icons\nounproject\",
                                                        activityTypeFilenames[i]);

                        using (var fileStream = File.OpenRead(filePath))
                        {
                            var content = fileStream.ReadFully();
                            _binaryStore.Put(iconBinaryFilePath, content);
                        }
                    }
                }
            }
#endif

#if false
            /* ----- Update the EmployeeModuleSettings rows ----- */
            {
                var iconsBinaryPath = string.Format("{0}/{1}/", EmployeeConsts.SettingsBinaryStoreBasePath,
                                                    EmployeeConsts.IconsBinaryStorePath);

                /* ----- Activity Type icons for USF ----- */
                //var activityTypeFilenames = new string[]
                //{
                //    "noun_project_762_idea.svg",
                //    "noun_project_14888_teacher.svg",
                //    "noun_project_17372_medal.svg",
                //    "noun_project_16986_podium.svg",
                //    "noun_project_401_briefcase.svg"
                //};

                var activityTypeFilenameMap = new Dictionary <string, string>
                {
                    { "noun_project_762_idea.svg", "5117FFC4-C3CD-42F8-9C68-6B4362930A99" },
                    { "noun_project_14888_teacher.svg", "0033E48C-95CD-487B-8B0D-571E71EFF844" },
                    { "noun_project_17372_medal.svg", "8C746B8A-6B24-4881-9D4D-D830FBCD723A" },
                    { "noun_project_16986_podium.svg", "E44978F8-3664-4F7A-A2AF-6A0446D38099" },
                    { "noun_project_401_briefcase.svg", "586DDDBB-DE01-429B-8428-57A9D03189CB" }
                };

                var activityTypeIconBinaryPath = string.Format("{0}/{1}/{2}/", EmployeeConsts.SettingsBinaryStoreBasePath,
                                                               1, // USF
                                                               EmployeeConsts.IconsBinaryStorePath);


                var settings = _entities.Get <EmployeeModuleSettings>().SingleOrDefault(x => x.Establishment.RevisionId == 3306 /* USF */);
                if (settings == null)
                {
                    return;
                }

                EmployeeActivityType activityType;

                activityType =
                    settings.ActivityTypes.Single(a => a.Type == "Research or Creative Endeavor");
                activityType.IconLength =
                    _binaryStore.Get(activityTypeIconBinaryPath + activityTypeFilenameMap["noun_project_762_idea.svg"])
                    .Length;
                activityType.IconMimeType = "image/svg+xml";
                activityType.IconName     = "Research.svg";
                activityType.IconPath     = activityTypeIconBinaryPath;
                activityType.IconFileName = activityTypeFilenameMap["noun_project_762_idea.svg"];

                activityType =
                    settings.ActivityTypes.Single(a => a.Type == "Teaching or Mentoring");
                activityType.IconLength =
                    _binaryStore.Get(activityTypeIconBinaryPath +
                                     activityTypeFilenameMap["noun_project_14888_teacher.svg"]).Length;
                activityType.IconMimeType = "image/svg+xml";
                activityType.IconName     = "Teaching.svg";
                activityType.IconPath     = activityTypeIconBinaryPath;
                activityType.IconFileName = activityTypeFilenameMap["noun_project_14888_teacher.svg"];

                activityType =
                    settings.ActivityTypes.Single(a => a.Type == "Award or Honor");
                activityType.IconLength =
                    _binaryStore.Get(activityTypeIconBinaryPath +
                                     activityTypeFilenameMap["noun_project_17372_medal.svg"]).Length;
                activityType.IconMimeType = "image/svg+xml";
                activityType.IconName     = "Award.svg";
                activityType.IconPath     = activityTypeIconBinaryPath;
                activityType.IconFileName = activityTypeFilenameMap["noun_project_17372_medal.svg"];

                activityType =
                    settings.ActivityTypes.Single(
                        a => a.Type == "Conference Presentation or Proceeding");
                activityType.IconLength =
                    _binaryStore.Get(activityTypeIconBinaryPath +
                                     activityTypeFilenameMap["noun_project_16986_podium.svg"]).Length;
                activityType.IconMimeType = "image/svg+xml";
                activityType.IconName     = "Conference.svg";
                activityType.IconPath     = activityTypeIconBinaryPath;
                activityType.IconFileName = activityTypeFilenameMap["noun_project_16986_podium.svg"];

                activityType =
                    settings.ActivityTypes.Single(
                        a => a.Type == "Professional Development, Service or Consulting");
                activityType.IconLength =
                    _binaryStore.Get(activityTypeIconBinaryPath +
                                     activityTypeFilenameMap["noun_project_401_briefcase.svg"]).Length;
                activityType.IconMimeType = "image/svg+xml";
                activityType.IconName     = "Professional.svg";
                activityType.IconPath     = activityTypeIconBinaryPath;
                activityType.IconFileName = activityTypeFilenameMap["noun_project_401_briefcase.svg"];


                var updateCommand = new UpdateEmployeeModuleSettings(settings.Id)
                {
                    EmployeeFacultyRanks       = settings.FacultyRanks,
                    NotifyAdminOnUpdate        = settings.NotifyAdminOnUpdate,
                    NotifyAdmins               = settings.NotifyAdmins,
                    PersonalInfoAnchorText     = settings.PersonalInfoAnchorText,
                    Establishment              = settings.Establishment,
                    EmployeeActivityTypes      = settings.ActivityTypes,
                    OfferCountry               = settings.OfferCountry,
                    OfferActivityType          = settings.OfferActivityType,
                    OfferFundingQuestions      = settings.OfferFundingQuestions,
                    InternationalPedigreeTitle = settings.InternationalPedigreeTitle,

                    GlobalViewIconLength   = _binaryStore.Get(iconsBinaryPath + EmployeeConsts.DefaultGlobalViewIconGuid).Length,
                    GlobalViewIconMimeType = "image/png",
                    GlobalViewIconName     = "GlobalViewIcon.png",
                    GlobalViewIconPath     = iconsBinaryPath,
                    GlobalViewIconFileName = EmployeeConsts.DefaultGlobalViewIconGuid,

                    FindAnExpertIconLength   = _binaryStore.Get(iconsBinaryPath + EmployeeConsts.DefaultFindAnExpertIconGuid).Length,
                    FindAnExpertIconMimeType = "image/svg+xml",
                    FindAnExpertIconName     = "FindAnExpertIcon.svg",
                    FindAnExpertIconPath     = iconsBinaryPath,
                    FindAnExpertIconFileName = EmployeeConsts.DefaultFindAnExpertIconGuid,
                };

                _updateEmployeeModuleSettings.Handle(updateCommand);
            }
#endif
        }
Exemple #8
0
        public void Handle(CreateActivityDocument command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            var values = command.ActivityValues;

            if (values == null)
            {
                if (command.Mode.HasValue)
                {
                    var modeText = command.Mode.Value.AsSentenceFragment();
                    values = _entities.Get <ActivityValues>()
                             .Single(x => x.ActivityId == command.ActivityId && x.ModeText == modeText);
                }
                else
                {
                    values = _entities.Get <ActivityValues>()
                             .Single(x => x.ActivityId == command.ActivityId && x.ModeText == x.Activity.ModeText);
                }
            }

            var path = command.Path;

            if (string.IsNullOrWhiteSpace(path))
            {
                path = string.Format(ActivityDocument.PathFormat, values.ActivityId, Guid.NewGuid());
                _binaryData.Put(path, command.Content, true);
            }

            var activityDocument = new ActivityDocument
            {
                ActivityValues     = values,
                Title              = command.Title,
                FileName           = command.FileName,
                MimeType           = command.MimeType,
                Path               = path,
                Length             = command.Length.HasValue ? (int)command.Length.Value : command.Content.Length,
                CreatedByPrincipal = command.Impersonator == null
                    ? command.Principal.Identity.Name
                    : command.Impersonator.Identity.Name,
            };

            if (command.EntityId.HasValue && command.EntityId != Guid.Empty)
            {
                activityDocument.EntityId = command.EntityId.Value;
            }
            values.Documents.Add(activityDocument);

            // do NOT update activity here as it throws concurrency exceptions
            // when users upload multiple documents at once

            _entities.Create(activityDocument);

            if (!command.NoCommit)
            {
                try
                {
                    _entities.SaveChanges();
                    command.CreatedActivityDocument = _detachedEntities.Query <ActivityDocument>()
                                                      .Single(x => x.RevisionId == activityDocument.RevisionId);
                }
                catch
                {
                    _binaryData.Delete(activityDocument.Path);
                    throw;
                }
            }
            else
            {
                command.CreatedActivityDocument = activityDocument;
            }
        }
        public void Handle(PurgeActivity command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            // load the activity along with its documents & alternate copies
            var activity = _entities.Get <Activity>()
                           .EagerLoad(_entities, new Expression <Func <Activity, object> >[]
            {
                x => x.Values.Select(y => y.Documents),
                x => x.WorkCopy,
                x => x.Original,
            })
                           .SingleOrDefault(x => x.RevisionId == command.ActivityId);

            if (activity == null)
            {
                return;
            }

            // deleting activity will cascade delete documents,
            // so they must be removed from the binary store
            command.DeletedDocuments = new Dictionary <string, byte[]>();
            foreach (var path in activity.Values.SelectMany(x => x.Documents.Select(y => y.Path)))
            {
                if (_binaryData.Exists(path))
                {
                    command.DeletedDocuments.Add(path, _binaryData.Get(path));
                    _binaryData.Delete(path);
                }
            }

            // if this activity is a work copy, also delete the original if it is empty
            PurgeActivity deleteOriginal = null;

            // if a work copy exists, delete it too
            PurgeActivity deleteWorkCopy = null;

            if (activity.Original != null && activity.Original.RevisionId != command.OuterActivityId && activity.Original.IsEmpty())
            {
                deleteOriginal = new PurgeActivity(command.Principal, activity.Original.RevisionId)
                {
                    NoCommit        = true,
                    OuterActivityId = command.ActivityId,
                };
                Handle(deleteOriginal);
            }
            else if (activity.WorkCopy != null && activity.WorkCopy.RevisionId != command.OuterActivityId)
            {
                deleteWorkCopy = new PurgeActivity(command.Principal, activity.WorkCopy.RevisionId)
                {
                    NoCommit        = true,
                    OuterActivityId = command.ActivityId,
                };
                Handle(deleteWorkCopy);
            }

            // log audit
            var audit = new CommandEvent
            {
                RaisedBy      = command.Principal.Identity.Name,
                Name          = command.GetType().FullName,
                Value         = JsonConvert.SerializeObject(new { command.ActivityId }),
                PreviousState = activity.ToJsonAudit(),
            };

            _entities.Create(audit);
            _entities.Purge(activity);

            try
            {
                // wrap removal in try block
                if (!command.NoCommit)
                {
                    _entities.SaveChanges();
                }
            }
            catch
            {
                // restore binary data when savechanges fails
                foreach (var path in command.DeletedDocuments)
                {
                    _binaryData.Put(path.Key, path.Value, true);
                }

                if (deleteOriginal != null)
                {
                    foreach (var path in deleteOriginal.DeletedDocuments)
                    {
                        _binaryData.Put(path.Key, path.Value, true);
                    }
                }

                if (deleteWorkCopy != null)
                {
                    foreach (var path in deleteWorkCopy.DeletedDocuments)
                    {
                        _binaryData.Put(path.Key, path.Value, true);
                    }
                }
            }
        }
        public override void Seed()
        {
            var establishment = _entities.Get <Establishment>().Single(x => x.WebsiteUrl == "www.usf.edu");
            var settings      = _entities.Get <EmployeeModuleSettings>().SingleOrDefault(x => x.Establishment.RevisionId == establishment.RevisionId);

            if (settings != null)
            {
                return;
            }

            #region CreateEmployeeModuleSettings

            CreatedEmployeeModuleSettings = Seed(new CreateEmployeeModuleSettings
            {
                EmployeeFacultyRanks = new Collection <EmployeeFacultyRank>
                {
                    new EmployeeFacultyRank {
                        Rank = "Distinguished University Professor", Number = 1
                    },
                    new EmployeeFacultyRank {
                        Rank = "Professor", Number = 2
                    },
                    new EmployeeFacultyRank {
                        Rank = "Associate Professor", Number = 3
                    },
                    new EmployeeFacultyRank {
                        Rank = "Assistant Professor", Number = 4
                    },
                    new EmployeeFacultyRank {
                        Rank = "Other", Number = 5
                    }
                },
                NotifyAdminOnUpdate    = false,
                PersonalInfoAnchorText = "My USF Profile",
                EstablishmentId        = establishment.RevisionId,
                EmployeeActivityTypes  = new Collection <EmployeeActivityType>
                {
                    new EmployeeActivityType
                    {
                        Type     = "Research or Creative Endeavor",
                        Rank     = 1,
                        CssColor = "blue",
                    },
                    new EmployeeActivityType
                    {
                        Type     = "Teaching or Mentoring",
                        Rank     = 2,
                        CssColor = "green",
                    },
                    new EmployeeActivityType
                    {
                        Type     = "Award or Honor",
                        Rank     = 3,
                        CssColor = "yellow",
                    },
                    new EmployeeActivityType
                    {
                        Type     = "Conference Presentation or Proceeding",
                        Rank     = 4,
                        CssColor = "orange",
                    },
                    new EmployeeActivityType
                    {
                        Type     = "Professional Development, Service or Consulting",
                        Rank     = 5,
                        CssColor = "red",
                    }
                },
                OfferCountry               = true,
                OfferActivityType          = true,
                OfferFundingQuestions      = true,
                InternationalPedigreeTitle = "My Formal Education Outside the US",
                ReportsDefaultYearRange    = 10
            });

            #endregion
            #region ActivityType Icons

            var activityTypeIconBinaryPath = string.Format("{0}/{1}/{2}/", EmployeeConsts.SettingsBinaryStoreBasePath,
                                                           CreatedEmployeeModuleSettings.EstablishmentId,
                                                           EmployeeConsts.IconsBinaryStorePath);

            foreach (var fileName in UsfActivityTypeIcons.Keys)
            {
                var binaryFilePath = string.Format("{0}{1}",
                                                   activityTypeIconBinaryPath, UsfActivityTypeIcons[fileName].Third);

                if (_binaryStore.Get(binaryFilePath) == null)
                {
                    var localFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                     @"..\UCosmic.Infrastructure\SeedData\SeedMediaFiles\", fileName);

                    using (var fileStream = File.OpenRead(localFilePath))
                        _binaryStore.Put(binaryFilePath, fileStream.ReadFully());
                }

                var activityType = CreatedEmployeeModuleSettings.ActivityTypes.Single(a => a.Type == UsfActivityTypeIcons[fileName].First);
                activityType.IconLength   = _binaryStore.Get(binaryFilePath).Length;
                activityType.IconMimeType = "image/svg+xml";
                activityType.IconName     = UsfActivityTypeIcons[fileName].Second;
                activityType.IconPath     = activityTypeIconBinaryPath;
                activityType.IconFileName = UsfActivityTypeIcons[fileName].Third.ToString();
            }

            #endregion
            #region UpdateEmployeeModuleSettings

            var updateCommand = new UpdateEmployeeModuleSettings(CreatedEmployeeModuleSettings.EstablishmentId)
            {
                EmployeeFacultyRanks       = CreatedEmployeeModuleSettings.FacultyRanks,
                NotifyAdminOnUpdate        = CreatedEmployeeModuleSettings.NotifyAdminOnUpdate,
                NotifyAdmins               = CreatedEmployeeModuleSettings.NotifyAdmins,
                PersonalInfoAnchorText     = CreatedEmployeeModuleSettings.PersonalInfoAnchorText,
                Establishment              = CreatedEmployeeModuleSettings.Establishment,
                EmployeeActivityTypes      = CreatedEmployeeModuleSettings.ActivityTypes,
                OfferCountry               = CreatedEmployeeModuleSettings.OfferCountry,
                OfferActivityType          = CreatedEmployeeModuleSettings.OfferActivityType,
                OfferFundingQuestions      = CreatedEmployeeModuleSettings.OfferFundingQuestions,
                InternationalPedigreeTitle = CreatedEmployeeModuleSettings.InternationalPedigreeTitle
            };

            #endregion

            _updateEmployeeModuleSettings.Handle(updateCommand);
        }