override public void Init() { if (DatabaseName == "") { Log.Write(LogLevel.Warning, ObjectPrivate.Name, "Database must have a name."); Unregister(); return; } if (!IsValid) { Log.Write(LogLevel.Warning, ObjectPrivate.Name, "None of the sceret numbers are allowed to be 0 or 100, and they are not allowed to all be the same number."); Unregister(); return; } salt = Salt1.ToString("00") + Salt2.ToString("00") + Salt3.ToString("00") + Salt4.ToString("00") + Salt5.ToString("00") + Salt6.ToString("00") + Salt7.ToString("00") + Salt8.ToString("00") + Salt9.ToString("00"); schema = ScenePrivate.CreateDataStore(salt + salt + "__schema__"); schema.Restore("scenes", (DataStore.Result <Dictionary <string, Dictionary <string, string> > > res) => { Dictionary <string, Dictionary <string, string> > scenes = new Dictionary <string, Dictionary <string, string> >(); if (res.Success) { scenes = res.Object; } Dictionary <string, string> info = scenes[ScenePrivate.SceneInfo.LocationHandle] = new Dictionary <string, string>(); info["name"] = ScenePrivate.SceneInfo.ExperienceName; info["last-use"] = DateTime.UtcNow.ToString("o"); info["owner"] = ScenePrivate.SceneInfo.AvatarId; schema.Store("scenes", scenes); }); }
public override void Init() { dataStore = ScenePrivate.CreateDataStore(dataStoreId); if (dataStore != null) { Log.Write("DataStore id is " + dataStore.Id); dataStore.Restore <List <DateTime> >(timeKey, getStartTime); } else { Log.Write("Unable to create a data store with id " + dataStoreId); } }
public Func <string, DataStore> GetCreateTable(string database) { if (database != DatabaseName) { return(null); } return((string tableName) => { if (tablesToAdd.Count == 0) { Timer.Create(.5, () => { List <string> ts = tablesToAdd; tablesToAdd = new List <string>(); schema.Restore("tables", (DataStore.Result <Dictionary <string, string> > res) => { Dictionary <string, string> tables = new Dictionary <string, string>(); if (res.Success) { tables = res.Object; } bool hasNew = false; foreach (string t in ts) { if (!tables.ContainsKey(t)) { hasNew = true; tables[t] = t; if (Debug) { Log.Write("[Database]", "[" + DatabaseName + "] - [new-table]: " + t); } } } if (hasNew) { schema.Store("tables", tables); } }); }); } tablesToAdd.Add(tableName); if (Debug) { Log.Write("[Database]", "[" + DatabaseName + "] - [get-table]: " + tableName); } return ScenePrivate.CreateDataStore(salt + tableName); }); }