private static string Translatecommunity(string translation, liteCommunity community)
        {
            translation = translation.Replace(GetPlaceHolder(CommonPlaceHoldersType.CommunityName), (community == null) ? "" : ReplaceChars(community.Name));
            translation = translation.Replace(GetPlaceHolder(CommonPlaceHoldersType.CommunityId), (community == null) ? "" : ReplaceChars(community.Id.ToString()));

            return(translation);
        }
Beispiel #2
0
 public dtoRequestItemPermission(long id, liteCommunity community, CallStatusForSubmitters status, dtoRequest request)
     : base(id, community, status)
 {
     Call       = request;
     Deleted    = request.Deleted;
     Permission = new dtoBaseCallPermission();
 }
 public dtoCallItemPermission(long id, liteCommunity community, CallStatusForSubmitters status, dtoCall callForPaper)
     : base(id, community, status)
 {
     Call       = callForPaper;
     Deleted    = callForPaper.Deleted;
     Permission = new dtoCallPermission();
 }
Beispiel #4
0
        private void LoadRevisions(ModuleRequestForMembership module, CallStandardAction action, int idCommunity, dtoRevisionFilters filters, int pageIndex, int pageSize)
        {
            liteCommunity community          = CurrentManager.GetLiteCommunity(idCommunity);
            litePerson    person             = CurrentManager.GetLitePerson(UserContext.CurrentUserID);
            Boolean       fromAllcommunities = false;
            PagerBase     pager = new PagerBase();

            pager.PageSize = pageSize;

            if (action == CallStandardAction.Manage)
            {
                pager.Count = (int)Service.RevisionCount(fromAllcommunities, (idCommunity == 0), community, person, CallForPaperType.RequestForMembership, filters, RevisionType.Manager) - 1;
            }
            else
            {
                fromAllcommunities = (idCommunity == 0);
                pager.Count        = (int)Service.RevisionCount(fromAllcommunities, (idCommunity == 0), community, person, CallForPaperType.RequestForMembership, filters, RevisionType.UserRequired) - 1;
            }
            pager.PageIndex = pageIndex;// Me.View.CurrentPageIndex
            View.Pager      = pager;
            if (pager.Count < 0)
            {
                View.LoadNoRevisionsFound();
            }
            else
            {
                View.LoadRevisions(Service.GetRevisionList(module, action, fromAllcommunities, (idCommunity == 0), community, person, filters, pager.PageIndex, pageSize));
            }

            View.SendUserAction(View.IdCallCommunity, ServiceRequest.ServiceModuleID(), ModuleRequestForMembership.ActionType.LoadRevisionsList);
        }
