Esempio n. 1
0
 private void RecurseLoadTemplate(DbSet<SigNode> nodeSet, TemplateViewModel template, ObservableCollection<TemplateNodeViewModel> nodes, Int64  parentId,List<TemplateNodeLayerViewModel> layersNodes)
 {
     List<SigNode> levelNodes = (from n in nodeSet where n.SigTemplateId == template.Id && n.ParentId == parentId orderby n.Order select n).ToList();
     foreach (SigNode levelNode in levelNodes)
     {
         if (levelNode.SigCodeNode.Code.Equals("Folder"))
         {
             TemplateNodeFolderViewModel vm = new TemplateNodeFolderViewModel(levelNode);
             nodes.Add(vm);
             this.RecurseLoadTemplate(nodeSet, template, vm.Nodes, levelNode.Id, layersNodes);
         }
         else if (levelNode.SigCodeNode.Code.Equals("Layer"))
         {
             TemplateNodeLayerViewModel vm = new TemplateNodeLayerViewModel(levelNode);
             nodes.Add(vm);
             layersNodes.Add(vm);
         }
     }
 }
Esempio n. 2
0
        private void AddLayerMetier(TemplateViewModel templateViewModel, TemplateNodeFolderViewModel parentFolder, EntityTableInfo tableInfo)
        {
            long nextMapOrder = this.GetNextMapOrder();
            DbSet<SigNode> nodes = this.DataService.GetDbSet<SigNode>();
            DbSet<SigLayer> layers = this.DataService.GetDbSet<SigLayer>();


            DbSet<SigCodeNode> codeNodes = this.DataService.GetDbSet<SigCodeNode>();
            DbSet<SigCodeLayer> codeLayers = this.DataService.GetDbSet<SigCodeLayer>();
           
            SigNode nodeLayerMetier = new SigNode();
            nodeLayerMetier.SigTemplateId = templateViewModel.Id;
            if (parentFolder != null)
            {
                nodeLayerMetier.ParentId = parentFolder.Model.Id;
                nodeLayerMetier.Order = parentFolder.Nodes.Count;
            }
            else
            {
                nodeLayerMetier.ParentId = -1;
                nodeLayerMetier.Order = templateViewModel.Nodes.Count;
            }
            nodeLayerMetier.SigCodeNode = (from c in codeNodes where c.Code.Equals("Layer") select c).FirstOrDefault();
            nodeLayerMetier.Libelle = tableInfo.DisplayName;
            SigLayer layer = new SigLayer();
            layer.Libelle = tableInfo.DisplayName;
            layer.MapOrder = nextMapOrder;
            layer.EntityName = tableInfo.EntityType.Name;
            layer.SigCodeLayer = (from c in codeLayers where c.Code.Equals("Geocodage") select c).FirstOrDefault();
            layers.Add(layer);           
            this.DataService.DataContext.SaveChanges();
            nodeLayerMetier.SigLayer = layer;
            nodes.Add(nodeLayerMetier);
            this.DataService.DataContext.SaveChanges();
            nodeLayerMetier.SigLayer = layer;
            nodeLayerMetier.SigLayerId = layer.Id;
            TemplateNodeLayerViewModel vm = new TemplateNodeLayerViewModel(nodeLayerMetier);
            if (parentFolder == null)
            { templateViewModel.Nodes.Add(vm); }
            else
            { parentFolder.Nodes.Add(vm); }
            vm.CreateLayers();
            foreach (IMapLayer mapLayer in vm.Layers)
            {this.Map.Layers.Add(mapLayer);}
        }
Esempio n. 3
0
 private void AddFolder(TemplateViewModel templateViewModel, TemplateNodeFolderViewModel parentFolder)
 {
    SigNode nodeFolder = new SigNode ();
    if (parentFolder != null)
    {
        nodeFolder.ParentId = parentFolder.Model.Id;
        nodeFolder.Order = parentFolder.Nodes.Count;
    }
    else
    {
        nodeFolder.ParentId = -1;
        nodeFolder.Order = templateViewModel.Nodes.Count;
    }
    nodeFolder.SigTemplateId = templateViewModel.Id;
    DbSet<SigCodeNode> codeNodes = this.DataService.GetDbSet<SigCodeNode>();
    nodeFolder.SigCodeNode = (from c in codeNodes where c.Code.Equals("Folder") select c).FirstOrDefault();
    nodeFolder = this.EngineService.ShowAddDialog<SigNode>(nodeFolder, new String[] {"Libelle" });
    if (nodeFolder != null)
    {
        if (parentFolder == null)
        { templateViewModel.Nodes.Add(new TemplateNodeFolderViewModel(nodeFolder)); }
        else
        { parentFolder.Nodes.Add(new TemplateNodeFolderViewModel(nodeFolder)); }
    }
 }
Esempio n. 4
0
        private void RemoveFolder(TemplateViewModel templateViewModel, TemplateNodeFolderViewModel folder)
        {
            DbSet<SigNode> nodes = this.DataService.GetDbSet<SigNode>();
            List<TemplateNodeViewModel> nodeToRemoves = new List<TemplateNodeViewModel>();
            List<TemplateNodeViewModel> subNodes = (from n in folder.Nodes select n).ToList();

            TemplateNodeFolderViewModel parentFolder = null;
            foreach (TemplateNodeViewModel node in subNodes)
            {
                if (node is TemplateNodeLayerViewModel)
                {
                    RemoveLayerMetier(templateViewModel, (node as TemplateNodeLayerViewModel));
                }
                else if (node is TemplateNodeFolderViewModel)
                {

                    TemplateNodeFolderViewModel subFolder = (node as TemplateNodeFolderViewModel);
                    parentFolder = this.GetParentFolder(templateViewModel, templateViewModel.Nodes, subFolder);
                    nodes.Remove(subFolder.Model);
                    this.RemoveFolder(templateViewModel, subFolder);
                    if (parentFolder != null)
                    { parentFolder.Nodes.Remove(subFolder); }
                    else templateViewModel.Nodes.Remove(subFolder);
                    
                }

            }

            parentFolder = this.GetParentFolder(templateViewModel, templateViewModel.Nodes, folder);

            if (parentFolder != null)
            { parentFolder.Nodes.Remove(folder); }
            else templateViewModel.Nodes.Remove(folder);
            nodes.Remove(folder.Model);
            this.DataService.DataContext.SaveChanges();
        }