示例#1
0
        public static byte[] UDBGet(int user, string key)
        {
            DatabaseArgs args = new DatabaseArgs(DatabaseActionType.Get, key, null, user);

            Hooks.Database.Invoke(args);
            return(args.Data);
        }
示例#2
0
        public static byte[] DBGet(string key)
        {
            DatabaseArgs args = new DatabaseArgs(DatabaseActionType.Get, key);

            Hooks.Database.Invoke(args);
            return(args.Data);
        }
 public static bool MyDatabaseCallback(DatabaseArgs args)
 {
     if (args.state == DatabaseState.Working)
     {
         string message = (args.elapsedMilliseconds / 1000) + " seconds";
         MyLogger.ShowWaiting(message);
     }
     else if (args.state == DatabaseState.Finished)
     {
         MyLogger.ShowFinished();
     }
     return(true);
 }
示例#4
0
        private static void OnDatabase(DatabaseArgs args)
        {
            switch (args.Type)
            {
            case DatabaseActionType.Get:
                //args.Value = JsonConvert.DeserializeObject(Database.GetData(args.Key), args.DataType);
                if (args.User.HasValue)
                {
                    args.Data = Database.GetData(args.User.Value, args.Key);
                }
                else
                {
                    args.Data = Database.GetData(args.Key);
                }
                break;

            case DatabaseActionType.Set:
                //Database.SetData(args.Key, JsonConvert.SerializeObject(args.Value));
                if (args.User.HasValue)
                {
                    Database.SetData(args.User.Value, args.Key, args.Data);
                }
                else
                {
                    Database.SetData(args.Key, args.Data);
                }
                break;

            case DatabaseActionType.Remove:
                if (args.User.HasValue)
                {
                    Database.RemoveKey(args.User.Value, args.Key);
                }
                else
                {
                    Database.RemoveKey(args.Key);
                }
                break;
            }
        }
 /// <summary>
 /// Creates a new instance of <see="SqlDatabaseBuilder" />
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public SqlDatabaseBuilder(string name, DatabaseArgs arguments, ResourceContext context) : this(name, context)
 {
     Arguments = arguments;
 }
 public SqlDatabaseBuilder(string name, DatabaseArgs arguments) : this(name)
 {
     Arguments = arguments;
 }