Beispiel #5
0
 public dtoCallToFind(liteCommunity community)
 {
     if (community != null)
     {
         Community = community;
     }
 }
        public CommunityEvent AddMultipleItems(Int32 idCommunity, CommunityEventItem dtoItem, String description, String descriptionPlain, int ownerId, CommunityEventType eventType, DateTime startDate, DateTime endDate, List <dtoWeekDay> weekDays)
        {
            CommunityEvent communityEvent = null;

            try
            {
                litePerson    person    = Manager.GetLitePerson(ownerId);
                liteCommunity community = Manager.GetLiteCommunity(idCommunity);
                if ((community != null && idCommunity > 0) && person != null)
                {
                    List <dtoWeekDayRecurrence> itemsToInsert = dtoWeekDayRecurrence.CreateRecurrency(startDate, endDate, weekDays);
                    if (itemsToInsert.Count > 0)
                    {
                        Manager.BeginTransaction();
                        communityEvent = CreateGenericEvent(idCommunity, dtoItem, eventType, person);
                        Manager.SaveOrUpdate(communityEvent);
                        foreach (dtoWeekDayRecurrence recurrence in itemsToInsert)
                        {
                            CommunityEventItem eventItem = new CommunityEventItem()
                            {
                                IdCommunityOwner = idCommunity, EventOwner = communityEvent, Owner = person, CreatedBy = person, CreatedOn = DateTime.Now
                            };
                            eventItem.ModifiedBy   = eventItem.CreatedBy;
                            eventItem.ModifiedOn   = eventItem.CreatedOn;
                            eventItem.Note         = dtoItem.Note;
                            eventItem.NotePlain    = dtoItem.NotePlain;
                            eventItem.Place        = dtoItem.Place;
                            eventItem.Title        = dtoItem.Title;
                            eventItem.StartDate    = recurrence.StartDate;
                            eventItem.EndDate      = recurrence.EndDate;
                            eventItem.ShowDateInfo = dtoItem.ShowDateInfo;
                            eventItem.IsVisible    = dtoItem.IsVisible;
                            eventItem.Link         = dtoItem.Link;
                            eventItem.AllowEdit    = true;
                            Manager.SaveOrUpdate(eventItem);
                            if (!String.IsNullOrEmpty(description))
                            {
                                DescriptionEventItem descriptionItem = new DescriptionEventItem()
                                {
                                    Id = eventItem.Id, Description = description
                                };
                                descriptionItem.DescriptionPlain = descriptionPlain;
                                Manager.SaveOrUpdate(descriptionItem);
                            }
                            communityEvent.Items.Add(eventItem);
                        }
                        Manager.SaveOrUpdate(communityEvent);
                        Manager.Commit();
                    }
                }
            }
            catch (Exception ex)
            {
                Manager.RollBack();
                communityEvent = null;
            }
            return(communityEvent);
        }
        private List <dtoModuleActionControl> AnalyzeActions(dtoInternalActionInitializer dto, StandardActionType actionsToDisplay)
        {
            List <dtoModuleActionControl> actions = new List <dtoModuleActionControl>();

            View.ContainerCSS = dto.ContainerCSS;
            View.IconSize     = dto.IconSize;

            if (dto.SubActivity == null || dto.SubActivity.Id == 0)
            {
                View.DisplayEmptyAction();
            }
            else
            {
                View.Display           = dto.Display;
                View.IdTemplate        = dto.SubActivity.IdCertificate;
                View.IdTemplateVersion = dto.SubActivity.IdCertificateVersion;
                View.IdPath            = dto.IdPath;
                View.IdUnit            = dto.IdUnit;
                View.IdActivity        = dto.IdActivity;

                liteCommunity community = Service.GetPathCommunity(dto.IdPath);
                View.IdCommunityContainer = (community != null) ? community.Id : dto.IdPathCommunity;
                View.CertificationName    = dto.SubActivity.Name;
                View.IdSubActivity        = dto.SubActivity.Id;
                if (dto.SubActivity.IdCertificate == 0)
                {
                    if (Display(dto.Display, DisplayActionMode.adminMode))
                    {
                        View.DisplayUnselectedTemplateInfo();
                    }
                    else
                    {
                        Certification cer = GetAvailableUserCertification(dto.SubActivity, View.IdCommunityContainer, View.ForUserId);
                        if (cer == null)
                        {
                            View.DisplayUnselectedTemplate();
                        }
                        else
                        {
                            dto.SubActivity.SaveCertificate = false;
                            AnalyzeInternalItem(dto.IdPath, dto.SubActivity, dto.Display, actionsToDisplay);
                        }
                    }
                }
                else
                {
                    // Check if associated template is valid
                    //Boolean isValid = ServiceTemplates.isValidTemplate(dto.SubActivity.IdCertificate, dto.SubActivity.IdCertificateVersion);
                    if (dto.PlaceHolders.Where(p => !String.IsNullOrEmpty(p.Text)).Any() && (Display(dto.Display, DisplayActionMode.defaultAction) || Display(dto.Display, DisplayActionMode.text) || Display(dto.Display, DisplayActionMode.textDefault)))
                    {
                        View.DisplayPlaceHolders(dto.PlaceHolders.Where(p => !String.IsNullOrEmpty(p.Text)).ToList());
                    }
                    actions = AnalyzeInternalItem(dto.IdPath, dto.SubActivity, dto.Display, actionsToDisplay);
                }
            }
            return(actions);
        }
Beispiel #8
0
 public dtoItemPermission(long id, liteCommunity community, CallStatusForSubmitters status)
     : base()
 {
     this.Id           = id;
     Community         = community;
     Status            = status;
     SubmissionsInfo   = new List <dtoSubmissionDisplayInfo>();
     AllowSubmissionAs = new List <dtoBaseSubmitterType>();
 }
