-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The database will allow for better flexibility and extensibility in maintaining varies types of art that are requested. This features a basic implementation of adding new orders to it but you can't yet search or delete. In the future, you will also be able to export these orders as Json files for use as a receipt or import into someone else's implementation of artm. Other features include automated category selection and hashing based on former to determine the appropriate to add. The hashing is meant to not only verify information but also allow for accurate searching and pave the way for the raffling system, see issue #1.
- Loading branch information
Showing
25 changed files
with
724 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="nuget" value="https://api.nuget.org/v3/index.json" /> | ||
</packageSources> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<AssemblyName>artm</AssemblyName> | ||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | ||
<Version>0.2</Version> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="EntryPoint" Version="1.2.3" /> | ||
<PackageReference Include="LiteDB" Version="4.1.4" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.11" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ArtManager\ArtManager.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extensions: designer.cs generated.cs | ||
extensions: .cs .cpp .h | ||
// Copyright (c) Anthony Wilcox and contributors. All rights reserved. | ||
// Licensed under the GNU GPL v3 license. See LICENSE file in the project | ||
// root for full license information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Anthony Wilcox and contributors. All rights reserved. | ||
// Licensed under the GNU GPL v3 license. See LICENSE file in the project | ||
// root for full license information. | ||
namespace ArtManager.CLI | ||
{ | ||
struct ArtmConsts | ||
{ | ||
public const string APPNAME = "Art Manager"; | ||
public const string DBERR = "Failed to connect to database"; | ||
public const string DBFILE = "artm.db"; | ||
public const string DBCOL = "art"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// Copyright (c) Anthony Wilcox and contributors. All rights reserved. | ||
// Licensed under the GNU GPL v3 license. See LICENSE file in the project | ||
// root for full license information. | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using ArtManager.Models; | ||
using EntryPoint; | ||
|
||
namespace ArtManager.CLI | ||
{ | ||
class CliCmd : BaseCliCommands | ||
{ | ||
Art _art; | ||
Order _order; | ||
|
||
[DefaultCommand] | ||
[Command("list")] | ||
public void ListAll(string[] args) | ||
{ | ||
if (File.Exists(ArtmConsts.DBFILE)) | ||
{ | ||
_order = new Order(); | ||
_order.DbListAll(); | ||
} | ||
else | ||
{ | ||
Console.WriteLine(ArtmConsts.DBERR); | ||
} | ||
} | ||
|
||
[Command("req")] | ||
public void Request(string[] args) | ||
{ | ||
var cli = Cli.Parse<BaseArgs>(args); | ||
_art = new Art() | ||
{ | ||
Name = cli.Name, | ||
Custmer = new Customer | ||
{ | ||
Name = cli.Customer, | ||
Contact = cli.Contact, | ||
}, | ||
Description = cli.Description, | ||
}; | ||
_order = new Order(_art); | ||
_order.DBInsert(); | ||
|
||
if (cli.Debug) | ||
_order.DbListAll(); | ||
} | ||
|
||
[Command("com")] | ||
public void Commission(string[] args) | ||
{ | ||
var cli = Cli.Parse<PayArgs>(args); | ||
_art = new Art() | ||
{ | ||
Name = cli.Name, | ||
Custmer = new Customer | ||
{ | ||
Name = cli.Customer, | ||
Contact = cli.Contact, | ||
Payment = cli.Payment, | ||
}, | ||
Price = cli.Price, | ||
Description = cli.Description, | ||
}; | ||
_order = new Order(_art); | ||
_order.DBInsert(); | ||
|
||
if (cli.Debug) | ||
_order.DbListAll(); | ||
} | ||
|
||
[Command("ych")] | ||
public void YCH(string[] args) | ||
{ | ||
var cli = Cli.Parse<YchArgs>(args); | ||
_art = new Art() | ||
{ | ||
Name = cli.Name, | ||
Custmer = new Customer | ||
{ | ||
Name = cli.Customer, | ||
Contact = cli.Contact, | ||
Payment = cli.Payment, | ||
}, | ||
Price = cli.Price, | ||
Slot = cli.Slot, | ||
Ticket = cli.Ticket | ||
}; | ||
_order = new Order(_art); | ||
_order.DBInsert(); | ||
|
||
if (cli.Debug || Debugger.IsAttached) | ||
_order.DbListAll(); | ||
} | ||
|
||
[Command("raf")] | ||
public void Raffle(string[] args) | ||
{ | ||
_order = new Order(); | ||
_order.DBRaffle(args); | ||
} | ||
|
||
public override void OnHelpInvoked(string helpText) | ||
{ | ||
var monero = "44xZM7FSdJ9TpYK99Y2e4JYyprRWR3fKxJWsw4jEFL6CWtWQG35qWAPDTPDuAGy1v74bL2arKP2Eq7GVPfsWTZVs7MhKhf4"; | ||
var about = "A command line application used for storing request, commission, and YCH information."; | ||
Console.WriteLine($"## About ##{Environment.NewLine}{about}{Environment.NewLine}"); | ||
Console.WriteLine($"{Environment.NewLine}## Donate ##{Environment.NewLine}Ko-Fi: ko-fi.com/antonwilc0x{Environment.NewLine}Monero: {monero}"); | ||
Console.WriteLine($"{Environment.NewLine}{helpText}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright (c) Anthony Wilcox and contributors. All rights reserved. | ||
// Licensed under the GNU GPL v3 license. See LICENSE file in the project | ||
// root for full license information. | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using ArtManager.Models; | ||
using LiteDB; | ||
|
||
namespace ArtManager.CLI | ||
{ | ||
class Order | ||
{ | ||
Art Art { get; set; } | ||
|
||
public bool IsDebug { get; set; } | ||
|
||
readonly List<Art> _arts = new List<Art>(); | ||
|
||
public Order() { } | ||
|
||
public Order(Art order) | ||
{ | ||
Art = order; | ||
} | ||
|
||
public void DBInsert() | ||
{ | ||
try | ||
{ | ||
using (var db = new LiteDatabase(ArtmConsts.DBFILE)) | ||
{ | ||
var art = db.GetCollection<Art>(ArtmConsts.DBCOL); | ||
art.Insert(Art); | ||
} | ||
} | ||
catch (Exception err) | ||
{ | ||
throw new Exception(err.Message); | ||
} | ||
} | ||
|
||
public void DBRaffle(string[] args) | ||
{ | ||
/* | ||
var cli = Cli.Parse<RaffleArgs>(args); | ||
var rand = new Random(); | ||
var tickets = rand.Next(cli.Tickets); | ||
var slots = rand.Next(cli.Slots); | ||
*/ | ||
|
||
if (IsDebug) | ||
{ | ||
|
||
} | ||
else | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
public void DbListAll() | ||
{ | ||
try | ||
{ | ||
using (var db = new LiteDatabase(ArtmConsts.DBFILE)) | ||
{ | ||
var art = db.GetCollection<Art>(ArtmConsts.DBCOL); | ||
art.EnsureIndex(x => x.Hash); | ||
var query = art.Include(x => x.Hash) | ||
.Include(x => x.Custmer) | ||
.Include(x => x.Name) | ||
.FindAll(); | ||
|
||
foreach (var q in query) | ||
_arts.Add(q); | ||
|
||
var json = ArtUtils.AsJson(_arts); | ||
|
||
if (IsDebug) | ||
Console.WriteLine(json); | ||
else if (Debugger.IsAttached) | ||
Debug.WriteLine(json); | ||
} | ||
} | ||
catch (Exception err) | ||
{ | ||
throw new Exception(err.Message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.