///////////////////////////////////////////////////////////////////////////////////////////////////////////////

        // This event handler deals with the results of the background operation
        private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            TxtOutput.AppendText("\n");

            if (e.Cancelled)
            {
                TxtOutput.AppendText("Process Cancelled 🚫");
                BtnCancel.Content   = "Cancel";
                BtnCancel.IsEnabled = true;
            }
            else if (e.Error != null)
            {
                TxtOutput.AppendText(
                    "ERROR!\nThe following error occured during the conversion:\n\n" + e.Error.Message
                    );
            }
            else
            {
                TxtOutput.AppendText("Finished");
            }

            BtnOpenFile.Visibility  = Visibility.Visible;
            BtnCancel.Visibility    = Visibility.Collapsed;
            WpOffsetInput.IsEnabled = true;
        }
        private void LogConfigSettings(CreationType creationType)
        {
            var properties = Settings.ExtensionConfig.GetType().GetProperties().ToDictionary(
                k => k.Name,
                v => v.GetValue(Settings.ExtensionConfig)?.ToString() ?? string.Empty);

            foreach (var kvp in properties.ToList())
            {
                if (kvp.Key.ToLower().EndsWith("list"))
                {
                    properties.Add(kvp.Key + "Count", string.IsNullOrWhiteSpace(kvp.Value)
                        ? "0"
                        : kvp.Value.Split('|').Length.ToString());
                }
            }

            properties["AudibleCompletionNotification"] = Settings.AudibleCompletionNotification.ToString();
            properties["CrmSvcUtilRelativePath"]        = Settings.CrmSvcUtilRelativePath;
            properties["IncludeCommandLine"]            = Settings.IncludeCommandLine.ToString();
            properties["MaskPassword"]    = Settings.MaskPassword.ToString();
            properties["SupportsActions"] = Settings.SupportsActions.ToString();
            properties["UseCrmOnline"]    = Settings.UseCrmOnline.ToString();
            properties["Version"]         = Settings.Version;
            properties["CreationType"]    = creationType.ToString();

            if (Telemetry.Enabled)
            {
                TxtOutput.AppendText($"Tracking {creationType} Generation Event." + Environment.NewLine);
                Telemetry.TrackEvent("ConfigSettings", properties);
            }
            else
            {
                TxtOutput.AppendText("Tracking not enabled!  Please consider allowing the Xrm Tool Box to send anonymous statistics via the Configuration --> Settings -- Data Collect.  This allows reporting for which features are used and what features can be deprecated." + Environment.NewLine);
            }
        }
 private void HydrateUiFromSettings(string settingsPath)
 {
     try
     {
         Settings = EarlyBoundGeneratorConfig.Load(settingsPath);
         Settings.CrmSvcUtilRealtiveRootPath = Paths.PluginsPath;
         SettingsMap = new SettingsMap(this, Settings)
         {
             SettingsPath = settingsPath
         };
         PropertiesGrid.SelectedObject = SettingsMap;
         SkipSaveSettings = false;
     }
     catch (Exception ex)
     {
         TxtOutput.AppendText($"Unable to Load Settings from Config file: {settingsPath}.  {ex}");
         var result = MessageBox.Show(@"The Settings File is either empty or malformed.  Would you like to reset the file to the default settings?", @"Unable to Load Settings!", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
         if (result == DialogResult.Yes)
         {
             Settings = EarlyBoundGeneratorConfig.GetDefault();
             Settings.CrmSvcUtilRealtiveRootPath = Paths.PluginsPath;
         }
         else
         {
             SkipSaveSettings = true;
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Updates "console" with a message in a specific color
        /// </summary>
        /// <param name="updateMsg">Message to output to "console"</param>
        /// <param name="color">Color from list of: yel, grn, blu, red</param>
        private void UpdateConsole(string updateMsg, string color)
        {
            // Check color input against list of used colors
            Color textColor = new Color();

            switch (color)
            {
            case "yel":     // Minor errors or important notices
                textColor = Color.Yellow;
                break;

            case "grn":     // Completed steps/tasks
                textColor = Color.Lime;
                break;

            case "blu":     // Started steps/tasks
                textColor = Color.Aqua;
                break;

            case "red":     // Errors
                textColor = Color.Red;
                break;

            default:
                textColor = Color.White;
                break;
            }

            // Output message with color
            TxtOutput.AppendText(Environment.NewLine + DateTime.Now.ToString("HH:mm:ss") + " >> " + updateMsg, textColor);
            TxtOutput.SelectionStart = TxtOutput.Text.Length;
            TxtOutput.ScrollToCaret();
        }
Пример #5
0
        private void HydrateUiFromSettings(string settingsPath)
        {
            try
            {
                Settings = EarlyBoundGeneratorConfig.Load(settingsPath);
                Settings.CrmSvcUtilRealtiveRootPath = Paths.PluginsPath;
                SkipSaveSettings = false;
            }
            catch (Exception ex)
            {
                TxtOutput.AppendText($"Unable to Load Settings from Config file: {settingsPath}.  {ex}");
                var result = MessageBox.Show(@"The Settings File is either empty or malformed.  Would you like to reset the file to the default settings?", @"Unable to Load Settings!", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    Settings = EarlyBoundGeneratorConfig.GetDefault();
                    Settings.CrmSvcUtilRealtiveRootPath = Paths.PluginsPath;
                }
                else
                {
                    SkipSaveSettings = true;
                }
            }

            ChkAddDebuggerNonUserCode.Checked     = Settings.ExtensionConfig.AddDebuggerNonUserCode;
            ChkAddFilesToProject.Checked          = Settings.ExtensionConfig.AddNewFilesToProject;
            ChkAudibleCompletion.Checked          = Settings.AudibleCompletionNotification;
            ChkCreateOneActionFile.Checked        = Settings.ExtensionConfig.CreateOneFilePerAction;
            ChkCreateOneEntityFile.Checked        = Settings.ExtensionConfig.CreateOneFilePerEntity;
            ChkCreateOneOptionSetFile.Checked     = Settings.ExtensionConfig.CreateOneFilePerOptionSet;
            ChkEditableResponseActions.Checked    = Settings.ExtensionConfig.MakeResponseActionsEditable;
            ChkIncludeCommandLine.Checked         = Settings.IncludeCommandLine;
            ChkMakeReadonlyFieldsEditable.Checked = Settings.ExtensionConfig.MakeReadonlyFieldsEditable;
            ChkMaskPassword.Checked = Settings.MaskPassword;
            ChkGenerateActionAttributeNameConsts.Checked = Settings.ExtensionConfig.GenerateActionAttributeNameConsts;
            ChkGenerateAttributeNameConsts.Checked       = Settings.ExtensionConfig.GenerateAttributeNameConsts;
            ChkGenerateAnonymousTypeConstructor.Checked  = Settings.ExtensionConfig.GenerateAnonymousTypeConstructor;
            ChkGenerateEntityRelationships.Checked       = Settings.ExtensionConfig.GenerateEntityRelationships;
            ChkGenerateOptionSetEnums.Checked            = Settings.ExtensionConfig.GenerateEnumProperties;
            ChkRemoveRuntimeComment.Checked         = Settings.ExtensionConfig.RemoveRuntimeVersionComment;
            ChkUseDeprecatedOptionSetNaming.Checked = Settings.ExtensionConfig.UseDeprecatedOptionSetNaming;
            ChkUseTFS.Checked               = Settings.ExtensionConfig.UseTfsToCheckoutFiles;
            ChkUseXrmClient.Checked         = Settings.ExtensionConfig.UseXrmClient;
            TxtActionPath.Text              = Settings.ActionOutPath;
            TxtEntityPath.Text              = Settings.EntityOutPath;
            TxtInvalidCSharpNamePrefix.Text = Settings.ExtensionConfig.InvalidCSharpNamePrefix;
            TxtOptionSetFormat.Text         = Settings.ExtensionConfig.LocalOptionSetFormat;
            TxtLanguageCodeOverride.Text    = Settings.ExtensionConfig.OptionSetLanguageCodeOverride + "";
            TxtNamespace.Text               = Settings.Namespace;
            TxtOptionSetPath.Text           = Settings.OptionSetOutPath;
            TxtServiceContextName.Text      = Settings.ServiceContextName;

            // Hide or show labels based on checked preferences
            LblActionsDirectory.Visible    = ChkCreateOneActionFile.Checked;
            LblActionPath.Visible          = !LblActionsDirectory.Visible;
            LblEntitiesDirectory.Visible   = ChkCreateOneEntityFile.Checked;
            LblEntityPath.Visible          = !LblEntitiesDirectory.Visible;
            LblOptionSetsDirectory.Visible = ChkCreateOneOptionSetFile.Checked;
            LblOptionSetPath.Visible       = !LblOptionSetsDirectory.Visible;
            SetAddFilesToProjectVisibility();
        }
Пример #6
0
        private void GenerateWithDefaultSettings()
        {
            var results = new object[]
            {
                new List <string> {
                    "Y", "C:\\Temp\\AdvXTB\\Abc.Xrm\\Abc.Xrm.sln"
                },
                "Abc.Xrm",
                new NuGetPackage
                {
                    Id               = "Microsoft.CrmSdk.CoreAssemblies",
                    LicenseUrl       = "http://download.microsoft.com/download/E/1/8/E18C0FAD-FEC8-44CD-9A16-98EDC4DAC7A2/LicenseTerms.docx",
                    Name             = "Microsoft Dynamics 365 SDK core assemblies",
                    Version          = new Version("9.0.2.5"),
                    VersionText      = "9.0.2.5",
                    XrmToolingClient = false
                },
                "Y",
                "Abc.Xrm",
                "Abc.Xrm.WorkflowCore",
                new List <string> {
                    "Y", "Abc.Xrm.Test", "Abc.Xrm.TestCore"
                },
                new List <string> {
                    "Y", "Abc.Xrm.Plugin", "0"
                },
                "Abc.Xrm.Plugin.Tests",
                new List <string> {
                    "Y", "Abc.Xrm.Workflow", "1"
                },
                "Abc.Xrm.Workflow.Tests",
                new List <string> {
                    "0", "0"
                },
            };

            var info        = InitializeSolutionInfo.InitializeSolution(results);
            var solutionDir = Path.GetDirectoryName(info.SolutionPath) ?? Guid.NewGuid().ToString();

            if (Directory.Exists(solutionDir))
            {
                foreach (var file in Directory.EnumerateFiles(solutionDir, "*", SearchOption.AllDirectories))
                {
                    File.Delete(file);
                }

                Directory.Delete(solutionDir, true);
            }

            do
            {
                TxtOutput.AppendText("Creating Directory." + Environment.NewLine);
                Directory.CreateDirectory(solutionDir);
            } while (!Directory.Exists(solutionDir));

            File.Copy("C:\\Temp\\AdvXTB\\Abc.Xrm.sln", info.SolutionPath);
            Execute(info);
        }
Пример #7
0
 private void TxtOutput_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.A && e.Control)
     {
         TxtOutput.SelectAll();
         e.Handled          = true;
         e.SuppressKeyPress = true;
     }
 }
Пример #8
0
 private void BtnTryAll_Click(object sender, EventArgs e)
 {
     TxtOutput.Clear();
     for (int a = 0; a < 26; a++)
     {
         TxtOutput.AppendText(a.ToString() + " " + Decipher(TxtInput.Text, a) + System.Environment.NewLine);
     }
     TxtOutput.ScrollToCaret();
 }
Пример #9
0
 public void AddOutput(string txt)
 {
     TxtOutput.BeginInvoke((Action) delegate()
     {
         TxtOutput.AppendText(txt);
         //TxtOutput.SelectionStart = TxtOutput.Text.Length;
         //TxtOutput.ScrollToCaret();
     });
 }
Пример #10
0
        // ReSharper disable once InconsistentNaming
        private void HydrateSettingsFromUI()
        {
            if (ConnectionDetail != null)
            {
                TxtOutput.AppendText("CRM Authentication Type Detected: " + ConnectionDetail.AuthType + Environment.NewLine);
                Settings.AuthType            = ConnectionDetail.AuthType;
                Settings.Domain              = ConnectionDetail.UserDomain;
                Settings.Password            = ConnectionDetail.GetUserPassword();
                Settings.SupportsActions     = ConnectionDetail.OrganizationMajorVersion >= Crm2013;
                Settings.UseConnectionString = Settings.UseConnectionString || Settings.AuthType == AuthenticationProviderType.ActiveDirectory;
                Settings.UseCrmOnline        = ConnectionDetail.UseOnline;
                Settings.UserName            = ConnectionDetail.UserName;
                Settings.Url = Settings.UseConnectionString ?
                               ConnectionDetail.OrganizationServiceUrl.Replace(@"/XRMServices/2011/Organization.svc", string.Empty) :
                               ConnectionDetail.OrganizationServiceUrl;
            }

            Settings.ActionOutPath = TxtActionPath.Text;
            Settings.EntityOutPath = TxtEntityPath.Text;
            if (ChkUseDeprecatedOptionSetNaming.Checked)
            {
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter, @"DLaB.CrmSvcUtilExtensions.OptionSet.CodeWriterFilterService,DLaB.CrmSvcUtilExtensions");
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService, string.Empty);
            }
            else
            {
                var defaultConfig = Config.GetDefault();
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter, defaultConfig.GetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter).Value);
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService, defaultConfig.GetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService).Value);
            }

            var extensions = Settings.ExtensionConfig;

            extensions.AddDebuggerNonUserCode           = ChkAddDebuggerNonUserCode.Checked;
            extensions.AddNewFilesToProject             = ChkAddFilesToProject.Checked;
            extensions.CreateOneFilePerAction           = ChkCreateOneActionFile.Checked;
            extensions.CreateOneFilePerEntity           = ChkCreateOneEntityFile.Checked;
            extensions.CreateOneFilePerOptionSet        = ChkCreateOneOptionSetFile.Checked;
            extensions.GenerateAttributeNameConsts      = ChkGenerateAttributeNameConsts.Checked;
            extensions.GenerateAnonymousTypeConstructor = ChkGenerateAnonymousTypeConstructor.Checked;
            extensions.GenerateEntityRelationships      = ChkGenerateEntityRelationships.Checked;
            extensions.GenerateEnumProperties           = ChkGenerateOptionSetEnums.Checked;
            extensions.InvalidCSharpNamePrefix          = TxtInvalidCSharpNamePrefix.Text;
            extensions.MakeReadonlyFieldsEditable       = ChkMakeReadonlyFieldsEditable.Checked;
            extensions.LocalOptionSetFormat             = TxtOptionSetFormat.Text;
            extensions.RemoveRuntimeVersionComment      = ChkRemoveRuntimeComment.Checked;
            extensions.UseXrmClient = ChkUseXrmClient.Checked;
            extensions.UseDeprecatedOptionSetNaming = ChkUseDeprecatedOptionSetNaming.Checked;
            extensions.UseTfsToCheckoutFiles        = ChkUseTFS.Checked;
            Settings.AudibleCompletionNotification  = ChkAudibleCompletion.Checked;
            Settings.IncludeCommandLine             = ChkIncludeCommandLine.Checked;
            Settings.MaskPassword       = ChkMaskPassword.Checked;
            Settings.Namespace          = TxtNamespace.Text;
            Settings.OptionSetOutPath   = TxtOptionSetPath.Text;
            Settings.ServiceContextName = string.IsNullOrWhiteSpace(TxtServiceContextName.Text) ? null : TxtServiceContextName.Text;
        }
        // ReSharper disable once InconsistentNaming
        private void HydrateSettingsFromUI()
        {
            if (ConnectionDetail != null)
            {
                TxtOutput.AppendText("CRM Authentication Type Detected: " + ConnectionDetail.AuthType + Environment.NewLine);
                Settings.Domain          = GetUserDomain();
                Settings.Password        = ConnectionDetail.GetUserPassword();
                Settings.SupportsActions = ConnectionDetail.OrganizationMajorVersion >= Crm2013;
                Settings.UseCrmOnline    = ConnectionDetail.UseOnline;
                Settings.UserName        = ConnectionDetail.UserName;
                Settings.Url             = ConnectionDetail.GetUrlString();

                if (Settings.UseConnectionString &&
                    string.IsNullOrWhiteSpace(Settings.Password) &&
                    ConnectionDetail.NewAuthType != AuthenticationType.Certificate &&
                    ConnectionDetail.NewAuthType != AuthenticationType.ClientSecret &&
                    ConnectionDetail.NewAuthType != AuthenticationType.OAuth)
                {
                    // Fix for https://github.com/daryllabar/DLaB.Xrm.XrmToolBoxTools/issues/43
                    // Difficulties with Early Bound Generator #43

                    var askForPassword = new PasswordDialog(this);
                    Settings.Password = askForPassword.ShowDialog(this) == DialogResult.OK ? askForPassword.Password : "******";
                }
                if (ConnectionDetail.AuthType == AuthenticationProviderType.ActiveDirectory && string.IsNullOrWhiteSpace(Settings.UserName))
                {
                    Settings.UserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                }
                if (string.IsNullOrWhiteSpace(Settings.ConnectionString))
                {
                    // Load any non-username/password situations via connection string #268
                    Settings.ConnectionString = ConnectionDetail.GetNonUserConnectionString();
                    if (!string.IsNullOrWhiteSpace(Settings.ConnectionString))
                    {
                        Settings.UseConnectionString = true;
                    }
                }
            }

            SettingsMap.PushChanges();
            Settings.RootPath = Path.GetDirectoryName(Path.GetFullPath(TxtSettingsPath.Text));
            if (SettingsMap.UseDeprecatedOptionSetNaming)
            {
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter, @"DLaB.CrmSvcUtilExtensions.OptionSet.CodeWriterFilterService,DLaB.CrmSvcUtilExtensions");
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService, string.Empty);
            }
            else
            {
                var defaultConfig = EarlyBoundGeneratorConfig.GetDefault();
                defaultConfig.CrmSvcUtilRelativeRootPath = Paths.PluginsPath;
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter, defaultConfig.GetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter).Value);
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService, defaultConfig.GetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService).Value);
            }
        }
