private void tv_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { //Discarded unreachable code: IL_0048, IL_006a, IL_006c, IL_007c, IL_009e int num2 = default(int); int num3 = default(int); try { int num = 1; if (!LikeOperator.LikeString(Declarer.startPath, "*Debug", Microsoft.VisualBasic.CompareMethod.Binary)) { ProjectData.ClearProjectError(); num2 = 1; } num = 3; if (Microsoft.VisualBasic.FileIO.FileSystem.FileExists(e.Node.Name)) { num = 4; TFile.ExecFileFolder(tv.SelectedNode.Name); } } catch (Exception obj) when((obj is Exception && num2 != 0) & (num3 == 0)) { ProjectData.SetProjectError((Exception)obj); /*Error near IL_009c: Could not find block for branch target IL_006c*/; } if (num3 != 0) { ProjectData.ClearProjectError(); } }
public void WriteFile(String filename, TFile data) { System.IO.Directory.CreateDirectory(STORAGE_DIR); filename = STORAGE_DIR + filename; BinaryFormatter formatter = new BinaryFormatter(); FileStream fs = new FileStream(filename, FileMode.Create); try { lock (this) { formatter.Serialize(fs, data); } String txt = Encoding.ASCII.GetString(data.Data); //Console.WriteLine("Storage: File Write: " + filename + " content: " + txt); } catch (SerializationException e) { Console.WriteLine("Storage: Failed to write File " + e.Message); } finally { fs.Close(); } }
public static FileTreeNode UploadTextFile(string sContent, string nodeName, string strID, string strInfo, ContentKind cKind, string strApp) { TFile file = new TFile(); file.FileContent = System.Text.Encoding.UTF8.GetBytes(sContent); file.FileId = strID; file.FileInfo = strInfo; file.FileKind = (TContentKind)cKind; file.FileSize = file.FileContent.Length; file.FromApp = strApp; file.FileOwner = GetValidator().VssID; ClientAdapt.Open(); TVssService.Client client = ClientAdapt.GetClient(); string strNewID = client.Put(GetValidator(), file); ClientAdapt.Close(); FileTreeNode fileTreeNode = new FileTreeNode(); System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); fileTreeNode.CreateDate = (uint)(DateTime.Now - startTime).TotalSeconds; fileTreeNode.FileID = strNewID; fileTreeNode.FileInfo = strInfo; fileTreeNode.FileKind = cKind; fileTreeNode.FileSize = (ulong)file.FileContent.Length; fileTreeNode.FromApp = strApp; fileTreeNode.SubNodes = null; fileTreeNode.FileOwner = GetValidator().VssID; fileTreeNode.NodeName = nodeName; return(fileTreeNode); }
public static void ExportUnitScene(UnityScene unitScene) { //write avatar //step1 write mesh foreach (var item in unitScene.avatarObj) { var avatar = item.Value; TFile file = new TFile(Export.config.outdir).ResolvePath(avatar.refName + ".km"); file.WriteAMF(avatar); } //write animation foreach (var item in unitScene.animationDataObj) { var path = item.Key.Replace("assets/", ""); var clip = item.Value; TFile file = new TFile(Export.config.outdir).ResolvePath(path); file.WriteAMF(clip); } foreach (var item in unitScene.materialObj) { string key = item.Key; string value = TFile.Join(Export.config.outdir, item.Value); var file = TFile.AppliationRoot.ResolvePath(key); file.CopyTo(value); } }
/// <summary> /// 上传一个文件,返回节点描述符。 /// </summary> /// <param name="sPath"></param> /// <returns></returns> public static FileTreeNode UploadFile(string sPath, string strID, string strInfo, ContentKind cKind, string strApp) { TFile file = new TFile(); file.FileContent = File.ReadAllBytes(sPath); FileStream fs = File.OpenRead(sPath); file.FileId = strID; file.FileInfo = strInfo; file.FileKind = (TContentKind)cKind; file.FileSize = fs.Length; file.FromApp = strApp; file.FileOwner = GetValidator().VssID; ClientAdapt.Open(); TVssService.Client client = ClientAdapt.GetClient(); string strNewID = client.Put(GetValidator(), file); ClientAdapt.Close(); FileTreeNode fileTreeNode = new FileTreeNode(); System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); fileTreeNode.CreateDate = (uint)(DateTime.Now - startTime).TotalSeconds; fileTreeNode.FileID = strNewID; fileTreeNode.FileInfo = strInfo; fileTreeNode.FileKind = cKind; fileTreeNode.FileSize = (ulong)fs.Length; fileTreeNode.FromApp = strApp; fileTreeNode.SubNodes = null; fileTreeNode.FileOwner = GetValidator().VssID; fileTreeNode.NodeName = fs.Name.Substring(fs.Name.LastIndexOf("\\") + 1); return(fileTreeNode); }
public async Task <Unit> Handle(CreateOneFileCommand request, CancellationToken cancellationToken) { TFile file = new TFile(); var fil = request.File; file.ArchivoData = trans(fil); file.TipoArchivo = fil.ContentType; file.Estado = true; file.Nombre = fil.FileName; file.Descripcion = (fil.Name == "nodesc") ? "" : fil.Name; file.NroDocReferencia = request.NroDocReferencia; file.NroSubDocReferencia = request.NroSubDocReferencia; file.CodTablaRef = request.CodTablaRef; if (file.TipoArchivo != null) { if (file.TipoArchivo.Contains("image") || file.TipoArchivo.Contains("video") || file.TipoArchivo.Contains("pdf")) { file.PreviewData = await IService.getImagePreview(file); } } _context.TFile.Add(file); await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
public async Task <Unit> Handle(CreateListFilesCommand request, CancellationToken cancellationToken) { TFile file; IFormFileCollection files = request.File; foreach (var fil in files) { file = new TFile(); if (fil.Length < 0) { throw new GeneralFailureException("Imagen no valida"); } file.ArchivoData = trans(fil); file.TipoArchivo = fil.ContentType; file.Estado = true; file.Nombre = fil.FileName; file.Descripcion = (fil.Name == "nodesc") ? "" : fil.Name; file.NroDocReferencia = request.NroDocReferencia; file.NroSubDocReferencia = request.NroSubDocReferencia; file.CodTablaRef = request.CodTablaRef; if (file.TipoArchivo != null) { if (file.TipoArchivo.Contains("image") || file.TipoArchivo.Contains("video") || file.TipoArchivo.Contains("pdf")) { file.PreviewData = await IService.getImagePreview(file); } } _context.TFile.Add(file); } await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
//載入資源列表 private void LoadVersion(string versionName) { #if UNITY_TVOS && !UNITY_EDITOR string path = Application.temporaryCachePath + "/" + TinyContext.Instance.LanguagePath + "/" + "Versions/"; #else string path = Application.persistentDataPath + "/" + TinyContext.Instance.LanguagePath + "/" + "Versions/"; #endif byte[] datas = TFile.Load(path, versionName); if (datas == null) { return; } string json = System.Text.UTF8Encoding.UTF8.GetString(datas); rMD5Info[] info = TJson.DeserializeObject <rMD5Info[]>(json); if (mRecordMap != null) { mRecordMap.Clear(); } else { mRecordMap = new Dictionary <string, string>(); } for (int i = 0; i < info.Length; i++) { mRecordMap.Add(info[i].FlieName, info[i].MD5Code); } return; }
public static string getAnimationPath(AnimationClip clip) { var path = GetAssetPath(clip); path = TFile.Join(TFile.PathParent(path), getAnimationName(clip)); return(path.ToLower()); }
/// <exception cref="System.IO.IOException"/> private void CompareRun(string compress) { string[] supported = TFile.GetSupportedCompressionAlgorithms(); bool proceed = false; foreach (string c in supported) { if (c.Equals(compress)) { proceed = true; break; } } if (!proceed) { System.Console.Out.WriteLine("Skipped for " + compress); return; } options.compress = compress; string parameters = Parameters2String(options); CreateSeqFile(parameters, compress); ReadSeqFile(parameters, true); CreateTFile(parameters, compress); ReadTFile(parameters, true); CreateTFile(parameters, compress); ReadTFile(parameters, true); CreateSeqFile(parameters, compress); ReadSeqFile(parameters, true); }
public TFile ReadFile(String filename) { String path = STORAGE_DIR + filename; TFile outFile = null; //If read a file that if (!System.IO.File.Exists(path)) { throw new Exception("Storage: Read: File doesnt exist"); } FileStream fs = new FileStream(path, FileMode.Open); BinaryFormatter formatter = new BinaryFormatter(); try { outFile = (TFile)formatter.Deserialize(fs); String txt = Encoding.ASCII.GetString(outFile.Data); //Console.WriteLine("Storage: File readed: " + filename+" content: " + txt); } catch (SerializationException) { Console.WriteLine("Storage: Failed to read the file: " + path); } finally { fs.Close(); } return(outFile); }
/// <exception cref="System.IO.IOException"/> public virtual void TestSeeks() { string[] supported = TFile.GetSupportedCompressionAlgorithms(); bool proceed = false; foreach (string c in supported) { if (c.Equals(options.compress)) { proceed = true; break; } } if (!proceed) { System.Console.Out.WriteLine("Skipped for " + options.compress); return; } if (options.DoCreate()) { CreateTFile(); } if (options.DoRead()) { SeekTFile(); } }
public String Read(int fileRegister, SemanticType semantic, int dataRegister) { TFile file = Read(fileRegister, semantic); DataRegister[dataRegister] = file.Data; Console.WriteLine("#READ Read Action Saved At DataRegister " + dataRegister); return("#READ Result Data is : " + Encoding.ASCII.GetString(file.Data) + " froam Server " + file.responseServerId + " at Version " + file.VersionNumber); }
public async Task<ActionResult> Receive() { bool thumb = true; int thumb_width = 200; int thumb_height = 200; string name = Request.Headers["UploaderName"]; bool chunk = bool.Parse(Request.Headers["Chunk"]); if (chunk) { var fileName = Request.Headers["FileName"]; var size = int.Parse(Request.Headers["FileSize"]); CFile file = null; //Check it if there is a file with that name and if there is not create one if (!chunkFilesPath.ContainsKey(fileName)) { file = new CFile(Server.MapPath("~/uploads") + "/" + fileName, size); chunkFilesPath.Add(fileName, file); } //Write the partion of the file with the position. if (chunkFilesPath.TryGetValue(fileName, out file)) { var stream = Request.InputStream; var position = int.Parse(Request.Headers["ChunkPosition"]); file.Upload(stream, position); } //If it is %100 then remove it from the dictionary. if (file.Percent == 100) { chunkFilesPath.Remove(fileName); } return Json(true); } else { TFile file = new TFile(Server.MapPath("~/uploads/images"), Server.MapPath("~/uploads/thumbnails"), thumb_width, thumb_height); if (file.UploadAjax(Request.InputStream, name, thumb) == -1) //fail { return Json(false); } else //success { return Json(true); } } }
public static TFile CreateCarFile <TFile, TModel>() where TFile : BaseCarsFile <TModel>, new() where TModel : XmlCar, new() { TFile file = new TFile(); file.Cars = CreateCarsCollection <TModel>(); return(file); }
private IReadOnlyDictionary <string, object> GetBindingData(TFile file) { string path = _parent._strategy.GetPath(file); var dict = GetBindingData(path); _parent._strategy.GetRuntimeBindingContract(file, dict); return(dict); }
public void DeepAdd_DoesNotSkipExistingDirectories() { filesystem.AddFile(new Directory("subOne"), filesystem.RootDirectory); var file = new TFile { Name = "baz" }; filesystem.AddFile(file, "/subOne/subTwo", true); Assert.That(filesystem.GetPathOfFile(file), Is.EqualTo("/subOne/subTwo/baz")); }
private FileNode(FileNode parent, TFile file) { this.File = file; this.treeNode_ = parent.treeNode_.Add(file.BetterFileName ?? file.FileName); this.treeNode_.Data = this; this.filterNode_ = parent.filterNode_.AddChild(this); this.InitFile_(); }
private void Me_Startup(object sender, StartupEventArgs e) { //Discarded unreachable code: IL_012d, IL_017b, IL_017d, IL_018d, IL_01af int num = default(int); int num3 = default(int); try { ProjectData.ClearProjectError(); num = 1; int num2 = 2; Declarer.startPath = AppDomain.CurrentDomain.BaseDirectory; num2 = 3; Declarer.startPath = Declarer.startPath.Substring(0, checked (Declarer.startPath.Length - 1)); num2 = 4; if (MySettingsProperty.Settings.lang.Length < 1) { num2 = 5; MySettingsProperty.Settings.lang = TFile.ReadIni(Declarer.startPath + "\\lang.ini", "Language", "lang"); num2 = 6; MySettingsProperty.Settings.Save(); } num2 = 7; Declarer.xd.Load(Declarer.startPath + "\\langs\\" + MySettingsProperty.Settings.lang + ".xml"); num2 = 8; Declarer.xeL = Declarer.xd["LANG_TEXT"]; num2 = 9; SelfService.UpgradeSettings(); num2 = 10; if (MySettingsProperty.Settings.types.Length < 1) { num2 = 11; SelfService.InitSettings(); } num2 = 12; SelfService.UpdateExts(); num2 = 13; SelfService.VerifyKey(MySettingsProperty.Settings.key, ref Declarer.licenseType, ref Declarer.licensedPCs); num2 = 14; Thread thread = new Thread(CheckLatestVerOnStartup); num2 = 15; thread.Start(); } catch (Exception obj) when((obj is Exception && num != 0) & (num3 == 0)) { ProjectData.SetProjectError((Exception)obj); /*Error near IL_01ad: Could not find block for branch target IL_017d*/; } if (num3 != 0) { ProjectData.ClearProjectError(); } }
/// <summary> /// 下载一个文件,返回描述符。 /// </summary> /// <param name="sPath"></param> /// <param name="file"></param> /// <returns></returns> public static TFile DownloadFile(string sPath, FileTreeNode file) { string strFID = file.FileID; ClientAdapt.Open(); TVssService.Client client = ClientAdapt.GetClient(); TFile tFile = client.Get(GetValidator(), strFID); ClientAdapt.Close(); File.WriteAllBytes(sPath, tFile.FileContent); return(tFile); }
public String Copy(int fileRegisterRead, SemanticType semantic, int fileRegisterWrite, byte[] stringSalt) { Console.WriteLine("#COPY From File at Register: " + fileRegisterRead + " with " + semantic.ToString() + " Semantic and Writes to File at Register: " + fileRegisterWrite + " adding the salt: " + (new ASCIIEncoding()).GetString(stringSalt)); TFile readFile = Read(fileRegisterRead, semantic); String parte1 = Encoding.ASCII.GetString(readFile.Data); String parte2 = Encoding.ASCII.GetString(stringSalt); String data = parte1 + parte2; Write(fileRegisterWrite, (new ASCIIEncoding()).GetBytes(data)); return("#COPY Complete"); }
protected void Page_Load(object sender, EventArgs e) { if (Request.Params["data"] == null) { Response.Write("NOPARAMS"); Response.End(); return; } string sData = Request.Params["data"]; if (HttpContext.Current.Session["UserLogin"] == null) { //这里也可以根据类型不同,返回适当的情况! Response.Write("NOLOGIN"); Response.End(); return; } TValidator tValidator = (TValidator)HttpContext.Current.Session["UserLogin"]; ClientAdapt.Open(); TVssService.Client client = ClientAdapt.GetClient(); TFile tFile = new TFile(); tFile.FileId = ""; tFile.FileContent = System.Text.Encoding.UTF8.GetBytes(sData); tFile.FileInfo = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + " Send a Blog."; tFile.FileKind = TContentKind.Weibo; tFile.FileOwner = tValidator.VssID; tFile.FileSize = tFile.FileContent.Length; tFile.FromApp = "VssBlog"; tFile.FileOwner = tValidator.VssID; string fileID = client.Put(tValidator, tFile); tFile.FileId = fileID; tFile.FileContent = System.Text.Encoding.UTF8.GetBytes(sData.Replace("[REPLACE_STRMSGID]", fileID)); fileID = client.Put(tValidator, tFile); ClientAdapt.Close(); Response.Write(fileID); Response.End(); }
private static FileTreeNode CreateTreeNodeByMessage(TMessages msg) { FileTreeNode node = new FileTreeNode(); TFile file = msg.FileOject; node.CreateDate = (uint)msg.ProvideTime; node.FileID = file.FileId; node.FileInfo = file.FileInfo; node.FileKind = (ContentKind)file.FileKind; node.FileSize = (ulong)file.FileSize; node.FromApp = msg.FromApp; node.NodeName = msg.ProvideName; node.SubNodes = null; return(node); }
//讀Json -> 開放給外界使用 public void LoadJson(byte[] byteArray) { byteArray = TFile.XOR(byteArray); using (MemoryStream stream = new MemoryStream(byteArray)) { using (StreamReader reader = new StreamReader(stream, System.Text.UTF8Encoding.UTF8)) { string str = reader.ReadToEnd(); if (str.Trim() == "[]") { return; } LoadJson(str); } } Analyze(); }
public string Dump() { StringBuilder builder = new StringBuilder(); builder.AppendLine("Server :" + ServerId + " at " + ServerIp + ":" + ServerPort); builder.AppendLine("Server is Online? :" + !isFailed); builder.AppendLine("Server is Freezed? :" + isFreezed); builder.AppendLine("| Name | Ver | Size |ReadsTraffic|WritesTraffic| Content |"); foreach (KeyValuePair <string, LocalFileStatistics> keyValuePair in _localFileNameList) { TFile file = storage.ReadFile(keyValuePair.Key); builder.AppendLine(value: "|" + keyValuePair.Key + " | " + keyValuePair.Value.version + " | " + keyValuePair.Value.size + "| " + keyValuePair.Value.readTraffic + " | " + keyValuePair.Value.writeTraffic + " |" + Encoding.ASCII.GetString(file.Data)); } return(builder.ToString()); }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Session["UserLogin"] == null) { //这里也可以根据类型不同,返回适当的情况! Response.Write("NOLOGIN"); Response.End(); return; } if (Request.Files.Count == 0) { return; } HttpPostedFile file = Request.Files[0]; Stream s = file.InputStream; s.Seek(0, SeekOrigin.Begin); byte[] buf = new byte[s.Length]; s.Read(buf, 0, (int)s.Length); TValidator tValidator = (TValidator)HttpContext.Current.Session["UserLogin"]; ClientAdapt.Open(); TVssService.Client client = ClientAdapt.GetClient(); TFile tFile = new TFile(); tFile.FileId = ""; tFile.FileContent = buf; tFile.FileInfo = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + "Upload a Picture"; tFile.FileKind = TContentKind.Picture; tFile.FileOwner = tValidator.VssID; tFile.FileSize = tFile.FileContent.Length; tFile.FromApp = "VssBlog"; tFile.FileOwner = tValidator.VssID; string fileID = client.Put(tValidator, tFile); ClientAdapt.Close(); Response.Write("<img id='mypic' width='400px' height='300px' src='GetFile.aspx?fileID=" + fileID + "' />"); Response.End(); }
// Operaçoes De Storage public String Write(string localFileName, byte[] data, long newVersion) { Console.WriteLine("Write: " + localFileName + " TFile: " + data); if (isFreezed) { Console.WriteLine("Write: Freeze"); Monitor.Enter(freezeMon); Monitor.Wait(freezeMon); Monitor.Exit(freezeMon); Console.WriteLine("Write: Defrost"); } LocalFileStatistics currentStatistics; _localFileNameList.TryGetValue(localFileName, out currentStatistics); // Se estiver outra escrita em curso ficamos a bloqueados // caso contrario reservamos a escrita lock (currentStatistics.mutex) { //Verifica Versão Proposta if (newVersion > currentStatistics.version) { currentStatistics.version = newVersion; } else { currentStatistics.version += 1; } //Actualiza as variaveis de estatistica currentStatistics.writeTraffic += data.Length; currentStatistics.size = data.Length; //Guardar File em Disco TFile t = new TFile(currentStatistics.version, data); storage.WriteFile(localFileName, t); Console.WriteLine("Write: New File Version is:" + currentStatistics.version); return(ServerId.ToString()); } }
internal static void AddFile(string name, TFile GFile) { TFile temp = GFile; TFile last = null; while (temp != null) { if (temp.Name == name) { return; } last = temp; temp = temp.Next; } last.Next = new TFile { Name = name }; }
/// <exception cref="System.IO.IOException"/> public RBlockState(Compression.Algorithm compressionAlgo, FSDataInputStream fsin, BCFile.BlockRegion region, Configuration conf) { // Index for meta blocks this.compressAlgo = compressionAlgo; this.region = region; this.decompressor = compressionAlgo.GetDecompressor(); try { this.@in = compressAlgo.CreateDecompressionStream(new BoundedRangeFileInputStream (fsin, this.region.GetOffset(), this.region.GetCompressedSize()), decompressor, TFile.GetFSInputBufferSize(conf)); } catch (IOException e) { compressAlgo.ReturnDecompressor(decompressor); throw; } }
public string Receive() { bool thumb = Convert.ToBoolean(HttpContext.Current.Request.Headers["Uploader-Thumb"]); int thumb_width = Convert.ToInt32(HttpContext.Current.Request.Headers["Uploader-ThumbHeight"]); int thumb_height = Convert.ToInt32(HttpContext.Current.Request.Headers["Uploader-ThumbWidth"]); string name = HttpContext.Current.Request.Headers["Uploader-Name"]; TFile file = new TFile(HttpContext.Current.Server.MapPath("~/uploads/images"), HttpContext.Current.Server.MapPath("~/uploads/thumbnails"), thumb_width, thumb_height); if (file.UploadAjax(HttpContext.Current.Request.InputStream, name , thumb) == -1) //fail { return "false"; } else //success { return "true"; } }
//存入資源列表 private void SaveVersion(string versionName) { #if UNITY_TVOS && !UNITY_EDITOR string path = Application.temporaryCachePath + "/" + TinyContext.Instance.LanguagePath + "/" + "Versions/"; #else string path = Application.persistentDataPath + "/" + TinyContext.Instance.LanguagePath + "/" + "Versions/"; #endif if (mRecordMap.Count > 0) { rMD5Info[] info = new rMD5Info[mRecordMap.Count]; int count = 0; foreach (KeyValuePair <string, string> pair in mRecordMap) { info[count].FlieName = pair.Key; info[count].MD5Code = pair.Value; count++; } string json = TJson.SerializeObject(info); TFile.Save(path, versionName, System.Text.UTF8Encoding.UTF8.GetBytes(json)); } }
public void CreateEmptyFile(String filename, string localFilename) { LocalFileStatistics value; Boolean exists = _localFileNameList.TryGetValue(localFilename, out value); if (exists == true) { //Console.WriteLine("Create: File already exists, ignore: " + localFilename); return; } TFile t = new TFile(0, new byte[0]); storage.WriteFile(localFilename, t); Console.WriteLine("Create new Empty File: " + localFilename); LocalFileStatistics currentStatistics = new LocalFileStatistics(filename, localFilename); currentStatistics.localFileName = localFilename; _localFileNameList.TryAdd(localFilename, currentStatistics); }
public ActionResult ReceiveForm(HttpPostedFileBase fileInput, int ThumbHeight, int ThumbWidth) { int thumb_width = ThumbHeight; int thumb_height = ThumbWidth; TFile file = new TFile(Server.MapPath("~/uploads/images"), Server.MapPath("~/uploads/thumbnails"), thumb_width, thumb_height); if (file.UploadForm(fileInput, false) == -1) //fail { return Json(false); } else //success { return Json(true); } }