コード例 #1
0
 private void DeltaStepsBetweenEnvironments_Load(object sender, EventArgs e)
 {
     // initializing log class
     Log = new LogUsage(this);
     Log.LogData(EventType.Event, LogAction.PluginOpened);
     LoadSetting();
 }
コード例 #2
0
        private void BPFMigration_Load(object sender, EventArgs e)
        {
            log = new LogUsage(this);
            log.LogData(EventType.Event, LogAction.PluginOpened);
            LoadSetting();

            //displaying the proper control for query
            radioButtonQueryView.Checked = true;
        }
コード例 #3
0
        private int DisplayPluginControl(Lazy <IXrmToolBoxPlugin, IPluginMetadata> plugin)
        {
            var  tabIndex = 0;
            Guid pluginControlInstanceId = Guid.NewGuid();

            try
            {
                var pluginControl = (UserControl)plugin.Value.GetControl();

                // ReSharper disable once SuspiciousTypeConversion.Global
                var host = pluginControl as IMessageBusHost;
                if (host != null)
                {
                    host.OnOutgoingMessage += MainForm_MessageBroker;
                }

                var statusBarMessager_old = pluginControl as IStatusBarMessager;
                if (statusBarMessager_old != null)
                {
                    statusBarMessager_old.SendMessageToStatusBar += StatusBarMessager_SendMessageToStatusBar;
                }

                var statusBarMessager = pluginControl as IStatusBarMessenger;
                if (statusBarMessager != null)
                {
                    statusBarMessager.SendMessageToStatusBar += StatusBarMessager_SendMessageToStatusBar;
                }

                if (service != null)
                {
                    var crmSvcClient = currentConnectionDetail.GetCrmServiceClient();

                    var clonedService          = crmSvcClient.OrganizationServiceProxy;
                    var clonedWebClientService = crmSvcClient.OrganizationWebProxyClient;
                    if (clonedService != null)
                    {
                        clonedService.SdkClientVersion = currentConnectionDetail.OrganizationVersion;
                    }
                    if (clonedWebClientService != null)
                    {
                        clonedWebClientService.SdkClientVersion = currentConnectionDetail.OrganizationVersion;
                    }

                    var earlyBoundProxiedControl = pluginControl as IEarlyBoundProxy;
                    if (earlyBoundProxiedControl != null)
                    {
                        clonedService?.EnableProxyTypes(earlyBoundProxiedControl.GetEarlyBoundProxyAssembly());
                    }

                    if (clonedService != null)
                    {
                        ((IXrmToolBoxPluginControl)pluginControl).UpdateConnection(clonedService, currentConnectionDetail);
                    }
                    else
                    {
                        ((IXrmToolBoxPluginControl)pluginControl).UpdateConnection(clonedWebClientService, currentConnectionDetail);
                    }
                }

                ((IXrmToolBoxPluginControl)pluginControl).OnRequestConnection += MainForm_OnRequestConnection;
                ((IXrmToolBoxPluginControl)pluginControl).OnCloseTool         += MainForm_OnCloseTool;

                string name = string.Format("{0} ({1})", plugin.Metadata.Name,
                                            currentConnectionDetail != null
                        ? currentConnectionDetail.ConnectionName
                        : "Not connected");

                var newTab = new TabPage(name)
                {
                    Tag = plugin
                };
                tabControl1.TabPages.Add(newTab);

                pluginControl.Dock   = DockStyle.Fill;
                pluginControl.Width  = newTab.Width;
                pluginControl.Height = newTab.Height;
                pluginControl.Tag    = pluginControlInstanceId;
                pluginControl.Parent = newTab;

                newTab.Controls.Add(pluginControl);
                newTab.Controls.Add(new NotificationArea {
                    Name = "NotifPanel", Visible = false, Dock = DockStyle.Top, Parent = newTab
                });

                tabIndex = tabControl1.TabPages.Count - 1;

                tabControl1.SelectTab(tabIndex);

                var pluginInOption = currentOptions.MostUsedList.FirstOrDefault(i => i.Name == plugin.Value.GetType().FullName);
                if (pluginInOption == null)
                {
                    pluginInOption = new PluginUseCount {
                        Name = plugin.Value.GetType().FullName, Count = 0
                    };
                    currentOptions.MostUsedList.Add(pluginInOption);
                }

                pluginInOption.Count++;

                if (currentOptions.LastAdvertisementDisplay == new DateTime() ||
                    currentOptions.LastAdvertisementDisplay > DateTime.Now ||
                    currentOptions.LastAdvertisementDisplay.AddDays(7) < DateTime.Now)
                {
                    bool displayAdvertisement = true;
                    try
                    {
                        var assembly = Assembly.LoadFile(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory +
                                                         "\\McTools.StopAdvertisement.dll");
                        if (assembly != null)
                        {
                            Type type = assembly.GetType("McTools.StopAdvertisement.LicenseManager");
                            if (type != null)
                            {
                                MethodInfo methodInfo = type.GetMethod("IsValid");
                                if (methodInfo != null)
                                {
                                    object classInstance = Activator.CreateInstance(type, null);

                                    if ((bool)methodInfo.Invoke(classInstance, null))
                                    {
                                        displayAdvertisement = false;
                                    }
                                }
                            }
                        }
                    }
                    catch (FileNotFoundException)
                    {
                    }

                    if (displayAdvertisement)
                    {
                        pnlSupport.Visible = true;
                        currentOptions.LastAdvertisementDisplay = DateTime.Now;
                    }
                }

                if (currentOptions.AllowLogUsage.HasValue && currentOptions.AllowLogUsage.Value)
                {
#pragma warning disable CS4014 // Dans la mesure où cet appel n'est pas attendu, l'exécution de la méthode actuelle continue avant la fin de l'appel
                    LogUsage.DoLog(plugin);
#pragma warning restore CS4014 // Dans la mesure où cet appel n'est pas attendu, l'exécution de la méthode actuelle continue avant la fin de l'appel
                }

                currentOptions.Save();

                if (pnlConnectLoading.Visible)
                {
                    pnlConnectLoading.SendToBack();
                    pnlConnectLoading.Visible = false;
                }
            }
            catch (Exception error)
            {
                MessageBox.Show(this, "An error occured when trying to display this plugin: " + error.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(tabIndex);
        }
コード例 #4
0
        private int DisplayPluginControl(UserControl plugin)
        {
            var tabIndex = 0;

            try
            {
                var control       = (Lazy <IXrmToolBoxPlugin, IPluginMetadata>)plugin.Tag;
                var pluginControl = (UserControl)control.Value.GetControl();

                if (service != null)
                {
                    var clonedService = (OrganizationService)currentConnectionDetail.GetOrganizationService();
                    ((OrganizationServiceProxy)clonedService.InnerService).SdkClientVersion = currentConnectionDetail.OrganizationVersion;

                    ((IXrmToolBoxPluginControl)pluginControl).UpdateConnection(clonedService,
                                                                               currentConnectionDetail);
                }

                // ReSharper disable once SuspiciousTypeConversion.Global
                var host = pluginControl as IMessageBusHost;
                if (host != null)
                {
                    host.OnOutgoingMessage += MainForm_MessageBroker;
                }

                ((IXrmToolBoxPluginControl)pluginControl).OnRequestConnection += MainForm_OnRequestConnection;
                ((IXrmToolBoxPluginControl)pluginControl).OnCloseTool         += MainForm_OnCloseTool;

                string name = string.Format("{0} ({1})", control.Metadata.Name,
                                            currentConnectionDetail != null
                        ? currentConnectionDetail.ConnectionName
                        : "Not connected");

                var newTab = new TabPage(name);
                tabControl1.TabPages.Add(newTab);

                pluginControl.Dock   = DockStyle.Fill;
                pluginControl.Width  = newTab.Width;
                pluginControl.Height = newTab.Height;

                newTab.Controls.Add(pluginControl);

                tabIndex = tabControl1.TabPages.Count - 1;

                tabControl1.SelectTab(tabIndex);

                var pluginInOption =
                    currentOptions.MostUsedList.FirstOrDefault(i => i.Name == pluginControl.GetType().FullName);
                if (pluginInOption == null)
                {
                    pluginInOption = new PluginUseCount {
                        Name = pluginControl.GetType().FullName, Count = 0
                    };
                    currentOptions.MostUsedList.Add(pluginInOption);
                }

                pluginInOption.Count++;

                var p1 = plugin as SmallPluginModel;
                if (p1 != null)
                {
                    p1.UpdateCount(pluginInOption.Count);
                }
                else
                {
                    var p2 = plugin as LargePluginModel;
                    if (p2 != null)
                    {
                        p2.UpdateCount(pluginInOption.Count);
                    }
                }

                if (currentOptions.LastAdvertisementDisplay == new DateTime() ||
                    currentOptions.LastAdvertisementDisplay > DateTime.Now ||
                    currentOptions.LastAdvertisementDisplay.AddDays(7) < DateTime.Now)
                {
                    bool displayAdvertisement = true;
                    try
                    {
                        var assembly =
                            Assembly.LoadFile(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory +
                                              "\\McTools.StopAdvertisement.dll");
                        if (assembly != null)
                        {
                            Type type = assembly.GetType("McTools.StopAdvertisement.LicenseManager");
                            if (type != null)
                            {
                                MethodInfo methodInfo = type.GetMethod("IsValid");
                                if (methodInfo != null)
                                {
                                    object classInstance = Activator.CreateInstance(type, null);

                                    if ((bool)methodInfo.Invoke(classInstance, null))
                                    {
                                        displayAdvertisement = false;
                                    }
                                }
                            }
                        }
                    }
                    catch (FileNotFoundException)
                    {
                    }

                    if (displayAdvertisement)
                    {
                        var sc = new SupportScreen(currentReleaseNote);
                        sc.ShowDialog(this);
                        currentOptions.LastAdvertisementDisplay = DateTime.Now;
                    }
                }

                if (currentOptions.AllowLogUsage.HasValue && currentOptions.AllowLogUsage.Value)
                {
                    LogUsage.DoLog(control);
                }

                currentOptions.Save();
            }
            catch (Exception error)
            {
                MessageBox.Show(this, "An error occured when trying to display this plugin: " + error.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(tabIndex);
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: tbienvenu/XrmToolBox
        private async void MainForm_Load(object sender, EventArgs e)
        {
            this.Opacity = 0;

            tstxtFilterPlugin.Focus();

            pManager = new PluginManagerExtended(this)
            {
                IsWatchingForNewPlugins = true
            };
            pManager.Initialize();
            pManager.PluginsListUpdated += pManager_PluginsListUpdated;

            tstxtFilterPlugin.AutoCompleteCustomSource.AddRange(pManager.Plugins.Select(p => p.Metadata.Name).ToArray());

            this.DisplayPlugins();

            var tasks = new List <Task>
            {
                this.LaunchWelcomeDialog(),
                this.CheckForPluginsUpdate(),
            };

            //if (!Debugger.IsAttached)
            //{
            tasks.Add(this.LaunchVersionCheck());
            //}

            if (!string.IsNullOrEmpty(this.initialConnectionName))
            {
                var connectionDetail = ConnectionManager.Instance.ConnectionsList.Connections.FirstOrDefault(x => x.ConnectionName == this.initialConnectionName);;

                if (connectionDetail != null)
                {
                    // If initiall connection is present, connect to given sever is initiated.
                    // After connection try to open intial plugin will be attempted.
                    tasks.Add(this.launchInitialConnection(connectionDetail));
                }
                else
                {
                    // Connection detail was not found, so name provided was incorrect.
                    // But if name of the plugin is set, it should be started
                    if (!string.IsNullOrEmpty(this.initialPluginName))
                    {
                        this.StartPluginWithoutConnection();
                    }
                }
            }
            else if (!string.IsNullOrEmpty(this.initialPluginName))
            {
                // If there is no initial connection, but initial plugin is set, openning plugin
                this.StartPluginWithoutConnection();
            }

            tasks.ForEach(x => x.Start());

            await Task.WhenAll(tasks.ToArray());

            // Adapt size of current form
            if (currentOptions.Size.IsMaximized)
            {
                WindowState = FormWindowState.Maximized;
            }
            else
            {
                currentOptions.Size.ApplyFormSize(this);
            }

            AdaptPluginControlSize();

            WebProxyHelper.ApplyProxy();

            this.Opacity = 100;

            if (!currentOptions.AllowLogUsage.HasValue)
            {
                currentOptions.AllowLogUsage = LogUsage.PromptToLog();
                currentOptions.Save();
            }

            if (currentOptions.DisplayPluginsStoreOnStartup)
            {
                var dlg = new PluginsChecker();
                dlg.ShowDialog(this);
            }
        }
コード例 #6
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            WebProxyHelper.ApplyProxy();

            pManager = new PluginManagerExtended(this)
            {
                IsWatchingForNewPlugins = true
            };
            pManager.Initialize();
            pManager.PluginsListUpdated += pManager_PluginsListUpdated;

            tstxtFilterPlugin.AutoCompleteCustomSource.AddRange(pManager.Plugins.Select(p => p.Metadata.Name).ToArray());

            blackScreen.SetWorkingMessage("Loading plugins...");
            DisplayPlugins();

            var tasks = new List <Task>
            {
                LaunchVersionCheck()
            };

            if (!string.IsNullOrEmpty(initialConnectionName))
            {
                var connectionDetail = ConnectionManager.Instance.ConnectionsList.Connections.FirstOrDefault(x => x.ConnectionName == initialConnectionName);;

                if (connectionDetail != null)
                {
                    // If initiall connection is present, connect to given sever is initiated.
                    // After connection try to open intial plugin will be attempted.
                    tasks.Add(launchInitialConnection(connectionDetail));
                }
                else
                {
                    // Connection detail was not found, so name provided was incorrect.
                    // But if name of the plugin is set, it should be started
                    if (!string.IsNullOrEmpty(initialPluginName))
                    {
                        StartPluginWithoutConnection();
                    }
                }
            }
            else if (!string.IsNullOrEmpty(initialPluginName))
            {
                // If there is no initial connection, but initial plugin is set, openning plugin
                StartPluginWithoutConnection();
            }

            tasks.ForEach(x => x.Start());
            await Task.WhenAll(tasks.ToArray());

            // Adapt size of current form
            if (currentOptions.Size.IsMaximized)
            {
                WindowState = FormWindowState.Maximized;
            }
            else
            {
                currentOptions.Size.ApplyFormSize(this);
            }

            AdaptPluginControlSize();

            // Hide & remove Welcome screen
            Opacity = 100;
            blackScreen.Hide();
            blackScreen.Dispose();

            if (!currentOptions.AllowLogUsage.HasValue)
            {
                currentOptions.AllowLogUsage = LogUsage.PromptToLog();
                currentOptions.Save();
            }

            if (currentOptions.DisplayPluginsStoreOnStartup)
            {
                if (currentOptions.DisplayPluginsStoreOnlyIfUpdates)
                {
                    if (store == null)
                    {
                        store = new Store();
                    }

                    if (store.Packages == null)
                    {
                        store.LoadNugetPackages();
                    }

                    if (store.Packages.Any(p => p.Action == PluginsStore.PackageInstallAction.Update))
                    {
                        pbOpenPluginsStore_Click(sender, e);
                    }
                }
                else
                {
                    pbOpenPluginsStore_Click(sender, e);
                }
            }

            Action action = CheckForPluginsUpdate;

            action.BeginInvoke(ar => action.EndInvoke(ar), null);

            tstxtFilterPlugin.Focus();
        }
コード例 #7
0
 private void DeltaAssemblyvsCrm_Load(object sender, EventArgs e)
 {
     log = new LogUsage(this);
     log.LogData(EventType.Event, LogAction.PluginOpened);
     LoadSetting();
 }