public void RunView(StorageCommitView storageCommitView, AdvancedSettings settings)
        {
            _view     = storageCommitView;
            _settings = settings;

            if (settings != null)
            {
                try
                {
                    _options = _settings.GetAddInCustomData <StorageCommitOptions>(_name, _storageCommitOptionsName);
                    if (_options == null)
                    {
                        _options = new StorageCommitOptions();

                        _settings.SetAddInCustomData <StorageCommitOptions>(_name, _storageCommitOptionsName, _options);
                        _settings.Save();
                    }
                }
                catch (Exception e)
                {
                    Logger.Global.Exception(_storageCommitOptionsName, e);
                    if (_options == null)
                    {
                        _options = new StorageCommitOptions();
                    }
                }

                StorageCommitOptions tempOptions = Clone(_options);

                _view.Initialize(tempOptions);
                // _view.Enabled = false;
            }

            _view.SettingsChanged += new EventHandler(View_SettingsChanged);
        }
        private static StorageCommitOptions Clone(StorageCommitOptions 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.", @"options");
            }

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

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

                return((StorageCommitOptions)formatter.Deserialize(stream));
            }
        }
示例#3
0
        public static bool IsEqual(StorageCommitOptions options1, StorageCommitOptions options2)
        {
            if (options1 == null)
            {
                return(options2 == null);
            }

            if (options2 == null)
            {
                // Options1 is not null, so return false
                return(false);
            }

            return(options1.reportType == options2.reportType);
        }
        public void SaveOptions()
        {
            _view.UpdateSettings();
            if (_settings != null)
            {
                _settings.SetAddInCustomData <StorageCommitOptions>(_name, _storageCommitOptionsName, _view.Options);

                try
                {
                    _settings.Save();
                }
                catch (Exception)
                {
                }
            }
            _options = Clone(_view.Options);
        }
示例#5
0
        public void Initialize(StorageCommitOptions options)
        {
            _options = options;
            switch (options.reportType)
            {
            case ReportType.SameAssociation:
                this.radioButtonSameAssociation.Checked = true;
                break;

            case ReportType.NewAssociation:
                this.radioButtonNewAssociation.Checked = true;
                break;

            case ReportType.ConditionalAssociation:
                this.radioButtonTrySameThenNew.Checked = true;
                break;
            }
        }