Пример #12
0
 public void WriteLine(string str)
 {
     if (TxtOutput.InvokeRequired)
     {
         TxtOutput.Invoke(new MethodInvoker(delegate { TxtOutput.Text += str + "\r\n"; }));
     }
     else
     {
         TxtOutput.Text += str + "\r\n";
     }
 }
Пример #13
0
        private void BtnShowResults_Click(object sender, EventArgs e)
        {
            TxtOutput.Text = String.Format("{0,-12}{1,14}\n", "Rating", "Frequency", TxtOutput.Text);
            TxtOutput.AppendText(Environment.NewLine);

            for (int i = 0; i < output.Length / 2; i++)
            {
                TxtOutput.Text += String.Format("{0, -12}{1, 14}", output[i, 0], output[i, 1]);
                TxtOutput.AppendText(Environment.NewLine);
            }
        }
Пример #14
0
 public void Clear()
 {
     if (TxtOutput.InvokeRequired)
     {
         TxtOutput.Invoke(new MethodInvoker(delegate { TxtOutput.Text = ""; }));
     }
     else
     {
         TxtOutput.Text = "";
     }
 }
Пример #15
0
        private void BtnToChar_Click(object sender, EventArgs e)
        {
            TxtOutput.Clear();
            TxtCount.Clear();

            Tuple <Dictionary <char, uint>, Dictionary <char, uint> > tp = Functions.MakeOldCodeDict(TxtInput.Text.ToCharArray());

            DictOldCode  = tp.Item1;
            DictCountDup = tp.Item2;

            ShowLastDict(DictOldCode);
        }