Beispiel #9
0
 public dtoCallItemPermission(long id, liteCommunity community, CallStatusForSubmitters status, dtoCall callForPaper, ModuleCallForPaper module, litePerson person)
     : this(id, community, status, callForPaper)
 {
     Permission.Delete           = false;
     Permission.VirtualDelete    = (Deleted == BaseStatusDeleted.None) && (module.ManageCallForPapers || module.Administration || (module.DeleteOwnCallForPaper && callForPaper.Owner.Id == person.Id));
     Permission.UnDelete         = (Deleted != BaseStatusDeleted.None) && (module.ManageCallForPapers || module.Administration || (module.EditCallForPaper && callForPaper.Owner.Id == person.Id));
     Permission.Edit             = (Deleted == BaseStatusDeleted.None) && (module.ManageCallForPapers || module.Administration || (module.EditCallForPaper && callForPaper.Owner.Id == person.Id));
     Permission.ManageComittees  = (Deleted == BaseStatusDeleted.None) && (module.ManageCallForPapers || module.Administration);
     Permission.ManageEvaluation = (Deleted == BaseStatusDeleted.None) && (module.ManageCallForPapers || module.Administration);
     Permission.ViewSubmissions  = (Deleted == BaseStatusDeleted.None) && (Call.Status != CallForPaperStatus.Draft) && (module.ManageCallForPapers || module.Administration || (module.EditCallForPaper && callForPaper.Owner.Id == person.Id));
 }
        public void InitView(String unknownUser)
        {
            Int32 idModule    = Service.ServiceModuleID();
            int   idCommunity = View.PreloadIdCommunity;

            if (idCommunity == 0 && UserContext.CurrentCommunityID > 0)
            {
                idCommunity = UserContext.CurrentCommunityID;
            }
            View.IdModuleCommunityDiary = idModule;
            View.IdModuleRepository     = CurrentManager.GetModuleID(lm.Comol.Core.FileRepository.Domain.ModuleRepository.UniqueCode);
            View.IdCommunityDiary       = idCommunity;
            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout(idCommunity);
            }
            else
            {
                liteCommunity community = CurrentManager.GetLiteCommunity(idCommunity);
                if (community == null && idCommunity > 0)
                {
                    View.IdCommunityDiary = -View.PreloadIdCommunity;
                    View.ShowUnkownCommunityDiary(idCommunity, idModule);
                }
                else
                {
                    ModuleCommunityDiary module = Service.GetPermissions(UserContext.CurrentUserID, idCommunity);
                    if (module == null)
                    {
                        module = new ModuleCommunityDiary();
                    }
                    if (module.Administration || module.DeleteItem || module.Edit || module.ViewDiaryItems)
                    {
                        View.DisplayOrderAscending = View.PreloadAscending;
                        InternalLoadDiaryItems(module, idCommunity, idModule, unknownUser);
                    }
                    else
                    {
                        View.HideItemsForNoPermission(idCommunity, idModule);
                    }
                }

                if (community == null && idCommunity == 0)
                {
                    View.SetTitleName(View.GetPortalNameTranslation());
                }
                else if (community != null && community.Id != UserContext.CurrentCommunityID)
                {
                    View.SetTitleName(community.Name);
                }
            }
        }
