public void LoadSpriteData() { try { string str = UtilFile.ReadStringFromFile(SpriteDataPath); string strReplace = str.Replace("213", "V213"); int nIdxExternal = strReplace.IndexOf("externalObjects"); if (nIdxExternal > 0) { strReplace = strReplace.Substring(0, nIdxExternal); } var input = new StringReader(strReplace); var deserializer = new DeserializerBuilder() .WithNamingConvention(new NullNamingConvention()) .Build(); SpriteBuildData = deserializer.Deserialize <Sprite_MultiRes>(input); } catch (SerializationException e) { int nres = e.ToString().IndexOf("externalObjects"); if (nres >= 0) { int a = 0; } } catch (FileNotFoundException e) { Debug.Log(e.ToString()); } }
/// <summary> /// 上传图片文件 /// </summary> /// <param name="files">上传的文件对象</param> /// <param name="uploadFlag">上传标识,上传文件的input组件的名称</param> /// <param name="upload_dir">上传文件存储的所在目录[最后一级目录,一般对应图片列名称]</param> /// <param name="categoryId">上传文件所在的目录标识,一般为类实例名称</param> /// <returns></returns> public Dictionary <string, object> UploadImage(HttpFileCollection files, string uploadFlag, string upload_dir, string categoryId = "default") { string diffpart = DateTime.Now.Ticks.ToString();//UtilDateTime.NowS(); Dictionary <string, object> result = null; if ((files != null) && (files.Count > 0)) { string filename, uploadPath, tmptail = ""; for (int i = 0; i < files.Count; i++) { HttpPostedFile hpf = files[i]; filename = hpf.FileName; if (!String.IsNullOrEmpty(filename)) { tmptail = Path.GetExtension(filename); uploadPath = Path.Combine(Business.Gc.UploadPath, "images", categoryId, upload_dir, diffpart + tmptail); //保存路径名称,统一文件命名 UtilFile.CreateDir(uploadPath); hpf.SaveAs(uploadPath); //保存文件 result = new Dictionary <string, object>(); result["success"] = true; result["file_showname"] = hpf.FileName; result["file_name"] = categoryId + "/" + upload_dir + "/" + diffpart + tmptail; } } } return(result); }
/// <summary> /// ファイルに書き込む /// </summary> /// <param name="f"></param> public override void Write(UtilFile f) { f.WriteByte(szName); //f.WriteInt(lenght); f.WriteInt(width); f.WriteInt(height); }
/// <summary> /// ファイルから読み込む /// </summary> /// <param name="f"></param> public override void Read(UtilFile f) { f.ReadByte(szName, 0, szName.Length); length = f.ReadInt(); width = f.ReadInt(); height = f.ReadInt(); }
/// <summary> /// 1.生成核心业务控制器 /// [如果是在线编辑器需生成:this.ViewBag.OnlineEditorHtml],默认不生成[1个文件] /// [模板文件]:action/homecontroller.txt /// 生成文件名称:HomeController.cs /// </summary> private void CreateHomeController() { string ClassName = "Admin"; string Table_Comment = "系统管理员"; string Template_Name, Unit_Template, Content, MainContent, Textarea_Text; string Column_Name, Column_Type, Column_Length; //读取原文件内容到内存 Template_Name = @"AutoCode/Model/action/homecontroller.txt"; Content = UtilFile.ReadFile2String(Template_Name); MainContent = ""; foreach (string Table_Name in TableList) { ClassName = Table_Name; if (TableInfoList.ContainsKey(Table_Name)) { Table_Comment = TableInfoList[Table_Name]["Comment"]; string[] t_c = Table_Comment.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); if (t_c.Length > 1) { Table_Comment = t_c[0]; } Unit_Template = @" // 控制器:{$Table_Comment} // GET: /Home/{$ClassName} public ActionResult {$ClassName}() {{$Textarea_Text} return View(); } "; Dictionary <string, Dictionary <string, string> > FieldInfo = FieldInfos[Table_Name]; Textarea_Text = ""; foreach (KeyValuePair <String, Dictionary <string, string> > entry in FieldInfo) { Column_Name = entry.Key; Column_Type = entry.Value["Type"]; Column_Length = entry.Value["Length"]; int iLength = UtilNumber.Parse(Column_Length); if (ColumnIsTextArea(Column_Name, Column_Type, iLength)) { Textarea_Text += "\"" + Column_Name + "\","; } } if (!string.IsNullOrEmpty(Textarea_Text)) { Textarea_Text = Textarea_Text.Substring(0, Textarea_Text.Length - 1); Textarea_Text = @" this.ViewBag.OnlineEditorHtml = this.Load_Onlineditor(" + Textarea_Text + ");"; } Unit_Template = Unit_Template.Replace("{$ClassName}", ClassName); Unit_Template = Unit_Template.Replace("{$Textarea_Text}", Textarea_Text); MainContent += Unit_Template.Replace("{$Table_Comment}", Table_Comment); } } Content = Content.Replace("{$MainContent}", MainContent); //存入目标文件内容 UtilFile.WriteString2File(Save_Dir + "HomeController.cs", Content); }
/// <summary> /// 运行主程序 /// </summary> public void Run() { base.Init(); //1.Core/Service服务层所有的服务业务类 Save_Dir = App_Dir + "Core" + Path.DirectorySeparatorChar + "Business" + Path.DirectorySeparatorChar + "Service" + Path.DirectorySeparatorChar; if (!Directory.Exists(Save_Dir)) { UtilFile.CreateDir(Save_Dir); } if (ServiceType == 1) { CreateNormalService(); } //2.Business/Admin后台所有ExtService服务类 Save_Dir = App_Dir + "Admin" + Path.DirectorySeparatorChar + "Services" + Path.DirectorySeparatorChar; if (!Directory.Exists(Save_Dir)) { UtilFile.CreateDir(Save_Dir); } if (ServiceType == 2) { CreateExtService(); } //3.Portal 网站主体的ManageService工具类 Save_Dir = App_Dir + "Core" + Path.DirectorySeparatorChar + "Business" + Path.DirectorySeparatorChar; if (!Directory.Exists(Save_Dir)) { UtilFile.CreateDir(Save_Dir); } if (ServiceType == 2) { CreateManageService(); } }
/// <summary> /// 1.后台普通的显示cshtml文件【多个文件】 /// 如果是大文本列,需生成@Html.Raw(ViewBag.OnlineEditorHtml),默认不生成 /// [模板文件]:view/view.txt /// [生成文件名称]:ClassName /// [生成文件后缀名]:.cshtml /// </summary> private void CreateNormalView() { string ClassName = "Admin"; string InstanceName = "admin"; string Table_Comment = "系统管理员"; string Template_Name, Content, Content_New, OnlineEditorHtml = "", ComboTreeInitHtml = ""; string Relation_Table_Name; string Column_Name, Column_Type, Column_Length; foreach (string Table_Name in TableList) { //读取原文件内容到内存 Template_Name = @"AutoCode/Model/view/view.txt"; Content = UtilFile.ReadFile2String(Template_Name); ClassName = Table_Name; ComboTreeInitHtml = ""; OnlineEditorHtml = ""; if (TableInfoList.ContainsKey(Table_Name)) { Table_Comment = TableInfoList[Table_Name]["Comment"]; string[] t_c = Table_Comment.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); if (t_c.Length > 1) { Table_Comment = t_c[0]; } InstanceName = UtilString.LcFirst(ClassName); Content_New = Content.Replace("{$ClassName}", ClassName); Content_New = Content_New.Replace("{$Table_Comment}", Table_Comment); Content_New = Content_New.Replace("{$InstanceName}", InstanceName); Dictionary <string, Dictionary <string, string> > FieldInfo = FieldInfos[Table_Name]; foreach (KeyValuePair <String, Dictionary <string, string> > entry in FieldInfo) { Column_Name = entry.Key; Column_Type = entry.Value["Type"]; Column_Length = entry.Value["Length"]; Relation_Table_Name = Column_Name.Replace("_ID", ""); if (Relation_Table_Name.ToUpper().Equals("PARENT")) { ComboTreeInitHtml = @" <script type=""text/javascript"" src=""@Url.Content(""~/Content/common/js/ajax/ext/shared/components/ComboBoxTree.js"")""></script>"; } int iLength = UtilNumber.Parse(Column_Length); if (ColumnIsTextArea(Column_Name, Column_Type, iLength)) { OnlineEditorHtml = " @Html.Raw(ViewBag.OnlineEditorHtml)"; } } Content_New = Content_New.Replace("{$OnlineEditorHtml}", OnlineEditorHtml); Content_New = Content_New.Replace("{$ComboTreeInitHtml}", ComboTreeInitHtml); //存入目标文件内容 UtilFile.WriteString2FileEncodingGbk(Save_Dir + ClassName + ".cshtml", Content_New); } } }
public void testJson() { string str = UtilFile.ReadStringFromFile(SpriteDataPath); var input = new StringReader(str); //var deserializer = new DeserializerBuilder() // .WithNamingConvention(new CamelCaseNamingConvention()) // .Build(); //var yamlObject = deserializer.Deserialize(input); //JsonUtility.se //string strJson = JsonUtility.ToJson(yamlObject); //JsonUtility.FromJson(str,Type.) var deserializer = new DeserializerBuilder().Build(); var yamlObject = deserializer.Deserialize(input); var serializer = new SerializerBuilder() .JsonCompatible() .Build(); var json = serializer.Serialize(yamlObject); //JsonUtility.FromJson(json, ConvertYamlToJson); int a = 0; // now convert the object to JSON. Simple! //Newtonsoft.Json.JsonSerializer js = new Newtonsoft.Json.JsonSerializer(); //var w = new StringWriter(); //js.Serialize(w, yamlObject); //string jsonText = w.ToString(); }
public void LoadFile() { try { string str = UtilFile.ReadStringFromFile(TileMapPath); //string strReplace = str.Replace("---", "aaa"); int nStartIdx = str.IndexOf("Tilemap", 0); int nEndIdx = str.IndexOf("---", nStartIdx); string strTileMapPaletteData = str.Substring(nStartIdx, nEndIdx - nStartIdx); string strFinal = strTileMapPaletteData; var input = new StringReader(strFinal); var deserializer = new DeserializerBuilder() .WithNamingConvention(new NullNamingConvention()) .Build(); var tileSetDataIns = deserializer.Deserialize <PrefabTileSet>(input); Debug.Log(str); } catch (FileNotFoundException e) { Debug.Log(e.ToString()); } }
public void LaunchAndCheckCrash(long testTimes) { var crashTimes = 0; UtilCmd.Clear(); for (var i = 1; i < testTimes; i++) { var titleTotal = $"Reopen Times: {i} - Crash Times: {crashTimes}"; var logLines = UtilFile.ReadFileByLine(LogPathLaunch); logLines.ForEach(UtilCmd.WriteLine); //logLines.ForEach(line => UtilCmd.WriteLine(line)); var launchLogTime = GetRestartLogTime(); var screenshotPath = Path.Combine(ScreenshotsPath, crashTimes.ToString()); UtilProcess.StartProcess(SwLnkPath); Timeout = 1; UtilCmd.WriteTitle($"{titleTotal} - Searching MP+ UI."); var startTime = DateTime.Now; var dialogWarning = UtilWait.ForAnyResultCatch(() => { UtilCmd.WriteTitle($"{titleTotal} - Searching Warning dialog of the MP+ in 60s. Time elapsed: {(DateTime.Now - startTime).Seconds}s."); SwMainWindow = new AT().GetElement(MPObj.MainWindow, Timeout); // The MP+ will change after a while. return(SwMainWindow.GetElement(MPObj.DialogWarning, Timeout)); }, 60, 2); if (SwMainWindow == null) { UtilCapturer.Capture(i.ToString()); UtilFile.WriteFile(LogPathLaunch, $"{launchLogTime}: Reopen Times: {i} - Could not open MasterPlus."); crashTimes++; } UtilTime.WaitTime(1); UtilProcess.KillProcessByName(SwProcessName); UtilTime.WaitTime(1); } }
/// <summary> /// ファイルに書き込む /// </summary> /// <param name="f"></param> public override void Write(UtilFile f) { f.WriteShort(wait); f.WriteShort(tileNo); f.WriteByte(transformFlg); f.WriteByte(tmp); }
/// <summary> /// ファイルから読み込む /// </summary> /// <param name="f"></param> public override void Read(UtilFile f) { wait = f.ReadShort(); tileNo = f.ReadShort(); transformFlg = f.ReadByte(); tmp = f.ReadByte(); }
/// <summary> /// 書き出しを終了する。 /// </summary> /// <returns>何も無ければ1を返す</returns> public int End() { if (m_vChankBlockStack.Count > 1) { throw new FormatException(string.Format("BlockEnd()を %d つ呼び忘れたところがあります。", m_vChankBlockStack.Count - 1)); } else if (m_lastState == LAST_NOTHING) { throw new FormatException("Start()を呼ぶ前に終了しようとしました。"); } else if (m_lastState == LAST_BLOCK_START) { throw new FormatException("BlockStart()の後に終了しないでください。"); } else if (m_lastState == LAST_WRITE) { throw new FormatException("Write()の後に終了しないでください。"); } if (m_RAFile != null) { // ヘッダ部分にデータサイズを再書き込みする m_RAFile.Seek(0); m_header.Write(m_RAFile); // 初回チャンク this.BlockChankStackPop(); m_RAFile.Close(); m_RAFile = null; } return(1); }
/// <summary> /// 1.Core/Service服务层所有的服务业务类|接口【多个文件】 /// [模板文件]:service/service.txt|service/iservice.txt /// [生成文件名称]:"Service"+ClassName|"IService"+ClassName /// [生成文件后缀名]:.cs /// </summary> private void CreateNormalService() { string ClassName = "Admin"; string InstanceName = "admin"; string Table_Comment = "系统管理员"; string Template_Name, Content, Content_New; string ID_Type, ID_Default_Value; foreach (string Table_Name in TableList) { //读取原文件内容到内存 Template_Name = @"AutoCode/Model/service/iservice.txt"; Content = UtilFile.ReadFile2String(Template_Name); ClassName = Table_Name; if (TableInfoList.ContainsKey(Table_Name)) { Table_Comment = TableInfoList[Table_Name]["Comment"]; string[] t_c = Table_Comment.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); if (t_c.Length > 1) { Table_Comment = t_c[0]; } InstanceName = UtilString.LcFirst(ClassName); Dictionary <string, Dictionary <string, string> > FieldInfo = FieldInfos[Table_Name]; Dictionary <string, string> entry = FieldInfo["ID"]; if (entry["Type"].Equals("uniqueidentifier")) { ID_Type = "Guid"; ID_Default_Value = "null"; } else { ID_Type = "int"; ID_Default_Value = "0"; } Content_New = Content.Replace("{$ClassName}", ClassName); Content_New = Content_New.Replace("{$Table_Comment}", Table_Comment); Content_New = Content_New.Replace("{$InstanceName}", InstanceName); Content_New = Content_New.Replace("{$ID_Type}", ID_Type); //存入目标文件内容 UtilFile.WriteString2File(Save_Dir + "IService" + ClassName + ".cs", Content_New); //读取原文件内容到内存 Template_Name = @"AutoCode/Model/service/service.txt"; Content = UtilFile.ReadFile2String(Template_Name); Content_New = Content.Replace("{$ClassName}", ClassName); Content_New = Content_New.Replace("{$Table_Comment}", Table_Comment); InstanceName = UtilString.LcFirst(ClassName); Content_New = Content_New.Replace("{$InstanceName}", InstanceName); Content_New = Content_New.Replace("{$ID_Type}", ID_Type); Content_New = Content_New.Replace("{$ID_Default_Value}", ID_Default_Value); //存入目标文件内容 UtilFile.WriteString2File(Save_Dir + "Service" + ClassName + ".cs", Content_New); } } }
public override void Read(UtilFile f) { f.ReadByte(szName, 0, 16); tileNumX = f.ReadShort(); tileNumY = f.ReadShort(); tmp = f.ReadInt(); }
/// <summary> /// ファイルに書き込む /// </summary> /// <param name="f"></param> public override void Write(UtilFile f) { f.WriteByte(collisionChipNo); f.WriteByte(collisionChipFlgs); f.WriteUShort(collisionTargetFlgs); f.WriteUInt(tileFlg); }
private List <Dictionary <string, string> > readFromFile(string fileName) { List <Dictionary <string, string> > list = UtilFile.GetJsonFromFile("", fileName); HttpContext.Session["traceJson"] = list; return(list); }
/// <summary> /// ファイルから読み込む /// </summary> /// <param name="f"></param> public override void Read(UtilFile f) { collisionChipNo = f.ReadByte(); collisionChipFlgs = f.ReadByte(); collisionTargetFlgs = f.ReadUShort(); tileFlg = f.ReadUInt(); }
public override void Write(UtilFile f) { f.WriteByte(szName); f.WriteShort(tileNumX); f.WriteShort(tileNumY); f.WriteInt(tmp); }
/// <summary> /// ファイルから読み込む /// </summary> /// <param name="f"></param> public override void Read(UtilFile f) { x = f.ReadShort(); y = f.ReadShort(); width = f.ReadShort(); height = f.ReadShort(); }
public static void FindNoUsedPrefabs() { Debug.ClearDeveloperConsole(); Debug.LogError(">>>>正在查找未使用prefab资源<<<"); Debug.Log(">>查找位置:Lua/Module中的所有lua文件,ModuleConfig.txt,和Resources/UI下的prefab名字比对 <<<"); { List <string> paths = new List <string>(); GetAllUsePrefabDictionary(); string[] prefabNames = LookForPrefab(); int totalCount = 0; for (int i = 0; i < prefabNames.Length; i++) { if (!usingDict.ContainsKey(prefabNames[i].GetHashCode())) { totalCount++; Debug.Log(prefabNames[i]); paths.Add(prefabNames[i]); } } foreach (var t in paths) { string path = Application.dataPath + "/Resources/" + t; Debug.LogError("del " + path); UtilFile.DeleteFile(path); } Debug.LogError(">>>>查找结束,共找到" + totalCount + "个未使用资源<<<"); Debug.LogError(@">>>>资源谨慎操作, 移到Assets\ArtTower\ui_old_prefab文件夹中,避免误删"); usingDict.Clear(); } }
public override void Write(UtilFile f) { // TODO 自動生成されたメソッド・スタブ f.WriteShort(L.anmTileNo); f.WriteShort(L.anmGroupNo); f.WriteUShort(L.flags); f.WriteShort(tmp); }
public override void Write(UtilFile f) { f.WriteByte(szName); f.WriteShort(x); f.WriteShort(y); f.WriteShort(width); f.WriteShort(height); }
/// <summary> /// Deletes all theme files and return new empty theme directory /// </summary> /// <returns></returns> public DirectoryInfo ClearUserThemeDirectory() { if (Directory.Exists(ThemeLocationPath)) { UtilFile.DeleteDirectory(ThemeLocationPath); } return(Directory.CreateDirectory(ThemeLocationPath)); }
/// <summary> /// 書き出しを終了する。 /// </summary> public void End() { if (m_file != null) { m_file.Close(); m_file = null; } }
public override void Read(UtilFile f) { f.ReadByte(szName, 0, 16); x = f.ReadShort(); y = f.ReadShort(); width = f.ReadShort(); height = f.ReadShort(); }
/// <summary> /// ファイルに書き込む /// </summary> /// <param name="f"></param> public override void Write(UtilFile f) { f.WriteByte(szName); f.WriteInt(width); f.WriteInt(height); f.WriteInt(tileWidht); f.WriteInt(tileHeight); }
public override void Read(UtilFile f) { // TODO 自動生成されたメソッド・スタブ L.anmTileNo = f.ReadShort(); L.anmGroupNo = f.ReadShort(); L.flags = f.ReadUShort(); tmp = f.ReadShort(); }
/// <summary> /// 刷新一个文件树所对应的所有文件与文件夹的图标 /// </summary> /// <param name="treeNodes">一个文件树.</param> /// <param name="imageList">所有文件与文件夹的图标集合,引用关系.</param> public static void RefreshSourceFolderFileTreeNodeIcon(IEnumerable treeNodes, ImageList imageList) { if (imageList == null) { imageList = new ImageList(); } foreach (TreeNode treeNode in treeNodes) { var path = treeNode.ToolTipText; if (string.IsNullOrWhiteSpace(path)) { continue; } if (UtilFile.IsDirectory(path)) //当是目录时 { if (!imageList.Images.ContainsKey(FolderType.Open.ToString())) { var closedIcon = GetFolderIcon(IconSize.Small, FolderType.Closed); var openIcon = GetFolderIcon(IconSize.Small, FolderType.Open); imageList.Images.Add(FolderType.Closed.ToString(), closedIcon); imageList.Images.Add(FolderType.Open.ToString(), openIcon); } treeNode.SelectedImageKey = FolderType.Open.ToString(); treeNode.ImageKey = FolderType.Closed.ToString(); if (treeNode.Nodes.Count > 0) //判断是否有子目录,进行递归 { RefreshSourceFolderFileTreeNodeIcon(treeNode.Nodes, imageList); } } else if (File.Exists(path)) //当是文件时 { var ext = Path.GetExtension(path); if (string.IsNullOrWhiteSpace(ext) || ext.Equals(".exe")) { ext = path; //可执行文件的图标都不一样;没有扩展名的文件的图标就不讲了,只能浪费一些内存了 } ext = ext.ToLower(); if (!imageList.Images.ContainsKey(ext)) { Icon icon; if (File.Exists(path)) { icon = GetFileIcon(path, IconSize.Small, false); } else { icon = GetFolderIcon(IconSize.Small, FolderType.Closed); } imageList.Images.Add(ext, icon); } treeNode.ImageKey = ext; treeNode.StateImageKey = ext; treeNode.SelectedImageKey = ext; } } }
/// <summary> /// ファイルに書き込む /// </summary> /// <param name="f"></param> public override void Write(UtilFile f) { f.WriteShort(x); f.WriteShort(y); f.WriteShort(width); f.WriteShort(height); f.WriteShort(anchorX); f.WriteShort(anchorY); }