public async Task Invoke(HttpContext context) { _DbNetGridConfiguration = SerialisationHelper.DeserialiseJson <DbNetGridConfiguration>(context.Request.Body); // Db = new DbNetData(_DbNetGridConfiguration.ConnectionString, _DbNetGridConfiguration.DataProvider, _httpContextAccessor, _hostingEnvironment, _configuration); Db.Open(_DbNetGridConfiguration.ConnectionString, _DbNetGridConfiguration.DataProvider); var handler = (string)context.Request.Query["handler"] ?? string.Empty; switch (handler.ToLower()) { case "init": ConfigureColumns(); _DbNetGridConfiguration.Html["toolbar"] = await _viewRenderService.RenderToStringAsync("DbNetGrid", _DbNetGridConfiguration); GetPage(); _DbNetGridConfiguration.Html["page"] = await _viewRenderService.RenderToStringAsync("DbNetGrid_Page", _DbNetGridConfiguration); break; case "page": GetPage(); _DbNetGridConfiguration.Html["page"] = await _viewRenderService.RenderToStringAsync("DbNetGrid_Page", _DbNetGridConfiguration); break; } Db.Close(); context.Response.ContentType = "application/json"; await context.Response.WriteAsync(SerialisationHelper.SerialiseToJson(_DbNetGridConfiguration)); // await _next.Invoke(context); }
public void Publish(HealthCheckResult message) { var data = SerialisationHelper <HealthCheckResult> .DataContractSerialize(message); using (var cmd = SQLiteAdhocCommand.UsingSmartConnection(myConfig.ConnectionString) .WithSql(SQLiteStatement.Create("INSERT INTO AgentData (") .Append("TypeId,EventType,SiteId,AgentId,CheckId,Result,ResultCount,GeneratedOnUtc,ReceivedOnUtc,Data,Tags,Version,MinuteBucket,HourBucket,DayBucket") .Append(") VALUES (") .InsertParameter("@pTypeId", message.Check.Identity.TypeId).Append(",") .InsertParameter("@pEventType", message.EventType).Append(",") .InsertParameter("@pSiteId", message.Agent.SiteId).Append(",") .InsertParameter("@pAgentId", message.Agent.AgentId).Append(",") .InsertParameter("@pCheckId", message.Check.Identity.Name).Append(",") .InsertParameter("@pResult", message.Check.Result).Append(",") .InsertParameter("@pResultCount", message.Check.ResultCount).Append(",") .InsertParameter("@pGeneratedOnUtc", message.Check.GeneratedOnUtc).Append(",") .InsertParameter("@pReceivedOnUtc", DateTime.UtcNow).Append(",") .InsertParameter("@pData", data).Append(",") .InsertParameter("@pTags", message.Check.Tags).Append(",") .InsertParameter("@pVersion", message.Id).Append(",") .InsertParameter("@pMinuteBucket", message.MinuteBucket).Append(",") .InsertParameter("@pHourBucket", message.HourBucket).Append(",") .InsertParameter("@pDayBucket", message.DayBucket) .Append(")"))) { cmd.ExecuteNonQuery(); } }
public bool doFileOpen() { if (closeFileOkToContinueDialoge()) { OpenFileDialog od = new OpenFileDialog(); od.Filter = fileDialogExtensionFilter; od.CheckFileExists = true; if (od.ShowDialog() == DialogResult.OK) { try { if (onOpenFile == null) { _document = SerialisationHelper <DOCTYPE> .open(od.FileName, serializationFormats.binary); } else { _document = onOpenFile(od.FileName); } _documentLastVersionIsSaved = true; _doumentFilePath = od.FileName; onUpdate(); return(true); } catch (Exception ex) { MessageBox.Show(string.Format("The file {0} could not be opened becasue the following error occured: {1}", od.FileName, ex.Message), "Could not open file."); onUpdate(); } } } return(false); }
public void Write <T>(List <T> entityList) { _memoryInstance.Write(entityList); var filePath = DetermineFilePath <T>(); var xmlContent = SerialisationHelper.Serialize(entityList); File.WriteAllText(filePath, xmlContent); }
private List <T> LoadEntityFile <T>() { var entityFilePath = DetermineFilePath <T>(); if (File.Exists(entityFilePath)) { var entityContents = SerialisationHelper.Deserialise <T>(entityFilePath); _memoryInstance.Write(entityContents); return(entityContents); } return(new List <T>()); }
private void saveFile(String fileName) { try { if (onSaveFile == null) { SerialisationHelper <DOCTYPE> .save(fileName, Document, serializationFormats.binary); } else { onSaveFile(fileName); } _documentLastVersionIsSaved = true; _doumentFilePath = fileName; } catch (Exception ex) { MessageBox.Show(string.Format("The file {0} could not be saved because the following error occured: {1}", fileName, ex.Message), "Error occored saving file."); } }
public void Publish(HealthCheckAgentStart message) { var data = SerialisationHelper <HealthCheckAgentStart> .DataContractSerialize(message); using (var cmd = SQLiteAdhocCommand.UsingSmartConnection(myConfig.ConnectionString) .WithSql(SQLiteStatement.Create("INSERT INTO AgentData (") .Append("TypeId,EventType,SiteId,AgentId,GeneratedOnUtc,ReceivedOnUtc,Data,Version") .Append(") VALUES (") .InsertParameter("@pTypeId", message.Id).Append(",") .InsertParameter("@pEventType", "SessionStart").Append(",") .InsertParameter("@pSiteId", message.Agent.SiteId).Append(",") .InsertParameter("@pAgentId", message.Agent.AgentId).Append(",") .InsertParameter("@pGeneratedOnUtc", message.DiscoveryStarted).Append(",") .InsertParameter("@pReceivedOnUtc", DateTime.UtcNow).Append(",") .InsertParameter("@pData", data).Append(",") .InsertParameter("@pVersion", message.Id) .Append(")"))) { cmd.ExecuteNonQuery(); } }