public OpResult Publish(int verId, short state, bool forced) { var obj = Get(verId); if (obj != null) { obj.VerStatus = state; var list = ProductPublishVerRepository.GetQuery(o => o.ProductId == obj.ProductId && o.PublishId != obj.PublishId).ToList(); list.Where(o => o.VerStatus == obj.VerStatus).Each(o => o.Status = 2); if (state == 1)//测试 { obj.PublishDT = DateTime.Now; obj.PublishUID = CurrentUser.UID; obj.Status = 1; obj.Forced = forced; var source = list.OrderByDescending(o => o.VerCode).FirstOrDefault(o => o.VerCode > 0); if (source == null) { obj.VerCode = 1; } else { obj.VerCode = source.VerCode + 0.1m; } } obj.CompanyCount = CompanyAuthorizeRepository.GetQuery(o => o.OpenVersionId == obj.ProductId && o.Status == 1).Count(); ProductPublishSqlRepository.SaveChanges(); return(OpResult.Success()); } return(OpResult.Fail()); }
public OpResult SaveData(Entity.ProductPublishSql obj) { if (obj.Id == 0) { obj.CreateDT = DateTime.Now; obj.CreateUID = CurrentUser.UID; obj.RunSort = ProductPublishSqlRepository.GetMaxInt(o => (int?)o.RunSort, whereLambda: o => o.PublishId == obj.PublishId); ProductPublishSqlRepository.Add(obj, false); } else { var menu = ProductPublishSqlRepository.Get(obj.Id); if (ProductPublishSqlRepository.IsExists(o => o.MenuId == obj.MenuId && o.PublishId == menu.PublishId && o.Id != obj.Id)) { return(OpResult.Fail("该菜单模块已存在")); } menu.RunSql = obj.RunSql; } var menuModelId = System.Web.HttpContext.Current.Request["menuModelId"]; if (obj.PublishId > 0 && !menuModelId.IsNullOrEmpty()) { var ver = Get(obj.PublishId); if (ver != null) { ver.MenuModuleId = menuModelId; ver.RunSqlWay = System.Web.HttpContext.Current.Request["runSqlWay"].ToType <short>(); ver.UpdateDT = DateTime.Now; ver.UpdateUID = CurrentUser.UID; } } ProductPublishSqlRepository.SaveChanges(); return(OpResult.Success()); }
public void MoveItem(short mode, int sn, int verId) { var list = ProductPublishSqlRepository.GetQuery(o => o.PublishId == verId).OrderBy(o => o.RunSort).ToList(); var obj = list.FirstOrDefault(o => o.MenuId == sn); switch (mode) { case 2: //下移 var obj1 = list.LastOrDefault(); if (obj.Id != obj1.Id) { Entity.ProductPublishSql next = null; for (var i = 0; i < list.Count; i++) { if (obj.Id == list[i].Id) { next = list[i + 1]; break; } } if (next != null) { var sort = obj.RunSort; obj.RunSort = next.RunSort; next.RunSort = sort; ProductPublishSqlRepository.SaveChanges(); } } break; default: //上移 var obj2 = list.FirstOrDefault(); if (obj.Id != obj2.Id) { Entity.ProductPublishSql prev = null; for (var i = 0; i < list.Count; i++) { if (obj.Id == list[i].Id) { prev = list[i - 1]; break; } } if (prev != null) { var sort = obj.RunSort; obj.RunSort = prev.RunSort; prev.RunSort = sort; ProductPublishSqlRepository.SaveChanges(); } } break; } }