private List <dtoEvaluationLink> GetRelatedLinks(int IdUser, long IdFile)
        {
            List <dtoEvaluationLink> results = null;

            try
            {
                if ((from e in CurrentManager.GetIQ <ScormPackageToEvaluate>() where e.IdFile == IdFile && e.IdPerson == IdUser && e.ToUpdate select e.Id).Any())
                {
                    IList <long> IdLinks = (from l in CurrentManager.GetIQ <ModuleLink>()
                                            where l.NotifyExecution && l.DestinationItem.ServiceCode == CoreModuleRepository.UniqueID && l.DestinationItem.ObjectLongID == IdFile
                                            select l.Id).ToList();
                    results = (from e in CurrentManager.GetIQ <ScormPackageToEvaluate>()
                               where IdLinks.Contains(e.IdLink) && e.IdPerson == IdUser && e.ToUpdate
                               select new dtoEvaluationLink()
                    {
                        Id = e.Id, LinkId = e.IdLink, ModifiedOn = e.ModifiedOn
                    }).ToList();
                }
                else
                {
                    results = new List <dtoEvaluationLink>();
                }
            }
            catch (Exception ex) {
                results = new List <dtoEvaluationLink>();
            }
            return(results);
        }
예제 #2
0
        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);
        }
예제 #3
0
        private Person GetCurrentUser(ref Int32 idUser)
        {
            Person person = null;

            if (UserContext.isAnonymous)
            {
                person = (from p in CurrentManager.GetIQ <Person>() where p.TypeID == (int)UserTypeStandard.Guest select p).Skip(0).Take(1).ToList().FirstOrDefault(); //CurrentManager.GetPerson(UserContext.CurrentUserID);
                idUser = (person != null) ? person.Id : UserContext.CurrentUserID;                                                                                     //if(Person!=null) { IdUser = PersonId} else {IdUser = UserContext...}
            }
            else
            {
                person = CurrentManager.GetPerson(idUser);
            }
            return(person);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="row">String row to analyze</param>
        /// <param name="dLanguage">Default language</param>
        /// <returns></returns>
        private Language GetUserLanguage(ProfileAttributesRow row, Language dLanguage)
        {
            Language result = null;
            String   lCode  = row.GetCellValue(ProfileAttributeType.language);

            if (!String.IsNullOrEmpty(lCode))
            {
                List <Language> languages = (from l in CurrentManager.GetIQ <Language>() where l.Code == lCode || l.Code.StartsWith(lCode + "-") select l).ToList();
                if (languages.Count == 1 || languages.Count > 1)
                {
                    result = languages.FirstOrDefault();
                }
            }
            return((result == null) ? dLanguage : result);
        }
예제 #5
0
        public List <dtoSubscriptionInfo> GetSubscriptionsInfo(String roles)
        {
            List <dtoSubscriptionInfo> subscriptions = new List <dtoSubscriptionInfo>();
            List <Int32> idRoles = GetIdRoles(roles);

            try
            {
                CurrentManager.BeginTransaction();
                foreach (Int32 idRole in idRoles)
                {
                    dtoSubscriptionInfo sub = new dtoSubscriptionInfo();
                    sub.IdRole = idRole;
                    sub.Count  = (from LazySubscription s in CurrentManager.GetIQ <LazySubscription>() where s.IdRole == idRole && s.Accepted && s.IdCommunity == UserContext.CurrentCommunityID select s.Id).Count();
                    subscriptions.Add(sub);
                }
                CurrentManager.Commit();
            }
            catch (Exception ex)
            {
                CurrentManager.RollBack();
            }
            return(subscriptions);
        }
        public void SaveCompleteSubmission(List <dtoSubmissionValueField> fields, lm.Comol.Core.MailCommons.Domain.Configurations.SmtpServiceConfig smtpConfig, String websiteUrl, Dictionary <SubmissionTranslations, string> translations, String BaseFilePath, String translationFileName, DateTime clickDt)
        {
            long           idSubmission = this.View.IdSubmission;
            long           idCall       = View.IdCall;
            UserSubmission submission   = Service.GetUserSubmission(View.IdSubmission);

            if (submission == null || submission.AllowEditSubmission(View.InitSubmissionTime, clickDt))
            {
                submission = SaveUserSubmission(fields);
                if (submission != null || submission.AllowEditSubmission(View.InitSubmissionTime, clickDt))
                {
                    idSubmission = submission.Id;
                    //View.IdSubmission = idSubmission;
                    View.TryToComplete = true;
                    Revision revision = Service.GetRevision(View.IdRevision);
                    try
                    {
                        Int32      idUser = UserContext.CurrentUserID;
                        litePerson person = GetCurrentUser(ref idUser);
                        if (submission.Owner.Id == idUser)
                        {
                            if (fields.Any(f => f.Field.Type == FieldType.FileInput && (f.Value == null || f.Value.IdLink == 0)))
                            {
                                List <SubmissionFieldFileValue> fValues = (from f in CurrentManager.GetIQ <SubmissionFieldFileValue>()
                                                                           where f.Submission == submission && f.Deleted == BaseStatusDeleted.None && f.Revision.Id == revision.Id
                                                                           select f).ToList();
                                if (fValues.Any())
                                {
                                    foreach (dtoSubmissionValueField field in fields.Where(f => f.Field.Type == FieldType.FileInput && (f.Value == null || f.Value.IdLink == 0)))
                                    {
                                        field.Value.IdLink = fValues.Where(f => f.Field.Id == field.IdField).Select(f => f.Link.Id).FirstOrDefault();
                                    }
                                }
                            }

                            Service.UserCompleteSubmission(submission, revision, View.InitSubmissionTime, idUser, BaseFilePath, fields, smtpConfig, websiteUrl, translations, translationFileName, clickDt);
                            View.AllowCompleteSubmission = false;
                            View.AllowDeleteSubmission   = false;
                            View.AllowSave = false;
                            View.SendUserAction(View.IdCallCommunity, View.IdCallModule, submission.Id, ModuleRequestForMembership.ActionType.ConfirmSubmission);
                            View.GoToUrl(RootObject.FinalMessage(CallForPaperType.RequestForMembership, idCall, idSubmission, View.IdRevision, submission.UserCode, View.isAnonymousSubmission, View.FromPublicList, CallStatusForSubmitters.Submitted, View.PreloadIdOtherCommunity));
                        }
                        else if (!View.isAnonymousSubmission && UserContext.isAnonymous)
                        {
                            View.DisplayCallUnavailableForPublic();
                        }
                        else
                        {
                            View.DisplaySessionTimeout();
                        }
                    }
                    catch (SubmissionStatusChange ex)
                    {
                        View.AllowDeleteSubmission = (submission != null && submission.Deleted == BaseStatusDeleted.None && submission.Status == SubmissionStatus.draft);
                        View.LoadError(SubmissionErrorView.SubmissionValueSaving, View.IdCallCommunity, idCall, CallStatusForSubmitters.SubmissionOpened);
                    }
                    catch (SubmissionItemsEmpty ex)
                    {
                        Dictionary <long, FieldError> errors = Service.GetSubmissionFieldErrors(submission, revision);
                        View.AllowDeleteSubmission = (submission != null && submission.Deleted == BaseStatusDeleted.None && submission.Status == SubmissionStatus.draft);
                        View.LoadError((errors.ToList().Where(er => er.Value != FieldError.Mandatory).Any()) ? SubmissionErrorView.InvalidFields : SubmissionErrorView.RequiredItems, View.IdCallCommunity, idCall, CallStatusForSubmitters.SubmissionOpened);
                        LoadSections(submission.Call, submission.Type.Id, idSubmission, View.IdRevision, errors);
                    }
                    catch (SubmissionTimeExpired ex)
                    {
                        View.LoadError(SubmissionErrorView.SubmissionValueSaving, View.IdCallCommunity, idCall, CallStatusForSubmitters.SubmissionClosed);
                    }
                    //View.InitSubmissionTime = DateTime.Now;
                }
            }
            else if (submission != null)
            {
                View.GoToUrl(CallStandardAction.None, RootObject.ViewSubmission(CallForPaperType.RequestForMembership, idCall, idSubmission, View.FromPublicList, CallStatusForSubmitters.Submitted, View.PreloadIdOtherCommunity, 0));
            }
            else
            {
                View.GoToUrl(CallStandardAction.List, RootObject.ViewCalls(idCall, CallForPaperType.RequestForMembership, CallStandardAction.List, View.IdCallCommunity, CallStatusForSubmitters.SubmissionClosed));
            }
        }
예제 #7
0
        public void InitView(String plattformId)
        {
            long idLink = View.PlayerIdLink;
            int  IdUser = UserContext.CurrentUserID;

            if (UserContext.isAnonymous)
            {
                View.SendToSessionExpiredPage(View.PlayerIdCommunity, View.PreloadedLanguage);
            }
            else
            {
                Guid playUniqueSessionId = Guid.NewGuid();
                View.PlayUniqueSessionId = playUniqueSessionId;
                String playSessionId = plattformId + "_" + playUniqueSessionId.ToString();
                View.PlaySessionId = playSessionId;

                Boolean           allowPlay = false;
                BaseCommunityFile item      = Service.GetItem(View.PlayerIdFile);
                if (item == null)
                {
                    View.LoadFileNotExist();
                }
                else
                {
                    if (idLink == 0 && View.PlayerIdModule == ModuleID)
                    {
                        int idCommunity = View.PlayerIdCommunity;
                        if (item.CommunityOwner != null && idCommunity == 0)
                        {
                            idCommunity            = item.CommunityOwner.Id;
                            View.PlayerIdCommunity = idCommunity;
                        }
                        allowPlay = HasPermissionForRepository(item, IdUser, idCommunity, View.PlayerIdModule);
                    }
                    else if (idLink > 0)
                    {
                        allowPlay = lm.Comol.Core.DomainModel.PermissionHelper.CheckPermissionSoft((long)CoreModuleRepository.Base2Permission.DownloadFile, View.GetPermissionToLink(IdUser, idLink, item, View.PlayerIdCommunity));
                    }

                    if (!allowPlay)
                    {
                        View.LoadFileNoPermission();
                    }
                    else if (item.RepositoryItemType == DomainModel.Repository.RepositoryItemType.FileStandard && item.RepositoryItemType == DomainModel.Repository.RepositoryItemType.Folder)
                    {
                        View.InvalidFileTypeToPlay(item.RepositoryItemType);
                    }
                    else if (Service.GetItemTransferStatus(item.UniqueID) == DomainModel.Repository.TransferStatus.Completed)
                    {
                        //if (item.RepositoryItemType== DomainModel.Repository.RepositoryItemType.ScormPackage)
                        Boolean autoEvaluate = (from l in CurrentManager.GetIQ <ModuleLink>() where l.Id == idLink && l.AutoEvaluable select l.Id).Any() && View.PlayerSavingStatistics;

                        if (View.PlayerSavingStatistics)
                        {
                            Service.SaveUserAccessToFile(playSessionId, IdUser, item, idLink);
                        }
                        switch (item.RepositoryItemType)
                        {
                        case DomainModel.Repository.RepositoryItemType.ScormPackage:
                            View.LoadFileIntoPlayer(playSessionId, View.PlayerWorkingSessionID, item.UniqueID, IdUser, idLink, item.Id, item.RepositoryItemType);
                            break;

                        case DomainModel.Repository.RepositoryItemType.Multimedia:
                            MultimediaFileTransfer fileTransfer = Service.GetMultimediaFileTransfer(item);
                            if (fileTransfer == null || fileTransfer.DefaultDocument == null)
                            {
                                View.InvalidFileTypeToPlay(item.RepositoryItemType);
                            }
                            else
                            {
                                View.LoadMultimediaFileIntoPlayer(playSessionId, View.PlayerWorkingSessionID, item.UniqueID, IdUser, idLink, item.Id, fileTransfer.DefaultDocumentPath.Replace("\\", "/"));
                                if (autoEvaluate)
                                {
                                    View.SaveLinkEvaluation(idLink, IdUser);
                                }
                            }
                            break;
                        }
                    }
                    else
                    {
                        View.LoadFileNoReadyToPlay(item.RepositoryItemType, Service.GetItemTransferStatus(item.UniqueID));
                    }
                }
            }
        }