private void AddProfilesToOrganizations(Int32 defaultIdOrganization, List <Int32> allOrganizationsId, List <Person> profiles, List <dtoNewProfileSubscription> subscriptions, Dictionary <Int32, String> notCreatedOrganizations) { Int32 index = 1; Boolean created = false; foreach (Int32 idOrganization in allOrganizationsId) { Organization organization = CurrentManager.GetOrganization(idOrganization); if (organization != null) { List <LazySubscription> items = ServiceCommunity.AddProfilesToOrganization(idOrganization, profiles.Select(p => p.Id).ToList(), subscriptions.Where(s => s.Node.Community.IdOrganization == idOrganization).FirstOrDefault(), (idOrganization == defaultIdOrganization)); created = (items.Count > 0); if (!created) { notCreatedOrganizations.Add(idOrganization, organization.Name); } View.UpdateAddProfilesToOrganizations(1, allOrganizationsId.Count, index, created, organization.Name); } else { View.UpdateAddProfilesToOrganizations(1, allOrganizationsId.Count, index, false, subscriptions.Where(s => s.Node.Community.IdOrganization == idOrganization).FirstOrDefault().Name); } index++; } }
private Boolean UpdateOrganizationAssociations(Person person, MacUrlAuthenticationProvider provider, List <dtoMacUrlUserAttribute> attributes) { Boolean updated = false; List <OrganizationAttributeItem> items = provider.GetOrganizationsInfo(attributes); List <lm.Comol.Core.BaseModules.ProfileManagement.dtoProfileOrganization> associations = ProfileService.GetProfileOrganizations(person); foreach (var item in items.Where(i => !associations.Select(a => a.IdOrganization).ToList().Contains(i.Organization.Id)).ToList()) { Organization organization = CurrentManager.GetOrganization(item.Organization.Id); if (organization != null) { LazySubscription sub = ServiceCommunity.AddProfileToOrganization(item.Organization.Id, person, false); if (!updated && (sub != null)) { updated = true; } } } if (updated) { View.UpdateLogonXml(person.Id); } // COSaA FARE SE NON SONO PI§ DI UNA ORGANIZZAZIONE ?? CHIEDERE PRIMA DI ESEGUIRE CODICE //foreach (var a in associations.Where(a => !items.Select(i => i.IdOrganization).ToList().Contains(a.IdOrganization)).ToList()) //{ //} return(updated); }
public void LoadCommunities(dtoCommunitiesFilters filters) { Int32 idProfile = View.IdProfile; litePerson person = CurrentManager.GetLitePerson(View.IdProfile); dtoTreeCommunityNode tree = ServiceCommunity.GetGenericCommunitiesTree(filters, person); List <Int32> list = (from m in CurrentManager.GetIQ <LazySubscription>() where m.IdPerson == idProfile && m.DisplayMail == true && m.IdRole > 0 select m.IdCommunity).ToList(); View.LoadTree(tree, list); }
private void AddProfilesToCommunities(List <ProfileImportAction> actions, List <Person> profiles, List <dtoNewProfileSubscription> subscriptions, Dictionary <Int32, String> notSubscribedCommunities) { Int32 index = 1; Boolean created = false; Int32 actionIndex = actions.Where(a => a != ProfileImportAction.SendMail).Count() - ((actions.Contains(ProfileImportAction.AddToOtherOrganizations)) ? 1 : 0); foreach (dtoNewProfileSubscription subscription in subscriptions.OrderBy(s => s.Node.PathDepth).ToList()) { List <LazySubscription> items = ServiceCommunity.AddProfilesToCommunity(profiles.Select(p => p.Id).ToList(), subscription); created = (items.Count > 0); if (!created) { notSubscribedCommunities.Add(subscription.Id, subscription.Name); } View.UpdateAddProfilesToCommunities(actionIndex, subscriptions.Count, index, created, subscription.Name); index++; } }
public void InitView(Int32 idProfile) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { View.IdProfile = idProfile; Person person = CurrentManager.GetPerson(idProfile); List <lm.Comol.Core.Communities.CommunityStatus> status = ServiceCommunity.GetCommunitiesAvailableStatus(idProfile); if (status.Count > 0) { View.AvailableStatus = status; LoadCommunities(View.CommunityFilters); } else { View.LoadNothing(); } } }
//private void MoveFromCommunities() { // if (UserContext.isAnonymous) // View.DisplaySessionTimeout(); // else if (View.HasAvailableCommunities == true) // { // List<dtoBaseCommunityNode> nodes = View.SelectedCommunities(); // Boolean hasSubscriptions = (nodes.Count != 0); // Boolean hasUnsubscriptions = false; // if (View.CurrentAvailability== CommunityAvailability.All || View.CurrentAvailability== CommunityAvailability.Subscribed) // hasUnsubscriptions = ServiceCommunity.ProfileHasCommunityToUnsubscribe(View.IdProfile, View.CommunityFilters, (nodes.Select(n => n.Id).ToList())); // UpdateStepsToSkip(CommunitySubscriptionWizardStep.SubscriptionsSettings, !hasSubscriptions); // UpdateStepsToSkip(CommunitySubscriptionWizardStep.RemoveSubscriptions, !hasUnsubscriptions); // if (hasSubscriptions) // View.GotoStep(CommunitySubscriptionWizardStep.SubscriptionsSettings, true); // else if (hasUnsubscriptions){ // SetupUnsubscriptions(); // View.GotoStep(CommunitySubscriptionWizardStep.RemoveSubscriptions); // }; // } //} //private void MoveFromSubscriptions() //{ // if (UserContext.isAnonymous) // View.DisplaySessionTimeout(); // else if (View.HasAvailableSubscriptions == true) // { // if (View.SkipSteps.Contains(CommunitySubscriptionWizardStep.RemoveSubscriptions)) // MoveToSummary(); // else if (View.HasUnsubscriptions) // View.GotoStep(CommunitySubscriptionWizardStep.RemoveSubscriptions); // else{ // SetupUnsubscriptions(); // View.GotoStep(CommunitySubscriptionWizardStep.RemoveSubscriptions); // } // } //} //private void SetupUnsubscriptions() //{ // Int32 idProfile = View.IdProfile; // List<dtoBaseUserSubscription> unsubscriptions = ServiceCommunity.ProfileIdCommunitiesToUnsubscribe(idProfile,View.CommunityFilters,View.SelectedIdCommunities()); // List<dtoBaseCommunityNode> nodes = View.GetNodesById(unsubscriptions.Select(s=>s.IdCommunity).ToList()); // unsubscriptions.ForEach(s => s.Path = nodes.Where(n => n.Id == s.IdCommunity).Select(n => n.Path).ToList()); // View.InitializeUnsubscriptionControl(idProfile, unsubscriptions); //} //private void MoveToSummary() //{ // if (UserContext.isAnonymous) // View.DisplaySessionTimeout(); // else if (View.HasAvailableSubscriptions || View.HasUnsubscriptions) // { // List<dtoBaseUserSubscription> toDelete = View.SelectedUnsubscriptions(); // List<dtoUserSubscription> subscriptions = View.SelectedSubscriptions(); // View.DisplaySummaryInfo((from s in subscriptions where s.isNew select s.CommunityName).ToList(), (from s in subscriptions where s.isToUpdate && s.isNew == false select s.CommunityName).ToList(), (from s in toDelete select s.CommunityName).ToList()); // View.GotoStep(CommunitySubscriptionWizardStep.Summary); // } //} //public void SaveChanges(List<dtoUserSubscription> subscriptions, List<dtoBaseUserSubscription> toDelete) //{ // Int32 idProfile = View.IdProfile; // Person person = CurrentManager.GetPerson(idProfile); // if (person == null || UserContext.isAnonymous) // View.DisplaySessionTimeout(); // else { // Person current = CurrentManager.GetPerson(UserContext.CurrentUserID); // if (ServiceCommunity.UpdateUserSubscriptions(person, subscriptions, toDelete)) // View.UpdateUserSubscriptions(idProfile, person.SurnameAndName, current.SurnameAndName, (from s in subscriptions where s.isNew select s).ToList(), toDelete.Select(s => s.IdCommunity).ToList()); // else // View.DisplayError(); // } //} public List <Int32> GetCommunityIdFromOrganization(List <Int32> idOrganizations) { return(ServiceCommunity.GetOrganizationsCommunityId(idOrganizations)); }
private void MoveFromOrganizationsSelector() { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else if (View.PrimaryOrganizationId > 0) { List <lm.Comol.Core.BaseModules.Dashboard.Domain.dtoCommunityPlainItem> organizations = ServiceCommunity.GetOrganizationNodes(View.AllOrganizationsId); View.OrganizationsNodes = organizations; if (!View.IsInitialized(ProfileImportStep.SelectCommunities)) { View.GotoStep(ProfileImportStep.SelectCommunities, true); } else { List <lm.Comol.Core.BaseModules.Dashboard.Domain.dtoCommunityPlainItem> items = View.SelectedCommunities(); List <String> avaliablePath = new List <String>(); organizations.ForEach(o => avaliablePath.AddRange(o.PathsToList())); items = items.Where(i => i.ContainsPath(avaliablePath)).ToList();; if (items.Count == 0) { View.GotoStep(ProfileImportStep.SelectCommunities, true); } else { View.UpdateSelectedCommunities(items.Select(i => i.Community.Id).ToList()); View.GotoStep(ProfileImportStep.SelectCommunities, false); } } } }