public void SystemTick(object sender, MessageBusEventArgs <T> e)
 {
     if (systemTickTimer == null)
     {
         systemTickTimer = new Timer(new TimerCallback(_ => e._bus.Trigger(AppEvents.AppTimeIntervalIncreased)), e, 0, 1000);
         _previous       = DateTime.UtcNow;
     }
     if (_previous.Minute != DateTime.UtcNow.Minute)
     {
         e._bus.Trigger(AppEvents.AppTimeIntervalIncreasedMinute, this, e.Message);
     }
     if (_previous.Hour != DateTime.UtcNow.Hour)
     {
         e._bus.Trigger(AppEvents.AppTimeIntervalIncreasedHour);
     }
     if (_previous.Day != DateTime.UtcNow.Day)
     {
         e._bus.Trigger(AppEvents.AppTimeIntervalIncreasedDay);
     }
     if (_previous.DayOfWeek != DateTime.UtcNow.DayOfWeek && DayOfWeek.Sunday == DateTime.UtcNow.DayOfWeek)
     {
         e._bus.Trigger(AppEvents.AppTimeIntervalIncreasedWeek);
     }
     if (_previous.Month != DateTime.UtcNow.Month)
     {
         e._bus.Trigger(AppEvents.AppTimeIntervalIncreasedMonth);
     }
     if (_previous.Year != DateTime.UtcNow.Year)
     {
         e._bus.Trigger(AppEvents.AppTimeIntervalIncreasedYear);
     }
     _previous = DateTime.UtcNow;
     Console.WriteLine("The threshold was reached.");
 }
 public void OnIncomingMessage(MessageBusEventArgs message)
 {
     _incomingMessage  = message;
     tsbReturn.Visible = true;
     tsbReturn.Text    = $"Return to {message.SourcePlugin}";
     ExecuteMethod(RetrieveSolutions);
 }
