public static void GetRunningActivities(CommandProperties commandProperties) { // Get a list of all running activities // TODO: This list could be filtered to only 'billable' activities EntityCollection runningActivities = OrganizationServiceProxy.RetrieveMultiple(Queries.CurrentOpenActivitesWithSessions); RibbonMenuSection section = new RibbonMenuSection("dev1.Activities.Section", "Activities", 1, RibbonDisplayMode.Menu16); int i = 0; foreach (Dictionary activity in runningActivities.Entities) { string image = "WebResources/dev1_/images/start.gif"; bool isRunning = activity["isRunning"] != null && (activity["isRunning"].ToString() == "1"); if (isRunning) { image = "WebResources/dev1_/images/stop.gif"; } section.AddButton( new RibbonButton("dev1.Activity." + activity["a.activityid"].ToString(), i, activity["a.subject"].ToString(), "dev1.ApplicationRibbon.StartStopActivity.Command", image, image)); i++; } RibbonMenu activities = new RibbonMenu("dev1.Activities").AddSection(section); commandProperties.PopulationXML = activities.SerialiseToRibbonXml(); }
public JsonMetricsPublisherCommand(string commandName, CommandMetrics metrics, ICircuitBreaker circuitBreaker, CommandProperties properties) { this.commandName = commandName; this.metrics = metrics; this.circuitBreaker = circuitBreaker; this.properties = properties; }
public JsonMetricsPublisherCommand(CommandMetrics metrics, ICircuitBreaker circuitBreaker = null) { this.commandName = metrics.CommandName; this.metrics = metrics; this.circuitBreaker = circuitBreaker ?? CircuitBreaker.CircuitBreakerFactory.GetInstance(commandName); this.properties = metrics.Properties; }
public override void ExecuteCmdlet() { if (commandCmdlet != null) { if (ShouldProcess(this.TaskName, Resources.createCommand)) { CommandProperties response = null; try { CommandProperties commandInput = commandCmdlet.ProcessCommandCmdlet(); response = DataMigrationClient.Tasks.Command(ResourceGroupName, ServiceName, ProjectName, TaskName, commandInput); } catch (ApiErrorException ex) { ThrowAppropriateException(ex); } WriteObject(response); } } else { throw new PSArgumentException("Invalid Argument List"); } }
public static void SelectNav(CommandProperties commandProperties) { string navId = commandProperties.SourceControlId.Replace(SELECT_NAV_COMMAND_PREFIX, ""); NavigationItem navItem = Page.Ui.Navigation.Items.Get(navId); navItem.SetFocus(); }
public static CommandMetrics GetInstance(string name, CommandProperties properties, IClock clock) { Contract.Assert(!String.IsNullOrEmpty(name)); Contract.Assert(properties != null); return _metrics.GetOrAdd(name, n => new CommandMetrics(n, properties, clock)); }
public JsonMetricsPublisherCommand(CommandMetrics metrics, ICircuitBreaker circuitBreaker=null) { this.commandName = metrics.CommandName; this.metrics = metrics; this.circuitBreaker = circuitBreaker ?? CircuitBreaker.CircuitBreakerFactory.GetInstance(commandName); this.properties = metrics.Properties; }
// Overloaded GetInstance() method public static CommandProperties GetInstance(String filename) { if (_props == null) { _props = new CommandProperties(); } return(_props); }
public CommandProperties PreViewNextCommandProperties() { lock (theLock) { CommandProperties Value = DequeueCommandProperties(true); return(Value); } }
public CommandProperties DequeueNextCommandProperties() { lock (theLock) { CommandProperties Value = DequeueCommandProperties(false); return(Value); } }
public static void StartStopActivity(CommandProperties commandProperties) { Script.Alert(commandProperties.SourceControlId); string values = "activityid=" + commandProperties.SourceControlId.Replace("dev1.Activity.", ""); string parameters = GlobalFunctions.encodeURIComponent(values); Utility.OpenWebResource("dev1_/scripts/StartStopSession.htm", parameters, 400, 300); }
internal DefaultCircuitBreaker(CommandProperties properties, CommandMetrics metrics, IClock clock) { Contract.Requires(clock != null); Contract.Requires(properties != null); Contract.Requires(metrics != null); _clock = clock; _properties = properties; _metrics = metrics; }
internal static ICircuitBreaker GetOrCreateInstance(string name, CommandProperties properties, CommandMetrics metrics, IClock clock) { Contract.Assert(!String.IsNullOrEmpty(name)); Contract.Assert(properties != null); Contract.Assert(metrics != null); Contract.Assert(clock != null); return _circuitBreakers.GetOrAdd(name, n => new DefaultCircuitBreaker(properties, metrics, clock)); }
internal static ICircuitBreaker GetOrCreateInstance(string name, CommandProperties properties, CommandMetrics metrics, IClock clock) { Contract.Assert(!String.IsNullOrEmpty(name)); Contract.Assert(properties != null); Contract.Assert(metrics != null); Contract.Assert(clock != null); return(_circuitBreakers.GetOrAdd(name, n => new DefaultCircuitBreaker(properties, metrics, clock))); }
internal CommandMetrics(string name, CommandProperties properties, IClock clock=null) { _clock = clock ?? Clock.GetInstance(); this._properties = properties; CommandName = name; _counter = new RollingNumber(_clock, properties.MetricsRollingStatisticalWindowInMilliseconds.Get(), properties.MetricsRollingStatisticalWindowBuckets.Get()); _percentileExecution = new RollingPercentileNumber(_clock, properties.MetricsRollingPercentileWindowInMilliseconds.Get(), properties.MetricsRollingPercentileWindowBuckets.Get(), properties.MetricsRollingPercentileBucketSize.Get(), properties.MetricsRollingPercentileEnabled); _percentileTotal = new RollingPercentileNumber(_clock, properties.MetricsRollingPercentileWindowInMilliseconds.Get(), properties.MetricsRollingPercentileWindowBuckets.Get(), properties.MetricsRollingPercentileBucketSize.Get(), properties.MetricsRollingPercentileEnabled); }
internal CommandMetrics([NotNull] string name, [NotNull] string commandGroup, [NotNull] CommandProperties properties, IClock clock = null) { CommandGroup = commandGroup; _clock = clock ?? Clock.GetInstance(); this._properties = properties; CommandName = name; _counter = new RollingNumber(_clock, properties.MetricsRollingStatisticalWindowInMilliseconds.Value, properties.MetricsRollingStatisticalWindowBuckets.Value); _percentileExecution = new RollingPercentileNumber(_clock, properties.MetricsRollingPercentileWindowInMilliseconds.Value, properties.MetricsRollingPercentileWindowBuckets.Value, properties.MetricsRollingPercentileBucketSize.Value, properties.MetricsRollingPercentileEnabled); _percentileTotal = new RollingPercentileNumber(_clock, properties.MetricsRollingPercentileWindowInMilliseconds.Value, properties.MetricsRollingPercentileWindowBuckets.Value, properties.MetricsRollingPercentileBucketSize.Value, properties.MetricsRollingPercentileEnabled); }
public static void SelectSiteMapNav(CommandProperties commandProperties) { string[] navId = commandProperties.SourceControlId.Split("|"); string areaId = navId[1]; string groupId = navId[2]; string subAreaId = navId[3]; foreach (Area area in _siteMap.areas) { if (area.id == areaId) { foreach (Group group in area.groups) { if (group.id == groupId) { foreach (SubArea subArea in group.subareas) { if (subArea.id == subAreaId) { // Navigate to sub area url string url = subArea.url; string siteMapPath = "sitemappath=" + GlobalFunctions.encodeURIComponent(areaId + "|" + groupId + "|" + subAreaId); if (url == null) { // Entity url int objectypecode = subArea.objecttypecode; url = "/_root/homepage.aspx?etc=" + objectypecode + "&" + siteMapPath; } else if (url.IndexOf("?") > -1) { url = url + "&" + siteMapPath; } else { url = url + "?" + siteMapPath; } Element navBar = Window.Top.Document.GetElementById("navBar"); if (navBar != null) { if (Script.Literal("{0}.control.raiseNavigateRequest", navBar) != null) { Dictionary <string, string> urlParameter = new Dictionary <string, string>(); urlParameter["uri"] = url; Script.Literal("{0}.control.raiseNavigateRequest({1})", navBar, urlParameter); } } } } } } } } }
public static void Populate(CommandProperties commandProperties) { _resources = (Dictionary <string, string>)Script.Literal("window.top._quickNav__resources"); _userPriviledgeNames = (Dictionary <string, string>)Script.Literal("window.top._quickNav__userPriviledgeNames"); _siteMap = (SiteMap)Script.Literal("window.top._quickNav__siteMap"); uniquePrefix = "dev1_" + DateTime.Now.GetTime().ToString() + "|"; bool isOnForm = (Page.Ui != null); LoadResources(); RibbonMenu quickNav = new RibbonMenu("dev1.QuickNav"); RibbonMenuSection topSection = new RibbonMenuSection("dev1.SiteMapMenuSection", "", 2, RibbonDisplayMode.Menu16); quickNav.AddSection(topSection); // Only show Sitemap in web client if (Page.Context.Client.GetClient() == ClientType.Web) { if (isOnForm) { RibbonFlyoutAnchor siteMapMenuFlyout = new RibbonFlyoutAnchor(uniquePrefix + "SiteMapButton", 1, ReplaceResourceToken("$Site_Map"), "Mscrm.Enabled", "/_imgs/FormEditorRibbon/Subgrid_16.png", null); topSection.AddButton((RibbonButton)(object)siteMapMenuFlyout); siteMapMenuFlyout.Menu = new RibbonMenu("dev1.SiteMapButton.Menu"); RibbonMenuSection siteMapMenuFlyoutSection = new RibbonMenuSection(uniquePrefix + "SiteMapButton.Menu.Section", "", 1, RibbonDisplayMode.Menu16); siteMapMenuFlyout.Menu.AddSection(siteMapMenuFlyoutSection); GetSiteMap(siteMapMenuFlyoutSection); } else { GetSiteMap(topSection); } } // Add Advanced Find RibbonButton advFind = new RibbonButton("dev1.OpenAdvancedFind.Button", 1, ReplaceResourceToken("$Advanced_Find"), "dev1.OpenAdvancedFind", "/_imgs/ribbon/AdvancedFind_16.png", null); topSection.AddButton(advFind); GetFormTabs(quickNav); GetFormNav(quickNav); commandProperties.PopulationXML = quickNav.SerialiseToRibbonXml(); // Store for next time Script.Literal("window.top._quickNav__resources={0}", _resources); Script.Literal("window.top._quickNav__userPriviledgeNames={0}", _userPriviledgeNames); Script.Literal("window.top._quickNav__siteMap={0}", _siteMap); }
public void EnqueueCommandProperties(CommandProperties CommandProperties) { lock (theLock) { if (_count == _capacity) { Grow(); //Debug.Print("New Capacity: " + _buffer.Length); } _buffer[_head] = CommandProperties; _head = (_head + 1) % _capacity; _count++; } }
private IMetricsPublisherCommand GetOrCreatePublisherForCommand(string commandName, CommandMetrics metrics, ICircuitBreaker circuitBreaker, CommandProperties properties) { // attempt to retrieve from cache first IMetricsPublisherCommand publisher; if (_commandPublishers.TryGetValue(commandName, out publisher)) { return publisher; } // it doesn't exist so we need to create it IMetricsPublisherCommandFactory factory; if (!_commandPublisherFactories.TryGetValue(commandName, out factory)) return null; // attempt to store it (race other threads) return _commandPublishers.GetOrAdd(commandName, factory.Create(commandName, metrics, circuitBreaker, properties)); }
private void RunCommandTimeoutTest <TCommand>(Func <CommandProperties, TCommand> createCommand) where TCommand : BaseCommand <string>, ITestCommand { CommandProperties properties = new CommandProperties(10); TCommand command = createCommand(properties); command.ExecutionDelay = 100; CommandResult <string> result = this.Execute(command).Result; result.IsSuccessful.Should().BeFalse(); result.Exception.Should().NotBeNull(); result.Exception.Should().BeOfType <CommandExecutionException>(); ((CommandExecutionException)result.Exception).FailureType.ShouldBeEquivalentTo(CommandFailureType.Timeout); result.Events.Should().HaveCount(1); result.Events.Single().ShouldBeEquivalentTo(CommandExecutionEventType.Timeout); }
public static void SelectTab(CommandProperties commandProperties) { string tabId = commandProperties.SourceControlId.Replace(SELECT_TAB_COMMAND_PREFIX, ""); Element tab = Window.Parent.Parent.Document.GetElementById("TabNode_tab0Tab-main"); // Move back to the main form if (tab != null) { tab.Click(); } TabItem tabControl = Page.Ui.Tabs.Get(tabId); if (tabControl.GetDisplayState() == DisplayState.Collapsed) { tabControl.SetDisplayState(DisplayState.Expanded); } tabControl.SetFocus(); }
private void Grow() { int newCapacity = _capacity << 1; CommandProperties[] newBuffer = new CommandProperties[newCapacity]; if (_tail < _head) { Array.Copy(_buffer, _tail, newBuffer, 0, _count); } else { Array.Copy(_buffer, _tail, newBuffer, 0, _capacity - _tail); Array.Copy(_buffer, 0, newBuffer, _capacity - _tail, _head); } _buffer = newBuffer; _head = _count; _tail = 0; _capacity = newCapacity; }
private CommandProperties DequeueCommandProperties(bool PreView) { lock (theLock) { if (_count > 0) { CommandProperties value = _buffer[_tail]; if (!PreView) { _tail = (_tail + 1) % _capacity; _count--; } return(value); } else { return(null); } } }
public CommandAttribute(CommandProperties properties) { if (properties.ExecutePreconditions == null || properties.ViewPreconditions == null || properties.Arguments == null || properties.Summary == null) { throw new ArgumentNullException(nameof(properties)); } Identifier = properties.Identifier; Summary = properties.Summary; Remarks = properties.Remarks; Link = properties.Link; RunInAsyncMode = properties.RunInAsyncMode; IsShitposting = properties.IsShitposting; if (Arguments.Length == 0) { MinimumArgumentCount = 0; MaximumArgumentCount = 0; } else { MaximumArgumentCount = Arguments.Length; bool lastArgOptional = true; for (int i = Arguments.Length - 1; i >= 0; i--) { if (lastArgOptional && !Arguments[i].Optional) { lastArgOptional = false; MinimumArgumentCount = i + 1; } if (Arguments[i].Multiple) { MaximumArgumentCount = UNLIMITEDARGS; } } } RequireGuildContext = ArgumentParserMethod == HandledContexts.GuildOnly || ExecutionMethod == HandledContexts.GuildOnly || ExecutePreconditions.Any(cond => { return(cond.RequireGuild); }) || ViewPreconditions.Any(cond => { return(cond.RequireGuild); }); }
public void ExecuteOracleCommand() { /* Create test table with the following script before running the test: * CREATE TABLE TestTable ( textField VARCHAR(255) ); */ var input = new CommandProperties { Command = "INSERT INTO TestTable (textField) VALUES ('unit test text')" }; var conn = new ConnectionProperties { Address = Address, Username = Username, Password = Password }; var result = IFSAccessProvider.Command(input, conn, new CancellationToken()); Assert.Equal("Command executed", result.Result); }
/// <summary> /// Enregistrement d'une vue /// </summary> public void RegisterNewViewCommand(string viewName) { //Récupération du controleur de la vue IController controller = LoadController(viewName); if (controller == null) { throw new ArgumentNullException("L'assembly n'a pas défini de controleur."); } //Récupère les propriété de la commande New dans la vue string cmdId = string.Format("New_{0}", viewName); CommandProperties commandProperties = controller.CommandManager.GetProperties("New"); if (commandProperties == null) { throw new ArgumentNullException(string.Format("La commande {0} n'existe pas dans la vue {1}", cmdId, viewName)); } //Enregistre la commande d'insertion de l'interface graphique dans la vue principale ICommand command = new NewViewCommand(commandReceiver, viewName, cmdId, commandProperties.Text, commandProperties.Icon, commandProperties.AccelKey, commandProperties.Description); CommandManager.RegisterCommand(command); }
internal DefaultCircuitBreaker([NotNull] CommandProperties properties, [NotNull] CommandMetrics metrics, [NotNull] IClock clock) { _clock = clock; _properties = properties; _metrics = metrics; }
/// <summary> /// Initialize a new instance of the TestCommand class. /// </summary> /// <param name="commandName">A name for the command.</param> /// <param name="properties">The properties for the command.</param> public TestCommand(string commandName, CommandProperties properties) : base("Test Group", commandName, properties) { }
/// <summary> /// Execute a command on a task /// </summary> /// <remarks> /// The tasks resource is a nested, proxy-only resource representing work /// performed by a DMS instance. This method executes a command on a running /// task. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='groupName'> /// Name of the resource group /// </param> /// <param name='serviceName'> /// Name of the service /// </param> /// <param name='projectName'> /// Name of the project /// </param> /// <param name='taskName'> /// Name of the Task /// </param> /// <param name='parameters'> /// Command to execute /// </param> public static CommandProperties Command(this ITasksOperations operations, string groupName, string serviceName, string projectName, string taskName, CommandProperties parameters) { return(operations.CommandAsync(groupName, serviceName, projectName, taskName, parameters).GetAwaiter().GetResult()); }
/// <summary> /// Execute a command on a task /// </summary> /// <remarks> /// The tasks resource is a nested, proxy-only resource representing work /// performed by a DMS instance. This method executes a command on a running /// task. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='groupName'> /// Name of the resource group /// </param> /// <param name='serviceName'> /// Name of the service /// </param> /// <param name='projectName'> /// Name of the project /// </param> /// <param name='taskName'> /// Name of the Task /// </param> /// <param name='parameters'> /// Command to execute /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <CommandProperties> CommandAsync(this ITasksOperations operations, string groupName, string serviceName, string projectName, string taskName, CommandProperties parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CommandWithHttpMessagesAsync(groupName, serviceName, projectName, taskName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
// default GetInstance() method public static CommandProperties GetInstance() { return(CommandProperties.GetInstance(PROPERTIES_FILE_VALUE)); }
static CommandFactory() { _commandProperties = CommandProperties.GetInstance(); }
public static void Reset() { CommandProperties.Clear(); ThreadPoolProperties.Clear(); CollapserProperties.Clear(); }
public IMetricsPublisherCommand Create(string commandName, CommandMetrics metrics, ICircuitBreaker circuitBreaker, CommandProperties properties) { return new JsonMetricsPublisherCommand(commandName, metrics, circuitBreaker, properties); }
public static IMetricsPublisherCommand CreateOrRetrievePublisherForCommand(string commandName, CommandMetrics metrics, ICircuitBreaker circuitBreaker, CommandProperties properties) { return MetricsPublisherFactory.Instance.GetOrCreatePublisherForCommand(commandName, metrics, circuitBreaker, properties); }
/// <summary> /// Initialize a new instance of the TestCommand class. /// </summary> /// <param name="properties">The properties for the command.</param> public TestCommand(CommandProperties properties) : base("Test Group", properties) { }
public static CommandMetrics GetInstance([NotNull] string name, [NotNull] string commandGroup, [NotNull] CommandProperties properties, IClock clock) { var metrics = _metrics.GetOrAdd(name, n => new CommandMetrics(n, commandGroup, properties, clock)); return(metrics); }
internal DefaultCircuitBreaker([NotNull]CommandProperties properties, [NotNull]CommandMetrics metrics, [NotNull]IClock clock) { _clock = clock; _properties = properties; _metrics = metrics; }