Пример #1
0
        private void WriteEncryptedCredentials()
        {
            string username = txtUsername.Text;
            string password = txtPassword.Text;

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
            {
                if (username != StringConstants.MgUsernamePlaceholder && password != StringConstants.MgPasswordPlaceholder)
                {
                    if (_bChangedUsername || _bChangedPassword)
                    {
                        _fs.SetConnectionProperty("Username", StringConstants.MgUsernamePlaceholder); //NOXLATE
                        _fs.SetConnectionProperty("Password", StringConstants.MgPasswordPlaceholder); //NOXLATE
                        _fs.SetEncryptedCredentials(_service.CurrentConnection, username, password);
                        _service.SyncSessionCopy();
                    }
                }
            }
            else if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password))
            {
                _fs.SetConnectionProperty("Username", null); //NOXLATE
                _fs.SetConnectionProperty("Password", null); //NOXLATE
                try
                {
                    _service.CurrentConnection.ResourceService.DeleteResourceData(_fs.ResourceID, StringConstants.MgUserCredentialsResourceData);
                }
                catch { }
                _service.SyncSessionCopy();
            }
        }
Пример #2
0
        private void chkReadOnly_CheckedChanged(object sender, EventArgs e)
        {
            var newValue  = chkReadOnly.Checked.ToString().ToUpper();
            var currValue = _fs.GetConnectionProperty("ReadOnly"); //NOXLATE

            if (!newValue.Equals(currValue))
            {
                _fs.SetConnectionProperty("ReadOnly", newValue); //NOXLATE
            }
        }
Пример #3
0
        protected override void OnResourceMarked(string dataName)
        {
            string fileProp     = StringConstants.MgDataFilePath + dataName;
            string currFileProp = _fs.GetConnectionProperty(this.FileFdoProperty);

            if (!currFileProp.Equals(fileProp))
            {
                _fs.SetConnectionProperty(this.FileFdoProperty, fileProp);
            }
        }
        private void chkReadOnly_CheckedChanged(object sender, EventArgs e)
        {
            if (_init)
            {
                return;
            }

            _fs.SetConnectionProperty(P_READONLY, chkReadOnly.Checked ? "TRUE" : "FALSE"); //NOXLATE
            OnResourceChanged();
        }
Пример #5
0
 private void txtFeatureServer_TextChanged(object sender, EventArgs e)
 {
     if (_init)
     {
         return;
     }
     _fs.SetConnectionProperty("FeatureServer", txtFeatureServer.Text); //NOXLATE
 }
Пример #6
0
        private void cmbResamplingMethod_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_init || !_bSupportsResample || !chkResamplingMethod.Checked)
            {
                return;
            }

            if (cmbResamplingMethod.SelectedItem != null)
            {
                _fs.SetConnectionProperty("ResamplingMethod", cmbResamplingMethod.SelectedItem.ToString()); //NOXLATE
            }
        }
        private void txtPath_TextChanged(object sender, EventArgs e)
        {
            if (_init)
            {
                return;
            }

            _fs.SetConnectionProperty("DefaultRasterFileLocation", txtPath.Text); //NOXLATE
        }
Пример #8
0
        protected override void OnResourceMarked(string dataName)
        {
            var newValue  = StringConstants.MgDataFilePath + dataName;
            var currValue = _fs.GetConnectionProperty(this.FileFdoProperty);

            if (!newValue.Equals(currValue))
            {
                _fs.SetConnectionProperty(this.FileFdoProperty, newValue);
            }
        }
Пример #9
0
 public override void Bind(IEditorService service)
 {
     base.Bind(service);
     _service = service;
     _fs = service.GetEditedResource() as IFeatureSource;
     Debug.Assert(_fs != null);
     if (_fs.ConnectionPropertyNames.Length == 0)
     {
         _fs.SetConnectionProperty("DefaultFileLocation", StringConstants.MgDataFilePath); //NOXLATE
     }
     MarkSelected();
     resDataCtrl.ResourceDataUploaded += new Maestro.Editors.Common.ResourceDataCtrl.ResourceUploadEventHandler(OnResourceDataUploaded);
 }
Пример #10
0
 public override void Bind(IEditorService service)
 {
     base.Bind(service);
     _service = service;
     _fs      = service.GetEditedResource() as IFeatureSource;
     Debug.Assert(_fs != null);
     if (_fs.ConnectionPropertyNames.Length == 0)
     {
         _fs.SetConnectionProperty("DefaultFileLocation", StringConstants.MgDataFilePath); //NOXLATE
     }
     MarkSelected();
     resDataCtrl.ResourceDataUploaded += new Maestro.Editors.Common.ResourceDataCtrl.ResourceUploadEventHandler(OnResourceDataUploaded);
 }
