예제 #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 OnExecute(object sender, EventArgs e)
        {
            var pdlg = new ProgressDialog();

            pdlg.CancelAbortsThread = true;

            var worker = new ProgressDialog.DoBackgroundWork(ExecuteLoadProcedure);

            try
            {
                _ed.SyncSessionCopy();
                var result = pdlg.RunOperationAsync(this.ParentForm, worker, _ed, _lp);
                MessageBox.Show(Strings.OperationCompleted);
                _ed.RequestRefresh(_lp.SubType.RootPath);

                //Load procedure may have modified this resource as part of executioin
                _ed.SyncSessionCopy();
                //HACK: Force dirty state as successful execution writes some extra XML content to the resource
                _ed.MarkDirty();
            }
            catch (CancelException)
            {
                MessageBox.Show(Strings.OperationCancelled);
            }
        }
예제 #3
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            txtConnectionStatus.Text = string.Empty;
            if (this.ChildEditor != null)
            {
                var props = Use64BitDriver ? this.ChildEditor.Get64BitConnectionProperties() : this.ChildEditor.ConnectionProperties;
                _fs.ApplyConnectionProperties(props);
                //Flush back to session before testing
                _service.SyncSessionCopy();
                string result = _service.CurrentConnection.FeatureService.TestConnection(_fs.ResourceID);

                txtConnectionStatus.Text = string.Format(Strings.FdoConnectionStatus, result);
            }
        }
        private void lnkSetCredentials_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var prov      = _service.CurrentConnection.FeatureService.GetFeatureProvider(_fs.Provider);
            var connProps = new List <string>();

            foreach (var p in prov.ConnectionProperties)
            {
                if (!p.Enumerable)
                {
                    connProps.Add(p.Name);
                }
            }
            using (var diag = new SetCredentialsDialog(connProps.ToArray()))
            {
                if (diag.ShowDialog() == DialogResult.OK)
                {
                    _fs.SetConnectionProperty(diag.UserProperty, StringConstants.MgUsernamePlaceholder);
                    _fs.SetConnectionProperty(diag.PasswordProperty, StringConstants.MgPasswordPlaceholder);
                    _fs.SetEncryptedCredentials(_service.CurrentConnection, diag.Username, diag.Password);
                    _service.SyncSessionCopy();
                    InitGrid();
                    resDataCtrl.Init(_service);
                }
            }
        }
예제 #5
0
        private void lnkApplyCredentials_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string connStr = txtConnStr.Text;

            if (connStr.Contains(StringConstants.MgUsernamePlaceholder) &&
                connStr.Contains(StringConstants.MgPasswordPlaceholder))
            {
                using (var diag = new SetCredentialsDialog(StringConstants.MgUsernamePlaceholder, StringConstants.MgPasswordPlaceholder))
                {
                    if (diag.ShowDialog() == DialogResult.OK)
                    {
                        var fs = (IFeatureSource)_service.GetEditedResource();
                        fs.SetEncryptedCredentials(_service.CurrentConnection, diag.Username, diag.Password);
                        //Bit of a hack as parent does a 64-bit driver check to determine
                        //which NameValueCollection to return from the child, but we can
                        //get away with this because the same NameValueCollection is returned
                        //for both
                        fs.ApplyConnectionProperties(this.ConnectionProperties);
                        _service.SyncSessionCopy();
                        MessageBox.Show("Credentials applied");
                    }
                }
            }
            else
            {
                MessageBox.Show(Strings.OdbcConnStrMissingMgPlaceholders);
            }
        }
예제 #6
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            txtStatus.Text = string.Empty;
            //Flush back to session before testing
            _service.SyncSessionCopy();
            var result = _service.CurrentConnection.FeatureService.TestConnection(_fs.ResourceID);

            txtStatus.Text = string.Format(Strings.FdoConnectionStatus, result);
        }
 private void UpdatePreviewImage()
 {
     using (new WaitCursor(this))
     {
         m_editor.SyncSessionCopy();
         _previewImg = _mappingSvc.GetLegendImage(_preview.Scale, _preview.LayerDefinition, _preview.ThemeCategory, 2, previewPicture.Width, previewPicture.Height, _preview.ImageFormat);
         previewPicture.Invalidate();
     }
 }
 private void UpdatePreviewImage()
 {
     using (new WaitCursor(this))
     {
         _edSvc.SyncSessionCopy();
         _previewImg = _mappingSvc.GetLegendImage(_preview.Scale, _preview.LayerDefinition, _preview.ThemeCategory, 4, symPreview.Width, symPreview.Height, _preview.ImageFormat);
         symPreview.Invalidate();
     }
 }
