Exemple #1
0
        /// <summary>
        /// Recupera il service dato il service Code,
        /// evitando 50 switch in tutte le funzioni a cui poi tocca "correre dietro" in caso di aggiunta di un servizio!!!
        /// </summary>
        /// <param name="serviceCode"></param>
        /// <param name="dc"></param>
        /// <returns></returns>
        private iLinkedService ServiceGet(string serviceCode, iDataContext dc, iDataContext ic = null)
        {
            iLinkedService service = null;

            switch (serviceCode)
            {
            //Percorso formativo
            case Services_EduPath.Codex:
                service = new lm.Comol.Modules.EduPath.BusinessLogic.Service(dc);
                break;

            //Community Diary
            case lm.Comol.Core.BaseModules.CommunityDiary.Domain.ModuleCommunityDiary.UniqueID:
                service = new lm.Comol.Core.BaseModules.CommunityDiary.Business.ServiceCommunityDiary(dc);
                break;

            //Project Management
            case lm.Comol.Modules.Standard.ProjectManagement.Domain.ModuleProjectManagement.UniqueCode:
                service = new lm.Comol.Modules.Standard.ProjectManagement.Business.ServiceProjectManagement(dc);
                break;

            //Bandi
            case lm.Comol.Modules.CallForPapers.Domain.ModuleCallForPaper.UniqueCode:
                service = new lm.Comol.Modules.CallForPapers.Business.ServiceCallOfPapers(dc);
                break;

            //Richieste adesione
            case lm.Comol.Modules.CallForPapers.Domain.ModuleRequestForMembership.UniqueCode:
                service = new lm.Comol.Modules.CallForPapers.Business.ServiceRequestForMembership(dc);
                break;

            //Ticket
            case lm.Comol.Core.BaseModules.Tickets.ModuleTicket.UniqueCode:
                service = new lm.Comol.Core.BaseModules.Tickets.TicketService(dc);
                break;

            ////Webinar (WebEx)
            //case "Webinar":     //ToDo: usare UniqueCode
            //    iApplicationContext ac = new ApplicationContext();
            //    ac.DataContext = dc;
            //    service = new WebExService(ac);
            //    break;

            //Questionari
            case COL_Questionario.ModuleQuestionnaire.UniqueID:
                service = new COL_Questionario.Business.ServiceQuestionnaire(dc);
                break;

            //Repository - SCORM
            case lm.Comol.Core.FileRepository.Domain.ModuleRepository.UniqueCode:
                service = new lm.Comol.Core.BaseModules.FileRepository.Business.ServiceRepositoryScorm(dc, ic);
                break;


            default:
                break;
            }

            return(service);
        }
        public List <StandardActionType> GetAllowedStandardActionForExternal(ModuleObject source, ModuleObject destination, Int32 idUser, Dictionary <String, long> moduleUserLong, Dictionary <String, String> moduleUserString)
        {
            List <StandardActionType> actions = new List <StandardActionType>();

            using (ISession session = NHSessionHelper.GetComolSession())
            {
                DataContext    dc      = new DataContext(session);
                int            idRole  = GetIdRole(session, idUser, source.CommunityID);
                iLinkedService service = null;
                switch (source.ServiceCode)
                {
                //Percorso formativo
                case Services_EduPath.Codex:
                    lm.Comol.Modules.EduPath.BusinessLogic.Service EPservice = new lm.Comol.Modules.EduPath.BusinessLogic.Service(dc);
                    actions = EPservice.GetAllowedStandardAction(source, destination, idUser, idRole, source.CommunityID, moduleUserLong, moduleUserString);
                    break;

                //Community Diary
                case lm.Comol.Core.BaseModules.CommunityDiary.Domain.ModuleCommunityDiary.UniqueID:
                    lm.Comol.Core.BaseModules.CommunityDiary.Business.ServiceCommunityDiary DRservice = new lm.Comol.Core.BaseModules.CommunityDiary.Business.ServiceCommunityDiary(dc);
                    actions = DRservice.GetAllowedStandardAction(source, destination, idUser, idRole, source.CommunityID, moduleUserLong, moduleUserString);

                    break;
                ////Project Management
                //case lm.Comol.Modules.Standard.ProjectManagement.Domain.ModuleProjectManagement.UniqueCode:
                //    lm.Comol.Modules.Standard.ProjectManagement.Business.ServiceProjectManagement PMservice = new lm.Comol.Modules.Standard.ProjectManagement.Business.ServiceProjectManagement(dc);
                //.GetAllowedStandardAction(source, destination, idUser, idRole, source.CommunityID, moduleUserLong, moduleUserString);
                //    break;

                //Bandi
                case lm.Comol.Modules.CallForPapers.Domain.ModuleCallForPaper.UniqueCode:
                    lm.Comol.Modules.CallForPapers.Business.ServiceCallOfPapers CPservice = new lm.Comol.Modules.CallForPapers.Business.ServiceCallOfPapers(dc);
                    actions = CPservice.GetAllowedStandardAction(source, destination, idUser, idRole, source.CommunityID, moduleUserLong, moduleUserString);

                    break;

                //Richieste adesione
                case lm.Comol.Modules.CallForPapers.Domain.ModuleRequestForMembership.UniqueCode:
                    lm.Comol.Modules.CallForPapers.Business.ServiceRequestForMembership RMservice = new lm.Comol.Modules.CallForPapers.Business.ServiceRequestForMembership(dc);
                    actions = RMservice.GetAllowedStandardAction(source, destination, idUser, idRole, source.CommunityID, moduleUserLong, moduleUserString);

                    break;

                //Ticket
                case lm.Comol.Core.BaseModules.Tickets.ModuleTicket.UniqueCode:
                    lm.Comol.Core.BaseModules.Tickets.TicketService TKservice = new lm.Comol.Core.BaseModules.Tickets.TicketService(dc);
                    actions = TKservice.GetAllowedStandardAction(source, destination, idUser, idRole, source.CommunityID, moduleUserLong, moduleUserString);

                    break;

                default:
                    break;
                }
                //iLinkedService service = ServiceGet(source.ServiceCode, dc);
                //if (service != null)
                //    actions = service.GetAllowedStandardAction(source, destination, idUser, idRole, source.CommunityID, moduleUserLong, moduleUserString);
            }
            return(actions);
        }
