formatting that makes it look slightly less icky
This commit is contained in:
parent
b26326baf5
commit
34657b9b78
5 changed files with 192 additions and 200 deletions
|
@ -5,7 +5,8 @@ namespace Buypeeb {
|
||||||
private readonly Entry entryURL;
|
private readonly Entry entryURL;
|
||||||
private readonly Entry entryName;
|
private readonly Entry entryName;
|
||||||
|
|
||||||
public AddItemDialogue() : this(new Builder("add.glade")) { }
|
public AddItemDialogue() : this(new Builder("add.glade")) {
|
||||||
|
}
|
||||||
|
|
||||||
private AddItemDialogue(Builder builder) : base(builder.GetObject("DialogueAdd").Handle) {
|
private AddItemDialogue(Builder builder) : base(builder.GetObject("DialogueAdd").Handle) {
|
||||||
Title = "Add item";
|
Title = "Add item";
|
||||||
|
|
180
MainWindow.cs
180
MainWindow.cs
|
@ -39,7 +39,6 @@ using Timeout = GLib.Timeout;
|
||||||
namespace Buypeeb {
|
namespace Buypeeb {
|
||||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||||
internal class MainWindow : Window {
|
internal class MainWindow : Window {
|
||||||
|
|
||||||
private string location;
|
private string location;
|
||||||
private JsonSerializerOptions jsonOptions;
|
private JsonSerializerOptions jsonOptions;
|
||||||
|
|
||||||
|
@ -52,20 +51,19 @@ namespace Buypeeb {
|
||||||
// that way we don't need to constantly do "builder.GetObject"s
|
// that way we don't need to constantly do "builder.GetObject"s
|
||||||
// when that is done, you can use the cache array to replace everything from here...
|
// when that is done, you can use the cache array to replace everything from here...
|
||||||
|
|
||||||
private Box selectionViewBox;
|
private readonly Box selectionViewBox;
|
||||||
private Label endingLabel;
|
private readonly Label endingLabel;
|
||||||
private bool queueActive;
|
private bool queueActive;
|
||||||
private SearchEntry searchEntry;
|
private readonly SearchEntry searchEntry;
|
||||||
private Dictionary<string, CheckButton> filterChecks = new Dictionary<string, CheckButton>();
|
private readonly Dictionary<string, CheckButton> filterChecks = new Dictionary<string, CheckButton>();
|
||||||
|
|
||||||
// ...to here.
|
// ...to here.
|
||||||
|
|
||||||
private static SemaphoreSlim taskLimit = new SemaphoreSlim(6);
|
private static SemaphoreSlim taskLimit = new SemaphoreSlim(6);
|
||||||
private Queue<string> updateQueue = new Queue<string>();
|
private readonly Queue<string> updateQueue = new Queue<string>();
|
||||||
private IEnumerable<YahooAuctionsItem> filterQuery {
|
|
||||||
get {
|
private IEnumerable<YahooAuctionsItem> filterQuery =>
|
||||||
// father forgive me for i have lynned
|
// father forgive me for i have lynned
|
||||||
return
|
|
||||||
from item in settings.watchlist.Values.ToList()
|
from item in settings.watchlist.Values.ToList()
|
||||||
where (item.favourite != filterChecks["Favourites"].Active ||
|
where (item.favourite != filterChecks["Favourites"].Active ||
|
||||||
item.favourite == filterChecks["NonFavourites"].Active) &&
|
item.favourite == filterChecks["NonFavourites"].Active) &&
|
||||||
|
@ -75,23 +73,18 @@ namespace Buypeeb {
|
||||||
item.endingToday == filterChecks["EndingAfterToday"].Active) &&
|
item.endingToday == filterChecks["EndingAfterToday"].Active) &&
|
||||||
(item.hasWinPrice != filterChecks["WithWinPrice"].Active ||
|
(item.hasWinPrice != filterChecks["WithWinPrice"].Active ||
|
||||||
item.hasWinPrice == filterChecks["WithNoWinPrice"].Active) &&
|
item.hasWinPrice == filterChecks["WithNoWinPrice"].Active) &&
|
||||||
(String.IsNullOrWhiteSpace(searchEntry.Text) ||
|
(string.IsNullOrWhiteSpace(searchEntry.Text) ||
|
||||||
item.name.ToLower().Contains(searchEntry.Text.ToLower()) ||
|
item.name.ToLower().Contains(searchEntry.Text.ToLower()) ||
|
||||||
item.originalName.ToLower().Contains(searchEntry.Text.ToLower()))
|
item.originalName.ToLower().Contains(searchEntry.Text.ToLower()))
|
||||||
select item;
|
select item;
|
||||||
}
|
|
||||||
}
|
private IEnumerable<YahooAuctionsItem> outdatedItemQuery =>
|
||||||
private IEnumerable<YahooAuctionsItem> outdatedItemQuery {
|
|
||||||
get {
|
|
||||||
// only returns items that meet all of the following:
|
// only returns items that meet all of the following:
|
||||||
// - marked as "ready", as in, they aren't in the process of updating
|
// - marked as "ready", as in, they aren't in the process of updating
|
||||||
// - not updated since the interval
|
// - not updated since the interval
|
||||||
return
|
|
||||||
from item in settings.watchlist.Values.ToList()
|
from item in settings.watchlist.Values.ToList()
|
||||||
where item.Ready && settings.ItemNotUpdatedSinceInterval(item)
|
where item.Ready && settings.ItemNotUpdatedSinceInterval(item)
|
||||||
select item;
|
select item;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private YahooAuctionsItem selectedItem {
|
private YahooAuctionsItem selectedItem {
|
||||||
get {
|
get {
|
||||||
|
@ -105,7 +98,8 @@ namespace Buypeeb {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainWindow() : this(new Builder("main.glade")) { }
|
public MainWindow() : this(new Builder("main.glade")) {
|
||||||
|
}
|
||||||
|
|
||||||
private MainWindow(Builder builder) : base(builder.GetObject("wndMain").Handle) {
|
private MainWindow(Builder builder) : base(builder.GetObject("wndMain").Handle) {
|
||||||
jsonOptions = new JsonSerializerOptions {
|
jsonOptions = new JsonSerializerOptions {
|
||||||
|
@ -114,11 +108,12 @@ namespace Buypeeb {
|
||||||
|
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
|
||||||
// C:\Users\Beebus\AppData\Roaming\Lynnear Software\buypeeb
|
// C:\Users\Beebus\AppData\Roaming\Lynnear Software\buypeeb
|
||||||
location = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%APPDATA%"), "Lynnear Software", "buypeeb");
|
location = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%APPDATA%"), "Lynnear Software",
|
||||||
}
|
"buypeeb");
|
||||||
else {
|
} else {
|
||||||
// ~/.config/Lynnear Software/buypeeb
|
// ~/.config/Lynnear Software/buypeeb
|
||||||
location = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config", "Lynnear Software", "buypeeb");
|
location = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config",
|
||||||
|
"Lynnear Software", "buypeeb");
|
||||||
}
|
}
|
||||||
|
|
||||||
var userdata = System.IO.Path.Combine(location, "userdata.json");
|
var userdata = System.IO.Path.Combine(location, "userdata.json");
|
||||||
|
@ -126,17 +121,15 @@ namespace Buypeeb {
|
||||||
try {
|
try {
|
||||||
var j = File.ReadAllText(userdata);
|
var j = File.ReadAllText(userdata);
|
||||||
settings = JsonSerializer.Deserialize<Settings>(j);
|
settings = JsonSerializer.Deserialize<Settings>(j);
|
||||||
}
|
} catch {
|
||||||
catch {
|
|
||||||
// ???
|
// ???
|
||||||
Console.WriteLine("oops");
|
Console.WriteLine("oops");
|
||||||
Application.Quit();
|
Application.Quit();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
settings = new Settings();
|
settings = new Settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
Title = "Buypeeb";
|
Title = "Buypeeb";
|
||||||
|
|
||||||
|
@ -151,7 +144,10 @@ namespace Buypeeb {
|
||||||
selectionViewBox = (Box) builder.GetObject("SelectionViewBox");
|
selectionViewBox = (Box) builder.GetObject("SelectionViewBox");
|
||||||
endingLabel = (Label) builder.GetObject("LabelSelectedEnding");
|
endingLabel = (Label) builder.GetObject("LabelSelectedEnding");
|
||||||
searchEntry = (SearchEntry) builder.GetObject("FilterSearchEntry");
|
searchEntry = (SearchEntry) builder.GetObject("FilterSearchEntry");
|
||||||
foreach (var name in new List<string> { "Favourites", "NonFavourites", "Active", "Ended", "EndingToday", "EndingAfterToday", "WithWinPrice", "WithNoWinPrice" }) {
|
foreach (var name in new List<string> {
|
||||||
|
"Favourites", "NonFavourites", "Active", "Ended", "EndingToday", "EndingAfterToday", "WithWinPrice",
|
||||||
|
"WithNoWinPrice"
|
||||||
|
}) {
|
||||||
filterChecks.Add(name, (CheckButton) builder.GetObject($"CheckButtonFilter{name}"));
|
filterChecks.Add(name, (CheckButton) builder.GetObject($"CheckButtonFilter{name}"));
|
||||||
filterChecks[name].Active = false;
|
filterChecks[name].Active = false;
|
||||||
}
|
}
|
||||||
|
@ -228,7 +224,6 @@ namespace Buypeeb {
|
||||||
using (var fs = File.CreateText(p)) {
|
using (var fs = File.CreateText(p)) {
|
||||||
fs.Write(j);
|
fs.Write(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -262,6 +257,7 @@ namespace Buypeeb {
|
||||||
if (pathAndIter.path != null) {
|
if (pathAndIter.path != null) {
|
||||||
items.EmitRowChanged(pathAndIter.path, pathAndIter.iter);
|
items.EmitRowChanged(pathAndIter.path, pathAndIter.iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == selectedItem) {
|
if (item == selectedItem) {
|
||||||
// if the user has this item selected and it just became ready, enable the selection box and redraw the info
|
// if the user has this item selected and it just became ready, enable the selection box and redraw the info
|
||||||
selectionViewBox.Sensitive = true;
|
selectionViewBox.Sensitive = true;
|
||||||
|
@ -281,8 +277,7 @@ namespace Buypeeb {
|
||||||
UpdateItem(updateQueue.Dequeue());
|
UpdateItem(updateQueue.Dequeue());
|
||||||
if (updateQueue.TryPeek(out var _)) {
|
if (updateQueue.TryPeek(out var _)) {
|
||||||
ProcessUpdateQueue();
|
ProcessUpdateQueue();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
queueActive = false;
|
queueActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,14 +297,10 @@ namespace Buypeeb {
|
||||||
// don't start a new task if there are more than `tasklimit` tasks currently running
|
// don't start a new task if there are more than `tasklimit` tasks currently running
|
||||||
// this makes sure we don't make 1000 simultaneous requests to yahoo auctions if there are 1000 items on the watchlist
|
// this makes sure we don't make 1000 simultaneous requests to yahoo auctions if there are 1000 items on the watchlist
|
||||||
taskLimit.Wait();
|
taskLimit.Wait();
|
||||||
Task.Factory.StartNew(() => {
|
Task.Factory.StartNew(() => { UpdateThread(id); }).ContinueWith(task => {
|
||||||
UpdateThread(id);
|
|
||||||
}).ContinueWith(task => {
|
|
||||||
taskLimit.Release();
|
taskLimit.Release();
|
||||||
if (renderListWhenDone) {
|
if (renderListWhenDone) {
|
||||||
Application.Invoke(delegate {
|
Application.Invoke(delegate { RenderList(); });
|
||||||
RenderList();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -338,10 +329,7 @@ namespace Buypeeb {
|
||||||
}
|
}
|
||||||
|
|
||||||
itemTreeView.QueueDraw();
|
itemTreeView.QueueDraw();
|
||||||
Task.Factory.StartNew(() => {
|
Task.Factory.StartNew(() => { ProcessUpdateQueue(); });
|
||||||
ProcessUpdateQueue();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -377,16 +365,16 @@ namespace Buypeeb {
|
||||||
foreach (var row in info) {
|
foreach (var row in info) {
|
||||||
((Label) builder.GetObject($"LabelSelected{row.Key}")).Text = row.Value;
|
((Label) builder.GetObject($"LabelSelected{row.Key}")).Text = row.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateSelectionEndTime();
|
UpdateSelectionEndTime();
|
||||||
|
|
||||||
var noteBuffer = (TextBuffer) builder.GetObject("TextBufferSelectedNotes");
|
var noteBuffer = (TextBuffer) builder.GetObject("TextBufferSelectedNotes");
|
||||||
noteBuffer.Clear();
|
noteBuffer.Clear();
|
||||||
if (!String.IsNullOrWhiteSpace(item.notes)) {
|
if (!string.IsNullOrWhiteSpace(item.notes)) {
|
||||||
noteBuffer.Text = item.notes;
|
noteBuffer.Text = item.notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
((ToggleButton) builder.GetObject("ButtonSelectedFavourite")).Active = item.favourite;
|
((ToggleButton) builder.GetObject("ButtonSelectedFavourite")).Active = item.favourite;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -401,8 +389,7 @@ namespace Buypeeb {
|
||||||
UseShellExecute = true,
|
UseShellExecute = true,
|
||||||
};
|
};
|
||||||
Process.Start(psi);
|
Process.Start(psi);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// let's hope you have xdg-open installed
|
// let's hope you have xdg-open installed
|
||||||
Process.Start("xdg-open", url);
|
Process.Start("xdg-open", url);
|
||||||
}
|
}
|
||||||
|
@ -421,11 +408,7 @@ namespace Buypeeb {
|
||||||
type: MessageType.Question,
|
type: MessageType.Question,
|
||||||
bt: buttonsType,
|
bt: buttonsType,
|
||||||
format: message
|
format: message
|
||||||
);
|
) {KeepAbove = true, Resizable = false, FocusOnMap = true, Title = "Buypeeb"};
|
||||||
md.KeepAbove = true;
|
|
||||||
md.Resizable = false;
|
|
||||||
md.FocusOnMap = true;
|
|
||||||
md.Title = "Buypeeb";
|
|
||||||
|
|
||||||
return md;
|
return md;
|
||||||
}
|
}
|
||||||
|
@ -437,22 +420,23 @@ namespace Buypeeb {
|
||||||
/// <param name="message">the prompt that should be presented to the user</param>
|
/// <param name="message">the prompt that should be presented to the user</param>
|
||||||
/// <param name="prefill">a string to prefill the input box with</param>
|
/// <param name="prefill">a string to prefill the input box with</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private (Boolean accepted, string response) EntryDialogue(string title = "Buypeeb", string message = "Hi there!", string prefill = null) {
|
private (bool accepted, string response) EntryDialogue(
|
||||||
|
string title = "Buypeeb", string message = "Hi there!", string prefill = null
|
||||||
|
) {
|
||||||
var ed = new Dialog(
|
var ed = new Dialog(
|
||||||
title: title,
|
title: title,
|
||||||
parent: this,
|
parent: this,
|
||||||
flags: DialogFlags.DestroyWithParent | DialogFlags.Modal,
|
flags: DialogFlags.DestroyWithParent | DialogFlags.Modal,
|
||||||
/* button_data: */ "Cancel", ResponseType.Cancel, "OK", ResponseType.Ok
|
/* button_data: */ "Cancel", ResponseType.Cancel, "OK", ResponseType.Ok
|
||||||
);
|
) {DefaultResponse = ResponseType.Ok, KeepAbove = true};
|
||||||
|
|
||||||
ed.DefaultResponse = ResponseType.Ok;
|
|
||||||
ed.KeepAbove = true;
|
|
||||||
|
|
||||||
var edLabel = new Label(message);
|
var edLabel = new Label(message);
|
||||||
var edEntry = new Entry();
|
var edEntry = new Entry();
|
||||||
if (!String.IsNullOrWhiteSpace(prefill)) {
|
if (!string.IsNullOrWhiteSpace(prefill)) {
|
||||||
edEntry.Text = prefill;
|
edEntry.Text = prefill;
|
||||||
}
|
}
|
||||||
|
|
||||||
edEntry.ActivatesDefault = true;
|
edEntry.ActivatesDefault = true;
|
||||||
|
|
||||||
ed.ContentArea.PackStart(edLabel, true, true, 2);
|
ed.ContentArea.PackStart(edLabel, true, true, 2);
|
||||||
|
@ -477,7 +461,9 @@ namespace Buypeeb {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>the id of the radiobutton without the "Sort" prefix</returns>
|
/// <returns>the id of the radiobutton without the "Sort" prefix</returns>
|
||||||
private string GetSortType() {
|
private string GetSortType() {
|
||||||
foreach (var name in new List<string> { "NameDescending", "NameAscending", "PriceDescending", "PriceAscending", "EndingDescending", "EndingAscending" }) {
|
foreach (var name in new List<string> {
|
||||||
|
"NameDescending", "NameAscending", "PriceDescending", "PriceAscending", "EndingDescending", "EndingAscending"
|
||||||
|
}) {
|
||||||
var radio = (RadioMenuItem) builder.GetObject($"Sort{name}");
|
var radio = (RadioMenuItem) builder.GetObject($"Sort{name}");
|
||||||
if (radio.Active) {
|
if (radio.Active) {
|
||||||
return name;
|
return name;
|
||||||
|
@ -502,20 +488,15 @@ namespace Buypeeb {
|
||||||
var type = GetSortType();
|
var type = GetSortType();
|
||||||
if (type == "NameDescending") {
|
if (type == "NameDescending") {
|
||||||
sorted = values.OrderByDescending(item => item.name);
|
sorted = values.OrderByDescending(item => item.name);
|
||||||
}
|
} else if (type == "NameAscending") {
|
||||||
else if (type == "NameAscending") {
|
|
||||||
sorted = values.OrderBy(item => item.name);
|
sorted = values.OrderBy(item => item.name);
|
||||||
}
|
} else if (type == "PriceDescending") {
|
||||||
else if (type == "PriceDescending") {
|
|
||||||
sorted = values.OrderByDescending(item => item.Price);
|
sorted = values.OrderByDescending(item => item.Price);
|
||||||
}
|
} else if (type == "PriceAscending") {
|
||||||
else if (type == "PriceAscending") {
|
|
||||||
sorted = values.OrderBy(item => item.Price);
|
sorted = values.OrderBy(item => item.Price);
|
||||||
}
|
} else if (type == "EndingDescending") {
|
||||||
else if (type == "EndingDescending") {
|
|
||||||
sorted = values.OrderByDescending(item => item.endDate);
|
sorted = values.OrderByDescending(item => item.endDate);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sorted = values.OrderBy(item => item.endDate);
|
sorted = values.OrderBy(item => item.endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,8 +508,7 @@ namespace Buypeeb {
|
||||||
foreach (var item in sorted.Where(item => !item.favourite)) {
|
foreach (var item in sorted.Where(item => !item.favourite)) {
|
||||||
items.AppendValues(item);
|
items.AppendValues(item);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
foreach (var item in sorted) {
|
foreach (var item in sorted) {
|
||||||
items.AppendValues(item);
|
items.AppendValues(item);
|
||||||
}
|
}
|
||||||
|
@ -536,7 +516,9 @@ namespace Buypeeb {
|
||||||
|
|
||||||
((TreeModelFilter) itemTreeView.Model).Refilter();
|
((TreeModelFilter) itemTreeView.Model).Refilter();
|
||||||
|
|
||||||
if (id == null) { return; }
|
if (id == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// attempt to reselect the item we were just looking at
|
// attempt to reselect the item we were just looking at
|
||||||
// ReSharper disable once UseDeconstruction
|
// ReSharper disable once UseDeconstruction
|
||||||
|
@ -562,8 +544,7 @@ namespace Buypeeb {
|
||||||
if (rx.IsMatch(url)) {
|
if (rx.IsMatch(url)) {
|
||||||
UpdateItem(settings.Watch(url, name).id, true);
|
UpdateItem(settings.Watch(url, name).id, true);
|
||||||
RenderList();
|
RenderList();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var md = MsgBox($"\"{url}\" is not a valid Buyee or Yahoo! Auctions Japan URL.", ButtonsType.Ok);
|
var md = MsgBox($"\"{url}\" is not a valid Buyee or Yahoo! Auctions Japan URL.", ButtonsType.Ok);
|
||||||
md.Run();
|
md.Run();
|
||||||
md.Dispose();
|
md.Dispose();
|
||||||
|
@ -602,6 +583,7 @@ namespace Buypeeb {
|
||||||
settings.watchlist.Clear();
|
settings.watchlist.Clear();
|
||||||
RenderList();
|
RenderList();
|
||||||
}
|
}
|
||||||
|
|
||||||
md.Dispose();
|
md.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,14 +607,14 @@ namespace Buypeeb {
|
||||||
settings = JsonSerializer.Deserialize<Settings>(j);
|
settings = JsonSerializer.Deserialize<Settings>(j);
|
||||||
RenderList();
|
RenderList();
|
||||||
UpdateItems();
|
UpdateItems();
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
var md = MsgBox($"Failed to load {od.Filename}!\n{e.Message}", ButtonsType.Ok);
|
var md = MsgBox($"Failed to load {od.Filename}!\n{e.Message}", ButtonsType.Ok);
|
||||||
md.Run();
|
md.Run();
|
||||||
md.Dispose();
|
md.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
od.Dispose();
|
od.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,8 +631,7 @@ namespace Buypeeb {
|
||||||
);
|
);
|
||||||
sd.CurrentName = "userdata.json";
|
sd.CurrentName = "userdata.json";
|
||||||
|
|
||||||
var sdf = new FileFilter();
|
var sdf = new FileFilter {Name = "JSON files"};
|
||||||
sdf.Name = "JSON files";
|
|
||||||
sdf.AddMimeType("application/json");
|
sdf.AddMimeType("application/json");
|
||||||
sdf.AddPattern("*.json");
|
sdf.AddPattern("*.json");
|
||||||
sd.AddFilter(sdf);
|
sd.AddFilter(sdf);
|
||||||
|
@ -662,8 +643,7 @@ namespace Buypeeb {
|
||||||
fs.Write(JsonSerializer.Serialize(settings, jsonOptions));
|
fs.Write(JsonSerializer.Serialize(settings, jsonOptions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
var md = MsgBox($"Failed to write {sd.Filename}!\n{e.Message}.", ButtonsType.Ok);
|
var md = MsgBox($"Failed to write {sd.Filename}!\n{e.Message}.", ButtonsType.Ok);
|
||||||
md.Run();
|
md.Run();
|
||||||
|
@ -702,11 +682,9 @@ namespace Buypeeb {
|
||||||
try {
|
try {
|
||||||
using (var writer = new StreamWriter(sd.Filename))
|
using (var writer = new StreamWriter(sd.Filename))
|
||||||
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture)) {
|
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture)) {
|
||||||
|
|
||||||
csv.WriteRecords(settings.watchlist);
|
csv.WriteRecords(settings.watchlist);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
var md = MsgBox($"Failed to write {sd.Filename}!\n{e.Message}.", ButtonsType.Ok);
|
var md = MsgBox($"Failed to write {sd.Filename}!\n{e.Message}.", ButtonsType.Ok);
|
||||||
md.Run();
|
md.Run();
|
||||||
|
@ -722,10 +700,12 @@ namespace Buypeeb {
|
||||||
foreach (var item in settings.watchlist) {
|
foreach (var item in settings.watchlist) {
|
||||||
Console.WriteLine(item);
|
Console.WriteLine(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("---\nFilter results:");
|
Console.WriteLine("---\nFilter results:");
|
||||||
foreach (var item in filterQuery) {
|
foreach (var item in filterQuery) {
|
||||||
Console.WriteLine(item);
|
Console.WriteLine(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("---\nListstore contents:");
|
Console.WriteLine("---\nListstore contents:");
|
||||||
foreach (object[] item in items) {
|
foreach (object[] item in items) {
|
||||||
Console.WriteLine(item[0]);
|
Console.WriteLine(item[0]);
|
||||||
|
@ -765,7 +745,9 @@ namespace Buypeeb {
|
||||||
private void ButtonSelectedRemoveClicked(object sender, EventArgs a) {
|
private void ButtonSelectedRemoveClicked(object sender, EventArgs a) {
|
||||||
var item = selectedItem;
|
var item = selectedItem;
|
||||||
|
|
||||||
var md = MsgBox($"Are you sure you want to remove the item \"{item.name}\"?"); // TODO: this looks bad being all on one line
|
var md = MsgBox(
|
||||||
|
$"Are you sure you want to remove the item \"{item.name}\"?"
|
||||||
|
);
|
||||||
|
|
||||||
var response = (ResponseType) md.Run();
|
var response = (ResponseType) md.Run();
|
||||||
md.Dispose();
|
md.Dispose();
|
||||||
|
@ -777,7 +759,10 @@ namespace Buypeeb {
|
||||||
|
|
||||||
private void ButtonSelectedRenameClicked(object sender, EventArgs a) {
|
private void ButtonSelectedRenameClicked(object sender, EventArgs a) {
|
||||||
var item = selectedItem;
|
var item = selectedItem;
|
||||||
(var accepted, var response) = EntryDialogue("Rename item", $"Enter a new name for the item \"{item.name}\".", item.name);
|
var (accepted, response) = EntryDialogue(
|
||||||
|
"Rename item", $"Enter a new name for the item \"{item.name}\".", item.name
|
||||||
|
);
|
||||||
|
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
item.name = response;
|
item.name = response;
|
||||||
UpdateSelectionView();
|
UpdateSelectionView();
|
||||||
|
@ -790,6 +775,7 @@ namespace Buypeeb {
|
||||||
// the item is already waiting to be updated
|
// the item is already waiting to be updated
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateItem(selectedItem.id);
|
UpdateItem(selectedItem.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,8 +785,7 @@ namespace Buypeeb {
|
||||||
|
|
||||||
if (settings.showFavouritesAtTopOfList) {
|
if (settings.showFavouritesAtTopOfList) {
|
||||||
RenderList();
|
RenderList();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// i don't know why this is necessary
|
// i don't know why this is necessary
|
||||||
var pathAndIter = GetRow(selectedItem.id);
|
var pathAndIter = GetRow(selectedItem.id);
|
||||||
if (pathAndIter.path != null) {
|
if (pathAndIter.path != null) {
|
||||||
|
@ -817,6 +802,7 @@ namespace Buypeeb {
|
||||||
noteBuffer.Clear();
|
noteBuffer.Clear();
|
||||||
selectedItem.notes = null;
|
selectedItem.notes = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
md.Dispose();
|
md.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,7 +811,7 @@ namespace Buypeeb {
|
||||||
// how very sneaky
|
// how very sneaky
|
||||||
var noteBuffer = (TextBuffer) builder.GetObject("TextBufferSelectedNotes");
|
var noteBuffer = (TextBuffer) builder.GetObject("TextBufferSelectedNotes");
|
||||||
if (selectedItem != null) {
|
if (selectedItem != null) {
|
||||||
selectedItem.notes = String.IsNullOrWhiteSpace(noteBuffer.Text) ? null : noteBuffer.Text;
|
selectedItem.notes = string.IsNullOrWhiteSpace(noteBuffer.Text) ? null : noteBuffer.Text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,12 +848,12 @@ namespace Buypeeb {
|
||||||
if (span.Days > 0) {
|
if (span.Days > 0) {
|
||||||
ending += span.ToString("dd' days, '"); // will format twelve days as "12 days, "
|
ending += span.ToString("dd' days, '"); // will format twelve days as "12 days, "
|
||||||
}
|
}
|
||||||
|
|
||||||
// timespan objects don't contain definitions for the time or date separators, so the colons need to be escaped
|
// timespan objects don't contain definitions for the time or date separators, so the colons need to be escaped
|
||||||
// `HH` doesn't exist, but `hh` behaves identically
|
// `HH` doesn't exist, but `hh` behaves identically
|
||||||
// see https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings
|
// see https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings
|
||||||
ending += span.ToString(@"hh\:mm\:ss");
|
ending += span.ToString(@"hh\:mm\:ss");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ending = "Auction has ended";
|
ending = "Auction has ended";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -899,22 +885,28 @@ namespace Buypeeb {
|
||||||
|
|
||||||
// column renderers
|
// column renderers
|
||||||
|
|
||||||
private void RenderColumnFavourite(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) {
|
private static void RenderColumnFavourite(
|
||||||
|
TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter
|
||||||
|
) {
|
||||||
var item = (YahooAuctionsItem) model.GetValue(iter, 0);
|
var item = (YahooAuctionsItem) model.GetValue(iter, 0);
|
||||||
((CellRendererText) cell).Text = item.favourite ? "♥" : "";
|
((CellRendererText) cell).Text = item.favourite ? "♥" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RenderColumnName(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) {
|
private static void RenderColumnName(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) {
|
||||||
var item = (YahooAuctionsItem) model.GetValue(iter, 0);
|
var item = (YahooAuctionsItem) model.GetValue(iter, 0);
|
||||||
((CellRendererText) cell).Text = item.name ?? "Loading...";
|
((CellRendererText) cell).Text = item.name ?? "Loading...";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RenderColumnPriceYen(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) {
|
private static void RenderColumnPriceYen(
|
||||||
|
TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter
|
||||||
|
) {
|
||||||
var item = (YahooAuctionsItem) model.GetValue(iter, 0);
|
var item = (YahooAuctionsItem) model.GetValue(iter, 0);
|
||||||
((CellRendererText) cell).Text = item.Ready ? item.priceJpy : "...";
|
((CellRendererText) cell).Text = item.Ready ? item.priceJpy : "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RenderColumnPriceAUD(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) {
|
private static void RenderColumnPriceAUD(
|
||||||
|
TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter
|
||||||
|
) {
|
||||||
var item = (YahooAuctionsItem) model.GetValue(iter, 0);
|
var item = (YahooAuctionsItem) model.GetValue(iter, 0);
|
||||||
((CellRendererText) cell).Text = item.Ready ? item.priceAud : "...";
|
((CellRendererText) cell).Text = item.Ready ? item.priceAud : "...";
|
||||||
}
|
}
|
||||||
|
@ -925,8 +917,7 @@ namespace Buypeeb {
|
||||||
if (item.Ready) {
|
if (item.Ready) {
|
||||||
if (!item.Available) {
|
if (!item.Available) {
|
||||||
ending = "Ended";
|
ending = "Ended";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
var end = item.endDate.ToLocalTime();
|
var end = item.endDate.ToLocalTime();
|
||||||
// TODO: should we show the year if the auction ends next year? 0uo
|
// TODO: should we show the year if the auction ends next year? 0uo
|
||||||
|
@ -934,6 +925,7 @@ namespace Buypeeb {
|
||||||
// the auction isn't ending today, so we should show the day it's ending on for clarity
|
// the auction isn't ending today, so we should show the day it's ending on for clarity
|
||||||
ending += end.ToString("MMM d ");
|
ending += end.ToString("MMM d ");
|
||||||
}
|
}
|
||||||
|
|
||||||
ending += end.ToString("HH:mm");
|
ending += end.ToString("HH:mm");
|
||||||
if (settings.showSecondsInListView) {
|
if (settings.showSecondsInListView) {
|
||||||
// add the seconds on to the end
|
// add the seconds on to the end
|
||||||
|
@ -941,6 +933,7 @@ namespace Buypeeb {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((CellRendererText) cell).Text = item.Ready ? ending : "...";
|
((CellRendererText) cell).Text = item.Ready ? ending : "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,6 +944,7 @@ namespace Buypeeb {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Price == 0) {
|
if (item.Price == 0) {
|
||||||
// the item has only just been added, so we can't compare it against the filters, since it's missing most of its data
|
// the item has only just been added, so we can't compare it against the filters, since it's missing most of its data
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -11,9 +11,7 @@ namespace Buypeeb {
|
||||||
public bool autosave { get; set; } = true;
|
public bool autosave { get; set; } = true;
|
||||||
public bool showFavouritesAtTopOfList { get; set; } = true;
|
public bool showFavouritesAtTopOfList { get; set; } = true;
|
||||||
|
|
||||||
public Dictionary<string, YahooAuctionsItem> watchlist {
|
public Dictionary<string, YahooAuctionsItem> watchlist { get; set; }
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Settings() {
|
public Settings() {
|
||||||
// create a new watchlist from an empty dictionary if it's null, which should only happen if either this is the
|
// create a new watchlist from an empty dictionary if it's null, which should only happen if either this is the
|
||||||
|
@ -34,10 +32,10 @@ namespace Buypeeb {
|
||||||
int seconds;
|
int seconds;
|
||||||
if (item.favourite) {
|
if (item.favourite) {
|
||||||
seconds = item.endingSoon ? favouriteUpdateIntervalCritical : favouriteUpdateInterval;
|
seconds = item.endingSoon ? favouriteUpdateIntervalCritical : favouriteUpdateInterval;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
seconds = item.endingSoon ? updateIntervalCritical : updateInterval;
|
seconds = item.endingSoon ? updateIntervalCritical : updateInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
var later = item.LastUpdated.AddSeconds(seconds);
|
var later = item.LastUpdated.AddSeconds(seconds);
|
||||||
return DateTime.Compare(later, DateTime.UtcNow) < 0;
|
return DateTime.Compare(later, DateTime.UtcNow) < 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Gtk;
|
using Gtk;
|
||||||
|
|
||||||
// ReSharper disable UnusedMember.Local
|
// ReSharper disable UnusedMember.Local
|
||||||
// ReSharper disable UnusedParameter.Local
|
// ReSharper disable UnusedParameter.Local
|
||||||
|
|
||||||
|
@ -11,10 +12,14 @@ namespace Buypeeb {
|
||||||
private readonly Settings settings;
|
private readonly Settings settings;
|
||||||
private readonly Builder builder;
|
private readonly Builder builder;
|
||||||
|
|
||||||
private readonly List<string> generalSwitchNames = new List<string> { "ShowSecondsInListView", "Autosave", "ShowFavouritesAtTopOfList" };
|
private readonly List<string> generalSwitchNames = new List<string>
|
||||||
private readonly List<string> updateIntervalEntryNames = new List<string> { "UpdateInterval", "UpdateIntervalCritical", "FavouriteUpdateInterval", "FavouriteUpdateIntervalCritical" };
|
{"ShowSecondsInListView", "Autosave", "ShowFavouritesAtTopOfList"};
|
||||||
|
|
||||||
public SettingsWindow(Settings settings) : this(new Builder("settings.glade"), settings) { }
|
private readonly List<string> updateIntervalEntryNames = new List<string>
|
||||||
|
{"UpdateInterval", "UpdateIntervalCritical", "FavouriteUpdateInterval", "FavouriteUpdateIntervalCritical"};
|
||||||
|
|
||||||
|
public SettingsWindow(Settings settings) : this(new Builder("settings.glade"), settings) {
|
||||||
|
}
|
||||||
|
|
||||||
private SettingsWindow(Builder builder, Settings settings) : base(builder.GetObject("WindowSettings").Handle) {
|
private SettingsWindow(Builder builder, Settings settings) : base(builder.GetObject("WindowSettings").Handle) {
|
||||||
Title = "Buypeeb - Settings";
|
Title = "Buypeeb - Settings";
|
||||||
|
@ -55,8 +60,7 @@ namespace Buypeeb {
|
||||||
var e = (Entry) builder.GetObject($"Entry{name}");
|
var e = (Entry) builder.GetObject($"Entry{name}");
|
||||||
if (!int.TryParse(e.Text, out var result)) {
|
if (!int.TryParse(e.Text, out var result)) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (result < 30 || result > 6000) {
|
if (result < 30 || result > 6000) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +70,8 @@ namespace Buypeeb {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var md = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Update intervals must be a whole number between 30 and 6000.");
|
var md = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok,
|
||||||
|
"Update intervals must be a whole number between 30 and 6000.");
|
||||||
md.Run();
|
md.Run();
|
||||||
md.Dispose();
|
md.Dispose();
|
||||||
return;
|
return;
|
||||||
|
@ -81,6 +86,7 @@ namespace Buypeeb {
|
||||||
foreach (var name in generalSwitchNames) {
|
foreach (var name in generalSwitchNames) {
|
||||||
SetSetting(PropertyName(name), ((Switch) builder.GetObject($"Switch{name}")).Active);
|
SetSetting(PropertyName(name), ((Switch) builder.GetObject($"Switch{name}")).Active);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dispose();
|
Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,9 @@ using CsvHelper.Configuration.Attributes;
|
||||||
|
|
||||||
namespace Buypeeb {
|
namespace Buypeeb {
|
||||||
internal class YahooAuctionsItem {
|
internal class YahooAuctionsItem {
|
||||||
[JsonIgnore]
|
[JsonIgnore] public string url => $"https://page.auctions.yahoo.co.jp/jp/auction/{id}";
|
||||||
public string url => $"https://page.auctions.yahoo.co.jp/jp/auction/{id}";
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore] public string buyeeUrl => $"https://buyee.jp/item/yahoo/auction/{id}";
|
||||||
public string buyeeUrl => $"https://buyee.jp/item/yahoo/auction/{id}";
|
|
||||||
|
|
||||||
// any items with a getter will be saved to userdata.json
|
// any items with a getter will be saved to userdata.json
|
||||||
// anything that's configurable by the user, such as the custom name, should be saved
|
// anything that's configurable by the user, such as the custom name, should be saved
|
||||||
|
@ -20,8 +18,7 @@ namespace Buypeeb {
|
||||||
// i'm also saving the original name to make it easier to tell what the items are in the userdata.json
|
// i'm also saving the original name to make it easier to tell what the items are in the userdata.json
|
||||||
// there's not really a need for it i guess but it's my program and i can do what i want
|
// there's not really a need for it i guess but it's my program and i can do what i want
|
||||||
// anything with the attribute [Ignore] won't be put in the CSV, and things with [JsonIgnore] won't be put in userdata.json
|
// anything with the attribute [Ignore] won't be put in the CSV, and things with [JsonIgnore] won't be put in userdata.json
|
||||||
[Ignore]
|
[Ignore] public string id { get; }
|
||||||
public string id { get; }
|
|
||||||
public string name { get; set; }
|
public string name { get; set; }
|
||||||
public int Price;
|
public int Price;
|
||||||
public int WinPrice;
|
public int WinPrice;
|
||||||
|
@ -44,26 +41,19 @@ namespace Buypeeb {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore] public string priceJpy => $"¥{Price}";
|
||||||
public string priceJpy => $"¥{Price}";
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore] public string winPriceJpy => $"¥{WinPrice}";
|
||||||
public string winPriceJpy => $"¥{WinPrice}";
|
|
||||||
|
|
||||||
[Ignore, JsonIgnore]
|
[Ignore, JsonIgnore] public string priceAud => $"${(Price / 75.0):f2}";
|
||||||
public string priceAud => $"${(Price / 75.0):f2}";
|
|
||||||
|
|
||||||
[Ignore, JsonIgnore]
|
[Ignore, JsonIgnore] public string winPriceAud => $"${(WinPrice / 75.0):f2}";
|
||||||
public string winPriceAud => $"${(WinPrice / 75.0):f2}";
|
|
||||||
|
|
||||||
[Ignore, JsonIgnore]
|
[Ignore, JsonIgnore] public bool endingToday => endDate.DayOfYear == DateTime.UtcNow.DayOfYear;
|
||||||
public bool endingToday => endDate.DayOfYear == DateTime.UtcNow.DayOfYear;
|
|
||||||
|
|
||||||
[Ignore, JsonIgnore]
|
[Ignore, JsonIgnore] public bool hasWinPrice => WinPrice != 0;
|
||||||
public bool hasWinPrice => WinPrice != 0;
|
|
||||||
|
|
||||||
[Ignore, JsonIgnore]
|
[Ignore, JsonIgnore] public bool endingSoon => DateTime.Compare(DateTime.UtcNow.AddMinutes(10), endDate) > 0;
|
||||||
public bool endingSoon => DateTime.Compare(DateTime.UtcNow.AddMinutes(10), endDate) > 0;
|
|
||||||
|
|
||||||
private bool success { get; set; } // TODO: custom setter that throws an exception if set to false or something idk
|
private bool success { get; set; } // TODO: custom setter that throws an exception if set to false or something idk
|
||||||
|
|
||||||
|
@ -78,26 +68,29 @@ namespace Buypeeb {
|
||||||
|
|
||||||
public void Update(string html) {
|
public void Update(string html) {
|
||||||
// TODO: handle all the parsing errors and weird interpretation that could possibly happen here
|
// TODO: handle all the parsing errors and weird interpretation that could possibly happen here
|
||||||
var rx = new Regex(@"var pageData ?= ?(\{.+?\});", RegexOptions.Singleline); // TODO: maybe compile and match the regex in another thread
|
var rx = new Regex(@"var pageData ?= ?(\{.+?\});",
|
||||||
|
RegexOptions.Singleline); // TODO: maybe compile and match the regex in another thread
|
||||||
var m = rx.Match(html);
|
var m = rx.Match(html);
|
||||||
|
|
||||||
Dictionary<string, Dictionary<string, string>> jFull;
|
Dictionary<string, Dictionary<string, string>> jFull;
|
||||||
try {
|
try {
|
||||||
// master forgive me, but i must go all out, just this once...
|
// master forgive me, but i must go all out, just this once...
|
||||||
jFull = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(m.Groups[1].Value);
|
jFull = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(m.Groups[1].Value);
|
||||||
}
|
} catch {
|
||||||
catch {
|
|
||||||
Console.WriteLine("oh jeez oh man oh jeez oh man oh jeez oh man");
|
Console.WriteLine("oh jeez oh man oh jeez oh man oh jeez oh man");
|
||||||
Console.WriteLine(m.Groups[1].Value);
|
Console.WriteLine(m.Groups[1].Value);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
var jst = TimeZoneInfo.CreateCustomTimeZone("JST", new TimeSpan(9, 0, 0), "Japan Standard Time", "Japen Standard Time");
|
var jst = TimeZoneInfo.CreateCustomTimeZone("JST", new TimeSpan(9, 0, 0), "Japan Standard Time",
|
||||||
|
"Japen Standard Time");
|
||||||
|
|
||||||
var j = jFull["items"];
|
var j = jFull["items"];
|
||||||
originalName = j["productName"];
|
originalName = j["productName"];
|
||||||
StartDate = TimeZoneInfo.ConvertTimeToUtc(DateTime.ParseExact(j["starttime"], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), jst);
|
StartDate = TimeZoneInfo.ConvertTimeToUtc(
|
||||||
endDate = TimeZoneInfo.ConvertTimeToUtc(DateTime.ParseExact(j["endtime"], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), jst);
|
DateTime.ParseExact(j["starttime"], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), jst);
|
||||||
|
endDate = TimeZoneInfo.ConvertTimeToUtc(
|
||||||
|
DateTime.ParseExact(j["endtime"], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), jst);
|
||||||
LastUpdated = DateTime.UtcNow;
|
LastUpdated = DateTime.UtcNow;
|
||||||
Available = j["isClosed"] == "0";
|
Available = j["isClosed"] == "0";
|
||||||
|
|
||||||
|
@ -105,7 +98,7 @@ namespace Buypeeb {
|
||||||
success = int.TryParse(j["winPrice"], out WinPrice);
|
success = int.TryParse(j["winPrice"], out WinPrice);
|
||||||
success = int.TryParse(j["bids"], out Bids);
|
success = int.TryParse(j["bids"], out Bids);
|
||||||
|
|
||||||
if (String.IsNullOrWhiteSpace(name)) {
|
if (string.IsNullOrWhiteSpace(name)) {
|
||||||
name = originalName;
|
name = originalName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue