public void CalculateStats() { var readValue = JsonStringHelper.ReadFromCompressedFile("envelopes.json.gz"); var envelopes = JsonStringHelper.CreateObject <List <NodeEnvelope> >(readValue); var root = NodeHierarchyRoot.CreateNodeHierarchy(envelopes); root.CalculateStats(); }
public DataFileVersion GetDataFileVersion() { var dataVersionFilePath = _filePathProvider.GetFilePath(_dataVersionFileName); //File.ReadAllBytes(dataFilePath); if (!File.Exists(dataVersionFilePath)) { return(null); } using (var file = File.OpenRead(dataVersionFilePath)) { var versionData = JsonStringHelper.ReadJsonObject <DataFileVersion>(file, JsonStringHelper.MaxJsonSize); return(versionData); } }
public void WrapSaveDataVersion(Action action, bool branch, int toFileVersion, string stationName) { var dataVersionFilePath = _filePathProvider.GetFilePath(_dataVersionFileName); using (var file = File.Open(dataVersionFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { var versionData = JsonStringHelper.ReadJsonObject <DataFileVersion>(file, JsonStringHelper.MaxJsonSize) ?? new DataFileVersion { FromVersionId = 0 }; var newDataFileVersion = new DataFileVersion { CurrentVersionId = toFileVersion, StationName = stationName, BeforeOperation = "Update", FromVersionId = versionData.FromVersionId }; if (!branch) { newDataFileVersion.FromVersionId = toFileVersion; } file.Seek(0, SeekOrigin.Begin); JsonStringHelper.WriteJsonObject(file, newDataFileVersion, compress: false); file.SetLength(file.Position); try { action(); newDataFileVersion.BeforeOperation = ""; file.Seek(0, SeekOrigin.Begin); JsonStringHelper.WriteJsonObject(file, newDataFileVersion, compress: false); file.SetLength(file.Position); } catch (Exception e) { file.Seek(0, SeekOrigin.Begin); JsonStringHelper.WriteJsonObject(file, versionData, compress: false); file.SetLength(file.Position); } } }
public void IndexPictures() { var pathEnumerator = new PathEnumerator(@"\\192.168.178.22\public", new[] { @":\\Windows", @":\\Program Files \(x86\)\\", @":\\Program Files\\", @":\\Users\\.*\\\..*", @":\\Users\\.*\\AppData\\Local.*\\", @":\\Users\\.*\\AppData\\Roaming\\", @":\\Users\\.*\\Searches", @"IISExpress\\TraceLogFiles", @"\\node_modules", @"\\wwwroot\\lib" }); pathEnumerator.Index(); var nodeEnvelopes = pathEnumerator.NodeEnvelopes; var root = NodeHierarchyRoot.CreateNodeHierarchy(nodeEnvelopes); var envelopes = JsonStringHelper.CreateString(pathEnumerator.NodeEnvelopes); JsonStringHelper.WriteToCompressedFile("envelopes.json.gz", envelopes); }