public void handleDirectoryTreeViewPopulationFromDirectory(string directory) { //this.operationControlCommandsDataGridView.EditingControlShowing += preloadedConfigurationCommandsDataGridView_EditingControlShowing //Root directory has null parent; FileDirectory rd = new FileDirectory(directory, null); if (DirectoryHandler.getInstance().directoryHasFilePattern(directory, PreloadedConfigurationGetterService.getInstance().getFilePattern(this.configFile))) { DirectoryTreeViewThreadHandler tvht = new DirectoryTreeViewThreadHandler(rd, this.getDirectoryTreeView()); DirectoryThreadHandler dht = new DirectoryThreadHandler(rd, PreloadedConfigurationGetterService.getInstance().getFilePattern(this.configFile)); Cursor.Current = Cursors.WaitCursor; try { if (!tvht.checkNodeExists(this.getDirectoryTreeView())) { Thread handleDirectory = new Thread(new ThreadStart(dht.Handle)); handleDirectory.Start(); handleDirectory.Join(); Thread handleTreeView = new Thread(new ThreadStart(tvht.HandleDirectoryTree)); handleTreeView.Start(); handleTreeView.Join(); this.getDirectoryTreeView().Nodes.Add(tvht.getRoot()); } } finally { Cursor.Current = Cursors.Default; } } }
public FileDirectory HandleDirectory(FileDirectory rd, string filepatterns) { rd.setChildren(this.getChildrenOf(rd, rd.getPath(), filepatterns)); foreach (FileDirectory current in rd.getChildren()){ this.HandleDirectory(current, filepatterns); } return rd; }
public string getPathFromParent(FileDirectory fd, string path) { if (fd.getParent() != null) { path = this.getPathFromParent(fd.getParent(), fd.getParent().getPath()) + "\\" + path; } return path; }
public string[] PrintDirectoryStructure(FileDirectory rd) { List<string> list = new List<string>(); list.Add(rd.getPath()); foreach (FileDirectory current in rd.getChildren()){ this.PrintDirectoryStructure(current, list, 1); } return list.ToArray(); }
public DirectoryTreeNode PopulateDirectoryTreeView(FileDirectory rd) { DirectoryTreeNode directoryTreeNode = new DirectoryTreeNode(rd); directoryTreeNode.Name = rd.getPath(); directoryTreeNode.Text = rd.getPath(); foreach (FileDirectory current in rd.getChildren()){ this.PopulateDirectoryTreeViewForChildren(current, directoryTreeNode); } return directoryTreeNode; }
public void PopulateDirectoryTreeViewForChildren(FileDirectory rd, TreeNode root) { DirectoryTreeNode directoryTreeNode = new DirectoryTreeNode(rd); directoryTreeNode.Text = rd.getPath(); directoryTreeNode.Name = rd.getPath(); root.Nodes.Add(directoryTreeNode); foreach (FileDirectory current in rd.getChildren()) { this.PopulateDirectoryTreeViewForChildren(current, directoryTreeNode); } }
public void addRow(DataGridView view, FileDirectory fd, string config) { DirectoryDataGridViewRow directoryDataGridViewRow = new DirectoryDataGridViewRow(fd); string text = DirectoryHandler.getInstance().getPathFromParent(fd, fd.getPath()); DirectoryDataGridViewTextBoxCell directories = new DirectoryDataGridViewTextBoxCell(text); DataGridViewComboBoxCell commands = new DataGridViewComboBoxCell(); DataGridViewCheckBoxCell include = new DataGridViewCheckBoxCell(); DataGridViewCheckBoxCell echo = new DataGridViewCheckBoxCell(); DataGridViewCheckBoxCell display = new DataGridViewCheckBoxCell(); DataGridViewCheckBoxCell autoExit = new DataGridViewCheckBoxCell(); DataGridViewCheckBoxCell waitForExit = new DataGridViewCheckBoxCell(); if (text.Length > 50) { int i = text.Length; int num = 20; while (i > 50) { i--; num++; } text = text.Substring(0, 5) + "....." + text.Substring(num); } directories.Value = text; foreach(Command c in PreloadedConfigurationGetterService.getInstance().getCommandsFromXMLConfiguration(config)){ commands.Items.Add(c.getName()); } if(commands.Items.Count == 0) return; commands.Value = commands.Items[0]; include.Value = true; echo.Value = true; display.Value = true; autoExit.Value = true; waitForExit.Value = true; directoryDataGridViewRow.Cells.Add(directories); directoryDataGridViewRow.Cells.Add(commands); directoryDataGridViewRow.Cells.Add(include); directoryDataGridViewRow.Cells.Add(display); directoryDataGridViewRow.Cells.Add(autoExit); directoryDataGridViewRow.Cells.Add(waitForExit); directories.ReadOnly = true; commands.ReadOnly = false; include.ReadOnly = false; echo.ReadOnly = false; display.ReadOnly = false; autoExit.ReadOnly = false; view.Rows.Add(directoryDataGridViewRow); }
private List<FileDirectory> getChildrenOf(FileDirectory fd, string path, string filepattern) { List<FileDirectory> list = new List<FileDirectory>(); if (fd.getParent() != null){ path = this.getPathFromParent(fd, path); } if (Directory.Exists(path)) { try{ foreach( string s in Directory.GetDirectories(path)){ if (directoryHasFilePattern(s, filepattern)) { list.Add(new FileDirectory(new DirectoryInfo(s).Name, fd)); } } } catch (UnauthorizedAccessException){ Console.Out.WriteLine(HelperErrors.UNAUTHORISED_DIRECTORY_ACCESS + path); } } return list; }
/// <summary> /// pdf添加水印 /// </summary> /// <param name="data"></param> private static void PDFAddWatermark(ToSwfData data) { WriteLog("开始添加水印", "PDFAddWatermark"); if (!FileDirectory.FileExists(pdfbgApiPath)) { WriteLog("接口不存在:", pdfbgApiPath); return; } string pdfName = data.FilePath + ".pdf"; string arguments = " \"{0}\" \"{1}\" \"{2}\" {3}".FormatWith(data.FilePath, WatermarkImage, pdfName, WatermarkPosition); Run(pdfbgApiPath, arguments); Url = "ok - [" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] - " + pdfbgApiPath + arguments; if (OnNewOrDelete != null) { OnNewOrDelete(null, null); } if (!FileDirectory.FileExists(pdfName)) { WriteLog(pdfName + " 文件不存在", "PDFAddWatermark"); return; } FileDirectory.FileDelete(data.FilePath); FileDirectory.FileRename(pdfName, data.FilePath); WriteLog(Url, "PDFAddWatermark"); }
public ApiReturns Post(FileDirectory model) { // 只有超级管理员才能添加顶级目录 if (model.ParentId == 0 && !LoginStatus.IsSuperAdminLogin()) { return(ApiReturns.Forbidden()); } if (DirNameExists(model)) { return(ApiReturns.Exists()); } model.CreateTime = DateTime.Now; model.LastModifyTime = DateTime.Now; model.CreatorId = LoginStatus.GetLoginUser().Id; // 插入数据库 var success = _dirBll.ExecuteTranscation(() => { var s = _dirBll.Add(model).Id > 0; if (s) { var d = new DbUpdateLog(nameof(FileDirectory), model.Id, (int)Operation.Insert); return(_logBll.Add(d).Id > 0); } return(false); }); if (success) { return(ApiReturns.Created(model)); } return(ApiReturns.BadRequest()); }
/// <summary> /// PDF转SWF 多个SWF /// </summary> /// <param name="filePath"></param> public static void PDFToSwfN(ToSwfData data) { if (!FileDirectory.FileExists(pdfToSwfApiPath)) { WriteLog("接口不存在:", pdfToSwfApiPath); return; } string swfName = System.IO.Path.ChangeExtension(data.FilePath, ".swf"); swfName = swfName.Substring(0, swfName.Length - 4) + "%.swf"; //swfName = System.IO.Path.GetDirectoryName(swfName) + "\\" + System.IO.Path.GetFileNameWithoutExtension(swfName) + "%.swf"; string arguments = " \"{0}\" -o \"{1}\" -f -T 9 -t -s storeallcharacters -s poly2bitmap".FormatWith(data.FilePath, swfName); Run(pdfToSwfApiPath, arguments); Url = "ok - [" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] - " + pdfToSwfApiPath + arguments; if (OnNewOrDelete != null) { OnNewOrDelete(null, null); } if (!FileDirectory.FileExists(swfName.Replace("%.swf", "1.swf"))) { WriteLog(swfName + " 文件不存在", "PDFToSwfN"); return; } WriteLog(Url, "PDFToSwfN"); }
public async Task BasicFileScan() { // Arrange // Prepare DB & files Assert.IsTrue(PrepareDirectories()); Assert.IsTrue(await ResetDatabase(), "Could not create database"); var targetDir = Path.Combine(testDirD, "dir1"); File.Copy(Path.GetFullPath(Path.Combine(testFileDir, "KeyMap.txt")), Path.Combine(targetDir, "KeyMap.txt")); File.Copy(Path.GetFullPath(Path.Combine(testFileDir, "0266554465.jpeg")), Path.Combine(targetDir, "0266554465.jpeg")); File.Copy(Path.GetFullPath(Path.Combine(testFileDir, "Nikon-1-V3-sample-photo.jpg")), Path.Combine(targetDir, "Nikon-1-V3-sample-photo.jpg")); File.Copy(Path.GetFullPath(Path.Combine(testFileDir, "randomExe.exe")), Path.Combine(targetDir, "randomExe.exe")); File.Copy(Path.GetFullPath(Path.Combine(testFileDir, "umlaut_äü(&テスト.txt")), Path.Combine(targetDir, "umlaut_äü(&テスト.txt")); var archiveLabel = "BasicFileScanArchive"; // Create reference file index var fileRootDir = Path.GetFullPath(targetDir).Substring(Path.GetPathRoot(targetDir).Length); var refFi = new FileIndex(); var dDrive = new LogicalVolume() { SerialNumber = "2822F77D", Size = 499971518464, Type = DriveType.Fixed, VolumeName = "Games", MountPoint = "D:\\" }; refFi.LogicalVolumes.Add(dDrive); var refArchive = new Archive() { RootDirectoryPath = fileRootDir, Volume = dDrive, Index = refFi, Label = archiveLabel }; refFi.Archives.Add(refArchive); var d1 = new FileDirectory() { Archive = refArchive, DirectoryName = Path.GetFullPath(testDirD).Substring(Path.GetPathRoot(testDirD).Length), Name = "dir1" }; refArchive.RootDirectory = d1; var h1 = new FileHash() { Checksum = "F03F01D5778DFB6DC499BFFC11C26EF7", Length = 56199, CreationTime = DateTime.Parse("2018-02-01 20:54:52.4866447"), LastWriteTime = DateTime.Parse("2018-01-31 22:27:16.2543275") }; var f1 = new FileNode() { DirectoryName = fileRootDir, Name = "0266554465.jpeg", Extension = ".jpeg", Checksum = "F03F01D5778DFB6DC499BFFC11C26EF7", Hash = h1, Archive = refArchive, Parent = d1, }; h1.AddNode(f1); refFi.Hashes.Add(h1); d1.FileNodes.Add(f1); var h2 = new FileHash() { Checksum = "9BFCF0A5F4660C7251F487F085C2580B", Length = 12155, CreationTime = DateTime.Parse("2018-02-01 20:54:52.5009427"), LastWriteTime = DateTime.Parse("2018-01-31 22:25:31.9274553") }; var f2 = new FileNode() { DirectoryName = fileRootDir, Name = "KeyMap.txt", Extension = ".txt", Checksum = "9BFCF0A5F4660C7251F487F085C2580B", Hash = h2, Archive = refArchive, Parent = d1 }; h2.AddNode(f2); refFi.Hashes.Add(h2); d1.FileNodes.Add(f2); var h3 = new FileHash() { Checksum = "C9C02F785EE42EFACE21B3164BE718C2", Length = 75349, CreationTime = DateTime.Parse("2018-02-01 20:54:52.51192"), LastWriteTime = DateTime.Parse("2018-01-31 22:25:54.6826964") }; var f3 = new FileNode() { DirectoryName = fileRootDir, Name = "Nikon-1-V3-sample-photo.jpg", Extension = ".jpg", Checksum = "C9C02F785EE42EFACE21B3164BE718C2", Hash = h3, Archive = refArchive, Parent = d1 }; h3.AddNode(f3); refFi.Hashes.Add(h3); d1.FileNodes.Add(f3); var h4 = new FileHash() { Checksum = "F6BA3E6C9CA1D37B980536ECF4075C77", Length = 13824, CreationTime = DateTime.Parse("2018-02-01 20:54:52.5334261"), LastWriteTime = DateTime.Parse("2018-01-31 22:28:23.013479") }; var f4 = new FileNode() { DirectoryName = fileRootDir, Name = "randomExe.exe", Extension = ".exe", Checksum = "F6BA3E6C9CA1D37B980536ECF4075C77", Hash = h4, Archive = refArchive, Parent = d1 }; h4.AddNode(f4); refFi.Hashes.Add(h4); d1.FileNodes.Add(f4); var h5 = new FileHash() { Checksum = "D41D8CD98F00B204E9800998ECF8427E", Length = 0, CreationTime = DateTime.Parse("2018-02-01 20:54:52.5399261"), LastWriteTime = DateTime.Parse("2018-01-31 22:27:04.4650235") }; var f5 = new FileNode() { DirectoryName = fileRootDir, Name = "umlaut_äü(&テスト.txt", Extension = ".txt", Checksum = "D41D8CD98F00B204E9800998ECF8427E", Hash = h5, Archive = refArchive, Parent = d1 }; h5.AddNode(f5); refFi.Hashes.Add(h5); d1.FileNodes.Add(f5); // Act var diffFi = new FileIndex(); var diffArchive = await diffFi.CreateArchiveAsync(new DirectoryInfo(targetDir), new CancellationTokenSource().Token, new Progress <int>(), new Progress <string>(), archiveLabel); // Several attributes are created on the fly, so we need to copy them // to the reference archive refArchive.Guid = diffArchive.Guid; // Assert Assert.AreEqual(refFi.Archives.Count, diffFi.Archives.Count, "Archive count incorrect."); Assert.AreEqual(refFi.LogicalVolumes.Count, diffFi.LogicalVolumes.Count, "LogicalVolume count incorrect."); foreach (var refVolume in refFi.LogicalVolumes) { Assert.IsTrue(diffFi.LogicalVolumes.Contains(refVolume), "LogicalVolume not found."); } Assert.AreEqual(refFi.Hashes.Count, diffFi.Hashes.Count, "FileHash count incorrect."); foreach (var refHash in refFi.Hashes) { Assert.IsTrue(diffFi.Hashes.Contains(refHash), "FileHash not found."); Assert.AreEqual(refHash, diffFi.Hashes.FirstOrDefault(x => x.Equals(refHash)), "FileHash not equal."); } Assert.AreEqual(refArchive.GetFileNodes().Count, diffArchive.GetFileNodes().Count, "FileNodes count incorrect."); foreach (var refNode in refArchive.GetFileNodes()) { Assert.IsTrue(diffArchive.GetFileNodes().Contains(refNode), "FileNode not found."); } Assert.AreEqual(refArchive.GetFileDirectories().Count, diffArchive.GetFileDirectories().Count, "FileDirectory count incorrect."); foreach (var refNode in refArchive.GetFileDirectories()) { Assert.IsTrue(diffArchive.GetFileDirectories().Contains(refNode), "FileDirectory not found."); } }
public static void Run(bool exit = false) { if (!string.IsNullOrEmpty(config.AdminPath) && config.IsAll) { Pub.Class.FileDirectory.DirectoryCreate(config.AdminPath + "\\xml\\"); Pub.Class.FileDirectory.FileDelete(config.AdminPath + "\\xml\\db.aspx"); FileDirectory.FileWrite(config.AdminPath + "\\xml\\db.aspx", "<div class='MenuTitlebar' style='top: 12px; left: 12px; width: 168px; height: 25px;' title='数据库管理'><table cellspacing='0' cellpadding='0'><tbody><tr style='width: 185px; height: 25px;'><td class='MenuTitlebarLeft_Head' style='width: 13px;'/><td class='MenuTitlebarMiddle_Head' style='width: 130px;'><div class='MenuTitle_Head' style='width: 130px; height: 25px; line-height: 25px;'>数据库管理</div></td><td class='MenuTitlebarRight_Open_Head' style='width: 25px;'/></tr></tbody></table></div>\n\r<div class='MenuBody_Head' style='border-width: 0px 1px 1px; padding: 9px 0px; overflow: hidden; top: 37px; left: 12px; width: 166px; opacity: 1;'>"); } StringBuilder sbSqlCode = new StringBuilder(); tables.Clear(); config.OPList = TableStructureFactory.LoadOPList(config, entity => { tables.Add((entity.isView ? "* " : "") + entity.Name); }); foreach (string key in tables) { string tabName = key; bool isView = false; if (tabName.IndexOf("* ") == 0) { tabName = tabName.Substring(2); isView = true; } TableOperator to = config.OPList.Where(p => p.Table == tabName).FirstOrDefault(); string dalCode = string.Empty; string idalCode = string.Empty; string bllCode = string.Empty; string sqlCode = string.Empty; string baseCode = string.Empty; if (!string.IsNullOrEmpty(config.ModelPath) && to.Entity && config.DesignPattern == "Model-DAL-BLL") { string code = TableStructureFactory.GetTableStructCode(config, tabName, config.Project, out idalCode, out dalCode, out bllCode, out sqlCode, isView); Pub.Class.FileDirectory.DirectoryCreate(config.ModelPath + "\\Model\\"); Pub.Class.FileDirectory.FileDelete(config.ModelPath + "\\Model\\" + tabName + ".cs"); FileDirectory.FileWrite(config.ModelPath + "\\Model\\" + tabName + ".cs", code); } if (!string.IsNullOrEmpty(config.EntityPath) && to.Entity && config.DesignPattern != "Model-DAL-BLL") { string code = TableStructureFactory.GetTableStructCode(config, tabName, config.Project, out baseCode, out sqlCode, isView); Pub.Class.FileDirectory.DirectoryCreate(config.EntityPath + "\\Entity\\"); Pub.Class.FileDirectory.FileDelete(config.EntityPath + "\\Entity\\" + tabName + ".cs"); FileDirectory.FileWrite(config.EntityPath + "\\Entity\\" + tabName + ".cs", code); } if (config.DesignPattern == "Model-DAL-BLL" && !string.IsNullOrEmpty(config.DALPath) && to.Entity) { Pub.Class.FileDirectory.DirectoryCreate(config.DALPath + "\\" + config.TemplateName.Split('-')[3] + "DAL" + "\\"); Pub.Class.FileDirectory.FileDelete(config.DALPath + "\\" + config.TemplateName.Split('-')[3] + "DAL" + "\\" + tabName + "DAL.cs"); Pub.Class.FileDirectory.DirectoryCreate(config.IDALPath + "\\IDAL\\"); Pub.Class.FileDirectory.FileDelete(config.IDALPath + "\\IDAL\\I" + tabName + "DAL.cs"); if (!string.IsNullOrEmpty(dalCode.Trim())) { FileDirectory.FileWrite(config.DALPath + "\\" + config.TemplateName.Split('-')[3] + "DAL" + "\\" + tabName + "DAL.cs", dalCode); FileDirectory.FileWrite(config.IDALPath + "\\IDAL\\I" + tabName + "DAL.cs", idalCode); } else { Pub.Class.FileDirectory.FileDelete(config.DALPath + "\\" + config.TemplateName.Split('-')[3] + "DAL" + "\\" + tabName + "DAL.cs"); Pub.Class.FileDirectory.FileDelete(config.IDALPath + "\\IDAL\\I" + tabName + "DAL.cs"); } Pub.Class.FileDirectory.DirectoryCreate(config.BLLPath + "\\BLL\\"); Pub.Class.FileDirectory.FileDelete(config.BLLPath + "\\BLL\\" + tabName + "BLL.cs"); if (!string.IsNullOrEmpty(bllCode.Trim())) { FileDirectory.FileWrite(config.BLLPath + "\\BLL\\" + tabName + "BLL.cs", bllCode); sbSqlCode.AppendLine(sqlCode); } else { Pub.Class.FileDirectory.FileDelete(config.BLLPath + "\\BLL\\" + tabName + "BLL.cs"); } } if (config.DesignPattern != "Model-DAL-BLL" && !string.IsNullOrEmpty(config.FactoryPath) && to.Entity) { Pub.Class.FileDirectory.DirectoryCreate(config.FactoryPath + "\\" + config.DesignPatternExtName + "\\"); Pub.Class.FileDirectory.FileDelete(config.FactoryPath + "\\" + config.DesignPatternExtName + "\\" + tabName + "" + config.DesignPatternExtName + ".cs"); if (!string.IsNullOrEmpty(baseCode.Trim())) { FileDirectory.FileWrite(config.FactoryPath + "\\" + config.DesignPatternExtName + "\\" + tabName + "" + config.DesignPatternExtName + ".cs", baseCode); sbSqlCode.AppendLine(sqlCode); } else { Pub.Class.FileDirectory.FileDelete(config.FactoryPath + "\\" + config.DesignPatternExtName + "\\" + tabName + "" + config.DesignPatternExtName + ".cs"); } } WriteLog(tabName + " 生成成功!"); } if (!string.IsNullOrEmpty(config.AdminPath) && config.IsAll) { FileDirectory.FileWrite(config.AdminPath + "\\xml\\db.aspx", "</div>"); } if (!string.IsNullOrEmpty(config.DALPath)) { string extFile = Server2.GetMapPath("") + "\\ext\\Sql\\SqlCode.sql"; string extCode = FileDirectory.FileReadAll(extFile, Encoding.UTF8).ToString(); Pub.Class.FileDirectory.DirectoryCreate(Server2.GetMapPath("") + "\\SQLCode\\"); string code = sbSqlCode.ToString() + "\r\n" + extCode; if (code.Trim().Length > 10) { FileDirectory.FileWrite(Server2.GetMapPath("") + "\\SQLCode\\SQLCode" + Rand.RndDateStr() + ".sql", sbSqlCode.ToString() + "\r\n" + extCode); } } WriteLog("共 {0} 张表!", tables.Count); WriteLog("END"); Input(exit); }
private List<string> PrintDirectoryStructure(FileDirectory rd, List<string> printOut, int tabs) { string str = ""; for (int i = 0; i < tabs; i++){ str += "\t"; } printOut.Add(str + rd.getPath()); foreach (FileDirectory current in rd.getChildren()){ this.PrintDirectoryStructure(current, printOut, tabs + 1); } return printOut; }
private static bool asduReceivedHandler(object parameter, ASDU asdu) { Console.WriteLine(asdu.ToString()); if (asdu.TypeId == TypeID.M_SP_NA_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var val = (SinglePointInformation)asdu.GetElement(i); Console.WriteLine(" IOA: " + val.ObjectAddress + " SP value: " + val.Value); Console.WriteLine(" " + val.Quality.ToString()); } } else if (asdu.TypeId == TypeID.M_ME_TE_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var msv = (MeasuredValueScaledWithCP56Time2a)asdu.GetElement(i); Console.WriteLine(" IOA: " + msv.ObjectAddress + " scaled value: " + msv.ScaledValue); Console.WriteLine(" " + msv.Quality.ToString()); Console.WriteLine(" " + msv.Timestamp.ToString()); } } else if (asdu.TypeId == TypeID.M_ME_TF_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var mfv = (MeasuredValueShortWithCP56Time2a)asdu.GetElement(i); Console.WriteLine(" IOA: " + mfv.ObjectAddress + " float value: " + mfv.Value); Console.WriteLine(" " + mfv.Quality.ToString()); Console.WriteLine(" " + mfv.Timestamp.ToString()); Console.WriteLine(" " + mfv.Timestamp.GetDateTime().ToString()); } } else if (asdu.TypeId == TypeID.M_SP_TB_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var val = (SinglePointWithCP56Time2a)asdu.GetElement(i); Console.WriteLine(" IOA: " + val.ObjectAddress + " SP value: " + val.Value); Console.WriteLine(" " + val.Quality.ToString()); Console.WriteLine(" " + val.Timestamp.ToString()); } } else if (asdu.TypeId == TypeID.M_ME_NC_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var mfv = (MeasuredValueShort)asdu.GetElement(i); Console.WriteLine(" IOA: " + mfv.ObjectAddress + " float value: " + mfv.Value); Console.WriteLine(" " + mfv.Quality.ToString()); } } else if (asdu.TypeId == TypeID.M_ME_NB_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var msv = (MeasuredValueScaled)asdu.GetElement(i); Console.WriteLine(" IOA: " + msv.ObjectAddress + " scaled value: " + msv.ScaledValue); Console.WriteLine(" " + msv.Quality.ToString()); } } else if (asdu.TypeId == TypeID.M_ME_ND_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var msv = (MeasuredValueNormalizedWithoutQuality)asdu.GetElement(i); Console.WriteLine(" IOA: " + msv.ObjectAddress + " scaled value: " + msv.NormalizedValue); } } else if (asdu.TypeId == TypeID.C_IC_NA_1) { if (asdu.Cot == CauseOfTransmission.ACTIVATION_CON) { Console.WriteLine((asdu.IsNegative ? "Negative" : "Positive") + "confirmation for interrogation command"); } else if (asdu.Cot == CauseOfTransmission.ACTIVATION_TERMINATION) { Console.WriteLine("Interrogation command terminated"); con.SendClockSyncCommand(1, new CP56Time2a(DateTime.Now)); } } else if (asdu.TypeId == TypeID.F_DR_TA_1) { Console.WriteLine("Received file directory:\n------------------------"); int ca = asdu.Ca; for (int i = 0; i < asdu.NumberOfElements; i++) { FileDirectory fd = (FileDirectory)asdu.GetElement(i); Console.Write(fd.FOR ? "DIR: " : "FILE: "); Console.WriteLine("CA: {0} IOA: {1} Type: {2}", ca, fd.ObjectAddress, fd.NOF.ToString()); } } else if (asdu.TypeId == TypeID.C_RD_NA_1)//102 { if (asdu.NumberOfElements > 0) { var obj = (ReadCommand)asdu.GetElement(0); Console.WriteLine($"Read command: ObjectAddress:{obj.ObjectAddress} !"); } } else if (asdu.TypeId == TypeID.C_CS_NA_1) { var obj = (ClockSynchronizationCommand)asdu.GetElement(0); if (asdu.Cot == CauseOfTransmission.REQUEST) { Console.WriteLine((asdu.IsNegative ? "Negative" : "Positive") + " confirmation for clock read command. " + obj.NewTime.ToString()); } else if (asdu.Cot == CauseOfTransmission.ACTIVATION_CON) { Console.WriteLine((asdu.IsNegative ? "Negative" : "Positive") + " confirmation for clock synchronization command"); } else if (asdu.Cot == CauseOfTransmission.ACTIVATION_TERMINATION) { Console.WriteLine("clock synchronization command terminated"); } } else if (asdu.TypeId == TypeID.C_RR_NA_1) { if (asdu.NumberOfElements > 0) { var obj = (ReadCurrentSettingArea)asdu.GetElement(0); Console.WriteLine($"Read current setting area: SN:{obj.SNCurrent} SN min:{obj.SNMin} SN max:{obj.SNMax}!"); } } else if (asdu.TypeId == TypeID.C_RS_NA_1) { if (asdu.NumberOfElements > 0) { var obj = (ReadParameters)asdu.GetElement(0); Console.WriteLine($" SN:{obj.SN} PI:{obj.PI.Followup} {obj.PI.RES} {obj.PI.CR} {obj.PI.Select}"); } } else if (asdu.TypeId == TypeID.M_EI_NA_1) { con.SendInterrogationCommand(CauseOfTransmission.ACTIVATION, 1, QualifierOfInterrogation.STATION); } else { Console.WriteLine("Unknown message type!"); } return(true); }
static void Main(string[] args) { Console.Title = $"HabBit[{GetVersion()}] ~ Processing Arguments..."; HandleArguments(args); UpdateTitle(); Watch.Restart(); if (Decompress(Game)) { Game.Disassemble(); Revision = Game.GetClientRevision(); UpdateTitle(); Console.Title += (", Revision: " + Revision); if (!FileDirectory.EndsWith(Revision)) { FileDirectory += ("\\" + Revision); Directory.CreateDirectory(FileDirectory); } string headerDump = string.Empty; if (IsDumpingHeaders) { WriteLine($"Generating unique hashes for Outgoing({Game.OutgoingMessages.Count})/Incoming({Game.IncomingMessages.Count}) messages..."); headerDump += DumpHeaders(Game, true); headerDump += "\r\n\r\n"; headerDump += DumpHeaders(Game, false); WriteLine($"Unique Message Hashes Generated: Outgoing[{UniqueOutMessageHashCount}], Incoming[{UniqueInMessageHashCount}]"); if (IsUpdatingHeaders) { WriteLine("Replacing previous Outgoing/Incoming headers with hashes..."); PreviousGame.Decompress(); PreviousGame.Disassemble(); string fileHeader = $"//Current: {Game.GetClientRevision()}\r\n//Previous: {PreviousGame.GetClientRevision()}\r\n"; OutgoingHeaders = (fileHeader + UpdateHeaders( OutgoingHeadersPath, Game, PreviousGame, true)); IncomingHeaders = (fileHeader + UpdateHeaders( IncomingHeadersPath, Game, PreviousGame, false)); } } Game.BypassOriginCheck(); Game.BypassRemoteHostCheck(); Game.ReplaceRSAKeys(Exponent, Modulus); WriteLine("Assembling..."); Game.Assemble(); byte[] reconstructed = (IsCompressingClient ? Compress(Game) : Game.ToByteArray()); Watch.Stop(); WriteLine($"Finished! | Completion Time: {Watch.Elapsed:s\\.ff} Seconds"); string clientPath = $"{FileDirectory}\\Habbo.swf"; File.WriteAllBytes(clientPath, reconstructed); string rsaKeysPath = $"{FileDirectory}\\RSAKeys.txt"; File.WriteAllText(rsaKeysPath, string.Format( "Exponent(e): {0:x}\r\nModulus(n): {1}\r\nPrivate Exponent(d): {2}", Exponent, Modulus, PrivateExponent)); Console.WriteLine("Client: " + clientPath); Console.WriteLine("RSA Keys: " + rsaKeysPath); if (!string.IsNullOrWhiteSpace(headerDump)) { string headersPath = $"{FileDirectory}\\Headers.txt"; File.WriteAllText(headersPath, headerDump); Console.WriteLine("Headers: " + headersPath); if (IsUpdatingHeaders) { string inPath = $"{FileDirectory}\\{Path.GetFileName(IncomingHeadersPath)}"; string outPath = $"{FileDirectory}\\{Path.GetFileName(OutgoingHeadersPath)}"; File.WriteAllText(outPath, OutgoingHeaders); Console.WriteLine("Client Outgoing Headers: " + outPath); File.WriteAllText(inPath, IncomingHeaders); Console.WriteLine("Client Incoming Headers: " + inPath); } } WriteLine(); } else { WriteLine($"File decompression failed! | {Game.Compression}"); } Console.CursorVisible = true; Console.ReadKey(true); }
public DirectoryDataGridViewRow(FileDirectory fd) { this.fd = fd; }
private static bool ParseFilePath(string[] args) { // Check if we received anything. if (args == null || args.Length == 0) { MessageBox.Show( "Please specify a text file to format on the command line.", "StoryFormatter - Invalid command line", MessageBoxButtons.OK); return(false); } // Combine the whole argument list to single path. var path = String.Join(" ", args); // Then check if that path exists. if (!File.Exists(path)) { MessageBox.Show( $@"Cannot find: {path} Please specify a text file to format on the command line.", "StoryFormatter - Invalid command line", MessageBoxButtons.OK); return(false); } FileStory = new FileInfo(path); FileDirectory = FileStory.Directory; FileBaseName = FileStory.NameWithoutExtension(); FileBasePath = Path.Combine(FileDirectory.FullName, FileBaseName); // Look for the ini file in the file's directory, and any parent location. // Or if that fails, in the executable directory. FileIni = FileDirectory.SearchUpFor("StoryFormatter.ini") ?? new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StoryFormatter.ini")); // Check that we have an ini file. if (!FileIni.Exists) { MessageBox.Show( $@"StoryFormatter.ini file missing from path: {FileDirectory.FullName} Please provide a StoryFormatter.ini file in the same directory as your story, or any parent, or at the StoryFormatter.exe.", "StoryFormatter - Invalid command line", MessageBoxButtons.OK); return(false); } // Some more checks. if (FileStory.Length > 250 * 1024) { MessageBox.Show( $@"File too large: {path} Please specify a text file no larger than 250Kb.", "StoryFormatter - Invalid command line", MessageBoxButtons.OK); return(false); } // Read the file and count the lines. FileLines = File.ReadAllLines(FileStory.FullName); // Some more checks. if (FileLines.Length > 10000) { MessageBox.Show( $@"File has too many lines: {path} Please specify a text file with no more than 10000 lines.", "StoryFormatter - Invalid command line", MessageBoxButtons.OK); return(false); } // Read the Ini file. Ini = new IniReader(FileIni.FullName, IniReader.InvalidSectionStrategy.Merge, IniReader.DuplicateSectionStrategy.Merge, IniReader.DuplicateKeyStrategy.Replace, StringComparer.OrdinalIgnoreCase); return(true); }
public static UITextureAtlas CreateTextureAtlas(string atlasName, string filename, FileDirectory dir, string[] spriteNames, int rows, int cols) { Texture2D texture2D = LoadTextureFromFile(GetFilePath(dir, filename + ".png")); Debug.Print(texture2D.width, texture2D.height); UITextureAtlas atlas = ScriptableObject.CreateInstance <UITextureAtlas>(); Material material = UnityEngine.Object.Instantiate <Material>(UIView.GetAView().defaultAtlas.material); material.mainTexture = texture2D; atlas.material = material; atlas.name = atlasName; float spriteWidth = 1.0f / cols; float spriteHeight = 1.0f / rows; for (int i = 0; i < spriteNames.Length; i++) { float x = (i % cols) / (float)cols; float y = (1.0f - spriteHeight) - ((i / cols) / (float)rows); atlas.AddSprite(new UITextureAtlas.SpriteInfo { name = spriteNames[i], texture = texture2D, region = new Rect(x, y, spriteWidth, spriteHeight) }); } return(atlas); }
protected override void OnStop() { this.timer1.Enabled = false; Safe.KillProcess("Pub.Class.ToSwf"); FileDirectory.FileWrite("ToSwfService.log".GetMapPath(), "[{0}] - ToSwfService服务已关闭!".FormatWith(DateTime.Now.ToDateTime())); }
private static bool asduReceivedHandler(object parameter, ASDU asdu) { Console.WriteLine(asdu.ToString()); if (asdu.TypeId == TypeID.M_SP_NA_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var val = (SinglePointInformation)asdu.GetElement(i); Console.WriteLine(" IOA: " + val.ObjectAddress + " SP value: " + val.Value); Console.WriteLine(" " + val.Quality.ToString()); } } else if (asdu.TypeId == TypeID.M_ME_TE_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var msv = (MeasuredValueScaledWithCP56Time2a)asdu.GetElement(i); Console.WriteLine(" IOA: " + msv.ObjectAddress + " scaled value: " + msv.ScaledValue); Console.WriteLine(" " + msv.Quality.ToString()); Console.WriteLine(" " + msv.Timestamp.ToString()); } } else if (asdu.TypeId == TypeID.M_ME_TF_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var mfv = (MeasuredValueShortWithCP56Time2a)asdu.GetElement(i); Console.WriteLine(" IOA: " + mfv.ObjectAddress + " float value: " + mfv.Value); Console.WriteLine(" " + mfv.Quality.ToString()); Console.WriteLine(" " + mfv.Timestamp.ToString()); Console.WriteLine(" " + mfv.Timestamp.GetDateTime().ToString()); } } else if (asdu.TypeId == TypeID.M_SP_TB_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var val = (SinglePointWithCP56Time2a)asdu.GetElement(i); Console.WriteLine(" IOA: " + val.ObjectAddress + " SP value: " + val.Value); Console.WriteLine(" " + val.Quality.ToString()); Console.WriteLine(" " + val.Timestamp.ToString()); } } else if (asdu.TypeId == TypeID.M_ME_NC_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var mfv = (MeasuredValueShort)asdu.GetElement(i); Console.WriteLine(" IOA: " + mfv.ObjectAddress + " float value: " + mfv.Value); Console.WriteLine(" " + mfv.Quality.ToString()); } } else if (asdu.TypeId == TypeID.M_ME_NB_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var msv = (MeasuredValueScaled)asdu.GetElement(i); Console.WriteLine(" IOA: " + msv.ObjectAddress + " scaled value: " + msv.ScaledValue); Console.WriteLine(" " + msv.Quality.ToString()); } } else if (asdu.TypeId == TypeID.M_ME_ND_1) { for (int i = 0; i < asdu.NumberOfElements; i++) { var msv = (MeasuredValueNormalizedWithoutQuality)asdu.GetElement(i); Console.WriteLine(" IOA: " + msv.ObjectAddress + " scaled value: " + msv.NormalizedValue); } } else if (asdu.TypeId == TypeID.C_IC_NA_1) { if (asdu.Cot == CauseOfTransmission.ACTIVATION_CON) { Console.WriteLine((asdu.IsNegative ? "Negative" : "Positive") + "confirmation for interrogation command"); } else if (asdu.Cot == CauseOfTransmission.ACTIVATION_TERMINATION) { Console.WriteLine("Interrogation command terminated"); } } else if (asdu.TypeId == TypeID.F_DR_TA_1) { Console.WriteLine("Received file directory:\n------------------------"); int ca = asdu.Ca; for (int i = 0; i < asdu.NumberOfElements; i++) { FileDirectory fd = (FileDirectory)asdu.GetElement(i); Console.Write(fd.FOR ? "DIR: " : "FILE: "); Console.WriteLine("CA: {0} IOA: {1} Type: {2}", ca, fd.ObjectAddress, fd.NOF.ToString()); } } else { Console.WriteLine("Unknown message type!"); } return(true); }
public DirectoryTreeNode(FileDirectory fd) { this.fd = fd; }
public void MPP2010() { WriteLog("先关闭Microsoft PowerPoint 2010..."); Safe.KillProcess("POWERPNT"); WriteLog("ispring2swf \"" + pptName + "\" \"" + swfName + "\""); Safe.RunAsync("POWERPNT", System.Diagnostics.ProcessWindowStyle.Normal, "\"" + pptName + "\""); WriteLog("正在打开Microsoft PowerPoint 2010..."); setTimeout((i1) => { IntPtr splash = WinApi.FindWindow("MsoSplash", "正在打开 - Microsoft PowerPoint"); if (splash != IntPtr.Zero) { WriteLog("找到“正在打开 - Microsoft PowerPoint”窗口!-" + splash.ToString()); WriteLog("等待“正在打开 - Microsoft PowerPoint”窗口关闭!"); setTimeout(() => { splash = WinApi.FindWindow("MsoSplash", "正在打开 - Microsoft PowerPoint"); if (splash == IntPtr.Zero) { WriteLog("“正在打开 - Microsoft PowerPoint”窗口已关闭!"); setTimeout((i2) => { IntPtr ppt = WinApi.FindWindow("PPTFrameClass", null); if (ppt != IntPtr.Zero) { WriteLog("找到“Microsoft PowerPoint”主窗口并激活窗口!-" + ppt.ToString()); setTimeout(() => { WinApi.SetActiveWindow(ppt); foreach (string key in Keys) { SendKeys.SendWait(key); WriteLog("模拟用户按: " + (key == "%" ? "alt" : key) + "键!"); Thread.Sleep(100); } FileDirectory.FileDelete(swfName); WriteLog("删除老的转换文件: " + swfName); setTimeout(() => { IList <WinApi.WindowInfo> childWindowNames = WinApi.GetAllDesktopWindows(); WinApi.WindowInfo info = childWindowNames.Where(p => p.szWindowName.IndexOf("Generating Flash Movie") != -1).FirstOrDefault(); if (info.IsNotNull() && info.hWnd != IntPtr.Zero) { WriteLog("找到“Generating Flash Movie”窗口!-" + info.hWnd.ToString()); WriteLog("名称:" + info.szWindowName); string fileName = info.szWindowName.Substring(23).Left(50); string filePath = DefaultPath + fileName + "\\" + fileName + ".swf"; setTimeout((i3) => { if (!WinApi.IsWindow(info.hWnd)) { WriteLog("完成转换swf!"); setTimeout(() => { IntPtr h = WinApi.FindWindow(null, fileName); if (h != IntPtr.Zero) { WriteLog("找到文件夹句柄,并关闭!"); WinApi.SendMessage(h, WMessages.WM_CLOSE, 0, 0); return(true); } WriteLog("找不到文件夹句柄:" + fileName); return(false); }, 1000, 5); setTimeout(() => { if (FileDirectory.FileExists(filePath)) { setTimeout(() => { FileDirectory.FileCopy(filePath, swfName, false); FileDirectory.FileDelete(filePath); FileDirectory.DirectoryDelete(filePath.GetParentPath('\\')); Exit(); return(true); }, 1000, 1); return(true); } WriteLog("没找到转换后文件:" + filePath, true); return(false); }, 1000, 60, () => { WriteLog("文件不存在,关闭!" + filePath); Exit(); }); return(true); } WriteLog("正在转换swf-" + i3.ToString(), true); return(false); }, 2000, 0); return(true); } return(false); }, 1000, 60, () => { WriteLog("找不到“Generating Flash Movie”窗口,退出!"); Exit(); }); return(true); }, 1000, 1); return(true); } WriteLog("查找“Microsoft PowerPoint”主窗口!-" + i2.ToString(), true); return(false); }, 1000, 60, () => { WriteLog("找不到“Microsoft PowerPoint”主窗口,退出!"); Exit(); }); return(true); } return(false); }, 1000, 60, () => { WriteLog("“正在打开 - Microsoft PowerPoint”未关闭,退出!"); Exit(); }); return(true); } WriteLog("查找“正在打开 - Microsoft PowerPoint”窗口!-" + i1.ToString(), true); return(false); }, 1000, 60, () => { WriteLog("找不到“正在打开 - Microsoft PowerPoint”窗口,退出!"); Exit(); }); }
public FileOrderRepository(DateTime date) { _filePath = FileDirectory.GetOrderFileFullName(date); }
private void frmEntity_Load(object sender, EventArgs e) { //Data.ConnString = WebConfig.GetConn("ConnString"); textBox1.Text = string.IsNullOrEmpty(WebConfig.GetApp("Project")) ? "Test" : WebConfig.GetApp("Project"); xmlFile = "".GetMapPath() + textBox1.Text + ".xml"; bool xmlExist = FileDirectory.FileExists(xmlFile); IList <TableEntity> list = TableFactory.GetTable(); foreach (TableEntity entity in list) { listBox.Items.Add((entity.isView ? "* " : "") + entity.Name, entity.isView ? false : true); if (!xmlExist) { OPList.Add(new TableOperator() { Table = entity.Name }); } else { Xml2 xml = new Xml2(xmlFile); string[] attrs = xml.GetAttr("root//Table[@Name='" + entity.Name + "']", "Name|Insert|Update|Delete|IsExistByID|SelectByID|SelectPageList|SelectListByFK|SelectListByAll|Entity|UpdateAndInsert").Split('|'); if (attrs[0].IsNullEmpty()) { OPList.Add(new TableOperator() { Table = entity.Name }); var info = OPList[OPList.Count - 1]; xml.AddNode("root", "Table", "Name|Entity|Insert|Update|Delete|IsExistByID|SelectByID|SelectPageList|SelectListByFK|SelectListByAll|UpdateAndInsert", "{0}|{9}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{10}".FormatWith( info.Table, info.Insert.ToString().ToLower(), info.Update.ToString().ToLower(), info.DeleteByID.ToString().ToLower(), info.IsExistByID.ToString().ToLower(), info.SelectByID.ToString().ToLower(), info.SelectPageList.ToString().ToLower(), info.SelectListByFK.ToString().ToLower(), info.SelectListByAll.ToString().ToLower(), info.Entity.ToString().ToLower(), info.UpdateAndInsert.ToString().ToLower() )); xml.Save(); } else { OPList.Add(new TableOperator() { Table = entity.Name, Insert = attrs[1] == "true" ? true : false, Update = attrs[2] == "true" ? true : false, DeleteByID = attrs[3] == "true" ? true : false, IsExistByID = attrs[4] == "true" ? true : false, SelectByID = attrs[5] == "true" ? true : false, SelectPageList = attrs[6] == "true" ? true : false, SelectListByFK = attrs[7] == "true" ? true : false, SelectListByAll = attrs[8] == "true" ? true : false, Entity = attrs[9] == "true" ? true : false, UpdateAndInsert = attrs[10] == "true" ? true : false, }); } xml.Close(); } } if (!xmlExist) { CreateXML(xmlFile); } if (listBox.Items.Count > 0) { listBox.SelectedIndex = 0; } this.Text = "Entity Tool [{2}] - {1}连接共有{0}个表".FormatWith(listBox.Items.Count, Data.DBType, TemplateName); }
/// <summary> /// 序列成bytes文件 /// </summary> /// <param name="o">对像</param> /// <param name="fileName">文件名</param> public void SerializeFile <T>(T o, string fileName) { FileDirectory.FileDelete(fileName); FileDirectory.FileWrite(fileName, Serialize(o).ToUTF8()); }
private void populateTreeButton_Click(object sender, EventArgs e) { String content = directoryInput.Text.Trim(); int res = Helper.getInstance().ValidateDirectoryInput(content); if (res == 0){ //Helper.getInstance().ThrowError(HelperErrors.NOT_A_DIRECTORY_OR_COMMAND); return; } else if(res == 1){ //Helper.getInstance().RunCommand(content, cmdTextBox); return; } //Root directory has null parent; FileDirectory rd = new FileDirectory(content, null); if(false){ DirectoryTreeViewThreadHandler tvht = new DirectoryTreeViewThreadHandler(rd, directoryTreeView); DirectoryThreadHandler dht = new DirectoryThreadHandler(rd, ""); Cursor.Current = Cursors.WaitCursor; try{ if (!tvht.checkNodeExists(directoryTreeView)) { Thread handleDirectory = new Thread(new ThreadStart(dht.Handle)); handleDirectory.Start(); handleDirectory.Join(); Thread handleTreeView = new Thread(new ThreadStart(tvht.HandleDirectoryTree)); handleTreeView.Start(); handleTreeView.Join(); directoryTreeView.Nodes.Add(tvht.getRoot()); } }finally{ Cursor.Current = Cursors.Default; } } }
public override void Handle() { this.fd = DirectoryHandler.getInstance().HandleDirectory(this.fd, filePattern); }
private void doRun() { if (listBox.Items.Count <= 0) return; string tabName = listBox.Items[listBox.SelectedIndex].ToString(); if (string.IsNullOrEmpty(tabName)) return; bool isView = false; if (tabName.IndexOf("* ") == 0) { tabName = tabName.Substring(2); isView = true; } string dalCode = string.Empty; string idalCode = string.Empty; string bllCode = string.Empty; string sqlCode = string.Empty; string baseCode = string.Empty; if (!string.IsNullOrEmpty(config.ModelPath) && config.OPList[listBox.SelectedIndex].Entity && config.DesignPattern == "Model-DAL-BLL") { tabPage1.Text = textBox1.Text + ".Model." + tabName; textBox.Text = TableStructureFactory.GetTableStructCode(config, tabName, textBox1.Text, out idalCode, out dalCode, out bllCode, out sqlCode, isView); Pub.Class.FileDirectory.DirectoryCreate(config.ModelPath + "\\Model\\"); Pub.Class.FileDirectory.FileDelete(config.ModelPath + "\\Model\\" + tabName + ".cs"); FileDirectory.FileWrite(config.ModelPath + "\\Model\\" + tabName + ".cs", textBox.Text); } if (!string.IsNullOrEmpty(config.EntityPath) && config.OPList[listBox.SelectedIndex].Entity && config.DesignPattern != "Model-DAL-BLL") { tabPage1.Text = textBox1.Text + ".Entity." + tabName; textBox.Text = TableStructureFactory.GetTableStructCode(config, tabName, textBox1.Text, out baseCode, out sqlCode, isView); Pub.Class.FileDirectory.DirectoryCreate(config.EntityPath + "\\Entity\\"); Pub.Class.FileDirectory.FileDelete(config.EntityPath + "\\Entity\\" + tabName + ".cs"); FileDirectory.FileWrite(config.EntityPath + "\\Entity\\" + tabName + ".cs", textBox.Text); } if (config.DesignPattern == "Model-DAL-BLL" && !string.IsNullOrEmpty(config.DALPath) && config.OPList[listBox.SelectedIndex].Entity) { tabPage2.Text = textBox1.Text + "." + config.TemplateName.Split('-')[3] + "DAL." + tabName + "DAL"; textBox2.Text = dalCode; Pub.Class.FileDirectory.DirectoryCreate(config.DALPath + "\\" + config.TemplateName.Split('-')[3] + "DAL" + "\\"); Pub.Class.FileDirectory.FileDelete(config.DALPath + "\\" + config.TemplateName.Split('-')[3] + "DAL" + "\\" + tabName + "DAL.cs"); Pub.Class.FileDirectory.DirectoryCreate(config.IDALPath + "\\IDAL\\"); Pub.Class.FileDirectory.FileDelete(config.IDALPath + "\\IDAL\\I" + tabName + "DAL.cs"); if (!string.IsNullOrEmpty(textBox2.Text.Trim())) { FileDirectory.FileWrite(config.DALPath + "\\" + config.TemplateName.Split('-')[3] + "DAL" + "\\" + tabName + "DAL.cs", textBox2.Text); FileDirectory.FileWrite(config.IDALPath + "\\IDAL\\I" + tabName + "DAL.cs", idalCode); } else { Pub.Class.FileDirectory.FileDelete(config.DALPath + "\\" + config.TemplateName.Split('-')[3] + "DAL" + "\\" + tabName + "DAL.cs"); Pub.Class.FileDirectory.FileDelete(config.IDALPath + "\\IDAL\\I" + tabName + "DAL.cs"); } tabPage3.Text = textBox1.Text + ".BLL." + tabName + "BLL"; textBox3.Text = bllCode; Pub.Class.FileDirectory.DirectoryCreate(config.BLLPath + "\\BLL\\"); Pub.Class.FileDirectory.FileDelete(config.BLLPath + "\\BLL\\" + tabName + "BLL.cs"); if (!string.IsNullOrEmpty(textBox3.Text.Trim())) { FileDirectory.FileWrite(config.BLLPath + "\\BLL\\" + tabName + "BLL.cs", textBox3.Text); sbSqlCode.AppendLine(sqlCode); textBox4.Text = sqlCode; } else { Pub.Class.FileDirectory.FileDelete(config.BLLPath + "\\BLL\\" + tabName + "BLL.cs"); } if (btnStart.Enabled) Clipboard.SetDataObject(textBox.Text); } if (config.DesignPattern != "Model-DAL-BLL" && !string.IsNullOrEmpty(config.FactoryPath) && config.OPList[listBox.SelectedIndex].Entity) { tabPage2.Text = textBox1.Text + "." + config.DesignPatternExtName + "." + tabName + "" + config.DesignPatternExtName + ""; textBox2.Text = baseCode; Pub.Class.FileDirectory.DirectoryCreate(config.FactoryPath + "\\" + config.DesignPatternExtName + "\\"); Pub.Class.FileDirectory.FileDelete(config.FactoryPath + "\\" + config.DesignPatternExtName + "\\" + tabName + "" + config.DesignPatternExtName + ".cs"); if (!string.IsNullOrEmpty(textBox2.Text.Trim())) { FileDirectory.FileWrite(config.FactoryPath + "\\" + config.DesignPatternExtName + "\\" + tabName + "" + config.DesignPatternExtName + ".cs", textBox2.Text); sbSqlCode.AppendLine(sqlCode); textBox3.Text = sqlCode; } else { Pub.Class.FileDirectory.FileDelete(config.FactoryPath + "\\" + config.DesignPatternExtName + "\\" + tabName + "" + config.DesignPatternExtName + ".cs"); } if (btnStart.Enabled) Clipboard.SetDataObject(textBox.Text); } }
/// <summary> /// json文件反序列化成对像 /// </summary> /// <typeparam name="T">对像类型</typeparam> /// <param name="fileName">文件名</param> /// <returns>对像</returns> public T DeserializeFile <T>(string fileName) { string data = FileDirectory.FileReadAll(fileName, Encoding.UTF8); return(Deserialize <T>(data)); }
public DirectoryTreeViewThreadHandler(FileDirectory fd, TreeView tree) { this.fd = fd; this.tree = tree; }
public void AddXStageProject(Uri uri) { pf.XStageProjects.Add(FileDirectory.MakeRelativeUri(uri)); XStageProjectListChanged.Invoke(); }
public void UploadMap() { ErrorText.enabled = false; if (!CheckUserInput()) { return; } string uniqueTempPathInProject = GetUniqueTempPath() + ".zip"; string tempPathForWrapperFolder = GetUniqueTempPath(); FileDirectory.DirectoryCopyWithSourceFolder(MapFolderPathInputField.text, tempPathForWrapperFolder, true); //Move Map Folder into a wrapper folder so map folder lies within the zip try { //Zip everything ZipUtil.CreateZipFromFolder(uniqueTempPathInProject, null, tempPathForWrapperFolder); } catch (Exception e) { OnError("Could not package map. Is the path you entered correct? Exception is:\n" + e.Message); return; } Debug.Log("Writing map to temp file: " + uniqueTempPathInProject); HttpClient httpClient = new HttpClient(); MultipartFormDataContent form = new MultipartFormDataContent(); form.Add(new StringContent("{\"isRanked\":" + (RankedToggle.isOn ? "true" : "false") + " }", Encoding.UTF8, "application/json"), "metadata"); FileStream fileStream = new FileStream(uniqueTempPathInProject, FileMode.Open); StreamContent streamContent = new StreamContent(fileStream); streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/zip"); form.Add(streamContent, "file", Path.GetFileName(uniqueTempPathInProject)); try { var token = GetAccessTokenFromOwnAuthSvr(); httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + token.AccessToken); } catch (Exception e) { OnError("Login failed, please check connection and login data. Exception is : \n" + e.Message); return; } httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); try { HttpResponseMessage res = httpClient.PostAsync(Config.ApiUrl + "/maps/upload", form).Result; try { res.EnsureSuccessStatusCode(); } catch (Exception e) { OnError( "JAVA-API complains: \n" + res.Content.ReadAsStringAsync().Result + "\n\nException is: \n" + e.Message); } } catch (Exception e) { OnError("Sending failed. Maybe map is too big... Exception was: \n" + e.Message); } httpClient.Dispose(); form.Dispose(); GenericInfoPopup.ShowInfo("Uploaded Successful... Check the vault to see ;)"); }
public override string ToString() { return(FileDirectory.ConvertToString()); }
public static UITextureAtlas CreateTextureAtlas(string atlasName, string[] spriteNames, FileDirectory dir) { int maxSize = 1024; Texture2D texture2D = new Texture2D(maxSize, maxSize, TextureFormat.ARGB32, false); Texture2D[] textures = new Texture2D[spriteNames.Length]; Rect[] regions = new Rect[spriteNames.Length]; for (int i = 0; i < spriteNames.Length; i++) { textures[i] = TextureLoader.LoadTextureFromFile(GetFilePath(dir, spriteNames[i] + ".png")); } regions = texture2D.PackTextures(textures, 2, maxSize); UITextureAtlas textureAtlas = ScriptableObject.CreateInstance <UITextureAtlas>(); Material material = UnityEngine.Object.Instantiate <Material>(UIView.GetAView().defaultAtlas.material); material.mainTexture = texture2D; textureAtlas.material = material; textureAtlas.name = atlasName; for (int i = 0; i < spriteNames.Length; i++) { UITextureAtlas.SpriteInfo item = new UITextureAtlas.SpriteInfo { name = spriteNames[i], texture = textures[i], region = regions[i], }; textureAtlas.AddSprite(item); } return(textureAtlas); }
public FileSelectedEventArgs(FileDirectory fd) { Directory = fd; }
public override void OnCreate() { base.OnCreate(); System.Net.ServicePointManager.DefaultConnectionLimit = 10; thisApp = this; #if !DEBUG #if PREVIEW Insights.Initialize("5c0f70a4d1326b40377a47d4cbea702a24c978f9", this); #elif TESTING Insights.Initialize("90497c422289e75c72756ed2e324aac80fcb559e", this); #endif #endif deviceId = Android.Provider.Settings.Secure.GetString(this.ContentResolver, Android.Provider.Settings.Secure.AndroidId); if (string.IsNullOrEmpty(deviceId)) { deviceId = PreferenceManager.GetDefaultSharedPreferences(this).GetString(PREF_DEVICEID, ""); if (deviceId.Length == 0) { deviceId = Guid.NewGuid().ToString(); var pref = PreferenceManager.GetDefaultSharedPreferences(this); var prefEditor = pref.Edit(); prefEditor.PutString(PREF_DEVICEID, deviceId); prefEditor.Commit(); } } else { deviceId = Sha1Hash(deviceId); } #if DEBUG var sdCardRoot = Android.OS.Environment.ExternalStorageDirectory.Path; var redRoot = Path.Combine(sdCardRoot, @"RedTemp"); DirectoryInfo di = new DirectoryInfo(redRoot); if (!di.Exists) { di.Create(); } FileDirectory.Init(redRoot, redRoot); #else FileDirectory.Init(FilesDir.AbsolutePath, GetExternalFilesDir(null).AbsolutePath); #endif IoCContainer.Instance.RegisterInterface <IDirectory, FileDirectory>(); IoCContainer.Instance.RegisterInterface <IDevice, AndroidDevice>(); IoCContainer.Instance.RegisterInterface <INetwork, AndroidNetwork>(); IoCContainer.Instance.RegisterInterface <IPackageFile, PackageFile>(); IoCContainer.Instance.RegisterInterface <ICryptogram, AndroidCryptogram>(); IoCContainer.Instance.RegisterInterface <ILogger, AndroidLogger>(); AsyncHelpers.RunSync(GlobalAccess.Instance.Init); var serviceCountryMapList = ConfigurationService.GetAllCountryMap(); DataCache.INSTATNCE.ServiceCountryList = new string[serviceCountryMapList.Count]; for (int i = 0; i < serviceCountryMapList.Count; ++i) { DataCache.INSTATNCE.ServiceCountryList[i] = this.Resources.GetString( this.Resources.GetIdentifier( "ServiceCountry_Name_" + serviceCountryMapList[i].CountryCode, "string", this.PackageName)); } }
public FileDirectory(string path, FileDirectory parent) { this.path = path; this.parent = parent; }
/// <summary> /// bytes文件反序列化成对像 /// </summary> /// <typeparam name="T">对像类型</typeparam> /// <param name="fileName">文件名</param> /// <returns>对像</returns> public T DeserializeFile <T>(string fileName) { byte[] data = FileDirectory.FileReadAll(fileName, Encoding.UTF8).FromBase64(); return(Deserialize <T>(data)); }
public DirectoryThreadHandler(FileDirectory fd, string filePattern) { this.fd = fd; this.filePattern = filePattern; }