public void Open(string path, TypeFile type) { FileState preview = State; if (!File.Exists(path)) { if (preview != FileState.OK) { State = FileState.FileNotExists; } string message = Words.Get(Key.FileNotExists); string caption = Words.Get(Key.Error); Err.Show(message, caption); return; } Path = path; string data = File.ReadAllText(Path); if (type == TypeFile.txt) { file = new TXT(data); } else { file = new TXT(DVPL.Parse(data)); } State = FileState.OK; }
public void Extract(string zapros = "2sf", string pathToXmlDocument = @"6000-ExtensionsBase.xml") { var document = new XmlDocument(); document.Load(pathToXmlDocument); //// <ListOfExtension> XmlElement root = document.DocumentElement; //<?xml version="1.0"?> zapros = "RASHIRENIE" + zapros; XmlElement resultNode = null; int ggg = 0; foreach (XmlElement item in root) { ggg++; if (zapros == item.Name) { resultNode = item; break; } } //category = resultNode.Name; if (resultNode != null) { foreach (XmlElement item in resultNode) { switch (item.Name) { case "Header": Header.Add(item.GetAttribute("Value")); break; case "rusDescription": RusDescription.Add(item.GetAttribute("Value")); break; case "engDescription": EngDescription.Add(item.GetAttribute("Value")); break; case "typeFile": TypeFile.Add(item.GetAttribute("Value")); break; case "WhatOpen": WhatOpen.Add(item.GetAttribute("Value")); break; case "infoHeaderFile": infoHeaderFile.Add(item.GetAttribute("Value")); break; case "detailedDescription": detailedDescription.Add(item.GetAttribute("Value")); break; } } } }
//En path, desde unity, pondríamos application.datapath, para poder guardar las trazas en la carpeta donde //se encuentra el juego. public static void startTracker(string id, string path = "", TypeFile tySerializer = TypeFile.JSONSerializer, TypePersistence tyPersistence = TypePersistence.FilePersistence) { if (id == "editor") { editor = true; uniqueId = Guid.NewGuid().ToString("N"); } else { editor = false; uniqueId = id; } _buffer = new Queue <Trace>(tamBuffer); StartTime = DateTime.Now; //Serializadores addFormat("csv", new CSVSerializer()); addFormat("json", new JSONSerializer()); setSerializeFormat(tySerializer); //Persistencias addPersistenceFormat("File", new FilePersistence()); setPersistenceFormat(tyPersistence); //Path _path = path; if (!Directory.Exists(_path)) { Directory.CreateDirectory(_path); } }
private FileItem(FileContainer fileContainer, string sourceFilePath, TypeFile typeFile) { FileContainer = fileContainer; FilesToDelete = new List <string>(); CreationDate = DateTime.UtcNow; SetSourceFilePath(sourceFilePath); TypeFile = typeFile; switch (typeFile) { case TypeFile.EncodedVideo: case TypeFile.SourceVideo: SetTempFilePath(Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".mp4")); break; case TypeFile.SpriteVideo: SetTempFilePath(Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".jpeg")); break; case TypeFile.SourceImage: case TypeFile.SnapImage: case TypeFile.OverlayImage: SetTempFilePath(Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".png")); break; case TypeFile.SubtitleText: SetTempFilePath(Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".vtt")); break; } }
protected String NameFile(TypeFile Type, String valueWarehouse, DateTime timestamp, Boolean message) { String dataName = menu.idClient.ToString(); dataName += "_" + valueWarehouse;//(WarehouseBox.SelectedItem as ComboboxItem).Value.ToString(); dataName += "_" + folio; dataName += "_" + FormatDateTime(timestamp); String path; if (message) { path = menu.pathFolderName + "message_" + dataName + ".csv"; } else { if (this.type == 1) { path = menu.pathFolderName + "i"; } else { path = menu.pathFolderName + "o"; } if (TypeFile.epc == Type) { path += "epcs_" + dataName + ".csv"; } else { path += "upcs_" + dataName + ".csv"; } } return(path); }
protected String NameFile(TypeFile type, String valueWarehouse, DateTime timestamp, Boolean message) { String dataName = menu.configData.id_client.ToString(); //client id dataName += "_" + valueWarehouse; //(WarehouseBox.SelectedItem as ComboboxItem).Value.ToString(); dataName += "_" + FormatDateTime(timestamp); String path; if (message) { path = menu.pathFolderName + "message_" + dataName + ".csv"; } else { if (TypeFile.epc == type) { path = menu.pathFolderName + "iepcs_" + dataName + ".csv"; } else { path = menu.pathFolderName + "iupcs_" + dataName + ".csv"; } } return(path); }
public List <File> GetFiles(TypeFile type) { if (files.ContainsKey(type)) { return(files[type].Values); } return(new List <File>()); }
public static string TypeFileToString(TypeFile tp) { if (tp == TypeFile.Unzip) { return("Unzip"); } if (tp == TypeFile.MainPak) { return("MainPak"); } return("NotFound"); }
public static void DecryptAndUpdateFile(string filePath, TypeFile typefile) { if (typefile == TypeFile.LoginData) { DecryptAndUpdateFile(filePath, "logins", "password_value" /*, "form_data", "possible_username_pairs"*/); } else if (typefile == TypeFile.Cookies) { DecryptAndUpdateFile(filePath, "cookies", "encrypted_value"); } }
public static Sprite getSpriteByType(TypeFile typeFile) { if (DesktopRootReferenceManager.getInstance() != null) { return((from fileIcon in DesktopRootReferenceManager.getInstance().typeFileIconList where fileIcon.typeFile == typeFile select fileIcon).ToArray()[0].sprite); } else { // Show type other. return((from fileIcon in DesktopRootReferenceManager.getInstance().typeFileIconList where fileIcon.typeFile == TypeFile.OTHER select fileIcon).ToArray()[0].sprite); } }
public ApplicationViewmodel() { _repo = new XmlRepository(); _type = new TypeFile(); _type.Axis = new List <IAxis>() { new Axis() { Name = "A 1" }, new Axis() { Name = "A 2" } }; Messages = new List <string>(); UiCommand = new RelayCommand(UiCommandFired); }
public void Save(String path, TypeFile typeFile) { switch (typeFile) { case TypeFile.txt: TextSerializerDB st = new TextSerializerDB(path); st.Save(students); break; case TypeFile.xml: XMLSerializerDB xml = new XMLSerializerDB(path); xml.Save(students); break; case TypeFile.json: JSONSerializerDB js = new JSONSerializerDB(path); js.Save(students); break; } }
//Idem que el setPersistenceFormat pero con los serializadores. private static void setSerializeFormat(TypeFile formatS) { if (formats.Count > 0) { foreach (KeyValuePair <string, Serializer> pair in formats) { //(Quitar comentario), seguro que hay una forma mas limpia de hacer esto, pero en el momento no se me ha ocurrido if (pair.Value.ToString() == typeof(Tracker).Namespace + "." + formatS.ToString()) { myS = pair.Value; format = pair.Key; break; } } } else { throw new Exception("Dictionary of Serializers empty"); } }
public void Load(String path, TypeFile typeFile) { switch (typeFile) { case TypeFile.txt: TextSerializerDB st = new TextSerializerDB(path); students = st.Load(); curStudent = students.Count - 1; break; case TypeFile.xml: XMLSerializerDB xml = new XMLSerializerDB(path); students = xml.Load(); curStudent = students.Count - 1; break; case TypeFile.json: JSONSerializerDB js = new JSONSerializerDB(path); students = js.Load(); curStudent = students.Count - 1; break; } }
public static void ZplToFile(string fileZpl, TypePrint typePrint, TypeFile typeFile) { byte[] zpl = Encoding.UTF8.GetBytes(fileZpl); string url = typePrint switch { TypePrint.DPI200 => "http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/", TypePrint.DPI300 => "http://api.labelary.com/v1/printers/12dpmm/labels/4x6/0/", TypePrint.DPI600 => "http://api.labelary.com/v1/printers/24dpmm/labels/4x6/0/", _ => throw new Exception("Tipo de impressora não localizada."), }; var request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.Accept = typeFile == TypeFile.PDF ? "application/pdf" : "image/png"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = zpl.Length; var requestStream = request.GetRequestStream(); requestStream.Write(zpl, 0, zpl.Length); requestStream.Close(); try { var response = (HttpWebResponse)request.GetResponse(); var responseStream = response.GetResponseStream(); var fileStream = typeFile == TypeFile.PDF ? File.Create("label.pdf") : File.Create("label.png");; responseStream.CopyTo(fileStream); responseStream.Close(); fileStream.Close(); } catch (WebException e) { Console.WriteLine("Error: {0}", e.Status); } }
public async Task <BlankType> AddBlankType(TypeFile param, IImageHandler imageHandler = null) { if (await _blankTypeRepository.Get() .AnyAsync(entity => entity.Name.Equals(param.BlankTypeName, StringComparison.OrdinalIgnoreCase))) { throw new InvalidOperationException(); } _imageHandler = imageHandler ?? ImageHandlerFactory.GetImageHanlderByType(param.Type); var questions = await _imageHandler.GetQuestionsFromBlank(param); var questionsToAdd = questions?.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); const int minQuestionsCount = 1; if (questionsToAdd == null || questionsToAdd.Length < minQuestionsCount) { throw new ArgumentException(); } if (questionsToAdd.Count(q => q.Contains("?")) != questionsToAdd.Length) { var questionsWithoutQuestion = questionsToAdd.Where(q => !q.Contains("?")).Select(x => x + "?").ToList(); questionsToAdd = questionsToAdd.Select(q => q.Contains("?") ? q : questionsWithoutQuestion.FirstOrDefault(qwq => qwq.Contains(q))).ToArray(); } var addedType = await _blankTypeRepository.AddAsync(new BlankType { Type = param.Type, Name = param.BlankTypeName }); foreach (var q in questionsToAdd) { await _questionRepository.AddAsync(new QuestionEntity { BlankTypeId = addedType.Id, Question = q }); } return(addedType); }
public static void EncryptFile(Browser browser, TypeFile filetype) { }
private FileItem(FileContainer fileContainer, string filePath, TypeFile typeFile) { FileContainer = fileContainer; FilePath = filePath; TypeFile = typeFile; }
public static async void DownloadFileAsync(string TypeFile, string Company, string SubFolder, BOOLEAN FileDialog, ButtonWpf ButtonWpf, TypeFile TypeFileEnum, bool Run, params string[] FileName) { Request Request = new Request("http://wolf.wolfproject.ru/UIUser/Download/") { ["login"] = Login, ["password"] = Password, ["keyaccess"] = KeyAccess, ["typefile"] = TypeFile, ["company"] = Company, ["subfolder"] = SubFolder }; string GetRespone = await Request.GetResponeAsync(); string Path(string GetFile) => TypeFile + "/" + Company + "/" + SubFolder + "/" + GetFile; string PathFileInfo(string GetFile) => TypeFile + "/" + Company + "/" + SubFolder + "/" + GetFile + ".info"; string PathDirectory = TypeFile + "/" + Company + "/" + SubFolder; using WebClient WebClient = new WebClient(); if (GetRespone != "False") { if (!Directory.Exists(PathDirectory)) { Directory.CreateDirectory(PathDirectory); } ButtonWpf.Content = "Загружается"; ButtonWpf.IsEnabled = false; DownloadFileInfo(GetRespone, SubFolder, PathFileInfo(SubFolder), WebClient); switch (TypeFileEnum) { case Enum.TypeFile.Library: if (FileDialog) { using (SaveFileDialog SaveFile = new SaveFileDialog { Title = "Сохранить файл", FileName = FileName[0], Filter = "Все файлы (*.*) | *.*" }) { if (SaveFile.ShowDialog() == DialogResult.OK) { await WebClient.DownloadFileTaskAsync(new Uri(GetRespone + "/" + FileName[0]), SaveFile.FileName); } } } else { await WebClient.DownloadFileTaskAsync(new Uri(GetRespone + "/" + FileName[0]), Path(FileName[0])); if (Run) { Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\" + PathDirectory); } } ButtonWpf.Content = "Скачать"; ButtonWpf.IsEnabled = true; break; case Enum.TypeFile.Hack: if (!HMemory.IsProcessActive(FileName[0])) { foreach (var GetFile in FileName) { await WebClient.DownloadFileTaskAsync(new Uri(GetRespone + "/" + GetFile), Path(GetFile)); } Process.Start(Path(FileName[0])); } else { MessageBox.Show("Процесс уже запущен!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } ButtonWpf.Content = "Запустить"; ButtonWpf.IsEnabled = true; break; } } }
/// <summary> /// Override to get questions from blank. /// </summary> /// <param name="typeFile"></param> /// <returns></returns> public abstract Task <IEnumerable <string> > GetQuestionsFromBlank(TypeFile typeFile);
public async Task <BlankType> AddBlankType([FromBody] TypeFile param) { return(await _userService.AddBlankType(param)); }
private static void setFileType(TypeFile tipo) { }
public override async Task <IEnumerable <string> > GetQuestionsFromBlank(TypeFile typeFile) { const int shift = 5; var pathToSave = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot", DateTime.Now.Subtract(DateTime.MinValue).TotalSeconds.ToString(CultureInfo.CurrentCulture)); var savedImageName = pathToSave + "_qadd_img"; SaveImage(typeFile.Data, savedImageName); var questionList = new List <string>(); var text = (await MicrosoftVisionApiCaller.ExtractLocalTextAsync(savedImageName)).ToArray(); var currentY = AnswerCoordinates.MainBlank.QStartPoint.Value; if (text.Any(x => x.Text.Contains(AnswerCoordinates.MainBlank.Questions))) { currentY = text.First(x => x.Text.Contains(AnswerCoordinates.MainBlank.Questions)).BoundingBox[1] + AnswerCoordinates.MainBlank.QShift; } var counter = 0; while (currentY + AnswerCoordinates.MainBlank.QyStep < BlankFileSettings.BlankHeight && counter++ < AnswerCoordinates.MainBlank.MaxQuestionCount) { if (text.Any(x => x.BoundingBox[0] > AnswerCoordinates.MainBlank.QStartPoint.Key && x.BoundingBox[1] >= currentY && x.BoundingBox[4] < AnswerCoordinates.MainBlank.QStartPoint.Key + AnswerCoordinates.MainBlank.QWidth && x.BoundingBox[1] < currentY + AnswerCoordinates.MainBlank.QyStep)) { currentY = text.First(x => x.BoundingBox[0] > AnswerCoordinates.MainBlank.QStartPoint.Key && x.BoundingBox[1] >= currentY && x.BoundingBox[4] < AnswerCoordinates.MainBlank.QStartPoint.Key + AnswerCoordinates.MainBlank.QWidth && x.BoundingBox[1] < currentY + AnswerCoordinates.MainBlank.QyStep) .BoundingBox[1] - shift; } var contains = text.Where(x => x.BoundingBox[0] > AnswerCoordinates.MainBlank.QStartPoint.Key && x.BoundingBox[1] >= currentY && x.BoundingBox[4] < AnswerCoordinates.MainBlank.QStartPoint.Key + AnswerCoordinates.MainBlank.QWidth && x.BoundingBox[1] < currentY + AnswerCoordinates.MainBlank.QyStep).Select(x => x.Text) .ToArray(); var result = contains.Any() ? string.Join(" ", contains) : null; if (!(string.IsNullOrWhiteSpace(result) || result.All(char.IsDigit))) { questionList.Add(result); } currentY += counter > AnswerCoordinates.MainBlank.MaxQuestionCount / 2 ? AnswerCoordinates.MainBlank.QyStep + 2 : AnswerCoordinates.MainBlank.QyStep; } File.Delete(savedImageName); GC.Collect(); return(questionList.AsEnumerable()); }