public async Task <ApiResult <IEnumerable <ServerInfoViewModel> > > List(int pageIndex, string Title, string ProjectID, int ProviderID, string System, string RegisterDate, string ExpireDate) { var res = new ApiResult <IEnumerable <ServerInfoViewModel> >() { statusCode = (int)ApiEnum.Status }; if (pageIndex == 0) { pageIndex = 1; } DateTime?RegisterDate1 = null; DateTime?ExpireDate1 = null; if (!string.IsNullOrWhiteSpace(RegisterDate)) { RegisterDate1 = C.DateTimes(RegisterDate); } if (!string.IsNullOrWhiteSpace(ExpireDate)) { ExpireDate1 = C.DateTimes(ExpireDate); } var parm = Expressionable.Create <ServerInfo>() .AndIF(!string.IsNullOrEmpty(Title), m => m.Title.Contains(Title)) .AndIF(!string.IsNullOrEmpty(ProjectID), m => m.ProjectID == ProjectID) .AndIF(ProviderID != 0, m => m.ProviderID == ProviderID) .AndIF(!string.IsNullOrEmpty(System), m => m.System.Contains(System)) .AndIF(RegisterDate1 != null, m => m.RegisterDate >= RegisterDate1) .AndIF(ExpireDate1 != null, m => m.ExpireDate <= ExpireDate1); var list = ServerInfodb.GetPages(parm.ToExpression(), new PageParm(pageIndex)); List <ServerInfoViewModel> list2 = new List <ServerInfoViewModel>(); if (list != null) { foreach (var item in list.DataSource) { ServerInfoViewModel n = IMapper.Map <ServerInfoViewModel>(item); n.ProjectName = Projectdb.Get("Projects", item.ProjectID).Names; n.ProviderName = providerdb.GetId(item.ProviderID).Title; list2.Add(n); } res.success = true; res.data = list2; res.index = pageIndex; res.count = list.TotalCount; res.size = list.PageSize; res.pages = list.TotalPages; } else { res.success = false; res.statusCode = (int)ApiEnum.Status; } return(await Task.Run(() => res)); }
public async Task <ApiResult <IEnumerable <CertificateViewModel> > > List(int pageIndex, string Title, int?ProviderID, string ProjectID, bool?IsEnable) { var res = new ApiResult <IEnumerable <CertificateViewModel> >() { statusCode = (int)ApiEnum.Status }; if (pageIndex == 0) { pageIndex = 1; } var parm = Expressionable.Create <Certificate>() .AndIF(ProviderID != null && ProviderID != 0, a => a.ProviderID == ProviderID) .AndIF(!string.IsNullOrEmpty(Title), m => m.Title.Contains(Title)) .AndIF(!string.IsNullOrEmpty(ProjectID), m => m.ProjectID == ProjectID) .AndIF(IsEnable != null, m => m.IsEnable == IsEnable); var list = Certificatedb.GetPages(parm.ToExpression(), new PageParm(pageIndex)); List <CertificateViewModel> list2 = new List <CertificateViewModel>(); if (list.DataSource != null && list.DataSource.Count > 0) { foreach (var item in list.DataSource) { CertificateViewModel n = IMapper.Map <CertificateViewModel>(item); ProjectInfo projectInfo = Projectdb.Get("Projects", item.ProjectID); if (projectInfo != null) { n.ProjectName = projectInfo.Names; } Provider provider = providerdb.GetId(item.ProviderID); if (provider != null) { n.ProviderName = provider.Title; } list2.Add(n); } res.success = true; res.data = list2; res.index = pageIndex; res.count = list.TotalCount; res.size = list.PageSize; res.pages = list.TotalPages; } else { res.success = false; res.statusCode = (int)ApiEnum.Status; } return(await Task.Run(() => res)); }
public async Task <ApiResult <APIProjectViewModel> > Item(string ID) { var res = new ApiResult <APIProjectViewModel>(); ProjectInfo m; APIProjectViewModel n = new APIProjectViewModel(); if (!string.IsNullOrEmpty(ID)) { m = Projectdb.Get("Projects", ID); if (m != null) { n.ID = C.String(m._id); n.Names = m.Names; n.URL = m.URL; n.Remarks = m.Remarks; n.State = m.State; n.ProjectTypeName = ProjectTypedb.Get("ProjectType", m.ProjectTypeID).Names; n.ProductionDate = Utility.GetDateFormat(m.ProductionDate); n.CompletionDate = Utility.GetDateFormat(m.CompletionDate); res.success = true; } } res.data = n; return(await Task.Run(() => res)); }
public async Task <ApiResult <IEnumerable <DomainNameViewModel> > > List(int pageIndex, string Title, bool?IsEnable) { var res = new ApiResult <IEnumerable <DomainNameViewModel> >() { statusCode = (int)ApiEnum.Status }; if (pageIndex == 0) { pageIndex = 1; } var parm = Expressionable.Create <DomainName>() .AndIF(!string.IsNullOrEmpty(Title), m => m.Title.Contains(Title)) .AndIF(IsEnable != null, m => m.IsEnable == IsEnable); var list = DomaNamedb.GetPages(parm.ToExpression(), new PageParm(pageIndex)); List <DomainNameViewModel> list2 = new List <DomainNameViewModel>(); if (list != null) { foreach (var item in list.DataSource) { list2.Add(new DomainNameViewModel { ID = item.ID, Title = item.Title, ProjectID = item.ProjectID, ProjectNames = Projectdb.Get("Projects", item.ProjectID).Names, Note = item.Note, RegisterDate = Utility.GetDateFormat(item.RegisterDate), ExpireDate = Utility.GetDateFormat(item.ExpireDate), IsEnable = item.IsEnable, }); } res.success = true; res.data = list2; res.index = pageIndex; res.count = list.TotalCount; res.size = list.PageSize; res.pages = list.TotalPages; } else { res.success = false; res.statusCode = (int)ApiEnum.Status; } return(await Task.Run(() => res)); }
public BaseResponse Authentication(AuthenticationRequest request) { BaseResponse baseResponse = new BaseResponse(); try { EntityListResponse <ProjectInfo> autResult = _projectInfoService.Get(t => t.ProjectCode == request.ProjectCode && t.Password == request.Password); if (autResult.Code != (int)ResponseCode.SUCCESS || autResult.EntityList.Count < 1) { baseResponse.SetStatus(ResponseCode.INVALID_PROJECT_CODE); return(baseResponse); } baseResponse.SetStatus(ResponseCode.SUCCESS); return(baseResponse); } catch (Exception ex) { baseResponse.SetStatus(ResponseCode.SYSTEM_ERROR); return(baseResponse); } }
public async Task <ApiResult <IEnumerable <ProjectNodeViewModel> > > GetList(int pageIndex, string?ProjectTypeID, string?ProjectID, bool?IsEnable, int?State, string?Title) { var res = new ApiResult <IEnumerable <ProjectNodeViewModel> >() { statusCode = (int)ApiEnum.Status }; int UserID = GetUserID(); if (UserID > 0) { if (pageIndex == 0) { pageIndex = 1; } var parm = Expressionable.Create <ProjectNodeInfo>(); PagedInfo <ProjectNodeInfo> list = null; UserInfo userInfo = userdb.GetId(UserID); if (userInfo != null) { var parm2 = Expressionable.Create <ProjectUserInfo>() .AndIF(userInfo.RoleID != 1, o => o.UserID == UserID) .And(o => o.IsEnable == true); List <ProjectUserInfo> projectUserInfo = projectUserdb.GetWhere(parm2.ToExpression()); int[] nodes; if (projectUserInfo != null && projectUserInfo.Count > 0) { if (userInfo.RoleID != 1) { nodes = new int[projectUserInfo.Count]; int i = 0; foreach (var item in projectUserInfo) { nodes[i] = item.ProjectNodeID; i++; } parm.AndIF(nodes.Length > 0, o => nodes.Contains(o.ID)); } parm.AndIF(!string.IsNullOrWhiteSpace(ProjectID), m => m.ProjectID == ProjectID); parm.AndIF(IsEnable != null, m => m.IsEnable == IsEnable); parm.AndIF(State != null, m => m.State == State); parm.AndIF(!string.IsNullOrWhiteSpace(Title), m => m.Title.Contains(Title)); parm.And(m => m.TypeID == 1); if (!string.IsNullOrWhiteSpace(ProjectTypeID)) { List <ProjectInfo> projects = Projectdb.GetList("Projects", Builders <ProjectInfo> .Filter.Where(o => o.ProjectTypeID == ProjectTypeID), null, null); string[] x = new string[projects.Count]; int a = 0; foreach (var item in projects) { x[a] = item.ID; a++; } parm.And(m => x.Contains(m.ProjectID)); } list = PNdb.GetPages(parm.ToExpression(), new PageParm(pageIndex), "ID DESC"); } List <ProjectNodeViewModel> list2 = new List <ProjectNodeViewModel>(); if (list != null) { foreach (var item in list.DataSource) { ProjectNodeViewModel projectNodeViewModel = IMapper.Map <ProjectNodeViewModel>(item); projectNodeViewModel.PlanCount = plandb.GetCount(o => o.ProjectNodeID == item.ID && o.ProjectID == item.ProjectID); ProjectInfo projectInfo = Projectdb.Get("Projects", item.ProjectID); List <UserInfo> userInfos = userdb.GetWhere(a => SqlFunc.Subqueryable <ProjectUserInfo>().Where(b => b.UserID == a.ID && b.ProjectNodeID == item.ID && b.Role == 1 && b.IsEnable == true).Any()); if (userInfos != null) { List <APITeamMembersViewModel> ats = new List <APITeamMembersViewModel>(); foreach (var item2 in userInfos) { ats.Add(new APITeamMembersViewModel() { ID = item2.ID, Name = userdb.GetNames(item2) }); } projectNodeViewModel.Teamleades = ats; } List <UserInfo> userInfos2 = userdb.GetWhere(a => SqlFunc.Subqueryable <ProjectUserInfo>().Where(b => b.UserID == a.ID && b.ProjectNodeID == item.ID && b.Role == 2 && b.IsEnable == true).Any()); if (userInfos2 != null) { List <APITeamMembersViewModel> ats = new List <APITeamMembersViewModel>(); foreach (var item2 in userInfos2) { ats.Add(new APITeamMembersViewModel() { ID = item2.ID, Name = userdb.GetNames(item2) }); } projectNodeViewModel.Teammembers = ats; } if (projectInfo != null) { projectNodeViewModel.ProjectName = projectInfo.Names; projectNodeViewModel.ProjectTypeID = projectInfo.ProjectTypeID; } list2.Add(projectNodeViewModel); } res.success = true; res.data = list2; res.index = pageIndex; res.count = list.TotalCount; res.size = list.PageSize; res.pages = list.TotalPages; } else { res.success = true; res.statusCode = (int)ApiEnum.Status; } } else { res.msg = "无该用户信息"; } } else { res.msg = "请重新登陆"; } return(await Task.Run(() => res)); }
public async Task <ApiResult <APIProNodesListWelViewModel> > WelcomeNodesList() { var res = new ApiResult <APIProNodesListWelViewModel>() { statusCode = (int)ApiEnum.Status }; int UserID = GetUserID(); if (UserID > 0) { var parm = Expressionable.Create <ProjectNodeInfo>(); parm.And(o => o.IsEnable == true); List <ProjectNodeInfo> list = null; UserInfo userInfo = db.GetId(UserID); List <ProjectUserInfo> projectUserInfo = projectUserdb.GetWhere(o => o.UserID == UserID && o.IsEnable == true); int[] nodes; if (projectUserInfo != null && projectUserInfo.Count > 0) { if (userInfo.RoleID != 1) { nodes = new int[projectUserInfo.Count]; int i = 0; foreach (var item in projectUserInfo) { nodes[i] = item.ProjectNodeID; i++; } parm.AndIF(nodes.Length > 0, o => nodes.Contains(o.ID)); } } list = PNdb.GetNopage(parm.ToExpression(), "ID DESC"); APIProNodesListWelViewModel aPIProNodesListWelViewModel = new APIProNodesListWelViewModel(); if (list != null && list.Count > 0) { IEnumerable <ProjectNodeInfo> list2 = list.Where(o => o.State == 1 || o.State == 2); List <APIProNodesWelViewModel> CompleteList = new List <APIProNodesWelViewModel>(); List <APIProNodesWelViewModel> UnfinishedList = new List <APIProNodesWelViewModel>(); List <APIProNodesWelViewModel> DelayList = new List <APIProNodesWelViewModel>(); foreach (var item in list2) { ProjectInfo projectInfo = Projectdb.Get("Projects", item.ProjectID); if (projectInfo != null) { //APIProNodesWelViewModel aPIProNodesWelViewModel = new APIProNodesWelViewModel(); //aPIProNodesWelViewModel.ProName = projectInfo.Names; //aPIProNodesWelViewModel.ProNodeTitle = item.Title; //aPIProNodesListWelViewModel.CompleteList.Add(aPIProNodesWelViewModel); CompleteList.Add(new APIProNodesWelViewModel { ProName = projectInfo.Names, ProNodeTitle = item.Title }); } } aPIProNodesListWelViewModel.CompleteList = CompleteList; IEnumerable <ProjectNodeInfo> list3 = list.Where(o => o.State == 0); foreach (var item in list3) { ProjectInfo projectInfo = Projectdb.Get("Projects", item.ProjectID); if (projectInfo != null) { UnfinishedList.Add(new APIProNodesWelViewModel { ProName = projectInfo.Names, ProNodeTitle = item.Title }); } } aPIProNodesListWelViewModel.UnfinishedList = UnfinishedList; IEnumerable <ProjectNodeInfo> list4 = list.Where(o => o.State == 3 || o.State == 4); foreach (var item in list4) { ProjectInfo projectInfo = Projectdb.Get("Projects", item.ProjectID); if (projectInfo != null) { DelayList.Add(new APIProNodesWelViewModel { ProName = projectInfo.Names, ProNodeTitle = item.Title }); } } aPIProNodesListWelViewModel.DelayList = DelayList; } res.data = aPIProNodesListWelViewModel; res.success = true; } else { res.msg = "请重新登陆"; } return(await Task.Run(() => res)); }