Exemple #3
0
        public static String Translate(string content, lm.Comol.Core.DomainModel.iApplicationContext appContext, long idPath, Int32 idUser, SubActivity subActivity)
        {
            String translation = content;

            lm.Comol.Modules.EduPath.BusinessLogic.Service service = new lm.Comol.Modules.EduPath.BusinessLogic.Service(appContext);
            Path path = service.GetPath(idPath);

            if (path != null)
            {
                translation = Translate(translation, service, path, idUser, subActivity);
            }
            return(translation);
        }
Exemple #4
0
        public static String Translate(string content, lm.Comol.Core.DomainModel.iApplicationContext appContext, long idPath, Int32 idUser, SubActivity subActivity, List <dtoQuizInfo> items)
        {
            //return content;

            #region Setup

            lm.Comol.Modules.EduPath.BusinessLogic.Service service = new lm.Comol.Modules.EduPath.BusinessLogic.Service(appContext);

            Path   path        = service.GetPath(idPath);
            String translation = Translate(content, service, path, idUser, subActivity);

            DateTime?endDate = service.GetEpEndDate(path, idUser);

            #endregion

            if (items.Count > 0 && translation.Contains(OpenTag + "ep.Quiz"))
            {
                foreach (dtoQuizInfo quiz in items)
                {
                    // DATE LE INFO RELATIVE AI QUIZ SISTEMARE l'OUTPUT INTANTO UN ESEMPIO PER VEDERE SE VA
                    var query = quiz.Attempts.Where(a => (!subActivity.UsePathEndDateStatistics || !endDate.HasValue) || (subActivity.UsePathEndDateStatistics && endDate.HasValue && a.CompletedOn <= endDate.Value));

                    //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.QuizName)))
                    //    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.QuizName), ReplaceChars(quiz.Name));
                    //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.QuizMinMark)))
                    //    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.QuizMinMark), quiz.MinScore.ToString());
                    //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.QuizMaxMark)))
                    //    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.QuizMaxMark), quiz.EvaluationScale.ToString());
                    //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.QuizMark)))
                    //    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.QuizMark), (query.Any()) ? ((int)query.OrderByDescending(a=> a.CompletedOn).FirstOrDefault().RelativeScore).ToString() : "");

                    //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.QuizAttempts)))
                    //    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.QuizAttempts), query.Count().ToString());

                    //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.QuizQuestionsNumber)))
                    //{

                    //}
                    //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.QuizList)))
                    //{
                    //}
                    //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.QuizTable)))
                    //{
                    //}
                }
            }
            return(translation);
        }
