示例#1
0
        public void deleteMessageCatalog(int id)
        {
            DBHelper._MessageCatalog dbhelp = new DBHelper._MessageCatalog();
            MessageCatalog           existingMessageCatalog = dbhelp.GetByid(id);

            dbhelp.Delete(existingMessageCatalog);
        }
示例#2
0
        private MessageCatalog generateMessageCatalogForTest(int messageCatalogId)
        {
            MessageCatalog mc = new MessageCatalog();

            mc.Id = messageCatalogId;

            switch (messageCatalogId)
            {
            case 79:
                mc.Name = "Message102";
                mc.MonitorFrequenceInMinSec = 10000;
                break;

            case 84:
                mc.Name = "OPCUA-Msg-Temperature_C";
                mc.MonitorFrequenceInMinSec = 10000;
                break;

            case 85:
                mc.Name = "ICP_DAS-UA5231";
                mc.MonitorFrequenceInMinSec = 15000;
                break;

            default:
                throw new ArgumentException();
            }

            mc.MessageElement   = generateMessageElementList(messageCatalogId);
            mc.EventRuleCatalog = generateEventRuleCatalogList(messageCatalogId);
            return(mc);
        }
示例#3
0
        public void Init()
        {
            var catalog = new MessageCatalog(new Collection <MessageEntry>
            {
                new MessageEntry(typeof(Message1), typeof(MockMessageHandler <Message1>))
            });

            _dispatcher = new MessageDispatcher(new MessageHandlerFactory(catalog));
        }
示例#4
0
        public void Init()
        {
            var catalog = new MessageCatalog(new Collection <MessageEntry>
            {
                new MessageEntry(typeof(Message1), typeof(MockMessageHandler <Message1>)),
                new MessageEntry(typeof(Message2), typeof(MockReusableMessageHandler <Message2>))
            });

            _factory = new MessageHandlerFactory(catalog);
        }
示例#5
0
        public void updateMessageCatalog(int id, Edit messageCatalog)
        {
            DBHelper._MessageCatalog dbhelp = new DBHelper._MessageCatalog();
            MessageCatalog           existingMessageCatalog = dbhelp.GetByid(id);

            existingMessageCatalog.Name             = messageCatalog.Name;
            existingMessageCatalog.CompanyID        = messageCatalog.CompanyId;
            existingMessageCatalog.Description      = messageCatalog.Description;
            existingMessageCatalog.ChildMessageFlag = messageCatalog.ChildMessageFlag;

            dbhelp.Update(existingMessageCatalog);
        }
示例#6
0
        public Detail getMessageCatalogById(int id)
        {
            DBHelper._MessageCatalog dbhelp         = new DBHelper._MessageCatalog();
            MessageCatalog           messageCatalog = dbhelp.GetByid(id);

            return(new Detail()
            {
                Id = messageCatalog.Id,
                Name = messageCatalog.Name,
                Description = messageCatalog.Description,
                ChildMessageFlag = messageCatalog.ChildMessageFlag
            });
        }
示例#7
0
        public void addMessageCatalog(Edit messageCatalog)
        {
            DBHelper._MessageCatalog dbhelp = new DBHelper._MessageCatalog();
            var newMessageCatalog           = new MessageCatalog()
            {
                Name             = messageCatalog.Name,
                CompanyID        = messageCatalog.CompanyId,
                Description      = messageCatalog.Description,
                ChildMessageFlag = messageCatalog.ChildMessageFlag,
                DeletedFlag      = false
            };

            dbhelp.Add(newMessageCatalog);
        }
示例#8
0
        public void DeleteById(int id)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                MessageCatalog existingData = dbEntity.MessageCatalog.Find(id);
                if (existingData == null)
                {
                    throw new CDSException(10701);
                }

                dbEntity.MessageCatalog.Remove(existingData);
                dbEntity.SaveChanges();
            }
        }
示例#9
0
        public void addMessageCatalog(Edit messageCatalog)
        {
            DBHelper._MessageCatalog dbhelp = new DBHelper._MessageCatalog();
            var newMessageCatalog           = new MessageCatalog()
            {
                Name        = messageCatalog.Name,
                CompanyID   = messageCatalog.CompanyId,
                Description = messageCatalog.Description,
                MonitorFrequenceInMinSec = (int)messageCatalog.MonitorFrequenceInMinSec,
                ChildMessageFlag         = messageCatalog.ChildMessageFlag
            };

            dbhelp.Add(newMessageCatalog);
        }
示例#10
0
        public int Create(int companyId, Format_Create parseData)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                MessageCatalog newData = new MessageCatalog();
                newData.CompanyID   = companyId;
                newData.Name        = parseData.Name;
                newData.Description = parseData.Description ?? "";
                newData.MonitorFrequenceInMinSec = parseData.MonitorFrequenceInMinSec;
                newData.ChildMessageFlag         = parseData.ChildMessageFlag;

                dbEntity.MessageCatalog.Add(newData);
                dbEntity.SaveChanges();
                return(newData.Id);
            }
        }
示例#11
0
        public Template GetMessageCatalogTemplate(int messageId, string iotHubDeviceId)
        {
            DBHelper._MessageCatalog dbhelp     = new DBHelper._MessageCatalog();
            MessageCatalog           msgCatalog = dbhelp.GetByid(messageId);

            dynamic msgCatalogPayload = new ExpandoObject();

            GetMessageCatalogPayload(messageId, msgCatalog.CompanyID, iotHubDeviceId, ref msgCatalogPayload, "");

            Template template = new Template();

            template.MessageId      = messageId;
            template.MessageName    = msgCatalog.Name;
            template.MessagePayload = msgCatalogPayload;

            return(template);
        }
示例#12
0
        public Format_Detail GetById(int id)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                MessageCatalog existingData = (from c in dbEntity.MessageCatalog.AsNoTracking()
                                               where c.Id == id
                                               select c).SingleOrDefault <MessageCatalog>();
                if (existingData == null)
                {
                    throw new CDSException(10701);
                }

                return(new Format_Detail()
                {
                    Id = existingData.Id,
                    Name = existingData.Name,
                    Description = existingData.Description,
                    MonitorFrequenceInMinSec = existingData.MonitorFrequenceInMinSec,
                    ChildMessageFlag = existingData.ChildMessageFlag
                });
            }
        }
示例#13
0
 protected virtual IMessageCatalog CreateMessageCatalog()
 {
     return(MessageCatalog = new MessageCatalog());
 }