Exemple #1
0
        public ExternalStoreOptions Clone(ExternalStoreOptions options)
        {
            //
            // Don't serialize a null object, simply return the default for that object
            //
            if (ReferenceEquals(options, null))
            {
                return(null);
            }

            if (!options.GetType().IsSerializable)
            {
                throw new ArgumentException(@"The type must be serializable.", "source");
            }

            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new MemoryStream();

            using (stream)
            {
                formatter.Serialize(stream, options);
                stream.Seek(0, SeekOrigin.Begin);

                return((ExternalStoreOptions)formatter.Deserialize(stream));
            }
        }
Exemple #2
0
        public void UpdateSettings(AdvancedSettings settings)
        {
            _Settings = settings;

            try
            {
                _Options = _Settings.GetAddInCustomData <ExternalStoreOptions>(_Name, "ExternalStoreOptions", _extraTypeList.ToArray());
                if (_Options == null)
                {
                    _Options = new ExternalStoreOptions();
                    _Settings.SetAddInCustomData <ExternalStoreOptions>(_Name, "ExternalStoreOptions", _Options, _extraTypeList.ToArray());
                    _Settings.Save();
                }
            }
            catch (Exception e)
            {
                Logger.Global.Exception("ExternalStore", e);
                if (_Options == null)
                {
                    _Options = new ExternalStoreOptions();
                }
            }

            ExternalStoreOptions tempOptions = Clone(_Options);

            _View.ExternalStoreAddins = _externalStoreAddinConfigArray;
            _View.Initialize(tempOptions, ServiceDirectory);
            _View.Enabled = true;
        }
Exemple #3
0
        public static void MyDumpExternalStoreOptions(string prefix, ExternalStoreOptions options)
        {
            ExternalStoreItem item = options.GetCurrentOption();

            if (item != null)
            {
                string s = string.Format("****** '{0}'  \n\tExternalStoreJob '{1}'\n\tCleanJob '{2}'", prefix, (item.ExternalStoreJob != null), (item.CleanJob != null));
                DicomUtilities.DebugString(DebugStringOptions.ShowCounter, s);
            }
        }
Exemple #4
0
        public void RunView(ExternalStoreConfigurationView view, AdvancedSettings settings)
        {
            _View     = view;
            _Settings = settings;

            if (settings != null)
            {
                try
                {
                    _Options = _Settings.GetAddInCustomData <ExternalStoreOptions>(_Name, "ExternalStoreOptions", _extraTypeList.ToArray());
                    if (_Options == null)
                    {
                        _Options = new ExternalStoreOptions();

                        foreach (ExternalStoreAddinConfigAbstract addinConfig in _externalStoreAddinConfigArray)
                        {
                            ExternalStoreItem item = new ExternalStoreItem();
                            item.ExternalStoreAddinConfig = addinConfig; // Here you can serialize this yourself
                        }
                        _Settings.SetAddInCustomData <ExternalStoreOptions>(_Name, "ExternalStoreOptions", _Options, _extraTypeList.ToArray());
                        _Settings.Save();
                    }
                }
                catch (Exception e)
                {
                    Logger.Global.Exception("ExternalStore", e);
                    if (_Options == null)
                    {
                        _Options = new ExternalStoreOptions();
                    }
                }

                ExternalStoreOptions tempOptions = Clone(_Options);

                _View.ExternalStoreAddins = _externalStoreAddinConfigArray;
                _View.Initialize(tempOptions, this.ServiceDirectory);
                _View.Enabled = false;
            }

            _View.ExternalStore       += new EventHandler <ExternalStoreMessageEventArgs>(View_ExternalStore);
            _View.CancelExternalStore += new EventHandler <EventArgs>(_View_CancelExternalStore);
            _View.Clean           += new EventHandler <CleanMessageEventArgs>(View_Clean);
            _View.Reset           += new EventHandler <ResetEventArgs>(View_Reset);
            _View.Restore         += new EventHandler <RestoreMessageEventArgs>(View_Restore);
            _View.CancelRestore   += new EventHandler <EventArgs>(_View_CancelRestore);
            _View.SettingsChanged += new EventHandler(View_SettingsChanged);
        }
Exemple #5
0
        public void SaveOptions()
        {
            _View.UpdateSettings();
            if (_Settings != null)
            {
                _Settings.SetAddInCustomData <ExternalStoreOptions>(_Name, "ExternalStoreOptions", _View.Options, _extraTypeList.ToArray());

                try
                {
                    _Settings.Save();
                    DicomUtilities.DebugString(DebugStringOptions.ShowCounter, "ExternalStorePresenter::SaveOptions -- _Settings.Save()");
                    MyDumpExternalStoreOptions("Saved Options", _View.Options);
                }
                catch (Exception ex)
                {
                    DicomUtilities.DebugString(DebugStringOptions.ShowCounter, "ExternalStorePresenter::SaveOptions -- Exception: " + ex.Message);
                }
            }
            _Options = Clone(_View.Options);
            MyDumpExternalStoreOptions("New Options", _Options);
        }