Beispiel #11
0
        public lm.Comol.Core.DomainModel.DocTemplateVers.Domain.DTO.ServiceExport.DTO_Template FillDataIntoTemplate(Int32 idCommunity, Int32 idUser, long idPath, long idSubActivity, String basePath, String istanceName, ref CertificationError cError)
        {
            lm.Comol.Core.DomainModel.DocTemplateVers.Domain.DTO.ServiceExport.DTO_Template template = null;
            SubActivity subActivity = Service.GetSubActivity(idSubActivity);

            if (subActivity != null)
            {
                template = ServiceTemplates.TemplateGet(subActivity.IdCertificate, subActivity.IdCertificateVersion, basePath);
                if (template != null)
                {
                    //litePerson person = CurrentManager.GetLitePerson(idUser);
                    Person person = CurrentManager.GetPerson(idUser);

                    liteCommunity        community    = CurrentManager.GetLiteCommunity(idCommunity);
                    liteSubscriptionInfo subscription = CurrentManager.GetLiteSubscriptionInfo(idUser, idCommunity);
                    String organization = "";


                    if (community != null)
                    {
                        organization = CurrentManager.GetOrganizationName(community.IdOrganization);
                    }

                    List <String> pHolders = TemplateEduPathPlaceHolders.PlaceHolders().Values.Select(v => v).ToList();

                    pHolders.AddRange(lm.Comol.Core.DomainModel.Helpers.TemplateCommonPlaceHolders.PlaceHolders().Values.Select(v => v).ToList());
                    if (template.Modules != null && template.Modules.Where(m => m.IdModule == Service.ServiceModuleID()).Any() && subActivity != null)
                    {
                        // DEVO RIEmPIRE I PLACE HOLDERS !
                        List <lm.Comol.Modules.EduPath.Domain.DTO.dtoSubActivityLink> links = Service.GetDtoSubactivityActiveLinks(idSubActivity);
                        if (links == null || links.Count == 0)
                        {
                            template.Body.Text = TemplateEduPathPlaceHolders.Translate(template.Body.Text, AppContext, idPath, idUser, subActivity);
                        }
                        else
                        {
                            template.Body.Text = TemplateEduPathPlaceHolders.Translate(template.Body.Text, AppContext, idPath, idUser, subActivity, View.GetQuizInfos(links.Where(l => l.Visible).Select(l => l.IdObject).ToList(), idUser, IsEvaluablePath(idPath)));
                        }
                    }
                    Int32 idLanguage = (person == null) ? UserContext.Language.Id : person.LanguageID;

                    template.Body.Text = lm.Comol.Core.DomainModel.Helpers.TemplateCommonPlaceHolders.Translate(template.Body.Text, person, community, (subscription == null) ? null : subscription.SubscribedOn, organization, CurrentManager.GetTranslatedRole(subscription.IdRole, idLanguage), CurrentManager.GetTranslatedProfileType((person == null) ? (int)UserTypeStandard.Guest : person.TypeID, idLanguage), istanceName);
                    Int32 missingPlaceHolders = pHolders.Where(p => template.Body.Text.Contains(p)).Count();
                    cError = (missingPlaceHolders == 0) ? CertificationError.None : ((missingPlaceHolders == 1) ? CertificationError.EmptyTemplateItem : CertificationError.EmptyTemplateItems);
                }
            }
            else
            {
                cError = CertificationError.ExternalItemUnknown;
            }
            return(template);
        }
        public void InitView(Int32 idCommunity, MenuBarType menubarType, String baseUrl, String defaultModuleToolTip, String defaultModuleUrl, String defaultModuleText)
        {
            if (idCommunity == -1)
            {
                idCommunity = UserContext.CurrentCommunityID;
            }

            Int32 idOrganization = 0;

            if (idCommunity > 0)
            {
                liteCommunity community = CurrentManager.Get <liteCommunity>(idCommunity);
                if (community == null)
                {
                    idCommunity = 0;
                }
                else
                {
                    idOrganization = community.IdOrganization;
                }
            }
            if (idOrganization == 0)
            {
                idOrganization = CurrentManager.GetUserDefaultIdOrganization(UserContext.CurrentUserID);
            }

            if (idCommunity == 0 && (menubarType != MenuBarType.Portal && menubarType != MenuBarType.PortalAdministration))
            {
                menubarType = MenuBarType.Portal;
                idCommunity = 0;
            }
            else if (idCommunity > 0 && menubarType == MenuBarType.None)
            {
                menubarType = MenuBarType.GenericCommunity;
            }
            if (idCommunity == 0)
            {
                View.DisplayName((menubarType == MenuBarType.Portal) ? View.GetPortalName : View.GetAdministrationName);
            }
            else
            {
                View.DisplayName(CurrentManager.GetCommunityName(idCommunity));
            }

            //Language language = CurrentManager.GetLanguageByIdOrDefault(UserContext.cu)
            View.BindLogo(idCommunity, idOrganization, UserContext.Language.Code);
            View.LoadMenuBar(Service.RenderCachedMenubar(idCommunity, menubarType, baseUrl, defaultModuleToolTip, defaultModuleUrl, defaultModuleText));
            View.MenubarType = menubarType;
        }
        public static String Translate(
            string content,
            Person person,
            liteCommunity community,
            DateTime?subscriptionOn,
            String organization,
            String roleName,
            String profileType,
            String istanceName)
        {
            //String translation = content;

            content = Translatecommunity(content, community);
            content = TranslatePerson(content, person);
            content = TranslateOther(content, istanceName, organization, profileType, subscriptionOn, roleName);

            return(content);
        }
