Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Updates & Insights
  • Questions
  • Learning
    • E-learning Courses
    • Empower Replay: Limited Edition
    • Tutorials
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
      • About the DevOps Program
      • DataMiner DevOps Support
  • Downloads
  • More
    • DataMiner Releases & Updates
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

Automation – move elements from one view to another

Solved714 views13th July 2023
2
Sean Kim [DevOps Member]28 31st August 2022 1 Comment

Hi,

I’m looking at automation script solution to move elements from one view to another, run periodically. I am looking to do this via C# code. Is there any reference I could use to implement this?

Marieke Goethals [SLC] [DevOps Catalyst] Selected answer as best 13th July 2023
Marieke Goethals [SLC] [DevOps Catalyst] commented 13th July 2023

As this question has been inactive for a long time, we will now close it. If you want further assistance, feel free to post a new question or contact techsupport@skyline.be.

1 Answer

  • Active
  • Voted
  • Newest
  • Oldest
3
Jens Vandewalle [SLC] [DevOps Enabler]9.44K Posted 31st August 2022 5 Comments

Hi Sean,

Following code should help you

using Skyline.DataMiner.Library.Automation;
using Skyline.DataMiner.Library.Common;

private void MoveElements(Engine engine)
{
var dms = engine.GetDms();
var currentView = dms.GetView(“Current View”);
var newView = dms.GetView(“New View”);

foreach (var element in currentView.Elements)
{
element.Views.Clear();
element.Views.Add(newView);

element.Update();
}
}

Update 1

private void MoveElements(Engine engine)
{
var dms = engine.GetDms();

var protocol = dms.GetProtocol(“protocol name”, “protocol version”);
var elements = dms.GetElements().Where(x => x.Protocol == protocol);

var newView = dms.GetView(“New View”);

foreach (var element in elements)
{
element.Views.Clear();
element.Views.Add(newView);

element.Update();
}
}

Marieke Goethals [SLC] [DevOps Catalyst] Selected answer as best 13th July 2023
Sean Kim [DevOps Member] commented 31st August 2022

I actually need to only move elements from a specific protocol. So I was doing engine.FindElementsByProtocol() function to get a list of elements. Is there a method to set/remove views from Element class?

If I follow the code below, is there a way to filter elements by protocol?

Lastly, I get an error when I add using Skyline.DataMiner.Library.Common. I am using Skyline.DataMiner.Automation (DM version 10.1).

Jens Vandewalle [SLC] [DevOps Enabler] commented 31st August 2022

Unfortunately the Engine class doesn’t have methods to change the view of an element and the Class Library doesn’t have a method to get the elements by protocol.
I’ve added an additional code sample in my original post in which I’m requesting all the elements of the system and filter on the protocol afterwards.
Would it be possible to mention which error you have so that I can look this up for you?

Sean Kim [DevOps Member] commented 31st August 2022

First error message:
Engine does not contain a definition for ‘GetDms’ and no accessible extension method ‘GetDms’ accepting a first argument of type ‘Engine’ could be found (are you missing a using directive or an assembly reference?)
This is likely related to the fact that I can’t use Skyline.DataMiner.Library.Automation, I can only use Skyline.DataMiner.Automation

Second error message:
foreach statement cannot operate on variables of type ‘?’ because ‘?’ does not contain a public instance definition for ‘GetEnumerator’
This seems related to the first message, doesn’t make much sense on its own.

Code:
using System;
using System.IO;
using Skyline.DataMiner.Automation;
using System.Collections.Generic;
using System.Text;
using System.Linq;

public class Script
{
private void MoveElement(Engine engine)
{
var dms = engine.GetDms();

var protocol = dms.GetProtocol(“Newtec Dialog Time Series Database – Network”, “Production”);
var elements = dms.GetElements().Where(x => x.Protocol == protocol);

var newView = dms.GetView(“Newtec-PROD-NWT”);

foreach (var element in elements)
{
element.Views.Clear();
element.Views.Add(newView);

element.Update();
}
}

}

Michiel Oda [SLC] [DevOps Enabler] commented 1st September 2022

Hi Sean

Class Library is code that is supplied via DIS. Are you developing this script in Visual Studio with DIS? Otherwise the usage of Class Library is not possible.
If you are developing this with DIS, make sure to have the Class Library feature enabled in the DIS Settings (https://docs.dataminer.services/develop/TOOLS/DIS/Reference/DIS_settings.html#class-library).

Sean Kim [DevOps Member] commented 1st September 2022

I generated the script via DIS but once exported to DMA, I am seeing the same validation error messages and when I run it:

The following was returned from the script:
(after retries) (Code: 0x80040251) Skyline.DataMiner.Net.Exceptions.DataMinerException: No Assembly found for cookie 2
(6,25): error CS0234: The type or namespace name ‘Library’ does not exist in the namespace ‘Skyline.DataMiner’ (are you missing an assembly reference?)
(7,25): error CS0234: The type or namespace name ‘Library’ does not exist in the namespace ‘Skyline.DataMiner’ (are you missing an assembly reference?)
(13,26): error CS1061: ‘Engine’ does not contain a definition for ‘GetDms’ and no accessible extension method ‘GetDms’ accepting a first argument of type ‘Engine’ could be found (are you missing a using directive or an assembly reference?)
(20,33): error CS1579: foreach statement cannot operate on variables of type ‘?’ because ‘?’ does not contain a public instance definition for ‘GetEnumerator’

at CManagedAutomation.RunWrapped(CManagedAutomation* , Int32 iCookie, IUnknown* pIAutomation, tagVARIANT* varParameters, tagVARIANT* pvarReturn, String scriptName)
at CManagedAutomation.Run(CManagedAutomation* , Int32 iCookie, Char* bstrScriptName, IUnknown* pIAutomation, tagVARIANT* varParameters, tagVARIANT* varEntryPoint, tagVARIANT* pvarReturn)

Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs