public string GetAll(int?curriculumID, int?classID, int?classRoomID, int?teacherID, DateTime?startTime, DateTime?endTime, int offset, int pageSize) { int total = 0; ArrangeClassManager manager = new ArrangeClassManager(); List <ArrangeClassViewEntity> list = manager.GetArrangeClassViewList(curriculumID, classID, classRoomID, teacherID, startTime, endTime); total = list.Count; List <ArrangeClassViewEntity> listView = list.Skip(offset).Take(pageSize).ToList(); //给分页实体赋值 PageModels <ArrangeClassViewEntity> model = new PageModels <ArrangeClassViewEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = listView; //将查询结果返回 return(new JavaScriptSerializer().Serialize(model)); }
public void GetCompanys() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); int total = 0; CompanyInfoManager manager = new CompanyInfoManager(); List <CompanyInfoEntity> list = manager.GetSearch(searchKey, sort, order, offset, pageSize, out total); //给分页实体赋值 PageModels <CompanyInfoEntity> model = new PageModels <CompanyInfoEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
public void GetClassStudentMaps() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); string classID = HttpContext.Request.Params["classID"]; int total = 0; ClassStudentMapManager manager = new ClassStudentMapManager(); List <ClassStudentMapViewEntity> list = manager.GetSearch(Ext.ToIntOrNull(classID), searchKey, order, offset, pageSize, out total); //给分页实体赋值 PageModels <ClassStudentMapViewEntity> model = new PageModels <ClassStudentMapViewEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
/// <summary> /// Contents the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <returns>the content</returns> public ActionResult Content(int id) { PageModels pageModels = new PageModels(); var page_view = new Page_static_view(); id = Convert.ToInt16(RouteData.Values["id"].ToString()); page_view.C_pages = pageModels.GetbyID(id); string strBread; if (page_view.C_pages.Title != string.Empty) { ViewBag.Title = page_view.C_pages.Title + " | " + GeneralModels.GetContent(CommonGlobal.PageName, this.Lang); strBread = "<li>" + page_view.C_pages.Title + "</li>"; } else { ViewBag.Title = page_view.C_pages.PageName + " | " + GeneralModels.GetContent(CommonGlobal.PageName, this.Lang); strBread = "<li>" + page_view.C_pages.PageName + "</li>"; } this.AddMeta(CommonGlobal.Keyword, page_view.C_pages.Keyword); this.AddMeta(CommonGlobal.Description, page_view.C_pages.Description); page_view.Str_breadcrumbs = strBread; return(this.PartialView("../page/content", page_view)); }
public void GetAllUsers() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0 int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); string userType = HttpContext.Request.Params["searchUserType"]; int total = 0; UserInfoManager um = new UserInfoManager(); List <UserInfoEntity> list = um.GetSearch(searchKey, userType, sort, order, offset, pageSize, out total); List <UserViewModel> listView = new List <UserViewModel>(); foreach (var item in list) { listView.Add(new UserViewModel { ID = item.ID, Code = item.Code, Name = item.Name, Type = item.Type, Group = item.Group, Company = item.Company, Department = item.Department, PositionID = item.PositionID, PositionName = item.PositionName, Sex = item.Sex, Birthday = item.Birthday == null ? "" : ((DateTime)item.Birthday).ToString("yyyy-MM-dd"), Email = item.Email, Phone = item.Phone, Address = item.Address, UpdateTime = item.UpdateTime }); } //给分页实体赋值 PageModels <UserViewModel> model = new PageModels <UserViewModel>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = listView; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
public async Task <PageModels <TasksQz> > GetPage(int pageIndex, int PageSize) { PageModels <TasksQz> models = new PageModels <TasksQz>(); models = await QueryPage(a => a.IsDeleted != true, pageIndex, PageSize, "Id desc "); return(models); }
public ActionResult DeleteConfirmed(int id) { PageModels pagemodels = db.PageModels.Find(id); db.PageModels.Remove(pagemodels); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(PageModels pagemodels) { if (ModelState.IsValid) { db.Entry(pagemodels).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pagemodels)); }
// // GET: /Page/Delete/5 public ActionResult Delete(int id = 0) { PageModels pagemodels = db.PageModels.Find(id); if (pagemodels == null) { return(HttpNotFound()); } return(View(pagemodels)); }
public PageViewModels(PageModels pageModel) { PageId = pageModel.Id; Author = pageModel.Author; Title = pageModel.Title; Content = pageModel.Content; AdditionalContent = pageModel.AdditionalContent; CommentsEnabled = pageModel.CommentsEnabled; CreationDate = pageModel.CreationDate; }
public ActionResult Create(PageModels pagemodels) { if (ModelState.IsValid) { db.PageModels.Add(pagemodels); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pagemodels)); }
/// <summary> /// Updates the status is show page static. /// </summary> /// <param name="id">The identifier.</param> /// <param name="status">The status.</param> /// <param name="type">The type.</param> /// <returns>update status is show page static</returns> public ActionResult Update_status_is_show_page_static(string id, string status, string type) { PageModels pageModels = new PageModels(); C_Pages cpage = new C_Pages(); bool isOk = false; if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, "change_static", "adminStatic", CommonGlobal.Edit, type)) { isOk = true; } else { isOk = false; } if (!string.IsNullOrEmpty(id)) { if (int.Parse(id) > 0) { cpage = pageModels.GetbyID(int.Parse(id)); } if (cpage != null) { try { if (bool.Parse(status) == true) { cpage.Show = true; } else { cpage.Show = false; } if (isOk) { cpage.DateModified = DateTime.Now; pageModels.Edit(cpage); } } catch (Exception) { } } } var jsonSerialiser = new JavaScriptSerializer(); var results = Convert.ToDateTime(DateTime.Now).ToString("dd/MM/yyyy") + "|" + cpage.Show; return(this.Json(results)); }
public void GetAllUsers() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0 int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); int total = 0; UserManager um = new UserManager(); List <UserEntity> list = um.GetSearch(searchKey, sort, order, offset, pageSize, out total); DicManager dm = new DicManager(); List <DicEntity> companyDicE = dm.GetDicByType("公司"); Dictionary <string, string> companyDic = new Dictionary <string, string>(); foreach (var item in companyDicE) { companyDic.Add(item.iKey, item.iValue); } List <UserViewModel> listView = new List <UserViewModel>(); foreach (var item in list) { listView.Add(new UserViewModel { iCompanyCode = item.iCompanyCode, iCompanyName = companyDic[item.iCompanyCode], iEmployeeCodeId = item.iEmployeeCodeId, iPassWord = item.iPassWord, iUserName = item.iUserName, iUserType = item.iUserType, iUpdatedOn = item.iUpdatedOn.ToString("yyyyMMdd HH:mm") }); } //给分页实体赋值 PageModels <UserViewModel> model = new PageModels <UserViewModel>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = listView; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
public void setPageInfo(PageResultModels <ArticlesModels> pageResultModels, ArticlesQueryModels articlesQueryModels) { //用户当前请求页码 int currentPage = pageResultModels.CurrentPage; //数据库数据总页数 int totalPage = pageResultModels.TotalPage; //总分页数量 const int totalPageSize = 11; int center = (totalPageSize / 2) + 1; int size = totalPageSize; int i = 0; if (currentPage > center) { int deviation = currentPage - center; i = deviation; size = totalPageSize + deviation; } if (totalPage < totalPageSize) { size = totalPage; } else if ((i + totalPageSize) > totalPage) { i = totalPage - totalPageSize; size = i + totalPageSize; } List <PageModels> numberList = new List <PageModels>(); for (; i < size; i++) { PageModels pageModels = new PageModels(); int page = i + 1; pageModels.Number = page; pageModels.Uri = uri(page, articlesQueryModels); numberList.Add(pageModels); } pageResultModels.NumberList = numberList; pageResultModels.Previous = uri(currentPage == 1 ? 1 : currentPage - 1, articlesQueryModels); pageResultModels.Next = uri(currentPage == totalPage ? totalPage : currentPage + 1, articlesQueryModels); pageResultModels.First = uri(1, articlesQueryModels); pageResultModels.Last = uri(totalPage, articlesQueryModels); }
public ActionResult StoreClick(int id = 0) { PageModels pagemodels = db.PageModels.Find(id); if (pagemodels == null) { return(HttpNotFound()); } string artistURL = pagemodels.ITunesPageURL; pagemodels.Clicks += 1; db.Entry(pagemodels).State = EntityState.Modified; db.SaveChanges(); return(Redirect(artistURL)); }
private static async Task <string> LookupItunes(string lookupString) { using (var client = new HttpClient()) { string requestURI = "http://itunes.apple.com/search?term=" + lookupString + "&media=all"; string response = await client.GetStringAsync( requestURI ).ConfigureAwait(false); JavaScriptSerializer js = new JavaScriptSerializer(); dynamic resultsObject = js.Deserialize <dynamic>(response); int resultCount = resultsObject["resultCount"]; object[] results = resultsObject["results"]; foreach (Dictionary <string, object> result in results) { string wrapperType = result["wrapperType"].ToString(); string viewURL = string.Empty; switch (wrapperType) { case "artist": viewURL = result["artistViewUrl"].ToString(); break; case "collection": viewURL = result["collectionViewUrl"].ToString(); break; case "track": viewURL = result["trackViewUrl"].ToString(); break; } PageController page = new PageController(); PageModels pageData = new PageModels(); pageData.ITunesPageURL = viewURL; pageData.Clicks = 0; page.Create(pageData); } return(response); } }
/// <summary> /// 分页获取数据 /// </summary> /// <param name="pageSize">每一页数据量</param> /// <param name="currentPage">当前页</param> /// <param name="whereParameters">限制条件</param> /// <param name="dyOrder">排序</param> /// <param name="columnParameters">查询属性</param> /// <returns></returns> public async Task <PageModels <T> > GetByPagerAsync(int pageSize, int currentPage, object whereParameters = null, string dyOrder = null, List <string> columnParameters = null) { string columnStr = "*"; string strWhere = " Status=0"; string orderStr = "Id"; if (columnParameters != null) { columnStr = string.Join(",", columnParameters); } if (whereParameters != null) { PropertyInfo[] properties = whereParameters.GetType().GetProperties(); string propertiesStr = string.Join(",", properties.Select(p => $" and {p.Name}='{p.GetValue(whereParameters)}'")); strWhere += propertiesStr; } if (!string.IsNullOrEmpty(dyOrder)) { orderStr = dyOrder; } string stringSql = $"select {columnStr} from {typeof(T).Name} where {strWhere} order by {orderStr} limit @Index,@PageSize"; string stringSqlCount = $"select count(1) from {typeof(T).Name} where {strWhere}"; int index = (currentPage - 1) * pageSize; PageModels <T> result = new PageModels <T>(); using (IDbConnection connection = new MySqlConnection(connectionStr)) { IEnumerable <T> models = await connection.QueryAsync <T>(stringSql, new { @Index = index, @PageSize = pageSize }); if (models != null && models.Count() > 0) { result.Data = models.ToList(); result.Count = await connection.QuerySingleAsync <int>(stringSqlCount); result.PageCount = (int)Math.Ceiling((double)result.Count / pageSize); return(result); } else { return(null); } } }
public void GetAllDics() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0 int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); int total = 0; DicManager dm = new DicManager(); List <DicEntity> list = dm.GetSearch(searchKey, sort, order, offset, pageSize, out total); List <DicViewModel> listView = new List <DicViewModel>(); foreach (var item in list) { listView.Add(new DicViewModel { iId = item.iId, iKey = item.iKey, iValue = item.iValue, iType = item.iType, iUpdatedOn = item.iUpdatedOn.ToString("yyyyMMdd HH:mm") }); } //给分页实体赋值 PageModels <DicViewModel> model = new PageModels <DicViewModel>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = listView; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
public void GetDigitalContents() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); List <DigitalContentEntity> list = new List <DigitalContentEntity>(); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchName = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); string category = HttpContext.Request.Params["category"]; //资源类别-共享文件夹2级目录(公司介绍、校园介绍) string type = HttpContext.Request.Params["type"]; //图片:1, 视频:2 int total = 0; list = GetDigitalContentList(category, type, searchName, sort, order, offset, pageSize, out total); //给分页实体赋值 PageModels <DigitalContentEntity> model = new PageModels <DigitalContentEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
public void GetHRInfoLog() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); jss.MaxJsonLength = Int32.MaxValue; //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["recordid"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0 int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); int total = 0; ModifyLogManager service = new ModifyLogManager(); List <ModifyLogEntity> list = service.GetSearch(searchKey, sort, order, offset, pageSize, out total); //给分页实体赋值 PageModels <ModifyLogEntity> model = new PageModels <ModifyLogEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
public string GetAll(string order, string sort, string searchKey, int offset, int pageSize) { int total = 0; CompanyInfoManager manager = new CompanyInfoManager(); List <CompanyInfoEntity> list = manager.GetSearch(searchKey, sort, order, offset, pageSize, out total); //给分页实体赋值 PageModels <CompanyInfoEntity> model = new PageModels <CompanyInfoEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 return(new JavaScriptSerializer().Serialize(model)); }
public ActionResult Change_static(int?id, string act, string ctrl, string lang, string type_act) { PageModels pageModels = new PageModels(); C_Pages cpage = new C_Pages(); StringBuilder sb = new StringBuilder(); var page_view = new Web.Areas.Admin.ViewModels.Page_view(); if (string.IsNullOrEmpty(act)) { act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "change_static"; } if (string.IsNullOrEmpty(ctrl)) { ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminStatic"; } if (id == null) { id = RouteData.Values["id"] != null?Convert.ToInt32(RouteData.Values["id"].ToString()) : 0; } if (string.IsNullOrEmpty(type_act)) { type_act = Request.QueryString["type_act"] != null ? Request.QueryString["type_act"].ToString() : CommonGlobal.Add; if (id == 0) { type_act = CommonGlobal.Add; } else { type_act = CommonGlobal.Edit; } } if (type_act == CommonGlobal.Edit) { cpage = pageModels.GetbyID((int)id); sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_page_static", ctrl = "adminStatic", page = "1" }) + "\"><span><span>Danh sách trang tĩnh</span></span></a></li>"); sb.Append("<li class=\"active\"><a href=\"#\"><span><span>" + cpage.PageName + "</span></span></a></li>"); page_view.Lang = cpage.Lang ?? lang; page_view.Id = cpage.PageID; page_view.PageName = cpage.PageName; page_view.PageContent = cpage.PageContent; page_view.Link = cpage.Link; page_view.Title = cpage.Title; page_view.ImagePath = cpage.ImagePath; page_view.Description = cpage.Description; page_view.Keyword = cpage.Description; page_view.Summary = cpage.Summary; page_view.OrderDisplay = cpage.OrderDisplay ?? 0; page_view.List_language = this.List_select_language(cpage.Lang ?? this.Lang); page_view.Show = cpage.Show ?? false; if (cpage.Show == true) { page_view.Show = true; page_view.Show_text = "checked='checked'"; } else { page_view.Show = false; page_view.Show_text = string.Empty; } } else { sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_page_static", ctrl = "adminStatic", page = "1" }) + "\"><span><span>Danh sách trang tĩnh</span></span></a></li>"); sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Thêm mới</span></span></a></li>"); page_view.Lang = lang; page_view.List_language = this.List_select_language(this.Lang); page_view.OrderDisplay = pageModels.GetMaxOrderDisplay(); } page_view.Html_link_tab = sb.ToString(); page_view.Type_act = type_act; ////action and parent action page_view.Act = act; page_view.Ctrl = ctrl; page_view.Parent_action = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString(); page_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString(); return(this.PartialView("../control/change_static", page_view)); }
public void GetAllHRInfo() { try { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); jss.MaxJsonLength = Int32.MaxValue; //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0 int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); Dictionary <string, string> bizParaDic = new Dictionary <string, string>(); bizParaDic.Add("search", searchKey); string itemName = HttpContext.Request.Params["iItemName"]; string company = HttpContext.Request.Params["iCompany"]; string idcard = HttpContext.Request.Params["iIdCard"]; string name = HttpContext.Request.Params["iName"]; string empId = HttpContext.Request.Params["iEmpNo"]; string status = HttpContext.Request.Params["iEmployeeStatus"]; string employeedate1 = HttpContext.Request.Params["iEmployeeDateFrom"]; string employeedate2 = HttpContext.Request.Params["iEmployeeDateTo"]; string contractdeadline1 = HttpContext.Request.Params["iContractDeadLineFrom"]; string contractdeadline2 = HttpContext.Request.Params["iContractDeadLineTo"]; string resigndate1 = HttpContext.Request.Params["iResignDateFrom"]; string resigndate2 = HttpContext.Request.Params["iResignDateTo"]; string modifyon1 = HttpContext.Request.Params["iModifyOnFrom"]; string modifyon2 = HttpContext.Request.Params["iModifyOnTo"]; bizParaDic.Add("iItemName", itemName); bizParaDic.Add("iCompany", company); bizParaDic.Add("iIdCard", idcard); bizParaDic.Add("iName", name); bizParaDic.Add("iEmpNo", empId); bizParaDic.Add("iEmployeeStatus", status); bizParaDic.Add("iEmployeeDate[d]", employeedate1 + "§" + employeedate2); bizParaDic.Add("iContractDeadLine[d]", contractdeadline1 + "§" + contractdeadline2); bizParaDic.Add("iResignDate[d]", resigndate1 + "§" + resigndate2); bizParaDic.Add("iUpdatedOn[d]", modifyon1 + "§" + modifyon2); int total = 0; HRInfoManager service = new HRInfoManager(); List <HRInfoEntity> list = service.GetSearch(SessionHelper.CurrentUser.UserType, bizParaDic, sort, order, offset, pageSize, out total); DicManager dm = new DicManager(); var companies = dm.GetAllCompanies(); var projects = dm.GetAllProjects(); Dictionary <string, string> comDic = companies.ToDictionary(i => i.iGuid, i => i.iName); Dictionary <string, string> proDic = projects.ToDictionary(i => i.iGuid, i => i.iName); foreach (var item in list) { item.iCompany = comDic[item.iCompany]; item.iItemName = proDic[item.iItemName]; } //给分页实体赋值 PageModels <HRInfoEntity> model = new PageModels <HRInfoEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); } catch (Exception e) { log4net.ILog log = log4net.LogManager.GetLogger(this.GetType()); log.Error(e); } }
public void GetLoginLogs(string jsonString) { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); //查询条件 LoginLogEntity entity = JsonConvert.DeserializeObject <LoginLogEntity>(jsonString); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0 int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); StringBuilder sbCondition = new StringBuilder(); if (entity != null) { sbCondition.Append(" where 1 = 1"); if (!string.IsNullOrWhiteSpace(entity.Type)) { sbCondition.Append(string.Format(" and Type = '{0}'", entity.Type)); } if (!string.IsNullOrWhiteSpace(entity.Guid)) { sbCondition.Append(string.Format(" and Guid = '{0}'", entity.Guid)); } if (entity.LoginID > 0) { sbCondition.Append(string.Format(" and LoginID = {0}", entity.LoginID)); } if (!string.IsNullOrWhiteSpace(entity.LoginName)) { sbCondition.Append(string.Format(" and LoginName = '{0}'", entity.LoginName)); } if (!string.IsNullOrWhiteSpace(entity.LoginType)) { sbCondition.Append(string.Format(" and LoginType = '{0}'", entity.LoginType)); } if (!string.IsNullOrWhiteSpace(entity.Action)) { sbCondition.Append(string.Format(" and Action = '{0}'", entity.Action)); } if (entity.StartTime != null) { sbCondition.Append(string.Format(" and TimeRecord >= '{0}'", entity.StartTime)); } if (entity.EndTime != null) { sbCondition.Append(string.Format(" and TimeRecord <= '{0}'", entity.EndTime)); } } int total = 0; LoginLogManager manager = new LoginLogManager(); List <LoginLogEntity> list = manager.GetSearch(sbCondition.ToString(), sort, order, offset, pageSize, out total); //给分页实体赋值 PageModels <LoginLogEntity> model = new PageModels <LoginLogEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
public void GetAllReturnFee() { try { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); jss.MaxJsonLength = Int32.MaxValue; //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0 int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); string editType = HttpContext.Request.Params["sEditType"]; Dictionary <string, string> bizParaDic = new Dictionary <string, string>(); bizParaDic.Add("search", searchKey); bizParaDic.Add("editType", editType); Dictionary <string, string> bizParaDicTemp = new Dictionary <string, string>(); foreach (string para in HttpContext.Request.Params.Keys) { if (para.StartsWith("s") && (ReturnFeeManager.ReturnFeeDic.ContainsValue("i" + para.Substring(1, para.Length - 1)) || (para.Length > 2 && ReturnFeeManager.ReturnFeeDic.ContainsValue("i" + para.Substring(1, para.Length - 2))))) { bizParaDicTemp.Add("i" + para.Substring(1, para.Length - 1), HttpContext.Request.Params[para]); } } foreach (var item in bizParaDicTemp) { if (item.Key.EndsWith("2")) { continue; } if (bizParaDicTemp.ContainsKey(item.Key + "2")) { bizParaDic.Add(item.Key + "[d]", item.Value + "§" + bizParaDicTemp[item.Key + "2"]); } else { bizParaDic.Add(item.Key, item.Value); } } int total = 0; ReturnFeeManager service = new ReturnFeeManager(); List <ReturnFeeModel> list = service.GetSearch(SessionHelper.CurrentUser.UserType, bizParaDic, sort, order, offset, pageSize, out total); DicManager dm = new DicManager(); var companies = dm.GetAllCompanies(); var projects = dm.GetAllProjects(); Dictionary <string, string> comDic = companies.ToDictionary(i => i.iGuid, i => i.iName); Dictionary <string, string> proDic = projects.ToDictionary(i => i.iGuid, i => i.iName); foreach (var item in list) { item.iCompany = comDic[item.iCompany]; item.iItemName = proDic[item.iItemName]; } //给分页实体赋值 PageModels <ReturnFeeModel> model = new PageModels <ReturnFeeModel>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); } catch (Exception ex) { log4net.ILog log = log4net.LogManager.GetLogger(this.GetType()); log.Error(ex); } }
public ActionResult List_page_static(int?id, string act, string ctrl, string type_act, string type, string lang, string search, int?page, int?page_size, string order_by, string order_type) { PageModels pageModels = new PageModels(); StringBuilder sb = new StringBuilder(); C_Pages cpage = new C_Pages(); var list_page_view = new Web.Areas.Admin.ViewModels.List_page_view(); int total_record = 0; if (string.IsNullOrEmpty(act)) { act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_page_static"; } if (string.IsNullOrEmpty(ctrl)) { ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminStatic"; } if (string.IsNullOrEmpty(type_act)) { type_act = Request.QueryString["type_act"] != null ? Request.QueryString["type_act"].ToString() : CommonGlobal.View; } if (page == null || page == 0) { page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1; } if (string.IsNullOrEmpty(lang)) { lang = LanguageModels.ActiveLanguage().LangCultureName; } if (page_size == null) { page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30")); } if (id != null && type_act != null && type_act == CommonGlobal.Delete) { ////check permission delete if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type ?? string.Empty)) { cpage = pageModels.GetbyID((int)id); if (cpage != null) { ////delete old image if (!string.IsNullOrEmpty(cpage.ImagePath)) { string strImg = cpage.ImagePath; strImg = "~" + strImg; string fileDelete = Server.MapPath(strImg); if (System.IO.File.Exists(fileDelete)) { System.IO.File.Delete(fileDelete); } string fileDelete2 = Server.MapPath(strImg.Replace("sc_small_", "sc_full_")); if (System.IO.File.Exists(fileDelete2)) { System.IO.File.Delete(fileDelete2); } } ////delete category bool rt = pageModels.Delete((int)id); if (rt) { list_page_view.Message = "Bạn đã xóa page " + id; } else { list_page_view.Message = "Xóa không thành công"; } } else { list_page_view.Message = "Không tìm thấy page : " + id; } } else { list_page_view.Message = " Bạn không có quyền thực thi hành động xóa."; } } if (string.IsNullOrEmpty(order_by) || string.IsNullOrEmpty(order_type)) { order_by = "OrderDisplay"; order_type = "asc"; } list_page_view.Type_act = type_act; list_page_view.Cate_type = "Danh sách trang tĩnh "; list_page_view.Lang = lang; ////tab sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_page_static", ctrl = "adminStatic", page = "1" }) + "\"><span><span>Danh sách trang tĩnh</span></span></a></li>"); sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "change_static", ctrl = "adminStatic", type_act = CommonGlobal.Add }) + "\"><span><span>Thêm trang tĩnh</span></span></a></li>"); list_page_view.Html_link_tab = sb.ToString(); ////list language list_page_view.List_language = this.List_select_language(this.Lang); ////list page size and paging list_page_view.List_page_size = this.GetSizePagingPublic((int)page_size); list_page_view.Page = (int)page; list_page_view.Page_size = (int)page_size; ////list catalog list_page_view.Page_list = pageModels.GetAllPageStaticAdmin(lang, search, (int)page, (int)page_size, order_by, order_type, out total_record); list_page_view.Search = search; list_page_view.Order_by = order_by; list_page_view.Order_type = order_type; list_page_view.Total_record = total_record; ////acton and parent action list_page_view.Act = act; list_page_view.Ctrl = ctrl; list_page_view.Parent_action = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString(); list_page_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString(); return(this.PartialView("../control/list_page_static", list_page_view)); }
public void GetClasses() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); int total = 0; ClassInfoManager manager = new ClassInfoManager(); List <ClassInfoEntity> list = manager.GetSearch(searchKey, sort, order, offset, pageSize, out total); var teacherList = new UserInfoManager().GetUserByType("Teacher"); List <ClassViewModel> listView = new List <ClassViewModel>(); foreach (var item in list) { ClassViewModel viewModel = new ClassViewModel(); viewModel.ClassID = item.ClassID; viewModel.Code = item.Code; viewModel.Name = item.Name; viewModel.Type = item.Type; viewModel.StartTime = item.StartTime; viewModel.EndTime = item.EndTime; viewModel.Company = item.Company; viewModel.Department = item.Department; viewModel.Remark = item.Remark; viewModel.UpdateTime = item.UpdateTime; var teacherEntity = teacherList.Where(r => r.ID == item.TeacherID).FirstOrDefault(); if (teacherEntity != null) { viewModel.TeacherID = teacherEntity.ID; viewModel.TeacherCode = teacherEntity.Code; viewModel.TeacherName = teacherEntity.Name; } listView.Add(viewModel); } //给分页实体赋值 PageModels <ClassViewModel> model = new PageModels <ClassViewModel>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = listView; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
public ActionResult Change_static(FormCollection collection) { PageModels pageModels = new PageModels(); C_Pages cpage = new C_Pages(); StringBuilder sb = new StringBuilder(); var page_view = new Web.Areas.Admin.ViewModels.Page_view(); this.TryUpdateModel(page_view); int rt = 0; bool is_valid = true; if (page_view.Id > 0) { cpage = pageModels.GetbyID(page_view.Id); } ////validation server if (string.IsNullOrEmpty(page_view.PageName)) { is_valid = false; if (page_view.Message != string.Empty) { page_view.Message = "Bạn cần nhập Tên trang"; } } if (string.IsNullOrEmpty(page_view.PageContent)) { is_valid = false; if (page_view.Message != string.Empty) { page_view.Message = "Bạn cần nhập nội dung trang tĩnh"; } } ////Link tab sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_page_static", ctrl = "adminStatic", page = "1" }) + "\"><span><span>Danh sách trang tĩnh</span></span></a></li>"); if (page_view.Id != 0 && page_view.Type_act == CommonGlobal.Edit) { sb.Append("<li class=\"active\"><a href=\"#\"><span><span>" + cpage.PageName + "</span></span></a></li>"); page_view.List_language = this.List_select_language(cpage.Lang); page_view.Id = cpage.PageID; } else { sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Thêm trang tĩnh</span></span></a></li>"); page_view.List_language = this.List_select_language(page_view.Lang); } page_view.Html_link_tab = sb.ToString(); ////action page_view.Parent_action = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString(); page_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString(); if (!is_valid) { return(this.PartialView("../control/change_static", page_view)); } cpage.Summary = string.IsNullOrEmpty(page_view.Summary) == false ? page_view.Summary : string.Empty; cpage.PageContent = string.IsNullOrEmpty(page_view.PageContent) == false ? page_view.PageContent : string.Empty; cpage.Lang = page_view.Lang; cpage.PageName = page_view.PageName; if (string.IsNullOrEmpty(page_view.Title)) { cpage.Title = page_view.PageName; } else { cpage.Title = page_view.Title; } cpage.Keyword = string.IsNullOrEmpty(page_view.Keyword) == false ? page_view.Keyword : string.Empty; cpage.Description = string.IsNullOrEmpty(page_view.Description) == false ? page_view.Description : string.Empty; cpage.Show = page_view.Show; if ((cpage.Show ?? false) == true) { page_view.Show = true; page_view.Show_text = "checked='checked'"; } else { page_view.Show = false; page_view.Show_text = string.Empty; } cpage.Link = CommonGlobal.CompleteLink(page_view.PageName); cpage.DateModified = DateTime.Now; var imgPathTemp = "images/static/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/"; var name_time = DateTime.Now.Day + DateTime.Now.Month + DateTime.Now.Year + DateTime.Now.Hour + DateTime.Now.Minute + string.Empty; if (page_view.File_image != null && page_view.File_image.ContentLength > 0 && CommonGlobal.IsImage(page_view.File_image) == true) { string image_small = imgPathTemp + "sc_small_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(page_view.File_image.FileName); string image_lager = imgPathTemp + "sc_full_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(page_view.File_image.FileName); ////save image and delete old file this.Savephoto(cpage.ImagePath, page_view.File_image, imgPathTemp, image_small, image_lager); ////set image thumb to link catalog cpage.ImagePath = "/" + image_small; page_view.ImagePath = "/" + image_small; } else if (string.IsNullOrEmpty(cpage.ImagePath)) { cpage.ImagePath = "0"; } else { cpage.ImagePath = page_view.ImagePath; } cpage.OrderDisplay = page_view.OrderDisplay; if (page_view.Id != 0 && page_view.Type_act == CommonGlobal.Edit) { rt = pageModels.Edit(cpage); } else { rt = pageModels.Add(cpage); } if (rt > 0) { page_view.Message = "Cập nhật thành công!"; page_view.Id = rt; page_view.Type_act = CommonGlobal.Edit; } else { page_view.Message = "Cập nhật không thành công!"; } return(this.PartialView("../control/change_static", page_view)); }
public void GetArrangeClasses() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); string student = HttpContext.Request.Params["student"]; string curriculumID = HttpContext.Request.Params["curriculumID"]; string classID = HttpContext.Request.Params["classID"]; string classRoomID = HttpContext.Request.Params["classRoomID"]; string teacherID = HttpContext.Request.Params["teacherID"]; string startTime = HttpContext.Request.Params["startTime"]; DateTime?endTime = null; if (!string.IsNullOrWhiteSpace(startTime)) { endTime = DateTime.Parse(startTime).AddDays(1); } List <int> classList = null; if (!string.IsNullOrWhiteSpace(student)) { classList = new ClassStudentMapManager().GetClassStudentMapViewList(Ext.ToIntOrNull(classID), null, student).Select(r => r.ClassID).ToList(); } int total = 0; ArrangeClassManager manager = new ArrangeClassManager(); List <ArrangeClassViewEntity> list = manager.GetArrangeClassViewList(Ext.ToIntOrNull(curriculumID), Ext.ToIntOrNull(classID), Ext.ToIntOrNull(classRoomID), Ext.ToIntOrNull(teacherID), Ext.ToDateOrNull(startTime), Ext.ToDateOrNull(endTime)); list = list.OrderByDescending(r => r.StartTime).OrderBy(r => r.ClassCode).ToList(); total = list.Count; List <ArrangeClassViewEntity> listView = list.Skip(offset).Take(pageSize).ToList(); if (!string.IsNullOrWhiteSpace(student)) { listView = list.Where(r => classList.Contains(r.ClassID)).Skip(offset).Take(pageSize).ToList(); } //给分页实体赋值 PageModels <ArrangeClassViewEntity> model = new PageModels <ArrangeClassViewEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = listView; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }