Пример #1
0
 private async Task DoCatalogsInt(int topN = 1000)
 {
     var table = SelectedConfiguration.ToDataTable(topN);
     await _worker.Run(async() => {
         return(await Task.FromResult(table.ToDatatableEx(table.ToTable())));
     });
 }
Пример #2
0
        public bool SaveConfiguration()
        {
            SelectedConfiguration.Inflate();
            var result = XmlHelper <CConfiguration> .Save(_configurationFile, SelectedConfiguration);

            SelectedConfiguration.Deflate();

            return(result);
        }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ob"></param>
 public void CancelConfigurationChanges(object ob)
 {
     SelectedConfiguration.RestoreCachedObject();
     SendMessage(new MainViewModelMessage()
     {
         Purpose = MessagePurpose.OPEN_SNACKBAR,
         Payload = "Discarded changes"
     });
 }
 private bool CanActivateSelectedConfiguration()
 {
     if (SelectedConfiguration != null &&
         !String.IsNullOrWhiteSpace(SelectedConfiguration.Attribute("server").Value) &&
         !String.IsNullOrWhiteSpace(SelectedConfiguration.Attribute("orgName").Value))
     {
         return(true);
     }
     return(false);
 }
        /// <summary>
        /// Write an nearly empty xml-file
        /// </summary>
        /// <param name="pathToConfigurationXml">
        /// The path To Configuration Xml.
        /// </param>
        /// <param name="pathToAssemblies">
        /// The path To Assemblies.
        /// </param>
        public static void WriteEmptyXmlFile(string pathToConfigurationXml, string pathToAssemblies)
        {
            var selectedConfiguration = new SelectedConfiguration
            {
                TestFramework =
                {
                    PathToAssemblies = pathToAssemblies
                }
            };

            WriteDataToXml(selectedConfiguration, pathToConfigurationXml);
        }
