private static void AddConfigActionComponent(CustomActionComponent configAction, HDInsight.ClusterCreateParametersV2 inputs, ClusterRole headnodeRole, ClusterRole workernodeRole) { configAction.CustomActions = new CustomActionList(); // Converts config action from PS/SDK to wire contract. foreach (ConfigAction ca in inputs.ConfigActions) { CustomAction newConfigAction; // Based on the config action type defined in SDK, convert them to config action defined in wire contract. ScriptAction sca = ca as ScriptAction; if (sca != null) { newConfigAction = new ScriptCustomAction { Name = ca.Name, Uri = sca.Uri, Parameters = sca.Parameters }; } else { throw new NotSupportedException("No such config action supported."); } newConfigAction.ClusterRoleCollection = new ClusterRoleCollection(); // Add in cluster role collection for each config action. foreach (ClusterNodeType clusterRoleType in ca.ClusterRoleCollection) { if (clusterRoleType == ClusterNodeType.HeadNode) { newConfigAction.ClusterRoleCollection.Add(headnodeRole); } else if (clusterRoleType == ClusterNodeType.DataNode) { newConfigAction.ClusterRoleCollection.Add(workernodeRole); } else { throw new NotSupportedException("No such node type supported."); } } configAction.CustomActions.Add(newConfigAction); } }
private static WabStorageAccountConfiguration GetStorageAccountForScript(ScriptAction sa, ClusterCreateParametersV2 details) { var accts = new List<WabStorageAccountConfiguration>(); accts.Add(new WabStorageAccountConfiguration( details.DefaultStorageAccountName, details.DefaultStorageAccountKey, details.DefaultStorageContainer)); accts.AddRange(details.AdditionalStorageAccounts); // Tests whether the host for the script is in the list of provided storage accounts. var storage = (from acct in accts where GetFullyQualifiedStorageAccountName(acct.Name).Equals( sa.Uri.Host, StringComparison.OrdinalIgnoreCase) select acct).FirstOrDefault(); return storage; }
private static WabStorageAccountConfiguration GetStorageAccountForScript(ScriptAction sa, ClusterCreateParameters details) { var accts = new List <WabStorageAccountConfiguration>(); accts.Add(new WabStorageAccountConfiguration( details.DefaultStorageAccountName, details.DefaultStorageAccountKey, details.DefaultStorageContainer)); accts.AddRange(details.AdditionalStorageAccounts); // Tests whether the host for the script is in the list of provided storage accounts. var storage = (from acct in accts where GetFullyQualifiedStorageAccountName(acct.Name).Equals( sa.Uri.Host, StringComparison.OrdinalIgnoreCase) select acct).FirstOrDefault(); return(storage); }
public static ActionResult SetupCamera(ScriptAction action, ScriptExecutionContext context) { var positionWaypoint = context.Scene.Waypoints[action.Arguments[0].StringValue]; var zoom = action.Arguments[1].FloatValue.Value; var pitch = action.Arguments[2].FloatValue.Value; var targetWaypoint = context.Scene.Waypoints[action.Arguments[3].StringValue]; context.Scene.CameraController.EndAnimation(); context.Scene.CameraController.TerrainPosition = positionWaypoint.Position; context.Scene.CameraController.Zoom = zoom; context.Scene.CameraController.Pitch = pitch; context.Scene.CameraController.SetLookDirection(Vector3.Normalize(targetWaypoint.Position - positionWaypoint.Position)); return(ActionResult.Finished); }
private static void applyActionOnScript <T>(ScriptAction action, T script, Action <T, bool> enableScriptAction) where T : Component { if (script == null) { return; } if (action == ScriptAction.None) { return; } T[] scripts = script.GetComponents <T>(); bool enableScript = action == ScriptAction.Enable; Array.ForEach(scripts, s => enableScriptAction(s, enableScript)); }
public void EnqueueAction(ScriptAction action, bool startDequeuingActions = false) { _actionsQueue.Enqueue(action); if (startDequeuingActions) { DequeueActions(0); } // If this account is a group chief, enqueue the action to the other members // Special case: if there is a coroutube currently being handled, ignore this if (_account.HasGroup && _account.IsGroupChief) { _account.Group.EnqueueActionToMembers(action, startDequeuingActions); } }
public override void OnInspectorGUI() { ScriptAction scriptAction = target as ScriptAction; if (scriptAction == null) { Debug.LogError("scriptAction==null"); return; } if (scriptAction.ActionInfoList == null) { scriptAction.ActionInfoList = new List <ActionInfo>(); } if (scriptAction.ActionInfoList == null) { Debug.LogError("scriptAction.ActionInfoList==null"); return; } if (scriptAction.ActionInfoList != null && scriptAction.ActionInfoList.Count <= 0) { if (GUILayout.Button("Create")) { scriptAction.ActionInfoList.Add(new ActionInfo()); } } for (int i = 0; i < scriptAction.ActionInfoList.Count; i++) { ActionInfo actionInfo = scriptAction.ActionInfoList[i]; HandleEditActionInfo(actionInfo); //如果是最后一个 if (i == scriptAction.ActionInfoList.Count - 1) { EditorGUILayout.BeginVertical(); if (GUILayout.Button("Add")) { scriptAction.ActionInfoList.Add(new ActionInfo()); } if (GUILayout.Button("Save")) { AssetDatabase.SaveAssets(); } EditorGUILayout.EndVertical(); } } }
private void ActionTable_KeyDown(object sender, KeyEventArgs e) { Debug.Assert(this.Actions != null, ""); char key = (char)e.KeyValue; if (key == (char)Keys.Enter) { this.ActionTable_DoubleClick(this, null); return; } else if (key == (char)Keys.Escape) { this.Close(); return; } else if (char.IsLetter(key) == true) { foreach (ScriptAction action in this.Actions) { if (Char.ToUpper(key) == Char.ToUpper(action.ShortcutKey)) { this.SelectedIndex = this.Actions.IndexOf(action); this.SelectedAction = action; if (this.CloseWhenComplete == true) { this.Close(); } if (this.SelectedAction != null && this.TriggerAction != null) { TriggerActionArgs e1 = new TriggerActionArgs(); e1.EntryName = this.SelectedAction.ScriptEntry; e1.sender = this.sender; e1.e = this.e; this.TriggerAction(this, e1); } return; } } // Console.Beep(); } }
/// <summary> /// 条件判断 /// <para>只支持以阻塞形式调用</para> /// </summary> /// <param name="check">执行什么判断</param> /// <param name="isTrue">真</param> /// <param name="isFalse">假</param> /// <returns>当前事件Id</returns> public int If(Func <bool> check, Action isTrue, Action isFalse = null) { //判断占位 var pos = _actionList.Count; var checkPos = (uint)_actionList.Count; _actionList.Add(null); //真 var trueBeginPos = (uint)_actionList.Count; isTrue?.Invoke(); var trueEndPos = (uint)_actionList.Count; _actionList.Add(null); //假 var falseBeginPos = (uint)_actionList.Count; isFalse?.Invoke(); var falseEndPos = (uint)_actionList.Count; _actionList.Add(null); var outPos = (uint)_actionList.Count; //真跳出 _actionList[(int)trueEndPos] = new ScriptAction("IfTrueEnd") { onStart = () => SetPos(outPos) }; //假跳出 _actionList[(int)falseEndPos] = new ScriptAction("IfFalseEnd") { onStart = () => SetPos(outPos) }; //最初if判断 _actionList[(int)checkPos] = new ScriptAction("If") { onStart = () => SetPos(check() ? trueBeginPos : falseBeginPos) }; return(pos); }
private void executeAction(ScriptAction action) { switch (mode) { case ScriptRunnerMode.CatchFunction: try { executeActionInternal(action); } catch { } break; case ScriptRunnerMode.CatchScript: try { executeAction(action); } catch { scriptActionIndex = script.Actions.Count; } break; default: executeActionInternal(action); break; } }
public override void RunCommand(object sender, ScriptAction parentCommand) { //get engine var engine = (AutomationEngineInstance)sender; var vSwitchValue = v_SwitchValue.ConvertUserVariableToString(engine); //get indexes of commands var caseIndices = FindAllCaseIndices(parentCommand.AdditionalScriptCommands); var endSwitchIndex = parentCommand.AdditionalScriptCommands.FindIndex(a => a.ScriptCommand is EndSwitchCommand); var targetCaseIndex = -1; var defaultCaseIndex = -1; ScriptAction caseCommandItem; CaseCommand targetCaseCommand; // get index of target case foreach (var caseIndex in caseIndices) { caseCommandItem = parentCommand.AdditionalScriptCommands[caseIndex]; targetCaseCommand = (CaseCommand)caseCommandItem.ScriptCommand; // Save Default Case Index if (targetCaseCommand.v_CaseValue == "Default") { defaultCaseIndex = caseIndex; } // Save index if the value of any Case matches with the Switch value if (vSwitchValue == targetCaseCommand.v_CaseValue) { targetCaseIndex = caseIndex; break; } } // If Target Case Found if (targetCaseIndex != -1) { ExecuteTargetCaseBlock(sender, parentCommand, targetCaseIndex, endSwitchIndex); } // Else execute Default block else if (defaultCaseIndex != -1) { ExecuteTargetCaseBlock(sender, parentCommand, defaultCaseIndex, endSwitchIndex); } }
public void SetsEngineDelay() { _engine = new AutomationEngineInstance(null); _setEngineDelay = new SetEngineDelayCommand(); string newDelay = "1000"; VariableMethods.CreateTestVariable(newDelay, _engine, "newDelay", typeof(string)); VariableMethods.CreateTestVariable(null, _engine, "var1", typeof(string)); VariableMethods.CreateTestVariable(null, _engine, "var2", typeof(string)); _setEngineDelay.v_EngineDelay = "{newDelay}"; _setEngineDelay.RunCommand(_engine); _setVariableCommand1 = new Variable.SetVariableCommand(); _setVariableCommand1.v_Input = "val1"; _setVariableCommand1.v_OutputUserVariableName = "{var1}"; _setVariableCommand2 = new Variable.SetVariableCommand(); _setVariableCommand2.v_Input = "val2"; _setVariableCommand2.v_OutputUserVariableName = "{var2}"; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); ScriptAction action1 = new ScriptAction(); action1.ScriptCommand = _setVariableCommand1; _engine.ExecuteCommand(action1); output.WriteLine(stopwatch.ElapsedMilliseconds.ToString()); Assert.True(stopwatch.ElapsedMilliseconds > 1000); ScriptAction action2 = new ScriptAction(); action2.ScriptCommand = _setVariableCommand2; _engine.ExecuteCommand(action2); output.WriteLine(stopwatch.ElapsedMilliseconds.ToString()); Assert.True(stopwatch.ElapsedMilliseconds > 2000); stopwatch.Stop(); Assert.Equal(int.Parse(newDelay), _engine.EngineSettings.DelayBetweenCommands); }
public DeploymentActionResource AddOrUpdateScriptAction(string name, ScriptAction scriptAction, ScriptTarget scriptTarget) { var action = AddOrUpdateAction(name); action.ActionType = "Octopus.Script"; action.Properties.Clear(); action.Properties["Octopus.Action.RunOnServer"] = scriptTarget == ScriptTarget.Server ? "true" : "false"; action.Properties["Octopus.Action.Script.Syntax"] = scriptAction.Syntax.ToString(); action.Properties["Octopus.Action.Script.ScriptSource"] = scriptAction.Source.ToString(); RequiresPackagesToBeAcquired = scriptAction.Source == ScriptSource.Package; switch (scriptAction.Source) { case ScriptSource.Inline: string scriptBody = null; var inlineScript = scriptAction as InlineScriptAction; if (inlineScript != null) { scriptBody = inlineScript.GetScriptBody(); } var inlineScriptFromFileInAssembly = scriptAction as InlineScriptActionFromFileInAssembly; if (inlineScriptFromFileInAssembly != null) { scriptBody = inlineScriptFromFileInAssembly.GetScriptBody(); } if (scriptBody == null) { throw new NotSupportedException($"{scriptAction.GetType().Name} is not a supported Script Action type yet..."); } action.Properties.Add("Octopus.Action.Script.ScriptBody", scriptBody); break; case ScriptSource.Package: var packageScript = (ScriptActionFromFileInPackage)scriptAction; action.Properties.Add("Octopus.Action.Package.PackageId", packageScript.PackageId); action.Properties.Add("Octopus.Action.Package.FeedId", packageScript.PackageFeedId); action.Properties.Add("Octopus.Action.Script.ScriptFileName", packageScript.ScriptFilePath); break; } return(action); }
private async Task <Result <Unit> > PerformAction(ScriptAction action) { Console.WriteLine($"Attempting to {action.ToString()}"); switch (action.ActionType) { case ScriptActionType.Start: return(await _repository.RetryStartService(action.ServiceName, MaxAttempts, RetryInterval)); case ScriptActionType.Stop: return(await _repository.RetryStopService(action.ServiceName, MaxAttempts, RetryInterval)); case ScriptActionType.Reset: return(new Exception("Reset actions are not primitive.").AsError <Unit>()); default: return(new Exception("Invalid enum value.").AsError <Unit>()); } }
private async Task GenerateScripts(TreeNode node, ScriptAction scriptAction) { object tag = node.Tag; if (tag is Database) { Database database = tag as Database; frmGenerateScripts frmGenerateScripts = new frmGenerateScripts(this.databaseType, this.GetConnectionInfo(database.Name)); frmGenerateScripts.ShowDialog(); } else if (tag is DatabaseObject) { string databaseName = this.GetDatabaseNode(node).Name; await this.GenerateObjectScript(databaseName, tag as DatabaseObject, scriptAction); } }
internal static string GenerateAuditScript(string storageConnectionString, ScriptAction scriptAction, ProgressChangeDelegate progressChangeDelegate) { //Set Audit Settings SqlAuditSettings myAuditSettings = new SqlAuditSettings(storageConnectionString); //Choose Script MMC.SyncAction myAuditSettings.ScriptAction = scriptAction; //Select Audit Columns myAuditSettings.AuditColumns = AuditColumns.ApplicationName | AuditColumns.AuditDateTime | AuditColumns.HostId | AuditColumns.HostName | AuditColumns.UserName | AuditColumns.UserSID; //Choose Triggers MMC.SyncAction myAuditSettings.TriggersActions = TriggerActions.Insert | TriggerActions.Update | TriggerActions.Delete; //Choose Indexes MMC.SyncAction myAuditSettings.IndexesAction = IndexesAction.SameIndexesAsSourceTable; //Assign naming properties myAuditSettings.AuditTablesSuffix = "_Audit"; myAuditSettings.AuditTriggersSuffix = "_TriggerForAudit"; //Define File Groups myAuditSettings.TablesFileGroupName = "[PRIMARY]"; myAuditSettings.IndexesFileGroupName = "[PRIMARY]"; //Use SqlAuditDiscovery Class to get Table Schemas. SqlAuditDiscovery auditDiscoveryUtility = new SqlAuditDiscovery(storageConnectionString); //Get TableInfo Collection TableInfoCollection myTables = auditDiscoveryUtility.GetAllTableInfo(myAuditSettings); //*** Tables Customization ***// myTables.Remove(new SchemaTablePair("dbo", "UsersDemo")); myTables.Remove(new SchemaTablePair("dbo", "netsqlazman_LogTable")); //Generate Audit Script SqlAuditGenerator generator = new SqlAuditGenerator(myAuditSettings); generator.ProgressChange += progressChangeDelegate; return(generator.GenerateDDLScriptForAuditTables(myTables)); }
public async override Tasks.Task RunCommand(object sender, ScriptAction parentCommand) { var engine = (IAutomationEngineInstance)sender; bool whileResult = true; engine.ReportProgress("Starting While"); while (whileResult) { foreach (var cmd in parentCommand.AdditionalScriptCommands) { if (engine.IsCancellationPending) { return; } await engine.ExecuteCommand(cmd); if (engine.CurrentLoopCancelled) { engine.ReportProgress("Exiting While"); engine.CurrentLoopCancelled = false; return; } if (engine.CurrentLoopContinuing) { engine.ReportProgress("Continuing Next While"); engine.CurrentLoopContinuing = false; break; } } if (v_Option == "Inline") { whileResult = (bool)await v_Condition.EvaluateCode(engine); } else { whileResult = await CommandsHelper.DetermineStatementTruth(engine, v_ActionType, v_ActionParameterTable); } } }
public async void ProcessesSwitch(string caseString) { _engine = new AutomationEngineInstance(null); _beginSwitch = new BeginSwitchCommand(); _case1 = new CaseCommand(); _defaultCase = new CaseCommand(); _endSwitch = new EndSwitchCommand(); _parentAction = new ScriptAction(); _setVariableCase1 = new Variable.SetVariableCommand(); _setVariableDefaultCase = new Variable.SetVariableCommand(); VariableMethods.CreateTestVariable(caseString, _engine, "caseInput", typeof(string)); VariableMethods.CreateTestVariable(null, _engine, "switchOutput", typeof(string)); _beginSwitch.v_SwitchValue = "{caseInput}"; _case1.v_CaseValue = "case1"; _defaultCase.v_CaseValue = "Default"; _setVariableCase1.v_Input = "case1Set"; _setVariableCase1.v_OutputUserVariableName = "{switchOutput}"; _setVariableDefaultCase.v_Input = "defaultCaseSet"; _setVariableDefaultCase.v_OutputUserVariableName = "{switchOutput}"; _parentAction.ScriptCommand = _beginSwitch; _parentAction.AddAdditionalAction(_case1); _parentAction.AddAdditionalAction(_setVariableCase1); _parentAction.AddAdditionalAction(_defaultCase); _parentAction.AddAdditionalAction(_setVariableDefaultCase); _parentAction.AddAdditionalAction(_endSwitch); _engine.ExecuteCommand(_parentAction); if (caseString.Equals("case1")) { Assert.Equal("case1Set", (string)await "{switchOutput}".EvaluateCode(_engine)); } else if (caseString.Equals("noCase")) { Assert.Equal("defaultCaseSet", (string)await "{switchOutput}".EvaluateCode(_engine)); } }
public async override Tasks.Task RunCommand(object sender, ScriptAction parentCommand) { var engine = (IAutomationEngineInstance)sender; foreach (var item in ScriptActions) { //exit if cancellation pending if (engine.IsCancellationPending) { return; } //only run if not commented if (!item.IsCommented) { item.RunCommand(engine); } } }
public override void RunCommand(object sender, ScriptAction parentCommand) { LoopNumberOfTimesCommand loopCommand = (LoopNumberOfTimesCommand)parentCommand.ScriptCommand; var engine = (IAutomationEngineInstance)sender; int loopTimes; var loopParameter = loopCommand.v_LoopParameter.ConvertUserVariableToString(engine); loopTimes = int.Parse(loopParameter); int.TryParse(v_LoopStart.ConvertUserVariableToString(engine), out int startIndex); for (int i = startIndex; i < loopTimes; i++) { engine.ReportProgress("Starting Loop Number " + (i + 1) + "/" + loopTimes + " From Line " + loopCommand.LineNumber); foreach (var cmd in parentCommand.AdditionalScriptCommands) { if (engine.IsCancellationPending) { return; } engine.ExecuteCommand(cmd); if (engine.CurrentLoopCancelled) { engine.ReportProgress("Exiting Loop From Line " + loopCommand.LineNumber); engine.CurrentLoopCancelled = false; return; } if (engine.CurrentLoopContinuing) { engine.ReportProgress("Continuing Next Loop From Line " + loopCommand.LineNumber); engine.CurrentLoopContinuing = false; break; } } engine.ReportProgress("Finished Loop From Line " + loopCommand.LineNumber); } }
public override void RunCommand(object sender, ScriptAction parentCommand) { var engine = (AutomationEngineInstance)sender; var ifResult = DetermineStatementTruth(sender); int startIndex, endIndex, elseIndex; if (parentCommand.AdditionalScriptCommands.Any(item => item.ScriptCommand is ElseCommand)) { elseIndex = parentCommand.AdditionalScriptCommands.FindIndex(a => a.ScriptCommand is ElseCommand); if (ifResult) { startIndex = 0; endIndex = elseIndex; } else { startIndex = elseIndex + 1; endIndex = parentCommand.AdditionalScriptCommands.Count; } } else if (ifResult) { startIndex = 0; endIndex = parentCommand.AdditionalScriptCommands.Count; } else { return; } for (int i = startIndex; i < endIndex; i++) { if ((engine.IsCancellationPending) || (engine.CurrentLoopCancelled) || (engine.CurrentLoopContinuing)) { return; } engine.ExecuteCommand(parentCommand.AdditionalScriptCommands[i]); } }
public override bool Act(float delta) { for (int i = running - 1; i >= 0; i--) { ScriptAction action = actions[i]; if (action.Act(delta)) { action.Reset(); running--; if (running != i) { actions[i] = actions[running]; actions[running] = action; } } } return(CompleteIf(running == 0)); }
public static ActionResult MoveCameraTo(ScriptAction action, ScriptExecutionContext context) { //Check if a named camera exists Vector3 targetPoint; var name = action.Arguments[0].StringValue; if (context.Scene.Cameras.Exists(name)) { targetPoint = context.Scene.Cameras[name].LookAtPoint; } else { targetPoint = context.Scene.Waypoints[name].Position; } var duration = TimeSpan.FromSeconds(action.Arguments[1].FloatValue.Value); var shutter = action.Arguments[2].FloatValue.Value; return(new MoveCameraToAction(targetPoint, duration, shutter).Execute(context)); }
private ScriptCommandSet(Package package) { if (package == null) { throw new ArgumentNullException("package"); } _package = package; OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (commandService != null) { var scriptMenuCommandId = new CommandID(CommandSet, CommandScriptId); var scriptMenuCommand = new MenuCommand(this.MenuScriptCallback, scriptMenuCommandId); commandService.AddCommand(scriptMenuCommand); var runMenuCommandId = new CommandID(CommandSet, CommandRunId); var runMenuCommand = new MenuCommand(this.MenuRunCallback, runMenuCommandId); commandService.AddCommand(runMenuCommand); } DTE2 dte = (DTE2)ServiceProvider.GetService(typeof(DTE)); IHostContext hostCtx = new HostContext(dte); IWindowsUser windowsUser = new WindowsUser(); string registryMasterKey = Registry.CurrentUser.Name + "\\Software\\SSMScripter"; IScripterParser scripterParser = new ScripterParser(); IScripter scripter = new SmoScripter(); IScripterConfigStorage scripterConfigStorage = new ScripterConfigRegistryStorage(registryMasterKey); _scriptAction = new ScriptAction(hostCtx, scripter, scripterParser, scripterConfigStorage); IRunConfigStorage runConfigStorage = new RunConfigRegistryStorage(registryMasterKey); IRunContextProvider runContextProvider = new RunContextProvider(hostCtx, runConfigStorage); IRunParamsProcessor runParamsProcessor = new RunParamsProcessor(windowsUser); IRunProcessStarter runProcessStarter = new RunProcessStarter(); _runAction = new RunAction(runContextProvider, runParamsProcessor, runProcessStarter); }
public static IRosCoreConnectionAction GetTeardownAction(this RosCoreConfigurationOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } var strategyName = options.TeardownStrategy?.Trim(); if (strategyName == null) { if (options.StartupStrategy != null && options.StartupStrategy.Equals("launch", StringComparison.InvariantCultureIgnoreCase)) { strategyName = "close"; } else { strategyName = "none"; } } if (strategyName.Equals("none", StringComparison.OrdinalIgnoreCase)) { return(new NoAction()); } if (strategyName.Equals("close", StringComparison.InvariantCultureIgnoreCase)) { return(new ShutdownRosCoreAction()); } if (strategyName.Equals("script", StringComparison.CurrentCultureIgnoreCase)) { if (options.TeardownScriptPath == null) { throw new Exception("No script"); // TODO: Correct exception } return(ScriptAction.Create(options.TeardownScriptPath)); } throw new InvalidOperationException($"The provided roscore teardown strategy {options.TeardownStrategy} is not supported."); }
internal static string GenerateAuditScript(string storageConnectionString, ScriptAction scriptAction, ProgressChangeDelegate progressChangeDelegate) { //Set Audit Settings SqlAuditSettings myAuditSettings = new SqlAuditSettings(storageConnectionString); //Choose Script MMC.SyncAction myAuditSettings.ScriptAction = scriptAction; //Select Audit Columns myAuditSettings.AuditColumns = AuditColumns.ApplicationName | AuditColumns.AuditDateTime | AuditColumns.HostId | AuditColumns.HostName | AuditColumns.UserName | AuditColumns.UserSID; //Choose Triggers MMC.SyncAction myAuditSettings.TriggersActions = TriggerActions.Insert | TriggerActions.Update | TriggerActions.Delete; //Choose Indexes MMC.SyncAction myAuditSettings.IndexesAction = IndexesAction.SameIndexesAsSourceTable; //Assign naming properties myAuditSettings.AuditTablesSuffix = "_Audit"; myAuditSettings.AuditTriggersSuffix = "_TriggerForAudit"; //Define File Groups myAuditSettings.TablesFileGroupName = "[PRIMARY]"; myAuditSettings.IndexesFileGroupName = "[PRIMARY]"; //Use SqlAuditDiscovery Class to get Table Schemas. SqlAuditDiscovery auditDiscoveryUtility = new SqlAuditDiscovery(storageConnectionString); //Get TableInfo Collection TableInfoCollection myTables = auditDiscoveryUtility.GetAllTableInfo(myAuditSettings); //*** Tables Customization ***// myTables.Remove(new SchemaTablePair("dbo", "UsersDemo")); myTables.Remove(new SchemaTablePair("dbo", "netsqlazman_LogTable")); //Generate Audit Script SqlAuditGenerator generator = new SqlAuditGenerator(myAuditSettings); generator.ProgressChange+=progressChangeDelegate; return generator.GenerateDDLScriptForAuditTables(myTables); }
protected override void OnProcess(Action.IAction action) { ScriptAction scriptAction = action as ScriptAction; if (scriptAction == null) { return; } LoggerManager.Debug(action.AutomationActionData); if (!string.IsNullOrEmpty(scriptAction.ScriptContent)) { object[] args = new object[1]; args[0] = scriptAction.ScriptContent; this.Call <WebBrowserEx>(delegate(WebBrowserEx ex) { ex.Document.InvokeScript("eval", args); }, this.webBrowser); } }
public override SQLScript Drop() { ScriptAction action = ScriptAction.DropConstraint; if (this.Type == ConstraintType.ForeignKey) { action = ScriptAction.DropConstraintFK; } if (this.Type == ConstraintType.PrimaryKey) { action = ScriptAction.DropConstraintPK; } if (!GetWasInsertInDiffList(action)) { SetWasInsertInDiffList(action); return(new SQLScript(this.ToSqlDrop(), ((Table)Parent).DependenciesCount, action)); } else { return(null); } }
private void ExecuteTargetCatchBlock(object sender, ScriptAction parentCommand, int startCatchIndex, int endCatchIndex) { //get engine var engine = (AutomationEngineInstance)sender; var catchIndices = FindAllCatchIndices(parentCommand.AdditionalScriptCommands); // Next Catch Index var nextCatchIndex = FindNextCatchIndex(catchIndices, startCatchIndex); // If Next Catch Exist if (nextCatchIndex != startCatchIndex) { // Next Catch will be the end of the Target Catch endCatchIndex = nextCatchIndex; } // Execute Target Catch Block for (var catchIndex = startCatchIndex; catchIndex < endCatchIndex; catchIndex++) { engine.ExecuteCommand(parentCommand.AdditionalScriptCommands[catchIndex]); } }
public static ActionResult MoveNamedUnitTo(ScriptAction action, ScriptExecutionContext context) { var unitName = action.Arguments[0].StringValue; if (!context.Scene.GameObjects.TryGetObjectByName(unitName, out var unit)) { ScriptingSystem.Logger.Warn($"Unit \"{unitName}\" does not exist."); return(ActionResult.Finished); } var waypointName = action.Arguments[1].StringValue; if (!context.Scene.Waypoints.TryGetByName(waypointName, out var waypoint)) { ScriptingSystem.Logger.Warn($"Waypoint \"{waypointName}\" does not exist."); return(ActionResult.Finished); } unit.SetTargetPoint(waypoint.Position); return(ActionResult.Finished); }
private string ComposeSampleCommand(string scriptPath, string additionalParams) { if ((string.IsNullOrEmpty(scriptPath)) || (scriptPath.Trim().Length == 0)) { return(""); } //TokenReplacer tokenReplacer = TokenHelper.TokenReplacerWithPlaceHolders; string scriptCall = Path.GetFileName(ScriptAction.ComposeScriptPath(scriptPath, _tokenReplacer)); if (!string.IsNullOrEmpty(additionalParams)) { scriptCall += " " + ScriptAction.ComposeScriptParameters(additionalParams, new[] { @"C:\File1.pdf", @"C:\File2.pdf" }, _tokenReplacer); } else { scriptCall += @" C:\File1.pdf C:\File2.pdf"; } return(scriptCall); }
private void button_excute_Click(object sender, EventArgs e) { if (Actions == null || this.TriggerAction == null) { return; } if (this.ActionTable.SelectedRows.Count == 0) { MessageBox.Show(this, "尚未选择要执行的事项..."); return; } if (this.CloseWhenComplete == true) { this.Close(); } List <DpRow> selections = new List <DpRow>(); selections.AddRange(this.ActionTable.SelectedRows); foreach (DpRow row in selections) { ScriptAction action = (ScriptAction)row.Tag; Debug.Assert(action != null, ""); if (action != null && this.TriggerAction != null) { TriggerActionArgs e1 = new TriggerActionArgs(); e1.EntryName = action.ScriptEntry; e1.sender = this.sender; e1.e = this.e; this.TriggerAction(this, e1); } } }
public string GenerateScript(ScriptAction action, ModelObject modelObject) { ISchemaBase schemaObject; switch (action) { case ScriptAction.OriginalFromSource: schemaObject = _source.Find(modelObject.Name); return schemaObject == null ? string.Empty : schemaObject.ToSql(); case ScriptAction.OriginalFromTarget: schemaObject = _target.Find(modelObject.Name); return schemaObject == null ? string.Empty : schemaObject.ToSql(); case ScriptAction.Merged: schemaObject = _merged.Find(modelObject.Name); return schemaObject == null ? string.Empty : schemaObject.ToSqlDiff().ToSQL(); } return string.Empty; }
private void ActionTable_DoubleClick(object sender, EventArgs e) { if (this.ActionTable.SelectedRows.Count == 0) { MessageBox.Show(this, "尚未选择事项..."); return; } this.SelectedAction = (ScriptAction)this.ActionTable.SelectedRows[0].Tag; Debug.Assert(this.SelectedAction != null, ""); this.SelectedIndex = this.Actions.IndexOf(this.SelectedAction); if (this.CloseWhenComplete == true) this.Close(); if (this.SelectedAction != null && this.TriggerAction != null) { TriggerActionArgs e1 = new TriggerActionArgs(); e1.EntryName = this.SelectedAction.ScriptEntry; e1.sender = this.sender; e1.e = this.e; this.TriggerAction(this, e1); } }
private void ActionTable_KeyDown(object sender, KeyEventArgs e) { Debug.Assert(this.Actions != null, ""); char key = (char)e.KeyValue; if (key == (char)Keys.Enter) { this.ActionTable_DoubleClick(this, null); return; } else if (key == (char)Keys.Escape) { this.Close(); return; } else if (char.IsLetter(key) == true) { foreach (ScriptAction action in this.Actions) { if (Char.ToUpper(key) == Char.ToUpper(action.ShortcutKey)) { this.SelectedIndex = this.Actions.IndexOf(action); this.SelectedAction = action; if (this.CloseWhenComplete == true) this.Close(); if (this.SelectedAction != null && this.TriggerAction != null) { TriggerActionArgs e1 = new TriggerActionArgs(); e1.EntryName = this.SelectedAction.ScriptEntry; e1.sender = this.sender; e1.e = this.e; this.TriggerAction(this, e1); } return; } } // Console.Beep(); } }
private void button_OK_Click(object sender, System.EventArgs e) { if (listView1.SelectedItems.Count == 0) { MessageBox.Show(this, "尚未选择事项..."); return; } this.SelectedIndex = listView1.SelectedIndices[0]; if (Actions != null) this.SelectedAction = (ScriptAction)this.Actions[this.SelectedIndex]; else this.SelectedAction = null; this.DialogResult = DialogResult.OK; this.Close(); }
public string GenerateScript(ScriptAction action, ModelObject modelObject) { return string.Empty; }
private static void LoadScriptBlock(Level level, ScriptDef targetSD, XmlNode node, ScriptBlock root, string firstChildName = "") { if (node == null || root == null) { return; } var child = node.FirstChild; if (child == null) { return; } do { if (!firstChildName.Equals("")) { if (!child.Name.Equals(firstChildName, StringComparison.InvariantCultureIgnoreCase)) { Log.WriteInfo("Attention ! Impossible d'ajouter le scriptBlock : " + child.Name + " alors que le scriptBlock obligatoire est : " + firstChildName); continue; } } ScriptBlock scriptBlock = null; switch (child.Name.ToLower()) { case "action": { var a = child.Attributes?["a"]; if (a == null) throw new Exception(" le scriptBlock <action> ne contient pas d'action \"a\" !"); var p = child.Attributes?["p"]; if (p == null) throw new Exception(" le scriptBlock <action> ne contient pas de paramètres ! \"p\" "); var parameters = new List<string>(); var i = 1; do { parameters.Add(p.Value); ++i; } while ((p = child.Attributes?["p" + i]) != null); scriptBlock = new ScriptAction(level, a.Value, parameters); } break; case "update": { var delayA = child.Attributes?["delay"]; if (delayA == null) throw new Exception(" le scriptBlock <update> ne contient pas de delay"); double delay = 0.0; if (delayA.Value.Equals("$FRAME_RATE")) { delay = 1.0 / 60.0; } else { if (!double.TryParse(delayA.Value, out delay)) throw new Exception(" le scriptBlock <update> ne contient pas de delay valide !"); if (delay <= 0) throw new Exception(" le scriptBlock <update> ne contient pas un delay valide ! Il est plus petit ou égal à 0 !"); } scriptBlock = new ScriptUpdate(delay); LoadScriptBlock(level, targetSD, child, scriptBlock); } break; case "condition": { var varRefA = child.Attributes?["ref"]; var valueConditionA = child.Attributes?["value"]; if (varRefA == null || valueConditionA == null) throw new Exception(" le scriptBlock <condition> ne contient pas la référence vers la variable ou sa condition \"ref\" ou \"value\" !"); if (!targetSD.Variables.ContainsKey(varRefA.Value)) throw new Exception(" le scriptBlock <condition> utilise la variable : " + varRefA.Value + " alors qu'elle n'est pas définie dans <variables> !"); var variable = targetSD.Variables[varRefA.Value]; if (variable is int) { if (!int.TryParse(valueConditionA.Value, out var condition)) { throw new Exception(" dans le scriptBlock <condition>, la condition utilisée ne peut pas être convertie en nombre (int) !"); } scriptBlock = new ScriptCondition<int>(varRefA.Value, condition); } else if (variable is bool) { if (!bool.TryParse(valueConditionA.Value, out var condition)) { throw new Exception(" dans le scriptBlock <condition>, la condition utilisée ne peut pas être convertie en booléen (bool) !"); } scriptBlock = new ScriptCondition<bool>(varRefA.Value, condition); } else throw new Exception(" le scriptBlock <condition> utilise une variable dont le type est inconnu !"); LoadScriptBlock(level, targetSD, child, scriptBlock); } break; case "collision": { var dirSide = child.Attributes?["side"]; var typeRef = child.Attributes?["typeRef"]; if (dirSide == null || typeRef == null) throw new Exception(" le scriptBlock <collision> ne contient pas la direction \"side\" ou la référence \"typeRef\" !"); var sides = new List<PhysicsBody.CollisionSide>(); var rawSides = dirSide.Value.Split('|'); foreach (var rawSide in rawSides) { if (!Enum.TryParse<PhysicsBody.CollisionSide>(rawSide, out var side)) throw new Exception(" le scriptBlock <collision> contient une erreur ! Impossible de convertir : " + dirSide.Value + " en direction !"); sides.Add(side); } scriptBlock = new ScriptCollisionEvent(sides, typeRef.Value); LoadScriptBlock(level, targetSD, child, scriptBlock); } break; case "key": { var codeA = child.Attributes?["code"]; var justPressedA = child.Attributes?["justPressed"]; var upA = child.Attributes?["up"]; if (codeA == null) throw new Exception(" le scriptBlock <key> ne contient pas la touche \"code\""); if (!Enum.TryParse<Keyboard.Key>(codeA.Value, true, out var key)) { throw new Exception(" le scriptBlock <key> contient une touche qui n'existe pas ! : " + codeA.Value); } bool justPressed = false, up = false; if (justPressedA != null) { if (!bool.TryParse(justPressedA.Value, out justPressed)) throw new Exception(" le scriptBlock <key> contient des erreurs ! Impossible de convertir : " + justPressedA.Value + " en valeur booléenne !"); } if (upA != null) { if (!bool.TryParse(upA.Value, out up)) throw new Exception(" le scriptBlock <key> contient des erreurs ! Impossible de convertir : " + upA.Value + " en valeur booléenne !"); } scriptBlock = new ScriptInput(key, justPressed, up); LoadScriptBlock(level, targetSD, child, scriptBlock); } break; } if (scriptBlock == null) throw new Exception(" le script contient un scriptBlock inconnu !"); root.AddChild(scriptBlock); } while ((child = child.NextSibling) != null); }
private void ActionTable_DoubleClick(object sender, EventArgs e) { if (this._processing > 0) { MessageBox.Show(this, "正在处理中,请稍后再重新启动执行"); return; } if (this.ActionTable.SelectedRows.Count == 0) { MessageBox.Show(this, "尚未选择事项..."); return; } this.SelectedAction = (ScriptAction)this.ActionTable.SelectedRows[0].Tag; if (this.SelectedAction == null) return; // 一般是因为双击了错误信息行 Debug.Assert(this.SelectedAction != null, ""); this.SelectedIndex = this.Actions.IndexOf(this.SelectedAction); if (this.CloseWhenComplete == true) this.Close(); if (this.SelectedAction != null && this.TriggerAction != null) { BeginProcess(); try { TriggerActionArgs e1 = new TriggerActionArgs(); e1.EntryName = this.SelectedAction.ScriptEntry; e1.sender = this.sender; e1.e = this.e; this.TriggerAction(this, e1); } finally { EndProcess(); } } }
private void dpTable1_KeyDown(object sender, KeyEventArgs e) { Debug.Assert(this.Actions != null, ""); char key = (char)e.KeyValue; if (key == (char)Keys.Enter) { button_OK_Click(null, null); return; } else if (key == (char)Keys.Escape) { button_Cancel_Click(null, null); return; } else if (char.IsLetter(key) == true) { foreach (ScriptAction action in this.Actions) { if (Char.ToUpper(key) == Char.ToUpper(action.ShortcutKey)) { this.SelectedIndex = this.Actions.IndexOf(action); this.SelectedAction = action; this.DialogResult = DialogResult.OK; this.Close(); return; } } // Console.Beep(); } }