public ProfileExternalResource GetFileContent(List <ProfileColumnComparer <String> > columns, dtoCsvSettings settings, dtoCSVfile file) { CsvFile csvFile = ContentOf.LoadCsvFile(file.RealName, settings); ProfileExternalResource result = new ProfileExternalResource(columns, csvFile); return(result); }
public void InitView(ProfileExternalResource source, dtoImportSettings settings) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { View.AutoGenerateLogin = settings.AutoGenerateLogin; lm.Comol.Core.BaseModules.ProviderManagement.dtoBaseProvider provider = Service.GetAuthenticationProvider(UserContext.Language.Id, settings.IdProvider); Service.AnalyzeItems(source, settings); List <ProfileExternalResource> items = new List <ProfileExternalResource>(); items.Add(source); View.LoadItems(items, GetInvalidItems(source), settings.IdProfileType, (provider == null) ? "" : provider.Translation.Name); } }
private List <InvalidImport> GetInvalidItems(ProfileExternalResource source) { List <InvalidImport> invalidItems = new List <InvalidImport>(); if (source.Rows.Where(r => r.isValid() == false).Any()) { invalidItems.Add(InvalidImport.InvalidData); } if (source.Rows.Where(r => r.HasDuplicatedValues).Any()) { invalidItems.Add(InvalidImport.SourceDuplicatedData); } if (source.Rows.Where(r => r.HasDBDuplicatedValues).Any()) { invalidItems.Add(InvalidImport.AlreadyExist); } return(invalidItems); }
private List <Person> CreateProfiles(dtoImportSettings settings, Int32 idDefaultOrganization, ProfileExternalResource selectedItems, List <dtoImportedProfile> createdProfiles, List <dtoBaseProfile> notCreatedProfiles) { List <Person> profiles = new List <Person>(); Language language = CurrentManager.GetDefaultLanguage(); AuthenticationProvider provider = Service.GetAuthenticationProvider(settings.IdProvider); if (provider != null && language != null) { Boolean created = false; Int32 idPerson = 0; Int32 index = 1; foreach (ProfileAttributesRow row in selectedItems.Rows) { dtoBaseProfile baseItem = null; switch (settings.IdProfileType) { case (int)UserTypeStandard.ExternalUser: dtoExternal externalUser = CreateExternal(row); baseItem = externalUser; break; case (int)UserTypeStandard.Company: dtoCompany company = CreateCompanyUser(row); baseItem = company; break; case (int)UserTypeStandard.Employee: dtoEmployee employee = CreateEmployee(row); baseItem = employee; break; default: baseItem = new dtoBaseProfile(); break; } created = false; if (baseItem != null) { GenerateBaseProfile(baseItem, settings, row, provider.ProviderType, GetUserLanguage(row, language)); if (InternalService.isUniqueMail(baseItem.Mail)) { PersonInfo info = GeneratePersonInfo(row, baseItem); idPerson = View.AddUserProfile(baseItem, info, idDefaultOrganization, provider); if (idPerson > 0) { Person person = CurrentManager.GetPerson(idPerson); if (person != null) { created = AddAuthentication(person, baseItem, settings, row, provider); if (created) { Service.SetDefaultProvider(provider.Id, person.Id); } profiles.Add(person); createdProfiles.Add(new dtoImportedProfile() { Profile = baseItem, Info = info }); } } } if (!created) { notCreatedProfiles.Add(baseItem); } View.UpdateProfileCreation(0, index, created, baseItem.DisplayName); } else { View.UpdateProfileCreation(0, index, created, " // "); } index++; } } return(profiles); }
public void ImportProfiles( dtoImportSettings settings, Int32 defaultIdOrganization, List <Int32> allOrganizationsId, ProfileExternalResource selectedItems, List <dtoNewProfileSubscription> subscriptions, Boolean sendMailToUsers, lm.Comol.Core.Mail.dtoMailContent mailContent) { List <ProfileImportAction> actions = new List <ProfileImportAction>(); View.PreviousStep = ProfileImportStep.None; actions.Add(ProfileImportAction.Create); if (allOrganizationsId.Where(id => id != defaultIdOrganization).Any()) { actions.Add(ProfileImportAction.AddToOtherOrganizations); } actions.Add(ProfileImportAction.AddToCommunities); if (sendMailToUsers) { actions.Add(ProfileImportAction.SendMail); } View.SetupProgressInfo(actions.Count, selectedItems.Rows.Count); // Create profiles List <dtoBaseProfile> notCreatedProfiles = new List <dtoBaseProfile>(); List <dtoImportedProfile> createdProfiles = new List <dtoImportedProfile>(); List <Person> profiles = CreateProfiles(settings, defaultIdOrganization, selectedItems, createdProfiles, notCreatedProfiles); Dictionary <Int32, String> notaddedToOrganizations = new Dictionary <Int32, String>(); Dictionary <Int32, String> notSubscribedCommunities = new Dictionary <Int32, String>(); List <dtoImportedProfile> notSentMail = new List <dtoImportedProfile>(); if (profiles != null && profiles.Count > 0) { AddProfilesToOrganizations(defaultIdOrganization, allOrganizationsId, profiles, subscriptions.Where(s => s.IdCommunityType == 0).ToList(), notaddedToOrganizations); AddProfilesToCommunities(actions, profiles, subscriptions.Where(s => s.IdCommunityType != 0).ToList(), notSubscribedCommunities); if (sendMailToUsers) { SendMailToProfiles(actions, createdProfiles, mailContent, Service.GetProfileTypeMailTemplateAttributes(settings), notSentMail); } } View.UpdateSourceItems(View.CurrentSource); Int32 itemsToSelect = View.ItemsToSelect; View.PreviousStep = (itemsToSelect > 0) ? ProfileImportStep.ItemsSelctor : ProfileImportStep.None; if (notCreatedProfiles.Count == 0 && notaddedToOrganizations.Count == 0 && notSubscribedCommunities.Count == 0 && notSentMail.Count == 0) { View.isCompleted = (itemsToSelect == 0); View.DisplayImportedProfiles(profiles.Count, itemsToSelect); } else { View.DisplayImportError(profiles.Count, notCreatedProfiles, notaddedToOrganizations, notSubscribedCommunities, notSentMail); } }