Пример #16
0
        private void BtnReplace_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TxtInput.Text) || string.IsNullOrWhiteSpace(TxtInput.Text))
            {
                return;
            }

            BtnPaste.Enabled   = false;
            BtnReplace.Enabled = false;
            BtnCancel.Enabled  = true;

            DgvData.EndEdit();
            TxtOutput.Clear();

            var output = new StringBuilder();

            foreach (DataGridViewRow r in DgvData.Rows)
            {
                var inputText = TxtInput.Text;

                foreach (DataGridViewCell c in r.Cells)
                {
                    if (c.Value == null)
                    {
                        continue;
                    }

                    inputText = inputText.Replace(c.OwningColumn.HeaderText, c.Value.ToString());
                }

                if (inputText != TxtInput.Text)
                {
                    output.Append(inputText + Environment.NewLine);
                }

                if (_cancel)
                {
                    CancelOperation();
                    return;
                }

                Application.DoEvents();
            }

            TxtOutput.Text = output.ToString();

            BtnPaste.Enabled  = true;
            BtnCancel.Enabled = false;
            MessageBox.Show("Operation complete");
            BtnReplace.Enabled = true;
        }
        private void EarlyBoundGenerator_Load(object sender, EventArgs e)
        {
            if (ConnectionDetail != null)
            {
                DisplayActionsIfSupported(false);
            }
            try
            {
                Settings = EarlyBoundGeneratorConfig.Load(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            }
            catch (Exception ex)
            {
                TxtOutput.AppendText("Unable to Load Settings form Config: " + ex);
                SkipSaveSettings = true;
                Settings         = EarlyBoundGeneratorConfig.GetDefault();
            }
            ChkAddDebuggerNonUserCode.Checked     = Settings.ExtensionConfig.AddDebuggerNonUserCode;
            ChkAddFilesToProject.Checked          = Settings.ExtensionConfig.AddNewFilesToProject;
            ChkAudibleCompletion.Checked          = Settings.AudibleCompletionNotification;
            ChkCreateOneActionFile.Checked        = Settings.ExtensionConfig.CreateOneFilePerAction;
            ChkCreateOneEntityFile.Checked        = Settings.ExtensionConfig.CreateOneFilePerEntity;
            ChkCreateOneOptionSetFile.Checked     = Settings.ExtensionConfig.CreateOneFilePerOptionSet;
            ChkIncludeCommandLine.Checked         = Settings.IncludeCommandLine;
            ChkMakeReadonlyFieldsEditable.Checked = Settings.ExtensionConfig.MakeReadonlyFieldsEditable;
            ChkMaskPassword.Checked = Settings.MaskPassword;
            ChkGenerateAttributeNameConsts.Checked      = Settings.ExtensionConfig.GenerateAttributeNameConsts;
            ChkGenerateAnonymousTypeConstructor.Checked = Settings.ExtensionConfig.GenerateAnonymousTypeConstructor;
            ChkGenerateEntityRelationships.Checked      = Settings.ExtensionConfig.GenerateEntityRelationships;
            ChkGenerateOptionSetEnums.Checked           = Settings.ExtensionConfig.GenerateEnumProperties;
            ChkRemoveRuntimeComment.Checked             = Settings.ExtensionConfig.RemoveRuntimeVersionComment;
            ChkUseDeprecatedOptionSetNaming.Checked     = Settings.ExtensionConfig.UseDeprecatedOptionSetNaming;
            ChkUseTFS.Checked               = Settings.ExtensionConfig.UseTfsToCheckoutFiles;
            ChkUseXrmClient.Checked         = Settings.ExtensionConfig.UseXrmClient;
            TxtActionPath.Text              = Settings.ActionOutPath;
            TxtEntityPath.Text              = Settings.EntityOutPath;
            TxtInvalidCSharpNamePrefix.Text = Settings.ExtensionConfig.InvalidCSharpNamePrefix;
            TxtOptionSetFormat.Text         = Settings.ExtensionConfig.LocalOptionSetFormat;
            TxtNamespace.Text               = Settings.Namespace;
            TxtOptionSetPath.Text           = Settings.OptionSetOutPath;
            TxtServiceContextName.Text      = Settings.ServiceContextName;

            // Hide or show labels based on checked preferences
            LblActionsDirectory.Visible    = ChkCreateOneActionFile.Checked;
            LblActionPath.Visible          = !LblActionsDirectory.Visible;
            LblEntitiesDirectory.Visible   = ChkCreateOneEntityFile.Checked;
            LblEntityPath.Visible          = !LblEntitiesDirectory.Visible;
            LblOptionSetsDirectory.Visible = ChkCreateOneOptionSetFile.Checked;
            LblOptionSetPath.Visible       = !LblOptionSetsDirectory.Visible;
            SetAddFilesToProjectVisibility();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

        // Is called when the open file dialog is closed with a legal file being selected
        private void dlgOpenFile_FileOk(object sender, CancelEventArgs e)
        {
            // Set up GUI for conversion
            BtnOpenFile.Visibility  = Visibility.Collapsed;
            BtnCancel.Visibility    = Visibility.Visible;
            WpOffsetInput.IsEnabled = false;
            LblProgress.Content     = "Progress: 0%";
            TxtOutput.Clear();
            TxtOutput.Visibility = Visibility.Visible;

            // Record the offset before starting the conversion
            _offsetMs = getOffsetTime();

            // Run the BackgroundWorker asynchronously to convert the selected files
            _backgroundWorker.RunWorkerAsync();
        }
Пример #19
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            ActivateTests(false, false, false, false, false, false, false, false, false, false,
                          false, false, false, false, false, false, false, false, false, false, false,
                          false, false, false, false, false, false, false);

            _engine = new OpenDMS.Storage.Providers.CouchDB.Engine();
            _db     = new OpenDMS.Storage.Providers.CouchDB.Database(
                new OpenDMS.Storage.Providers.CouchDB.Server("http", "192.168.1.111", 5984, 50000, 4096),
                "test1");

            TxtOutput.Text = "Welcome to the OpenDMS.Storage Testing Environment.  This application allows for simple testing of the OpenDMS.Storage library and those libraries used by the OpenDMS.Storage library.\r\n\r\nThis window will display the results of the tests.\r\n\r\nSome tests must be run in certain orders.  Available tests will have enabled buttons, tests that cannot be run will be greyed out.\r\n\r\n";
            TxtOutput.Select(TxtOutput.Text.Length, 0);

            DetermineIfInstalled();
        }
Пример #20
0
        private void BwMiniXml_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                TxtOutput.Text = e.Error.Message;
                TxtOutput.RefreshUndoRedoButton();
            }
            else
            {
                TxtXml.Text = e.Result?.ToString();
                TxtXml.RefreshUndoRedoButton();
            }

            ClearAllSelections(XmlMiniButton.GetCurrentParent());
            EnableControls(true);
        }
