-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
127 lines (104 loc) · 3.85 KB
/
Program.cs
File metadata and controls
127 lines (104 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using SQLite;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Main start");
Console.WriteLine("Main end");
Console.ReadLine();
}
public void testSqlite()
{
// Get an absolute path to the database file
//var databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MyData.db");
var databasePath = "MyData.db";
var db = new SQLiteConnection(databasePath);
//db.CreateTable<Stock>();
//db.CreateTable<Valuation>();
}
public void testJobQueue()
{
JobQueue.define("test", () => { Console.WriteLine("Test"); });
JobQueue.define("test", () => { Console.WriteLine("Test"); }, () => { Console.WriteLine("Test"); });
JobQueue.define("test with data",
(data) =>
{
Console.WriteLine("Test" + JsonConvert.SerializeObject(data));
}
);
JobQueue.start();
//Job without name
JobQueue.enqueue(() => { Console.WriteLine("Test-Job without name"); });
//Parameterless call
JobQueue.enqueue("test");
//call with parameters
JobQueue.enqueue("test with data", new { algo ="algo" });
//call with parameters and callback
JobQueue.enqueue("test with data", new { algo = "algo" }, () => { Console.WriteLine("Test-call with parameters and callback"); });
}
public void testTaskQueue()
{
var queue = new TaskQueue();// define a new task
queue
.on("error", (job) => { }) // queue error handler
.on("complete", (job) => { }); // queue success handler
queue
.define("my-task")
.online() // check that navigator is online before attempting to process job
.interval("10s") // replay a failed job every 10sec (default is 2sec)
.retry(5) // retry up to 5 times
.delay("5ms") // start task after a 5ms delay
.timeout("10ms") // task fail if it lasts more than 10ms
.lifetime("5m") // stop retrying if job is more than 5min old
.action((job, done) => {
// ...
done("err"); // pass an error to the callback if task failed
});
var data = new { };
// load and process jobs persisted in the localstorage
queue.start();
// process a new job
var jobTask = queue
.create("my-task", data)
.on("error", () => { }) // job error handler
.on("complete", () => { }) // job success handler
;
}
public void testLocalStorage()
{
}
//public static void AddStock(SQLiteConnection db, string symbol)
//{
// var stock = new Stock()
// {
// Symbol = symbol
// };
// db.Insert(stock);
// Console.WriteLine("{0} == {1}", stock.Symbol, stock.Id);
//}
}
//public class Stock
//{
// [PrimaryKey, AutoIncrement]
// public int Id { get; set; }
// public string Symbol { get; set; }
//}
//public class Valuation
//{
// [PrimaryKey, AutoIncrement]
// public int Id { get; set; }
// [Indexed]
// public int StockId { get; set; }
// public DateTime Time { get; set; }
// public decimal Price { get; set; }
//}
}