private FileV8Tree GetModelsTree(FileV8Tree rootPropertiesTree) { if (rootPropertiesTree.GetLeaf(3, 1, 3, 0).Value.Equals(@"3daea016-69b7-4ed4-9453-127911372fe6")) { return(rootPropertiesTree.GetLeaf(3, 1, 3)); } else if (rootPropertiesTree.GetLeaf(3, 1, 4, 0).Value.Equals(@"3daea016-69b7-4ed4-9453-127911372fe6")) { return(rootPropertiesTree.GetLeaf(3, 1, 4)); } return(null); }
private FileV8Tree GetFormsTree(FileV8Tree rootPropertiesTree) { if (rootPropertiesTree.GetLeaf(3, 1, 5, 0).Value.Equals(@"d5b0e5ed-256d-401c-9c36-f630cafd8a62")) { return(rootPropertiesTree.GetLeaf(3, 1, 5)); } else if (rootPropertiesTree.GetLeaf(3, 1, 5, 0).Value.Equals(@"a3b368c0-29e2-11d6-a3c7-0050bae0a776")) { return(rootPropertiesTree.GetLeaf(3, 1, 5)); } return(null); }
public void Parse(FileV8Reader fileV8Reader, V8FileSystem fileSystem, string output, int threads = 1) { FileV8Tree rootTree = GetDescriptionTree(fileV8Reader, fileSystem, String.Empty, @"root"); FileV8Tree rootPropertiesTree = GetDescriptionTree(fileV8Reader, fileSystem, String.Empty, rootTree.GetLeaf(1).Value); FileV8Tree objectModule = rootPropertiesTree.GetLeaf(3, 1, 1, 3, 1, 1, 2); FileV8Tree forms = GetFormsTree(rootPropertiesTree); FileV8Tree models = GetModelsTree(rootPropertiesTree); if (fileV8Reader.FindFileSystemReferenceByFileHeaderName(fileSystem.References, objectModule.Value + ".0") != null) { FileV8Tree objectModuleTree = GetDescriptionTree(fileV8Reader, fileSystem, objectModule.Value + ".0", @"text"); { string path = output + "\\МодульОбъекта\\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string module = '\uFEFF' + objectModuleTree.GetLeaf(0).Value; string filePath = path + "МодульОбъекта.txt"; string hashFile = _hashService.HashFile(filePath); string hashModule = _hashService.HashString(module); if (!hashModule.Equals(hashFile)) { using (StreamWriter fileStream = new StreamWriter(filePath)) { fileStream.Write(module); } } } } if (!Directory.Exists(output + "Form")) { Directory.CreateDirectory(output + "Form"); } if (!Directory.Exists(output + "СКД")) { Directory.CreateDirectory(output + "СКД"); } /* Directories that are mighty to be deleted */ List <string> directories = new List <string>(); directories.AddRange(Directory.GetDirectories(output + "Form")); directories.AddRange(Directory.GetDirectories(output + "СКД")); if (forms != null) { int count = Convert.ToInt32(forms.GetNode(1).Value); for (int i = 2; i < count + 2; i++) { FileV8Tree formTree = GetDescriptionTree(fileV8Reader, fileSystem, String.Empty, forms.GetNode(i).Value + ".0"); FileV8Tree formPropertiesTree = GetDescriptionTree(fileV8Reader, fileSystem, String.Empty, forms.GetNode(i).Value); string formName = formPropertiesTree.GetLeaf(1, 1, 1, 1, 2).Value.Replace("\"", ""); string path = output + "Form\\" + formName; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } // This directory is no needed to be deleted directories.Remove(path); string tmpSheet = formTree.GetLeaf(2).Value; string formModule = '\uFEFF' + tmpSheet.Substring(1, tmpSheet.Length - 2).Replace("\"\"", "\""); string filePath = path + "\\" + formName + ".txt"; string hashFile = _hashService.HashFile(filePath); string hashForm = _hashService.HashString(formModule); if (!hashForm.Equals(hashFile)) { using (StreamWriter fileStream = new StreamWriter(filePath)) { fileStream.Write(formModule); } } } } if (models != null) { int count = Convert.ToInt32(models.GetNode(1).Value); for (int i = 2; i < count + 2; i++) { FileV8Tree modelTree = GetDescriptionTree(fileV8Reader, fileSystem, String.Empty, models.GetNode(i).Value + ".0"); FileV8Tree modelPropertiesTree = GetDescriptionTree(fileV8Reader, fileSystem, String.Empty, models.GetNode(i).Value); string modelName = modelPropertiesTree.GetLeaf(1, 2, 2).Value.Replace("\"", ""); string path = output + "СКД\\" + modelName; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } /* This directory is no needed to be deleted */ directories.Remove(path); string tmpSheet = modelTree.GetLeaf(0).Value; int index = tmpSheet.IndexOf("<?xml"); string modelModule; if (tmpSheet.IndexOf("<?xml") == -1) { modelModule = tmpSheet; } else { modelModule = tmpSheet.Substring(tmpSheet.IndexOf("<?xml")); } string filePath = path + "\\" + modelName + ".txt"; string hashFile = _hashService.HashFile(filePath); string hashModel = _hashService.HashString(modelModule); if (!hashModel.Equals(hashFile)) { using (StreamWriter fileStream = new StreamWriter(filePath)) { fileStream.Write(modelModule); } } } } // This directories are need to be deleted DeleteDirectories(directories); }