forked from liaohan918/AutoTicket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppsetting.cs
116 lines (98 loc) · 2.93 KB
/
Appsetting.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
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
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutoTicket
{
public static class Appsetting
{
public static IConfigurationRoot _root = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("Appsetting.json").Build();
public static string TicketWeb => Get("TicketWeb");
public static string Get(string key)
{
if (_root.GetSection(key) != null)
return _root.GetSection(key).Value;
else
return string.Empty;
}
public static string Get(params string[] sections)
{
try
{
if (sections.Any())
{
return _root[string.Join(":", sections)];
}
}
catch (Exception) { }
return "";
}
/// <summary>
/// 获取浏览器头部高度
/// </summary>
/// <returns></returns>
public static int GetChromeHeaderHeight()
{
return int.Parse(Get("ChromeHeaderHeight"));
}
/// <summary>
/// 获取观影人
/// </summary>
/// <returns></returns>
public static IList<string> GetWatchers()
{
return Get("PeopleName").Split(',').ToList();
}
/// <summary>
/// 获取抢票日期
/// </summary>
/// <returns></returns>
public static IEnumerable<int> GetDate()
{
var date = Get("Date").ToIntArray(',').ToList<int>();
return Tools.ListRandom(date);
}
/// <summary>
/// 获取场次
/// </summary>
/// <returns></returns>
public static IList<int> GetPositionIndex()
{
var position = Get("PositionIndex").ToIntArray(',').ToList<int>();
return Tools.ListRandom(position);
}
/// <summary>
/// 获取票档
/// </summary>
/// <returns></returns>
public static IList<int> GetPriceIndex()
{
var position = Get("PriceIndex").ToIntArray(',').ToList<int>();
return Tools.ListRandom(position);
}
/// <summary>
/// 抢票规则
/// </summary>
/// <returns></returns>
public static int GetPriorityRule()
{
return int.Parse(Get("PriorityRule"));
}
/// <summary>
/// 抢票页面
/// </summary>
/// <returns></returns>
public static string GetTargetUrl()
{
return Get("Web", Appsetting.TicketWeb, "TargetUrl");
}
public static string GetCookie()
{
return Get("Web", Appsetting.TicketWeb, "Cookie");
}
}
}