-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
102 lines (96 loc) · 3.84 KB
/
Program.cs
File metadata and controls
102 lines (96 loc) · 3.84 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
using DataAccessLayer;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UpdateData
{
class Program
{
static void Main(string[] args)
{
StockManager stockManager = new StockManager();
DataManager dataMgr = new DataManager();
char menustr = '4';
if ((args.Length == 0) || ((args[0].Equals("1") == false) && (args[0].Equals("2") == false) && (args[0].Equals("3") == false) && (args[0].Equals("4") == false)))
{
Console.WriteLine("Select Menu:");
Console.WriteLine("1. Background update of NAV");
Console.WriteLine("2. Background refresh NSE stock master");
Console.WriteLine("3. Background update ALL stock price");
Console.WriteLine("4. to exit");
Console.Write("Enter your choice: ");
menustr = Console.ReadKey().KeyChar; //ReadLine();
Console.WriteLine();
}
else
{
menustr = args[0].First();
}
do
{
if (menustr == '1')
{
//update NAV records
try
{
dataMgr.UpdateNAVFromLastFetchDate();
}
catch (Exception ex)
{
Console.WriteLine("UpdateNAVFromLastFetchDate :" + ex.Message);
}
}
else if (menustr == '2')
{
//this will get latest stock symbols for NSE only
try
{
stockManager.FetchStockMasterFromWebAndInsert();
}
catch (Exception ex)
{
Console.WriteLine("FetchStockMasterFromWebAndInsert :" + ex.Message);
}
}
else if (menustr == '3')
{
//update stock price data for all existing symbols
try
{
DataTable stockMaster = stockManager.getStockMaster();
if ((stockMaster != null) && (stockMaster.Rows.Count > 0))
{
foreach (DataRow stockrow in stockMaster.Rows)
{
stockManager.FetchOnlineAndSaveDailyStockData(stockrow["SYMBOL"].ToString());
}
}
}
catch (Exception ex)
{
Console.WriteLine("UpdateStockPriceData :" + ex.Message);
}
}
if ( (menustr != '4') &&
((args.Length == 0) ||
((args[0].Equals("1") == false) && (args[0].Equals("2") == false) && (args[0].Equals("3") == false) && (args[0].Equals("4") == false))))
{
Console.WriteLine("Select Menu:");
Console.WriteLine("1. Background update of NAV");
Console.WriteLine("2. Background refresh NSE stock master");
Console.WriteLine("3. Background update ALL stock price");
Console.WriteLine("4. to exit");
Console.Write("Enter your choice: ");
menustr = Console.ReadKey().KeyChar; //ReadLine();
}
else
{
menustr = '4';
}
} while (menustr != '4');
}
}
}