Пример #21
0
        private void WriteOutput(Dictionary <int, string> dictionary)
        {
            TxtOutput.Text = "enum Permissions" + Environment.NewLine +
                             "{" + Environment.NewLine;

            foreach (var item in dictionary)
            {
                TxtOutput.Text += "\t" + Regex.Replace(item.Value, "[.,@;\\/:*?\"<>|&']", "_") + " = " + item.Key + "," + Environment.NewLine;
            }

            TxtOutput.Text += "}";

            TxtOutput.Focus();

            Clipboard.SetText(TxtOutput.Text);
        }
Пример #22
0
        private void Form1_Load(object sender, EventArgs e)
        {
            ToolStripStatusLabel1.Text = string.Empty;
            ToolStripStatusLabel2.Text = string.Empty;
            TxtXml.EmptyUndoBuffer();
            TxtXslt.EmptyUndoBuffer();
            TxtOutput.EmptyUndoBuffer();

            IEnumerable <Control> GetAll(Control control)
            {
                var controls = control.Controls.Cast <Control>();

                return(controls.SelectMany(ctrl => GetAll(ctrl)).Concat(controls));
            }

            _controlsListBlockable = GetAll(this).Where(t => t.Tag?.ToString() == "blockable").ToList();
        }
Пример #23
0
        private void BtnLoadSelectedFiles_Click(object sender, EventArgs e)
        {
            TxtInput.Clear();
            List <string> FilesToLoad = new List <string>();

            foreach (var file in LstFiles.SelectedItems)
            {
                FilesToLoad.Add(file.ToString());
            }
            TxtInput.Text = Functions.LoadFiles(FilesToLoad);

            TxtOutput.Clear();
            TxtCount.Clear();

            Tuple <Dictionary <char, uint>, Dictionary <char, uint> > tp = Functions.MakeOldCodeDict(TxtInput.Text.ToCharArray());

            DictOldCode  = tp.Item1;
            DictCountDup = tp.Item2;

            ShowLastDict(DictOldCode);
        }
