1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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<EmptyPlaceViewEntity, BASEEmptyPlaceView, DbModelCore>
    {
 
        private static object Lock = new object();
 
        private EmptyPlaceViewService() : base(EmptyPlaceViewDao.GetInstance()) { }
 
        private static EmptyPlaceViewService Instance = null;
 
        /// <summary>
        /// 获取单例的方法
        /// </summary>
        /// <returns>角色服务的单例实体</returns>
        public static EmptyPlaceViewService GetInstance()
        {
 
            if (Instance == null)
            {
                lock (Lock)
                {
                    if (Instance == null)
                    {
                        Instance = new EmptyPlaceViewService();
                    }
                }
            }
            return Instance;
        }
 
 
 
        /// <summary>
        /// 批量修改物料状态
        /// </summary>
        /// <param name="ids">需要修改的物料id列表</param>
        /// <param name="status">状态:1为启用,0为锁定</param>
        /// <param name="msg">异常错误消息</param>
        /// <returns>修改的物料数量</returns>
        public int ChangeStatus(List<int> 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;
                }
            }
        }
 
        
 
    }
}