Пример #1
0
            public void AddEquipment(int id, int cost, int level, string name, string description = "", int accessLevel = 0)
            {
                TEquipment equipment = new TEquipment(id, cost, level, name, description, accessLevel);

                EquipmentList.Add(equipment);
            }
Пример #2
0
        /// <summary>
        /// 初始化数据库
        /// </summary>
        private static void InitializeDB()
        {
            BLL.TLocation.EmptyData();
            BLL.TManufacture.EmptyData();
            BLL.TManufactureWorkpiece.EmptyData();
            BLL.TEquipment.EmptyData();
            BLL.TWorkpiece.EmptyData();
            BLL.TWorkpieceProcess.EmptyData();
            BLL.TSetting.EmptyData();
            if (!BLL.SettingExist(AdminID, "MacIP"))
            {
                string[] array = { "192.168.1.120", "192.168.1.121", "192.168.1.122", "192.168.1.123", "192.168.1.124" };
                BLL.SettingAdd(AdminID, "MacIP", string.Join(";", array));
            }
            if (!BLL.SettingExist(AdminID, "RFIDIP"))
            {
                string[] array = { "192.168.1.131", "192.168.1.132", "192.168.1.133", "192.168.1.134", "192.168.1.135", "192.168.1.136", "192.168.1.137", "192.168.1.138", "192.168.1.139" };
                BLL.SettingAdd(AdminID, "RFIDIP", string.Join(";", array));
            }
            var location = new TLocation
            {
                Name        = LocationName,
                Type        = "默认", //EnumHelper.GetName(TLocation.EnumType.默认),
                State       = "正常", //EnumHelper.GetName(TLocation.EnumState.正常),
                Description = LocationName,
            };

            BLL.TLocation.Insert(location, AdminID);
            LocationID = location.ID;
            BLL.SettingAdd(AdminID, "SelectedLocation", LocationID, "TLocation");
            var wps = Enum.GetValues(typeof(EnumWorkpiece)).Cast <EnumWorkpiece>().ToArray();

            string[] wpDescriptions = { "小圆", "中圆", "大圆", "底座", "装配成品" };
            for (int i = 0; i < wps.Length; i++)
            {
                var workpiece = new TWorkpiece
                {
                    LocationID  = LocationID,
                    Name        = Enum.GetName(typeof(EnumWorkpiece), wps[i]),
                    Type        = "默认", //EnumHelper.GetName(TWorkpiece.EnumType.默认),
                    State       = "正常", //EnumHelper.GetName(TWorkpiece.EnumState.正常),
                    Description = wpDescriptions[i],
                };
                BLL.TWorkpiece.Insert(workpiece, AdminID);
                WorkpieceIDs.Add(wps[i], workpiece.ID);
            }
            var manufacture = new TManufacture
            {
                LocationID  = LocationID,
                Name        = ManufactureName,
                Type        = "默认", //EnumHelper.GetName(TManufacture.EnumType.默认),
                State       = "停止", //EnumHelper.GetName(TManufacture.EnumState.停止),
                Description = ManufactureName,
                WorkpieceID = WorkpieceIDs[EnumWorkpiece.E],
            };

            BLL.TManufacture.Insert(manufacture, AdminID);
            ManufactureID = manufacture.ID;
            foreach (var wpid in WorkpieceIDs.Values.ToArray())
            {
                var mw = new TManufactureWorkpiece
                {
                    ManufactureID = manufacture.ID,
                    WorkpieceID   = wpid,
                    IsAllowed     = true,
                };
                BLL.TManufactureWorkpiece.Insert(mw, AdminID);
            }
            var jc1 = new TEquipment
            {
                Name          = "车床",
                Type          = "机床", //EnumHelper.GetName(TEquipment.EnumType.机床),
                State         = "停止", //EnumHelper.GetName(TEquipment.EnumState.停止),
                Description   = "IP地址:192.168.1.121",
                ManufactureID = manufacture.ID,
            };

            BLL.TEquipment.Insert(jc1, AdminID);
            var jc2 = new TEquipment
            {
                Name          = "高速钻工中心",
                Type          = "机床", //EnumHelper.GetName(TEquipment.EnumType.机床),
                State         = "停止", //EnumHelper.GetName(TEquipment.EnumState.停止),
                Description   = "IP地址:192.168.1.122",
                ManufactureID = manufacture.ID,
            };

            BLL.TEquipment.Insert(jc2, AdminID);
            var jc3 = new TEquipment
            {
                Name          = "铣床",
                Type          = "机床", //EnumHelper.GetName(TEquipment.EnumType.机床),
                State         = "停止", //EnumHelper.GetName(TEquipment.EnumState.停止),
                Description   = "IP地址:192.168.1.123",
                ManufactureID = manufacture.ID,
            };

            BLL.TEquipment.Insert(jc3, AdminID);
            var jc4 = new TEquipment
            {
                Name          = "五轴加工中心",
                Type          = "机床", //EnumHelper.GetName(TEquipment.EnumType.机床),
                State         = "停止", //EnumHelper.GetName(TEquipment.EnumState.停止),
                Description   = "IP地址:192.168.1.124",
                ManufactureID = manufacture.ID,
            };

            BLL.TEquipment.Insert(jc4, AdminID);
        }