Пример #24
0
        private void ExecuteBttn_Click(object sender, EventArgs e)
        {
            try
            {
                switch (ActionCmb.SelectedIndex)
                {
                case 0:
                    ShowAddAcceleratorsWizard();
                    break;

                case 1:
                    ShowAddAssemblyWizard();
                    break;

                case 2:
                    ExecuteInstallCodeSnippets();
                    break;

                case 3:
                    GenerateWithDefaultSettings();
                    break;

                case 4:
                    GenerateAddAssemblyWithDefaultSettings();
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, @"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtOutput.AppendText(Environment.NewLine + ex);
            }
        }
Пример #25
0
        private void CmdStart_Click(object sender, EventArgs e)
        {
            TxtOutput.Clear();
            int loop = 0;

            /*int value = Convert.ToInt32(TxtInput.Text);
             *
             * while (value > 0)
             * {
             *  value /= 2;
             *  TxtOutput.Text += value + "\r\n";
             *  loop++;
             * }*/

            int    value = 0;
            string data  = "";
            Random r     = new Random();
            int    input = Convert.ToInt32(TxtInput.Text);

            if (input >= 0 && input <= 1000)
            {
                do
                {
                    value = r.Next(0, 10000);
                    data += value + ", ";
                    loop++;
                } while (value != input);

                TxtOutput.Text     = data;
                LblNumRepeats.Text = loop.ToString();
            }
            else
            {
                MessageBox.Show("Zahl muss zwischen 0 und 1000 leigen :)");
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

        // This event handler executes on the main thread to update displayed progress in the GUI
        private void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            LblProgress.Content = "Progress: " + e.ProgressPercentage + "%";
            TxtOutput.AppendText((string)e.UserState); // Append the message to the output textbox
            TxtOutput.ScrollToEnd();                   // Scroll to the bottom to keep the most recently converted files visible
        }
Пример #27
0
 private void Write(object data)
 {
     TxtOutput.AppendText("" + data);
 }
Пример #28
0
        // ReSharper disable once InconsistentNaming
        private void HydrateSettingsFromUI()
        {
            if (ConnectionDetail != null)
            {
                TxtOutput.AppendText("CRM Authentication Type Detected: " + ConnectionDetail.AuthType + Environment.NewLine);
                Settings.AuthType            = ConnectionDetail.AuthType;
                Settings.Domain              = GetUserDomain();
                Settings.Password            = ConnectionDetail.GetUserPassword();
                Settings.SupportsActions     = ConnectionDetail.OrganizationMajorVersion >= Crm2013;
                Settings.UseConnectionString = Settings.UseConnectionString; // #151 || Settings.AuthType == AuthenticationProviderType.ActiveDirectory;
                Settings.UseCrmOnline        = ConnectionDetail.UseOnline;
                Settings.UserName            = ConnectionDetail.UserName;
                Settings.Url = GetUrlString();

                if (Settings.UseConnectionString && string.IsNullOrWhiteSpace(Settings.Password))
                {
                    // Fix for https://github.com/daryllabar/DLaB.Xrm.XrmToolBoxTools/issues/43
                    // Difficulties with Early Bound Generator #43

                    var askForPassowrd = new PasswordDialog(this);
                    Settings.Password = askForPassowrd.ShowDialog(this) == DialogResult.OK ? askForPassowrd.Password : "******";
                }
                if (ConnectionDetail.AuthType == AuthenticationProviderType.ActiveDirectory && string.IsNullOrWhiteSpace(Settings.UserName))
                {
                    Settings.UserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                }
            }

            Settings.ActionOutPath = TxtActionPath.Text;
            Settings.EntityOutPath = TxtEntityPath.Text;
            Settings.RootPath      = Path.GetDirectoryName(Path.GetFullPath(TxtSettingsPath.Text));
            if (ChkUseDeprecatedOptionSetNaming.Checked)
            {
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter, @"DLaB.CrmSvcUtilExtensions.OptionSet.CodeWriterFilterService,DLaB.CrmSvcUtilExtensions");
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService, string.Empty);
            }
            else
            {
                var defaultConfig = EarlyBoundGeneratorConfig.GetDefault();
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter, defaultConfig.GetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter).Value);
                Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService, defaultConfig.GetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService).Value);
            }

            var validLanguageCode = int.TryParse(TxtLanguageCodeOverride.Text, out var languageCode);

            var extensions = Settings.ExtensionConfig;

            extensions.AddDebuggerNonUserCode            = ChkAddDebuggerNonUserCode.Checked;
            extensions.AddNewFilesToProject              = ChkAddFilesToProject.Checked;
            extensions.CreateOneFilePerAction            = ChkCreateOneActionFile.Checked;
            extensions.CreateOneFilePerEntity            = ChkCreateOneEntityFile.Checked;
            extensions.CreateOneFilePerOptionSet         = ChkCreateOneOptionSetFile.Checked;
            extensions.GenerateActionAttributeNameConsts = ChkGenerateActionAttributeNameConsts.Checked;
            extensions.GenerateAttributeNameConsts       = ChkGenerateAttributeNameConsts.Checked;
            extensions.GenerateAnonymousTypeConstructor  = ChkGenerateAnonymousTypeConstructor.Checked;
            extensions.GenerateEntityRelationships       = ChkGenerateEntityRelationships.Checked;
            extensions.GenerateEnumProperties            = ChkGenerateOptionSetEnums.Checked;
            extensions.InvalidCSharpNamePrefix           = TxtInvalidCSharpNamePrefix.Text;
            extensions.MakeReadonlyFieldsEditable        = ChkMakeReadonlyFieldsEditable.Checked;
            extensions.MakeResponseActionsEditable       = ChkEditableResponseActions.Checked;
            extensions.LocalOptionSetFormat              = TxtOptionSetFormat.Text;
            extensions.OptionSetLanguageCodeOverride     = validLanguageCode ? languageCode : (int?)null;
            extensions.RemoveRuntimeVersionComment       = ChkRemoveRuntimeComment.Checked;
            extensions.UseXrmClient = ChkUseXrmClient.Checked;
            extensions.UseDeprecatedOptionSetNaming = ChkUseDeprecatedOptionSetNaming.Checked;
            extensions.UseTfsToCheckoutFiles        = ChkUseTFS.Checked;
            Settings.AudibleCompletionNotification  = ChkAudibleCompletion.Checked;
            Settings.IncludeCommandLine             = ChkIncludeCommandLine.Checked;
            Settings.MaskPassword       = ChkMaskPassword.Checked;
            Settings.Namespace          = TxtNamespace.Text;
            Settings.OptionSetOutPath   = TxtOptionSetPath.Text;
            Settings.ServiceContextName = string.IsNullOrWhiteSpace(TxtServiceContextName.Text) ? null : TxtServiceContextName.Text;
        }