Ejemplo n.º 3
0
        private void toolStripButtonRunit_Click(object sender, EventArgs e)
        {
            CommitLastChange();
            var xtbver = new Version(TopLevelControl.ProductVersion);

            if (xtbver > new Version("1.2018") &&
                xtbver < new Version("1.2018.5"))
            {   // Bug introduced with docking layout in XTB
                MessageBox.Show($"Unfortunately current version ({xtbver}) of XrmToolBox cannot connect properly to Shuffle Runner.\nPlease start Shuffle Runner from the Plugin List instead.", "Shuffle Runner", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            var args = new MessageBusEventArgs("Shuffle Runner", false)
            {
                TargetArgument = fileName
            };

            try
            {
                OnOutgoingMessage(this, args);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Calliung Shuffle Runner failed:\n" + ex.Message);
            }
        }
Ejemplo n.º 4
0
 public void SendOutgoingMessage(MessageBusEventArgs args)
 {
     _ai.TrackEvent("Outgoing message", new Dictionary <string, string> {
         ["TargetPlugin"] = args.TargetPlugin
     });
     OnOutgoingMessage(this, args);
 }
Ejemplo n.º 5
0
 public void OnIncomingMessage(MessageBusEventArgs message)
 {
     if (message.SourcePlugin == "FetchXML Builder" && message.TargetArgument is string)
     {
         FetchUpdated(message.TargetArgument);
     }
 }
 public void OnIncomingMessage(MessageBusEventArgs message)
 {
     if (message.SourcePlugin == "FetchXML Builder" &&
         message.TargetArgument as string != null)
     {
         txtFetchXML.Text = message.TargetArgument as string;
     }
 }
Ejemplo n.º 7
0
 public void SendIncomingBrokerMessage(MessageBusEventArgs message)
 {
     // ReSharper disable once SuspiciousTypeConversion.Global
     if (pluginControlBase is IMessageBusHost host)
     {
         host.OnIncomingMessage(message);
     }
 }
Ejemplo n.º 8
0
 public void OnIncomingMessage(MessageBusEventArgs message)
 {
     if (message.TargetArgument is string)
     {
         var definitionfile = (string)message.TargetArgument;
         txtFile.Text = definitionfile;
     }
 }
 public void OnIncomingMessage(MessageBusEventArgs message)
 {
     if (message.SourcePlugin == "FetchXML Builder" &&
         message.TargetArgument is string)
     {
         XDocument XDocument = XDocument.Parse((string)message.TargetArgument);
         rtxtFetchXML.Text = XDocument.ToString();
     }
 }
        /// <summary>
        /// Open the Portal Records Mover tool
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LinkLabelPortalRecordsMover_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var messageBusEventArgs = new MessageBusEventArgs("Portal Records Mover")
            {
                SourcePlugin = "Portal Site Settings Manager"
            };

            OnOutgoingMessage(this, messageBusEventArgs);
        }
Ejemplo n.º 11
0
        public void OnIncomingMessage(MessageBusEventArgs message)
        {
            callerArgs = message;
            if (message.TargetArgument != null)
            {
                fetchxmlQuery = (string)message.TargetArgument;
            }

            btnRetrieveRecordsFetchQuery.Enabled = !String.IsNullOrEmpty(fetchxmlQuery);
        }
Ejemplo n.º 12
0
        internal void CallFXB(string text)
        {
            CommitLastChange();
            var args = new MessageBusEventArgs("FetchXML Builder", false)
            {
                TargetArgument = text
            };

            OnOutgoingMessage(this, args);
        }
Ejemplo n.º 13
0
        private void GetFromFXB()
        {
            var messageBusEventArgs = new MessageBusEventArgs("FetchXML Builder")
            {
                //SourcePlugin = "Bulk Data Updater"
            };

            messageBusEventArgs.TargetArgument = fetchXml;
            OnOutgoingMessage(this, messageBusEventArgs);
        }
        public void OnIncomingMessage(MessageBusEventArgs message)
        {
            if (message.SourcePlugin != "FetchXML Builder")
            {
                return;
            }

            txtFetchXml.Text = (string)message.TargetArgument;
            FormatXML(true);
        }
 public void OnIncomingMessage(MessageBusEventArgs message)
 {
     if (message.SourcePlugin == "FetchXML Builder" &&
         message.TargetArgument is FXBMessageBusArgument)
     {
         var fxbArg = (FXBMessageBusArgument)message.TargetArgument;
         txtFetchXml.Text = fxbArg.FetchXML;
         FormatXML(true);
         fetchXml = fxbArg.FetchXML;
     }
 }
Ejemplo n.º 16
0
        private void btnOpenFXB_Click(object sender, EventArgs e)
        {
            log.LogData(EventType.Event, LogAction.FXBBuilerUsed);
            var messageBusEventArgs = new MessageBusEventArgs("FetchXML Builder")
            {
                SourcePlugin   = "BPF Manager",
                TargetArgument = fetchxmlQuery
            };

            OnOutgoingMessage(this, messageBusEventArgs);
        }
Ejemplo n.º 17
0
 public void OnIncomingMessage(MessageBusEventArgs message)
 {
     if (message.SourcePlugin == "FetchXML Builder")
     {
         var fetchXml = (string)message.TargetArgument;
         if (Service != null && userSelector1.Service == null)
         {
             userSelector1.Service = Service;
         }
         userSelector1.PopulateUsers(fetchXml);
     }
 }
Ejemplo n.º 18
0
 public void OnIncomingMessage(MessageBusEventArgs message)
 {
     if (message.TargetArgument is string arg && Guid.TryParse(arg, out Guid argid))
     {
         InArgumentId = argid;
         if (cmbSolution.DataSource != null)
         {
             SelectDefaultSolution();
             GetCustomActions(cmbSolution.SelectedEntity);
         }
     }
 }
Ejemplo n.º 19
0
        public void OnIncomingMessage(MessageBusEventArgs message)
        {
            if (message.TargetArgument != null)
            {
                int i = comboBoxAssemblyList.FindStringExact(message.TargetArgument);

                if (i != -1)
                {
                    comboBoxAssemblyList.SelectedIndex = comboBoxAssemblyList.FindStringExact(message.TargetArgument);
                }
            }
            this.log.LogData(EventType.Event, LogAction.LoadedFromOtherPlugin);
        }
        private void tsbEditInFxb_Click(object sender, EventArgs e)
        {
            if (lvViews.SelectedItems.Count == 0 || fetchXml == string.Empty)
            {
                MessageBox.Show("No views selected.", "Error");
                return;
            }

            var messageBusEventArgs = new MessageBusEventArgs("FetchXML Builder");

            messageBusEventArgs.TargetArgument = fetchXml;
            OnOutgoingMessage(this, messageBusEventArgs);
        }
        private void buttonOpenFXB_Click(object sender, EventArgs e)
        {
            var fetchxml = GetQueryFetchXML();

            if (string.IsNullOrEmpty(fetchxml))
            {
                return;
            }
            var messageBusEventArgs = new MessageBusEventArgs("FetchXML Builder")
            {
                TargetArgument = fetchxml
            };

            OnOutgoingMessage(this, messageBusEventArgs);
        }
Ejemplo n.º 22
0
        private void OpenFXB()
        {
            var entity     = ((EntityMetadataProxy)cmbEntities.SelectedItem).Metadata;
            var attributes = ((gridAttributes.DataSource as BindingSource)?.DataSource as BindingList <AttributeProxy>).Select(a => a.attributeMetadata.LogicalName);
            var fetchxml   = "<fetch top='10' ><entity name='" + entity.LogicalName + "' >" +
                             "<attribute name='" + entity.PrimaryNameAttribute + "' /><attribute name='createdon' />" +
                             string.Join("", attributes.Select(a => "<attribute name='" + a + "' />")) +
                             "<order attribute='createdon' descending='true' /></entity></fetch>";
            var messageBusEventArgs = new MessageBusEventArgs("FetchXML Builder")
            {
                TargetArgument = fetchxml
            };

            OnOutgoingMessage(this, messageBusEventArgs);
        }
        private void toolStripButtonRunit_Click(object sender, EventArgs e)
        {
            var args = new MessageBusEventArgs("Shuffle Runner")
            {
                TargetArgument = fileName
            };

            try
            {
                OnOutgoingMessage(this, args);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Calliung Shuffle Runner failed:\n" + ex.Message);
            }
        }
Ejemplo n.º 24
0
        private void tsbEditInFXB_Click(object sender, EventArgs e)
        {
            if (Service != null && userSelector1.Service == null)
            {
                userSelector1.Service = Service;
            }
            if (areas == null || !areas.Any())
            {
                ExecuteMethod(LoadSettings);
            }
            var messageBusEventArgs = new MessageBusEventArgs("FetchXML Builder");
            var fetchXml            = (((ComboBox)userSelector1.Controls.Find("cbbViews", true)?[0]).SelectedItem as ViewItem)?.FetchXml;

            messageBusEventArgs.TargetArgument = fetchXml ?? ACTIVE_USERS_FETCH;
            OnOutgoingMessage(this, messageBusEventArgs);
        }
 public void OnIncomingMessage(MessageBusEventArgs message)
 {
     if (message.TargetArgument is string strarg)
     {
         if (message.SourcePlugin == "FetchXML Builder" &&
             strarg.ToLowerInvariant().Trim().StartsWith("<fetch"))
         {
             FetchUpdated(strarg);
         }
         else if (ParseFilterArgs(strarg) is PTVFilter filter)
         {
             filterControl?.ApplyFilter(filter);
             RefreshTraces(GetQuery(false));
         }
     }
 }
Ejemplo n.º 26
0
        public void OnIncomingMessage(MessageBusEventArgs message)
        {
            _ai.TrackEvent("Incoming message", new Dictionary <string, string> {
                ["SourcePlugin"] = message.SourcePlugin
            });

            var param = message.TargetArgument as IDictionary <string, object>;

            if (param == null)
            {
                var xml = message.TargetArgument as string;
                param                = new Dictionary <string, object>();
                param["FetchXml"]    = xml;
                param["ConvertOnly"] = false;
            }

            if (_objectExplorer.SelectedConnection == null)
            {
                return;
            }

            var con      = _objectExplorer.SelectedConnection;
            var metadata = _metadata[con];

            var fetch   = DeserializeFetchXml((string)param["FetchXml"]);
            var options = new FetchXml2SqlOptions();

            if ((bool)param["ConvertOnly"])
            {
                options.PreserveFetchXmlOperatorsAsFunctions = false;
            }

            var sql = FetchXml2Sql.Convert(con.ServiceClient, metadata, fetch, options, out _);

            if ((bool)param["ConvertOnly"])
            {
                param["Sql"] = sql;
                OnOutgoingMessage(this, new MessageBusEventArgs(message.SourcePlugin)
                {
                    TargetArgument = null
                });
            }
            else
            {
                CreateQuery(con, "-- Imported from " + message.SourcePlugin + "\r\n\r\n" + sql, message.SourcePlugin == "FetchXML Builder" ? null : message.SourcePlugin);
            }
        }
Ejemplo n.º 27
0
        private void toolStripButtonViewSolutionsSteps_Click(object sender, EventArgs e)
        {
            var solutionName = comboBoxAssemblyList.SelectedItem.ToString();

            if (string.IsNullOrEmpty(solutionName))
            {
                MessageBox.Show(this, "Please select a solution first to open the Steps details plugin.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            var messageBusEventArgs = new MessageBusEventArgs("Delta Plugin Steps between two environments")
            {
                SourcePlugin   = "Delta Plugins : Local Assembly vs CRM",
                TargetArgument = solutionName
            };

            OnOutgoingMessage(this, messageBusEventArgs);
        }
Ejemplo n.º 28
0
        private void tsbEditFetch_Click(object sender, EventArgs e)
        {
            if (Service == null)
            {
                MessageBox.Show("Please connect to CRM.", ((ToolStripButton)sender).Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var view = ViewEditor != null ? ViewEditor.ViewChanges : null;

            if (view == null || string.IsNullOrEmpty(view.LogicalName))
            {
                MessageBox.Show("First select a view to design.", ((ToolStripButton)sender).Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            try
            {
                var messageBusEventArgs = new MessageBusEventArgs("FetchXML Builder");
                messageBusEventArgs.TargetArgument = ViewEditor.FetchXml.OuterXml;
                OnOutgoingMessage(this, messageBusEventArgs);
            }
            catch (System.IO.FileNotFoundException)
            {
                if (MessageBox.Show("FetchXML Builder is not installed.\nDownload latest version from\n\nhttp://fxb.xrmtoolbox.com", "FetchXML Builder",
                                    MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
                {
                    DownloadFXB();
                }
            }
            catch (PluginNotFoundException)
            {
                var xtbver = ParentForm.ProductVersion;
                if (xtbver == "1.2015.7.6")
                {
                    MessageBox.Show("XrmToolBox version " + xtbver + " has a minor problem integrating plugins.\nHang in there - new version will be released soon!", "Launching FetchXML Builder",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (MessageBox.Show("FetchXML Builder was not found.\nInstall it from the XrmToolBox Plugin Store or visit\n\nhttp://fxb.xrmtoolbox.com", "FetchXML Builder",
                                         MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
                {
                    DownloadFXB();
                }
            }
        }
Ejemplo n.º 29
0
        public void OnIncomingMessage(MessageBusEventArgs message)
        {
            if (inSql4Cds)
            {
                return;
            }

            callerArgs = message;
            var fetchXml      = string.Empty;
            var requestedType = "FetchXML";

            if (message.TargetArgument != null)
            {
                if (message.TargetArgument is FXBMessageBusArgument)
                {
                    var fxbArg = (FXBMessageBusArgument)message.TargetArgument;
                    fetchXml      = fxbArg.FetchXML;
                    requestedType = fxbArg.Request.ToString();
                }
                else if (message.TargetArgument is string)
                {
                    fetchXml = (string)message.TargetArgument;
                }
            }
            dockControlBuilder.ParseXML(fetchXml, false);
            UpdateLiveXML();
            tsbReturnToCaller.ToolTipText = "Return " + requestedType + " to " + callerArgs.SourcePlugin;
            dockControlBuilder.RecordHistory("called from " + message.SourcePlugin);
            LogUse("CalledBy." + callerArgs.SourcePlugin);
            if (callerArgs.SourcePlugin == "View Designer" && !connectionsettings.TipsAgainstOrViewDesignerToolShown)
            {
                if (MessageBox.Show("Did you know you can work with the layouts too in the FetchXML Builder?\nClick the Help button to see how!\n\nDon't show again.",
                                    "Called from View Designer", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2, 0,
                                    Utils.ProcessURL("https://jonasr.app/fxb-layout/")) == DialogResult.OK)
                {
                    connectionsettings.TipsAgainstOrViewDesignerToolShown = true;
                }
            }
            EnableControls(true);
        }
Ejemplo n.º 30
0
        private void ReturnToCaller()
        {
            if (callerArgs == null)
            {
                return;
            }
            LogUse("ReturnTo." + callerArgs.SourcePlugin);
            var fetch = dockControlBuilder.GetFetchString(true, true);

            if (string.IsNullOrWhiteSpace(fetch))
            {
                return;
            }
            var message = new MessageBusEventArgs(callerArgs.SourcePlugin);

            if (callerArgs.TargetArgument is FXBMessageBusArgument)
            {
                var fxbArgs = (FXBMessageBusArgument)callerArgs.TargetArgument;
                switch (fxbArgs.Request)
                {
                case FXBMessageBusRequest.FetchXML:
                    fxbArgs.FetchXML = fetch;
                    break;

                case FXBMessageBusRequest.QueryExpression:
                    fxbArgs.QueryExpression = dockControlBuilder.GetQueryExpression();
                    break;

                case FXBMessageBusRequest.OData:
                    fxbArgs.OData = GetOData(2);
                    break;
                }
                message.TargetArgument = fxbArgs;
            }
            else
            {
                message.TargetArgument = fetch;
            }
            OnOutgoingMessage(this, message);
        }
Ejemplo n.º 31
0
        private void MainForm_MessageBroker(object sender, MessageBusEventArgs message)
        {
            if (!IsMessageValid(sender, message))
            {
                return;
            }

            // Trying to find the tab where plugin is located
            var tab = tabControl1.TabPages.Cast<TabPage>().FirstOrDefault(x => x.Controls[0].GetType().GetTitle() == message.TargetPlugin);

            if (tab != null && !message.NewInstance)
            {
                // Using existing plugin instance, switching to plugin tab
                tabControl1.SelectTab(tabControl1.TabPages.IndexOf(tab));
            }
            else
            {
                // Searching for suitable plugin
                var target = pManager.Plugins.FirstOrDefault(p => p.Metadata.Name == message.TargetPlugin);
                if (target == null)
                {
                    throw new PluginNotFoundException("Plugin {0} was not found", message.TargetPlugin);
                }
                // Displaying plugin and keeping number of the tab where it was opened
                var tabIndex = this.DisplayPluginControl(target);
                // Getting the tab where plugin was opened
                tab = tabControl1.TabPages[tabIndex];
                // New intance of the plugin was created, even if user did not explicitly asked about this.
                message.NewInstance = true;
            }

            var targetControl = (UserControl)tab.Controls[0];

            if (targetControl is IMessageBusHost)
            {
                ((IMessageBusHost)targetControl).OnIncomingMessage(message);
            }
        }
Ejemplo n.º 32
0
        private bool IsMessageValid(object sender, MessageBusEventArgs message)
        {
            if (message == null || sender == null || !(sender is UserControl) || !(sender is IXrmToolBoxPluginControl))
            {
                // Error. Possible reasons are:
                // * empty sender
                // * empty message
                // * sender is not UserControl
                // * sender is not XrmToolBox Plugin
                return false;
            }

            var sourceControl = (UserControl)sender;

            if (string.IsNullOrEmpty(message.SourcePlugin))
            {
                message.SourcePlugin = sourceControl.GetType().GetTitle();
            }
            else if (message.SourcePlugin != sourceControl.GetType().GetTitle())
            {
                // For some reason incorrect name was set in Source Plugin field
                return false;
            }

            // Everything went ok
            return true;
        }