Skip to content

Instantly share code, notes, and snippets.

View talkingdotnet's full-sized avatar

Talking Dotnet talkingdotnet

View GitHub Profile
<ul class="nav navbar-nav navbar-right">
<li><a href="/Identity/Account/Register">Register</a></li>
<li><a href="/Identity/Account/Login">Login</a></li>
</ul>
services.AddIdentity<IdentityUser, IdentityRole>(options => options.Stores.MaxLengthForKeys = 128)
.AddEntityFrameworkStores<IdentityDbContext>()
.AddDefaultUI()
.AddDefaultTokenProviders();
import { Component, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-fetch-data',
templateUrl: './fetch-data.component.html'
})
export class FetchDataComponent {
public forecasts: WeatherForecast[];
public cacheForecasts: WeatherForecast[];
{
"AppSettings": {
"SQLConnectionString": "Server=DESKTOP-AT25PLJ\\SQLEXPRESS; Database=SampleDB;user=sa;password=pass@123;Trusted_Connection=False;",
"SourceDirectoryPath": "C:\\Temp",
"MySQLConnectionString": "Server=localhost;Database=sampledb;Uid=root;Pwd=pass@123;",
"DestinationDirectoryPath": "C:\\Temp"
}
}
private void Populate(DataTable dt, string tableName)
{
if (dt.Rows.Count == 0) return;
try
{
string truncateQuery = "Truncate Table `" + tableName + "`;"; //First truncate the table
using (MySqlConnection connection = new MySqlConnection(_connectionString))
{
using (MySqlCommand command = new MySqlCommand())
{
private void TransferData(DataSet ds)
{
try
{
DisableForeignKey(true);
if (ds != null)
{
foreach (DataTable dt in ds.Tables)
{
Populate(dt, dt.TableName);
public bool Import(string url = "")
{
WriteToConsole("** MySql Data Export Started**");
bool bValue = true;
string newFileName = "Dbdata.xml.gz";
string filePath = Path.Combine(_directoryPath, newFileName);
if(url != "")
bValue = DownloadFile(url, filePath);
if (bValue)
{
private void DisableForeignKey(bool flag)
{
string query = "";
if (flag)
query = "SET FOREIGN_KEY_CHECKS=0;";
else
query = "SET FOREIGN_KEY_CHECKS=1;";
try
{
using (MySqlConnection connection = new MySqlConnection(_connectionString))
class Program
{
static void Main(string[] args)
{
var services = new ServiceCollection();
ConfigureServices(services);
var provider = services.BuildServiceProvider();
Console.WriteLine("** Welcome to Data Transfer tool **");
Console.WriteLine("** Please select one of the following option **");
Console.WriteLine("** [1] - Enter 1 for extracting data from SQL Server Data **");
public class MySQLDataImport
{
private const int cBatchCount = 2000;
private string _connectionString = "";
private string _directoryPath = "";
public MySQLDataExport(IConfigurationRoot config)
{
_connectionString = config["AppSettings:MySQLConnectionString"];