Пример #29
0
 private void WriteLine(object data)
 {
     TxtOutput.AppendText(data + Environment.NewLine);
 }
Пример #30
0
        public void CreateCode(CreationType creationType)
        {
            EnableForm(false);

            HydrateSettingsFromUI();
            if (new Version(Settings.Version) < new Version(Settings.SettingsVersion))
            {
                if (MessageBox.Show($@"This version of the Early Bound Generator ({Settings.Version}) is older than the previous ran version from the settings ({Settings.SettingsVersion}).  You should probably update the plugin before running.  Are you sure you want to countinue?", "Older Version detected", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) != DialogResult.Yes)
                {
                    EnableForm(true);
                    return;
                }
            }
            if (!SkipSaveSettings)
            {
                SaveSettings();
            }

            WorkAsync(new WorkAsyncInfo("Shelling out to Command Line...",
                                        (w, e) => // Work To Do Asynchronously
            {
                var settings = (EarlyBoundGeneratorConfig)e.Argument;

                var generator          = new Logic(settings);
                Logic.LogHandler onLog = m => w.ReportProgress(0, m);
                generator.OnLog       += onLog;
                try
                {
                    switch (creationType)
                    {
                    case CreationType.Actions:
                        w.ReportProgress(0, "Executing for Actions");
                        generator.CreateActions();
                        break;

                    case CreationType.All:
                        w.ReportProgress(0, "Executing for All");
                        generator.ExecuteAll();
                        break;

                    case CreationType.Entities:
                        w.ReportProgress(0, "Executing for Entities");
                        generator.CreateEntities();
                        break;

                    case CreationType.OptionSets:
                        w.ReportProgress(0, "Executing for OptionSets");
                        generator.CreateOptionSets();
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(creationType));
                    }
                    w.ReportProgress(99, "Creation Complete!");
                }
                catch (InvalidOperationException ex)
                {
                    w.ReportProgress(int.MinValue, ex.Message);
                }
                catch (Exception ex)
                {
                    w.ReportProgress(int.MinValue, ex.ToString());
                }
                finally
                {
                    generator.OnLog -= onLog;
                }
            })
            {
                AsyncArgument    = Settings,
                PostWorkCallBack = e => // Creation has finished.  Cleanup
                {
                    var result = e.Result as Logic.LogMessageInfo;
                    if (result != null)
                    {
                        TxtOutput.AppendText(result.Detail + Environment.NewLine);
                    }
                    EnableForm(true);
                },
                ProgressChanged = e => // Logic wants to display an update
                {
                    string summary;
                    var result = e.UserState as Logic.LogMessageInfo;
                    if (result == null)
                    {
                        summary = e.UserState.ToString();
                    }
                    else
                    {
                        if (result.Detail != null)
                        {
                            TxtOutput.AppendText(result.Detail + Environment.NewLine);
                        }
                        summary = result.Summary;
                    }
                    // Status Update
                    if (e.ProgressPercentage == int.MinValue)
                    {
                        TxtOutput.AppendText(e.UserState + Environment.NewLine);
                    }
                    else
                    {
                        if (summary != null)
                        {
                            SetWorkingMessage(summary);
                        }
                    }
                }
            });
        }