public void Export() { RegionId.GenerateRegion(); ConstantsReader.SetupRegion(RegionId.myRegion, "../../"); Stopwatch sw = new Stopwatch(); sw.Start(); ; all_rooms = new RoomSave[296]; all_maps = new MapSave[160]; CheckGameTitle(); progressBar.Value++; LoadDungeonsRooms(); progressBar.Value++; LoadOverworldTiles(); progressBar.Value++; LoadOverworldMaps(); progressBar.Value++; TextData.readAllText(); LoadedProjectStatistics.texts = TextData.messages.Count; progressBar.Value++; WriteLog("All data loaded successfuly.", Color.Green, FontStyle.Bold); sw.Stop(); WriteLog("Elapsed Milliseconds : " + sw.ElapsedMilliseconds.ToString(), Color.DarkRed, FontStyle.Bold); SaveJson s = new SaveJson(all_rooms, all_maps, null, TextData.messages.ToArray(), overworld); progressBar.Value = progressBar.Maximum; WriteLog("All data exported successfuly.", Color.Green, FontStyle.Bold); }
public WorldHandler(Game game, string WorldName) { Seed = 14153456352343; map = new Map(game, new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 2), Seed); map.GenerateMap(game.GraphicsDevice); save = new SaveJson <Map>(); }
public void ChangeVOL(float i) { if (Gaming) //判断该滑杆的属性 { VOLBaseSetting.BgmVOL = i; //给全局变量赋值,i是当前拖动滑杆的值 } else if (Prop) { VOLBaseSetting.PropVOL = i; } else if (Action) { VOLBaseSetting.ActionVOL = i; } BGM.GetComponent <AudioSource>().volume = i; var model = new VOLBase(); model.ActionVOL = VOLBaseSetting.ActionVOL; model.PropVOL = VOLBaseSetting.PropVOL; model.BgmVOL = VOLBaseSetting.BgmVOL; //根据最新的音量配置实例化一个新的实体,转换成Json串 var str = JsonUtility.ToJson(model); SaveJson.Save(GameBaseSetting.VolJsonPath, str);//保存到本地 }
public void LoadLast() { if (PlayerPrefs.HasKey(prefskey)) { string jsonstr = PlayerPrefs.GetString(prefskey); if (!string.IsNullOrEmpty(jsonstr)) { SaveJson saveJson = dealdeserial(jsonstr); if (saveJson != null) { enemyManager.Setnowexits(saveJson.enemyTypeSCs); SetGoalNum(saveJson.goalnum); SetShutNum(saveJson.shutnum); this.musicon = saveJson.musicon; if (Continue != null) { Continue(); } } return; } //空 } setmsg("当前没有存档!请新建游戏"); }
void GetValue() { User u = SaveJson.ReadJson <User>(GameBaseSetting.JsonPath);//用户文件 if (u != null) { GameBaseSetting.Sname = u.SName; GameBaseSetting.Id = u.Id; } }
void Start() { if (instance == null) { instance = this; } if (!PlayerPrefs.HasKey("Save")) { PlayerPrefs.SetString("Save", JsonUtility.ToJson(save)); } else save = JsonUtility.FromJson<Save>(PlayerPrefs.GetString("Save")); }
/// <summary> /// 保存登录的信息 /// </summary> /// <param name="values"></param> private void Save(string values) { //Debug.Log(values); try { SaveJson.Save(GameBaseSetting.JsonPath, values); } catch (System.Exception) { GameObject.FindGameObjectWithTag("Tag_Msg").SetActive(true); GameObject.FindGameObjectWithTag("Tag_MsgTXT").GetComponent <Text>().text = "连接失败"; } }
public Dictionary <string, string> StartFilter() { Dictionary <string, string> msg = SaveJson.DeserializeStringToDictionary <string, string>(message); string header = msg["Header"]; string body = msg["Body"]; try { string headerID = header.Trim()[0].ToString(); string headerAccount = header.Trim().Substring(1, 9); switch (header.Trim()[0]) { case 'S': filter = new Sms(body); Dictionary <string, string> sfInfomation = filter.StartFilter(); msg = msg.Concat(sfInfomation).ToDictionary(k => k.Key, v => v.Value); msg.Add("Type", "SMS"); msg.Add("error", "0"); break; case 'E': filter = new email(body); Dictionary <string, string> efInfomation = filter.StartFilter(); msg = msg.Concat(efInfomation).ToDictionary(k => k.Key, v => v.Value); msg.Add("Type", "Email"); msg.Add("error", "0"); break; case 'T': filter = new tweet(body); Dictionary <string, string> tfInfomation = filter.StartFilter(); msg = msg.Concat(tfInfomation).ToDictionary(k => k.Key, v => v.Value); msg.Add("Type", "Tweets"); msg.Add("error", "0"); break; default: MessageBox.Show("Input Error"); msg.Add("error", "1"); break; } } catch (Exception e) { msg.Add("error", "1"); msg.Add("errorInf", e.ToString()); } return(msg); }
protected InputDefinitions() { if (!StartedLoad) // Prevents this from getting called when a new instance of input definitions is called { JsonControls = new SaveJson <InputDefinitions>(); if (File.Exists(SaveFile))//TODO Tie this to a file singleton so it isn't windows based { LoadSettings(); } else { GenerateSettings(); } } //Todo implement for multiple inputs }
private void Start() { if (instance == null) { instance = this; } if (!PlayerPrefs.HasKey("Save")) { PlayerPrefs.SetString("Save", JsonUtility.ToJson(saveData)); } else { saveData = JsonUtility.FromJson <Save>(PlayerPrefs.GetString("Save")); } //sceneIndex = SceneManager.GetActiveScene().buildIndex; // Balls.progressLevel = saveData.ProgressLevel[sceneIndex]; }
void Start() { GameBaseSetting.DestoryBGM = true; //生成首个地图模块 GameObject go = GetComponent <GoPool>().GetGo(0, false); go.SetActive(true); //设置音量 var Vol = SaveJson.ReadJson <VOLBase>(GameBaseSetting.VolJsonPath); VOLBaseSetting.BgmVOL = Vol.BgmVOL; VOLBaseSetting.ActionVOL = Vol.ActionVOL; VOLBaseSetting.PropVOL = Vol.PropVOL; BGM.GetComponent <AudioSource>().volume = Vol.BgmVOL; ActionBGM.GetComponent <AudioSource>().volume = Vol.ActionVOL; PropBGM.GetComponent <AudioSource>().volume = Vol.PropVOL; }
protected void Page_Load(object sender, EventArgs e) { switch (Request["action"]) { case ("SaveJsonToDB"): { //将json存入固定的数据库位置,提供用户名和存入时间 OperRecord.OperRecord.SaveOper(Request["action"], Request.Cookies["username"].Value, Request.UserHostAddress); SaveJson save = new SaveJson(Request["name"], Request["JSONDATA"]); string saveDB = save.SaveDB(); Response.Write(saveDB); Response.End(); break; } case ("SaveJsonWithTime"): { //将json存入固定的数据库位置,提供用户名和存入时间 OperRecord.OperRecord.SaveOper(Request["action"], Request.Cookies["username"].Value, Request.UserHostAddress); SaveJson save = new SaveJson(Request["name"], Request["JSONDATA"]); string saveDB = save.SaveDBWithTime(Request["time"]); Response.Write(saveDB); Response.End(); break; } case ("SaveJsonToFile"): { //将json存入指定的文件位置,提供存储名,存储地址 OperRecord.OperRecord.SaveOper(Request["action"], Request.Cookies["username"].Value, Request.UserHostAddress); SaveJson save = new SaveJson(Request["name"], Request["url"], Request["JSONDATA"]); string saveFile = save.Savefile(); Response.Write(saveFile); Response.End(); break; } case ("LoadJsonLikeTime"): { LoadJson load = new LoadJson(Request["name"], Request["time"], ""); string sRes = load.LoadJsonLikeTime(); Response.Write(sRes); Response.End(); break; } default: { break; } } }
//初期化 void Awake() { //easing初期化 _easing = GameObject.FindObjectOfType <Easing>(); _save_json = GameObject.FindObjectOfType <SaveJson>(); //sprite初期化 _character = GetComponent <SpriteRenderer>(); _character.sprite = _charater_index[(int)_current_state]; //デフォルトのスケールを保存. _defalt_scale = new Vector2(transform.localScale.x, transform.localScale.y); _defalt_position = transform.localPosition; //アニメーションデータを読み込み if (DoRoadedAnimarionJsonDate) { _transition_index = _save_json.LoadAnimation(_root); _do_scenario = true; } }
private string dealserialize(SaveJson saveJson) { JsonArray jsonArray = new JsonArray(); foreach (var item in saveJson.enemyTypeSCs) { JsonObject pairs = new JsonObject(); pairs["ColorIndex"] = item.ColorIndex; pairs["PositionIndex"] = item.PositionIndex; pairs["TypeIndex"] = item.TypeIndex; jsonArray.Add(pairs); } JsonObject result = new JsonObject(); result["enemyTypeSCs"] = jsonArray; result["goalnum"] = saveJson.goalnum; result["shutnum"] = saveJson.shutnum; result["musicon"] = saveJson.musicon; return(SimpleJson.SimpleJson.SerializeObject(result)); }
public IHttpActionResult UpdateRetrievalForm(SaveJson json) { var retrievalService = new RetrievalService(Context); var disbursementService = new DisbursementService(Context); try { // find the Retrieval Retrieval r = retrievalService.FindRetrievalById(json.RetId); foreach (BreakdownByDepartment bd in json.List) { // find the related Disbursement Disbursement d = r.Disbursements.Where(x => x.Department.DepartmentCode == bd.DeptId).First(); disbursementService.UpdateActualQuantityForDisbursementDetail(d.DisbursementId, json.ItemCode, bd.Actual); } } catch (Exception e) { return(BadRequest(e.Message)); } return(Ok()); }
public void SaveNow() { List <EnemyTypeSC> list = enemyManager.Getnowexits(); SaveJson saveJson = new SaveJson() { enemyTypeSCs = list, goalnum = this.goalnum, musicon = this.musicon, shutnum = this.shutnum }; string savestr = dealserialize(saveJson); if (!string.IsNullOrEmpty(savestr)) { PlayerPrefs.SetString(prefskey, savestr); setmsg("保存成功!"); } else { setmsg("保存失败!请稍后再试"); } }
private SaveJson dealdeserial(string jsonstr) { JsonObject result = SimpleJson.SimpleJson.DeserializeObject <JsonObject>(jsonstr); SaveJson saveJson = new SaveJson(); JsonArray jsonArray = (JsonArray)result["enemyTypeSCs"]; saveJson.goalnum = int.Parse(result["goalnum"].ToString()); saveJson.shutnum = int.Parse(result["shutnum"].ToString()); saveJson.musicon = bool.Parse(result["musicon"].ToString()); saveJson.enemyTypeSCs = new List <EnemyTypeSC>(); foreach (JsonObject item in jsonArray) { EnemyTypeSC enemyTypeSC = new EnemyTypeSC(); enemyTypeSC.ColorIndex = int.Parse(item["ColorIndex"].ToString()); enemyTypeSC.PositionIndex = int.Parse(item["PositionIndex"].ToString()); enemyTypeSC.TypeIndex = int.Parse(item["TypeIndex"].ToString()); saveJson.enemyTypeSCs.Add(enemyTypeSC); } return(saveJson); }
/// <summary> /// 按配置的特殊索引导出方式输出json文件(如果声明了在生成的json文件开头以注释形式展示列信息,将生成更直观的嵌套字段信息,而不同于普通导出规则的列信息展示) /// </summary> public static bool SpecialExportTableToJson(TableInfo tableInfo, string exportRule, out string errorString) { exportRule = exportRule.Trim(); // 解析按这种方式导出后的json文件名 int colonIndex = exportRule.IndexOf(':'); // 解析table value中要输出的字段名 List <FieldInfo> tableValueField = new List <FieldInfo>(); // 解析完依次作为索引的字段以及table value中包含的字段后,按索引要求组成相应的嵌套数据结构 Dictionary <object, object> data = new Dictionary <object, object>(); //自定义导出规则检查 TableCheckHelper.CheckSpecialExportRule(tableInfo, exportRule, out tableValueField, out data, out errorString); if (errorString != null) { errorString = string.Format("错误:对表格{0}按\"{1}\"规则进行特殊索引导出时发现以下错误,导出被迫停止,请修正错误后重试:\n{2}\n", tableInfo.TableName, exportRule, errorString); return(false); } // 生成导出的文件内容 StringBuilder content = new StringBuilder(); // 生成数据内容开头 content.Append("{");//content.AppendLine("{"); // 当前缩进量 int currentLevel = 1; // 逐层按嵌套结构输出数据 _GetIndexFieldData(content, data, tableValueField, ref currentLevel, out errorString); if (errorString != null) { errorString = string.Format("错误:对表格{0}按\"{1}\"规则进行特殊索引导出时发现以下错误,导出被迫停止,请修正错误后重试:\n{2}\n", tableInfo.TableName, exportRule, errorString); return(false); } // 去掉最后一个子元素后多余的英文逗号 content.Remove(content.Length - 1, 1); // 生成数据内容结尾 content.AppendLine("}"); string exportString = content.ToString(); // 如果声明了要整理为带缩进格式的形式 if (JsonStruct.ExportJsonIsFormat == true) { exportString = _FormatJson2(exportString); // exportString = JsonConvert.SerializeObject(exportString); } // 保存为json文件 string fileName = exportRule.Substring(0, colonIndex).Trim(); if (SaveJson.SaveJsonFile(tableInfo.ExcelName, ExcelMethods.GetSaveTableName(fileName), exportString) == true) { errorString = null; try { LitJson.JsonData jsonData = LitJson.JsonMapper.ToObject(exportString); } catch (LitJson.JsonException exception) { errorString = "错误:导出json出现异常,请检查导出的json及Excel\n"; } return(true); } else { errorString = "保存为json文件失败\n"; return(false); } }
public static bool ExportTableToJson(TableInfo tableInfo, out string errorString) { StringBuilder content = new StringBuilder(); // 若生成为各行数据对应的json object包含在一个json array的形式 if (JsonStruct.ExportJsonIsExportJsonArrayFormat == true) { // 生成json字符串开头,每行数据为一个json object,作为整张表json array的元素 content.Append("["); // 逐行读取表格内容生成json List<FieldInfo> allField = tableInfo.GetAllClientFieldInfo(); int dataCount = tableInfo.GetKeyColumnFieldInfo().Data.Count; int fieldCount = allField.Count; for (int row = 0; row < dataCount; ++row) { // 生成一行数据json object的开头 content.Append("{"); for (int column = 0; column < fieldCount; ++column) { string oneFieldString = _GetOneField(allField[column], row, out errorString); if (errorString != null) { errorString = string.Format("导出表格{0}为json文件失败,", tableInfo.TableName) + errorString; return false; } else { content.Append(oneFieldString); } } // 去掉本行最后一个字段后多余的英文逗号,json语法不像lua那样最后一个字段后的逗号可有可无 content.Remove(content.Length - 1, 1); // 生成一行数据json object的结尾 content.Append("}"); // 每行的json object后加英文逗号 content.Append(","); } // 去掉最后一行后多余的英文逗号,此处要特殊处理当表格中没有任何数据行时的情况 if (content.Length > 1) content.Remove(content.Length - 1, 1); // 生成json字符串结尾 content.Append("]"); } else { // 生成json字符串开头,每行数据以表格主键列为key,各字段信息组成的json object为value,作为整张表json object的元素 content.Append("{"); // 逐行读取表格内容生成json List<FieldInfo> allField = tableInfo.GetAllClientFieldInfo(); FieldInfo keyColumnInfo = tableInfo.GetKeyColumnFieldInfo(); int dataCount = keyColumnInfo.Data.Count; int fieldCount = allField.Count; for (int row = 0; row < dataCount; ++row) { // 将主键列的值作为key string keyString = null; StringBuilder contentkey = new StringBuilder(); if (keyColumnInfo.DataType == DataType.String) { keyString = _GetStringValue(keyColumnInfo, row); contentkey.Append(keyString); } else if (keyColumnInfo.DataType == DataType.Int || keyColumnInfo.DataType == DataType.Long) { keyString = _GetNumberValue(keyColumnInfo, row); contentkey.Append("\"").Append(keyString).Append("\""); } else { errorString = string.Format("ExportTableToJson函数中未定义{0}类型的主键数值导出至json文件的形式", keyColumnInfo.DataType); AppLog.LogErrorAndExit(errorString); return false; } StringBuilder contenvalue = new StringBuilder(); int startColumn = (JsonStruct.ExportJsonIsExportJsonMapIncludeKeyColumnValue == true ? 0 : 1); for (int column = startColumn; column < fieldCount; ++column) { string oneFieldString = _GetOneField(allField[column], row, out errorString); if (errorString != null) { errorString = string.Format("额外导出表格{0}为json文件失败,", tableInfo.TableName) + errorString; return false; } else { contenvalue.Append(oneFieldString); } } string str = contenvalue.ToString(); if (JsonStruct.ExportJsonIsExportJsonMapIncludeKeyColumnValue == true) { // 生成一行数据json object的开头 content.Append(contentkey); content.Append(":{"); content.Append(contenvalue); // 去掉本行最后一个字段后多余的英文逗号,json语法不像lua那样最后一个字段后的逗号可有可无 content.Remove(content.Length - 1, 1); // 生成一行数据json object的结尾 content.Append("}"); // 每行的json object后加英文逗号 content.Append(","); } else if (str != "") { // 生成一行数据json object的开头 content.Append(contentkey); content.Append(":{"); content.Append(contenvalue); // 去掉本行最后一个字段后多余的英文逗号,json语法不像lua那样最后一个字段后的逗号可有可无 content.Remove(content.Length - 1, 1); // 生成一行数据json object的结尾 content.Append("}"); // 每行的json object后加英文逗号 content.Append(","); } } // 去掉最后一行后多余的英文逗号,此处要特殊处理当表格中没有任何数据行时的情况 if (content.Length > 1) content.Remove(content.Length - 1, 1); // 生成json字符串结尾 content.Append("}"); } string exportString = content.ToString(); // 如果声明了要整理为带缩进格式的形式 if (JsonStruct.ExportJsonIsFormat == true) exportString = _FormatJson(exportString); // 保存为json文件 if (SaveJson.SaveJsonFile(tableInfo.ExcelName, ExcelMethods.GetSaveTableName(tableInfo.TableName), exportString) == true) { errorString = null; //try //{ // LitJson.JsonData jsonData = LitJson.JsonMapper.ToObject(exportString); //} //catch (LitJson.JsonException exception) //{ // errorString = "错误:导出json出现异常,请检查导出的json及Excel\n"; //} return true; } else { errorString = "保存为json文件失败\n"; return false; } }
public static bool ExportTableToJson(TableInfo tableInfo, out string errorString) { StringBuilder content = new StringBuilder(); // 生成数据内容开头 content.AppendLine("{"); // 当前缩进量 int currentLevel = 1; // 判断是否设置要将主键列的值作为导出的table中的元素 bool isAddKeyToJsonTable = tableInfo.TableConfig != null && tableInfo.TableConfig.ContainsKey(JsonStruct.CONFIG_NAME_ADD_KEY_TO_JSON_TABLE) && tableInfo.TableConfig[JsonStruct.CONFIG_NAME_ADD_KEY_TO_JSON_TABLE].Count > 0 && "true".Equals(tableInfo.TableConfig[JsonStruct.CONFIG_NAME_ADD_KEY_TO_JSON_TABLE][0], StringComparison.CurrentCultureIgnoreCase); // 逐行读取表格内容生成json table List <FieldInfo> allField = tableInfo.GetAllClientFieldInfo(); int dataCount = tableInfo.GetKeyColumnFieldInfo().Data.Count; for (int row = 0; row < dataCount; ++row) { // 将主键列作为key生成 content.Append(_GetJsonIndentation(currentLevel)); FieldInfo keyColumnField = allField[0]; if (keyColumnField.DataType == DataType.Int || keyColumnField.DataType == DataType.Long) { content.AppendFormat("\"{0}\":", keyColumnField.Data[row]); } // 注意:像“1_2”这样的字符串作为table的key必须加[""]否则json认为是语法错误 else if (keyColumnField.DataType == DataType.String) { content.AppendFormat("\"{0}\":", keyColumnField.Data[row]); } else { errorString = "用ExportTableTojson导出不支持的主键列数据类型"; AppLog.LogErrorAndExit(errorString); return(false); } content.AppendLine("{"); ++currentLevel; // 如果设置了要将主键列的值作为导出的table中的元素 if (isAddKeyToJsonTable == true) { content.Append(_GetJsonIndentation(currentLevel)); content.Append("\"").Append(keyColumnField.FieldName); content.Append("\":"); if (keyColumnField.DataType == DataType.Int || keyColumnField.DataType == DataType.Long) { content.Append(keyColumnField.Data[row]); } else if (keyColumnField.DataType == DataType.String) { content.AppendFormat("\"{0}\"", keyColumnField.Data[row]); } content.AppendLine(","); } // 将其他列依次作为value生成 for (int column = 1; column < allField.Count; ++column) { string oneFieldString = _GetOneField(allField[column], row, currentLevel, out errorString); if (errorString != null) { errorString = string.Format("导出表格{0}失败,", tableInfo.TableName) + errorString; return(false); } else { content.Append(oneFieldString); } } // 一行数据生成完毕后添加右括号结尾等 --currentLevel; content.Append(_GetJsonIndentation(currentLevel)); content.AppendLine("},"); } // 生成数据内容结尾 content.AppendLine("}"); string exportString = content.ToString(); //if (JsonStruct.IsNeedColumnInfo == true) // exportString = _GetColumnInfo(tableInfo) + exportString; // 保存为json文件 if (SaveJson.SaveJsonFile(tableInfo.TableName, tableInfo.TableName, exportString) == true) { errorString = null; return(true); } else { errorString = "保存为json文件失败\n"; return(false); } }
//初期化 void Awake() { //easing初期化 _easing = GameObject.FindObjectOfType<Easing>(); _save_json = GameObject.FindObjectOfType<SaveJson>(); //sprite初期化 _character = GetComponent<SpriteRenderer>(); _character.sprite = _charater_index[(int)_current_state]; //デフォルトのスケールを保存. _defalt_scale = new Vector2(transform.localScale.x, transform.localScale.y); _defalt_position = transform.localPosition; //アニメーションデータを読み込み if (DoRoadedAnimarionJsonDate) { _transition_index = _save_json.LoadAnimation(_root); _do_scenario = true; } }
public void UpdateRetrievalFormTest() { // ARRANGE RetrievalAPIController retrievalAPIController = new RetrievalAPIController() { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration(), Context = context, }; string retId = "RETRIEVAL"; string deptId = "COMM"; string itemCode = "C001"; string disbId = "DISBURSEMENT"; int actual = 99; Retrieval r = new Retrieval { RetrievalId = retId, CreatedDateTime = DateTime.Now }; Disbursement d = new Disbursement { DisbursementId = disbId, Department = departmentService.FindDepartmentByDepartmentCode(deptId), Retrieval = r, CreatedDateTime = DateTime.Now, DisbursementDetails = new List <DisbursementDetail> { new DisbursementDetail { Item = ItemRepository.FindById(itemCode), PlanQuantity = 99, ActualQuantity = 0 } } }; retrievalRepository.Save(r); disbursementRepository.Save(d); try { SaveJson json = new SaveJson { ItemCode = itemCode, RetId = retId, List = new List <BreakdownByDepartment> { new BreakdownByDepartment { DeptId = deptId, Actual = actual } } }; // ACT retrievalAPIController.UpdateRetrievalForm(json); // ASSERT int expected = 99; DisbursementDetail dd; //using (context = new ApplicationDbContext()) //{ disbursementRepository = new DisbursementRepository(context); dd = disbursementRepository .FindById(disbId) .DisbursementDetails .Where(x => x.ItemCode == itemCode).First(); //} Assert.AreEqual(expected, dd.ActualQuantity); } finally { //using (context = new ApplicationDbContext()) //{ Disbursement deleteD = context.Disbursement.Where(x => x.DisbursementId == disbId).First(); context.Disbursement.Remove(deleteD); Retrieval deleteR = context.Retrieval.Where(x => x.RetrievalId == retId).First(); context.Retrieval.Remove(deleteR); context.SaveChanges(); //} } }
private void saveFileEvent(string fileName) { SaveJson.saveJson(fileName); }