-
Notifications
You must be signed in to change notification settings - Fork 0
/
HelperMethods.cs
79 lines (68 loc) · 1.69 KB
/
HelperMethods.cs
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
using System;
using Actioncards.BL;
using System.Diagnostics;
using Actioncards.SAL;
using System.Globalization;
using HtmlAgilityPack;
using System.IO;
using HtmlAgilityPack;
using Actioncards.Instantiater;
namespace Actioncards
{
public class HelperMethods
{
public static Actioncard MakeActioncard(string title, string stitle, string parent, string meta, string version, string id, string date)
{
Actioncard card = new Actioncard();
card.ID = id;
card.Title = title;
card.Stitle = stitle;
card.ParentCatID = parent;
card.meta = meta;
card.Version = version;
card.TimeStamp = DateTime.Parse(date, CultureInfo.InvariantCulture);
return card;
}
public static Category MakeCategory(String title, string catId, int color, bool isRoot = false)
{
Category cat = new Category ();
cat.Title = title;
cat.ID = catId;
cat.Color = color;
cat.IsRoot = isRoot;
return cat;
}
public static CardListElement MakeListElement(string id, string version)
{
var element = new CardListElement ();
element.Id = id;
element.Version = version;
return element;
}
public static void ReportError(string msg)
{
Report (msg, Constants.ErrorLogUrl);
}
public static void ReportInfo(string msg)
{
Report (msg, Constants.InfoLogUrl);
}
public static void Report(string msg, string url)
{
if (Constants.ProductionMode) {
IOnlineManager _om = ServiceProvider.Instanceses.GetOnlineManager ();
_om.reportToLog (msg, url);
}
else
{
Console.WriteLine (msg);
}
}
public static string GetRandomCacheParameter()
{
var random = new Random ();
var num = random.Next ().ToString ();
return "?cache=" + num;
}
}
}