Exemplo n.º 1
0
 public CreateTemplateCode CreateNodeTemplate(Guid uid, string name, string description, string key,
                                              Guid needsInterface,
                                              Guid providesInterface, bool defaultCreated, bool isReadable, bool isReadableFixed, bool isWriteable,
                                              bool isWriteableFixed, Base.Templates.NodeDataType dataType, int maxInstances, bool isAdapterInterface)
 {
     return(CreateNodeTemplate(uid, name, description, key, needsInterface, providesInterface, defaultCreated,
                               isReadable, isReadableFixed, isWriteable, isWriteableFixed, dataType, maxInstances, isAdapterInterface,
                               true));
 }
Exemplo n.º 2
0
        public CreateTemplateCode CreateNodeTemplate(Guid uid, string name, string description, string key,
                                                     Guid needsInterface,
                                                     Guid providesInterface, bool defaultCreated, bool isReadable, bool isReadableFixed, bool isWriteable,
                                                     bool isWriteableFixed, Base.Templates.NodeDataType dataType, int maxInstances, bool isAdapterInterface, bool deleteAble)
        {
            try
            {
                var nodeTemplate = Db.NodeTemplates.SingleOrDefault(p => p.ObjId == uid);
                var retValue     = CreateTemplateCode.Updated;

                bool isNewObject = false;
                if (nodeTemplate == null)
                {
                    isNewObject        = true;
                    nodeTemplate       = new NodeTemplate();
                    nodeTemplate.ObjId = uid;
                    retValue           = CreateTemplateCode.Created;
                }

                nodeTemplate.Name        = name;
                nodeTemplate.Description = description;
                nodeTemplate.Key         = key;
                nodeTemplate.This2DefaultMobileVisuTemplate  = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label);
                nodeTemplate.NeedsInterface2InterfacesType   = needsInterface;
                nodeTemplate.ProvidesInterface2InterfaceType = providesInterface;
                nodeTemplate.DefaultCreated     = defaultCreated;
                nodeTemplate.IsReadable         = isReadable;
                nodeTemplate.IsReadableFixed    = isReadableFixed;
                nodeTemplate.IsWriteable        = isWriteable;
                nodeTemplate.IsWriteableFixed   = isWriteableFixed;
                nodeTemplate.This2NodeDataType  = (long)dataType;
                nodeTemplate.MaxInstances       = maxInstances;
                nodeTemplate.IsAdapterInterface = isAdapterInterface;
                nodeTemplate.IsDeleteable       = deleteAble;

                if (isNewObject)
                {
                    Db.NodeTemplates.Add(nodeTemplate);
                }
                else
                {
                    Db.NodeTemplates.Update(nodeTemplate);
                }

                return(retValue);
            }
            catch (Exception e)
            {
                SystemLogger.Instance.LogError($"Could not create node template {uid}-{name}.{key} {e}");

                throw;
            }
        }
        public CreateTemplateCode CreateNodeTemplate(Guid uid, string name, string description, string key, Guid needsInterface, Guid providesInterface,
                                                     bool defaultCreated, bool isReadable, bool isReadableFixed, bool isWriteable, bool isWriteableFixed, Base.Templates.NodeDataType dataType,
                                                     int maxInstances, bool isAdapterInterface, bool deleteAble)
        {
            var nodeTemplate = new NodeTemplate
            {
                ObjId       = uid,
                Name        = name,
                Description = description,
                Key         = key,
                This2DefaultMobileVisuTemplate =
                    VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label),
                NeedsInterface2InterfacesType   = needsInterface,
                ProvidesInterface2InterfaceType = providesInterface,
                DefaultCreated     = defaultCreated,
                IsReadable         = isReadable,
                IsReadableFixed    = isReadableFixed,
                IsWriteable        = isWriteable,
                IsWriteableFixed   = isWriteableFixed,
                This2NodeDataType  = (long)dataType,
                MaxInstances       = maxInstances,
                IsAdapterInterface = isAdapterInterface,
                IsDeleteable       = deleteAble
            };



            _nodeTemplates.Add(uid, nodeTemplate);
            return(CreateTemplateCode.Created);
        }