// Get the Root Assemblies
        public List <TabItem> GetRootAssemblies(bool isPart = true)
        {
            var items = new List <TabItem>();

            var RootConfigs = (from c in dataContext.Configurations
                               where c.IsRoot.HasValue && c.IsRoot.Value && !string.IsNullOrEmpty(c.ConfigurationName)
                               orderby c.Id descending
                               select c).ToList();

            foreach (var rootConfig in RootConfigs)
            {
                //if(rootConfig.Id == 1)
                //{
                var rootNode = ConvertEntities.GetNodeFromEntity(rootConfig, null, isPart);
                rootNode.Level = 1;
                List <Node> display = new List <Node>();
                LoadData(display, rootNode);
                var tabitem = new TabItem()
                {
                    Header  = rootConfig.ConfigurationName,
                    Id      = rootConfig.Id.Value,
                    Content = LoadData(rootNode, isPart),
                };
                items.Add(tabitem);
                // }
            }
            return(items);
        }
 private void ExportJsonTask(object obj)
 {
     try
     {
         ClearMessage();
         var msg = ConvertEntities.GetJsonForNode(SelectedTab.Content);
         SuccessMessage = $"Exported to location {msg}";
     }
     catch (Exception ex)
     {
         ErrorMessage = ex.Message;
     }
 }
        // Update Visibility
        public void UpdateTabItemVisibilty(Node node, bool isPart = true, bool isFile = true)
        {
            if (node == null)
            {
                return;
            }

            if (node.IsParent)
            {
                foreach (Node n in node.ChildNodes)
                {
                    UpdateTabItemVisibilty(n, isPart, isFile);
                }
            }

            ConvertEntities.UpdateNodeVisibility(node, isPart, isFile);
        }
        private void LoadData(List <Node> children, Node parent, bool isPart = true)
        {
            if (children == null)
            {
                return;
            }

            if (parent == null)
            {
                return;
            }

            var boms = (from b in dataContext.Boms
                        where b.ParentConfigIndex == parent.Id
                        select b).ToList();

            if (boms == null || boms.Count == 0)
            {
                children.Add(parent);
            }

            foreach (var bom in boms)
            {
                var config = (from c in dataContext.Configurations
                              where (!c.IsRoot.HasValue || !c.IsRoot.Value) && c.Id == bom.ChildConfigIndex
                              select c).FirstOrDefault();

                if (config != null)
                {
                    var node = ConvertEntities.GetNodeFromEntity(config, bom, isPart);

                    if (node != null)
                    {
                        node.Level      = parent.Level + 1;
                        node.ParentNode = parent;
                        LoadData(children, node);
                        children.Add(node);
                    }
                }
            }
        }
 /// <summary>
 /// Default constructor.
 /// </summary>
 public AuthorizationHandler()
 {
     this.convertEntities = new ConvertEntities();
 }
 /// <summary>
 /// This constructor will construct the BaseManager and instantiate it's properties.
 /// </summary>
 protected BaseManager()
 {
     Validation = new Validation();
     ConvertEntities = new ConvertEntities();
 }
 /// <summary>
 /// This constructor will construct the BaseManager and instantiate it's properties.
 /// The IValidation property is set to the given value.
 /// </summary>
 /// <param name="validation">IValidation to be set.</param>
 protected BaseManager(IValidation validation)
 {
     Validation = validation;
     ConvertEntities = new ConvertEntities();
 }
 /// <summary>
 /// This constructor will construct the BaseManager and instantiate it's properties.
 /// </summary>
 protected BaseManager()
 {
     Validation = new Validation();
     ConvertEntities = new ConvertEntities();
     OpenIDContext = new OpenIDContext();
 }
 /// <summary>
 /// This constructor will construct the BaseManager and instantiate it's properties.
 /// The IValidation property is set to the given values.
 /// </summary>
 /// <param name="validation">IValidation to be set.</param>
 protected BaseManager(IValidation validation)
 {
     Validation = validation;
     ConvertEntities = new ConvertEntities();
     OpenIDContext = new OpenIDContext();
 }
示例#10
0
        private Transactionfile LoadEntity(JObject payload, FileModel file)
        {
            Transactionfile result = new Transactionfile();

            JsonSerializer serializer = new JsonSerializer()
            {
            };
            var reader    = new JTokenReader(payload);
            var converter = new ConvertEntities <ReferentialEntity>(this._parent, this._parent.Diagnostic, file);

            serializer.Converters.Add(converter);
            var model = (Entities <ReferentialEntity>)serializer.Deserialize(reader, typeof(Entities <ReferentialEntity>));

            if (converter.Exception != null)
            {
                throw converter.Exception;
            }

            //if (model.HasChangedOnLoading)
            //    model.Save(file.FullPath, Formatting.Indented, converter);

            var items = this._parent.CollectContentOfFile <ReferentialEntity>(file).ToList();

            foreach (var item in model)
            {
                try
                {
                    if (!string.IsNullOrEmpty(item.Name))
                    {
                        this._parent.Add(item);
                        var p = items.RemoveWhere(c => c.Name == item.Name);
                        if (p.Count == 0)
                        {
                            result.Added.Add(item);
                        }
                        else
                        {
                            result.Updated.Add(item);
                        }
                    }
                }
                catch (System.Exception e)
                {
                    _parent.Diagnostic.Append(
                        new DiagnositcMessage()
                    {
                        Severity  = SeverityEnum.Error,
                        File      = file.FullPath,
                        Exception = e,
                        Text      = $"Failed to adding entity {item.Name}"
                    }
                        );
                }
            }

            foreach (var item in items)
            {
                this._parent.RemoveReferential(item);
                result.Deleted.Add(item);
            }

            return(result);
        }