private void LoadTable(UnityEngine.Object obj) { _isLoaded = true; TextAsset asset = obj as TextAsset; if (asset != null) { _recordTable = new RecordTable <T>(_tableName); _recordTable.LoadTdrBin(asset); if (_isListData) { _InitList(_keyName); } else { _Init(); } Resources.UnloadAsset(asset); //加载成功不打日志 //Log.Debug("load table over: " + name); } else { //AiToyDebug.LogError("load table error: " + _tableName); } loadedCallback(""); }
static void LoadOption() { RecordTable difficulty = RecordManager.GetData(c_difficultyRecordKey); foreach (var item in difficulty) { s_difficultyLevels.Add(item.Key); } if (s_difficultyLevels.Count == 0) { s_difficultyLevels.Add("normal"); } RecordTable poemTypes = RecordManager.GetData(c_poemTypesKey); foreach (var item in poemTypes) { s_poemTypes.Add(item.Key); } if (s_poemTypes.Count == 0) { s_poemTypes.Add("songci"); } RecordTable langeConfig = RecordManager.GetData(c_langeuageRecord); SystemLanguage langeType = langeConfig.GetEnumRecord <SystemLanguage>(c_langeuageKey, Application.systemLanguage); LanguageManager.SetLanguage(langeType); }
static IEnumerator StartDownLoad() { Debug.Log("下载服务器文件到本地"); UpdateDateCallBack(HotUpdateStatusEnum.Updating, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(0))); RecordTable hotupdateData = RecordManager.GetData(c_HotUpdateRecordName); for (int i = 0; i < s_downLoadList.Count; i++) { Hash128 md5Tmp = Hash128.Parse(hotupdateData.GetRecord(s_downLoadList[i].name, "null")); if (md5Tmp.Equals(s_downLoadList[i].md5)) { Debug.Log("文件已更新完毕 " + s_downLoadList[i].name); //该文件已更新完毕 UpdateDateCallBack(HotUpdateStatusEnum.Updating, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(i))); } else { string downloadPath = s_resourcesFileDownLoadPath + s_downLoadList[i].name; WWW www = new WWW(downloadPath); yield return(www); if (www.error != null && www.error != "") { Debug.LogError("下载出错! " + downloadPath + " " + www.error); UpdateDateCallBack(HotUpdateStatusEnum.UpdateFail, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(i))); yield break; } else { Debug.Log("下载成功! " + downloadPath); ResourceIOTool.CreateFile(PathTool.GetAssetsBundlePersistentPath() + "/" + s_downLoadList[i].name, www.bytes); RecordManager.SaveRecord(c_HotUpdateRecordName, s_downLoadList[i].name, s_downLoadList[i].md5.ToString()); UpdateDateCallBack(HotUpdateStatusEnum.Updating, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(i))); } } } //保存版本信息 //保存文件信息 ResourceIOTool.CreateFile(PathTool.GetAssetsBundlePersistentPath() + c_versionFileName, s_versionByteCache); ResourceIOTool.CreateFile(PathTool.GetAssetsBundlePersistentPath() + AssetsManifestManager.c_ManifestFileName, s_ManifestByteCache); //从stream读取配置 RecordManager.SaveRecord(c_HotUpdateRecordName, c_useHotUpdateRecordKey, true); //重新生成资源配置 ResourcesConfigManager.LoadResourceConfig(); AssetsManifestManager.LoadAssetsManifest(); //延迟2秒卸载Bundle缓存,防止更新界面掉图(更新时间短时,卸载过快界面会掉图) //yield return new WaitForSeconds(2); ResourceManager.ReleaseAll(false); UpdateDateCallBack(HotUpdateStatusEnum.UpdateSuccess, 1); }
/// <summary> /// Populate the record table list. Keep reading records until one is empty /// </summary> /// <returns></returns> public bool readRecordTable() { //TODO test this function bool isEmpty = false; byte index = 0; RecordTable table; while (!isEmpty) { table = new RecordTable(this); if (table.readRecordTable(index)) { isEmpty = table.RecordEmpty; if (!isEmpty) // only add the table if it is not empty { this.recordTable.Add(table); } index++; } else { return(false); } } return(true); }
private void InitRanorex() { Mouse.DefaultMoveTime = 300; Keyboard.DefaultKeyPressTime = 100; Delay.SpeedFactor = 1.0; itemRecorder = new ItemRecorder(); itemRecorder.CreateControl(); recordTable = new RecordTable("recordTableName", new List <RecordItem>()); recorder = new Recorder(itemRecorder, recordTable, ElementEngine.Instance.RootElement); recorder.ValidationHandler = new ValidationRequestHandler(this.ValidationRequestCallback); recorder.RecordingStopped += new EventHandler <RecordingStoppedEventArgs>(recorder_RecordingStopped); recorder.ItemRecorded += new EventHandler <ItemRecordedEventArgs>(this.Recorder_ItemRecorded); CreateControlPanel(); tracker = new TrackerCheckBox(); tracker.EnableMouseWheelParentCounterChange = false; tracker.EnableHighlighterAutoUpdate = false; tracker.CreateControl(); tracker.EnableInstantTracking = false; tracker.EnableKeyboardShortcuts = false; }
public static RecordTable GetData(string RecordName) { if (s_RecordCache.ContainsKey(RecordName)) { return(s_RecordCache[RecordName]); } RecordTable record = null; string dataJson = ""; string fullPath = Utility.Path.GetCombinePath(UnityUtility.Path.PersistentDataPath, Constant.DevicePlatform.GetCurDevicePlatformPath(), c_directoryName, RecordName + "." + c_expandName); if (File.Exists(fullPath)) { dataJson = IOTool.ReadStringByFile(fullPath); } if (dataJson == "") { record = new RecordTable(); } else { record = RecordTable.Analysis(dataJson); } s_RecordCache.Add(RecordName, record); return(record); }
public static void SaveRecord(string RecordName, string key, string value) { RecordTable table = GetData(RecordName); table.SetRecord(key, value); SaveData(RecordName, table); }
public static void CleanRecord(string recordName) { RecordTable table = GetData(recordName); table.Clear(); SaveData(recordName, table); }
//获取数据 public RecordTable GetData(string recordName) { if (m_recordCache.ContainsKey(recordName)) { return(m_recordCache[recordName]); } RecordTable record = null; var dataJson = string.Empty; var path = PathTool.GetRelativelyPath(m_directoryName, recordName, m_expandName); var fullPath = PathTool.GetAbsolutePath(ResLoadLocation.Persistent, path); if (File.Exists(fullPath)) { //记录永远从沙盒路径读取 dataJson = ResourceIOTool.ReadStringByFile(fullPath); } if (string.IsNullOrEmpty(dataJson)) { record = new RecordTable(); } else { record = RecordTable.Analysis(dataJson); } m_recordCache.Add(recordName, record); return(record); }
private static void Main() { while (true) { var map = LevelSwitcher.GetNextLevel(); var test = new Player(); if (!Game.IsOver) { Game.Map = LevelCreator.CreateMap(map); Application.Run(new GameWindow()); } else { break; } } End(); void End() { if (!Game.IsOver) { return; } var name = Interaction.InputBox("Enter your name", "Succes", "", -1, -1); RecordTable.AddRecord(name, Game.MovesCount); MessageBox.Show(RecordTable.GetTopFive(), "Records", MessageBoxButtons.OKCancel); } }
/// <summary> /// Add a binary attachment to existing record /// Can be file/image/mail/... depending on what ServiceNow allows /// </summary> /// <typeparam name="T"></typeparam> /// <param name="recordId">Record sys_id</param> /// <param name="filename">Name of the attachment</param> /// <param name="file">The attachment in binary format</param> /// <returns></returns> public async Task <RestResponseSingle <Attachment> > PostAttachment <T>(string recordId, string filename, byte[] file) where T : Record { if (string.IsNullOrWhiteSpace(recordId)) { throw new ArgumentNullException(nameof(recordId)); } if (!RecordNumber.IsValidId(recordId)) { throw new ArgumentException("Invalid record ID.", nameof(recordId)); } if (string.IsNullOrWhiteSpace(filename)) { throw new ArgumentNullException(nameof(filename)); } if (file == null || file.Length == 0) { throw new ArgumentNullException(nameof(file)); } // Convert to safe values var nvs = new NameValueCollection { { "table_name", RecordTable.GetTableName <T>() }, { "table_sys_id", recordId }, { "file_name", HttpUtility.UrlEncode(filename) } }; // Build url with keys var urlBuilder = new StringBuilder(); urlBuilder.Append("attachment/file?"); for (var i = 0; i < nvs.Keys.Count; i++) { if (i > 0) { urlBuilder.Append("&"); } var key = nvs.Keys[i]; urlBuilder.AppendFormat("{0}={1}", key, nvs[key]); } var url = urlBuilder.ToString(); // Post var response = await _Client.PostAsFileAsync(url, filename, file); if (response.IsSuccessStatusCode) { return(await response.Content.ReadAsJsonAsync <RestResponseSingle <Attachment> >()); } else { return new RestResponseSingle <Attachment>() { ErrorMsg = $"POST attachment error ({response.StatusCode}): {response.ReasonPhrase}" } }; } #endregion }
public DBHelper(string connectionString, LogFunc log = null) : base(connectionString, log) { _AppLogTable = new AppLogTable(connectionString, log); _CompanyTable = new CompanyTable(connectionString, log); _MaterialTable = new MaterialTable(connectionString, log); _ReceiptTable = new ReceiptTable(connectionString, log); _RecordTable = new RecordTable(connectionString, log); }
public override void Execute() { RetCode rc; var nlFlag = false; gOut.WriteLine(); gEngine.PrintTitle(Title, true); var helper = Globals.CreateInstance <U>(); var j = RecordTable.GetRecordsCount(); var i = 0; foreach (var record in RecordTable.Records) { helper.Record = record; helper.ListRecord(false, false, false, false, false, false); nlFlag = true; if ((i != 0 && (i % (Constants.NumRows - 8)) == 0) || i == j - 1) { nlFlag = false; PrintPostListLineSep(); gOut.Write("{0}Press any key to continue or X to exit: ", Environment.NewLine); Buf.Clear(); rc = Globals.In.ReadField(Buf, Constants.BufSize02, null, ' ', '\0', true, null, gEngine.ModifyCharToNullOrX, null, gEngine.IsCharAny); Debug.Assert(gEngine.IsSuccess(rc)); gOut.Print("{0}", Globals.LineSep); if (Buf.Length > 0 && Buf[0] == 'X') { break; } } i++; } if (nlFlag) { gOut.WriteLine(); } gOut.Print("Done listing {0} record names.", RecordTypeName); }
//static List<ResourcesConfig> s_deleteList = new List<ResourcesConfig>(); static IEnumerator StartDownLoad() { Debug.Log("下载服务器文件到本地"); UpdateDateCallBack(HotUpdateStatusEnum.Updating, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(0))); RecordTable hotupdateData = RecordManager.GetData(c_HotUpdateRecordName); for (int i = 0; i < s_downLoadList.Count; i++) { string md5Tmp = hotupdateData.GetRecord(s_downLoadList[i].name, "null"); if (md5Tmp == s_downLoadList[i].md5) { //该文件已更新完毕 UpdateDateCallBack(HotUpdateStatusEnum.Updating, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(i))); } else { string downloadPath = s_resourcesFileDownLoadPath + s_downLoadList[i].path + "." + AssetsBundleManager.c_AssetsBundlesExpandName; WWW www = new WWW(downloadPath); yield return(www); if (www.error != null && www.error != "") { Debug.LogError("下载出错! " + downloadPath + " " + www.error); UpdateDateCallBack(HotUpdateStatusEnum.UpdateFail, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(i))); yield break; } else { Debug.Log("下载成功! " + downloadPath); ResourceIOTool.CreateFile(Application.persistentDataPath + "/" + s_downLoadList[i].path + "." + AssetsBundleManager.c_AssetsBundlesExpandName, www.bytes); RecordManager.SaveRecord(c_HotUpdateRecordName, s_downLoadList[i].name, s_downLoadList[i].md5); UpdateDateCallBack(HotUpdateStatusEnum.Updating, GetHotUpdateProgress(true, true, GetDownLoadFileProgress(i))); } } } //保存版本信息 //保存文件信息 ResourceIOTool.WriteStringByFile(PathTool.GetAbsolutePath(ResLoadLocation.Persistent, HotUpdateManager.c_versionFileName + "." + ConfigManager.c_expandName), m_versionFileCatch); ResourceIOTool.WriteStringByFile(PathTool.GetAbsolutePath(ResLoadLocation.Persistent, ResourcesConfigManager.c_ManifestFileName + "." + ConfigManager.c_expandName), m_Md5FileCatch); //从stream读取配置 RecordManager.SaveRecord(c_HotUpdateRecordName, c_useHotUpdateRecordKey, true); UpdateDateCallBack(HotUpdateStatusEnum.UpdateSuccess, 1); //重新生成资源配置 ResourcesConfigManager.Initialize(); }
public static void SaveFavorites() { RecordTable data = new RecordTable(); for (int i = 0; i < s_favoritesList.Count; i++) { data.SetRecord(s_favoritesList[i], ""); } RecordManager.SaveData(c_recordName, data); }
//TODO: maybe move this to a subclass protected virtual RecordTable ApplyOutputClause(RecordTable source, OutputClause clause) { var selectors = Visit <Func <Environment, Func <IResultTable, Selector[]> > >(clause)?.Invoke(Database.GlobalEnvironment)(source); if (selectors != null) { return(new RecordTable(source.TableName, selectors, Filter.From(source.Records, (row) => true, null))); } return(null); }
public async Task <int> SaveRecordAsync(RecordTable record) { if (record.ID != 0 && (await GetRecordAsync(record.ID)) != null) { return(await _database.UpdateAsync(record)); } else { return(await _database.InsertAsync(record)); } }
void LoadRecord(string recordName) { if (m_currentRecordName != recordName) { m_currentRecordName = recordName; if (m_currentRecordName != "None") { m_currentRecord = RecordManager.GetData(recordName); } } }
public static void SaveData(string RecordName, RecordTable data) { ResourceIOTool.WriteStringByFile( PathTool.GetAbsolutePath(ResLoadType.Persistent, PathTool.GetRelativelyPath(c_directoryName, RecordName, c_expandName)), RecordTable.Serialize(data)); #if UNITY_EDITOR UnityEditor.AssetDatabase.Refresh(); #endif }
public static RecordTable Analysis(string data) { var result = new RecordTable(); var tmp = JsonTool.Json2Dictionary <SingleField>(data); var keys = new List <string>(tmp.Keys); for (int i = 0; i < keys.Count; i++) { result.Add(keys[i], tmp[keys[i]]); } return(result); }
private void OnGUI() { if (GUI.Button(new Rect(10, 10, 100, 20), "Save")) { AudioPlayManager.StopMusic2D(1); } if (GUI.Button(new Rect(10, 40, 100, 20), "Show")) { RecordTable table = RecordManager.GetData("GameSettingData"); Debug.Log(table["TotleVolume"].GetFloat()); } }
public void SaveData(string recordName, RecordTable data) { var path = PathTool.GetRelativelyPath(m_directoryName, recordName, m_expandName); ResourceIOTool.WriteStringByFile(PathTool.GetAbsolutePath(ResLoadLocation.Persistent, path), RecordTable.Serialize(data)); #if UNITY_EDITOR if (!Application.isPlaying) { UnityEditor.AssetDatabase.Refresh(); } #endif }
public static void Init() { if (!isInit) { isInit = true; s_favoritesList = new List<string>(); RecordTable data = RecordManager.GetData(c_recordName); foreach (var item in data) { s_favoritesList.Add(item.Key); } } }
static int Serialize(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); RecordTable arg0 = (RecordTable)ToLua.CheckObject(L, 1, typeof(RecordTable)); string o = RecordTable.Serialize(arg0); LuaDLL.lua_pushstring(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int Analysis(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); string arg0 = ToLua.CheckString(L, 1); RecordTable o = RecordTable.Analysis(arg0); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SaveData(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); string arg0 = ToLua.CheckString(L, 1); RecordTable arg1 = (RecordTable)ToLua.CheckObject(L, 2, typeof(RecordTable)); RecordManager.SaveData(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SetEnumRecord(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); RecordTable obj = (RecordTable)ToLua.CheckObject(L, 1, typeof(RecordTable)); string arg0 = ToLua.CheckString(L, 2); System.Enum arg1 = (System.Enum)ToLua.CheckObject(L, 3, typeof(System.Enum)); obj.SetEnumRecord(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// Create new record in ServiceNow using its Table API /// </summary> /// <typeparam name="T">Record type</typeparam> /// <param name="record">Instance of Record type</param> /// <returns></returns> public Task <RestResponseSingle <T> > Post <T>(T record) where T : Record, new() { if (record == null) { throw new ArgumentNullException(nameof(record)); } if (record.Equals(new T())) { throw new ArgumentException("The record cannot be empty.", nameof(record)); } if (record.Id != null) { throw new ArgumentException("The record cannot contain an ID when creating.", nameof(record)); } return(Post <RestResponseSingle <T>, T>($"{GetUrl<T>()}?sysparm_fields={RecordTable.GetFieldList<T>()}", record)); }
public static RecordTable GetData(string RecordName) { string dataJson = ""; dataJson = ResourceIOTool.ReadStringByFile( PathTool.GetAbsolutePath(ResLoadType.Persistent, PathTool.GetRelativelyPath(c_directoryName, RecordName, c_expandName))); if (dataJson == "") { return(new RecordTable()); } else { return(RecordTable.Analysis(dataJson)); } }
public static RecordTable Analysis(string data) { RecordTable result = new RecordTable(); Dictionary <string, SingleField> tmp = JsonTool.Json2Dictionary <SingleField>(data); List <string> keys = new List <string>(tmp.Keys); for (int i = 0; i < keys.Count; i++) { //Debug.Log("Key: " + keys[i]); result.Add(keys[i], tmp[keys[i]]); } return(result); }
/// <summary> /// Populate the record table list. Keep reading records until one is empty /// </summary> /// <returns></returns> public bool readRecordTable() { //TODO test this function bool isEmpty = false; byte index = 0; RecordTable table; while (!isEmpty) { table = new RecordTable(this); if (table.readRecordTable(index)) { isEmpty = table.RecordEmpty; if (!isEmpty) // only add the table if it is not empty this.recordTable.Add(table); index++; } else return false; } return true; }
/// <summary> /// Populate the record table list. Keep reading records until one is empty /// </summary> /// <returns></returns> public bool readRecordTable() { //TODO test this function bool isEmpty = false; byte index = 0; RecordTable table; while (!isEmpty) { table = new RecordTable(this); if (table.readRecordTable(index)) { isEmpty = table.RecordEmpty; //TODO remove the check for trackID, this was to get around some corrupted entries in the record table if (!isEmpty && table.TrackID != 255) // only add the table if it is not empty this.recordTable.Add(table); index++; } else return false; } return true; }
void LoadRecord(string recordName) { if (m_currentRecordName != recordName) { m_currentRecordName = recordName; if (m_currentRecordName != "None") m_currentRecord = RecordManager.GetData(recordName); } }
void AddRecordGUI() { EditorGUI.indentLevel = 0; isRecordFold = EditorGUILayout.Foldout(isRecordFold, "新增数据"); if (isRecordFold) { EditorGUI.indentLevel = 1; recordName = EditorGUILayout.TextField("数据名", recordName); if (!m_recordNameList.Contains(recordName) && recordName != "") { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("新增", GUILayout.Width(position.width - 60))) { RecordTable dict = new RecordTable(); RecordManager.SaveData(recordName, dict); FindAllRecordName(); LoadRecord(recordName); recordName = ""; } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); } else { if (m_recordNameList.Contains(recordName)) { EditorGUILayout.LabelField("已存在该数据"); } } } EditorGUILayout.Space(); }