public async Task AddOrUpdateExport(BeatmapExport export) { if (export.BeatmapId == null || export.BeatmapId.Length == 0) { Console.WriteLine("No beatmap found."); return; } var beatmap = await Beatmaps.FindAsync(export.BeatmapId); if (beatmap == null) { Console.WriteLine("No beatmap found."); return; } var exist = await Exports.FindAsync(export.Id); if (exist != null) { exist.UpdateTime = DateTime.Now; exist.ExportPath = export.ExportPath; exist.IsValid = true; } else { export.Beatmap = beatmap; Exports.Add(export); } await SaveChangesAsync(); }
public Main() { Debug.WriteLine(typeof(MySql.Data.MySqlClient.MySqlConnection).Name); // to work around mysql-async ready event not triggering on starts Exports.Add("hasTicked", new Func <bool>(() => m_ticked)); }
public Weather() { // Add the exports Exports.Add("getWeatherSyncMode", new Func <int>(() => API.GetConvarInt("simplesync_modeweather", 0))); Exports.Add("setWeatherSyncMode", new Func <int, bool>((i) => SetSyncMode(i, "simplesync_modeweather"))); Exports.Add("getWeather", new Func <string>(() => currentWeather)); Exports.Add("setWeather", new Func <string, bool>(SetWeather)); Exports.Add("getTransitionWeather", new Func <string>(() => transitionWeather)); Exports.Add("getNextWeatherFetch", new Func <long>(() => nextFetch)); Exports.Add("getWeatherTransitionFinish", new Func <long>(() => transitionFinish)); // Get the Weather Switches as a string string data = API.LoadResourceFile(API.GetCurrentResourceName(), "Switch.json"); // And try to parse it try { switches = JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(data); } // If we failed, notify it catch (JsonException e) { Debug.WriteLine($"Error when parsing Switch.json: {e.Message}"); } // And log some important commands Logging.Log("Weather Synchronization has started"); Logging.Log($"Sync Mode is set to {Convars.WeatherMode}"); Logging.Log(string.IsNullOrWhiteSpace(Convars.OpenWeatherKey) ? "No OpenWeather API Key is set" : "An OpenWeather API Key is present"); Logging.Log(string.IsNullOrWhiteSpace(Convars.OpenWeatherCity) ? "No OpenWeather City is set" : $"OpenWeather City is set to {Convars.OpenWeatherCity}"); }
public Data() { EventHandlers.Add("Sync:Client:Data:Get", new Action <object>(GetServer)); EventHandlers.Add("Sync:Client:Data:GetAll", new Action <dynamic>(GetAllServer)); EventHandlers.Add("Sync:Client:Data:Has", new Action <bool>(HasServer)); Exports.Add("client_sync_data_enable_debug", new Action <bool, CallbackDelegate>((enableDebug, callback) => { Debug = enableDebug; })); Exports.Add("client_sync_data_set", new Action <int, string, object>(Set)); Exports.Add("client_sync_data_reset", new Action <int, string>(Reset)); Exports.Add("client_sync_data_get", new Func <int, string, Task <object> >(async(id, key) => await Get(id, key))); Exports.Add("client_sync_data_getall", new Func <int, Task <object> >(async id => await GetAll(id))); Exports.Add("client_sync_data_has", new Func <int, string, Task <bool> >(async(id, key) => await Has(id, key))); Exports.Add("client_sync_data_set_locally", new Action <int, string, object>(SetLocally)); Exports.Add("client_sync_data_reset_locally", new Action <int, string>(ResetLocally)); Exports.Add("client_sync_data_get_locally", new Func <int, string, object>(GetLocally)); Exports.Add("client_sync_data_getall_locally", new Func <int, object>(GetAllKeyLocally)); Exports.Add("client_sync_data_has_locally", new Func <int, string, bool>(HasLocally)); TriggerEvent("OnClientSyncDataLoaded", CitizenFX.Core.Native.API.GetCurrentResourceName()); }
public ServerBase() { Exports.Add("QueryResult", new Func <string, dynamic, Task <List <dynamic> > >( (query, parameters) => QueryResult(query, parameters)) ); Exports.Add("QueryAsync", new Action <string, dynamic, CallbackDelegate>( (query, parameters, cb) => QueryAsync(query, parameters, cb)) ); _saveMinutes = 15; _flushHours = 3; _logger = new ServerLogger("GGSQL", LogLevel.Info); EventHandlers["onServerResourceStart"] += new Action <string>(BaseOnServerResourceStart); EventHandlers["playerReady"] += new Action <Player>(OnPlayerReady); EventHandlers["gg_internal:updateXpMoney"] += new Action <int, int, int>(OnUpdateXpAndMoney); EventHandlers["gg_internal:syncUsers"] += new Action <string>(OnUsersSync); EventHandlers["gg_internal:syncUser"] += new Action <string, string>(OnUserSync); EventHandlers["gg_internal:syncWinner"] += new Action <string>(OnWinnerSync); // Tick += SaveTick; // Tick += FlushTick; Tick += InitializeController; }
public Core() { taskScheduler = new GHMattiTaskScheduler(); initialized = false; EventHandlers["onServerResourceStart"] += new Action <string>(Initialization); Exports.Add("Query", new Func <string, dynamic, Task <int> >( (query, parameters) => Query(query, parameters)) ); Exports.Add("QueryResult", new Func <string, dynamic, Task <MySQLResult> >( (query, parameters) => QueryResult(query, parameters)) ); Exports.Add("QueryScalar", new Func <string, dynamic, Task <dynamic> >( (query, parameters) => QueryScalar(query, parameters)) ); Exports.Add("QueryAsync", new Action <string, dynamic, CallbackDelegate>( (query, parameters, cb) => QueryAsync(query, parameters, cb)) ); Exports.Add("QueryResultAsync", new Action <string, dynamic, CallbackDelegate>( (query, parameters, cb) => QueryResultAsync(query, parameters, cb)) ); Exports.Add("QueryScalarAsync", new Action <string, dynamic, CallbackDelegate>( (query, parameters, cb) => QueryScalarAsync(query, parameters, cb)) ); Exports.Add("Insert", new Action <string, dynamic>( (table, parameters) => Insert(table, parameters)) ); }
public Passive() { // Add the exports Exports.Add("getActivation", new Func <bool>(() => GetPlayerActivation(Game.Player.ServerId))); Exports.Add("setActivation", new Action <bool>(SetPassiveActivation)); // And tell the server that this client is ready to work TriggerServerEvent("simplepassive:initialized"); }
/// <summary> /// Register the exports /// </summary> private void RegisterExports() { Exports.Add("show", new Action(ShowInteraction)); Exports.Add("hide", new Action(HideInteraction)); Exports.Add("highlight", new Action <bool>(Highlight)); Exports.Add("option", new Action <int, string>(SetOption)); Exports.Add("reset", new Action(Reset)); }
public Passive() { Exports.Add("getActivation", new Func <int, bool>(GetPlayerActivation)); Exports.Add("setActivation", new Func <int, bool, bool>(SetPlayerActivation)); Exports.Add("isOverriden", new Func <int, bool>((id) => overrides.ContainsKey(id))); Exports.Add("setOverride", new Func <int, bool, bool>(SetPlayerOverride)); Exports.Add("clearOverride", new Func <int, bool>(ClearOverride)); }
public KoiStream(string name, IReadableSegment contents, ILogger logger) : base(name, contents) { var reader = contents.CreateReader(); logger.Debug(Tag, "Reading koi stream header..."); uint magic = reader.ReadUInt32(); if (magic != Signature) { logger.Warning(Tag, $"Koi stream data does not start with a valid signature (Expected 0x{Signature:X4} but read 0x{magic:X4})."); } uint mdCount = reader.ReadUInt32(); uint strCount = reader.ReadUInt32(); uint expCount = reader.ReadUInt32(); logger.Debug(Tag, $"Reading {mdCount} references..."); for (int i = 0; i < mdCount; i++) { uint id = Utils.ReadCompressedUInt(ref reader); uint token = Utils.FromCodedToken(Utils.ReadCompressedUInt(ref reader)); References.Add(id, new MetadataToken(token)); } logger.Debug(Tag, $"Reading {strCount} strings..."); for (int i = 0; i < strCount; i++) { uint id = Utils.ReadCompressedUInt(ref reader); int length = (int)Utils.ReadCompressedUInt(ref reader); byte[] buffer = new byte[length * 2]; reader.ReadBytes(buffer, 0, buffer.Length); Strings.Add(id, Encoding.Unicode.GetString(buffer)); } logger.Debug(Tag, $"Reading {expCount} exports..."); for (int i = 0; i < expCount; i++) { uint id = Utils.ReadCompressedUInt(ref reader); var exportInfo = VMExportInfo.FromReader(ref reader); // Exports in KoiVM either point to entrypoints of virtualised methods, or just act as a descriptor // for methods that are intra linked through instructions like ldftn. if (exportInfo.IsSignatureOnly) { logger.Debug(Tag, $"Export {id} maps to a method signature of an intra-linked method."); } else { logger.Debug(Tag, $"Export {id} maps to function_{exportInfo.EntrypointAddress:X4}."); } Exports.Add(id, exportInfo); } }
/// <summary> /// Add a single repository to the set that is exported by this daemon. /// <para /> /// The existence (or lack-thereof) of <code>git-daemon-export-ok</code> is /// ignored by this method. The repository is always published. /// </summary> /// <param name="name"> /// name the repository will be published under. /// </param> /// <param name="db">the repository instance. </param> public void ExportRepository(string name, Repository db) { if (!name.EndsWith(Constants.DOT_GIT_EXT)) { name = name + Constants.DOT_GIT_EXT; } Exports.Add(name, db); RepositoryCache.register(db); }
public void AddExport(string sheetName, dynamic export, dynamic data) { Exports.Add(new ExportItem() { Export = export, Data = data, SheetName = sheetName }); }
public BaseServer() { Tick += FirstTick; Self = this; Exports.Add("registerPluginOutlet", new Action <string, CallbackDelegate>(this.RegisterPluginOutlet)); Exports.Add("registerPluginPage", new Action <string, CallbackDelegate>(this.RegisterPluginPage)); Exports.Add("isInRole", new Func <string, bool>(this.IsInRole)); Exports.Add("getPluginUrl", new Func <string, IDictionary <string, object>, string>(this.GetPluginUrl)); }
public VSql() { Exports.Add("execute_async", new Action <string, IDictionary <string, object>, CallbackDelegate>(async(query, parameters, callback) => { Init(); var numberOfUpdatedRows = await ExecuteAsync(query, parameters); if (callback != null) { await Delay(0); callback.Invoke(numberOfUpdatedRows); } })); Exports.Add("transaction_async", new Action <IList <object>, IDictionary <string, object>, CallbackDelegate>(async(queries, parameters, callback) => { Init(); var isSucceed = await TransactionAsync(queries.Select(query => query.ToString()).ToList(), parameters); if (callback != null) { await Delay(0); callback.Invoke(isSucceed); } })); Exports.Add("fetch_scalar_async", new Action <string, IDictionary <string, object>, CallbackDelegate>(async(query, parameters, callback) => { Init(); var result = await FetchScalarAsync(query, parameters); if (callback != null) { await Delay(0); callback.Invoke(result); } })); Exports.Add("fetch_all_async", new Action <string, IDictionary <string, object>, CallbackDelegate>(async(query, parameters, callback) => { Init(); var result = await FetchAllAsync(query, parameters); if (callback != null) { await Delay(0); callback.Invoke(result); } })); }
public DuiHandler() { Exports.Add("createDui", new Func <string, string, Task <DuiContainer> >(AddDui)); Exports.Add("CreateRandomUniqueDuiContainer", new Func <string, Task <DuiContainer> >(CreateRandomUniqueDuiContainer)); Exports.Add("destroyAllDui", new Func <Task>(DestroyAllDui)); var renderTargetsJson = API.LoadResourceFile("addon", "renderTargets.json"); RenderTargets = JsonConvert.DeserializeObject <Dictionary <String, List <String> > >(renderTargetsJson); this.Tick += DuiHandler_Tick; }
private void SetupExports() { Exports.Add("SpawnCar", new Func <string, Task <Vehicle> >((veh) => { return(SpawnCar(veh)); })); Exports.Add("SpawnCarWithCoords", new Func <string, dynamic, Task <Vehicle> >((veh, coord) => { return(SpawnCar(veh, coord)); })); }
public void RegisterExport(string _exportName, Delegate _action) { try { Exports.Add(_exportName, _action); } catch (Exception _ex) { Utils.Throw(_ex); } }
public void RegisterExport(string _exportName, Delegate _action) { try { Exports.Add(_exportName, _action); } catch (Exception _ex) { Utils.Throw(_ex, "Something went wrong when registering exports!!"); } }
public MySQL() { Console.WriteLine("[cRP/C#] Load MySQL app."); task_id = 0; Exports.Add("createConnection", new Action <string, string>(e_createConnection)); Exports.Add("createCommand", new Action <string, string>(e_createCommand)); Exports.Add("query", new Action <string, IDictionary <string, object>, int>(e_query)); EventHandlers["cRP:MySQL_query"] += new Action <string, IDictionary <string, object>, int>(e_query); EventHandlers["cRP:MySQL_tick"] += new Action(e_tick); //Exports.Add("checkTask", new Func<int,object>(e_checkTask)); }
public main() { //===================================// // SoundSystem // //===================================// Exports.Add("Play", new Action <string, float>((name, volume) => { PlayerSound.Play(name, volume); })); Exports.Add("PlayPos", new Action <string, float, Vector3>((name, volume, pos) => { PlayerSound.Play(name, volume, pos); })); Exports.Add("PlayUrl", new Action <string, string, float>((name, url, volume) => { PlayerSound.PLayUrl(name, url, volume); })); Exports.Add("PlayUrlPos", new Action <string, string, float, Vector3>((name, url, volume, pos) => { PlayerSound.PLayUrl(name, url, volume, pos); })); Exports.Add("Pause", new Action <string>((name) => { PlayerSound.Pause(name); })); Exports.Add("Stop", new Action <string>((name) => { PlayerSound.Stop(name); })); Exports.Add("Resume", new Action <string>((name) => { PlayerSound.Resume(name); })); Exports.Add("Distance", new Action <string, int>((name, disc) => { PlayerSound.Distance(name, disc); })); Exports.Add("Position", new Action <string, Vector3>((name, pos) => { PlayerSound.Position(name, pos); })); //===================================// // MoneySystem // //===================================// Exports.Add("getDirtyMoney", new Func <int>(PlayerMoney.getDirtyMoney)); Exports.Add("getBankMoney", new Func <int>(PlayerMoney.getBankMoney)); Exports.Add("getMoney", new Func <int>(PlayerMoney.getMoney)); //===================================// // JobSystem // //===================================// Exports.Add("getJob", new Func <string>(PlayerJob.getJobName)); Exports.Add("getGrade", new Func <string>(PlayerJob.getJobGrade)); }
/// <summary> /// Constructor /// </summary> public GtaOScoreboardClient() { addColumn ADDCOLUMN = new addColumn(AddColumn); editColumn EDITCOLUMN = new editColumn(EditColumn); editCell EDITCELL = new editCell(EditCell); GetConfig(); Initialize(); Tick += OnTick; Exports.Add("AddColumn", ADDCOLUMN); Exports.Add("EditCell", EDITCELL); Exports.Add("EditColumn", EDITCOLUMN); }
/// <summary> /// Add a type to the interface T, /// the type has to implement the interface T /// </summary> /// <param name="type"></param> public static void Add(Type type) { if (!CanAddItem(type)) { return; } if (ExportAttribute.InstanceRule == InstanceRule.Singleton) { AddOrUpdateSingleton(type); return; } Exports.Add(type); }
public MySqlAsync() { Exports.Add("mysql_configure", new Action(() => { Configure(Function.Call <string>(Hash.GET_CONVAR, "mysql_connection_string")); })); Exports.Add("mysql_execute", new Action <string, IDictionary <string, object>, CallbackDelegate>((query, parameters, callback) => { ExecuteNonQuery(query, parameters, callback); })); Exports.Add("mysql_sync_execute", new Func <string, IDictionary <string, object>, int>((query, parameters) => { return(ExecuteNonQuery(query, parameters)); })); Exports.Add("mysql_fetch_all", new Action <string, IDictionary <string, object>, CallbackDelegate>((query, parameters, callback) => { ExecuteReader(query, parameters, callback); })); Exports.Add("mysql_sync_fetch_all", new Func <string, IDictionary <string, object>, List <Dictionary <string, Object> > >((query, parameters) => { return(ExecuteReader(query, parameters)); })); Exports.Add("mysql_fetch_scalar", new Action <string, IDictionary <string, object>, CallbackDelegate>((query, parameters, callback) => { ExecuteScalar(query, parameters, callback); })); Exports.Add("mysql_sync_fetch_scalar", new Func <string, IDictionary <string, object>, Object>((query, parameters) => { return(ExecuteScalar(query, parameters)); })); EventHandlers["onMySqlQueryExecute"] += new Action <int, bool>((key, error) => { CallbackRegistry[key].Call <int, int>(error, (result) => { return(result); }); }); EventHandlers["onMySqlQueryFetchAll"] += new Action <int, bool>((key, error) => { CallbackRegistry[key].Call <DbDataReader, List <Dictionary <string, Object> > >(error, (reader) => { return(ReaderToDictionary(reader)); }); }); EventHandlers["onMySqlQueryFetchScalar"] += new Action <int, bool>((key, error) => { CallbackRegistry[key].Call <Object, Object>(error, (result) => { return(result); }); }); }
public Main() { ML = Exports["mysql-async"]; //===================================// // MoneySystem // //===================================// Exports.Add("playerMoneyHolder", new Func <int, dynamic> (PlayerMoneyHolder.getPlayerMoney)); //===================================// // JobSystem // //===================================// Exports.Add("playerJobHolder", new Func <int, dynamic> (PlayerJobHolder.getPlayerJob)); //===================================// // GroupSystem // //===================================// Exports.Add("playerGroupHolder", new Func <int, dynamic>(PlayerGroupHolder.getPlayerGroup)); }
public Main() { Exports.Add("Show", new Action <bool, int, CallbackDelegate>((can_walk, maxlenght, cb) => { try { if (!IsVisible) { if (cb != null) { int req = GetRequestId(); IsVisible = true; CanWalk = can_walk; SendNuiMessage("{ \"show\": true }"); SendNuiMessage("{ \"request\": " + req.ToString() + " }"); SendNuiMessage("{ \"maxlength\": " + maxlenght.ToString() + " }"); PendingRequests.Add(req, cb); if (!IsMainTaskWorking) { SetNuiFocus(true, true); SetNuiFocusKeepInput(true); IsMainTaskWorking = true; Tick += OnTick; } } else { Log.Error("Callback is null"); } } } catch (Exception ex) { Log.Error(ex); } })); Exports.Add("IsVisible", new Func <bool>(() => { return(IsVisible); })); Exports.Add("Hide", new Action(() => Hide())); RegisterNUICallback("allowmove", NUI_allowmove); RegisterNUICallback("response", NUI_response); }
/// <summary> /// Constructor with dependency injection /// </summary> /// <param name="script">The script which owns this menu</param> internal VStancerMenu(VStancerEditor script) { vstancerEditor = script; vstancerEditor.PresetChanged += new EventHandler((sender, args) => UpdateEditorMenu()); vstancerEditor.ToggleMenuVisibility += new EventHandler((sender, args) => { if (editorMenu == null) { return; } editorMenu.Visible = !editorMenu.Visible; }); InitializeMenu(); Exports.Add("LoadVStancerPreset", new Func <Task>(LoadPreset)); Tick += OnTick; }
public Time() { // Add a couple of exports to set the time Exports.Add("getTimeSyncMode", new Func <int>(() => API.GetConvarInt("simplesync_modetime", 0))); Exports.Add("setTimeSyncMode", new Func <int, bool>((i) => SetSyncMode(i, "simplesync_modetime"))); Exports.Add("setTime", new Action <int, int>(SetTime)); Exports.Add("getHours", new Func <int>(() => hours)); Exports.Add("getMinutes", new Func <int>(() => minutes)); Exports.Add("setTimeZone", new Func <string, bool>(SetTimeZone)); Exports.Add("getTimeZone", new Func <string>(() => Convars.TimeZone)); Exports.Add("getNextTimeFetch", new Func <long>(() => nextFetch)); // And log a couple of messages Logging.Log("Time Synchronization has started"); Logging.Log($"Sync Mode is set to {Convars.TimeMode}"); Logging.Log($"Scale is set to {Convars.Scale}"); Logging.Log($"Time Zone is set to {Convars.TimeZone}"); }
private void ReadExports() { UInt32 exportsLength = CollectionLinkPosition - ExportsPosition; ExportsCount = exportsLength / EXPORT_SIZE; int seek = (int)ExportsPosition; for (int i = 0; i < ExportsCount; i++) { Export export = new Export(); seek += 4; export.Name = EncodingUtil.encoding.GetString(ByteUtil.ReadBytes(OriginalFile, 32, ref seek)); export.OldAddress = ByteUtil.ReadUInt32(OriginalFile, ref seek); Exports.Add(export); } }
public Data() { EventHandlers.Add("Sync:Server:Data:Set", new Action <int, string, object>(Set)); EventHandlers.Add("Sync:Server:Data:Reset", new Action <int, string>(Reset)); EventHandlers.Add("Sync:Server:Data:Get", new Action <Player, int, string>(GetClient)); EventHandlers.Add("Sync:Server:Data:Has", new Action <Player, int, string>(HasClient)); Exports.Add("server_sync_data_set", new Action <int, string, object>(Set)); Exports.Add("server_sync_data_reset", new Action <int, string>(Reset)); Exports.Add("server_sync_data_enable_debug", new Action <bool>(enableDebug => { Debug = enableDebug; })); Exports.Add("server_sync_data_get", new Func <int, string, object>(Get)); Exports.Add("server_sync_data_has", new Func <int, string, bool>(Has)); TriggerEvent("OnServerSyncDataLoaded", CitizenFX.Core.Native.API.GetCurrentResourceName()); }
public MySQLAsync() { Exports.Add("mysql_configure", new Action(() => { Configure( Function.Call <string>(Hash.GET_CONVAR, "mysql_connection_string"), Function.Call <string>(Hash.GET_CONVAR, "mysql_debug") == "true" ); })); Exports.Add("mysql_execute", new Action <string, IDictionary <string, object>, CallbackDelegate>(async(query, parameters, callback) => { await(new Execute(ConnectionString)).ExecuteAsync(query, parameters, callback, debug); })); Exports.Add("mysql_sync_execute", new Func <string, IDictionary <string, object>, int>((query, parameters) => { return((new Execute(ConnectionString)).Execute(query, parameters, null, debug)); })); Exports.Add("mysql_fetch_all", new Action <string, IDictionary <string, object>, CallbackDelegate>(async(query, parameters, callback) => { await(new FetchAll(ConnectionString)).ExecuteAsync(query, parameters, callback, debug); })); Exports.Add("mysql_sync_fetch_all", new Func <string, IDictionary <string, object>, List <Dictionary <string, Object> > >((query, parameters) => { return((new FetchAll(ConnectionString)).Execute(query, parameters, null, debug)); })); Exports.Add("mysql_fetch_scalar", new Action <string, IDictionary <string, object>, CallbackDelegate>(async(query, parameters, callback) => { await(new FetchScalar(ConnectionString)).ExecuteAsync(query, parameters, callback, debug); })); Exports.Add("mysql_sync_fetch_scalar", new Func <string, IDictionary <string, object>, Object>((query, parameters) => { return((new FetchScalar(ConnectionString)).Execute(query, parameters, null, debug)); })); Exports.Add("mysql_insert", new Action <string, IDictionary <string, object>, CallbackDelegate>(async(query, parameters, callback) => { await(new Insert(ConnectionString)).ExecuteAsync(query, parameters, callback, debug); })); Exports.Add("mysql_sync_insert", new Func <string, IDictionary <string, object>, Object>((query, parameters) => { return((new Insert(ConnectionString)).Execute(query, parameters, null, debug)); })); }