Example #1
0
        public static void Update(MessageDataObject mdo)
        {
            var list = new List <Dictionary <string, object> >();

            foreach (var d in mdo.Data)
            {
                MdciService.MesRepository.DbContext.Updateable(d.Value).AS($"{mdo.DestModule}").ExecuteCommand();
            }
        }
        /// <summary>
        /// Update deviceinfo
        /// </summary>
        /// <param name="mdo"></param>
        public static void Update(MessageDataObject mdo)
        {
            var entityList = new List <Dictionary <string, object> >();

            foreach (var d in mdo.Data)
            {
                foreach (var p in d.Value)
                {
                    int propertyId = 0;

                    if (!BdciService.DevicePropertyDefineMap.ContainsKey(mdo.ModuleName))
                    {
                        BdciService.DevicePropertyDefineMap[mdo.ModuleName] = new Dictionary <string, DevicePropertyDefine>();
                    }

                    if (BdciService.DevicePropertyDefineMap[mdo.ModuleName].ContainsKey(p.Key))
                    {
                        propertyId = BdciService.DevicePropertyDefineMap[mdo.ModuleName][p.Key].Id;
                    }
                    else
                    {
                        var dp = new DevicePropertyDefine
                        {
                            ModuleName = mdo.ModuleName,
                            Name       = p.Key
                        };

                        propertyId = BdciService.BcRepository.DbContext.Insertable <DevicePropertyDefine>(dp).ExecuteReturnEntity().Id;
                        BdciService.DevicePropertyDefineMap[mdo.ModuleName][p.Key] = new DevicePropertyDefine
                        {
                            Id         = propertyId,
                            ModuleName = mdo.DestModule,
                            Name       = p.Key
                        };
                    }

                    var entity = new Dictionary <string, object>
                    {
                        ["CreateTime"]     = mdo.CreateTime,
                        ["PlantId"]        = mdo.PlantId,
                        ["AssemblyLineId"] = mdo.AssemblyLineId,
                        ["DeviceId"]       = d.Key,
                        ["PropertyId"]     = propertyId,
                        ["PropertyValue"]  = p.Value
                    };

                    entityList.Add(entity);
                }
            }

            //BdciService.BcRepository.DbContext.Insertable(entityList).AS($"DEV_{mdo.DestModule}").ExecuteCommand();
            BdciService.BcRepository.DbContext.Updateable(entityList).AS($"REL_{mdo.DestModule}").ExecuteCommand();
        }
Example #3
0
        /// <summary>
        /// 初始化进程间消息通信对象
        /// </summary>
        /// <param name="destModule">目标模块</param>
        /// <param name="actionName">Action名称</param>
        /// <returns></returns>
        protected MessageDataObject InitMessageObject(string destModule, string actionName)
        {
            var obj = new MessageDataObject
            {
                ModuleName     = SysConf.ModuleName,
                DestModule     = destModule,
                ActionName     = actionName,
                ServiceName    = ServiceName,
                PlantId        = SysConf.Main.Plant.Id,
                AssemblyLineId = SysConf.Main.AssemblyLine.Id
            };

            return(obj);
        }