public ReportRepository(MainDBUnitWorkContext context) : base(context) { _context = context; }
public UserInformationRepository(MainDBUnitWorkContext _unitOfWork) : base(_unitOfWork) { context = _unitOfWork; }
public UserService(MainDBUnitWorkContext context) { context_tem = context; }
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 CallSP() { int jobId = 0; string querySql = string.Empty; string jobIdStr = Request.QueryString["jobId"].Trim(); if (string.IsNullOrEmpty(jobIdStr)) { return("Querystring:jobId is empty!"); } try { jobId = int.Parse(jobIdStr); } catch (FormatException ex) { return("Querystring:jobId shall be an integer value!"); } querySql = @"usp_AddJobRunToQueue"; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter() { ParameterName = "@JobId", DbType = System.Data.DbType.Int32, Value = jobId, Direction = System.Data.ParameterDirection.Input }, new SqlParameter() { ParameterName = "@RetryCounter", DbType = System.Data.DbType.Int32, Value = DBNull.Value, Direction = System.Data.ParameterDirection.Input }, new SqlParameter() { ParameterName = "@OverrideQueueDateTime", DbType = System.Data.DbType.DateTime2, Value = DBNull.Value, Direction = System.Data.ParameterDirection.Input }, new SqlParameter() { ParameterName = "@JobRunId", DbType = System.Data.DbType.Int32, Direction = System.Data.ParameterDirection.Output }, }; using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { string[] str = new string[] { "@JobRunId" }; var outPutValue = context.ExecuteCommand(querySql, str, parameters); if (int.Parse(outPutValue["@JobRunId"].ToString()) > 0) { return("{\"AddJobResult\":1}"); } else { return("{\"AddJobResult\":0}"); } } }
public UserService(UserInformationRepository _re) { context_tem = _re.context; _userDepo = _re; }
public TileQueryLogicRepository(MainDBUnitWorkContext _unitOfWork) : base(_unitOfWork) { }
public UsefulLinksRepository(MainDBUnitWorkContext context) : base(context) { }
protected void Page_Load(object sender, EventArgs e) { using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { up = new UserRepository(context); service = new UserService(up); SegmentRepository segRe = new SegmentRepository(context); DivisionRepository dvRe = new DivisionRepository(context); TeamRepository tRe = new TeamRepository(context); AppDivisionSegmentsService appService = new AppDivisionSegmentsService(tRe, segRe, dvRe); if (Request["requestType"] == "getdivisions") { var divisions = appService.GetAllDivisions().ToList <AppDivision>(); Response.Write(jss.Serialize(divisions)); } if (Request["requestType"] == "getdivisionbyid") { int divisionId = int.Parse(Request["divisionid"]); var division = appService.GetAllDivisions().FirstOrDefault(_ => _.Id == divisionId); Response.Write(jss.Serialize(division)); } if (Request["requestType"] == "getsegmentandteams") { int divisionId = Int16.Parse(Request["divisionid"]); var segments = appService.GetSegmentAndTeamsInDivsion(divisionId); List <SegmentTeamModel> segmentTeamSites = new List <SegmentTeamModel>(); List <SegmentTeamModel> subSegmentTeamSites = new List <SegmentTeamModel>(); foreach (var segment in segments) { var teamSites = new List <TeamSiteModel>(); foreach (var t in segment.Teamsites) { teamSites.Add(new TeamSiteModel() { TeamId = t.Id, TeamGuid = t.TeamGuid.ToString(), TeamName = t.TeamName, TeamLogo = t.TeamLogo }); } foreach (var t in segment.ChildSegements) { var teamSites2 = new List <TeamSiteModel>(); foreach (var t2 in t.Teamsites) { teamSites2.Add(new TeamSiteModel() { TeamId = t2.Id, TeamGuid = t2.TeamGuid.ToString(), TeamName = t2.TeamName, TeamLogo = t2.TeamLogo }); } subSegmentTeamSites.Add(new SegmentTeamModel() { SegmentName = t.Name, SegmentId = t.Id, TeamSites = teamSites2 }); } segmentTeamSites.Add(new SegmentTeamModel() { SegmentId = segment.Id, SegmentName = segment.Name, TeamSites = teamSites, ChildSegments = subSegmentTeamSites }); } string test = jss.Serialize(segmentTeamSites); Response.Write(jss.Serialize(segmentTeamSites)); } if (Request["requestType"] == "searchteams") { string teamname = Request["teamname"].ToString(); var tem = jss.Serialize(appService.GetTeamsWithTitle(teamname)); Response.Write(tem); } if (Request.Params["queryType"] == "getadmintilereport") { // get all the report Response.Write(GetAdminReportFromCurrentTeamSite()); } if (Request.Params["queryType"] == "gettilefilterlist") { string userName = Session["UserName"].ToString(); string teamGuid = Request["SiteGUID"]; bool isAdmin = Request["IsAdmin"] == "1" ? true : false; Response.Write(GetAdminTileFilterInfo(userName, teamGuid, isAdmin)); } if (Request.Params["queryType"] == "GetTempTileReportCount") { string userName = Session["UserName"] == null ? "" : Session["UserName"].ToString(); string teamGuid = Request["SiteGUID"]; Response.Write(GetTempTileReportCount(teamGuid, userName)); } if (Request["queryType"] == "reportsList") { Response.Write(GetReports()); } if (Request["queryType"] == "reportDetail") { Response.Write(GetReportDetal()); } else if (Request["queryType"] == "reportfilter") { Response.Write(GetFilter()); } } }
public CategoryRepository(MainDBUnitWorkContext context) : base(context) { }
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)); } }
private string GetReports() { string userName = Session["UserName"] == null ? "" : Session["UserName"].ToString(); string output; string siteType = Request["siteType"]; string teamGuid = Request["SiteGuid"]; JavaScriptSerializer jss = new JavaScriptSerializer(); var paramDes = jss.Deserialize <WebApplication1.Models.QueryParameterViewModel>(Request["queryParam"]); int tileId = int.Parse(paramDes.TileId); // Get the reports from the reports list using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { ReportRepository rep = new ReportRepository(context); TileRepository tileRep = new TileRepository(context); TileQueryLogicRepository tileQuery = new TileQueryLogicRepository(context); TileServices tService = new TileServices(tileRep, null, null, null, null, null, tileQuery); var tile = tService.GetTileById(tileId); EditReportService editReport = new EditReportService(rep, null, null, null, null, tileRep, tileQuery); #region Get ReportFilter ReportFilter filer = new ReportFilter(); foreach (WebApplication1.Models.FilterModel vm in paramDes.FilterEntityList) { switch (vm.FilterType) { case "Tag": filer.TagsIdCollection = (from fl in vm.FilterItemList select int.Parse(fl.Value)).ToList(); break; case "Owner": filer.OwnerIdCollection = (from fl in vm.FilterItemList select fl.Value).ToList(); break; case "Sub Category": filer.SubCategoryIdCollection = (from fl in vm.FilterItemList select int.Parse(fl.Value)).ToList(); break; default: break; } } #endregion // TO-DO: Team admin is set to true var reports = editReport.GetReportsByTeamWithReportsRequire(teamGuid, tileId, filer, true, userName, paramDes.CurrentPage, paramDes.PageSize, SortField.ReportTitle, (paramDes.SortAscending ? SortOrder.ASC : SortOrder.DESC)).ToArray(); ReportListModel rptList = GetReportList(reports, Convert.ToInt32(paramDes.TileId)); output = jss.Serialize(rptList); return(output); } }
public DivisionRepository(MainDBUnitWorkContext context) : base(context) { }
public SegmentRepository(MainDBUnitWorkContext context) : base(context) { }
public TeamRepository(MainDBUnitWorkContext _unitOfWork) : base(_unitOfWork) { }
private void SetAppTitleLogic(string logicString, AppTile appTile) { using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { TileRepository repository = new TileRepository(context); ReportRepository _reportRepository = new ReportRepository(context); if (!string.IsNullOrEmpty(logicString)) { EditReportService reportService = new EditReportService(null, null, null, null, null, null); switch (appTile.logicType) { case LogicType.Static: appTile.BasicLogic = null; break; case LogicType.Selected: List <int> cataIDList = logicString.Split(',').Select(_ => Convert.ToInt32(_)).ToList(); appTile.BasicLogic = (new ReportDataId()).In(cataIDList); break; case LogicType.Filtered: ReportFilter filer = new ReportFilter(); JavaScriptSerializer jss = new JavaScriptSerializer(); #region Deserialize TileFilterListViewModel vm = new TileFilterListViewModel(); if (!String.IsNullOrEmpty(logicString)) { vm = jss.Deserialize <TileFilterListViewModel>(logicString); } #endregion #region Get ReportFilter filer.OwnerIdCollection = (from o in vm.Owner select o.Id).ToList(); //filer.CatalogTypeIdCollection = (from c in vm.CatelogType select c.Id).ToList(); filer.TagsIdCollection = (from t in vm.Tag select t.Id.Value).ToList(); filer.SubCategoryIdCollection = (from c in vm.SubCategory select c.Id.Value).ToList(); #endregion appTile.BasicLogic = reportService.GenerateLogicByFilter(filer); break; case LogicType.Tagged: List <int> tagIds = logicString.Split(',').Select(i => int.Parse(i.Trim())).ToList(); appTile.BasicLogic = (new TagId()).In(tagIds); break; case LogicType.AllReports: appTile.BasicLogic = null; break; } } else { appTile.BasicLogic = null; } } }
protected void Page_Load(object sender, EventArgs e) { if (Request["requestType"].Contains("getimage")) { string str = ""; IVerificationCodeRepository repository = new VerficationCodeRepository(); VerificationCodeService service = new VerificationCodeService(repository); ImageConverter converter = new ImageConverter(); var returnSrc = (byte[])converter.ConvertTo(service.Response(ref str), typeof(byte[])); Session["verificationcode-reg"] = str; Response.ContentType = "image/gif"; Response.BinaryWrite(returnSrc); } if (Request["requestType"] == "validateUser") { using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { UserService _service = new UserService(context); JavaScriptSerializer jss = new JavaScriptSerializer(); var paramDes = jss.Deserialize <IEnumerable <UserLoginApp> >(Request["queryParam"]); User result = _service.Login(paramDes.First().UserName, paramDes.First().Password); if (result == null) { Response.Write(jss.Serialize("")); } else { Session["IsAuthorized"] = true; Session["UserName"] = paramDes.First().UserName; Session["UserId"] = paramDes.First().Id; Response.Write(jss.Serialize("Succeed")); } } } if (Request["requestType"] == "logoff") { using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { UserService _service = new UserService(context); Response.StatusCode = 303; _service.LogOff(); Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache); Response.Write(""); } } if (Request["requestType"] == "changephoto") { JavaScriptSerializer jss = new JavaScriptSerializer(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { UserService _service = new UserService(context); var paramDes = jss.Deserialize <IEnumerable <UserLoginApp> >(Request["queryParam"]); var userToUpdate = _service.GetUserByLoginName(paramDes.First().UserName); userToUpdate.HeadPhoto = paramDes.First().UserPhoto; bool result = _service.SetUserHeadPhoto(userToUpdate); Response.Write(jss.Serialize(result)); } } if (Request["requestType"] == "getloginuser") { JavaScriptSerializer jss = new JavaScriptSerializer(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { UserService _service = new UserService(context); var paramDes = jss.Deserialize <IEnumerable <UserLoginApp> >(Request["queryParam"]); var userToUpdate = _service.GetUserByLoginName(paramDes.First().UserName); UserLoginApp user = new UserLoginApp() { UserName = userToUpdate.UserName, UserPhoto = userToUpdate.HeadPhoto, Sex = userToUpdate.Sex }; Response.Write(jss.Serialize(user)); } } if (Request["requestType"] == "resetpassword") { JavaScriptSerializer jss = new JavaScriptSerializer(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { UserService _service = new UserService(context); var paramDes = jss.Deserialize <IEnumerable <UserLoginApp> >(Request["queryParam"]); if (_service.CheckPassword(paramDes.First().UserName, paramDes.First().Password)) { var result = _service.ChangePassword(paramDes.First().Password, paramDes.First().NewPassword); if (result == IdentityResult.Success) { Response.Write(jss.Serialize("密码重置成功,请使用新密码登陆")); } else { Response.Write(jss.Serialize("密码重置成功,请使用新密码登陆")); } } else { Response.Write(jss.Serialize("原密码错误,请重试")); } } } if (Request["requestType"] == "getprovincecity") { JavaScriptSerializer jss = new JavaScriptSerializer(); Response.Write(jss.Serialize(UserHelper.GetProvinceCityList(Server.MapPath("../Data/")))); } if (Request["requestType"] == "getcitydistrict") { JavaScriptSerializer jss = new JavaScriptSerializer(); string pName = Request["provinceName"].ToString(); Response.Write(jss.Serialize(UserHelper.GetCityDistrictList(Server.MapPath("../Data/"), pName))); } if (Request["requestType"] == "getuserinformation") { JavaScriptSerializer jss = new JavaScriptSerializer(); string userId = Request["uid"].ToString(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { UserInformationRepository rep = new UserInformationRepository(context); UserService uservice = new UserService(rep); Response.Write(jss.Serialize(uservice.GetUserInformation(userId))); } } if (Request["requestType"] == "findlistofuser") { JavaScriptSerializer jss = new JavaScriptSerializer(); string users = Request["users"].ToString(); List <String> notExistedUsers = new List <String>(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { UserService service = new UserService(context); foreach (var str in users.Split(';')) { if (str.Trim() != "") { var u = service.GetUserByLoginName(str); if (u == null) { // Not exist notExistedUsers.Add(str); } } } } Response.Write(jss.Serialize(notExistedUsers)); } if (Request["requestType"] == "saveuserinformation") { JavaScriptSerializer jss = new JavaScriptSerializer(); var paramDes = jss.Deserialize <UserInformationModel>(Request["queryParam"]); string userName = Request["uid"].ToString(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { UserInformationRepository rep = new UserInformationRepository(context); UserService uservice = new UserService(rep); var userid = paramDes.UserId; var user_related = uservice.GetUserById(); paramDes.UserRelated = user_related; uservice.SaveUserInformation(userid, paramDes); Response.Write(jss.Serialize("Success")); } } if (Request["requestType"] == "getusersforadmin") { JavaScriptSerializer jss = new JavaScriptSerializer(); string searchKeyword = Request["key"].ToString().Trim(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { UserRepository up = new UserRepository(context); UserService service = new UserService(up); var users = service.SearchUsers(searchKeyword).Select(_ => _.ToAppUser()); var s = jss.Serialize(users.ToList <UserLoginApp>()); Response.Write(s); } } if (Request["requestType"] == "getuserbyid") { JavaScriptSerializer jss = new JavaScriptSerializer(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { UserRepository up = new UserRepository(context); UserService service = new UserService(up); var users = service.GetUserById(); var s = jss.Serialize(users.ToAppUser()); Response.Write(s); } } if (Request["requestType"] == "getteamsforuser") { JavaScriptSerializer jss = new JavaScriptSerializer(); string searchKeyword = Request["userName"].ToString().Trim(); using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { UserRepository up = new UserRepository(context); UserService service = new UserService(up); var teams = service.GetUserAdminTeams(searchKeyword).Select(_ => _.ToAppTeamSite()); Response.Write(jss.Serialize(teams)); } } }