Beispiel #14
0
        private List <RevisionStatus> LoadAvailableStatus(CallStandardAction action, int idCommunity, CallForPaperType type)
        {
            liteCommunity      community          = CurrentManager.GetLiteCommunity(idCommunity);
            litePerson         person             = CurrentManager.GetLitePerson(UserContext.CurrentUserID);
            Boolean            fromAllcommunities = false;
            dtoRevisionFilters filters            = new dtoRevisionFilters()
            {
                OrderBy = RevisionOrder.None, Status = RevisionStatus.None, CallType = type
            };

            if (action == CallStandardAction.Manage)
            {
                return(Service.GetAvailableRevisionStatus(fromAllcommunities, (idCommunity == 0), community, person, type, filters, RevisionType.Manager));
            }
            else
            {
                fromAllcommunities = (idCommunity == 0);
                return(Service.GetAvailableRevisionStatus(fromAllcommunities, (idCommunity == 0), community, person, type, filters, RevisionType.UserRequired));
            }
        }
Beispiel #15
0
 public dtoCallForPaper(long Id, String name, String edition, String description, DateTime startDate, System.DateTime?endDate, String awardDate,
                        Boolean submissionClosed, CallForPaperType type, bool displayWinner, liteCommunity community, Boolean isPublic, CallForPaperStatus status, EvaluationType evaluationType, Boolean allowSubmissionExtension, string notificationMail)
     : base(Id)
 {
     Name                     = name;
     Edition                  = edition;
     Description              = description;
     StartDate                = startDate;
     EndDate                  = endDate;
     AwardDate                = awardDate;
     SubmissionClosed         = submissionClosed;
     Type                     = type;
     DisplayWinner            = displayWinner;
     Community                = community;
     IsPublic                 = isPublic;
     Status                   = status;
     AllowSubmissionExtension = allowSubmissionExtension;
     NotificationEmail        = notificationMail;
     EvaluationType           = evaluationType;
 }