Пример #11
0
        /// <summary>
        /// Sets the connection properties of the feature source
        /// </summary>
        /// <param name="fs"></param>
        /// <param name="values"></param>
        public static void ApplyConnectionProperties(this IFeatureSource fs, NameValueCollection values)
        {
            Check.ArgumentNotNull(fs, nameof(fs));
            Check.ArgumentNotNull(values, nameof(values));

            fs.ClearConnectionProperties();

            foreach (string name in values.Keys)
            {
                string value = values[name];

                fs.SetConnectionProperty(name, value);
            }
        }
        /// <summary>
        /// Sets the connection properties of the feature source
        /// </summary>
        /// <param name="fs"></param>
        /// <param name="values"></param>
        public static void ApplyConnectionProperties(this IFeatureSource fs, NameValueCollection values)
        {
            Check.NotNull(fs, "fs");         //NOXLATE
            Check.NotNull(values, "values"); //NOXLATE

            fs.ClearConnectionProperties();

            foreach (string name in values.Keys)
            {
                string value = values[name];

                fs.SetConnectionProperty(name, value);
            }
        }
Пример #13
0
        public override void Bind(IEditorService service)
        {
            base.Bind(service);
            _service = service;
            _fs = _service.GetEditedResource() as IFeatureSource;
            Debug.Assert(_fs != null);

            MarkSelected();

            //HACK: Set ReadOnly property if not specified otherwise this will be an invalid feature source
            if (string.IsNullOrEmpty(_fs.GetConnectionProperty("ReadOnly"))) //NOXLATE
                _fs.SetConnectionProperty("ReadOnly", "FALSE"); //NOXLATE

            chkReadOnly.Checked = _fs.GetConnectionProperty("ReadOnly").ToUpper().Equals(true.ToString().ToUpper()); //NOXLATE
        }
Пример #14
0
        public override void Bind(IEditorService service)
        {
            base.Bind(service);
            _service = service;
            _fs      = service.GetEditedResource() as IFeatureSource;
            Debug.Assert(_fs != null);

            MarkSelected();

            //HACK: Set UseFdoMetadata property if not specified otherwise this will be an invalid feature source
            if (string.IsNullOrEmpty(_fs.GetConnectionProperty("UseFdoMetadata")))                                               //NOXLATE
            {
                _fs.SetConnectionProperty("UseFdoMetadata", "FALSE");                                                            //NOXLATE
            }
            chkUseFdoMetadata.Checked = _fs.GetConnectionProperty("UseFdoMetadata").ToUpper().Equals(true.ToString().ToUpper()); //NOXLATE
        }
Пример #15
0
        private void InitGrid()
        {
            grdConnectionParameters.Rows.Clear();
            grdConnectionParameters.Columns.Clear();
            var prov = _service.CurrentConnection.FeatureService.GetFeatureProvider(_fs.Provider);

            var colName = new DataGridViewColumn();

            colName.Name         = "COL_NAME"; //NOXLATE
            colName.HeaderText   = Strings.ColHeaderName;
            colName.ReadOnly     = true;
            colName.CellTemplate = new DataGridViewTextBoxCell();
            var colValue = new DataGridViewColumn();

            colValue.Name         = "COL_VALUE"; //NOXLATE
            colValue.HeaderText   = Strings.ColHeaderValue;
            colValue.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            colValue.CellTemplate = new DataGridViewTextBoxCell();

            grdConnectionParameters.Columns.Add(colName);
            grdConnectionParameters.Columns.Add(colValue);

            foreach (var p in prov.ConnectionProperties)
            {
                var row      = new DataGridViewRow();
                var nameCell = new DataGridViewTextBoxCell();
                nameCell.Value       = p.Name;
                nameCell.ToolTipText = p.LocalizedName;

                var currentValue           = _fs.GetConnectionProperty(p.Name);
                DataGridViewCell valueCell = null;
                if (p.Enumerable)
                {
                    valueCell       = new DataGridViewTextBoxCell();
                    valueCell.Tag   = p;
                    valueCell.Value = currentValue;
                }
                else
                {
                    valueCell       = new DataGridViewTextBoxCell();
                    valueCell.Tag   = p;
                    valueCell.Value = currentValue;
                }

                if (string.IsNullOrEmpty(currentValue) && !string.IsNullOrEmpty(p.DefaultValue))
                {
                    valueCell.Value = p.DefaultValue;
                    _fs.SetConnectionProperty(p.Name, p.DefaultValue);
                }

                row.Cells.Add(nameCell);
                row.Cells.Add(valueCell);

                if (p.Protected)
                {
                    pwdCells.Add(valueCell);
                }

                grdConnectionParameters.Rows.Add(row);
            }
        }
        public override void Bind(IEditorService service)
        {
            _init    = true;
            _service = service;
            _fs      = (IFeatureSource)_service.GetEditedResource();

            resDataCtrl.Init(service);
            if (_fs.UsesEmbeddedDataFiles)
            {
                var df = _fs.GetEmbeddedDataName();
                resDataCtrl.MarkedFile = df;
            }

            var values = _fs.GetConnectionProperties();

            txtDataSource.Text  = values[P_DATASOURCE];
            chkReadOnly.Checked = values[P_READONLY] == "TRUE";                                   //NOXLATE

            var prov = _service.CurrentConnection.FeatureService.GetFeatureProvider("OSGeo.OGR"); //NOXLATE

            foreach (var p in prov.ConnectionProperties.Where(p => p.Name != P_DATASOURCE && p.Name != P_READONLY))
            {
                var row      = new DataGridViewRow();
                var nameCell = new DataGridViewTextBoxCell();
                nameCell.Value       = p.Name;
                nameCell.ToolTipText = p.LocalizedName;

                var currentValue           = _fs.GetConnectionProperty(p.Name);
                DataGridViewCell valueCell = null;
                if (p.Enumerable)
                {
                    valueCell       = new DataGridViewTextBoxCell();
                    valueCell.Tag   = p;
                    valueCell.Value = currentValue;
                }
                else
                {
                    valueCell       = new DataGridViewTextBoxCell();
                    valueCell.Tag   = p;
                    valueCell.Value = currentValue;
                }

                if (string.IsNullOrEmpty(currentValue) && !string.IsNullOrEmpty(p.DefaultValue))
                {
                    valueCell.Value = p.DefaultValue;
                    _fs.SetConnectionProperty(p.Name, p.DefaultValue);
                }

                row.Cells.Add(nameCell);
                row.Cells.Add(valueCell);

                if (p.Protected)
                {
                    pwdCells.Add(valueCell);
                }

                grdOtherProperties.Rows.Add(row);
            }

            _init = false;
        }
