2using System.Collections.Generic;
5using System.Threading.Tasks;
27 : base(
"/StartAnalyze")
72 if (!(Obj is Dictionary<string, object> Parameters))
75 if (!Parameters.TryGetValue(
"repair", out Obj) || !(Obj is
bool Repair))
80 Response.StatusCode = 409;
81 Response.StatusMessage =
"Conflict";
83 await Response.
Write(
"Analysis is underway.");
87 if (!Directory.Exists(BasePath))
88 Directory.CreateDirectory(BasePath);
90 BasePath += Path.DirectorySeparatorChar;
92 string FullFileName = Path.Combine(BasePath,
"DBReport " + DateTime.Now.ToString(
"yyyy-MM-dd HH_mm_ss"));
98 fs =
new FileStream(FullFileName, FileMode.Create, FileAccess.Write);
99 DateTime Created = File.GetCreationTime(FullFileName);
101 string FileName = FullFileName.Substring(BasePath.Length);
103 Task _ = Task.Run(() =>
DoAnalyze(FullFileName, FileName, Created, XmlOutput, fs, Repair));
105 Response.StatusCode = 200;
107 await Response.
Write(FileName);
115 File.Delete(FullFileName);
139 private static bool analyzing =
false;
140 private static readonly
object synchObject =
new object();
141 private static XslCompiledTransform xslt =
null;
142 internal static System.Text.Encoding utf8Bom =
new UTF8Encoding(
true);
154 public static async Task<string[]>
DoAnalyze(
string FullPath,
string FileName, DateTime Created, XmlWriter XmlOutput, FileStream fs,
bool Repair)
156 string[] Collections =
null;
162 ExportFormats.ExportFormat.UpdateClientsFileUpdated(FileName, 0, Created);
170 ExportFormats.ExportFormat.UpdateClientsFileUpdated(FileName, fs.Length, Created);
183 byte[] Bin = utf8Bom.GetBytes(s);
185 string FullPath2 = FullPath.Substring(0, FullPath.Length - 4) +
".html";
188 ExportFormats.ExportFormat.UpdateClientsFileUpdated(FileName.Substring(0, FileName.Length - 4) +
".html", Bin.Length, Created);
204 XmlOutput?.Dispose();
Helps with parsing of commong data types.
static string JsonStringEncode(string s)
Encodes a string for inclusion in JSON.
Static class managing loading of resources stored as embedded resources or in content files.
static Task WriteAllBytesAsync(string FileName, byte[] Data)
Creates a binary file asynchronously.
static async Task< string > ReadAllTextAsync(string FileName)
Reads a text file asynchronously.
Plain text encoder/decoder.
const string DefaultContentType
text/plain
Helps with common XML-related tasks.
static XmlWriterSettings WriterSettings(bool Indent, bool OmitXmlDeclaration)
Gets an XML writer settings object.
Static class managing loading of XSL resources stored as embedded resources or in content files.
static XslCompiledTransform LoadTransform(string ResourceName)
Loads an XSL transformation from an embedded resource.
static string Transform(string XML, XslCompiledTransform Transform)
Transforms an XML document using an XSL transform.
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
The ClientEvents class allows applications to push information asynchronously to web clients connecte...
static string[] GetTabIDsForLocation(string Location)
Gets the Tab IDs of all tabs that display a particular resource.
static Task< int > PushEvent(string[] TabIDs, string Type, object Data)
Puses an event to a set of Tabs, given their Tab IDs.
Static class managing data export.
static async Task< string > GetFullExportFolderAsync()
Full path to export folder.
Static class managing the runtime environment of the IoT Gateway.
static IUser AssertUserAuthenticated(HttpRequest Request, string Privilege)
Makes sure a request is being made from a session with a successful user login.
static string AppDataFolder
Application data folder.
Starts analyzing the database
override bool UserSessions
If the resource uses user sessions.
static bool CanStartAnalyzeDB()
Checks to see if analyzing the database can start.
StartAnalyze()
Starts analyzing the database
static async Task< string[]> DoAnalyze(string FullPath, string FileName, DateTime Created, XmlWriter XmlOutput, FileStream fs, bool Repair)
Analyzes the object database
bool AllowsPOST
If the POST method is allowed.
override bool HandlesSubPaths
If the resource handles sub-paths.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
static string GetUniqueFileName(string Base, string Extension)
Gets a unique filename.
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
bool HasData
If the request has data.
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
async Task Write(byte[] Data)
Returns binary data in the response.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static Task< string[]> Analyze(XmlWriter Output, string XsltPath, string ProgramDataFolder, bool ExportData)
Analyzes the database and exports findings to XML.
POST Interface for HTTP resources.