private string UploadNewArticle() { int newAddedReportId = -1; JavaScriptSerializer jss = new JavaScriptSerializer(); var paramDes = jss.Deserialize <AppReport>(Request.Params["articleData"]); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { ReportRepository repository = new ReportRepository(context); UserRepository uRepository = new UserRepository(context); TeamRepository tRepository = new TeamRepository(context); CategoryRepository cRepository = new CategoryRepository(context); TeamTagRepository tagRepository = new TeamTagRepository(context); TileRepository tileRepository = new TileRepository(context); EditReportService service = new EditReportService(repository, uRepository, tRepository, cRepository, tagRepository, tileRepository); newAddedReportId = service.AddReport(paramDes); } return("{\"id\":\"" + newAddedReportId + "\"}"); }
private string GetAdminReportFromCurrentTeamSite() { string tileID = Request["TileID"]; string teamGuid = Request["SiteGUID"]; string userName = Session["UserName"] == null ? "" : Session["UserName"].ToString(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { ReportRepository repository = new ReportRepository(context); UserRepository uRepository = new UserRepository(context); TeamRepository tRepository = new TeamRepository(context); CategoryRepository cRepository = new CategoryRepository(context); TeamTagRepository tagRepository = new TeamTagRepository(context); TileRepository tileRepository = new TileRepository(context); EditReportService service = new EditReportService(repository, uRepository, tRepository, cRepository, tagRepository, tileRepository); var reports = service.GetAllReportsOfTeamSite(userName, teamGuid, true, global::Application.MainBoundedContect.Enums.SortField.ReportTitle, global::Application.MainBoundedContect.Enums.SortOrder.ASC); JavaScriptSerializer jss = new JavaScriptSerializer(); return(jss.Serialize(reports)); } }
private string GetAdminTileFilterInfo(string userName, string teamGuid, bool isAdmin) { JavaScriptSerializer jss = new JavaScriptSerializer(); // TileManager tm = new TileManager(); TileFilterListViewModel filterViewModel = new TileFilterListViewModel(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { ICategoryRepository _categoryRepository = new CategoryRepository(context); ITagRepository _tagRepository = new TeamTagRepository(context); ITileRepository _tileRepository = new TileRepository(context); ITeamRepository _teamRepository = new TeamRepository(context); IReportRepository _reportRepository = new ReportRepository(context); IUserRepository _userRepository = new UserRepository(context); TileServices tileService = new TileServices(_tileRepository, _teamRepository, _reportRepository, _userRepository, _tagRepository, _categoryRepository, null); //Owner IEnumerable <UserLoginApp> userList = tileService.GetOwnerList(userName, teamGuid, isAdmin); filterViewModel.Owner = userList.OrderBy(_ => _.UserName).Distinct <UserLoginApp>(new UserComparer()); //Category IEnumerable <AppCategory> categoryList = tileService.GetCategoryList(); filterViewModel.SubCategory = categoryList.OrderBy(_ => _.CategoryName).Distinct <AppCategory>(new CategoryComparer()); //Tag IEnumerable <AppTeamTag> tagList = tileService.GetTagListByTeam(teamGuid).Distinct <AppTeamTag>(new TagComparer()); filterViewModel.Tag = tagList; } return(jss.Serialize(filterViewModel)); }
private string GetArticlesByTagId() { int tagId = int.Parse(Request.QueryString["tagid"]); string teamId = Request.QueryString["teamid"]; JavaScriptSerializer jss = new JavaScriptSerializer(); string userAlias = Session["UserName"] == null?"Test":Session["UserName"].ToString(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { ReportRepository repository = new ReportRepository(context); UserRepository uRepository = new UserRepository(context); TeamRepository tRepository = new TeamRepository(context); CategoryRepository cRepository = new CategoryRepository(context); TeamTagRepository tagRepository = new TeamTagRepository(context); TileRepository tileRepository = new TileRepository(context); EditReportService service = new EditReportService(repository, uRepository, tRepository, cRepository, tagRepository, tileRepository); var services = service.GetReportsOfTeamSiteByTagId(userAlias, teamId, true, tagId, global::Application.MainBoundedContect.Enums.SortField.ReportTitle, global::Application.MainBoundedContect.Enums.SortOrder.ASC); var otherReports = services.Select(report1 => new ReportItem() { ID = report1.Id.Value, TagName = report1.Tags.FirstOrDefault(_ => _.Id.Value == tagId).Title, ReportDescription = report1.Description, ReportName = report1.Title, ReprotStatus = report1.Status.Name, ReportFeaturePics = report1.Images, ReportOwners = report1.Owners.Select(_ => new UserLoginApp { Sex = _.Sex, Id = _.Id, UserEmail = _.UserEmail, UserName = _.UserName, UserPhoto = _.UserPhoto }).ToList <UserLoginApp>() }); return(jss.Serialize(otherReports)); } }
private string GetArticlesByID() { JavaScriptSerializer jss = new JavaScriptSerializer(); var paramDes = jss.Deserialize <QueryParameterReport>(Request.Params["queryParam"]); int id = paramDes.articleid; string teamGuid = paramDes.teamguid; string userAlias = Session["UserName"] == null ? "Test" : Session["UserName"].ToString(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { ReportRepository repository = new ReportRepository(context); UserRepository uRepository = new UserRepository(context); TeamRepository tRepository = new TeamRepository(context); CategoryRepository cRepository = new CategoryRepository(context); TeamTagRepository tagRepository = new TeamTagRepository(context); TileRepository tileRepository = new TileRepository(context); EditReportService service = new EditReportService(repository, uRepository, tRepository, cRepository, tagRepository, tileRepository); // This report var report = service.GetReportById(id); var category = report.Categories.Select(_ => _.Id.GetValueOrDefault()).ToList <int>(); // Other reports var otherReportsTemp = service. GetReportsOfTeamSiteByCategory(userAlias, teamGuid, true, category, global::Application.MainBoundedContect.Enums.SortField.ReportTitle, global::Application.MainBoundedContect.Enums.SortOrder.ASC).Where(_ => _.Id.Value != id).ToList <AppReport>(); // Assemble the reports information var thisReport = new ReportItem() { ReportTags = report.Tags, ID = report.Id.Value, ReportFeaturePics = report.Images, ReportDescription = report.Description, ReprotContent = report.Content, ReportName = report.Title, ReprotStatus = report.Status.Name, ReportOwners = report.Owners.Select(_ => new UserLoginApp { Id = _.Id, UserEmail = _.UserEmail, UserName = _.UserName }).ToList <UserLoginApp>() }; var otherReports = otherReportsTemp.Select(report1 => new ReportItem() { ID = report1.Id.Value, ReportDescription = report1.Description, ReportName = report1.Title, ReprotStatus = report1.Status.Name, ReportOwners = report1.Owners.Select(_ => new UserLoginApp { Id = _.Id, UserEmail = _.UserEmail, UserName = _.UserName }).ToList <UserLoginApp>() }); QueryParameterReportSearch reports = new QueryParameterReportSearch() { ThisReport = thisReport, OtherReports = otherReports == null ? null : otherReports.ToList <ReportItem>() }; // Return the search result return(jss.Serialize(reports)); } }
protected void Page_Load(object sender, EventArgs e) { JavaScriptSerializer jss = new JavaScriptSerializer(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { TeamTagRepository tagRepository = new TeamTagRepository(context); TeamRepository teamRepository = new TeamRepository(context); TeamStatusRepository statusRepository = new TeamStatusRepository(context); ITileRepository tileRepository = new TileRepository(context); IReportRepository reportRepository = new ReportRepository(); TeamAdminService tService = new TeamAdminService(tagRepository, teamRepository, statusRepository, tileRepository, reportRepository); var teamGuid = Request.Params["SiteGUID"].ToString(); Guid guid = Guid.Parse(teamGuid); int teamId = teamRepository.GetFiltered(_ => _.TeamGuid == guid).FirstOrDefault().Id; var UserName = Session["UserName"]; if (Request["queryType"] == "getreportstatus") { // If current user is an admin. var team = teamRepository.GetAll().FirstOrDefault(_ => _.Id == teamId); if (UserName == null) { Response.Redirect("../MyAccounts/NoLoginPage.aspx"); } else { List <AppStatus> status = new List <AppStatus>(); bool isAdmin = team.TeamOwners.FirstOrDefault(_ => _.UserName == UserName.ToString().Trim()) != null; if (isAdmin) { status = tService.GetStatusByRole(1).ToList <AppStatus>(); } else { status = tService.GetStatusByRole(0).ToList <AppStatus>(); } string r = jss.Serialize(status); Response.Write(r); } } if (Request["queryType"] == "getsitetags") { var tags = tService.GetTagsByTeamId(Guid.Parse(teamGuid)); Response.Write(jss.Serialize(tags)); } if (Request["queryType"] == "updatetags") { List <AppTeamTag> tags = new List <AppTeamTag>(); tags = jss.Deserialize <List <AppTeamTag> >(Request.Params["TagData"]); List <AppTeamTag> tagsUpdate = new List <AppTeamTag>(); var originalTags = tService.GetTagsByTeamId(Guid.Parse(teamGuid)); foreach (var item in originalTags) { if (!tags.Any(_ => _.Id == item.Id)) { AppTeamTag appTag = tService.GetTagById(item.Id.Value); appTag.Status = tagStatus.Delete; tagsUpdate.Add(appTag); } } foreach (var para in tags) { if (para.Id < 0) { AppTeamTag appTag = new AppTeamTag(); appTag.Title = para.Title; appTag.TeamGuid = teamGuid; appTag.Status = tagStatus.Add; appTag.TeamId = teamId; tagsUpdate.Add(appTag); } else { AppTeamTag appTag = tService.GetTagById(para.Id.Value); if (appTag == null) { continue; } appTag.Status = tagStatus.Modify; appTag.TeamGuid = teamGuid; appTag.Title = para.Title; appTag.TeamId = teamId; tagsUpdate.Add(appTag); } } tService.ModifyTags(tagsUpdate); var tags_after = tService.GetTagsByTeamId(Guid.Parse(teamGuid)); Response.Write(jss.Serialize(tags_after)); } } }
private string GetFilter() { string sitetype = Request["sitetype"]; string siteGUID = Request["SiteGuid"]; string searchWords = Request["SearchWords"]; int tileId = int.Parse(Request["tileId"]); //if (tileId == 0) //{ // TileManager tm = new TileManager(); // if (sitetype.ToLower() == "selfservice") // { // tileId = SystemDefinedTile.SelfService_AllBIModels.SystemDefinedTileId; // } // else // { // tileId = SystemDefinedTile.MyReports_AllReports.SystemDefinedTileId; // } //} string logonUser = Session["UserName"] == null ? "" : Session["UserName"].ToString(); bool isCurrentSiteAdmin = logonUser == "" ? false : service.GetUserAdminTeams(logonUser).Count() > 0; using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { IReportRepository report_repository = new ReportRepository(context); IUserRepository user_repository = new UserRepository(context); ITeamRepository team_repository = new TeamRepository(context); ICategoryRepository category_repository = new CategoryRepository(context); ITagRepository tag_repository = new TeamTagRepository(context); ITileRepository tile_repository = new TileRepository(context); ITileQueryLogicRepository tile_query_repository = new TileQueryLogicRepository(context); EditReportService sa = new EditReportService(report_repository, user_repository, team_repository, category_repository, tag_repository, tile_repository, tile_query_repository); FilterListViewModel filterList = new FilterListViewModel(); #region query filter data int DataCount = 0; ICollection <Statistics> ls = null; switch (sitetype.ToLower()) { case "teamsite": ls = sa.GetTeamSiteReportsStatistics(tileId, logonUser, siteGUID, isCurrentSiteAdmin); break; case "reportcatalog": break; //case "myreport": // ls = sa.GetMyReportsStatistics(tileId, logonUser, teamSiteGuidUnderControl); // break; //case "selfservice": // ls = sa.GetSelfServiceStatistics(tileId, logonUser, teamSiteGuidUnderControl); // break; //case "searchreport": // ls = sa.GetSearchReportsStatistics(logonUser, teamSiteGuidUnderControl, searchWords, out DataCount); // break; default: break; } #endregion filterList.DataCount = DataCount; #region Get Statistics business moel foreach (Statistics l in ls) { FilterEntityViewModel filterEty = new FilterEntityViewModel(); filterEty.FilterType = l.Name; foreach (AttributeValue attr in l.Values) { Application.MainBoundedContect.ViewModel.Filters.FilterItem item = new Application.MainBoundedContect.ViewModel.Filters.FilterItem(); item.Name = attr.Name; if (l.Name == "Owner") { item.Value = attr.GUID.ToString(); } else { item.Value = attr.Value.ToString(); } item.Count = attr.Count; item.ParentValue = attr.ParentValue; filterEty.FilterItemList.Add(item); } if (!filterEty.FilterType.Equals("Category")) { filterEty.FilterItemList.OrderByDescending(c => c.Count).ThenBy(n => n.Value); } filterList.FilterList.Add(filterEty); } JavaScriptSerializer jss = new JavaScriptSerializer(); #endregion return(jss.Serialize(filterList)); } }