public void frompage_shouldfillcorrectproperties() { // Arrange Page page = new Page(); page.Id = 123; page.CreatedBy = "createdby"; page.CreatedOn = DateTime.UtcNow; page.IsLocked = true; page.ModifiedBy = "modifiedby"; page.ModifiedOn = DateTime.UtcNow; page.Tags = "tag1,tag2"; page.Title = "title"; PageEntity entity = new PageEntity(); // Act ToEntity.FromPage(page, entity); // Assert Assert.That(entity.Id, Is.Not.EqualTo(page.Id)); // the id isn't copied from the page Assert.That(entity.CreatedBy, Is.EqualTo(page.CreatedBy)); Assert.That(entity.CreatedOn, Is.EqualTo(page.CreatedOn)); Assert.That(entity.IsLocked, Is.EqualTo(page.IsLocked)); Assert.That(entity.ModifiedBy, Is.EqualTo(page.ModifiedBy)); Assert.That(entity.ModifiedOn, Is.EqualTo(page.ModifiedOn)); Assert.That(entity.Tags, Is.EqualTo(page.Tags)); Assert.That(entity.Title, Is.EqualTo(page.Title)); }
public PageContent AddNewPage(Page page, string text, string editedBy, DateTime editedOn) { PageEntity pageEntity = new PageEntity(); ToEntity.FromPage(page, pageEntity); pageEntity.Id = 0; UnitOfWork.Add(pageEntity); UnitOfWork.SaveChanges(); PageContentEntity pageContentEntity = new PageContentEntity() { Id = Guid.NewGuid(), Page = pageEntity, Text = text, EditedBy = editedBy, EditedOn = editedOn, VersionNumber = 1, }; UnitOfWork.Add(pageContentEntity); UnitOfWork.SaveChanges(); PageContent pageContent = FromEntity.ToPageContent(pageContentEntity); pageContent.Page = FromEntity.ToPage(pageEntity); return pageContent; }
public static void FromPage(Page page, PageEntity entity) { entity.CreatedBy = page.CreatedBy; entity.CreatedOn = page.CreatedOn; entity.IsLocked = page.IsLocked; entity.ModifiedOn = page.ModifiedOn; entity.ModifiedBy = page.ModifiedBy; entity.Tags = page.Tags; entity.Title = page.Title; }
public void GetChildPages(ref List<PageEntity> pageList, PageEntity parent, List<PageEntity> lstPages) { foreach (PageEntity obj in lstPages) { if (obj.ParentID == parent.PageID) { obj.PageNameWithoughtPrefix = obj.PageName; obj.Prefix = GetPrefix(obj.Level); obj.PageName = obj.Prefix + obj.PageName; pageList.Add(obj); GetChildPages(ref pageList, obj, lstPages); } } }
public static void FromPage(Page page, PageEntity entity) { entity.CreatedBy = page.CreatedBy; entity.CreatedOn = page.CreatedOn; entity.IsLocked = page.IsLocked; entity.ModifiedOn = page.ModifiedOn; entity.ModifiedBy = page.ModifiedBy; entity.ProjectStart = page.ProjectStart; entity.ProjectEnd = page.ProjectEnd; entity.ProjectEstimatedTime = page.ProjectEstimatedTime; entity.ProjectStatus = page.ProjectStatus; entity.ProjectLanguage = page.ProjectLanguage; entity.orgID = page.orgID; entity.Tags = page.Tags; entity.Title = page.Title; }
public static Page ToPage(PageEntity entity) { if (entity == null) return null; Page page = new Page(); page.Id = entity.Id; page.CreatedBy = entity.CreatedBy; page.CreatedOn = entity.CreatedOn; page.IsLocked = entity.IsLocked; page.ModifiedBy = entity.ModifiedBy; page.ModifiedOn = entity.ModifiedOn; page.Tags = entity.Tags; page.Title = entity.Title; return page; }
public void ToPageList_ShouldContainValidList() { // Arrange PageEntity entity1 = new PageEntity(); entity1.CreatedBy = "createdtest1"; entity1.CreatedOn = DateTime.UtcNow; entity1.IsLocked = true; entity1.ModifiedBy = "modtest1"; entity1.ModifiedOn = DateTime.UtcNow.AddYears(1); entity1.Tags = "tag1,tag2"; entity1.Title = "title1"; PageEntity entity2 = new PageEntity(); entity2.CreatedBy = "createdtest2"; entity2.CreatedOn = DateTime.UtcNow; entity2.IsLocked = true; entity2.ModifiedBy = "modtest2"; entity2.ModifiedOn = DateTime.UtcNow.AddYears(2); entity2.Tags = "tag2"; entity2.Title = "title2"; PageEntity entity3 = new PageEntity(); entity3.CreatedBy = "createdtest3"; entity3.CreatedOn = DateTime.UtcNow; entity3.IsLocked = true; entity3.ModifiedBy = "modtest3"; entity3.ModifiedOn = DateTime.UtcNow.AddYears(3); entity3.Tags = "tagtag3"; entity3.Title = "title3"; List<PageEntity> entities = new List<PageEntity>(); entities.Add(entity1); entities.Add(entity2); entities.Add(entity3); // Act List<Page> pageList = FromEntity.ToPageList(entities).ToList(); // Assert Assert.That(pageList.Count, Is.EqualTo(3)); Assert.That(pageList[0].Title, Is.EqualTo(entity1.Title)); Assert.That(pageList[1].Title, Is.EqualTo(entity2.Title)); Assert.That(pageList[2].Title, Is.EqualTo(entity3.Title)); }
/// <summary> /// 根据条件分页获取指定数据 /// <param name="pageIndex">当前页</param> /// <para>索引从0开始</para> /// <param name="pageSize">每页记录条数</param> /// <para>记录数必须大于0</para> /// </summary> public PageEntity <SysRoleFunction> Search(Int32 SysRoleFunctionId, Int32 RoleId, Int32 FunctionId, int pageIndex, int pageSize) { PageEntity <SysRoleFunction> returnValue = new PageEntity <SysRoleFunction>(); MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdLoadSysRoleFunction = cmdLoadSysRoleFunction.Clone() as MySqlCommand; MySqlCommand _cmdGetSysRoleFunctionCount = cmdGetSysRoleFunctionCount.Clone() as MySqlCommand; _cmdLoadSysRoleFunction.Connection = oc; _cmdGetSysRoleFunctionCount.Connection = oc; try { _cmdLoadSysRoleFunction.Parameters["@PageIndex"].Value = pageIndex; _cmdLoadSysRoleFunction.Parameters["@PageSize"].Value = pageSize; _cmdLoadSysRoleFunction.Parameters["@SysRoleFunctionId"].Value = SysRoleFunctionId; _cmdLoadSysRoleFunction.Parameters["@RoleId"].Value = RoleId; _cmdLoadSysRoleFunction.Parameters["@FunctionId"].Value = FunctionId; if (oc.State == ConnectionState.Closed) { oc.Open(); } MySqlDataReader reader = _cmdLoadSysRoleFunction.ExecuteReader(); while (reader.Read()) { returnValue.Items.Add(new SysRoleFunction().BuildSampleEntity(reader)); } returnValue.RecordsCount = (int)_cmdGetSysRoleFunctionCount.ExecuteScalar(); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdLoadSysRoleFunction.Dispose(); _cmdLoadSysRoleFunction = null; _cmdGetSysRoleFunctionCount.Dispose(); _cmdGetSysRoleFunctionCount = null; GC.Collect(); } return(returnValue); }
/// <summary> /// 获取文档对象 /// </summary> /// <returns></returns> public PageEntity Read() { PageEntity Result = new PageEntity(); if (!FileManager.FileExists(this.FilePath)) { throw new Exception("打印模板文件不存在"); } this.Root = XDocument.Load(this.FilePath); float Width = this.Root.Element("Page").Value <float>("Width"); float Heigth = this.Root.Element("Page").Value <float>("Heigth"); string DefaultPrinter = this.Root.Element("Page").Value("DefaultPrinter"); bool AutoHeight = this.Root.Element("Page").Value <bool>("AutoHeight"); Result.Width = Width; Result.Heigth = Heigth; Result.DefaultPrinter = DefaultPrinter; Result.AutoHeight = AutoHeight; Result.Rows = new List <RowEntity>(); foreach (XElement item in this.Root.Element("Page").Elements()) { if (item.Name == "Line") { LineEntity LineRow = this.ReadLine(item); Result.Rows.Add(LineRow); } else if (item.Name == "Loop") { LoopEntity LineRow = this.ReadLoop(item); Result.Rows.Add(LineRow); } else if (item.Name == "Table") { TableEntity LineRow = this.ReadTable(item); Result.Rows.Add(LineRow); } } return(Result); }
public JsonResult PageEdit(PageEntity entity) { var isInsert = Request.Form[NamingCenter.PARAM_FORM_VIEW_MODE].Equals("Insert"); bool result = false; if (isInsert) { if (DBContext <PageEntity> .Instance.FirstOrDefault(o => o.Id.Equals(entity.Id, StringComparison.OrdinalIgnoreCase)) != null) { throw new FoxOneException("Page_Id_Exist"); } result = DBContext <PageEntity> .Insert(entity); } else { result = DBContext <PageEntity> .Update(entity); } return(Json(result)); }
/// <summary> /// 根据条件分页获取指定数据 /// <param name="pageIndex">当前页</param> /// <para>索引从0开始</para> /// <param name="pageSize">每页记录条数</param> /// <para>记录数必须大于0</para> /// </summary> public PageEntity <AdUser> Search(String UserAccount, DateTime BabyBirthday, int State, int pageIndex, int pageSize) { PageEntity <AdUser> returnValue = new PageEntity <AdUser>(); MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdLoadAdUser = cmdLoadAdUser.Clone() as MySqlCommand; MySqlCommand _cmdGetAdUserCount = cmdGetAdUserCount.Clone() as MySqlCommand; _cmdLoadAdUser.Connection = oc; _cmdGetAdUserCount.Connection = oc; try { _cmdLoadAdUser.Parameters["@PageIndex"].Value = pageIndex * pageSize;; _cmdLoadAdUser.Parameters["@PageSize"].Value = (pageIndex + 1) * pageSize;; _cmdLoadAdUser.Parameters["@UserAccount"].Value = UserAccount; _cmdLoadAdUser.Parameters["@BabyBirthday"].Value = BabyBirthday; _cmdLoadAdUser.Parameters["@State"].Value = State; if (oc.State == ConnectionState.Closed) { oc.Open(); } MySqlDataReader reader = _cmdLoadAdUser.ExecuteReader(); while (reader.Read()) { returnValue.Items.Add(new AdUser().BuildSampleEntity(reader)); } returnValue.RecordsCount = Convert.ToInt32(_cmdGetAdUserCount.ExecuteScalar()); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdLoadAdUser.Dispose(); _cmdLoadAdUser = null; _cmdGetAdUserCount.Dispose(); _cmdGetAdUserCount = null; GC.Collect(); } return(returnValue); }
public CustomJsonResult ManageMachineGetMachineList(string operater, string merchId, RupStoreManageMachineGetMachineList rup) { var result = new CustomJsonResult(); var query = (from u in CurrentDb.MerchMachine where u.MerchId == merchId && u.StoreId == rup.StoreId select new { u.MerchId, u.MachineId, u.Name, u.StoreId, u.CreateTime }); int total = query.Count(); int pageIndex = rup.Page - 1; int pageSize = rup.Limit; query = query.OrderByDescending(r => r.CreateTime).Skip(pageSize * (pageIndex)).Take(pageSize); var list = query.ToList(); List <object> olist = new List <object>(); foreach (var item in list) { var machine = CurrentDb.Machine.Where(m => m.Id == item.MachineId).FirstOrDefault(); olist.Add(new { Id = item.MachineId, Name = item.Name, MainImgUrl = machine.MainImgUrl, Status = MerchServiceFactory.Machine.GetStatus(), CreateTime = item.CreateTime, }); } PageEntity pageEntity = new PageEntity { PageSize = pageSize, Total = total, Items = olist }; result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "", pageEntity); return(result); }
public CustomJsonResult GetTypeList(SearchCondition condition) { var list = (from u in CurrentDb.SysBannerType select new { u.Id, u.Name, u.Description, u.CreateTime }); int total = list.Count(); int pageIndex = condition.PageIndex; int pageSize = 10; list = list.OrderByDescending(r => r.CreateTime).Skip(pageSize * (pageIndex)).Take(pageSize); PageEntity pageEntity = new PageEntity { PageSize = pageSize, TotalRecord = total, Rows = list }; return(Json(ResultType.Success, pageEntity, "")); }
protected PageEditRoleEntity(SerializationInfo info, StreamingContext context) : base(info, context) { if (SerializationHelper.Optimization != SerializationOptimization.Fast) { _aspnetRole = (AspnetRolesEntity)info.GetValue("_aspnetRole", typeof(AspnetRolesEntity)); if (_aspnetRole != null) { _aspnetRole.AfterSave += new EventHandler(OnEntityAfterSave); } _page = (PageEntity)info.GetValue("_page", typeof(PageEntity)); if (_page != null) { _page.AfterSave += new EventHandler(OnEntityAfterSave); } this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance()); } // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor // __LLBLGENPRO_USER_CODE_REGION_END }
public CustomJsonResult GetList(string operater, Enumeration.BelongSite belongSite, RupSysRoleGetList rup) { var result = new CustomJsonResult(); var query = (from u in CurrentDb.SysRole where (rup.Name == null || u.Name.Contains(rup.Name)) && u.BelongSite == belongSite select new { u.Id, u.Name, u.Description, u.CreateTime, u.Priority }); int total = query.Count(); int pageIndex = rup.Page - 1; int pageSize = rup.Limit; query = query.OrderBy(r => r.Priority).Skip(pageSize * (pageIndex)).Take(pageSize); var list = query.ToList(); List <object> olist = new List <object>(); foreach (var item in list) { olist.Add(new { Id = item.Id, Name = item.Name, Description = item.Description, CreateTime = item.CreateTime.ToUnifiedFormatDateTime() }); } PageEntity pageEntity = new PageEntity { PageSize = pageSize, Total = total, Items = olist }; result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "", pageEntity); return(result); }
public CustomJsonResult GetEditList(SearchCondition condition) { string clientCode = condition.ClientCode.ToSearchString(); string yYZZ_Name = condition.YYZZ_Name.ToSearchString(); string yYZZ_RegisterNo = condition.YYZZ_RegisterNo.ToSearchString(); var query = (from m in CurrentDb.Merchant join u in CurrentDb.SysClientUser on m.UserId equals u.Id where (clientCode.Length == 0 || u.ClientCode.Contains(clientCode)) && (yYZZ_Name.Length == 0 || m.YYZZ_Name.Contains(yYZZ_Name)) && (yYZZ_RegisterNo.Length == 0 || m.YYZZ_RegisterNo.Contains(yYZZ_RegisterNo)) select new { m.Id, u.ClientCode, m.Type, m.RepairCapacity, m.Area, m.YYZZ_Name, m.FR_Name, m.ContactName, m.CreateTime }); int total = query.Count(); int pageIndex = condition.PageIndex; int pageSize = 10; query = query.OrderByDescending(r => r.CreateTime).Skip(pageSize * (pageIndex)).Take(pageSize); List <object> list = new List <object>(); foreach (var item in query) { list.Add(new { item.Id, item.ClientCode, item.YYZZ_Name, item.ContactName, Type = item.Type.GetCnName(), RepairCapacity = item.RepairCapacity.GetCnName(), item.Area, item.CreateTime }); } PageEntity pageEntity = new PageEntity { PageSize = pageSize, TotalRecord = total, Rows = list }; return(Json(ResultType.Success, pageEntity, "")); }
public JsonResult GetApplyList(CarInsureCommissionRateCondition condition) { string name = condition.Name.ToSearchString(); var query = (from b in CurrentDb.BizProcessesAudit join e in CurrentDb.CarInsureCommissionRate on b.AduitReferenceId equals e.Id where b.AduitType == Enumeration.BizProcessesAuditType.CommissionRateAudit && (name.Length == 0 || e.ReferenceName.Contains(name)) select new { e.Id, e.ReferenceName, e.Commercial, e.Compulsory, b.Status, b.CreateTime, b.JsonData }); int total = query.Count(); int pageIndex = condition.PageIndex; int pageSize = 10; query = query.OrderByDescending(r => r.CreateTime).Skip(pageSize * (pageIndex)).Take(pageSize); List <object> list = new List <object>(); foreach (var item in query) { CommissionRateAdjustModel commissionRateAdjustModel = Newtonsoft.Json.JsonConvert.DeserializeObject <CommissionRateAdjustModel>(item.JsonData); list.Add(new { item.Id, BeforeCommercial = commissionRateAdjustModel.Before.Commercial.ToPrice(), AfterCommercial = commissionRateAdjustModel.After.Commercial.ToPrice(), BeforeCompulsory = commissionRateAdjustModel.Before.Compulsory.ToPrice(), AfterCompulsory = commissionRateAdjustModel.After.Compulsory.ToPrice(), item.ReferenceName, Status = ((Enumeration.CommissionRateAuditStatus)item.Status).GetCnName(), item.CreateTime, }); } PageEntity pageEntity = new PageEntity { PageSize = pageSize, TotalRecord = total, Rows = list }; return(Json(ResultType.Success, pageEntity, "")); }
public CustomJsonResult GetListByInsurance(WebBack.Models.Biz.Product.SearchCondition condition) { // u.ProductCategoryId.ToString().StartsWith(condition.CategoryId.ToString()) && var query = (from u in CurrentDb.Product where (condition.Name == null || u.Name.Contains(condition.Name)) && u.ProductCategoryId.ToString().StartsWith("1002") select new { u.Id, u.Name, u.MainImg, u.CreateTime, u.Supplier, u.ProductCategory }); int total = query.Count(); int pageIndex = condition.PageIndex; int pageSize = 10; query = query.OrderByDescending(r => r.CreateTime).Skip(pageSize * (pageIndex)).Take(pageSize); var list1 = query.ToList(); List <object> list = new List <object>(); foreach (var item in list1) { var skus = CurrentDb.ProductSku.Where(m => m.ProductId == item.Id).ToList(); list.Add(new { Id = item.Id, Name = item.Name, MainImg = item.MainImg, Supplier = item.Supplier, ProductCategory = item.ProductCategory, CreateTime = item.CreateTime, skus = skus }); } PageEntity pageEntity = new PageEntity { PageSize = pageSize, TotalRecord = total, Rows = list }; return(Json(ResultType.Success, pageEntity, "")); }
public async Task Update( string projectId, IPage page, CancellationToken cancellationToken = default(CancellationToken) ) { if (page == null) { throw new ArgumentException("page must not be null"); } if (string.IsNullOrEmpty(page.Id)) { throw new ArgumentException("can only update an existing page with a populated Id"); } //if (string.IsNullOrEmpty(projectId)) throw new ArgumentException("projectId must be provided"); var p = PageEntity.FromIPage(page); p.LastModified = DateTime.UtcNow; bool tracking = dbContext.ChangeTracker.Entries <PageEntity>().Any(x => x.Entity.Id == p.Id); if (!tracking) { dbContext.PageResources.RemoveRange(dbContext.PageResources.Where(x => x.PageEntityId == p.Id)); dbContext.Pages.Update(p); } int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false); if (page.Resources.Count > 0) { p.Resources = page.Resources; foreach (var r in p.PageResources) { r.PageEntityId = p.Id; } rowsAffected = await dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false); } }
public JsonResult GetApplyList(ExtendedAppSearchCondition condition) { string name = condition.Name.ToSearchString(); var query = (from b in CurrentDb.BizProcessesAudit join e in CurrentDb.ExtendedApp on b.AduitReferenceId equals e.Id where (b.AduitType == Enumeration.BizProcessesAuditType.ExtendedAppOff || b.AduitType == Enumeration.BizProcessesAuditType.ExtendedAppOn || b.AduitType == Enumeration.BizProcessesAuditType.ExtendedAppRecovery) && e.Type == Enumeration.ExtendedAppType.ThirdPartyApp && (name.Length == 0 || e.Name.Contains(name)) select new { e.Id, b.AduitType, e.ImgUrl, e.LinkUrl, e.Name, b.Status, b.CreateTime }); int total = query.Count(); int pageIndex = condition.PageIndex; int pageSize = 10; query = query.OrderByDescending(r => r.CreateTime).Skip(pageSize * (pageIndex)).Take(pageSize); List <object> list = new List <object>(); foreach (var item in query) { list.Add(new { item.Id, item.ImgUrl, item.LinkUrl, AduitType = item.AduitType.GetCnName(), item.Name, Status = ((Enumeration.ExtendedAppAuditStatus)item.Status).GetCnName(), item.CreateTime, }); } PageEntity pageEntity = new PageEntity { PageSize = pageSize, TotalRecord = total, Rows = list }; return(Json(ResultType.Success, pageEntity, "")); }
public CustomJsonResult GetNotBindUsers(RoleUserSearchCondition condition) { string userName = ""; if (condition.UserName != null) { userName = condition.UserName.Trim(); } string fullName = ""; if (condition.FullName != null) { fullName = condition.FullName.Trim(); } var list = (from u in CurrentDb.SysStaffUser where !(from d in CurrentDb.SysUserRole where d.RoleId == condition.RoleId select d.UserId).Contains(u.Id) where (userName.Length == 0 || u.UserName.Contains(userName)) && (fullName.Length == 0 || u.FullName.Contains(fullName)) && u.IsDelete == false select new { u.Id, u.UserName, u.FullName }).Distinct(); int total = list.Count(); int pageIndex = condition.PageIndex; int pageSize = 10; list = list.OrderBy(r => r.Id).Skip(pageSize * (pageIndex)).Take(pageSize); PageEntity pageEntity = new PageEntity { PageSize = pageSize, TotalRecord = total, Rows = list }; return(Json(ResultType.Success, pageEntity)); }
public async Task <HttpResponseMessage> MapModuleWisePageAccessWithRole(List <ModuleWisePageAccessModel> moduleWisePageAccessModelList) { try { List <ModuleWisePageAccessEntity> listModulewisepageAccessEntity = new List <ModuleWisePageAccessEntity>(); foreach (var moduleWisePageAccessModel in moduleWisePageAccessModelList) { ModuleWisePageAccessEntity moduleWisePageAccessEntity = new ModuleWisePageAccessEntity(); moduleWisePageAccessEntity.Module = new ModuleEntity(); moduleWisePageAccessEntity.Module.ModuleId = moduleWisePageAccessModel.Module.ModuleId; moduleWisePageAccessEntity.Module.ModuleName = moduleWisePageAccessModel.Module.ModuleName; moduleWisePageAccessEntity.Role = new RoleEntity(); if (moduleWisePageAccessModel.Role != null) { if (moduleWisePageAccessModel.Role.RoleId != 0) { moduleWisePageAccessEntity.Role.RoleId = moduleWisePageAccessModel.Role.RoleId; } } foreach (var pageModel in moduleWisePageAccessModel.pageList) { PageEntity pageEntity = new PageEntity(); pageEntity.PageId = pageModel.PageId; pageEntity.PageName = pageModel.PageName; pageEntity.IsPageSelected = pageModel.IsPageSelected; moduleWisePageAccessEntity.pageList.Add(pageEntity); } listModulewisepageAccessEntity.Add(moduleWisePageAccessEntity); } BusinessFactory.CreateAccountManagementBusinessInstance().MapModuleWisePageAccessWithRole(listModulewisepageAccessEntity); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (System.Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } }
public JsonResult GetList(RetailerSearchCondition condition) { var list = (from u in CurrentDb.Retailer where (condition.Name == null || u.Name.Contains(condition.Name)) && u.IsDelete == false select new { u.Id, u.Name, u.CreateTime, u.IsDelete }); int total = list.Count(); int pageIndex = condition.PageIndex; int pageSize = 10; list = list.OrderByDescending(r => r.CreateTime).Skip(pageSize * (pageIndex)).Take(pageSize); PageEntity pageEntity = new PageEntity { PageSize = pageSize, TotalRecord = total, Rows = list }; return(Json(ResultType.Success, pageEntity, "")); }
public ActionResult EditMenu(int id, string type) { var page = new PageEntity(); var menu = new MenuEntity(); if (type.ToLower() == "page") { page = new Helpers.SystemHelper().GetPageByID(id); } else { menu = new Helpers.SystemHelper().GetMenuByID(id); } ViewBag.Page = page; ViewBag.Menu = menu; ViewBag.Type = type; return(View()); }
public async Task <Guid> Handle(CreatePageCommand request, CancellationToken cancellationToken) { var uid = Guid.NewGuid(); var page = new PageEntity { Id = uid, Title = request.Payload.Title.Trim(), Slug = request.Payload.Slug.ToLower().Trim(), MetaDescription = request.Payload.MetaDescription, CreateTimeUtc = DateTime.UtcNow, HtmlContent = request.Payload.RawHtmlContent, CssContent = request.Payload.CssContent, HideSidebar = request.Payload.HideSidebar, IsPublished = request.Payload.IsPublished }; await _pageRepo.AddAsync(page); return(uid); }
public override List <Client> GetEntitiesByPage(PageEntity pageEntity, string whereSql = null, string orderBySql = null) { if (ValidateUtil.isBlank(orderBySql)) { orderBySql = "c.ClientCode"; } List <Client> classes = new List <Client>(); DataSet ds = DB.GetDataByPage(new PageQueryEntity { PageEntity = pageEntity, TableName = string.Format(" {0} c left join {1} p on c.PayTypeID=p.PayTypeID ", TableName, PayTypeDAL.TableName), PK = "c.ClientID", Fields = "c.ClientID,c.ClientCode,c.ClientName,c.ClientTel,c.ClientAddress,c.Contactor,c.Remark,c.Receiver,c.ReceiverTel,c.BillingInfo,c.PayTypeID,p.PayTypeName PayType_Name", OrderBySql = orderBySql, WhereSql = whereSql }); if (ds.HasRow()) { foreach (DataRow row in ds.Tables[0].Rows) { classes.Add(new Client { ClientID = row["ClientID"].ToString(), ClientCode = row["ClientCode"].ToString(), ClientName = row["ClientName"].ToString(), ClientTel = row["ClientTel"].ToString(), ClientAddress = row["ClientAddress"].ToString(), Contactor = row["Contactor"].ToString(), Receiver = row["Receiver"].ToString(), ReceiverTel = row["ReceiverTel"].ToString(), BillingInfo = row["BillingInfo"].ToString(), PayTypeID = row["PayTypeID"].ToString(), PayType_Name = row["PayType_Name"].ToString(), Remark = row["Remark"].ToString() }); } } return(classes); }
public void GetListInner(bool isForHelp) { //过滤条件 //这里拼写过滤条件时,使用了很多sql,违背分层原则,为了省事儿先这样吧 string whereSql = string.Empty; string code = Context.Request["BillCode"]; if (!ValidateUtil.isBlank(code)) { whereSql += string.Format(" and BillCode like '%{0}%'", code); } string name = Context.Request["BillName"]; if (!ValidateUtil.isBlank(name)) { whereSql += string.Format(" and BillName like '%{0}%'", name); } string type = Context.Request["BillType"]; if (!ValidateUtil.isBlank(type)) { whereSql += string.Format(" and BillType = '{0}'", type); } //分页参数:easyui分页查询时,page、rows int pageIndex = 1; Int32.TryParse(Context.Request["page"], out pageIndex); int pageSize = 10; Int32.TryParse(Context.Request["rows"], out pageSize); PageEntity pageEntity = new PageEntity(pageIndex, pageSize); var users = bll.GetBillTypesByPage(pageEntity, whereSql, string.Empty, isForHelp); //easyui分页查询,要求返回json数据,并且包含total和rows string json = new { total = pageEntity.TotalRecords,//总记录数已被更新 rows = users }.SerializeToJson(); Context.Response.WriteJson(json); }
/// <summary> /// /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="count"></param> /// <param name="yybh"></param> /// <param name="qybh"></param> /// <returns></returns> public List <dynamic> GetPageList(int pageIndex, int pageSize, ref int count, string yybh, string qybh, int type) { StringBuilder strWhere = new StringBuilder(); if (!string.IsNullOrEmpty(yybh)) { strWhere.AppendFormat(" a.yybh='{0}'", yybh); } if (!string.IsNullOrEmpty(qybh)) { strWhere.AppendFormat(" and a.qybh= '{0}'", qybh); } if (type == 0) { strWhere.AppendFormat(" and b.sfqd=0"); } else { strWhere.AppendFormat(" and b.sfqd=1"); } PageEntity pageEntity = new PageEntity(); pageEntity = new PageEntity() { TableName = " dbo.pq_qysz a INNER JOIN dbo.qy_jbxx b ON a.yybh=b.yybh AND a.qybh=b.bh and b.sfqy=1 ", Fields = "a.pqbh,a.yybh,a.qybh,a.ksrq,a.jsrq,a.tqts,a.jzsj,a.xxr,a.tjrs,b.mc", PageIndex = pageIndex, PageSize = pageSize, WhereStr = strWhere.ToString(), OrderBy = "a.cjsj desc" }; var list = new PagingService().GetPage <dynamic>(pageEntity, out count); list.ForEach(x => { x.xxr = x.xxr.Replace("0", "星期日").Replace("1", "星期一").Replace("2", "星期二").Replace("3", "星期三").Replace("4", "星期四").Replace("5", "星期五").Replace("6", "星期六").Replace("|", ","); }); return(list); }
public JsonResult GetWithdrawList(Models.Biz.Withdraw.WithdrawSearchCondition condition) { var query = (from m in CurrentDb.Withdraw join u in CurrentDb.Merchant on m.MerchantId equals u.Id where m.UserId == condition.UserId select new { m.Id, m.Sn, u.ClientCode, m.Amount, m.AmountByAfterFee, m.Fee, m.SettlementStartTime, m.Status, m.CreateTime }); int pageIndex = condition.PageIndex; int pageSize = 10; query = query.OrderByDescending(r => r.CreateTime).Skip(pageSize * (pageIndex)).Take(pageSize); int total = query.Count(); List <object> olist = new List <object>(); foreach (var item in query) { olist.Add(new { item.Id, item.Sn, item.ClientCode, Amount = item.Amount.ToPrice(), AmountByAfterFee = item.AmountByAfterFee.ToPrice(), Fee = item.Fee.ToPrice(), Status = item.Status.GetCnName(), item.SettlementStartTime }); } PageEntity pageEntity = new PageEntity { PageSize = pageSize, TotalRecord = total, Rows = olist }; return(Json(ResultType.Success, pageEntity, "")); }
void VirtualSkinnedEndPoint_MergeRegion(object sender, EndPointEventArgs e) { //Get ref to BASEApp BASEApplication app = (BASEApplication)HttpContext.Current.ApplicationInstance; VirtualSkinnedEndPoint ep = (VirtualSkinnedEndPoint)sender; //Get the Page info int pageID = app.BASERequest._pageUID; PageEntity page = PageDataHelper.SelectSingle(pageID); if (page == null) { throw new ContentMergingException("Page not found. TODO: This needs to change!"); //TODO: Need to change for better handling, as well as default management } //TODO: Page entity/table needs to be modified to be preparsed just like templates. //page.HTMLContent //Grab PageRegions EntityCollection <PageRegionEntity> regions = new EntityCollection <PageRegionEntity>(); RelationPredicateBucket filter = new RelationPredicateBucket(); filter.PredicateExpression.Add(PageRegionFields.PageUID == pageID); DataAccessAdapter da = new DataAccessAdapter(); da.FetchEntityCollection(regions, filter); foreach (PageRegionEntity region in regions) { Control[] controls = new HtmlParser().ParseToControls(ep, region.RegionContent); RegionPanel regPanel = new RegionPanel(RegionPanelType.PlaceHolder); regPanel.RegionID = region.RegionId; foreach (Control c in controls) { regPanel.Controls.Add(c); } ep.RegionPanels.Add(regPanel.RegionID, regPanel); } //Add content to RegionPanel //Add region panels to RegionList }
public CustomJsonResult GetListByNoUse(SearchCondition condition) { string fuselageNumber = condition.FuselageNumber.ToSearchString(); string deviceId = condition.DeviceId.ToSearchString(); var query = (from m in CurrentDb.PosMachine where (fuselageNumber.Length == 0 || m.FuselageNumber.Contains(fuselageNumber)) && (deviceId.Length == 0 || m.DeviceId.Contains(deviceId)) && m.IsUse == false select new { m.Id, m.DeviceId, m.FuselageNumber, m.TerminalNumber, m.Version, m.CreateTime }); int total = query.Count(); int pageIndex = condition.PageIndex; int pageSize = 10; query = query.OrderByDescending(r => r.CreateTime).Skip(pageSize * (pageIndex)).Take(pageSize); List <object> list = new List <object>(); foreach (var item in query) { list.Add(new { item.Id, item.DeviceId, item.FuselageNumber, item.TerminalNumber, item.Version, item.CreateTime }); } PageEntity pageEntity = new PageEntity { PageSize = pageSize, TotalRecord = total, Rows = list }; return(Json(ResultType.Success, pageEntity, "")); }
// // GET: /CustomerManagement/Customer/ /// <summary> /// 通过销售人员ID获取销售的企业客户 /// </summary> /// <param name="ownerid"></param> /// <returns></returns> public JsonResult SearchCustomerEntByOwnerId(int pageIndex, int pageSize) { var Res = new JsonResult(); AdvancedResult <PageEntity <CustomerEnt> > result = new AdvancedResult <PageEntity <CustomerEnt> >(); if (CacheManagerFactory.GetMemoryManager().Contains(token)) { if (!CheckUserFunction(7)) { result.Error = AppError.ERROR_PERMISSION_FORBID; Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); } int ownerid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token)); try { PageEntity <CustomerEnt> list = new PageEntity <CustomerEnt>(); list = CustomerEntAccessor.Instance.SearchCustomerEntByOwnerId(ownerid, pageIndex, pageSize); result.Error = AppError.ERROR_SUCCESS; result.Data = list; } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } result.Error = AppError.ERROR_SUCCESS; } else { result.Error = AppError.ERROR_PERSON_NOT_LOGIN; } Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); }
public LayoutEntity GetByPage(PageEntity page) { LayoutEntity baseLayout = base.Get(page.LayoutId); LayoutEntity entity = new LayoutEntity { ID = baseLayout.ID, Style = baseLayout.Style, Script = baseLayout.Script, LayoutName = baseLayout.LayoutName, ContainerClass = baseLayout.ContainerClass }; IEnumerable <ZoneEntity> zones = _zoneService.GetByPage(page); entity.Zones = new ZoneCollection(); zones.Each(entity.Zones.Add); IEnumerable <LayoutHtml> htmls = _layoutHtmlService.GetByPage(page); entity.Html = new LayoutHtmlCollection(); htmls.Each(entity.Html.Add); return(entity); }
/// <summary> /// Sorts the items. /// </summary> /// <param name="pages">The full page list</param> /// <param name="parent">The current parent id</param> /// <param name="level">The level in structure</param> /// <returns>The sitemap</returns> private Sitemap Sort(IEnumerable <PageEntity> pages, PageEntity parent = null, int level = 0) { var result = new Sitemap(); foreach (var page in pages.Where(p => p.Parent == parent).OrderBy(p => p.SortOrder)) { var item = Module.Mapper.Map <PageEntity, SitemapItem>(page); if (!string.IsNullOrEmpty(page.RedirectUrl)) { item.Permalink = page.RedirectUrl; } item.Level = level; item.PageTypeName = App.PageTypes.First(t => t.Id == page.PageType.Id).Title; item.Items = Sort(pages, page, level + 1); result.Add(item); } return(result); }
private static Page EntityToPage(PageEntity entity) { if (entity is null) { return(null); } return(new() { Id = entity.Id, Title = entity.Title.Trim(), CreateTimeUtc = entity.CreateTimeUtc, CssContent = entity.CssContent, RawHtmlContent = entity.HtmlContent, HideSidebar = entity.HideSidebar, Slug = entity.Slug.Trim().ToLower(), MetaDescription = entity.MetaDescription?.Trim(), UpdateTimeUtc = entity.UpdateTimeUtc, IsPublished = entity.IsPublished }); }
public virtual async Task <_ <string> > UpdatePage(PageEntity model) { var data = new _ <string>(); var page = await this._pageRepo.GetFirstAsync(x => x.UID == model.UID); Com.AssertNotNull(page, "页面不存在"); this.UpdatePageEntity(ref page, ref model); page.Update(); if (!page.IsValid(out var msg)) { data.SetErrorMsg(msg); return(data); } if (await this._pageRepo.UpdateAsync(page) > 0) { data.SetSuccessData(string.Empty); return(data); } throw new Exception("更新页面失败"); }
// private async Task<Guid> MakeDraft(ISession session, PageEntity page, double revisionNumber, DateTime lastModified) // { // var draft = await session.Query<PageRevisionEntity>() // .FirstOrDefaultAsync(r => r.Page.Id == page.Id && r.Created > lastModified) // .ConfigureAwait(false); // string pageId = "n/a"; // pageId = page?.Id.ToString(); // if (draft == null) // { // draft = new PageRevisionEntity // { // SiteId = page.Site.Id // }; // await session.SaveAsync(draft).ConfigureAwait(false); // } // //var unproxied = session.GetSessionImplementation().PersistenceContext.Unproxy(page); // var mapped = _mapper.Map<PageEntity,PageEntity>(page); // //var mappedPageType = _mapper.Map<PageTypeEntity>(page.PageType).GetType(); // draft.Data = JsonConvert.SerializeObject(mapped); // // draft.Data = JsonConvert.SerializeObject(page); // draft.RevisionNumber = revisionNumber; // // NHibernate keeps track of changes and writes as needed. // //await _db.SaveChangesAsync().ConfigureAwait(false); // return draft.Id; // } /// <summary> /// Performs additional processing and loads related models. /// </summary> /// <param name="page">The source page</param> /// <param name="model">The targe model</param> private Task Process <T>(PageEntity page, T model) where T : PageBase { // Permissions foreach (var permission in page.Permissions) { model.Permissions.Add(permission.Permission); } // Comments model.EnableComments = page.EnableComments; if (model.EnableComments) { model.CommentCount = page.Comments.Count; ///await _db.PageComments.CountAsync(c => c.PageId == model.Id).ConfigureAwait(false); //model.CommentCount = await _db.PageComments.CountAsync(c => c.PageId == model.Id).ConfigureAwait(false); } model.CloseCommentsAfterDays = page.CloseCommentsAfterDays; // Blocks if (!(model is IContentInfo)) { if (page.Blocks.Count > 0) { foreach (var pageBlock in page.Blocks.OrderBy(b => b.SortOrder)) { if (pageBlock.Block.ParentId.HasValue) { var parent = page.Blocks.FirstOrDefault(b => b.Block.Id == pageBlock.Block.ParentId.Value); if (parent != null) { pageBlock.Block.ParentId = parent.Block.Id; } } } model.Blocks = _contentService.TransformBlocks(page.Blocks.OrderBy(b => b.SortOrder).Select(b => b.Block)); } } return(Task.CompletedTask); }
public static Page ToPage(PageEntity entity) { if (entity == null) return null; Page page = new Page(); page.Id = entity.Id; page.CreatedBy = entity.CreatedBy; page.CreatedOn = entity.CreatedOn; page.IsLocked = entity.IsLocked; page.ModifiedBy = entity.ModifiedBy; page.ModifiedOn = entity.ModifiedOn; page.Tags = entity.Tags; page.Title = entity.Title; page.ProjectStart = entity.ProjectStart; page.ProjectEnd = entity.ProjectEnd; page.ProjectEstimatedTime = entity.ProjectEstimatedTime; page.ProjectStatus = entity.ProjectStatus; page.ProjectLanguage = entity.ProjectLanguage; page.orgID = entity.orgID; return page; }
public void ToPage_ShouldFillCorrectProperties() { // Arrange PageEntity entity = new PageEntity(); entity.CreatedBy = "createdtest"; entity.CreatedOn = DateTime.UtcNow; entity.IsLocked = true; entity.ModifiedBy = "modtest"; entity.ModifiedOn = DateTime.UtcNow.AddYears(1); entity.Tags = "tag1,tag2"; entity.Title = "title1"; // Act Page page = FromEntity.ToPage(entity); // Assert Assert.That(page.CreatedBy, Is.EqualTo(entity.CreatedBy)); Assert.That(page.CreatedOn, Is.EqualTo(entity.CreatedOn)); Assert.That(page.IsLocked, Is.EqualTo(entity.IsLocked)); Assert.That(page.ModifiedBy, Is.EqualTo(entity.ModifiedBy)); Assert.That(page.ModifiedOn, Is.EqualTo(entity.ModifiedOn)); Assert.That(page.Tags, Is.EqualTo(entity.Tags)); Assert.That(page.Title, Is.EqualTo(entity.Title)); }
public void Save() { using (var context = new DataContext()) { var pageEntity = context.Pages.SingleOrDefault(x => x.PageId == PageId); if (pageEntity == null) { pageEntity = new PageEntity { PageId = PageId, PageTypeId = PageTypeId, ParentId = ParentId, RootId = RootId, SortOrder = SortIndex, TreeLevel = TreeLevel }; context.Add(pageEntity); context.SaveChanges(); } // --------------- var pageInstance = context.PageInstances.SingleOrDefault(x => x.PageInstanceId == PageInstanceId); if (pageInstance == null) { CurrentVersion = context.PageInstances.Where(x => x.PageId == PageId && x.LanguageId == LanguageId).Max(x => x.CurrentVersion) + 1; pageInstance = new PageInstanceEntity { PageId = PageId, LanguageId = LanguageId, CreatedDate = DateTime.Now.ToUniversalTime(), CurrentVersion = CurrentVersion, Status = PageInstanceStatus.WorkingCopy }; context.Add(pageInstance); } pageInstance.Author = HttpContext.Current.User.Identity.Name; pageInstance.ChildSortDirection = ChildSortDirection; pageInstance.ChildSortOrder = ChildSortOrder; pageInstance.PageName = PageName; pageInstance.StartPublish = StartPublish; pageInstance.StopPublish = StopPublish; pageInstance.UpdateDate = DateTime.Now.ToUniversalTime(); pageInstance.VisibleInMenu = VisibleInMenu; pageInstance.VisibleInSitemap = VisibleInSiteMap; EnsurePageUrl(); pageInstance.PageUrl = UrlSegment; context.SaveChanges(); PageInstanceId = pageInstance.PageInstanceId; // --------------- var pagePropertiesForPage = context.PageProperties.Where(x => x.PageId == PageId && x.LanguageId == LanguageId && x.Version == CurrentVersion).ToList(); foreach (var propertyItem in Property) { var propertyEntity = pagePropertiesForPage.Find(c => c.PropertyId == propertyItem.PropertyId); if (propertyEntity == null) { propertyEntity = new PagePropertyEntity { LanguageId = LanguageId, PageId = PageId, PropertyId = propertyItem.PropertyId, Version = CurrentVersion }; context.Add(propertyEntity); pagePropertiesForPage.Add(propertyEntity); } propertyEntity.PageData = GetSerializedPropertyValue(propertyItem); } context.SaveChanges(); } // Allow property types to execute code when a property of that type is saved foreach (var propertyItem in Property) { if (propertyItem == null) { continue; } var propertyData = propertyItem.PropertyData as IPageSavedHandler; if (propertyData != null) { propertyData.PageSaved(this); } } if (CurrentVersion == 1) { Publish(true); } PageFactory.RaisePageSaved(PageId, LanguageId, CurrentVersion); }
public PageContent AddNewPage(Page page, string text, string editedBy, DateTime editedOn, DateTime projectStart, DateTime projectEnd, bool projectEstimatedTime, string projectStatus, string projectLanguage, int orgID) { PageEntity pageEntity = new PageEntity(); ToEntity.FromPage(page, pageEntity); pageEntity.Id = 0; UnitOfWork.Add(pageEntity); UnitOfWork.SaveChanges(); PageContentEntity pageContentEntity = new PageContentEntity() { Id = Guid.NewGuid(), Page = pageEntity, Text = text, EditedBy = editedBy, EditedOn = editedOn, VersionNumber = 1, ProjectStart = projectStart, ProjectEnd = projectEnd, ProjectEstimatedTime = projectEstimatedTime, ProjectStatus = projectStatus, ProjectLanguage = projectLanguage, orgID = orgID, }; UnitOfWork.Add(pageContentEntity); UnitOfWork.SaveChanges(); PageContent pageContent = FromEntity.ToPageContent(pageContentEntity); pageContent.Page = FromEntity.ToPage(pageEntity); return pageContent; }
/// <summary> /// 根据条件分页获取指定数据 /// <param name="pageIndex">当前页</param> /// <para>索引从0开始</para> /// <param name="pageSize">每页记录条数</param> /// <para>记录数必须大于0</para> /// </summary> public PageEntity<SysUser> Search(Int32 UserId, String UserName, String Pwd, String Mobile, String Email, DateTime CreateTime, DateTime EndTime, Int32 FatherId, int pageIndex, int pageSize) { PageEntity<SysUser> returnValue = new PageEntity<SysUser>(); MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdLoadSysUser = cmdLoadSysUser.Clone() as MySqlCommand; MySqlCommand _cmdGetSysUserCount = cmdGetSysUserCount.Clone() as MySqlCommand; _cmdLoadSysUser.Connection = oc; _cmdGetSysUserCount.Connection = oc; try { _cmdLoadSysUser.Parameters["@PageIndex"].Value = pageIndex; _cmdLoadSysUser.Parameters["@PageSize"].Value = pageSize; _cmdLoadSysUser.Parameters["@UserId"].Value = UserId; _cmdLoadSysUser.Parameters["@UserName"].Value = UserName; _cmdLoadSysUser.Parameters["@Pwd"].Value = Pwd; _cmdLoadSysUser.Parameters["@Mobile"].Value = Mobile; _cmdLoadSysUser.Parameters["@Email"].Value = Email; _cmdLoadSysUser.Parameters["@CreateTime"].Value = CreateTime; _cmdLoadSysUser.Parameters["@EndTime"].Value = EndTime; _cmdLoadSysUser.Parameters["@FatherId"].Value = FatherId; if (oc.State == ConnectionState.Closed) oc.Open(); MySqlDataReader reader = _cmdLoadSysUser.ExecuteReader(); while (reader.Read()) { returnValue.Items.Add(new SysUser().BuildSampleEntity(reader)); } returnValue.RecordsCount = (int)_cmdGetSysUserCount.ExecuteScalar(); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdLoadSysUser.Dispose(); _cmdLoadSysUser = null; _cmdGetSysUserCount.Dispose(); _cmdGetSysUserCount = null; GC.Collect(); } return returnValue; }
/// <summary> /// 根据条件分页获取指定数据 /// <param name="pageIndex">当前页</param> /// <para>索引从0开始</para> /// <param name="pageSize">每页记录条数</param> /// <para>记录数必须大于0</para> /// </summary> public PageEntity<ProProductionType> Search(Int32 PTypeId, String PTypeName, Int32 UserId, int pageIndex, int pageSize) { PageEntity<ProProductionType> returnValue = new PageEntity<ProProductionType>(); MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdLoadProProductionType = cmdLoadProProductionType.Clone() as MySqlCommand; MySqlCommand _cmdLoadProProductionTypeCount = cmdLoadProProductionTypeCount.Clone() as MySqlCommand; _cmdLoadProProductionType.Connection = oc; _cmdLoadProProductionTypeCount.Connection = oc; try { _cmdLoadProProductionType.Parameters["@PageIndex"].Value = pageIndex; _cmdLoadProProductionType.Parameters["@PageSize"].Value = pageSize; _cmdLoadProProductionType.Parameters["@PTypeId"].Value = PTypeId; _cmdLoadProProductionType.Parameters["@PTypeName"].Value = PTypeName; _cmdLoadProProductionType.Parameters["@UserId"].Value = UserId; if (oc.State == ConnectionState.Closed) oc.Open(); MySqlDataReader reader = _cmdLoadProProductionType.ExecuteReader(); while (reader.Read()) { returnValue.Items.Add(new ProProductionType().BuildSampleEntity(reader)); } _cmdLoadProProductionTypeCount.Parameters["@PTypeId"].Value = PTypeId; _cmdLoadProProductionTypeCount.Parameters["@PTypeName"].Value = PTypeName; _cmdLoadProProductionTypeCount.Parameters["@UserId"].Value = UserId; returnValue.RecordsCount = (int)_cmdLoadProProductionTypeCount.ExecuteScalar(); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdLoadProProductionType.Dispose(); _cmdLoadProProductionType = null; _cmdLoadProProductionTypeCount.Dispose(); _cmdLoadProProductionTypeCount = null; GC.Collect(); } return returnValue; }
/// <summary> /// 获取产品入库单列表 /// </summary> /// <param name="pid"></param> /// <returns></returns> public AdvancedResult<PageEntity<ProProductonDetail>> SearchProductonDetailList(int pid, DateTime startTime, DateTime endTime, int pageIndex, int pageSize) { AdvancedResult<PageEntity<ProProductonDetail>> result = new AdvancedResult<PageEntity<ProProductonDetail>>(); try { PageEntity<ProProductonDetail> list = new PageEntity<ProProductonDetail>(); list = ProProductonDetailAccessor.Instance.Search(0, 0, 0, string.Empty,startTime,endTime,0,pid,pageIndex,pageSize); result.Error = AppError.ERROR_SUCCESS; result.Data = list; } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } return result; }
/// <summary> /// 根据条件分页获取指定数据 /// <param name="pageIndex">当前页</param> /// <para>索引从0开始</para> /// <param name="pageSize">每页记录条数</param> /// <para>记录数必须大于0</para> /// </summary> public PageEntity<SysFunction> Search(Int32 IdsysFunction, String FunctionName, Int32 FatherId, String Mark, String FunctionUrl, String FunctionCode, Int32 Level, int pageIndex, int pageSize) { PageEntity<SysFunction> returnValue = new PageEntity<SysFunction>(); MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdLoadSysFunction = cmdLoadSysFunction.Clone() as MySqlCommand; MySqlCommand _cmdGetSysFunctionCount = cmdGetSysFunctionCount.Clone() as MySqlCommand; _cmdLoadSysFunction.Connection = oc; _cmdGetSysFunctionCount.Connection = oc; try { _cmdLoadSysFunction.Parameters["@PageIndex"].Value = pageIndex; _cmdLoadSysFunction.Parameters["@PageSize"].Value = pageSize; _cmdLoadSysFunction.Parameters["@IdsysFunction"].Value = IdsysFunction; _cmdLoadSysFunction.Parameters["@FunctionName"].Value = FunctionName; _cmdLoadSysFunction.Parameters["@FatherId"].Value = FatherId; _cmdLoadSysFunction.Parameters["@Mark"].Value = Mark; _cmdLoadSysFunction.Parameters["@FunctionUrl"].Value = FunctionUrl; _cmdLoadSysFunction.Parameters["@FunctionCode"].Value = FunctionCode; _cmdLoadSysFunction.Parameters["@Level"].Value = Level; if (oc.State == ConnectionState.Closed) oc.Open(); MySqlDataReader reader = _cmdLoadSysFunction.ExecuteReader(); while (reader.Read()) { returnValue.Items.Add(new SysFunction().BuildSampleEntity(reader)); } returnValue.RecordsCount = (int)_cmdGetSysFunctionCount.ExecuteScalar(); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdLoadSysFunction.Dispose(); _cmdLoadSysFunction = null; _cmdGetSysFunctionCount.Dispose(); _cmdGetSysFunctionCount = null; GC.Collect(); } return returnValue; }
public Page SaveOrUpdatePage(Page page) { PageEntity entity = UnitOfWork.FindById<PageEntity>(page.Id); if (entity == null) { entity = new PageEntity(); ToEntity.FromPage(page, entity); UnitOfWork.Add(entity); UnitOfWork.SaveChanges(); page = FromEntity.ToPage(entity); } else { ToEntity.FromPage(page, entity); UnitOfWork.SaveChanges(); page = FromEntity.ToPage(entity); } return page; }
private void RemovePageWithChildPages(SiteDBContext dbContext, PageEntity entity) { dbContext.Pages.Remove(entity); var children = dbContext.Pages .Where(it => it.SiteName == entity.SiteName && it.ParentPage == entity.FullName) .ToArray(); foreach (var item in children) { RemovePageWithChildPages(dbContext, item); } }
public List<PagePermissionInfo> GetPagePermissionDetails(PageEntity obj) { SqlDataReader reader = null; try { List<KeyValuePair<string, object>> ParaMeterCollection = new List<KeyValuePair<string, object>> { new KeyValuePair<string, object>("@PageID", obj.PageID), new KeyValuePair<string, object>( "@portalID", obj.PortalID) }; SQLHandler sqlH = new SQLHandler(); List<PagePermissionInfo> lst = new List<PagePermissionInfo>(); reader = sqlH.ExecuteAsDataReader("sp_GetPagePermissionByPageID", ParaMeterCollection); while (reader.Read()) { PagePermissionInfo objPP = new PagePermissionInfo { PageID = int.Parse(reader["PageID"].ToString()), PermissionID = int.Parse(reader["PermissionID"].ToString()), RoleID = reader["RoleID"] == DBNull.Value ? "" : reader["RoleID"].ToString(), Username = reader["Username"] == DBNull.Value ? "" : reader["Username"].ToString(), IsActive = bool.Parse(reader["IsActive"].ToString()), AllowAccess = bool.Parse(reader["AllowAccess"].ToString()), AddedBy = reader["AddedBy"].ToString() }; lst.Add(objPP); } return lst; } catch (Exception e) { throw e; } finally { if (reader != null) { reader.Close(); } } }
/// <summary> /// 根据条件分页获取指定数据 /// <param name="pageIndex">当前页</param> /// <para>索引从0开始</para> /// <param name="pageSize">每页记录条数</param> /// <para>记录数必须大于0</para> /// </summary> public PageEntity<SysRoleUser> Search(Int32 SysRoleUserId, Int32 RoleId, Int32 UserId, int pageIndex, int pageSize) { PageEntity<SysRoleUser> returnValue = new PageEntity<SysRoleUser>(); MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdLoadSysRoleUser = cmdLoadSysRoleUser.Clone() as MySqlCommand; MySqlCommand _cmdGetSysRoleUserCount = cmdGetSysRoleUserCount.Clone() as MySqlCommand; _cmdLoadSysRoleUser.Connection = oc; _cmdGetSysRoleUserCount.Connection = oc; try { _cmdLoadSysRoleUser.Parameters["@PageIndex"].Value = pageIndex; _cmdLoadSysRoleUser.Parameters["@PageSize"].Value = pageSize; _cmdLoadSysRoleUser.Parameters["@SysRoleUserId"].Value = SysRoleUserId; _cmdLoadSysRoleUser.Parameters["@RoleId"].Value = RoleId; _cmdLoadSysRoleUser.Parameters["@UserId"].Value = UserId; if (oc.State == ConnectionState.Closed) oc.Open(); MySqlDataReader reader = _cmdLoadSysRoleUser.ExecuteReader(); while (reader.Read()) { returnValue.Items.Add(new SysRoleUser().BuildSampleEntity(reader)); } returnValue.RecordsCount = (int)_cmdGetSysRoleUserCount.ExecuteScalar(); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdLoadSysRoleUser.Dispose(); _cmdLoadSysRoleUser = null; _cmdGetSysRoleUserCount.Dispose(); _cmdGetSysRoleUserCount = null; GC.Collect(); } return returnValue; }
public void AddUpdatePages(PageEntity objPage) { try { PageDataProvider objProvider = new PageDataProvider(); objProvider.AddUpdatePages(objPage); } catch (Exception e) { throw e; } }
public List<PagePermissionInfo> GetPagePermissionDetails(PageEntity obj) { try { PageDataProvider objProvider = new PageDataProvider(); List<PagePermissionInfo> lst = objProvider.GetPagePermissionDetails(obj); return lst; } catch (Exception e) { throw e; } }
public void AddUpdatePages(PageEntity objPage) { SQLHandler sqlH = new SQLHandler(); SqlTransaction tran = (SqlTransaction)sqlH.GetTransaction(); try { List<KeyValuePair<string, object>> ParaMeterCollection = new List<KeyValuePair<string, object>> { new KeyValuePair<string, object>( "@PageID", objPage.PageID), new KeyValuePair<string, object>( "@PageOrder", objPage.PageOrder), new KeyValuePair<string, object>( "@PageName", objPage.PageName.ToString()), new KeyValuePair<string, object>( "@IsVisible", objPage.IsVisible), new KeyValuePair<string, object>( "@ParentID", objPage.ParentID), new KeyValuePair<string, object>( "@IconFile", objPage.IconFile.ToString()), new KeyValuePair<string, object>( "@DisableLink", objPage.DisableLink), new KeyValuePair<string, object>( "@Title", objPage.Title.ToString()), new KeyValuePair<string, object>( "@Description", objPage.Description.ToString()), new KeyValuePair<string, object>( "@KeyWords", objPage.KeyWords.ToString()), new KeyValuePair<string, object>( "@Url", objPage.Url.ToString()), new KeyValuePair<string, object>( "@StartDate", objPage.StartDate.ToString()), new KeyValuePair<string, object>( "@EndDate", objPage.EndDate.ToString()), new KeyValuePair<string, object>( "@RefreshInterval", objPage.RefreshInterval), new KeyValuePair<string, object>( "@PageHeadText", objPage.PageHeadText.ToString()), new KeyValuePair<string, object>( "@IsSecure", objPage.IsSecure), new KeyValuePair<string, object>( "@IsActive", objPage.IsActive), new KeyValuePair<string, object>( "@IsShowInFooter", objPage.IsShowInFooter), new KeyValuePair<string, object>( "@IsRequiredPage", objPage.IsRequiredPage), new KeyValuePair<string, object>( "@BeforeID", objPage.BeforeID), new KeyValuePair<string, object>( "@AfterID", objPage.AfterID), new KeyValuePair<string, object>( "@PortalID", objPage.PortalID), new KeyValuePair<string, object>( "@AddedBy", objPage.AddedBy.ToString()), new KeyValuePair<string, object>( "@IsAdmin", objPage.IsAdmin), }; int pageID = 0; pageID = sqlH.ExecuteNonQuery(tran, CommandType.StoredProcedure, "sp_AddUpdatePage", ParaMeterCollection, "@InsertedPageID"); if (pageID > 0) { // objPage.PortalID = objPage.PortalID == -1 ? 1 : objPage.PortalID; AddUpdatePagePermission(objPage.LstPagePermission, tran, pageID, objPage.PortalID, objPage.AddedBy, objPage.IsAdmin); if (!objPage.IsAdmin) { if (objPage.Mode == "A") { MenuPageUpdate(objPage.MenuList, tran, pageID); } } if (objPage.MenuList != "0") { AddUpdateSelectedMenu(objPage.MenuList, tran, pageID, objPage.ParentID, objPage.Mode, objPage.Caption, objPage.PortalID, objPage.UpdateLabel); } } tran.Commit(); } catch (SqlException sqlEx) { tran.Rollback(); throw sqlEx; } catch (Exception ex) { throw ex; } }
/// <summary> /// 根据条件分页获取指定数据 /// <param name="pageIndex">当前页</param> /// <para>索引从0开始</para> /// <param name="pageSize">每页记录条数</param> /// <para>记录数必须大于0</para> /// </summary> public PageEntity<ProProductonDetail> Search(Int32 PDId, Decimal Price, Int32 PNum, String PCode, DateTime StartTime,DateTime EndTime, Int32 UserId,Int32 PId, int pageIndex, int pageSize) { PageEntity<ProProductonDetail> returnValue = new PageEntity<ProProductonDetail>(); MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdLoadProProductonDetail = cmdLoadProProductonDetail.Clone() as MySqlCommand; MySqlCommand _cmdLoadProProductonDetailCount = cmdLoadProProductonDetailCount.Clone() as MySqlCommand; _cmdLoadProProductonDetail.Connection = oc; _cmdLoadProProductonDetailCount.Connection = oc; try { _cmdLoadProProductonDetail.Parameters["@PageIndex"].Value = pageIndex; _cmdLoadProProductonDetail.Parameters["@PageSize"].Value = pageSize; _cmdLoadProProductonDetail.Parameters["@PDId"].Value = PDId; _cmdLoadProProductonDetail.Parameters["@Price"].Value = Price; _cmdLoadProProductonDetail.Parameters["@PNum"].Value = PNum; _cmdLoadProProductonDetail.Parameters["@PCode"].Value = PCode; _cmdLoadProProductonDetail.Parameters["@UserId"].Value = UserId; _cmdLoadProProductonDetail.Parameters["@PId"].Value = PId; if (oc.State == ConnectionState.Closed) oc.Open(); if (!string.IsNullOrEmpty(StartTime.ToString("yyyy-MM-dd HH24:mm:ss")) && !string.IsNullOrEmpty(EndTime.ToString("yyyy-MM-dd HH24:mm:ss"))) { _cmdLoadProProductonDetail.CommandText = string.Format(_cmdLoadProProductonDetail.CommandText, "create_time between" + StartTime.ToString() + "and " + EndTime.ToString()); _cmdLoadProProductonDetailCount.CommandText = string.Format(_cmdLoadProProductonDetailCount.CommandText, "create_time between" + StartTime.ToString() + "and " + EndTime.ToString()); } else { _cmdLoadProProductonDetail.CommandText = string.Format(_cmdLoadProProductonDetail.CommandText,string.Empty); _cmdLoadProProductonDetailCount.CommandText = string.Format(_cmdLoadProProductonDetailCount.CommandText, string.Empty); } MySqlDataReader reader = _cmdLoadProProductonDetail.ExecuteReader(); while (reader.Read()) { returnValue.Items.Add(new ProProductonDetail().BuildSampleEntity(reader)); } _cmdLoadProProductonDetailCount.Parameters["@PDId"].Value = PDId; _cmdLoadProProductonDetailCount.Parameters["@Price"].Value = Price; _cmdLoadProProductonDetailCount.Parameters["@PNum"].Value = PNum; _cmdLoadProProductonDetailCount.Parameters["@PCode"].Value = PCode; _cmdLoadProProductonDetailCount.Parameters["@UserId"].Value = UserId; _cmdLoadProProductonDetailCount.Parameters["@PId"].Value = PId; returnValue.RecordsCount = (int)_cmdLoadProProductonDetailCount.ExecuteScalar(); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdLoadProProductonDetail.Dispose(); _cmdLoadProProductonDetail = null; _cmdLoadProProductonDetailCount.Dispose(); _cmdLoadProProductonDetailCount = null; GC.Collect(); } return returnValue; }
/// <summary> /// 根据分类获取产品列表 /// </summary> /// <param name="typeid"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public AdvancedResult<PageEntity<ProProduction>> SearchProductionSByType(string pName,int typeid,int pageIndex,int pageSize) { AdvancedResult<PageEntity<ProProduction>> result = new AdvancedResult<PageEntity<ProProduction>>(); try { PageEntity<ProProduction> list = new PageEntity<ProProduction>(); list = ProProductionAccessor.Instance.Search(pName,typeid,0, pageIndex, pageSize); result.Error = AppError.ERROR_SUCCESS; result.Data =list; } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } return result; }
/// <summary> /// 根据用户获取分类列表 /// </summary> /// <param name="userid"></param> /// <returns></returns> public AdvancedResult<PageEntity<ProProductionType>> SearchProductTypeListByuserID(int userid,int pageIndex,int pageSize) { AdvancedResult<PageEntity<ProProductionType>> result = new AdvancedResult<PageEntity<ProProductionType>>(); try { PageEntity<ProProductionType> list = new PageEntity<ProProductionType>(); list = ProProductionTypeAccessor.Instance.Search(0, string.Empty, userid, pageIndex,pageSize); result.Error = AppError.ERROR_SUCCESS; result.Data = list; } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } return result; }