Beispiel #16
0
        //public void SelectCommunityToAdd()
        //{
        //    long idVersion = View.IdVersion;
        //    if (UserContext.isAnonymous)
        //        Logout(View.CurrentType, View.IdTemplate, idVersion);
        //    else
        //    {
        //        TemplateDefinitionVersion version = Service.GetVersion(idVersion);
        //        Dictionary<Int32, long> rPermissions = new Dictionary<Int32, long>();
        //        Boolean forAdmin = (UserContext.UserTypeID == (Int32)UserTypeStandard.SysAdmin) || (UserContext.UserTypeID == (Int32)UserTypeStandard.Administrator) || (UserContext.UserTypeID == (Int32)UserTypeStandard.Administrative);
        //        Core.BaseModules.CommunityManagement.CommunityAvailability availability = (forAdmin) ? Core.BaseModules.CommunityManagement.CommunityAvailability.All : Core.BaseModules.CommunityManagement.CommunityAvailability.Subscribed;

        //        /*if (version!=null && version.Template!= null && version.Template.OwnerInfo.Type== OwnerType.Module)
        //            rPermissions.Add(version.Template.OwnerInfo.IdModule, version.Template.OwnerInfo.);
        //        else*/
        //        rPermissions.Add(Service.ServiceModuleID(), (long)ModuleTemplateMessages.Base2Permission.Administration | (long)ModuleTemplateMessages.Base2Permission.ManageTemplates);
        //        rPermissions.Add(CommunityService.ServiceModuleID(), (long)lm.Comol.Core.DomainModel.Domain.ModuleCommunityManagement.Base2Permission.Manage | (long)lm.Comol.Core.DomainModel.Domain.ModuleCommunityManagement.Base2Permission.AdminService);
        //        List<Int32> idCommunities = Service.GetIdCommunityAssignments(idVersion);
        //        View.InitializeCommunityToAdd(UserContext.CurrentUserID, forAdmin, rPermissions, idCommunities, availability);
        //    }
        //}
        public void AddCommunity(List <Int32> idCommunites)
        {
            long idVersion = View.IdVersion;

            if (UserContext.isAnonymous)
            {
                Logout(View.CurrentType, View.IdTemplate, idVersion);
            }
            else if (idCommunites.Any())
            {
                Boolean saved = Service.AddCommunityAssignment(idVersion, idCommunites);
                if (saved)
                {
                    if (idCommunites.Count > 1)
                    {
                        View.DisplayCommunityAssignmentsAdded();
                    }
                    else
                    {
                        liteCommunity c = CurrentManager.GetLiteCommunity(idCommunites.First());
                        if (c != null)
                        {
                            View.DisplayCommunityAssignmentAdded(c.Name);
                        }
                        else
                        {
                            View.DisplayCommunityAssignmentsAdded();
                        }
                    }
                    LoadAssignments(idVersion, View.GetPermissions(), PermissionType.Base);
                    InitializeCommunitySelector();
                }
                else
                {
                    View.DisplayCommunityAddingError();
                }
            }
        }
        private dtoProject InitializeContext(long idProject, ref dtoProjectContext cContex)
        {
            dtoProject project = Service.GetdtoProject(idProject);

            View.IdProject = idProject;
            if (project == null)
            {
                Int32         idCommunity = (!cContex.isForPortal && cContex.IdCommunity < 1) ? UserContext.CurrentCommunityID : cContex.IdCommunity;
                liteCommunity community   = (idCommunity > 0) ? CurrentManager.GetLiteCommunity(idCommunity) : null;
                cContex.IdCommunity = (community != null) ? community.Id : 0;
            }
            else
            {
                cContex.IdCommunity = project.IdCommunity;
                View.forPortal      = project.isPortal;
                View.isPersonal     = project.isPersonal;
            }

            View.ProjectIdCommunity = cContex.IdCommunity;
            View.forPortal          = cContex.isForPortal;
            View.isPersonal         = cContex.isPersonal;
            return(project);
        }
        /// <summary>
        /// Metodo creato per Trentino Sviluppo che chiama i loro servizi per controllare se è un utente Federato
        /// </summary>
        /// <param name="communityId"></param>
        /// <param name="userId"></param>
        /// <param name="externlUrl">ToDo: diventerà OBJECT con i parametri necesari.</param>
        /// <returns></returns>
        /// <remarks>
        /// externlUrl: l'oggetto che lo sostiuirà avrà una classe base con un set minimo di informazioni (es: URL) ed eventuali sottoclassi che lo estendono con ulteriori informazioni specifiche.
        /// </remarks>
        public Enums.FederationResult FederationUserCheck(
            int communityId,
            int userId,
            string settings)
        {
            if (String.IsNullOrEmpty(settings))
            {
                return(Enums.FederationResult.CommunityNotFederated);
            }


            if (communityId <= 0)
            {
                return(FederationInternalUserCheck(userId, settings));
            }


            //lm.Comol.Core.BaseModules.Federation.Enums.FederationType communityFederation = Enums.FederationType.None;

            litePerson    person    = null;
            liteCommunity community = null;

            Enums.FederationType fedType = Enums.FederationType.None;

            try
            {
                using (ISession session = NHSessionHelper.GetComolSession())
                {
                    DataContext dc = new DataContext(session);

                    lm.Comol.Core.BaseModules.Federation.Business.FederationService service =
                        new lm.Comol.Core.BaseModules.Federation.Business.FederationService(dc);

                    fedType = service.CommunityFederation(communityId);

                    switch (fedType)
                    {
                    case Enums.FederationType.TrentinoSviluppo:
                        person = service.UserGet(userId);
                        break;

                    case Enums.FederationType.None:
                        return(Enums.FederationResult.CommunityNotFederated);
                    }
                }

                switch (fedType)
                {
                case Enums.FederationType.TrentinoSviluppo:
                    if (person == null || person.Id <= 0)
                    {
                        return(Enums.FederationResult.UserNotFound);    //o throw new Exception("Persona non trovata");
                    }
                    return(FederationCheck(person, settings));

caseelse:
                    break;
                }
            }
            catch (Exception)
            {
            }

            return(Enums.FederationResult.Unknow);
        }
