// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var PatientOptions = new DbContextOptionsBuilder <PatientContext>() .UseInMemoryDatabase("Patients").Options; var DrugOptions = new DbContextOptionsBuilder <DrugContext>() .UseInMemoryDatabase("Drugs").Options; var DosagesOptions = new DbContextOptionsBuilder <DosageContext>() .UseInMemoryDatabase("Dosage").Options; var PatientCont = new PatientContext(PatientOptions); var DrugCont = new DrugContext(DrugOptions); var DosageCont = new DosageContext(DosagesOptions); IRelationshipService Relationship = new RelationshipService(PatientCont, DrugCont, DosageCont); services.AddSingleton(Relationship); services.AddDbContext <PatientContext>(opt => opt.UseInMemoryDatabase("Patients")); services.AddDbContext <DrugContext>(opt => opt.UseInMemoryDatabase("Drugs")); services.AddDbContext <DosageContext>(opt => opt.UseInMemoryDatabase("Dosage")); services.AddControllers(); }
/// <summary> /// 获取指定用户关注的所有的用户的动态(包含指定用户的动态) /// 目前移动端只需要 说说、分享课程 /// </summary> /// <param name="userId"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public List <IntUserActivity> GetMobileUsersActivities(int userId, int pageIndex, int pageSize = 10) { var activityService = new RelationshipService(); var attends = activityService.GetAttentions(userId).ToList(); var sqlwhere = string.Format(@"Int_UserActivity.IsDelete=0 AND ( Int_UserActivity.UserId = {0} OR ( Int_UserActivity.UserId <> {0} AND Int_UserActivity.IsPrivate = 0 AND Int_UserActivity.UserId IN ({1}) ) ) And Int_UserActivity.ActionType in (1,2) ", userId, attends.GetString()); int total; var list = GetActivities(out total, pageIndex, pageSize, sqlwhere, " ActionTime DESC"); if (list.Any(p => p.ActionType == ActionType.CourseShared)) { var courseList = _dataAccess.FetchListBySql <SharedResourceDetail>(string.Format("select CourseId as ResourceId,CourseName as ResourceName,FrontImage as FrontImg,OutLine as ResourceDesc from Res_Course where CourseId in ({0})", list.Where(p => p.ActionType == ActionType.CourseShared).Select(p => p.ResourceId).GetString())); foreach (var item in list.Where(p => p.ActionType == ActionType.CourseShared)) { item.SharedResourceDetail = courseList.FirstOrDefault(p => p.ResourceId == item.ResourceId); } } return(list); }
public void RelationshipService_Should_Set_Parameters() { var mockedRepository = new Mock <IRelationshipRepository>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedDbContext = new MockedDbContext(); var service = new RelationshipService(mockedRepository.Object, mockedUnitOfWork.Object, mockedDbContext); Assert.IsInstanceOf <RelationshipService>(service); }
public void RelationshipService_Repo_Should_Call_SetContext() { var mockedRepository = new Mock <IRelationshipRepository>(); mockedRepository.Setup(r => r.setContext(It.IsAny <INotebookDbContext>())); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedDbContext = new MockedDbContext(); var service = new RelationshipService(mockedRepository.Object, mockedUnitOfWork.Object, mockedDbContext); mockedRepository.Verify(r => r.setContext(It.IsAny <INotebookDbContext>()), Times.Once); }
public void RelationshipService_Should_Call_RepoAdd_When_Call_ServiceAdd() { var mockedRepository = new Mock <IRelationshipRepository>(); mockedRepository.Setup(r => r.Add(It.IsAny <Relationship>())); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedDbContext = new MockedDbContext(); var service = new RelationshipService(mockedRepository.Object, mockedUnitOfWork.Object, mockedDbContext); service.Add(new Relationship()); mockedRepository.Verify(r => r.Add(It.IsAny <Relationship>()), Times.Once); }
/// <summary> /// 获取指定用户关注的所有的用户的动态(包含指定用户的动态) /// </summary> /// <param name="userId"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public List <IntUserActivity> GetUsersActivities(int userId, int pageIndex, int pageSize = 10) { var activityService = new RelationshipService(); var attends = activityService.GetAttentions(userId).ToList(); var sqlwhere = string.Format(@"Int_UserActivity.IsDelete=0 AND ( Int_UserActivity.UserId = {0} OR ( Int_UserActivity.UserId <> {0} AND Int_UserActivity.IsPrivate = 0 AND Int_UserActivity.UserId IN (" + attends.GetString() + ")) ) ", userId); int total; var list = GetActivities(out total, pageIndex, pageSize, sqlwhere, " ActionTime DESC"); //加载分享信息 //课程 var courseIds = list.Where(p => p.ActionType == ActionType.CourseShared).Select(p => p.ResourceId); var cs = _dataAccess.GetList <ResCourse>("CourseId IN (" + courseIds.GetString() + ")"); //知识 //var knowledgeIds = list.Where(p => p.ActionType == ActionType.KnowledgeShared).Select(p => p.ResourceId); //var ks = _dataAccess.GetList<KL_Resource>("ResourceId IN (" + knowledgeIds.GetString() + ")"); //学习计划 var planIds = list.Where(p => p.ActionType == ActionType.StudyPlanShared).Select(p => p.ResourceId); var ps = _dataAccess.GetList <LenLearnPlan>("PlanId IN (" + planIds.GetString() + ")"); //外部资源 var urlIds = list.Where(p => p.ActionType == ActionType.UrlShared).Select(p => p.ResourceId); var us = _dataAccess.GetList <IntShared>("ShareId IN (" + urlIds.GetString() + ")"); foreach (var userActivity in list) { switch (userActivity.ActionType) { case ActionType.CourseShared: userActivity.CourseShared = cs.FirstOrDefault(p => p.CourseId == userActivity.ResourceId); continue; //case ActionType.KnowledgeShared: // userActivity.KnowledgeShared = ks.FirstOrDefault(p => p.ResourceId == userActivity.ResourceId); // continue; case ActionType.StudyPlanShared: userActivity.StudyPlanShared = ps.FirstOrDefault(p => p.PlanId == userActivity.ResourceId); continue; case ActionType.UrlShared: userActivity.UrlShared = us.FirstOrDefault(p => p.ShareId == userActivity.ResourceId); continue; } } return(list); }
public void RelationshipService_Should_Call_RepoFind1Teacher_When_Call_ServiceFind1Teacher() { var mockedRepository = new Mock <IRelationshipRepository>(); mockedRepository.Setup(r => r.FindByTeacher(It.IsAny <string>())); var mockedUnitOfWork = new Mock <IUnitOfWork>(); mockedUnitOfWork.Setup(u => u.Commit()); var mockedDbContext = new MockedDbContext(); var service = new RelationshipService(mockedRepository.Object, mockedUnitOfWork.Object, mockedDbContext); service.FindByTeacher("Test"); mockedRepository.Verify(r => r.FindByTeacher(It.IsAny <string>()), Times.Once); }
public void RelationshipService_Should_Call_UOWCommit_When_Call_ServiceDelete() { var mockedRepository = new Mock <IRelationshipRepository>(); mockedRepository.Setup(r => r.Delete(It.IsAny <Relationship>())); var mockedUnitOfWork = new Mock <IUnitOfWork>(); mockedUnitOfWork.Setup(u => u.Commit()); var mockedDbContext = new MockedDbContext(); var service = new RelationshipService(mockedRepository.Object, mockedUnitOfWork.Object, mockedDbContext); service.Delete(new Relationship()); mockedUnitOfWork.Verify(u => u.Commit(), Times.Once); }
public static void Main(string[] args) { SourceService sourceService = new SourceService(); sourceService.Url = "http://*****:*****@WebFault."); } catch (SoapException e) { //fall through } relationshipService.Touch(); AssertionService assertionService = new AssertionService(); assertionService.Url = "http://localhost:8080/full/soap-services/AssertionServiceService"; Assertion[] assertions = assertionService.ReadAssertions(); Assertion gender = assertions[0]; Assert.AreEqual("gender", gender.Id); Assert.IsTrue(gender is Gender); Assertion name = assertions[1]; Assert.AreEqual("name", name.Id); Assert.IsTrue(name is Name); }
public WallController(IHttpContextAccessor httpContextAccessor, AccountService accountService, DialogService dialogService, FileService fileService, ProfileService profileService, RelationshipService relationshipService, WallService wallService) : base(httpContextAccessor, accountService, dialogService, fileService, profileService, relationshipService, wallService) { }
public UserList(ProfileService profileService, RelationshipService relationshipService) { this.profileService = profileService; this.relationshipService = relationshipService; }
public RelationshipsController(RelationshipService relationshipService, ILogger <RelationshipsController> logger) { _relationshipService = relationshipService; _logger = logger; }
public static void Main(string[] args) { SourceService sourceService = new SourceService("http://*****:*****@WebFault."); } catch (SoapException e) { //fall through } relationshipService.Touch(); AssertionService assertionService = new AssertionService("http://localhost:8080/full/AssertionServiceService"); Assertion[] assertions = assertionService.ReadAssertions(); Assertion gender = assertions[0]; Assert.AreEqual("gender",gender.Id); Assert.IsTrue(gender is Gender); Assertion name = assertions[1]; Assert.AreEqual("name",name.Id); Assert.IsTrue(name is Name); }
/// <summary> /// 首页 /// </summary> /// <returns></returns> //[OutputCache(CacheProfile = "homeProfile", VaryByCustom = "1")] public ActionResult Index() { Response.Cache.SetOmitVaryStar(true); if (CurrentUser.IndexPage != "Index") { return(RedirectToAction(CurrentUser.IndexPage)); } UserLevel level = _userLevelService.GetUserLevel(CurrentUser.TenantId, CurrentUser.UserId); ViewBag.currentLevel = level; IEnumerable <int> myAttds = new RelationshipService().GetAttentions(CurrentUser.UserId); _cacheService.Add("userAttends:" + CurrentUser.UserId, myAttds, CachingExpirationType.UsualObjectCollection); var attends = _cacheService.Get <IEnumerable <int> >("userAttends:" + CurrentUser.UserId); if (attends == null) { attends = new RelationshipService().GetAttentions(CurrentUser.UserId); _cacheService.Add("userAttends:" + CurrentUser.UserId, myAttds, CachingExpirationType.UsualObjectCollection); } ////专题问题 //IEnumerable<IntQuestion> questions = _qaService.GetThematicQuestons(CurrentTenant.TenantId, 7); //ViewBag.questions = questions; ////系统人数 //ViewBag.userCount = SystemUsers.Count(p => p.Status == 0 && (!p.Freezed)); ////课程数 //string coursekey = "courseCount"; //object coursecount = CacheHelper.CacheService.Get(coursekey); //if (coursecount == null) //{ // coursecount = _courseManager.GetCourseCount(CurrentTenant.TenantId); // CacheHelper.CacheService.Set(coursekey, coursecount, CachingExpirationType.Stable); //} //ViewBag.courseCount = coursecount; ////考试数 //string examcountKey = "examcountKey"; //object examcount = CacheService.Get(examcountKey); //if (examcount == null) //{ // //examcount = _examinationManager.GetAllExaminationByTenantId(CurrentTenant.TenantId).Count; // examcount = _examinationManager.GetExaminationCount(); // CacheService.Set(examcountKey, examcount, CachingExpirationType.Stable); //} //ViewBag.allexamCount = examcount; var totalCount = 0; var list = _trainLearningManager.GetCanSingUpClassLists(out totalCount, CurrentUser.UserId, " 1=1 "); list = list.Where(p => p.SignUpStatusStr == 0).ToList(); list = list.Take(6).ToList(); ViewBag.TrainClass = list; return(View()); }
public VcksController(IHttpContextAccessor httpContextAccessor, AccountService accountService, DialogService dialogService, FileService fileService, ProfileService profileService, RelationshipService relationshipService, WallService wallService) { this.httpContextAccessor = httpContextAccessor; this.accountService = accountService; this.dialogService = dialogService; this.fileService = fileService; this.profileService = profileService; this.relationshipService = relationshipService; this.wallService = wallService; }
private void syncOperationBySttings() { if (selProjects.Count == 0) { MessageBox.Show("Выберите проекты"); return; } if (wbsIsSync.Checked) { using (WBSService wbsService = new WBSService()) { using (PpDsTableAdapters.projwbsTableAdapter wbsTab = new PpDsTableAdapters.projwbsTableAdapter()) { wbsService.Url = String.Format("{0}/p6ws/services/WBSService", Properties.Settings.Default.EppmWsUrl); wbsService.CookieContainer = eppm.sessionCookie; ReadAllWBS readAllWBS = new ReadAllWBS(); readAllWBS.Field = new WBSFieldType[5] { WBSFieldType.ObjectId, WBSFieldType.ParentObjectId, WBSFieldType.ProjectObjectId, WBSFieldType.Name, WBSFieldType.GUID }; WBS[] wbses = null; foreach (int wbsId in selProjects) { readAllWBS.ObjectId = wbsId; wbses = wbsService.ReadAllWBS(readAllWBS); foreach (WBS w in wbses) { if (wbsTab.CheckByGUID(w.GUID) == 0) { wbsTab.Insert(w.ObjectId, w.ParentObjectId, w.ProjectObjectId, w.Name, w.GUID); } } } } } } if (taskIsSync.Checked) { using (ActivityService taskService = new ActivityService()) { taskService.Url = String.Format("{0}/p6ws/services/ActivityService", Properties.Settings.Default.EppmWsUrl); taskService.CookieContainer = eppm.sessionCookie; ReadAllActivitiesByWBS readTasks = new ReadAllActivitiesByWBS(); //readTasks.Filter = String.Format("Type IN ('{0}','{1}')", "Start Milestone", "Finish Milestone"); readTasks.Field = new ActivityFieldType[7] { ActivityFieldType.WBSObjectId, ActivityFieldType.Id, ActivityFieldType.Type, ActivityFieldType.StartDate, ActivityFieldType.FinishDate, ActivityFieldType.WBSName, ActivityFieldType.Name }; Activity[] tasks = null; foreach (int wbsId in selProjects) { readTasks.WBSObjectId = wbsId; tasks = taskService.ReadAllActivitiesByWBS(readTasks); Debug.Write(tasks.Length); if (tasks.Length > 0) { foreach (Activity t in tasks) { string tType = (t.Type == ActivityType.FinishMilestone) ? "E" : "S"; DateTime aDate = (t.Type == ActivityType.FinishMilestone) ? t.FinishDate : t.StartDate; //ptmDs.pcm_milstones.Addpcm_milstonesRow(t.ProjectObjectId, t.Id, tType, String.Format("{0} :: {1}", t.WBSName, t.Name), aDate, aDate, 0); } } } } using (RelationshipService relService = new RelationshipService()) { } } }