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 }
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); }