Beispiel #19
0
        public CommunityEventItem SaveEventItem(int idCommunity, CommunityEventItem unsavedItem, String description, String descriptionPlain, int ownerId, int savedById, CommunityEventType eventType)
        {
            CommunityEventItem eventItem = null;

            litePerson     owner      = Manager.GetLitePerson(ownerId);
            litePerson     savedBy    = Manager.GetLitePerson(savedById);
            liteCommunity  community  = Manager.GetLiteCommunity(idCommunity);
            CommunityEvent eventOwner = unsavedItem.EventOwner;

            try
            {
                if (owner != null && savedBy != null && (community != null && idCommunity > 0))
                {
                    Manager.BeginTransaction();
                    if (unsavedItem.Id == 0)
                    {
                        eventItem                  = new CommunityEventItem();
                        eventItem.Owner            = owner;
                        eventItem.CreatedBy        = savedBy;
                        eventItem.CreatedOn        = DateTime.Now;
                        eventItem.ModifiedBy       = savedBy;
                        eventItem.ModifiedOn       = eventItem.CreatedOn;
                        eventItem.IdCommunityOwner = idCommunity;
                        eventItem.AllowEdit        = true;
                    }
                    else
                    {
                        eventItem = Manager.Get <CommunityEventItem>(unsavedItem.Id);
                        if (eventItem.Owner == null)
                        {
                            eventItem.Owner = savedBy;
                        }
                        eventItem.ModifiedBy = savedBy;
                        eventItem.ModifiedOn = DateTime.Now;
                    }
                    eventItem.Note         = unsavedItem.Note;
                    eventItem.NotePlain    = unsavedItem.NotePlain;
                    eventItem.Place        = unsavedItem.Place;
                    eventItem.Title        = unsavedItem.Title;
                    eventItem.StartDate    = unsavedItem.StartDate;
                    eventItem.EndDate      = unsavedItem.EndDate;
                    eventItem.ShowDateInfo = unsavedItem.ShowDateInfo;
                    eventItem.IsVisible    = unsavedItem.IsVisible;
                    eventItem.Link         = unsavedItem.Link;

                    if (unsavedItem.Id == 0)
                    {
                        eventOwner = CreateGenericEvent(idCommunity, eventItem, eventType, savedBy);
                        Manager.SaveOrUpdate(eventOwner);
                        eventItem.EventOwner = eventOwner;
                        if (eventOwner.Items == null)
                        {
                            eventOwner.Items = new List <CommunityEventItem>();
                        }
                        eventOwner.Items.Add(eventItem);
                        Manager.SaveOrUpdate(eventItem);
                        Manager.SaveOrUpdate(eventOwner);
                    }
                    else
                    {
                        Manager.SaveOrUpdate(eventItem);
                    }

                    DescriptionEventItem descriptionItem = Manager.Get <DescriptionEventItem>(eventItem.Id);
                    if (descriptionItem == null && !string.IsNullOrEmpty(description))
                    {
                        descriptionItem = new DescriptionEventItem()
                        {
                            Id = eventItem.Id
                        }
                    }
                    ;
                    if (descriptionItem != null)
                    {
                        descriptionItem.Description      = description;
                        descriptionItem.DescriptionPlain = descriptionPlain;
                        Manager.SaveOrUpdate(descriptionItem);
                    }
                    Manager.Commit();
                }
            }
            catch (Exception ex)
            {
                Manager.RollBack();
                eventItem = null;
            }

            return(eventItem);
        }
