public bool gameStart() { //Reset flags _arena.flagReset(); _arena.flagSpawn(); //We've started! _tickGameStart = Environment.TickCount; _tickGameStarting = 0; //Scramble the teams! ScriptHelpers.scrambleTeams(_arena, 2, true); //Spawn our flags! _arena.flagSpawn(); //Create some points and subscribe to our point modification event _points = new Points(_arena.ActiveTeams, 0, 1000); _points.PointModify += onPointModify; //Start keeping track of healing _healingDone = new Dictionary <Player, int>(); //Let everyone know _arena.sendArenaMessage("Game has started! First team to " + _points.MaxPoints + " points wins!", _config.flag.resetBong); updateTickers(); return(true); }
public async Task StaticInit() { IStorageAccount account = new FakeStorageAccount(); var config = TestHelpers.NewConfig(account); // Can do the static init. Get the binders. var ctx = config.CreateStaticServices(); var provider = ctx.GetService <IBindingProvider>(); var attr = new BlobAttribute("container/path", FileAccess.Read); var result1 = await ScriptHelpers.CanBindAsync(provider, attr, typeof(TextReader)); var result2 = await ScriptHelpers.CanBindAsync(provider, attr, typeof(TextWriter)); Assert.True(result1); Assert.False(result2); // Can now set type locator and types, do indexing, and run. // Important that we're able to set this *after* we've queried the binding graph. config.TypeLocator = new FakeTypeLocator(typeof(ProgramSimple)); var expected = "123"; using (var jobHost = new JobHost(config)) { var method = typeof(ProgramSimple).GetMethod("Test"); jobHost.Call(method, new { value = expected }); Assert.Equal(expected, ProgramSimple._value); } }
public override async Task <bool> Execute() { // If we have the quest, drop it... if (HasQuest(QuestId)) { Me.QuestLog.AbandonQuestById((uint)QuestId); await Coroutine.Wait(Delay.LagDuration, () => !HasQuest(QuestId)); return(true); } // If we cannot 'see' the mob yet, move to the rough location... var questGiver = ObjectManager.GetObjectsOfType <WoWUnit>().FirstOrDefault(u => u.Entry == QuestGiverId); if (questGiver == null) { await UtilityCoroutine.MoveTo(QuestGiverRoughLocation, "Quest Giver"); return(true); } if (!Navigator.AtLocation(questGiver.Location)) { return(await UtilityCoroutine.MoveTo(questGiver.Location, questGiver.Name)); } await ScriptHelpers.PickupQuest(questGiver, (uint)QuestId); await Coroutine.Wait(Delay.LagDuration, () => HasQuest(QuestId)); return(false); }
public T GetFieldAnswer <T>(string fieldName) { var answer = GetFieldAnswerValue(fieldName); if (answer == null) { return(default(T)); } // Special handling for JArray caused by serialization of the data if (answer is JArray jarrayAnswer) { return((jarrayAnswer).ToObject <T>()); } if (answer is T) { return((T)answer); } try { return(ScriptHelpers.ConvertToType <T>(answer)); } catch (JsonReaderException) { } return((T)Convert.ChangeType(answer, typeof(T))); }
public object CallLambda(object function, dynamic options, dynamic values) { if (!(function is string functionText)) { throw new ApplicationException($"{nameof(CallLambda)}: {nameof(function)} must be a string"); } LambdaRequestOptions lambdaOptions = ProcessLambdaRequestOptions(options); string data = null; var native = ConvertToNative(values); if (native != null) { data = JsonConvert.SerializeObject(native); } var response = lambdaService.Invoke(functionText, data); if (lambdaOptions.KeepResponseAsString) { return(response); } var result = JsonConvert.DeserializeObject <dynamic>(response); return(ScriptHelpers.ToScriptValue(result, ScriptContext)); }
public bool gameStart() { //Reset Flags _arena.flagReset(); _arena.flagSpawn(); //We've started! _tickGameStart = Environment.TickCount; _tickGameStarting = 0; //Scramble the teams! ScriptHelpers.scrambleTeams(_arena, 2, true); //Spawn our flags! _arena.flagSpawn(); //Let everyone know _arena.sendArenaMessage("Game has started!", _config.flag.resetBong); _arena.setTicker(1, 1, _config.deathMatch.timer * 100, "Time Left: ", delegate() { //Trigger game end. //Skrall have won _arena.sendArenaMessage("Skrall have resumed supreme control of the station, the marines have become nothing more than bones and bits.", 21); try { _arena.gameEnd(); } catch (Exception e) { Log.write(TLog.Warning, "_arena.gameEnd() " + e); } } ); return(true); }
protected async Task OnWindowResizeAsync() { if (!In && Placement != Placement.Bottom && Placement != Placement.End) { await ScriptHelpers.SetTranslateValueAsync(Placement, RefBack.Current); } }
/// <summary> /// Truncates the database and runs the SQL file at the provided path against the current database /// </summary> /// <param name="FileName">The file name to run</param> /// <param name="SplitOn">The batch delimeter, defaults to "GO"</param> public static async Task Restore(string FileName, string ConnectionString, int CommandTimeout = 300, string SplitOn = ScriptHelpers.DEFAULT_SPLIT, Encoding encoding = null) { encoding = encoding ?? Encoding.Default; TruncateDatabase(ConnectionString); await ScriptHelpers.RunSplitScript(FileName, ConnectionString, CommandTimeout, SplitOn, encoding); }
protected override async Task OnAfterUpdateAsync() { await base.OnAfterUpdateAsync(); if (!In) { await ScriptHelpers.SetTranslateValueAsync(Placement, RefBack.Current); } }
public async Task <DcValues> GetDcEarningsData(short academicYear, byte collectionPeriod, List <long> ukprnList) { var sql = ScriptHelpers.GetSqlScriptText(DcEarnings); sql = sql.Replace(UkprnListToken, string.Join(",", ukprnList)); var results = new DcValues(); using (var connection = GetDataStoreConnectionString(academicYear)) { using (var cmd = connection.CreateCommand()) { cmd.CommandTimeout = configuration.SqlCommandTimeout.Seconds; cmd.CommandText = sql; cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@collectionPeriod", collectionPeriod); connection.Open(); using (var reader = await cmd.ExecuteReaderAsync()) { while (await reader.ReadAsync()) { var newValues = new DcContractTypeTotals(); Func <SqlDataReader, int, decimal> getValueAsNullableDecimal = (dataReader, i) => !dataReader.IsDBNull(i) ? (decimal)dataReader.GetValue(i) : (decimal)0; newValues.ContractType = (int)reader[0]; newValues.TT1 = getValueAsNullableDecimal(reader, 1); newValues.TT2 = getValueAsNullableDecimal(reader, 2); newValues.TT3 = getValueAsNullableDecimal(reader, 3); newValues.TT4 = getValueAsNullableDecimal(reader, 4); newValues.TT5 = getValueAsNullableDecimal(reader, 5); newValues.TT6 = getValueAsNullableDecimal(reader, 6); newValues.TT7 = getValueAsNullableDecimal(reader, 7); newValues.TT8 = getValueAsNullableDecimal(reader, 8); newValues.TT9 = getValueAsNullableDecimal(reader, 9); newValues.TT10 = getValueAsNullableDecimal(reader, 10); newValues.TT11 = getValueAsNullableDecimal(reader, 11); newValues.TT12 = getValueAsNullableDecimal(reader, 12); newValues.TT13 = getValueAsNullableDecimal(reader, 13); newValues.TT14 = getValueAsNullableDecimal(reader, 14); newValues.TT15 = getValueAsNullableDecimal(reader, 15); newValues.TT16 = getValueAsNullableDecimal(reader, 16); results.DcContractTypeTotals.Add(newValues); } } } } return(results); }
protected void Page_PreRender(object sender, EventArgs o) { using (MiniProfiler.Current.Step("LoadStyle")) { StyleHelpers.LoadStyle(this.Page); } using (MiniProfiler.Current.Step("LoadScript")) { ScriptHelpers.LoadScript(this.Page); } }
protected virtual void PageLoadComplete() { using (MiniProfiler.Current.Step("AddStyle and AddScript")) { StyleHelpers.AddStyle(this.Page, "Style"); ScriptHelpers.AddScript(this.Page, "Script"); } ExcutePrePageLoadCompleteJs(); ExcutePageLoadCompletedJs(); }
/// <summary>Turns in a quest at object </summary> /// <param name="wowObject"> The turnin object. </param> /// <param name="questId"> The quest Id. If 0 (default) then first completed quest is turned in. </param> /// <param name="searchLocation">The search location of <paramref name="wowObject" />.</param> /// <param name="movementBy">The movement type to use.</param> /// <param name="navigationFailedAction"> /// The action to take if <paramref name="wowObject" /> or <paramref name="searchLocation"/> cant be navigated to /// </param> /// <param name="notFoundAction"> /// The action to take if <paramref name="wowObject" /> is not found at /// <paramref name="searchLocation" />. /// </param> /// <returns><c>true</c> if an action was taken; <c>false</c> otherwise</returns> /// <exception cref="Exception">A delegate callback throws an exception.</exception> public static async Task <bool> TurninQuest( WoWObject wowObject, WoWPoint searchLocation, uint questId = 0, MovementByType movementBy = MovementByType.FlightorPreferred, Action navigationFailedAction = null, Action notFoundAction = null) { if (wowObject == null) { if (!Navigator.AtLocation(searchLocation)) { if (await MoveTo(searchLocation, "Quest turnin search area", movementBy)) { return(true); } if (navigationFailedAction != null) { navigationFailedAction(); } return(false); } if (notFoundAction != null) { notFoundAction(); } else { TreeRoot.StatusText = "Waiting for the WoW object selected for quest turnin to spawn"; } return(true); } if (!wowObject.WithinInteractRange) { if (await MoveTo(wowObject.Location, wowObject.SafeName, movementBy)) { return(true); } if (navigationFailedAction != null) { navigationFailedAction(); } return(false); } return(await ScriptHelpers.TurninQuest(wowObject, questId)); }
public Task <ErrorHandlerResult> ProcessErrorHandler(ChatModel chatModel, ChatFlowStep chatFlowStep) { if (!initialized) { throw new ApplicationException("ChatScriptManager is not initialized. Call Initialize()"); } string script = chatFlowStep.ErrorHandler; ChatVariables globalFields = chatModel.CurrentState.GlobalAnswers; ChatVariables flowFields = chatModel.CurrentState.GetFlowAnswers(chatFlowStep.Flow); if (AwsUtilityMethods.IsRunningOnAWS) { AWSXRayRecorder.Instance.BeginSubsegment("Script: Process Parser Error Handler"); } try { return(Task.FromResult( RunScript <ErrorHandlerResult>((engine, globalValues, flowValues) => { dynamic result = engine.Evaluate(script); if (result == null) { return null; } ConvertFieldsToNative(globalFields, globalValues, true); ConvertFieldsToNative(flowFields, flowValues, false); return ScriptHelpers.ConvertToType <ErrorHandlerResult>(result); }, globalFields, flowFields, null) )); } catch (Exception ex) { if (AwsUtilityMethods.IsRunningOnAWS) { AWSXRayRecorder.Instance.AddException(ex); } logger.ErrorFormat("Script: Process Parser Error Handler Error. '{0}'", ex.Message); throw; } finally { if (AwsUtilityMethods.IsRunningOnAWS) { AWSXRayRecorder.Instance.EndSubsegment(); } } }
private static Dictionary <string, object> TestConversion(string testJson, string code) { V8Runtime v8Runtime = new V8Runtime(); using (var context = v8Runtime.CreateScriptEngine()) { var result = JsonConvert.DeserializeObject <dynamic>(testJson); var jsValues = ScriptHelpers.ToScriptValue(result, context); context.AddHostObject("s", jsValues); Assert.IsTrue((bool)context.Evaluate(code)); return(ConvertJsToNative(jsValues)); } }
protected async Task HandleExitAsync(IReference refback) { var transition = CreateTransition("transform", GetExitDuration(), TransitionDelay, TransitionEasing.EasingSharp); var styles = new Dictionary <string, object> { { "transition", transition }, { "webkitTransition", transition } }; await DomHelpers.SetStyleAsync(refback.Current, styles, trigger : true); await ScriptHelpers.SetTranslateValueAsync(Placement, refback.Current); OnExit?.Invoke(refback); }
public async Task <PaymentsValues> GetPaymentsData(DateTime runStartDateTime, short academicYear, byte collectionPeriod, bool populateEarnings, IList <long> ukprnList) { var sql = ScriptHelpers.GetSqlScriptText(PaymentsQuerySql); sql = sql.Replace("@ukprnList", string.Join(",", ukprnList)); var paymentsMetrics = new PaymentsValues(); var results = new Dictionary <string, decimal?>(StringComparer.OrdinalIgnoreCase); using (var connection = GetPaymentsConnectionString()) { using (var cmd = connection.CreateCommand()) { cmd.CommandTimeout = configuration.SqlCommandTimeout.Seconds; cmd.CommandText = sql; cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@monthendStartTime", runStartDateTime); cmd.Parameters.AddWithValue("@startDate", runStartDateTime); cmd.Parameters.AddWithValue("@collectionPeriod", collectionPeriod); connection.Open(); using (var reader = await cmd.ExecuteReaderAsync()) { await reader.ReadAsync(); PopulatePaymentsResults(results, reader); await reader.NextResultAsync(); await reader.ReadAsync(); PopulatePaymentsResults(results, reader); await reader.NextResultAsync(); await reader.ReadAsync(); PopulatePaymentsResults(results, reader); } } } SetMetricsFromResults(results, paymentsMetrics); return(paymentsMetrics); }
public GeoJSONFeature(Link l, RiverSystemScenario scenario, bool useSchematicLocation) { id = LinkURL(l); properties.Add("name", l.Name); properties.Add(FeatureTypeProperty, "link"); properties.Add("from_node", NodeURL((Node)l.UpstreamNode, l.Network)); properties.Add("to_node", NodeURL((Node)l.DownstreamNode, l.Network)); properties.Add("length", l.Length); if (useSchematicLocation) { var schematic = ScriptHelpers.GetSchematic(scenario); if (scenario != null) { geometry = new GeoJSONGeometry(SchematicLocationForNode(l.from, schematic), SchematicLocationForNode(l.to, schematic)); return; } } geometry = new GeoJSONGeometry(l, useSchematicLocation); }
public GeoJSONFeature(Node n, RiverSystemScenario scenario, bool useSchematicLocation) { id = NodeURL(n, scenario.Network); properties.Add("name", n.Name); properties.Add(FeatureTypeProperty, "node"); Coordinate loc = n.location; var schematic = ScriptHelpers.GetSchematic(scenario); if (schematic != null) { PointF schematicLocation = SchematicLocationForNode(n, schematic); properties.Add("schematic_location", new double[] { schematicLocation.X, schematicLocation.Y }); if (useSchematicLocation) { loc = new Coordinate(schematicLocation); } } properties.Add(ResourceProperty, UriTemplates.Resources.Replace("{resourceName}", ResourceName(n))); geometry = new GeoJSONGeometry(loc); }
//private static void LoadScripts(string basePath, List<ClassDefinition> classDefs) private static void LoadScripts(List <Tuple <string, ClassDefinition> > filesAndDefs) { const string AssemblyNamePrefix = "ClassDef_"; LevelingPlugin.Instance.LogPrint("Compiling Class scripts...", TraceLevel.Info); //get script files paths var scriptedDefs = filesAndDefs.Where(d => !string.IsNullOrWhiteSpace(d.Item2.ScriptPath)); var booScripts = scriptedDefs.Select(d => Path.Combine(Path.GetDirectoryName(d.Item1), d.Item2.ScriptPath)) .ToList(); var newModuleManager = new BooModuleManager(LevelingPlugin.Instance, ScriptHelpers.GetReferences(), ScriptHelpers.GetDefaultImports(), GetEnsuredMethodSignatures()); newModuleManager.AssemblyNamePrefix = AssemblyNamePrefix; foreach (var f in booScripts) { newModuleManager.Add(f); } Dictionary <string, CompilerContext> results = null; if (ModuleManager != null) { results = newModuleManager.IncrementalCompile(ModuleManager); } else { results = newModuleManager.Compile(); } ModuleManager = newModuleManager; //link! foreach (var def in scriptedDefs) { //var fileName = Path.Combine(basePath, def.ScriptPath); var fileName = Path.Combine(Path.GetDirectoryName(def.Item1), def.Item2.ScriptPath); //if newly compile assembly, examine the context, and try to link to the new assembly if (results.TryGetValue(fileName, out var context)) { var scriptAssembly = context.GeneratedAssembly; if (scriptAssembly != null) { var result = def.Item2.LinkToScriptAssembly(scriptAssembly); //if(!result) // // CustomNpcsPlugin.Instance.LogPrint($"Failed to link {kvp.Key}.", TraceLevel.Info); } } else { var scriptAssembly = ModuleManager[fileName]; if (scriptAssembly != null) { var result = def.Item2.LinkToScriptAssembly(scriptAssembly); //if(!result) // // CustomNpcsPlugin.Instance.LogPrint($"Failed to link {kvp.Key}.", TraceLevel.Info); } } } }
public object MakeWebRequestEx(object apiUrl, object apiMethod, dynamic options, dynamic values) { if (!(apiUrl is string apiUrlText)) { throw new ApplicationException($"{nameof(MakeWebRequestEx)}: {nameof(apiUrl)} must be a string"); } if (!(apiMethod is string apiMethodText)) { throw new ApplicationException($"{nameof(MakeWebRequestEx)}: {nameof(apiMethod)} must be a string"); } int tries = 0; int dnsAttempts = 1; WebRequestOptions webRequestOptions = ProcessWebRequestOptions(options); do { logger.InfoFormat("Script: Calling web url: {0}", apiUrlText); Uri uri = new Uri(apiUrlText); // Makes sure the url is valid try { // Using older WebClient class since it has non-async methods. // We can't use Async calls here because we aren't passing the async/await context through javscript. // That requires using the javascript callback method and makes the javascript more complex. using (WebClientEx wc = new WebClientEx(webRequestOptions.Timeout)) { // fix for possible performance issue with WebClient class // https://stackoverflow.com/questions/4932541/c-sharp-webclient-acting-slow-the-first-time wc.Proxy = null; Stopwatch sw = new Stopwatch(); sw.Start(); if (DummyMode) { wc.Headers.Add("X-DummyMode", "True"); } // Add headers if (webRequestOptions.Headers != null) { foreach (var header in webRequestOptions.Headers) { wc.Headers.Add(header.Key, header.Value?.ToString()); } } string response; if (apiMethodText.Equals("GET", StringComparison.OrdinalIgnoreCase)) { response = wc.DownloadString(uri); } else { string data = null; if (webRequestOptions.KeepRequestAsString) { data = values; } else { var native = ConvertToNative(values); if (native != null) { data = JsonConvert.SerializeObject(native); } } logger.DebugFormat("Script: Request: {0}", data); response = wc.UploadString(uri, apiMethodText, data); } logger.DebugFormat("Script: Response: {0}", response); sw.Stop(); var elapsedTime = sw.Elapsed.TotalSeconds; if ((ChatConfiguration.DefaultRestAPIWarnSendTime >= 0) && (elapsedTime > ChatConfiguration.DefaultRestAPIWarnSendTime)) { logger.WarnFormat("Network: MakeWebRequestEx() took {0} seconds. Url: {1}", elapsedTime, uri); } if (webRequestOptions.KeepResponseAsString) { return(response); } var result = JsonConvert.DeserializeObject <dynamic>(response); return(ScriptHelpers.ToScriptValue(result, ScriptContext)); } } catch (WebException ex) { if (ex.Status == WebExceptionStatus.NameResolutionFailure) { // WebClient gets DNS failures sometimes, so we auto retry. if (++dnsAttempts <= MaxDnsAttempts) { logger.WarnFormat("Script: Warning DNS failure. Retrying: {0}", apiUrl); // dont count as regulare try tries--; continue; } logger.ErrorFormat("Script: Error calling url {0}. {1}, {2}", apiUrl, ex.Status, ex.ToString()); return(null); } logger.ErrorFormat("Script: Error calling url {0}. {1}, {2}", apiUrl, ex.Status, ex.ToString()); if (ex.Status == WebExceptionStatus.ProtocolError) { var webResponse = (HttpWebResponse)ex.Response; var errorBody = new StreamReader(webResponse.GetResponseStream()).ReadToEnd(); logger.DebugFormat("Script: Error Response: {0}", errorBody); if (((int)webResponse.StatusCode >= 400) && ((int)webResponse.StatusCode <= 499)) { // log 400 error. not re-try-able); break; } } } } while (tries++ < webRequestOptions.Retries); return(null); }
/// <summary> /// Handles opening treasure coffers or opening an exit portal /// </summary> /// <returns></returns> internal async Task <bool> TreasureOrExit() { var tries = 0; var npcid = Target.Unit.NpcId; if (Target.Location.Distance2D(Core.Me.Location) >= 3) { await CommonTasks.MoveAndStop(new MoveToParameters(Target.Location, Target.Name), 2.5f, true); return(true); } while (!DeepDungeon2.StopPlz && tries < 3 && Target.Unit.IsValid) { //if we are a frog / lust we can't open a chest if (Core.Me.HasAura(Auras.Toad) || Core.Me.HasAura(Auras.Frog) || Core.Me.HasAura(Auras.Toad2) || Core.Me.HasAura(Auras.Lust)) { Logger.Warn("Unable to open chest. Waiting for aura to end..."); await CommonTasks.StopMoving("Waiting on aura to end"); await Coroutine.Wait(TimeSpan.FromSeconds(30), () => !(Core.Me.HasAura(Auras.Toad) || Core.Me.HasAura(Auras.Frog) || Core.Me.HasAura(Auras.Toad2) || Core.Me.HasAura(Auras.Lust)) || Core.Me.InCombat || DeepDungeon2.StopPlz); return(true); } await Coroutine.Yield(); if (Core.Me.HasAura(Auras.Lust)) { await Tasks.Coroutines.Common.CancelAura(Auras.Lust); } Logger.Verbose("Attempting to interact with: {0} ({1} / 3)", Target.Name, tries + 1); if (!PartyManager.IsInParty || PartyManager.IsPartyLeader || PartyManager.IsInParty && Constants.IsExitObject(Target.Unit)) { await CommonTasks.StopMoving("Interacting with chest"); if (!await ScriptHelpers.ObjectInteraction(Target.Unit)) { break; } //Target.Unit.Interact(); } else { await CommonTasks.StopMoving("Waiting for leader to use chest"); } await Coroutine.Sleep(700); tries++; if (!Target.Unit.IsValid) { break; } if (!Target.Unit.IsTargetable) { break; } if (SelectYesno.IsOpen) { break; } } await Coroutine.Wait(700, () => SelectYesno.IsOpen); //if this is an exit if (SelectYesno.IsOpen) { SelectYesno.ClickYes(); await Coroutine.Wait(TimeSpan.MaxValue, () => DeepDungeon2.StopPlz || QuestLogManager.InCutscene || NowLoading.IsVisible); return(true); } Blacklist.Add(Target.Unit.ObjectId, TimeSpan.FromMinutes(1), $"Tried to Interact with the Target {tries+1} times"); Poi.Clear($"Tried to Interact with the Target {tries+1} times"); return(false); }
protected async Task HandleEnterAsync(IReference refback, bool appear) { await ScriptHelpers.SetTranslateValueAsync(Placement, refback.Current); OnEnter?.Invoke(refback, appear); }
public bool playerBreakdown(Player from, bool bCurrent) { //Allows additional "custom" breakdown information //List the best healers by sorting them according to healingdone from.sendMessage(0, "#Healer Breakdown"); if (_healingDone != null && _healingDone.Count > 0) { List <KeyValuePair <Player, int> > healers = _healingDone.ToList(); healers.Sort((a, b) => { return(a.Value.CompareTo(b.Value)); }); healers.Reverse(); int i = 1; foreach (KeyValuePair <Player, int> healer in healers) { //Display top 3 healers in arena from.sendMessage(0, String.Format("!{0} (Healed={1}): {2}", ScriptHelpers.toOrdinal(i), healer.Value, healer.Key._alias)); if (i++ > 3) { break; } } } //List teams by most points from.sendMessage(0, "#Team Breakdown"); if (_points != null) { List <Team> teams = _arena.Teams.Where(t => _points[t] != 0).ToList(); teams.OrderByDescending(t => _points[t]); int j = 1; foreach (Team t in teams) { from.sendMessage(0, String.Format("!{0} (Points={1} Kills={2} Deaths={3}): {4}", ScriptHelpers.toOrdinal(j), _points[t], t._currentGameKills, t._currentGameDeaths, t._name)); j++; } } from.sendMessage(0, "#Player Breakdown"); int k = 1; foreach (Player p in _arena.PlayersIngame.OrderByDescending(player => (bCurrent ? player.StatsCurrentGame.kills : player.StatsLastGame.kills))) { //Display top 3 players from.sendMessage(0, String.Format("!{0} (K={1} D={2}): {3}", ScriptHelpers.toOrdinal(k), (bCurrent ? p.StatsCurrentGame.kills : p.StatsLastGame.kills), (bCurrent ? p.StatsCurrentGame.deaths : p.StatsLastGame.deaths), p._alias)); if (k++ > 3) { break; } } //Display his score from.sendMessage(0, String.Format("@Personal Score: (K={0} D={1})", (bCurrent ? from.StatsCurrentGame.kills : from.StatsLastGame.kills), (bCurrent ? from.StatsCurrentGame.deaths : from.StatsLastGame.deaths))); //return true to avoid another breakdown from showing return(true); }
/// <summary> /// Runs the SQL file at the provided path against the current database /// </summary> /// <param name="FileName">The file name to run</param> /// <param name="SplitOn">The batch delimeter, defaults to "GO"</param> /// <param name="encoding">The encoding to read the file with</param> /// <param name="detectEncodingFromByteOrderMarks">Try to automatically detect the file encoding</param> /// <param name="bufferSize">The buffer size for the stream reader</param> public async Task ExecuteScript(string FileName, string SplitOn = ScriptHelpers.DEFAULT_SPLIT, Encoding encoding = null, bool detectEncodingFromByteOrderMarks = true, int bufferSize = -1) { encoding = encoding ?? Encoding.Default; await ScriptHelpers.RunSplitScript(FileName, this.ConnectionString, this.CommandTimeout, SplitOn, encoding, detectEncodingFromByteOrderMarks, bufferSize); }