Exemple #5
0
        public static String Translate(string content, lm.Comol.Modules.EduPath.BusinessLogic.Service service, Path path, Int32 idUser, SubActivity subActivity)
        {
            String translation = content;

            if (path != null)
            {
                Int32 IdCRole = service.CommunityRoleId(path.Community.Id, idUser);
                ILookup <StatusStatistic, ActivityStatistic> statdict = null;

                DateTime?startEpDate = path.StartDate;
                if (startEpDate.HasValue)
                {
                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathStartedOn), ReplaceChars(startEpDate.Value.ToShortDateString()));
                }
                else
                {
                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathStartedOn), "");
                }

                DateTime?endDate = service.GetEpEndDate(path, idUser);
                if (endDate.HasValue)
                {
                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathEndedOn), ReplaceChars(endDate.Value.ToShortDateString()));
                }
                else
                {
                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathEndedOn), "");
                }



                //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.PathName)))
                translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathName), ReplaceChars(path.Name));
                if (!String.IsNullOrEmpty(path.PathCode))
                {
                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathCode), ReplaceChars(path.PathCode));
                }
                else
                {
                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathCode), "");
                }
                translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathId), ReplaceChars(path.Id.ToString()));


                //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.UnitCount)))
                //    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.UnitCount), path.UnitList.Where(u=> u.Deleted== BaseStatusDeleted.None));
                if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.PathMinCompletion)))
                {
                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathMinCompletion), path.MinCompletion.ToString() + "%");
                }
                //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.PathMinMark)))
                //    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathMinMark), path.MinCompletion.ToString());
                Boolean timeBased = service.CheckEpType(path.EPType, EPType.Time);

                Int32 totalAct           = -1;
                Int32 notStarted         = -1;
                Int32 started            = -1;
                Int32 completed          = -1;
                Int32 completedAndPassed = -1;

                // ANCHE SE è AUTO devo verificare ??
                //Boolean timeBased = service.CheckEpType(path.EPType, EPType.Time) && service.CheckEpType(path.EPType, EPType.Auto);
                if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.PathDuration)) && timeBased)
                {
                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathDuration), (path.Weight > 0) ? service.ConvertTimeFromLong(path.Weight) : "//");
                }

                if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.UnitCount)))
                {
                    short count = service.GetActiveUnitsCount(path.UnitList, idUser, IdCRole, true, false);
                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.UnitCount), count.ToString());
                }
                if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.ActivitiesCount)))
                {
                    totalAct = service.GetActiveActivitiesCount(path.UnitList.SelectMany(x => x.ActivityList).ToList(), idUser, IdCRole, true, false);
                    //foreach (var item in path.UnitList)
                    //{
                    //    count += service.GetActiveActivitiesCount(item.ActivityList , idUser, IdCRole, true, false);
                    //}
                    //totalAct = count;
                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.ActivitiesCount), totalAct.ToString());
                }
                if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.StartedActivities)))
                {
                    //if (statdict == null)
                    //    statdict = service.ServiceStat.GetStatCount_ByUser(path.Id, idUser, DateTime.Now);


                    //started = statdict[StatusStatistic.BrowsedStarted].Count();

                    started = service.ServiceStat.GetStatCount_ByUserAndStatus(path.Id, idUser, DateTime.Now, StatusStatistic.Started);

                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.StartedActivities), started.ToString());
                }
                if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.CompletedActivities)))
                {
                    //if (statdict == null)
                    //    statdict = service.ServiceStat.GetStatCount_ByUser(path.Id, idUser, DateTime.Now);
                    //completed = statdict[StatusStatistic.Started | StatusStatistic.Browsed | StatusStatistic.Completed ].Count();
                    //completed = statdict[StatusStatistic.Started | StatusStatistic.Browsed | StatusStatistic.CompletedPassed].Count();

                    completedAndPassed = service.ServiceStat.GetStatCount_ByUserAndStatus(path.Id, idUser, DateTime.Now, StatusStatistic.Completed);

                    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.CompletedActivities), completedAndPassed.ToString());
                }
                //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.NotStartedActivities)))
                //{
                //    //if (statdict == null)
                //    //    statdict = service.ServiceStat.GetStatCount_ByUser(path.Id, idUser, DateTime.Now);
                //    //if (totalAct == -1)
                //    //{
                //    //    totalAct = service.GetActiveActivitiesCount(path.UnitList.SelectMany(x => x.ActivityList).ToList(), idUser, IdCRole, true, false);
                //    //}
                //    //Int32 x = statdict[StatusStatistic.].Count();

                //    notStarted = totalAct - (started);//service.ServiceStat.GetStatCount_ByUserAndStatus(path.Id, idUser, DateTime.Now, StatusStatistic.None ,true );
                //    notStarted = (notStarted < 0) ? 0 : notStarted;
                //    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.NotStartedActivities), notStarted.ToString());
                //}

                //if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.CompletedOn)))
                //{

                //(!subActivity.UsePathEndDateStatistics || !endDate.HasValue) || (subActivity.UsePathEndDateStatistics && endDate.HasValue && a.CompletedOn <= endDate.Value));

                PathStatistic pathStatistic = null;

                if (!subActivity.UsePathEndDateStatistics || !endDate.HasValue)
                {
                    pathStatistic = service.ServiceStat.GetPathStat(path.Id, idUser);
                }
                else if (subActivity.UsePathEndDateStatistics && endDate.HasValue)
                {
                    pathStatistic = service.ServiceStat.GetPathStat(path.Id, idUser, endDate.Value);
                }

                if (pathStatistic != null)
                {
                    //TODO:Check epAuto
                    if (service.ServiceStat.CheckStatusStatistic(pathStatistic.Status, StatusStatistic.Completed) ||
                        service.ServiceStat.CheckStatusStatistic(pathStatistic.Status,
                                                                 StatusStatistic.CompletedPassed))
                    {
                        translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.CompletedOn),
                                                          pathStatistic.CreatedOn.Value.ToShortDateString());
                    }
                    else
                    {
                        translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.CompletedOn), "");
                    }

                    DateTime?compilationStartedOn = pathStatistic.StartDate;

                    if (compilationStartedOn.HasValue)
                    {
                        translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathStartCompilationOn),
                                                          compilationStartedOn.Value.ToShortDateString());
                    }
                    else
                    {
                        translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathStartCompilationOn), "");
                    }
                }

                //else
                //{
                //    translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.CompletedOn), "###");
                //}
                //}
            }

            return(translation);
        }