update nach Schuelererfassung
This commit is contained in:
46
BlazorApp - Kopie (4)/Helper/EMailSender.cs
Normal file
46
BlazorApp - Kopie (4)/Helper/EMailSender.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Helper
|
||||
{
|
||||
public class EmailSender : IEmailSender
|
||||
{
|
||||
|
||||
// Our private configuration variables
|
||||
private string host;
|
||||
private int port;
|
||||
private bool enableSSL;
|
||||
private string userName;
|
||||
private string password;
|
||||
|
||||
// Get our parameterized configuration
|
||||
public EmailSender(string host, int port, bool enableSSL, string userName, string password)
|
||||
{
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.enableSSL = enableSSL;
|
||||
this.userName = userName;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
// Use our configuration to send the email by using SmtpClient
|
||||
public Task SendEmailAsync(string email, string subject, string htmlMessage)
|
||||
{
|
||||
|
||||
|
||||
var client = new SmtpClient(host, port)
|
||||
{
|
||||
Credentials = new NetworkCredential(userName, password),
|
||||
EnableSsl = enableSSL
|
||||
};
|
||||
return client.SendMailAsync(
|
||||
new MailMessage(userName, email, subject, htmlMessage) { IsBodyHtml = true }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
866
BlazorApp - Kopie (4)/Helper/ExampleService.cs
Normal file
866
BlazorApp - Kopie (4)/Helper/ExampleService.cs
Normal file
@@ -0,0 +1,866 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BlazorApp
|
||||
{
|
||||
public class ExampleService
|
||||
{
|
||||
Example[] allExamples = new[] {
|
||||
new Example()
|
||||
{
|
||||
Name = "First Look",
|
||||
Path = "/",
|
||||
Icon = ""
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Dashboard",
|
||||
Path = "/dashboard",
|
||||
Icon = ""
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Get Started",
|
||||
Title = "How to get started with the Radzen Blazor components",
|
||||
Path = "/get-started",
|
||||
Icon = ""
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Support",
|
||||
Title = "How to get support for the Radzen Blazor components",
|
||||
Path = "/support",
|
||||
Icon = ""
|
||||
},
|
||||
|
||||
new Example()
|
||||
{
|
||||
Name="DataGrid",
|
||||
Children = new [] {
|
||||
new Example
|
||||
{
|
||||
Name = "Data-binding",
|
||||
Icon = "",
|
||||
Children = new [] {
|
||||
new Example
|
||||
{
|
||||
Name = "IQueryable",
|
||||
Path = "datagrid",
|
||||
Tags = new [] { "datatable", "datagridview", "dataview", "grid", "table" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "LoadData event",
|
||||
Path = "datagrid-loaddata",
|
||||
Title = "Blazor DataGrid custom data-binding",
|
||||
Tags = new [] { "datagrid", "bind", "load", "data", "loaddata", "custom" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "OData service",
|
||||
Path = "datagrid-odata",
|
||||
Title = "Blazor DataGrid OData data-binding",
|
||||
Icon = "",
|
||||
Tags = new [] { "datagrid", "bind", "load", "data", "loaddata", "odata", "service", "rest" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Dynamic data",
|
||||
Path = "datagrid-dynamic",
|
||||
Title = "Blazor DataGrid binding dynamic data",
|
||||
Icon = "",
|
||||
Tags = new [] { "datagrid", "bind", "load", "data", "loaddata", "dynamic" }
|
||||
},
|
||||
}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Virtualization",
|
||||
Icon = "",
|
||||
Children = new []
|
||||
{
|
||||
new Example
|
||||
{
|
||||
Name = "IQueryable support",
|
||||
Path = "datagrid-virtualization",
|
||||
Title = "Blazor DataGrid IQueryable virtualization",
|
||||
Tags = new [] { "datagrid", "bind", "load", "data", "virtualization", "ondemand" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "LoadData support",
|
||||
Path = "datagrid-virtualization-loaddata",
|
||||
Title = "Blazor DataGrid custom virtualization",
|
||||
Tags = new [] { "datagrid", "bind", "load", "data", "loaddata", "virtualization", "ondemand" }
|
||||
},
|
||||
}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Columns",
|
||||
Icon = "",
|
||||
Children = new []
|
||||
{
|
||||
new Example
|
||||
{
|
||||
Name = "Template",
|
||||
Path = "datagrid-column-template",
|
||||
Title = "Blazor DataGrid column template",
|
||||
Tags = new [] { "column", "template", "grid", "datagrid", "table"}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Resizing",
|
||||
Path = "datagrid-column-resizing",
|
||||
Title = "Blazor DataGrid column resizing",
|
||||
Tags = new [] { "column", "resizing", "grid", "datagrid", "table"}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Footer Totals",
|
||||
Path = "datagrid-footer-totals",
|
||||
Title = "Blazor DataGrid footer totals",
|
||||
Tags = new [] { "summary", "total", "aggregate", "datagrid", "table", "dataview" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Filter Template",
|
||||
Path = "datagrid-filter-template",
|
||||
Title = "Blazor DataGrid custom filtering",
|
||||
Tags = new [] { "datagrid", "column", "filter", "template" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Frozen Columns",
|
||||
Path = "datagrid-frozen-columns",
|
||||
Title = "Blazor DataGrid frozen columns",
|
||||
Tags = new [] { "datagrid", "column", "frozen", "locked" }
|
||||
}
|
||||
}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Filtering",
|
||||
Icon = "",
|
||||
Children = new []
|
||||
{
|
||||
new Example
|
||||
{
|
||||
Name = "Simple Mode",
|
||||
Path = "datagrid-simple-filter",
|
||||
Title = "Blazor DataGrid Simple filter mode",
|
||||
Tags = new [] { "filter", "simple", "grid", "datagrid", "table"}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Advanced Mode",
|
||||
Path = "datagrid-advanced-filter",
|
||||
Title = "Blazor DataGrid Simple filter mode",
|
||||
Tags = new [] { "filter", "advanced", "grid", "datagrid", "table"}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Filter API",
|
||||
Path = "datagrid-filter-api",
|
||||
Title = "Blazor DataGrid Filter API",
|
||||
Tags = new [] { "filter", "api", "grid", "datagrid", "table"}
|
||||
},
|
||||
}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Hierarchy",
|
||||
Icon = "",
|
||||
Children = new []
|
||||
{
|
||||
new Example
|
||||
{
|
||||
Name = "Hierarchy",
|
||||
Path = "master-detail-hierarchy",
|
||||
Title = "Blazor DataGrid Hierarchy",
|
||||
Tags = new [] { "master", "detail", "datagrid", "table", "dataview" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Hierarchy on demand",
|
||||
Path = "master-detail-hierarchy-demand",
|
||||
Title = "Blazor DataGrid Hierarchy on demand",
|
||||
Tags = new [] { "master", "detail", "datagrid", "table", "dataview", "on-demand" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Master/Detail",
|
||||
Path = "master-detail",
|
||||
Title = "Master and detail Blazor DataGrid",
|
||||
Tags = new [] { "master", "detail", "datagrid", "table", "dataview" }
|
||||
},
|
||||
}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Selection",
|
||||
Icon = "",
|
||||
Children = new []
|
||||
{
|
||||
new Example
|
||||
{
|
||||
Name = "Single selection",
|
||||
Path = "datagrid-single-selection",
|
||||
Title = "Blazor DataGrid single selection",
|
||||
Tags = new [] { "single", "selection", "datagrid", "table", "dataview" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Multiple selection",
|
||||
Path = "datagrid-multiple-selection",
|
||||
Title = "Blazor DataGrid Multiple selection",
|
||||
Tags = new [] { "multiple", "selection", "datagrid", "table", "dataview" }
|
||||
},
|
||||
}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Sorting",
|
||||
Icon = "",
|
||||
Children = new []
|
||||
{
|
||||
new Example
|
||||
{
|
||||
Name = "Single Column Sorting",
|
||||
Path = "datagrid-sort",
|
||||
Title = "Blazor DataGrid sorting",
|
||||
Tags = new [] { "single", "sort", "datagrid", "table", "dataview" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Multiple Column Sorting",
|
||||
Path = "datagrid-multi-sort",
|
||||
Title = "Blazor DataGrid multiple column sorting",
|
||||
Tags = new [] { "multi", "sort", "datagrid", "table", "dataview" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Sort API",
|
||||
Path = "datagrid-sort-api",
|
||||
Title = "Blazor DataGrid Sort API",
|
||||
Tags = new [] { "api", "sort", "datagrid", "table", "dataview" }
|
||||
}
|
||||
}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Paging",
|
||||
Icon = "",
|
||||
Children = new []
|
||||
{
|
||||
new Example
|
||||
{
|
||||
Name = "Pager Position",
|
||||
Path = "datagrid-pager-position",
|
||||
Title = "Blazor DataGrid pager position",
|
||||
Tags = new [] { "pager", "paging", "datagrid", "table", "dataview" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Pager API",
|
||||
Path = "datagrid-pager-api",
|
||||
Title = "Blazor DataGrid pager API",
|
||||
Tags = new [] { "pager", "paging", "api", "datagrid", "table", "dataview" }
|
||||
}
|
||||
}
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "InLine Editing",
|
||||
Path = "datagrid-inline-edit",
|
||||
Title = "Blazor DataGrid InLine Editing",
|
||||
Icon = "",
|
||||
Tags = new [] { "inline", "editor", "datagrid", "table", "dataview" }
|
||||
},
|
||||
|
||||
new Example()
|
||||
{
|
||||
Name = "Conditional formatting",
|
||||
Path = "datagrid-conditional-template",
|
||||
Title = "DataGrid conditional template",
|
||||
Icon = "",
|
||||
Tags = new [] { "conditional", "template", "style", "datagrid", "table", "dataview" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Export to Excel and CSV",
|
||||
Path = "export-excel-csv",
|
||||
Title = "Blazor DataGrid export to Excel and CSV",
|
||||
Icon = "",
|
||||
Tags = new [] { "export", "excel", "csv" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Cascading DropDowns",
|
||||
Path = "cascading-dropdowns",
|
||||
Title = "Blazor Cascading DropDowns",
|
||||
Icon = "",
|
||||
Tags = new [] { "related", "parent", "child" }
|
||||
},
|
||||
}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name="Data",
|
||||
Children = new [] {
|
||||
new Example()
|
||||
{
|
||||
Name = "DataList",
|
||||
Path = "datalist",
|
||||
Icon = "",
|
||||
Tags = new [] { "dataview", "grid", "table" }
|
||||
},
|
||||
|
||||
new Example()
|
||||
{
|
||||
Name = "Pager",
|
||||
Path = "pager",
|
||||
Icon = "",
|
||||
Tags = new [] { "pager", "paging" }
|
||||
},
|
||||
|
||||
new Example()
|
||||
{
|
||||
Name = "Tree",
|
||||
Path = "tree",
|
||||
Icon = "",
|
||||
Tags = new [] { "tree", "treeview", "nodes", "hierarchy" }
|
||||
},
|
||||
|
||||
new Example()
|
||||
{
|
||||
Name = "Scheduler",
|
||||
Path = "scheduler",
|
||||
Icon = "",
|
||||
Tags = new [] { "scheduler", "calendar", "event", "appointment"}
|
||||
},
|
||||
}
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name="HtmlEditor",
|
||||
Children = new [] {
|
||||
new Example()
|
||||
{
|
||||
Name = "Default Tools",
|
||||
Path = "html-editor",
|
||||
Icon = "",
|
||||
Tags = new [] { "html", "editor", "rich", "text" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Custom Tools",
|
||||
Path = "html-editor-custom-tools",
|
||||
Icon = "",
|
||||
Tags = new [] { "html", "editor", "rich", "text", "tool", "custom" }
|
||||
},
|
||||
}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name="Charts",
|
||||
Children= new [] {
|
||||
new Example
|
||||
{
|
||||
Name = "Line Chart",
|
||||
Path = "line-chart",
|
||||
Icon = "",
|
||||
Tags = new [] { "chart", "graph", "line" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Area Chart",
|
||||
Path = "area-chart",
|
||||
Icon = "",
|
||||
Tags = new [] { "chart", "graph", "area" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Column Chart",
|
||||
Path = "column-chart",
|
||||
Icon = "",
|
||||
Tags = new [] { "chart", "graph", "column", "bar" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Bar Chart",
|
||||
Path = "bar-chart",
|
||||
Icon = "",
|
||||
Tags = new [] { "chart", "graph", "column", "bar" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Pie Chart",
|
||||
Path = "pie-chart",
|
||||
Icon = "",
|
||||
Tags = new [] { "chart", "graph", "pie" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Donut Chart",
|
||||
Path = "donut-chart",
|
||||
Icon = "",
|
||||
Tags = new [] { "chart", "graph", "donut" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Styling",
|
||||
Path = "styling-chart",
|
||||
Icon = "",
|
||||
Tags = new [] { "chart", "graph", "styling" }
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
new Example()
|
||||
{
|
||||
Name="Forms",
|
||||
Children = new [] {
|
||||
new Example()
|
||||
{
|
||||
Name = "AutoComplete",
|
||||
Path = "autocomplete",
|
||||
Icon = "",
|
||||
Tags = new [] { "form", "complete", "suggest", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Switch",
|
||||
Path = "switch",
|
||||
Icon = "",
|
||||
Tags = new [] { "form", "edit", "switch" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "CheckBox",
|
||||
Path = "checkbox",
|
||||
Icon = "",
|
||||
Tags = new [] { "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "CheckBoxList",
|
||||
Path = "checkboxlist",
|
||||
Icon = "",
|
||||
Tags = new [] { "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "ColorPicker",
|
||||
Path = "colorpicker",
|
||||
Icon = "",
|
||||
Tags = new [] { "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "DatePicker",
|
||||
Path = "datepicker",
|
||||
Icon = "",
|
||||
Tags = new [] { "calendar", "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "DropDown",
|
||||
Path = "dropdown",
|
||||
Icon = "",
|
||||
Tags = new [] { "select", "picker", "form" , "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "DropDownDataGrid",
|
||||
Path = "dropdown-datagrid",
|
||||
Icon = "",
|
||||
Tags = new [] { "select", "picker", "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "FileInput",
|
||||
Path = "fileinput",
|
||||
Icon = "",
|
||||
Tags = new [] { "upload", "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "ListBox",
|
||||
Path = "listbox",
|
||||
Icon = "",
|
||||
Tags = new [] { "select", "picker", "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Numeric",
|
||||
Path = "numeric",
|
||||
Icon = "",
|
||||
Tags = new [] { "input", "number", "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Password",
|
||||
Path = "password",
|
||||
Icon = "",
|
||||
Tags = new [] { "input", "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "RadioButtonList",
|
||||
Path = "radiobuttonlist",
|
||||
Icon = "",
|
||||
Tags = new [] { "toggle", "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Rating",
|
||||
Path = "rating",
|
||||
Icon = "",
|
||||
Tags = new [] { "star", "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "SelectBar",
|
||||
Path = "selectbar",
|
||||
Icon = "",
|
||||
Tags = new [] { "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Slider",
|
||||
Path = "slider",
|
||||
Icon = "",
|
||||
Tags = new [] { "form", "slider" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "TemplateForm",
|
||||
Path = "templateform",
|
||||
Icon = "",
|
||||
Tags = new [] { "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "TextBox",
|
||||
Path = "textbox",
|
||||
Icon = "",
|
||||
Tags = new [] { "input", "form", "edit" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Mask",
|
||||
Path = "mask",
|
||||
Icon = "",
|
||||
Tags = new [] { "input", "form", "edit", "mask" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "TextArea",
|
||||
Path = "textarea",
|
||||
Icon = "",
|
||||
Tags = new [] { "input", "form", "edit" }
|
||||
},
|
||||
},
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Validators",
|
||||
Children = new [] {
|
||||
new Example()
|
||||
{
|
||||
Name = "RequiredValidator",
|
||||
Path = "requiredvalidator",
|
||||
Icon = "",
|
||||
Tags = new [] { "validator", "validation", "required"}
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "LengthValidator",
|
||||
Path = "lengthvalidator",
|
||||
Icon = "",
|
||||
Tags = new [] { "validator", "validation", "required", "length"}
|
||||
} ,
|
||||
new Example()
|
||||
{
|
||||
Name = "NumericRangeValidator",
|
||||
Path = "numericrangevalidator",
|
||||
Icon = "",
|
||||
Tags = new [] { "validator", "validation", "required", "range"}
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "CompareValidator",
|
||||
Path = "comparevalidator",
|
||||
Icon = "",
|
||||
Tags = new [] { "validator", "validation", "required", "compare"}
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "EmailValidator",
|
||||
Path = "emailvalidator",
|
||||
Icon = "",
|
||||
Tags = new [] { "validator", "validation", "required", "email"}
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "RegexValidator",
|
||||
Path = "regexvalidator",
|
||||
Icon = "",
|
||||
Tags = new [] { "validator", "validation", "pattern", "regex", "regular", "expression"}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
new Example()
|
||||
{
|
||||
Name="Containers",
|
||||
Children = new [] {
|
||||
new Example()
|
||||
{
|
||||
Name = "Accordion",
|
||||
Path = "accordion",
|
||||
Icon = "",
|
||||
Tags = new [] { "panel", "container" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Card",
|
||||
Path = "card",
|
||||
Icon = "",
|
||||
Tags = new [] { "container" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Fieldset",
|
||||
Path = "fieldset",
|
||||
Icon = "",
|
||||
Tags = new [] { "form", "container" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Panel",
|
||||
Path = "panel",
|
||||
Icon = "",
|
||||
Tags = new [] { "container" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Tabs",
|
||||
Path = "tabs",
|
||||
Icon = "",
|
||||
Tags = new [] { "tabstrip", "tabview", "container" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Steps",
|
||||
Path = "steps",
|
||||
Icon = "",
|
||||
Tags = new [] { "step", "steps", "wizard" }
|
||||
},
|
||||
}
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name="Gauges",
|
||||
Children= new [] {
|
||||
new Example
|
||||
{
|
||||
Name = "Radial Gauge",
|
||||
Path = "radial-gauge",
|
||||
Icon = "",
|
||||
Tags = new [] { "gauge", "graph", "radial", "circle" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Arc Gauge",
|
||||
Path = "arc-gauge",
|
||||
Icon = "",
|
||||
Tags = new [] { "gauge", "graph", "arc", "progress" }
|
||||
},
|
||||
new Example
|
||||
{
|
||||
Name = "Styling Gauge",
|
||||
Path = "styling-gauge",
|
||||
Icon = "",
|
||||
Tags = new [] { "gauge", "graph", "styling" }
|
||||
},
|
||||
}
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Misc",
|
||||
Children = new [] {
|
||||
new Example()
|
||||
{
|
||||
Name = "Button",
|
||||
Path = "button",
|
||||
Icon = ""
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "GoogleMap",
|
||||
Path = "googlemap",
|
||||
Icon = ""
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Gravatar",
|
||||
Path = "gravatar",
|
||||
Icon = ""
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "SplitButton",
|
||||
Path = "splitbutton",
|
||||
Icon = ""
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Icon",
|
||||
Path = "icon",
|
||||
Icon = ""
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Image",
|
||||
Path = "image",
|
||||
Icon = ""
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Link",
|
||||
Path = "link",
|
||||
Icon = ""
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Login",
|
||||
Path = "login",
|
||||
Icon = ""
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "ProgressBar",
|
||||
Path = "progressbar",
|
||||
Icon = "",
|
||||
Tags = new [] { "progress", "spinner" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Dialog",
|
||||
Path = "dialog",
|
||||
Icon = "",
|
||||
Tags = new [] { "popup", "window" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Notification",
|
||||
Path = "notification",
|
||||
Icon = "",
|
||||
Tags = new [] { "message", "alert" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Tooltip",
|
||||
Path = "tooltip",
|
||||
Icon = "",
|
||||
Tags = new [] { "popup", "tooltip" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Menu",
|
||||
Path = "menu",
|
||||
Icon = "",
|
||||
Tags = new [] { "navigation", "dropdown" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "PanelMenu",
|
||||
Path = "panelmenu",
|
||||
Icon = "",
|
||||
Tags = new [] { "navigation", "menu" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "ContextMenu",
|
||||
Path = "contextmenu",
|
||||
Icon = "",
|
||||
Tags = new [] { "popup", "dropdown", "menu" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "ProfileMenu",
|
||||
Path = "profile-menu",
|
||||
Icon = "",
|
||||
Tags = new [] { "navigation", "dropdown", "menu" }
|
||||
},
|
||||
new Example()
|
||||
{
|
||||
Name = "Upload",
|
||||
Path = "example-upload",
|
||||
Icon = "",
|
||||
Tags = new [] { "upload", "file"}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
public IEnumerable<Example> Examples
|
||||
{
|
||||
get
|
||||
{
|
||||
return allExamples;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Example> Filter(string term)
|
||||
{
|
||||
bool contains(string value) => value.Contains(term, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
bool filter(Example example) => contains(example.Name) || (example.Tags != null && example.Tags.Any(contains));
|
||||
|
||||
bool deepFilter(Example example) => filter(example) || example.Children?.Any(filter) == true;
|
||||
|
||||
return Examples.Where(category => category.Children?.Any(deepFilter) == true)
|
||||
.Select(category => new Example
|
||||
{
|
||||
Name = category.Name,
|
||||
Expanded = true,
|
||||
Children = category.Children.Where(deepFilter).Select(example => new Example
|
||||
{
|
||||
Name = example.Name,
|
||||
Path = example.Path,
|
||||
Icon = example.Icon,
|
||||
Expanded = true,
|
||||
Children = example.Children
|
||||
}
|
||||
).ToArray()
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public Example FindCurrent(Uri uri)
|
||||
{
|
||||
return Examples.SelectMany(example => example.Children ?? new[] { example })
|
||||
.FirstOrDefault(example => example.Path == uri.AbsolutePath || $"/{example.Path}" == uri.AbsolutePath);
|
||||
}
|
||||
|
||||
public string TitleFor(Example example)
|
||||
{
|
||||
if (example != null && example.Name != "First Look")
|
||||
{
|
||||
return example.Title ?? $"Blazor {example.Name} | a free UI component by Radzen";
|
||||
}
|
||||
|
||||
return "Free Blazor Components | 60+ controls by Radzen";
|
||||
}
|
||||
|
||||
public string DescriptionFor(Example example)
|
||||
{
|
||||
return example?.Description ?? "The Radzen Blazor component library provides more than 50 UI controls for building rich ASP.NET Core web applications.";
|
||||
}
|
||||
}
|
||||
}
|
||||
109
BlazorApp - Kopie (4)/Helper/HttpClientHelper.cs
Normal file
109
BlazorApp - Kopie (4)/Helper/HttpClientHelper.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace BlazorApp.Helper
|
||||
{
|
||||
public class HttpClientHelper
|
||||
{
|
||||
string apikey = "";
|
||||
public class DataStore<T>
|
||||
{
|
||||
//public T Data { get; set; }
|
||||
public string daten { get; set; }
|
||||
public bool resultstatus { get; set; }
|
||||
public string resultstatuscode { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public HttpResponseMessage ResponsTask;
|
||||
public HttpResponseMessage ResponsResult;
|
||||
public DataStore<object> Results = new DataStore<object>();
|
||||
public string BaseAPI = "";
|
||||
|
||||
string uri = "";
|
||||
public HttpClientHelper()
|
||||
{
|
||||
Helper.ParameterHelper ph = new Helper.ParameterHelper();
|
||||
uri = ph.GetParameter("API");
|
||||
apikey = ph.GetParameter("ApiKey");
|
||||
}
|
||||
|
||||
public void CallService(string api, string key, string fnkt, Object daten)
|
||||
{
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
client.BaseAddress = new Uri(uri);
|
||||
client.DefaultRequestHeaders.Add("ApiKey", apikey);
|
||||
|
||||
switch (fnkt)
|
||||
{
|
||||
|
||||
case "GET":
|
||||
if (key!="")
|
||||
{
|
||||
api = api+ "/" + key;
|
||||
}
|
||||
var responseTask = client.GetAsync(api);
|
||||
responseTask.Wait();
|
||||
var result = responseTask.Result;
|
||||
Results.resultstatus = responseTask.IsCompletedSuccessfully;
|
||||
if (result.IsSuccessStatusCode)
|
||||
{
|
||||
var readTask = result.Content.ReadAsStringAsync();
|
||||
readTask.Wait();
|
||||
//DataStore<object> ds = new DataStore<object>();
|
||||
|
||||
|
||||
Results.daten = readTask.Result;
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case "PUT":
|
||||
if (key != "")
|
||||
{
|
||||
api = api+ "/" + key;
|
||||
}
|
||||
var response = client.PutAsJsonAsync(api, daten).Result;
|
||||
Results.resultstatuscode = response.StatusCode.ToString();
|
||||
break;
|
||||
case "POST":
|
||||
|
||||
var postresponse = client.PostAsJsonAsync(api, daten).Result;
|
||||
Results.resultstatuscode = postresponse.StatusCode.ToString();
|
||||
break;
|
||||
case "DELETE":
|
||||
if (key != "")
|
||||
{
|
||||
api = api + "/" + key;
|
||||
}
|
||||
var deleteresponse = client.DeleteAsync(api).Result;
|
||||
Results.resultstatuscode = deleteresponse.StatusCode.ToString();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// var responseTask = client.GetAsync("user");
|
||||
//responseTask.Wait();
|
||||
|
||||
//var result = responseTask.Result;
|
||||
//if (result.IsSuccessStatusCode)
|
||||
//{
|
||||
// var readTask = result.Content.ReadAsStringAsync();
|
||||
// readTask.Wait();
|
||||
// DataStore<object> ds = new DataStore<object>();
|
||||
// ds.Data = readTask;
|
||||
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
146
BlazorApp - Kopie (4)/Helper/MenuService.cs
Normal file
146
BlazorApp - Kopie (4)/Helper/MenuService.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorApp.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BlazorApp
|
||||
{
|
||||
public class MenuService
|
||||
{
|
||||
|
||||
MenuItem[] CompanyMenu = new[] {
|
||||
new MenuItem()
|
||||
{ Name = "Home", Path = "/", Icon = "home" },
|
||||
new MenuItem()
|
||||
{ Name = "Dashboard", Path = "/Admin/Dashboard", Icon = "dashboard" },
|
||||
new MenuItem()
|
||||
{ Name = "Firmen-Daten", Path = "/Company/Company", Icon = "account_balance" },
|
||||
new MenuItem()
|
||||
{ Name = "Ansprechpartner", Path = "/Company/CompanyContact", Icon = "account_balance" },
|
||||
new MenuItem()
|
||||
{ Name = "Berufsangebot", Path = "/Company/Berufsangebot", Icon = "account_balance" },
|
||||
//new MenuItem()
|
||||
//{ Name = "Auswertungen",Icon = "account_balance" },
|
||||
new MenuItem()
|
||||
{
|
||||
Name = "Auswertungen",Icon="Home",
|
||||
Children = new []
|
||||
{
|
||||
new MenuItem() {Name="Firmen/Angebot",Path = "/Reporting/Reporting/1"},
|
||||
new MenuItem() {Name="Dokumente",Path = "/Reporting/Reprots/ReportNr=2"},
|
||||
},
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
MenuItem[] TeacherMenu = new[] {
|
||||
new MenuItem()
|
||||
{ Name = "Home", Path = "/", Icon = "home" },
|
||||
new MenuItem()
|
||||
{ Name = "Dashboard", Path = "/Teacher/Dashboard", Icon = "dashboard" },
|
||||
new MenuItem()
|
||||
{ Name = "Stammdaten", Path = "/Teacher/TeacherContact", Icon = "account_balance" },
|
||||
new MenuItem()
|
||||
{ Name = "Schüler/Berufswahl", Path = "/Teacher/TeacherStudent", Icon = "account_balance" },
|
||||
new MenuItem()
|
||||
{
|
||||
Name = "Auswertungen",Icon="Home",
|
||||
Children = new []
|
||||
{
|
||||
new MenuItem() {Name="Firmen/Angebot",Path = "/Reporting/Reporting/1"},
|
||||
new MenuItem() {Name="Dokumente",Path = "/Reporting/Reprots/ReportNr=2"},
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
MenuItem[] AdminMenu = new[] {
|
||||
new MenuItem()
|
||||
{ Name = "Home", Path = "/", Icon = "home" },
|
||||
new MenuItem()
|
||||
{ Name = "Dashboard", Path = "/Admin/Dashboard", Icon = "dashboard" },
|
||||
new MenuItem()
|
||||
{ Name = "Firmen", Path = "/Admin/Firmen", Icon = "account_balance" },
|
||||
new MenuItem()
|
||||
{ Name = "Schüler", Path = "/Admin/Schueler", Icon = "accessibility" },
|
||||
new MenuItem()
|
||||
{ Name = "Zuteilung", Path = "/Admin/Zuteilung", Icon = "grade" },
|
||||
new MenuItem()
|
||||
{ Name = "Auswertungen", Path = "/Admin/Reporting", Icon = "list" },
|
||||
|
||||
new MenuItem()
|
||||
{ Name = "Administration", Icon="build",
|
||||
Children = new [] {
|
||||
new MenuItem()
|
||||
{
|
||||
Name = "Stammdaten",Icon="Home",
|
||||
Children = new []
|
||||
{
|
||||
new MenuItem() {Name="Einstellungen",Path = "Admin/Optionen/OptionenList"},
|
||||
new MenuItem() {Name="Benutzer",Path = "Admin/AspNetUsers/AspNetUserRolleList"},
|
||||
new MenuItem() {Name="Berufe",Path = "Admin/Beruf/BerufList"},
|
||||
new MenuItem() {Name="Zeiten",Path = "Admin/Zeiten/ZeitenList"},
|
||||
new MenuItem() {Name="Schulhaus",Path = "Admin/Schulhaus/Schulhauslist"},
|
||||
new MenuItem() {Name="Lehrer",Path = "Admin/Lehrer"},
|
||||
new MenuItem() {Name="Klassen",Path = "Admin/Klassen"},
|
||||
new MenuItem() {Name="Klassentyp",Path = "Admin/Klassentyp/Klassentyplist"},
|
||||
new MenuItem() {Name="Zugehörigkeit",Path = "Admin/Zugehörigkeit"},
|
||||
new MenuItem() {Name="Anrede",Path = "Admin/Anrede/AnredeList"},
|
||||
},
|
||||
},
|
||||
new MenuItem()
|
||||
{
|
||||
Name = "Auswertungen",Icon="Home",
|
||||
Children = new []
|
||||
{
|
||||
new MenuItem() {Name="Definition",Path = "Admin/Reporting/Defintion"},
|
||||
new MenuItem() {Name="Dokumente",Path = "Admin/Reporting/Dokumente"},
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
new MenuItem()
|
||||
{
|
||||
Name = "Schulhaus",
|
||||
Path = "User/Userlist"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public IEnumerable<MenuItem> MenuComapny
|
||||
{
|
||||
get
|
||||
{
|
||||
return CompanyMenu;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<MenuItem> MenuTeacher
|
||||
{
|
||||
get
|
||||
{
|
||||
return TeacherMenu;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<MenuItem> MenuAdmin
|
||||
{
|
||||
get
|
||||
{
|
||||
return AdminMenu;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
34
BlazorApp - Kopie (4)/Helper/ParameterHelper.cs
Normal file
34
BlazorApp - Kopie (4)/Helper/ParameterHelper.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Helper
|
||||
{
|
||||
public class ParameterHelper
|
||||
{
|
||||
public string GetParameter(string Keyvalue)
|
||||
{
|
||||
var configuation = GetConfiguration();
|
||||
return configuation.GetSection("Appsettings").GetSection(Keyvalue).Value;
|
||||
}
|
||||
public string GetConnString(string Keyvalue)
|
||||
{
|
||||
var configuation = GetConfiguration();
|
||||
return configuation.GetSection("ConnectionStrings").GetSection(Keyvalue).Value;
|
||||
}
|
||||
|
||||
public IConfigurationRoot GetConfiguration()
|
||||
{
|
||||
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
||||
return builder.Build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
13
BlazorApp - Kopie (4)/Helper/SessionState.cs
Normal file
13
BlazorApp - Kopie (4)/Helper/SessionState.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Helper
|
||||
{
|
||||
public class SessionState
|
||||
|
||||
{
|
||||
public string SessionUser { get; set; }
|
||||
}
|
||||
}
|
||||
292
BlazorApp - Kopie (4)/Helper/dbhelper.cs
Normal file
292
BlazorApp - Kopie (4)/Helper/dbhelper.cs
Normal file
@@ -0,0 +1,292 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlazorApp.Helper
|
||||
{
|
||||
public class dbhelper
|
||||
{
|
||||
//SqlConnection con;
|
||||
string connectionstring;
|
||||
public DataSet dsdaten = new DataSet();
|
||||
private SqlDataAdapter dadaten;
|
||||
public dbhelper()
|
||||
{
|
||||
var configuation = GetConfiguration();
|
||||
connectionstring = configuation.GetSection("ConnectionStrings").GetSection("BlazorAppContextConnection").Value;
|
||||
}
|
||||
|
||||
public string Get_Option(int ID)
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlDataAdapter dad = new SqlDataAdapter();
|
||||
|
||||
|
||||
string sql = "Select Inhalt from optionen where id=" + ID.ToString() ;
|
||||
DataTable data = new DataTable();
|
||||
|
||||
dad = new SqlDataAdapter(sql, this.connectionstring);
|
||||
|
||||
dad.Fill(data);
|
||||
string s;
|
||||
s = data.Rows[0][0].ToString();
|
||||
return s;
|
||||
dad.Dispose();
|
||||
data.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
int a = 1;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static DataTable ObjectToDataTable(object o)
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
List<PropertyInfo> properties = o.GetType().GetProperties().ToList();
|
||||
|
||||
foreach (PropertyInfo prop in properties)
|
||||
|
||||
dt.Columns.Add(prop.Name, prop.PropertyType);
|
||||
|
||||
dt.TableName = o.GetType().Name;
|
||||
|
||||
return dt;
|
||||
}
|
||||
public IConfigurationRoot GetConfiguration()
|
||||
{
|
||||
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
public DataTable Get_Tabledata(string Tablename, bool StoredProc = false, bool is_SQL_String = false)
|
||||
{
|
||||
SqlConnection sqlconnect = new SqlConnection();
|
||||
DataSet ds = new DataSet();
|
||||
ds.Tables.Clear();
|
||||
sqlconnect.ConnectionString = this.connectionstring;
|
||||
sqlconnect.Open();
|
||||
SqlDataAdapter da = new SqlDataAdapter("", sqlconnect);
|
||||
SqlCommand sqlcmd = new SqlCommand();
|
||||
sqlcmd.Connection = sqlconnect;
|
||||
if (StoredProc == true)
|
||||
{
|
||||
sqlcmd.CommandType = CommandType.StoredProcedure;
|
||||
if (Tablename.IndexOf("@@Mandantnr@@") > 0)
|
||||
Tablename = Tablename.Replace("@@Mandantnr@@", "");
|
||||
sqlcmd.CommandText = Tablename;
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlcmd.CommandType = CommandType.Text;
|
||||
sqlcmd.CommandText = "Select * from " + Tablename;
|
||||
}
|
||||
if (is_SQL_String == true)
|
||||
sqlcmd.CommandText = Tablename;
|
||||
da.SelectCommand = sqlcmd;
|
||||
da.Fill(dsdaten, "Daten");
|
||||
sqlconnect.Close();
|
||||
|
||||
return dsdaten.Tables[0];
|
||||
}
|
||||
|
||||
|
||||
public void Get_Tabeldata_for_Update(string Tablename, bool StoredProc = false, bool is_SQL_String = false)
|
||||
{
|
||||
dsdaten.Clear();
|
||||
dsdaten.Tables.Clear();
|
||||
dadaten = new SqlDataAdapter(Tablename, this.connectionstring);
|
||||
dadaten.Fill(dsdaten, Tablename);
|
||||
}
|
||||
public void Update_Tabeldata()
|
||||
{
|
||||
SqlCommandBuilder cb = new SqlCommandBuilder(dadaten);
|
||||
dadaten.Update(dsdaten, dsdaten.Tables[0].TableName);
|
||||
}
|
||||
|
||||
public Dictionary<string, List<object>> DatatableToDictionary(DataTable dataTable)
|
||||
{
|
||||
var dict = new Dictionary<string, List<object>>();
|
||||
foreach (DataColumn dataColumn in dataTable.Columns)
|
||||
{
|
||||
var columnValueList = new List<object>();
|
||||
|
||||
foreach (DataRow dataRow in dataTable.Rows)
|
||||
{
|
||||
columnValueList.Add(dataRow[dataColumn.ColumnName]);
|
||||
}
|
||||
|
||||
dict.Add(dataColumn.ColumnName, columnValueList);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
#region "Converters"
|
||||
|
||||
public List<T> ConvertDataTable<T>(DataTable dt)
|
||||
{
|
||||
List<T> data = new List<T>();
|
||||
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
T item = GetItem<T>(row);
|
||||
data.Add(item);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private T GetItem<T>(DataRow dr)
|
||||
{
|
||||
Type temp = typeof(T);
|
||||
T obj = Activator.CreateInstance<T>();
|
||||
|
||||
foreach (DataColumn column in dr.Table.Columns)
|
||||
{
|
||||
foreach (PropertyInfo pro in temp.GetProperties())
|
||||
{
|
||||
if (pro.Name == column.ColumnName)
|
||||
pro.SetValue(obj, dr[column.ColumnName], null/* TODO Change to default(_) if this is not a reference type */);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetEntities<T>(DataTable dt)
|
||||
{
|
||||
if (dt == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<T> returnValue = new List<T>();
|
||||
List<string> typeProperties = new List<string>();
|
||||
|
||||
T typeInstance = Activator.CreateInstance<T>();
|
||||
|
||||
foreach (DataColumn column in dt.Columns)
|
||||
{
|
||||
var prop = typeInstance.GetType().GetProperty(column.ColumnName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
|
||||
if (prop != null)
|
||||
{
|
||||
typeProperties.Add(column.ColumnName);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
T entity = Activator.CreateInstance<T>();
|
||||
|
||||
foreach (var propertyName in typeProperties)
|
||||
{
|
||||
|
||||
if (row[propertyName] != DBNull.Value)
|
||||
{
|
||||
string str = row[propertyName].GetType().FullName;
|
||||
|
||||
if (entity.GetType().GetProperty(propertyName).PropertyType == typeof(System.String))
|
||||
{
|
||||
object Val = row[propertyName].ToString();
|
||||
entity.GetType().GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(entity, Val, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, null, null);
|
||||
}
|
||||
else if (entity.GetType().GetProperty(propertyName).PropertyType == typeof(System.Guid))
|
||||
{
|
||||
object Val = Guid.Parse(row[propertyName].ToString());
|
||||
entity.GetType().GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(entity, Val, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.GetType().GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(entity, row[propertyName], BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, null, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.GetType().GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(entity, null, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
returnValue.Add(entity);
|
||||
}
|
||||
|
||||
return returnValue.AsEnumerable();
|
||||
}
|
||||
public string DataTableToJSONWithStringBuilder(DataTable table)
|
||||
{
|
||||
var JSONString = new StringBuilder();
|
||||
if (table.Rows.Count > 0)
|
||||
{
|
||||
JSONString.Append("[");
|
||||
for (int i = 0; i < table.Rows.Count; i++)
|
||||
{
|
||||
JSONString.Append("{");
|
||||
for (int j = 0; j < table.Columns.Count; j++)
|
||||
{
|
||||
if (j < table.Columns.Count - 1)
|
||||
{
|
||||
JSONString.Append("\"" + table.Columns[j].ColumnName.ToString() + "\":" + "\"" + table.Rows[i][j].ToString() + "\",");
|
||||
}
|
||||
else if (j == table.Columns.Count - 1)
|
||||
{
|
||||
JSONString.Append("\"" + table.Columns[j].ColumnName.ToString() + "\":" + "\"" + table.Rows[i][j].ToString() + "\"");
|
||||
}
|
||||
}
|
||||
if (i == table.Rows.Count - 1)
|
||||
{
|
||||
JSONString.Append("}");
|
||||
}
|
||||
else
|
||||
{
|
||||
JSONString.Append("},");
|
||||
}
|
||||
}
|
||||
JSONString.Append("]");
|
||||
}
|
||||
return JSONString.ToString();
|
||||
}
|
||||
public string ConvertDataTableToString(DataTable table)
|
||||
{
|
||||
int iColumnCount = table.Columns.Count;
|
||||
int iRowCount = table.Rows.Count;
|
||||
int iTempRowCount = 0;
|
||||
string strColumName = table.Columns[0].ColumnName;
|
||||
string strOut = "{";
|
||||
foreach (DataRow row in table.Rows)
|
||||
{
|
||||
strOut = strOut + "{";
|
||||
foreach (DataColumn col in table.Columns)
|
||||
{
|
||||
string val = row.Field<string>(col.ColumnName);
|
||||
strOut = strOut + col.ColumnName + ":" + val;
|
||||
|
||||
if (col.Ordinal != iColumnCount - 1)
|
||||
{
|
||||
strOut = strOut + ",";
|
||||
}
|
||||
}
|
||||
strOut = strOut + "}";
|
||||
iTempRowCount++;
|
||||
|
||||
if (iTempRowCount != iRowCount)
|
||||
{
|
||||
strOut = strOut + ",";
|
||||
}
|
||||
}
|
||||
strOut = strOut + "}";
|
||||
return strOut;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user