public async Task ConfigTraining(CommandContext ctx) { var sadgeEmoji = DiscordEmoji.FromName(ctx.Client, ":Sadge:"); var usagiEmoji = DiscordEmoji.FromName(ctx.Client, ":usagi:"); var inputStep = new ConfigStep("Should I notify you when your **training** is done?", null); string input = string.Empty; inputStep.OnValidResult += (result) => input = result; var inputDialogHandler = new DialogueHandler(ctx.Client, ctx.Channel, ctx.User, inputStep); bool succeeded = await inputDialogHandler.ProcessDialogue().ConfigureAwait(false); if (!succeeded) { return; } if (input.Equals("yes") || input.Equals("y")) { await UpdateState(ctx, AlertType.Training, true).ConfigureAwait(false); await ctx.Channel.SendMessageAsync($"{ctx.Member.Mention}, your **training** alerts are enabled! {usagiEmoji}").ConfigureAwait(false); } else { await UpdateState(ctx, AlertType.Training, false).ConfigureAwait(false); await ctx.Channel.SendMessageAsync($"{ctx.Member.Mention}, your *training** alerts are disabled! {sadgeEmoji}").ConfigureAwait(false); } }
/// <summary> /// Buffer values to read. /// </summary> /// <param name="configStep">Configurations step.</param> /// <value>Configuration value.</value> /// <returns>True or false.</returns> public static bool BufferValues(ConfigStep configStep) { try { dynamic key = configStep.TestVariableName; dynamic valueAttribute = configStep.TestDataValue; if (TestCase.TestDataSavedValues.ContainsKey(key)) { TestCase.TestDataSavedValues.Remove(key); } if (!string.IsNullOrEmpty(valueAttribute)) { TestCase.TestDataSavedValues.Add(key, valueAttribute); } return(true); } catch (Exception ex) { Result.PassStepOutandSave(configStep.TestConfigKeyToUse, configStep.TestStepNo, "SaveUIControlValueAttribute", Entities.Constants.Fail, string.Format(Entities.Constants.Messages.DueToException, ex.Message), configStep.Remarks); LogHelper.ErrorLog(ex, Entities.Constants.ClassName.UiActionsClassName, MethodBase.GetCurrentMethod().Name); return(false); } }
private void InitData() { _congfigStep = (ConfigStep)ConfigManager.Instance().GetConfig(ConfigType.ConfigStep); Transform tran = GameObject.Find("StepObjs").transform; EleItems = new List <EleItem>(tran.childCount); for (int i = 0; i < tran.childCount; i++) { EleItem item = new EleItem(tran.GetChild(i)); EleItems.Add(item); } StepItems = new Dictionary <int, StepItem>(5); for (int i = 0; i < _congfigStep.ConfigDatas.Count; i++) { StepItem sItem = new StepItem(); sItem.Index = i; sItem.Desc = StepManager.Instance().GetCurStepDesc(i); sItem.CurDragEleItem = EleItems.Find(x => x.Name.Equals(_congfigStep.Get(i + 1).dragName)); sItem.CurCastEleItem = EleItems.Find(x => x.Name.Equals(_congfigStep.Get(i + 1).castName)); StepItems.Add(i, sItem); } }
private Result CreateClone() { Result initRepoResult = this.TryInitRepo(); if (!initRepoResult.Success) { return(initRepoResult); } string errorMessage; if (!this.TrySetObjectCacheLocation(this.fileSystem, this.enlistment, out errorMessage)) { return(new Result("Error configuring alternate: " + errorMessage)); } this.context = new ScalarContext(this.tracer, this.fileSystem, this.enlistment); // Set required and optional config. // Explicitly pass useGvfsProtocol: true as the enlistment can not discover that setting from // Git config yet. Other verbs will discover this automatically from the config we set now. ConfigStep configStep = new ConfigStep(context, useGvfsProtocol: true); if (!configStep.TrySetConfig(out string configError)) { return(new Result($"Failed to set initial config: {configError}")); } CacheServerResolver cacheServerResolver = new CacheServerResolver(this.tracer, this.enlistment); if (!cacheServerResolver.TrySaveUrlToLocalConfig(this.cacheServer, out errorMessage)) { return(new Result("Unable to configure cache server: " + errorMessage)); } if (!this.TryDownloadCommit( this.refs.GetTipCommitId(this.Branch), this.enlistment, out errorMessage)) { return(new Result(errorMessage)); } this.git = new GitProcess(this.enlistment); string originBranchName = "origin/" + this.Branch; GitProcess.Result createBranchResult = this.git.CreateBranchWithUpstream(this.Branch, originBranchName); if (createBranchResult.ExitCodeIsFailure) { return(new Result("Unable to create branch '" + originBranchName + "': " + createBranchResult.Errors + "\r\n" + createBranchResult.Output)); } File.WriteAllText( Path.Combine(this.enlistment.WorkingDirectoryRoot, ScalarConstants.DotGit.Head), "ref: refs/heads/" + this.Branch); try { this.LogEnlistmentInfoAndSetConfigValues(this.tracer, this.git, this.enlistment); } catch (Exception e) { this.tracer.RelatedError(e.ToString()); return(new Result(e.Message)); } return(new Result(true)); }
private Result GitClone() { string gitBinPath = ScalarPlatform.Instance.GitInstallation.GetInstalledGitBinPath(); if (string.IsNullOrWhiteSpace(gitBinPath)) { return(new Result(ScalarConstants.GitIsNotInstalledError)); } GitProcess git = new GitProcess(this.enlistment); // protocol.version=2 is broken right now. git.SetInLocalConfig("protocol.version", "1"); git.SetInLocalConfig("remote.origin.url", this.RepositoryURL); git.SetInLocalConfig("remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*"); git.SetInLocalConfig("remote.origin.promisor", "true"); git.SetInLocalConfig("remote.origin.partialCloneFilter", "blob:none"); string branch = this.Branch ?? "master"; git.SetInLocalConfig($"branch.{branch}.remote", "origin"); git.SetInLocalConfig($"branch.{branch}.merge", $"refs/heads/{branch}"); if (!this.FullClone) { GitProcess.SparseCheckoutInit(this.enlistment); } this.context = new ScalarContext(this.tracer, this.fileSystem, this.enlistment); // Set required and optional config. // Explicitly pass useGvfsProtocol: true as the enlistment can not discover that setting from // Git config yet. Other verbs will discover this automatically from the config we set now. ConfigStep configStep = new ConfigStep(this.context, useGvfsProtocol: false); if (!configStep.TrySetConfig(out string configError)) { return(new Result($"Failed to set initial config: {configError}")); } GitProcess.Result fetchResult = null; if (!this.ShowStatusWhileRunning(() => { using (ITracer activity = this.tracer.StartActivity("git-fetch-partial", EventLevel.LogAlways)) { fetchResult = git.ForegroundFetch("origin"); return(fetchResult.ExitCodeIsSuccess); } }, "Fetching objects from remote")) { if (!fetchResult.Errors.Contains("filtering not recognized by server")) { return(new Result($"Failed to complete regular clone: {fetchResult?.Errors}")); } } if (fetchResult.ExitCodeIsFailure && !this.ShowStatusWhileRunning(() => { using (ITracer activity = this.tracer.StartActivity("git-fetch", EventLevel.LogAlways)) { git.DeleteFromLocalConfig("remote.origin.promisor"); git.DeleteFromLocalConfig("remote.origin.partialCloneFilter"); fetchResult = git.ForegroundFetch("origin"); return(fetchResult.ExitCodeIsSuccess); } }, "Fetching objects from remote")) { return(new Result($"Failed to complete regular clone: {fetchResult?.Errors}")); } GitProcess.Result checkoutResult = null; if (!this.ShowStatusWhileRunning(() => { using (ITracer activity = this.tracer.StartActivity("git-checkout", EventLevel.LogAlways)) { checkoutResult = git.ForceCheckout(branch); return(checkoutResult.ExitCodeIsSuccess); } }, $"Checking out '{branch}'")) { return(new Result($"Failed to complete regular clone: {checkoutResult?.Errors}")); } return(new Result(true)); }
/// <summary> /// Load Test Configurations. /// </summary> /// <param name="applicationClass">Name of the Application under test.</param> private static void LoadTestConfigurations(ApplicationClass applicationClass) { var testdatakeyConfig = 1; try { var workbook = WorkBookUtility.OpenWorkBook(applicationClass, TestCase.RootFilePath + ConfigurationManager.AppSettings.Get(Entities.Constants.AppSetting.TestConfigurationFile)); dynamic worksheet = (Worksheet)workbook.Worksheets[1]; var rowsCount = worksheet.UsedRange.Rows.Count; var cellCount = worksheet.UsedRange.Columns.Count + 1; for (var rowindex = 2; rowindex <= rowsCount; rowindex++) { if (string.IsNullOrEmpty(worksheet.Cells[rowindex, 1].value)) { break; //// reading the sheet untill the first empty row } var configStep = new ConfigStep(); for (var cellindex = 1; cellindex <= cellCount; cellindex++) { string dataValue = Convert.ToString(worksheet.Cells[rowindex, cellindex].value); string headerValue = Convert.ToString(worksheet.Cells[1, cellindex].value); if (string.IsNullOrEmpty(headerValue)) { ConfigStep.TestConfigNames.Add(configStep); break; //// reading the sheet untill the first empty column } switch (headerValue.ToUpper()) { case Entities.Constants.TestConfiguration.SNo: configStep.TestStepNo = dataValue; testdatakeyConfig = 1; break; case Entities.Constants.TestConfiguration.Datatype: configStep.TestDataType = dataValue; break; case Entities.Constants.TestConfiguration.VariableName: configStep.TestVariableName = dataValue; break; case Entities.Constants.TestConfiguration.TestData: if (testdatakeyConfig > ConfigStep.TestDataConfigCount) { ConfigStep.TestDataConfigCount += 1; } testdatakeyConfig += 1; configStep.TestDataValue = dataValue; break; default: if (headerValue.Length > 0) { throw new Exception(string.Format(Entities.Constants.Messages.TestConfigurationError, headerValue)); } ConfigStep.TestConfigNames.Add(configStep); break; } } } WorkBookUtility.CloseWorkBook(workbook); } catch (Exception ex) { LogHelper.ErrorLog(ex, Entities.Constants.ClassName.Data, MethodBase.GetCurrentMethod().Name); throw; } }