Example #1
0
        public void TestPackWhenEditorStateIsDeleted(string appName)
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", appName);

            Assert.IsTrue(File.Exists(root));

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            errors.ThrowOnErrors();

            using (var tempDir = new TempDir())
            {
                string outSrcDir = tempDir.Dir;

                // Save to sources
                msapp.SaveToSources(outSrcDir);

                // Delete Entropy directory
                var editorStatePath = Path.Combine(outSrcDir, "Src", "EditorState");
                if (Directory.Exists(editorStatePath))
                {
                    Directory.Delete(editorStatePath, true);
                }

                // Load app from the sources after deleting the entropy
                var app = SourceSerializer.LoadFromSource(outSrcDir, new ErrorContainer());

                using (var tempFile = new TempFile())
                {
                    // Repack the app
                    MsAppSerializer.SaveAsMsApp(app, tempFile.FullPath, new ErrorContainer());
                }
            }
        }
        public void TestTableDefinitionsAreLastEntriesWhenEntropyDeleted(string appName)
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", appName);

            Assert.IsTrue(File.Exists(root));

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            errors.ThrowOnErrors();

            using (var tempDir = new TempDir())
            {
                string outSrcDir = tempDir.Dir;

                // Save to sources
                msapp.SaveToSources(outSrcDir);

                // Delete Entropy directory
                var entropyPath = Path.Combine(outSrcDir, "Entropy");
                if (Directory.Exists(entropyPath))
                {
                    Directory.Delete(entropyPath, true);
                }

                // Load app from the sources after deleting the entropy
                var app = SourceSerializer.LoadFromSource(outSrcDir, new ErrorContainer());

                using (var tempFile = new TempFile())
                {
                    // Repack the app
                    MsAppSerializer.SaveAsMsApp(app, tempFile.FullPath, new ErrorContainer());

                    using (var stream = new FileStream(tempFile.FullPath, FileMode.Open))
                    {
                        // Read the msapp file
                        ZipArchive zipOpen = new ZipArchive(stream, ZipArchiveMode.Read);

                        foreach (var entry in zipOpen.Entries)
                        {
                            var kind = FileEntry.TriageKind(FilePath.FromMsAppPath(entry.FullName));

                            switch (kind)
                            {
                            // Validate that the last entry in the DataSources.json is TableDefinition entry.
                            case FileKind.DataSources:
                            {
                                var dataSourcesFromMsapp = ToObject <DataSourcesJson>(entry);
                                var last = dataSourcesFromMsapp.DataSources.LastOrDefault();
                                Assert.AreEqual(last.TableDefinition != null, true);
                                return;
                            }

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        private SourceResponse <T> ToSourceResponse <T>(IApiCallDetails apiCallDetails, Stream stream) where T : class
        {
            var source = SourceSerializer.Deserialize <T>(stream);

            return(new SourceResponse <T>
            {
                Body = source,
            });
        }
        public void TestTopParentNameFallback(string appName, string topParentName)
        {
            var root = Path.Combine(Environment.CurrentDirectory, "Apps", appName);

            Assert.IsTrue(File.Exists(root));

            (var msapp, var errors) = CanvasDocument.LoadFromMsapp(root);
            errors.ThrowOnErrors();

            using (var tempDir = new TempDir())
            {
                string outSrcDir = tempDir.Dir;

                // Save to sources
                msapp.SaveToSources(outSrcDir);

                // Go find the source file for the editor state
                string filename     = $"{topParentName}.editorstate.json";
                string fullFilePath = Path.Combine(outSrcDir, "Src", "EditorState", filename);
                if (File.Exists(fullFilePath))
                {
                    // Get the file for the specific control we're looking for
                    DirectoryReader.Entry file        = new DirectoryReader.Entry(fullFilePath);
                    ControlTreeState      editorState = file.ToObject <ControlTreeState>();

                    // Rename the file so we know that the file name itself is used.
                    string newFileName = Guid.NewGuid().ToString();
                    string newFilePath = Path.Combine(outSrcDir, "Src", "EditorState");

                    // Write out only the dictionary to the file, which is the older format.
                    DirectoryWriter dir = new DirectoryWriter(newFilePath);
                    dir.WriteAllJson(newFilePath, $"{newFileName}{EditorStateFileExtension}", editorState.ControlStates);

                    // Remove the old file, we only want the re-written and re-named file
                    File.Delete(fullFilePath);

                    // Load app from the source folder
                    var app = SourceSerializer.LoadFromSource(outSrcDir, new ErrorContainer());

                    // Find the relevant controls and check their top parent name
                    foreach (var control in editorState.ControlStates)
                    {
                        app._editorStateStore.TryGetControlState(control.Value.Name, out ControlState state);
                        Assert.AreEqual(newFileName, state.TopParentName);
                    }
                }
                else
                {
                    Assert.Fail($"Could not find expected file {fullFilePath}.");
                }
            }
        }
        public void SetUp()
        {
            _source = new CsvFileSource()
            {
                FilePath = @"C:\Data.csv"
            };

            _xSource = new XElement("csv-file-source",
                                    new XElement("file-path", @"C:\Data.csv"));

            _serializer = new SourceSerializer(
                new PropertySerializer(null));
        }
 /// <summary>
 /// Вызывает проверку подключения к рабочему списку DICOM
 /// </summary>
 private void CheckWorklistConnection()
 {
     try
     {
         var connectionHelper = new WorklistConnectionHelper();
         if (connectionHelper.CheckConnection(SourceSerializer.WorklistDeserialize(Source)))
         {
             IsConnected = true;
             _connectionMessenger.ShowConnectionSuccess("Соединение с Dicom Worklist установленно!");
         }
     }
     catch (Exception e)
     {
         IsConnected = false;
         _connectionMessenger.ShowConnectionErrorMessage(e);
     }
 }
 /// <summary>
 /// Вызывает проверку подключения к базе данных
 /// </summary>
 private void CheckDbConnection()
 {
     _configuration.DbSource = SourceSerializer.DbDeserialize(Source);
     try
     {
         if (_configuration.GetStateConnection())
         {
             IsConnected = true;
             _connectionMessenger.ShowConnectionSuccess("Соединение с базой данных установленно!");
         }
     }
     catch (Exception e)
     {
         IsConnected = false;
         _connectionMessenger.ShowConnectionErrorMessage(e);
     }
 }
Example #8
0
        /// <summary>
        /// Возвращает коллекцию поциентов из текущего источника
        /// </summary>
        private void FindPatient()
        {
            if (!string.IsNullOrEmpty(SearchString))
            {
                switch (_source.TypeEnum)
                {
                case SourceTypeEnum.DataBase:
                {
                    try
                    {
                        var configuration = new DbConnectionHelper(SourceSerializer.DbDeserialize(_source));
                        _patientRepository = new PatientDbConnectionRepository(configuration);
                        var patients = _patientRepository.FindPatientsByValue(SearchString);
                        Patients = new ObservableCollection <Patient>(patients);
                    }
                    catch (Exception e)
                    {
                        _connectionMessenger.ShowConnectionErrorMessage(e);
                        ClearSearchArea();
                    }
                }
                    return;

                case SourceTypeEnum.Worklist:
                {
                    try
                    {
                        _patientRepository = new PatientRepositoryDicom(SourceSerializer.WorklistDeserialize(_source));
                        var patients = _patientRepository.FindPatientsByValue(SearchString);
                        Patients = new ObservableCollection <Patient>(patients);
                    }
                    catch (Exception e)
                    {
                        _connectionMessenger.ShowConnectionErrorMessage(e);
                        ClearSearchArea();
                    }
                }
                    return;
                }
            }

            Patients.Clear();
        }
        public void TestNoLocalDatabaseRefsWhenLocalDatabaseReferencesPropertyWasEmptyJson(string appName)
        {
            var pathToMsApp = Path.Combine(Environment.CurrentDirectory, "Apps", appName);

            Assert.IsTrue(File.Exists(pathToMsApp));

            var(msApp, errors) = CanvasDocument.LoadFromMsapp(pathToMsApp);
            errors.ThrowOnErrors();

            using var sourcesTempDir = new TempDir();
            var sourcesTempDirPath = sourcesTempDir.Dir;

            msApp.SaveToSources(sourcesTempDirPath);

            var loadedMsApp = SourceSerializer.LoadFromSource(sourcesTempDirPath, new ErrorContainer());

            Assert.IsTrue(loadedMsApp._entropy.WasLocalDatabaseReferencesEmpty.Value);
            Assert.IsFalse(loadedMsApp._entropy.LocalDatabaseReferencesAsEmpty);
            Assert.IsTrue(loadedMsApp._dataSourceReferences.Count == 0);
        }
Example #10
0
        public void WorklistDeserialize_isCorrect()
        {
            var result = SourceSerializer.WorklistDeserialize(s_wl);

            Assert.IsTrue(result.Equals(wl));
        }
Example #11
0
        public void DbDeserialize_isCorrect()
        {
            var result = SourceSerializer.DbDeserialize(s_db);

            Assert.IsTrue(result.Equals(db));
        }