Пример #6
0
        private string saveConfiguration()
        {
            var cfgFile = ConfigurationManager.AppSettings["ConfigurationFile"];

            TraceLog.Information("Saving {cfgFile} file", cfgFile);

            SelectedConfiguration.Inflate();
            XmlHelper <CConfiguration> .Save(cfgFile, SelectedConfiguration);

            SelectedConfiguration.Deflate();

            return(cfgFile);
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ob"></param>
        public void SaveConfiguration(object ob)
        {
            var changes = SelectedConfiguration.GetChanges();

            ConfigurationRepositoryHelper.UpdateConfiguration(SelectedConfiguration, changes);
            RepositoryHelper.CommitPendingDbChanges();
            SelectedConfiguration.CacheObject();
            SendMessage(new MainViewModelMessage()
            {
                Purpose = MessagePurpose.OPEN_SNACKBAR,
                Payload = $"Saved configuration for {SelectedConfiguration.Crypto.CryptoName} "
            });
        }
        /// <summary>
        /// Write data into xml-file
        /// </summary>
        /// <param name="selectedConfiguration">source object</param>
        /// <param name="fileName">name of xml-file</param>
        public static void WriteDataToXml(SelectedConfiguration selectedConfiguration, string fileName)
        {
            var fileDirectory = Path.GetDirectoryName(fileName);

            if (fileDirectory != null && !Directory.Exists(fileDirectory))
            {
                Directory.CreateDirectory(fileDirectory);
            }

            try
            {
                var        serializerObj   = new XmlSerializer(typeof(SelectedConfiguration));
                TextWriter writeFileStream = new StreamWriter(fileName);
                serializerObj.Serialize(writeFileStream, selectedConfiguration);
                writeFileStream.Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show(LogInfo.Namespace(MethodBase.GetCurrentMethod()) + " Error: file could not be written." + "\n" + fileName + "\n\n" + exception.Message);
                throw;
            }
        }
        /// <summary>
        /// Add List To Configuration Items
        /// </summary>
        /// <param name="selectedConfiguration">Available information from configuration file</param>
        /// <param name="selectableConfiguration">Container to store available information from hard disk into</param>
        /// <param name="categoryAndItems">Found category and items to put into "selectableItems"</param>
        /// <param name="folder">Found folder to put into "selectableItems"</param>
        private static void AddListToConfigurationItems(SelectedConfiguration selectedConfiguration, SelectableConfiguration selectableConfiguration, CategoryAndItems categoryAndItems, string folder)
        {
            if (selectedConfiguration.TestEnvironment.Communication.Folder.Equals(folder))
            {
                selectableConfiguration.CommunicationItems.Items.Add(categoryAndItems);
            }

            if (selectedConfiguration.TestEnvironment.HostApplication.Folder.Equals(folder))
            {
                selectableConfiguration.HostApplicationItems.Items.Add(categoryAndItems);
            }

            if (selectedConfiguration.TestEnvironment.OperatingSystem.Folder.Equals(folder))
            {
                selectableConfiguration.OperatingSystemItems.Items.Add(categoryAndItems);
            }

            if (selectedConfiguration.TestEnvironment.DeviceFunction.Folder.Equals(folder))
            {
                selectableConfiguration.DeviceFunctionsItems.Items.Add(categoryAndItems);
            }
        }
Пример #10
0
        private void InstantiateService()
        {
            ServerConnection.Configuration config = new ServerConnection.Configuration();
            try
            {
                if (SelectedConfiguration == null)
                {
                    throw new Exception("Please choose a configuration.");
                }

                //Get the Password
                string         password = String.Empty;
                PasswordWindow pw       = new PasswordWindow();
                pw.Owner = Application.Current.MainWindow;
                bool?submitted = pw.ShowDialog();
                if (submitted.Value)
                {
                    password = pw.GetPassword();
                }
                else
                {
                    ErrorWindow needPassword = new ErrorWindow("You need to supply a Password and Submit. Try again.");
                    needPassword.Owner = Application.Current.MainWindow;
                    needPassword.ShowDialog();
                    return;
                }


                _serverConnect = new ConsolelessServerConnection();
                ConsolelessServerConnection.Configuration _config = new ConsolelessServerConnection.Configuration();
                _config = _serverConnect.GetServerConfiguration(
                    SelectedConfiguration.Attribute("server").Value,
                    SelectedConfiguration.Attribute("orgName").Value,
                    SelectedConfiguration.Attribute("userName").Value,
                    password,
                    SelectedConfiguration.Attribute("domain").Value);

                _serviceProxy = ServerConnection.GetOrganizationProxy(config);


                // This statement is required to enable early-bound type support.
                _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors
                .Add(new ProxyTypesBehavior());

                // The OrganizationServiceContext is an object that wraps the service
                // proxy and allows creating/updating multiple records simultaneously.
                _orgContext = new OrganizationServiceContext(_serviceProxy);

                //Set the ActiveConnection
                ActiveConfiguration = SelectedConfiguration;

                //If all worked, retrieve the solutions.
                LoadSolutions();
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(e.Message);
                sb.AppendLine();
                sb.AppendLine("Please fix the Connection information and try again.");
                ErrorWindow errorWindow = new ErrorWindow(sb.ToString());
                errorWindow.Owner = Application.Current.MainWindow;
                var x = errorWindow.ShowDialog();
            }
        }
        public void CreateDisk(object obj)
        {
            bool cnt = true;

            StatusInformation = "Configuration of a USB key is in progress...";

            ChooseDiskEnable           = false;
            SelectConfigurationEnabled = false;

            if (currentWorkerIdx == -1)
            {
                WarningWindow ww = new WarningWindow(SelectedDiskDrive.ToString());
                ww.Owner = mainWindow;
                ww.ShowDialog();

                if (!ww.UserConfirmed)
                {
                    StatusInformation = "Configuration of a USB key was cancelled!";

                    ChooseDiskEnable           = true;
                    SelectConfigurationEnabled = true;

                    return;
                }
                else
                {
                    SelectedConfiguration.ResetStepStatuses();
                    currentWorkerIdx = 0;
                }
            }
            else
            {
                currentWorkerIdx++;
                if (currentWorkerIdx >= SelectedConfiguration.Workers.Count)
                {
                    cnt = false;
                }
            }

            if (cnt)
            {
                SelectedConfiguration.Workers[currentWorkerIdx].ProgressChanged    += Bw_ProgressChanged;
                SelectedConfiguration.Workers[currentWorkerIdx].RunWorkerCompleted += Bw_RunWorkerCompleted;

                SelectedConfigurationStepModel = SelectedConfiguration.Steps[currentWorkerIdx];
                SelectedConfiguration.Steps[currentWorkerIdx].SetStatus("IN WORK");

                SelectedConfiguration.Workers[currentWorkerIdx].RunWorkerAsync();

                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            }
            else
            {
                foreach (BackgroundWorker bw in SelectedConfiguration.Workers)
                {
                    bw.ProgressChanged    -= Bw_ProgressChanged;
                    bw.RunWorkerCompleted -= Bw_RunWorkerCompleted;
                }

                currentWorkerIdx = -1;
                SelectedConfigurationStepModel = null;

                if (SelectedConfiguration.Steps.Last().Type == "eject")
                {
                    StatusInformation = "USB disk was sucessfully created and can be removed now.";
                }
                else
                {
                    StatusInformation = "USB disk was sucessfully created. Please remove it safely.";
                }
                CommandManager.InvalidateRequerySuggested();

                ChooseDiskEnable           = true;
                SelectConfigurationEnabled = true;

                if (SelectedConfiguration.Steps.Last().Type == "eject")
                {
                    RefreshDiskDrives(null);
                }

                Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
            }
        }
        /// <summary>
        /// Converts one dimensional list to ConfigurationItems
        /// </summary>
        /// <param name="foldersAndFiles">List of found folders and items</param>
        /// <param name="selectedConfiguration">Available information from configuration file</param>
        /// <returns>Selectable Items</returns>
        public static SelectableConfiguration ConvertFromListToConfigurationItems(List <string> foldersAndFiles, SelectedConfiguration selectedConfiguration)
        {
            var selectableConfiguration = new SelectableConfiguration();
            var folder = string.Empty;
            CategoryAndItems categoryAndItemsCase3 = null;

            foreach (var item in foldersAndFiles)
            {
                string[] innerStringParts = item.Split(new[] { @"\" }, StringSplitOptions.None);

                switch (innerStringParts.Length)
                {
                case 3:
                {
                    // Wenn der Container leer ist
                    if (categoryAndItemsCase3 == null)
                    {
                        categoryAndItemsCase3 = new CategoryAndItems
                        {
                            Category = innerStringParts[1]
                        };
                        categoryAndItemsCase3.Items.Add(innerStringParts[2]);            // Hinzufügen des ersten Listenelements

                        folder = innerStringParts[0];
                    }
                    else
                    {
                        // Wenn es die aktuelle Kategorie bereits gibt
                        if (categoryAndItemsCase3.Category.Equals(innerStringParts[1]))
                        {
                            categoryAndItemsCase3.Items.Add(innerStringParts[2]);            // Hinzufügen eines weiteren Listenelements
                        }
                        else
                        {
                            // Wenn es die aktuelle Kategorie noch nicht gibt
                            AddListToConfigurationItems(selectedConfiguration, selectableConfiguration, categoryAndItemsCase3, folder);          // Einfügen zu den ConfigurationItems
                            categoryAndItemsCase3 = new CategoryAndItems {
                                Category = innerStringParts[1]
                            };
                            categoryAndItemsCase3.Items.Add(innerStringParts[2]);

                            folder = innerStringParts[0];
                        }
                    }

                    break;
                }

                default:
                {
                    var exception = new Exception(LogInfo.Namespace(MethodBase.GetCurrentMethod()) + ": Unexpected number of elements.");
                    throw exception;
                }
                }
            }

            AddListToConfigurationItems(selectedConfiguration, selectableConfiguration, categoryAndItemsCase3, folder);
            return(selectableConfiguration);
        }
Пример #13
0
 public override bool IsValid()
 {
     return(SelectedConfiguration != null && SelectedConfiguration.IsValid());
 }