using iWareCommon.Common.Service; using iWareCommon.Utils; using iWareDataCore.BASE.Dao; using iWareDataCore.BASE.Entity; using iWareDataCore.ORM; using iWareDataCore.Properties; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace iWareDataCore.BASE.Service { public class EmptyPlaceViewService : CommonService { private static object Lock = new object(); private EmptyPlaceViewService() : base(EmptyPlaceViewDao.GetInstance()) { } private static EmptyPlaceViewService Instance = null; /// /// 获取单例的方法 /// /// 角色服务的单例实体 public static EmptyPlaceViewService GetInstance() { if (Instance == null) { lock (Lock) { if (Instance == null) { Instance = new EmptyPlaceViewService(); } } } return Instance; } /// /// 批量修改物料状态 /// /// 需要修改的物料id列表 /// 状态:1为启用,0为锁定 /// 异常错误消息 /// 修改的物料数量 public int ChangeStatus(List ids, int status, out string msg) { msg = ""; using (var dbModel = new DbModelCore()) { try { var ones = dbModel.BASEMaterials.Where(x => ids.Contains(x.id)).ToList(); foreach (var one in ones) { one.status = status; } dbModel.SaveChanges(); return ones.Count; } catch (Exception ex) { msg = ex.Message; LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "ChangeStatus", ex.Message); return -1; } } } } }