/// <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); }
public static String Translate(string content, lm.Comol.Modules.CallForPapers.Business.ServiceCallOfPapers service, CallForPaper call, Int32 idUser, UserSubmission submission) { String translation = content; //if (path != null) //{ // Int32 IdCRole = service.CommunityRoleId(path.Community.Id,idUser); // ILookup<StatusStatistic, ActivityStatistic> statdict = null; // DateTime? endDate = service.GetEpEndDate(path, idUser); // if (content.Contains(GetPlaceHolder(EduPathPlaceHoldersType.PathName))) // translation = translation.Replace(GetPlaceHolder(EduPathPlaceHoldersType.PathName), ReplaceChars(path.Name)); // //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 = service.ServiceStat.GetStatCount_ByUserAndStatus(path.Id, idUser, DateTime.Now, StatusStatistic.Started ,true ); // 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); // //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), "###"); // //} // } //} return(translation); }