예제 #9
0
 private void btnTest_Click(object sender, EventArgs e)
 {
     txtStatus.Text = string.Empty;
     using (new WaitCursor(this))
     {
         _service.SyncSessionCopy();
         var result = _service.CurrentConnection.FeatureService.TestConnection(_fs.ResourceID);
         txtStatus.Text = string.Format(Strings.FdoConnectionStatus, result);
     }
 }
예제 #10
0
        private void OnResourceDataMarked(object sender, string dataName)
        {
            _dws.SourceName = dataName;

            //Re-calc sheet extents for this DWF
            using (new WaitCursor(this))
            {
                _dws.RemoveAllSheets();
                _edSvc.SyncSessionCopy();

                //Re-populate sheets
                _dws.RegenerateSheetList(_edSvc.CurrentConnection);

                _edSvc.SyncSessionCopy();
                //Re-calc extents
                _dws.UpdateExtents(_edSvc.CurrentConnection);
                OnResourceChanged();
            }
        }
예제 #11
0
        private void btnDeleteRule_Click(object sender, EventArgs e)
        {
            //Minimum content model dictates that we must have at least one rule
            if (grdRules.Rows.Count == 1)
            {
                return;
            }

            List <RuleModel> remove = new List <RuleModel>();

            foreach (DataGridViewRow row in grdRules.SelectedRows)
            {
                remove.Add((RuleModel)row.DataBoundItem);
            }

            if (remove.Count > 0)
            {
                try
                {
                    _init = true;
                    //Remove in reverse order
                    foreach (var r in remove)
                    {
                        _rules.Remove(r);
                    }
                }
                finally
                {
                    //Yes, we're going thermonuclear, simply because the BindingList's ordering may be out of sync with the underlying
                    //model as a result of removing rules. Since the BindingList is currently the point of truth (we just made changes to it),
                    //the underlying model has to be updated to match
                    ReSyncBindingListToRules(_style);
                    _edSvc.SyncSessionCopy();
                    _init = false;
                    GenerateStylePreviewsForVisibleRows(false);
                    _edSvc.HasChanged();
                }
            }
        }
예제 #12
0
        private void btnDiff_Click(object sender, EventArgs e)
        {
            TextFileDiffList sLF        = null;
            TextFileDiffList dLF        = null;
            string           sourceFile = null;
            string           targetFile = null;

            try
            {
                _edSvc.SyncSessionCopy();
                var set = XmlCompareUtil.PrepareForComparison(_edSvc.CurrentConnection.ResourceService,
                                                              _edSvc.ResourceID,
                                                              _edSvc.EditedResourceID);
                sLF = set.Source;
                dLF = set.Target;
            }
            catch (Exception ex)
            {
                ErrorDialog.Show(ex);
                return;
            }
            finally
            {
                try { File.Delete(sourceFile); }
                catch { }
                try { File.Delete(targetFile); }
                catch { }
            }

            try
            {
                double     time = 0;
                DiffEngine de   = new DiffEngine();
                time = de.ProcessDiff(sLF, dLF, DiffEngineLevel.SlowPerfect);

                var          rep = de.DiffReport();
                TextDiffView dlg = new TextDiffView(sLF, dLF, rep, time);
                dlg.SetLabels(_edSvc.ResourceID, Strings.EditedResource);
                dlg.ShowDialog();
                dlg.Dispose();
            }
            catch (Exception ex)
            {
                string nl  = Environment.NewLine;
                string tmp = $"{ex.Message}{nl}{nl}***STACK***{nl}{ex.StackTrace}";
                MessageBox.Show(tmp, Strings.CompareError);
                return;
            }
        }
예제 #13
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //The editor has been modify an in-memory model. This needs to be serialized back to
     //the session copy first
     _edSvc.SyncSessionCopy();
     //Call save on the editor service to commit back the changes from the session copy
     //back to the original resource
     _edSvc.Save();
     //Restore title
     if (this.Text.EndsWith(" *"))
     {
         this.Text = this.Text.Substring(0, this.Text.Length - 2);
     }
     MessageBox.Show("Saved");
 }
예제 #14
0
 public void SyncSessionCopy() => _inner.SyncSessionCopy();