예제 #1
0
        /// <summary>
        /// Edits the element.
        /// </summary>
        /// <param name="elementId">The element identifier.</param>
        /// <param name="elementDefinition">The element definition.</param>
        public void EditElement(Guid elementId, IElementDefinitionEdit elementDefinition)
        {
            IElementEntry entry = null;

            using (var transaction = uow.BeginTransaction())
            {
                entry             = engineRepository.GetElementById(elementId);
                entry.Name        = elementDefinition.Name;
                entry.Description = elementDefinition.Description;

                foreach (var inputProperty in elementDefinition.InputProperties)
                {
                    var entryProperty = entry.InputProperties.FirstOrDefault(p => p.Key == inputProperty.Key);
                    var data          = GetPopertyDataValue(entryProperty);
                    data.ReadFromStringValue(inputProperty.Value.Base64Decode());
                    entryProperty.Value = data.WriteToStringValue();
                }

                foreach (var outputProperties in elementDefinition.OutputProperties)
                {
                    var entryProperty = entry.OutputProperties.FirstOrDefault(p => p.Key == outputProperties.Key);
                    var data          = GetPopertyDataValue(entryProperty);
                    data.ReadFromStringValue(outputProperties.Value.Base64Decode());
                    entryProperty.Value = data.WriteToStringValue();
                }

                if (elementDefinition.ParentModuleId != null && elementDefinition.ParentModuleId != entry.ParentModule?.Id)
                {
                    var parentModule = engineRepository.GetModuleById((Guid)elementDefinition.ParentModuleId);
                    entry.ParentModule = parentModule;
                }

                engineRepository.UpdateElement(entry);
            }
        }
예제 #2
0
        /// <summary>
        /// Creates the new element.
        /// </summary>
        /// <param name="elementDefinition">The element definition.</param>
        /// <returns></returns>
        /// <exception cref="EngineException">
        /// Error creating new element. The parent task not exists.
        /// or
        /// Error creating new element. The element type not exists.
        /// </exception>
        public Guid CreateNewElement(IElementDefinitionCreate elementDefinition)
        {
            IElementEntry elementEntry = null;

            using (var transaction = uow.BeginTransaction())
            {
                // Load parent task
                var taskEntry = engineRepository.GetTaskById(elementDefinition.ParentTaskId);

                // Check if parent task exists
                if (taskEntry == null)
                {
                    throw new EngineException(logger, "Error creating new element. The parent task not exists.");
                }

                // get the engine element
                IEngineElement engineElement = GetEngineElement(elementDefinition.ElementTypeKey);

                // Get the right entry model for this engine element type
                elementEntry = (IElementEntry)engineElement.GetEmptyEntity();

                // Populate the entry element whit data provided by user
                elementEntry.ParentTask  = taskEntry;
                elementEntry.Name        = elementDefinition.Name;
                elementEntry.Description = elementDefinition.Description;
                elementEntry.IsEnabled   = true;

                // create the element in db
                engineRepository.CreateElement(elementEntry);
            }

            return(elementEntry.Id);
        }
예제 #3
0
        public ElementsLinkEntry(IElementEntry previuousElement, IElementEntry nextElement)
        {
            Key         = "ElementsLink";
            Name        = "ElementsLink";
            Description = "This element is the link between two different elements.";

            Previuous = previuousElement;
            Next      = nextElement;
            Mappings  = new List <IElementsMappingEntry>();
        }
예제 #4
0
        public Guid UpdateElement(IElementDefinitionCreate elementDefinition)
        {
            IElementEntry elementEntry = null;

            using (var transaction = uow.BeginTransaction())
            {
                elementEntry = engineRepository.GetElementById(elementDefinition.Id);
                // Populate the entry element whit data provided by user
                elementEntry.Name        = elementDefinition.Name;
                elementEntry.Description = elementDefinition.Description;
                elementEntry.IsEnabled   = true;

                // update the element in db
                engineRepository.UpdateElement(elementEntry);
            }

            return(elementEntry.Id);
        }
예제 #5
0
 public void DeleteLogicallyElement(IElementEntry elementEntry)
 {
     base.DeleteLogically((ElementEntry)elementEntry);
 }
예제 #6
0
 public void UpdateElement(IElementEntry elementEntry)
 {
     base.Update((ElementEntry)elementEntry);
 }
예제 #7
0
 public void CreateElement(IElementEntry entityToCreate)
 {
     base.Create((ElementEntry)entityToCreate);
 }