4using System.Threading.Tasks;
27 : base(
"/StartAnalyze")
75 if (Content.
HasError || !(Content.
Decoded is Dictionary<string, object> Parameters))
81 if (!Parameters.TryGetValue(
"repair", out
object Obj) || !(Obj is
bool Repair))
89 Response.StatusCode = 409;
90 Response.StatusMessage =
"Conflict";
92 await Response.
Write(
"Analysis is underway.");
96 if (!Directory.Exists(BasePath))
97 Directory.CreateDirectory(BasePath);
99 BasePath += Path.DirectorySeparatorChar;
101 string FullFileName = Path.Combine(BasePath,
"DBReport " + DateTime.Now.ToString(
"yyyy-MM-dd HH_mm_ss"));
103 FileStream fs =
null;
107 fs =
new FileStream(FullFileName, FileMode.Create, FileAccess.Write);
108 DateTime Created = File.GetCreationTime(FullFileName);
110 string FileName = FullFileName[BasePath.Length..];
112 Task
_ = Task.Run(() =>
DoAnalyze(FullFileName, FileName, Created, XmlOutput, fs, Repair));
114 Response.StatusCode = 200;
115 Response.StatusMessage =
"OK";
117 await Response.
Write(FileName);
125 File.Delete(FullFileName);
149 private static bool analyzing =
false;
150 private static readonly
object synchObject =
new object();
151 private static XslCompiledTransform xslt =
null;
163 public static async Task<string[]>
DoAnalyze(
string FullPath,
string FileName, DateTime Created, XmlWriter XmlOutput, FileStream fs,
bool Repair)
165 string[] Collections =
null;
171 ExportFormats.ExportFormat.UpdateClientsFileUpdated(FileName, 0, Created);
179 ExportFormats.ExportFormat.UpdateClientsFileUpdated(FileName, fs.Length, Created);
193 string FullPath2 = FullPath[..^4] +
".html";
196 ExportFormats.ExportFormat.UpdateClientsFileUpdated(FileName[..^4] +
".html", Bin.Length, Created);
212 XmlOutput?.Dispose();
Helps with parsing of commong data types.
static string JsonStringEncode(string s)
Encodes a string for inclusion in JSON.
Contains information about a response to a content request.
bool HasError
If an error occurred.
object Decoded
Decoded object.
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 async Task< 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< ContentResponse > 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...
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.
static Task WriteAllBytesAsync(string FileName, byte[] Data)
Creates a binary file asynchronously.
static async Task< string > ReadAllTextAsync(string FileName)
Reads a text file asynchronously.
Static class managing binary representations of strings.
static Encoding Utf8WithBom
UTF-8 encoding with Byte Order Mark (BOM)
POST Interface for HTTP resources.