private void LoadSingleGroupFile_Click(object sender, RoutedEventArgs e)
        {
            var ConsoleService = ConsoleContract.CreateChannel(new EndpointAddress(MyEndpoint));



            //First we needs to get a file
            string filename = SDC.Filepicker();


            SRCServerList LoadedList = new SRCServerList();

            if (filename.ToLower().EndsWith("serverlayout.xml"))
            {
                var dalist = SDC.GetServersFromFile(filename);
                LoadedList.Folder.Name = "SingleFile";
                int servercount = dalist.Count;
                StivTaskConsole.Folder afolder = new Folder();
                afolder.Name = "ServerLayout";
                foreach (var aserver in dalist)
                {
                    StivTaskConsole.Server serveritem = new Server();
                    serveritem.Name   = aserver.Key;
                    serveritem.Domain = aserver.Value;
                    afolder.ServerList.Add(serveritem);
                }
                LoadedList.Folder.FolderList.Add(afolder);
                HierarchicServerList = LoadedList;
            }
            else
            {
                try
                {
                    LoadedList = SRCServerList.LoadFromFile(filename);

                    HierarchicServerList = LoadedList;
                }
                catch
                {
                    MessageBox.Show("Failed to load list of servers from der einen file! Woe unto you!");
                }
            }

            ServerPickerWindow();
        }
        // Insert logic for processing found files here.
        private StivTaskConsole.Folder ProcessFile(string path)
        {
            StivTaskConsole.Folder FolderforFile = new Folder();
            if (path.ToLower().Contains("serverlayout.xml"))
            {
                FolderforFile.Name = "ServerLayout";

                var ActiveServerLayoutFile = XElement.Load(path);
                var addem = SDC.GetServersFromFile(path);
                foreach (KeyValuePair <string, string> KVP in addem)
                {
                    if (!ActiveServerList.Keys.Contains(KVP.Key))
                    {
                        ActiveServerList.Add(KVP.Key, KVP.Value);
                    }
                    StivTaskConsole.Server oneserver = new Server();

                    var myroles = GetRolesForServer(ActiveServerLayoutFile, KVP.Key);

                    oneserver.Name   = KVP.Key;
                    oneserver.Domain = KVP.Value;

                    // Need to add the roles we want added to the server based on roles in serverlayout.

                    //All servers in layout shall have a Mediaroom type
                    Type MediaroomType = new Type();
                    MediaroomType.Name = "Mediaroom"; oneserver.Type.Add(MediaroomType);


                    foreach (string arole in myroles)
                    {
                        Type atype    = new Type();
                        bool DBNotSet = true;

                        switch (arole.ToLower())
                        {
                        case "ntp": atype.Name = "NTP"; oneserver.Type.Add(atype); break;

                        case "listingslibrarian": atype.Name = "ListingsLibrarian"; oneserver.Type.Add(atype); break;

                        case "dserverservice": atype.Name = "DServer"; oneserver.Type.Add(atype); break;

                        case "vodimportpreprocessorservice": atype.Name = "VODImport"; oneserver.Type.Add(atype); break;

                        case "acquisitionserviceV3": atype.Name = "Aserver"; oneserver.Type.Add(atype); break;

                        case "bootstrap": atype.Name = "ClientFacing"; oneserver.Type.Add(atype); break;

                        case "smtchannelmap": atype.Name = "BranchManagement"; oneserver.Type.Add(atype); break;

                        case "livebackendmanagement": atype.Name = "LBEManagement"; oneserver.Type.Add(atype); break;
                        }
                        if (DBNotSet && arole.ToLower().EndsWith("db"))
                        {
                            atype.Name = "Database";

                            oneserver.Type.Add(atype);
                            DBNotSet = false;
                        }
                    }


                    FolderforFile.ServerList.Add(oneserver);
                }
            }
            else if (path.ToLower().Contains("serverlist.xml"))
            {
                FolderforFile = SRCServerList.LoadFromFile(path).Folder;
            }
            return(FolderforFile);
        }
        public MainWindow()
        {
            InitializeComponent();

            MyIP = ConsoleIP().ToString();



            //Trying to find an open port, starting with MyPort:

            IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();

            TcpConnectionInformation[] tcpConnInfoArray = ipGlobalProperties.GetActiveTcpConnections();

            bool ihaveopenport = false;

            while (!ihaveopenport)
            {
                ihaveopenport = true;
                foreach (TcpConnectionInformation tcpi in tcpConnInfoArray)
                {
                    if (tcpi.LocalEndPoint.Port == MyPort)
                    {
                        ihaveopenport = false;
                        MyPort++;
                        break;
                    }
                }
            }



            MyEndpoint = "net.tcp://" + ConsoleIP().ToString() + ":" + MyPort.ToString() + "/StivTaskConsole/";

            this.host = new ServiceHost(typeof(TaskConsoleWCFService.Service1));
            bindbert.Security.Mode = SecurityMode.None;
            bindbert.MaxBufferSize = 640000;
            string myid = WindowsIdentity.GetCurrent().Name.Split('\\')[1].ToLower();

            if (myid.ToLower().StartsWith("b-"))
            {
                UserTextBox.Text = myid.ToLower().Remove(0, 2);
            }
            ConsoleContract = new ChannelFactory <TaskConsoleWCFService.ContractDefinition>(bindbert);
            var ConsoleService = ConsoleContract.CreateChannel(new EndpointAddress(MyEndpoint));

            StartWCFService();

            ConsoleService.SetPort(MyPort.ToString());



            //Here is where we load default definition files from current directory if they exist!

            var mydir = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (File.Exists(mydir + @"\ServerList.xml"))
            {
                try
                {
                    var LoadedList = SRCServerList.LoadFromFile(mydir + @"\ServerList.xml");

                    HierarchicServerList = LoadedList;
                    try
                    {
                        ServerPickerWindow();
                    }
                    catch { }
                }
                catch
                {
                    MessageBox.Show("Failed to load list of servers from der einen file! Woe unto you!");
                }
            }
            ;



            ColorDropbox.Items.Add("Red");
            ColorDropbox.Items.Add("Blue");
            ColorDropbox.Items.Add("Yellow");
            ColorDropbox.Items.Add("Purple");
            ColorDropbox.Items.Add("Orange");
            ColorDropbox.Items.Add("Green");
            ColorDropbox.Items.Add("Dark");

            TaskConsoleWCFService.JobStatusRow TCRowItem = new TaskConsoleWCFService.JobStatusRow();

            var dispatcherTimer = new System.Windows.Threading.DispatcherTimer();

            dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();

            var DatasourceUpdate = new System.Windows.Threading.DispatcherTimer();

            DatasourceUpdate.Tick    += new EventHandler(UpdateJobDataGrid_Tick);
            DatasourceUpdate.Interval = new TimeSpan(0, 0, 7);
            DatasourceUpdate.Start();

            DasGrid.ItemsSource = JobDataGridSource.Values.ToArray();
        }