Beispiel #20
0
        public void InitView(Int32 idCommunity, long idItem, String unknownUser, Boolean isForAdd = false)
        {
            idCommunity = (idCommunity == 0 ? UserContext.CurrentCommunityID : idCommunity);
            if (!UserContext.isAnonymous)
            {
                litePerson         person = CurrentManager.GetLitePerson(UserContext.CurrentUserID);
                CommunityEventItem item   = (idItem > 0  ? Service.EventItemGet(idItem) :null);
                if (item != null && idCommunity != item.IdCommunityOwner)
                {
                    idCommunity = item.IdCommunityOwner;
                }
                View.IdCommunityDiary       = idCommunity;
                View.IdModuleCommunityDiary = GetIdModule();
                View.IdModuleRepository     = ServiceRepository.GetIdModule();
                liteCommunity community = CurrentManager.GetLiteCommunity(idCommunity);
                if ((community == null && idCommunity > 0) || (!isForAdd && idItem == 0))
                {
                    View.NoPermission(idCommunity, GetIdModule());
                }
                else
                {
                    if (item == null && !isForAdd)
                    {
                        View.ShowNoItemWithThisID(idCommunity, GetIdModule(), idItem);
                    }
                    else
                    {
                        long idEvent = ((item != null && item.EventOwner != null)? item.EventOwner.Id : 0);
                        View.CurrentIdItem  = idItem;
                        View.CurrentIdEvent = idEvent;
                        ModuleCommunityDiary module = Service.GetPermissions(UserContext.CurrentUserID, idCommunity);
                        if ((module.AddItem && isForAdd) || (module.Administration || module.Edit))
                        {
                            String description = "";
                            if (idItem == 0)
                            {
                                item                  = new CommunityEventItem();
                                item.Title            = "";
                                item.Note             = "";
                                item.Owner            = CurrentManager.GetLitePerson(UserContext.CurrentUserID);
                                item.ModifiedOn       = DateTime.Now;
                                item.StartDate        = new DateTime(item.ModifiedOn.Year, item.ModifiedOn.Month, item.ModifiedOn.Day, 8, 0, 0);
                                item.EndDate          = new DateTime(item.ModifiedOn.Year, item.ModifiedOn.Month, item.ModifiedOn.Day, 11, 0, 0);
                                item.IsVisible        = true;
                                item.Link             = "";
                                item.Place            = "";
                                item.Title            = "";
                                item.IdCommunityOwner = idCommunity;
                                item.ShowDateInfo     = true;
                            }
                            else
                            {
                                description = Service.EventItemGetDescription(item);
                            }

                            lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier identifier = lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier.Create((idCommunity > 0 ? lm.Comol.Core.FileRepository.Domain.RepositoryType.Community : lm.Comol.Core.FileRepository.Domain.RepositoryType.Portal), idCommunity);

                            View.RepositoryIdentifier = identifier;
                            String communityName = (community != null ? community.Name : View.GetPortalNameTranslation());
                            List <dtoAttachmentItem> attachments = null;
                            if (idItem > 0)
                            {
                                lm.Comol.Core.FileRepository.Domain.ModuleRepository moduleRepository = ServiceRepository.GetPermissions(identifier, UserContext.CurrentUserID);
                                List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> availableActions = Service.GetAvailableUploadActions(module, moduleRepository);
                                lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions        dAction          = (availableActions == null || !availableActions.Any()) ? lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions.none : availableActions.FirstOrDefault();
                                View.InitializeAttachmentsControl(idEvent, idItem, availableActions, dAction);

                                attachments              = Service.AttachmentsGet(person, item, true, Service.GetItemPermission(person, item, module, moduleRepository), moduleRepository, unknownUser);
                                View.AllowEdit           = true;
                                View.AllowFileManagement = availableActions.Any();
                            }
                            else
                            {
                                View.AllowEdit           = module.Administration || module.AddItem;
                                View.AllowFileManagement = false;
                            }
                            View.LoadItem(item, description, communityName, attachments);
                        }
                        else
                        {
                            View.NoPermission(idCommunity, GetIdModule());
                        }
                    }
                    View.SetBackToDiary(idCommunity, idItem);
                }
            }
            else
            {
                View.DisplaySessionTimeout(idCommunity, idItem);
            }
        }
Beispiel #21
0
 public dtoItemPermission(long id, liteCommunity community, CallStatusForSubmitters status, dtoSubmissionDisplayInfo subInfo)
     : this(id, community, status)
 {
     SubmissionsInfo.Add(subInfo);
 }
Beispiel #22
0
        public virtual DashboardSettings Copy(litePerson person, String ipAddress, String proxyIpAddress, liteCommunity community = null)
        {
            DashboardSettings clone = BaseClone();

            clone.CreateMetaInfo(person, ipAddress, proxyIpAddress);
            if (community != null)
            {
                clone.Community = community;
                clone.Type      = DashboardType.Community;
            }
            clone.Container = Container.Copy();
            clone.Pages     = Pages.Where(p => p.Deleted == BaseStatusDeleted.None).Select(p => p.Copy(clone)).ToList();
            if (Assignments.Any())
            {
                clone.Assignments = Assignments.Where(a => a.Deleted == BaseStatusDeleted.None).Select(a => a.Copy(clone, person, ipAddress, proxyIpAddress)).ToList();
            }
            return(clone);
        }