Пример #17
0
        public override void Bind(IEditorService service)
        {
            _bChangedUsername       = false;
            _bChangedPassword       = false;
            _service                = service;
            _service.BeforeSave    += OnBeforeSave;
            _service.BeforePreview += OnBeforePreview;
            _service.RegisterCustomNotifier(this);
            _fs = _service.GetEditedResource() as IFeatureSource;

            //Set the field values
            txtService.Text = _fs.GetConnectionProperty("Service"); //NOXLATE

            //We're gonna follow MG Studio behaviour here which is: Never load the password
            //and auto trigger dirty state.
            if (!_service.IsNew)
            {
                txtUsername.Text = _fs.GetEncryptedUsername(_service.CurrentConnection) ?? _fs.GetConnectionProperty("Username"); //NOXLATE
                txtPassword.Text = GenerateRandomFakeString();
            }

            //Set initial value of data store if possible
            var dstore = _fs.GetConnectionProperty("DataStore"); //NOXLATE

            txtDataStore.Text = dstore;

            //As our connection properties are not CLR properties,
            //"manually" bind these fields
            txtService.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("Service", txtService.Text); //NOXLATE
            };

            txtUsername.TextChanged += (s, e) =>
            {
                _bChangedUsername = true;
                if (string.IsNullOrEmpty(txtUsername.Text))
                {
                    _fs.SetConnectionProperty("Username", null); //NOXLATE
                }
                else
                {
                    _fs.SetConnectionProperty("Username", txtUsername.Text); //NOXLATE
                }
            };

            txtPassword.TextChanged += (s, e) =>
            {
                _bChangedPassword = true;
                if (string.IsNullOrEmpty(txtPassword.Text))
                {
                    _fs.SetConnectionProperty("Password", null); //NOXLATE
                }
                else
                {
                    _fs.SetConnectionProperty("Password", txtPassword.Text); //NOXLATE
                }
            };

            txtDataStore.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("DataStore", txtDataStore.Text); //NOXLATE
            };
        }
Пример #18
0
        public override void Bind(IEditorService service)
        {
            _bChangedUsername = false;
            _bChangedPassword = false;
            _service = service;
            _service.BeforeSave += OnBeforeSave;
            _service.BeforePreview += OnBeforePreview;
            _service.RegisterCustomNotifier(this);
            _fs = _service.GetEditedResource() as IFeatureSource;

            //Set the field values
            txtService.Text = _fs.GetConnectionProperty("Service"); //NOXLATE

            //We're gonna follow MG Studio behaviour here which is: Never load the password
            //and auto trigger dirty state.
            if (!_service.IsNew)
            {
                txtUsername.Text = _fs.GetEncryptedUsername() ?? _fs.GetConnectionProperty("Username"); //NOXLATE
                txtPassword.Text = GenerateRandomFakeString();
            }

            //Set initial value of data store if possible
            var dstore = _fs.GetConnectionProperty("DataStore"); //NOXLATE
            txtDataStore.Text = dstore;

            //As our connection properties are not CLR properties,
            //"manually" bind these fields
            txtService.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("Service", txtService.Text); //NOXLATE
            };

            txtUsername.TextChanged += (s, e) =>
            {
                _bChangedUsername = true;
                if (string.IsNullOrEmpty(txtUsername.Text))
                    _fs.SetConnectionProperty("Username", null); //NOXLATE
                else
                    _fs.SetConnectionProperty("Username", txtUsername.Text); //NOXLATE
            };

            txtPassword.TextChanged += (s, e) =>
            {
                _bChangedPassword = true;
                if (string.IsNullOrEmpty(txtPassword.Text))
                    _fs.SetConnectionProperty("Password", null); //NOXLATE
                else
                    _fs.SetConnectionProperty("Password", txtPassword.Text); //NOXLATE
            };

            txtDataStore.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("DataStore", txtDataStore.Text); //NOXLATE
            };
        }