Initial Commit
This commit is contained in:
commit
082b328aff
398
.gitignore
vendored
Normal file
398
.gitignore
vendored
Normal file
@ -0,0 +1,398 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
25
SQLiteTest.sln
Normal file
25
SQLiteTest.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27703.2035
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLiteTest", "SQLiteTest\SQLiteTest.csproj", "{1A03F4BF-E99E-4FF6-A30E-2668A7773456}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1A03F4BF-E99E-4FF6-A30E-2668A7773456}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1A03F4BF-E99E-4FF6-A30E-2668A7773456}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1A03F4BF-E99E-4FF6-A30E-2668A7773456}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1A03F4BF-E99E-4FF6-A30E-2668A7773456}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {890761E3-C514-481C-AE0E-0BF232E700DD}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
22
SQLiteTest/App.config
Normal file
22
SQLiteTest/App.config
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="mssqllocaldb" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
|
||||
</configuration>
|
166
SQLiteTest/Movie.cs
Normal file
166
SQLiteTest/Movie.cs
Normal file
@ -0,0 +1,166 @@
|
||||
using Microsoft.Data.Sqlite;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace SQLiteTest {
|
||||
internal class Movie {
|
||||
public Movie() {
|
||||
}
|
||||
|
||||
public Movie(ref SqliteDataReader query) {
|
||||
ID = query.GetInt32(query.GetOrdinal("ID")); // Non null objects
|
||||
Title = query.GetString(query.GetOrdinal("Title"));
|
||||
Overview = query.GetString(query.GetOrdinal("Overview"));
|
||||
|
||||
int index = query.GetOrdinal("Tagline");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No Tagline found!");
|
||||
else
|
||||
Tagline = query.GetString(index);
|
||||
|
||||
index = query.GetOrdinal("BackdropPath");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No BackdropPath found!");
|
||||
else
|
||||
BackdropPath = query.GetString(index);
|
||||
|
||||
index = query.GetOrdinal("PosterPath");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No PosterPath found!");
|
||||
else
|
||||
PosterPath = query.GetString(index);
|
||||
|
||||
index = query.GetOrdinal("ImdbID");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No ImdbID found!");
|
||||
else
|
||||
ImdbID = query.GetString(index);
|
||||
|
||||
index = query.GetOrdinal("Adult");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No Adult found!");
|
||||
else
|
||||
Adult = query.GetBoolean(index);
|
||||
|
||||
index = query.GetOrdinal("Budget");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No Budget found!");
|
||||
else
|
||||
Budget = query.GetInt64(index);
|
||||
|
||||
index = query.GetOrdinal("Genres");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No Genres found!");
|
||||
else
|
||||
Genres = query.GetString(index); // TODO: This!
|
||||
|
||||
index = query.GetOrdinal("Popularity");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No Popularity found!");
|
||||
else
|
||||
Popularity = query.GetDouble(index);
|
||||
|
||||
index = query.GetOrdinal("ReleaseDate");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No ReleaseDate found!");
|
||||
else {
|
||||
string ReleaseDatestring = query.GetString(index);
|
||||
}
|
||||
|
||||
index = query.GetOrdinal("Revenue");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No Revenue found!");
|
||||
else
|
||||
Revenue = query.GetInt64(index);
|
||||
|
||||
index = query.GetOrdinal("Runtime");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No Runtime found!");
|
||||
else
|
||||
Runtime = query.GetInt32(index);
|
||||
|
||||
index = query.GetOrdinal("Status");
|
||||
if (query.IsDBNull(index))
|
||||
Debug.WriteLine("No Status found!");
|
||||
else
|
||||
Status = query.GetString(index);
|
||||
}
|
||||
/// <summary>
|
||||
/// Movie ID on TMDB.
|
||||
/// </summary>
|
||||
public int ID { get; set; }
|
||||
/// <summary>
|
||||
/// Title of the movie.
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
/// <summary>
|
||||
/// Tagline of the movie.
|
||||
/// </summary>
|
||||
public string Tagline { get; set; }
|
||||
/// <summary>
|
||||
/// Summary of the movie plot.
|
||||
/// </summary>
|
||||
public string Overview { get; set; }
|
||||
/// <summary>
|
||||
/// Path to a wallpaper of the movie.
|
||||
/// </summary>
|
||||
public string BackdropPath { get; set; }
|
||||
/// <summary>
|
||||
/// Path to a poster of the movie.
|
||||
/// </summary>
|
||||
public string PosterPath { get; set; }
|
||||
/// <summary>
|
||||
/// Movie ID on IMDB.
|
||||
/// </summary>
|
||||
public string ImdbID { get; set; }
|
||||
/// <summary>
|
||||
/// Whether or not the movie is age restricted.
|
||||
/// Pattern: ^tt[0-9]{7}
|
||||
/// </summary>
|
||||
public bool? Adult { get; set; }
|
||||
/// <summary>
|
||||
/// Production budget of the movie.
|
||||
/// </summary>
|
||||
public long? Budget { get; set; }
|
||||
/// <summary>
|
||||
/// Comma Separated list of genres.
|
||||
/// </summary>
|
||||
public string Genres { get; set; }
|
||||
/// <summary>
|
||||
/// Current popularity. Has to be refreshed!
|
||||
/// </summary>
|
||||
public double? Popularity { get; set; }
|
||||
/// <summary>
|
||||
/// Release date of the movie.
|
||||
/// </summary>
|
||||
public DateTime? ReleaseDate { get; set; }
|
||||
/// <summary>
|
||||
/// Revenue of the movie.
|
||||
/// </summary>
|
||||
public long? Revenue { get; set; }
|
||||
/// <summary>
|
||||
/// Runtime of the movie in minutes.
|
||||
/// </summary>
|
||||
public int? Runtime { get; set; }
|
||||
/// <summary>
|
||||
/// Current movie status: Rumored, Planned, In Production, Post Production, Released, Canceled.
|
||||
/// </summary>
|
||||
public string Status { get; set; }
|
||||
|
||||
public override bool Equals(object obj) {
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ID is unique to a movie object thus it can be used as a hash.
|
||||
/// </summary>
|
||||
/// <returns>Movie ID as a unique id.</returns>
|
||||
public override int GetHashCode() => ID;
|
||||
/// <summary>
|
||||
/// String containing the movie ID as well as the title and the release year.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString() => $"{ID}: {Title}{(ReleaseDate.HasValue ? $" ({ReleaseDate.Value.Year})" : "")}";
|
||||
}
|
||||
}
|
185
SQLiteTest/Program.cs
Normal file
185
SQLiteTest/Program.cs
Normal file
@ -0,0 +1,185 @@
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SQLiteTest {
|
||||
class Program {
|
||||
const string APIKey = "badd41f2c2c9879186a8082b1d16fd69";
|
||||
const string Language = "en-US";
|
||||
const string filename = @"C:\Users\micha\source\repos\SQLiteTest\MovieDatabase.db";
|
||||
const string CreateGenreTable = @"CREATE TABLE `Genres` (
|
||||
`ID` INTEGER NOT NULL UNIQUE,
|
||||
`Name` TEXT NOT NULL,
|
||||
PRIMARY KEY(`ID`)
|
||||
);";
|
||||
static void Main(string[] args) {
|
||||
RefreshGenreList();
|
||||
Random rnd = new Random();
|
||||
int random = rnd.Next(999999);
|
||||
Movie newMovie = new Movie() { ID = random, Title = "Movie no. " + random.ToString(), Overview = "The Inception is amazing!", ReleaseDate = null, Adult = true, ImdbID = "tt" + rnd.Next(0000000, 9999999), Status = "Released", Runtime = 148 };
|
||||
AddMovie(in newMovie);
|
||||
foreach (Movie movie in QueryMovies())
|
||||
Console.WriteLine(movie.ToString());
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
private static void RefreshGenreList() {
|
||||
var client = new RestClient($"https://api.themoviedb.org/3/genre/movie/list?language={Language}&api_key={APIKey}");
|
||||
var request = new RestRequest(Method.GET);
|
||||
request.AddParameter("undefined", "{}", ParameterType.RequestBody);
|
||||
IRestResponse response = client.Execute(request);
|
||||
try {
|
||||
dynamic responseObject = JsonConvert.DeserializeObject<dynamic>(response.Content);
|
||||
if (!(responseObject.status_message is null))
|
||||
Console.WriteLine("Status: {0}", responseObject.status_message);
|
||||
Dictionary<int, string> genres = new Dictionary<int, string>();
|
||||
foreach (var a in responseObject.genres) {
|
||||
genres.Add((int)a.id, (string)a.name);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine("Response could not be parsed: {0}", e.Message);
|
||||
}
|
||||
if (!response.IsSuccessful) {
|
||||
Console.WriteLine("Request failed: {0}", response.ErrorMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<Movie> QueryMovies() {
|
||||
const string tableCommand = "SELECT * FROM Movies";
|
||||
using (SqliteConnection db = new SqliteConnection($"Data Source={filename};")) {
|
||||
try {
|
||||
db.Open();
|
||||
} catch (SqliteException e) {
|
||||
Console.WriteLine("Database connection failed: {0}", e.Message);
|
||||
yield break;
|
||||
}
|
||||
using (SqliteCommand readTableCommand = new SqliteCommand(tableCommand, db)) {
|
||||
SqliteDataReader query;
|
||||
try {
|
||||
query = readTableCommand.ExecuteReader();
|
||||
} catch (SqliteException e) {
|
||||
Console.WriteLine("Query failed: {0}", e.Message);
|
||||
yield break;
|
||||
}
|
||||
while (query.Read()) {
|
||||
yield return new Movie(ref query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Query(in string command) {
|
||||
using (SqliteConnection db = new SqliteConnection($"Data Source={filename};")) {
|
||||
try {
|
||||
db.Open();
|
||||
} catch (SqliteException e) {
|
||||
Console.WriteLine("Database connection failed: {0}", e.Message);
|
||||
return;
|
||||
}
|
||||
using (SqliteCommand insertCommand = new SqliteCommand(command, db)) {
|
||||
SqliteDataReader query;
|
||||
try {
|
||||
query = insertCommand.ExecuteReader();
|
||||
} catch (SqliteException e) {
|
||||
Console.WriteLine("Query failed: {0}", e.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
db.Close();
|
||||
} catch (SqliteException e) {
|
||||
Console.WriteLine("Database closing failed: {0}", e.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Query successful!");
|
||||
}
|
||||
private static void AddMovie(in Movie movie) {
|
||||
using (SqliteConnection db = new SqliteConnection($"Data Source={filename};")) {
|
||||
try {
|
||||
db.Open();
|
||||
} catch (SqliteException e) {
|
||||
Console.WriteLine("Database connection failed: {0}", e.Message);
|
||||
return;
|
||||
}
|
||||
using (SqliteCommand insertCommand = new SqliteCommand()) {
|
||||
insertCommand.Connection = db;
|
||||
insertCommand.CommandText = "INSERT INTO `Movies`(`ID`,`Title`,`Tagline`,`Overview`,`BackdropPath`,`PosterPath`,`ImdbID`,`Adult`,`Budget`,`Genres`,`Popularity`,`ReleaseDate`,`Revenue`,`Runtime`,`Status`) VALUES (@ID, @Title, @Tagline, @Overview, @BackdropPath, @PosterPath, @ImdbID, @Adult, @Budget, @Genres, @Popularity, @ReleaseDate, @Revenue, @Runtime, @Status);";
|
||||
#region Params
|
||||
insertCommand.Parameters.AddWithValue("@ID", movie.ID);
|
||||
insertCommand.Parameters.AddWithValue("@Title", movie.Title);
|
||||
insertCommand.Parameters.AddWithValue("@Overview", movie.Overview);
|
||||
if (string.IsNullOrWhiteSpace(movie.Tagline))
|
||||
insertCommand.Parameters.AddWithValue("@Tagline", DBNull.Value);
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@Tagline", movie.Tagline);
|
||||
if (string.IsNullOrWhiteSpace(movie.BackdropPath))
|
||||
insertCommand.Parameters.AddWithValue("@BackdropPath", DBNull.Value);
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@BackdropPath", movie.BackdropPath);
|
||||
if (string.IsNullOrWhiteSpace(movie.PosterPath))
|
||||
insertCommand.Parameters.AddWithValue("@PosterPath", DBNull.Value);
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@PosterPath", movie.PosterPath);
|
||||
if (string.IsNullOrWhiteSpace(movie.ImdbID))
|
||||
insertCommand.Parameters.AddWithValue("@ImdbID", DBNull.Value);
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@ImdbID", movie.ImdbID);
|
||||
if (string.IsNullOrWhiteSpace(movie.Status))
|
||||
insertCommand.Parameters.AddWithValue("@Status", DBNull.Value);
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@Status", movie.Status);
|
||||
if (string.IsNullOrWhiteSpace(movie.Genres))
|
||||
insertCommand.Parameters.AddWithValue("@Genres", DBNull.Value);
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@Genres", movie.Genres);
|
||||
if (movie.Adult.HasValue)
|
||||
insertCommand.Parameters.AddWithValue("@Adult", movie.Adult.Value ? "1" : "0");
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@Adult", DBNull.Value);
|
||||
if (movie.Budget.HasValue)
|
||||
insertCommand.Parameters.AddWithValue("@Budget", movie.Budget.Value.ToString());
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@Budget", DBNull.Value);
|
||||
if (movie.Popularity.HasValue)
|
||||
insertCommand.Parameters.AddWithValue("@Popularity", movie.Popularity.Value.ToString());
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@Popularity", DBNull.Value);
|
||||
if (movie.Runtime.HasValue)
|
||||
insertCommand.Parameters.AddWithValue("@Runtime", movie.Runtime.Value.ToString());
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@Runtime", DBNull.Value);
|
||||
if (movie.Revenue.HasValue)
|
||||
insertCommand.Parameters.AddWithValue("@Revenue", movie.Revenue.Value.ToString());
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@Revenue", DBNull.Value);
|
||||
if (movie.ReleaseDate.HasValue)
|
||||
insertCommand.Parameters.AddWithValue("@ReleaseDate", movie.ReleaseDate.Value.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
||||
else
|
||||
insertCommand.Parameters.AddWithValue("@ReleaseDate", DBNull.Value);
|
||||
#endregion
|
||||
SqliteDataReader query;
|
||||
try {
|
||||
query = insertCommand.ExecuteReader();
|
||||
} catch (SqliteException e) {
|
||||
Console.WriteLine("Insertion failed: {0}", e.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
db.Close();
|
||||
} catch (SqliteException e) {
|
||||
Console.WriteLine("Database closing failed: {0}", e.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
36
SQLiteTest/Properties/AssemblyInfo.cs
Normal file
36
SQLiteTest/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
[assembly: AssemblyTitle("SQLiteTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("SQLiteTest")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
||||
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
|
||||
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||
[assembly: Guid("1a03f4bf-e99e-4ff6-a30e-2668a7773456")]
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
98
SQLiteTest/SQLiteTest.csproj
Normal file
98
SQLiteTest/SQLiteTest.csproj
Normal file
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1A03F4BF-E99E-4FF6-A30E-2668A7773456}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>SQLiteTest</RootNamespace>
|
||||
<AssemblyName>SQLiteTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<LangVersion>7.2</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<LangVersion>7.2</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Data.Sqlite, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Data.Sqlite.Core.2.1.0\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp, Version=106.5.2.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RestSharp.106.5.2\lib\net452\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.batteries_green, Version=1.1.11.121, Culture=neutral, PublicKeyToken=a84b7dcfb1391f7f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.bundle_green.1.1.11\lib\net45\SQLitePCLRaw.batteries_green.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.batteries_v2, Version=1.1.11.121, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.bundle_green.1.1.11\lib\net45\SQLitePCLRaw.batteries_v2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.core, Version=1.1.11.121, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.core.1.1.11\lib\net45\SQLitePCLRaw.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLitePCLRaw.provider.e_sqlite3, Version=1.1.11.121, Culture=neutral, PublicKeyToken=9c301db686d0bd12, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.provider.e_sqlite3.net45.1.1.11\lib\net45\SQLitePCLRaw.provider.e_sqlite3.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Movie.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets" Condition="Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SQLitePCLRaw.lib.e_sqlite3.linux.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.linux.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.osx.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.osx.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SQLitePCLRaw.lib.e_sqlite3.osx.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.osx.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.v110_xp.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.v110_xp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SQLitePCLRaw.lib.e_sqlite3.v110_xp.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.v110_xp.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\SQLitePCLRaw.lib.e_sqlite3.osx.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.osx.targets" Condition="Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.osx.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.osx.targets')" />
|
||||
<Import Project="..\packages\SQLitePCLRaw.lib.e_sqlite3.v110_xp.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.v110_xp.targets" Condition="Exists('..\packages\SQLitePCLRaw.lib.e_sqlite3.v110_xp.1.1.11\build\net35\SQLitePCLRaw.lib.e_sqlite3.v110_xp.targets')" />
|
||||
</Project>
|
14
SQLiteTest/packages.config
Normal file
14
SQLiteTest/packages.config
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EntityFramework" version="6.2.0" targetFramework="net461" />
|
||||
<package id="Microsoft.Data.Sqlite" version="2.1.0" targetFramework="net461" />
|
||||
<package id="Microsoft.Data.Sqlite.Core" version="2.1.0" targetFramework="net461" />
|
||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
|
||||
<package id="RestSharp" version="106.5.2" targetFramework="net461" />
|
||||
<package id="SQLitePCLRaw.bundle_green" version="1.1.11" targetFramework="net461" />
|
||||
<package id="SQLitePCLRaw.core" version="1.1.11" targetFramework="net461" />
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3.linux" version="1.1.11" targetFramework="net461" />
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3.osx" version="1.1.11" targetFramework="net461" />
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3.v110_xp" version="1.1.11" targetFramework="net461" />
|
||||
<package id="SQLitePCLRaw.provider.e_sqlite3.net45" version="1.1.11" targetFramework="net461" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user