Пример #1
0
        public static void StoreData(this IScienceDataContainer container, IScienceDataContainer experiment, bool dumpDuplicates, ILogHandler logHandler)
        {
            if (logHandler == null)
            {
                logHandler = new ScreenMessageLogHandler();
            }
            if (container == experiment)
            {
                logHandler.Log("Container is the same as experiment!");
                return;
            }

            var containerWrapper  = new ScienceDataContainerWrapper(container);
            var experimentWrapper = new ScienceDataContainerWrapper(experiment);
            var containerData     = containerWrapper.GetData();
            var experimentData    = experimentWrapper.GetData();

            if (experimentData.Length == 0)
            {
                logHandler.Log($"GetData returned no scienceData");
            }
            for (var i = 0; i < experimentData.Length; i++)
            {
                var currentData = experimentData[i];
                logHandler.Log($"Processing {i + 1}/{experimentData.Length}: {currentData.subjectID} ({currentData.title})");
                if (!containerWrapper.HasData(currentData))
                {
                    containerWrapper.ReturnData(currentData);
                    if (containerWrapper.HasData(currentData))
                    {
                        experimentWrapper.DumpData(currentData);
                        logHandler.Log($"{currentData.dataAmount} data stored");
                    }
                    else
                    {
                        logHandler.Log($"Container didn't store the experiment");
                    }
                }
                else if (dumpDuplicates)
                {
                    logHandler.Log($"{currentData.subjectID} - {currentData.title}: already contains -> dump");
                    experimentWrapper.DumpData(currentData);
                }
            }
        }