forked from sayanee/angularjs-pdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DailyTrackerController.cs
341 lines (286 loc) · 13.5 KB
/
DailyTrackerController.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Http;
using RndApp.Models;
using System.Net.Http;
using System.Web.Security;
using System.Net;
using System.Data;
using System.IO;
namespace RndApp.Controllers
{
public class DailyTrackerController : Controller
{
//
// GET: /DailyTracker/
[System.Web.Mvc.Authorize]
public ActionResult Tracker()
{
return View();
}
[System.Web.Http.Authorize]
[System.Web.Http.HttpPost]
public string DailyTrackerPost(DailyTrackerUpload objDailyTrackerUpload)
{
try
{
DailyTrackerUpload[] arrDailyTrackerUpload = { objDailyTrackerUpload };
AcceesModel obj = new AcceesModel();
DataTable tbCategories = validateTable(obj.ToDataTable<DailyTrackerUpload>(arrDailyTrackerUpload));
DataSet ds = obj.getDataSet("CollectionManualmport", tbCategories, "0", Convert.ToString(Session["userID"]), false);
if (ds.Tables[0].Rows[0][0].ToString() == "0")
return "Error!";
else
return ds.Tables[0].Rows[0][0].ToString();
}
catch (Exception ex)
{
return "Error";
}
}
[System.Web.Http.Authorize]
[System.Web.Http.HttpPost]
public string DailyTrackerUpdatePost(DailyTrackerUpload objDailyTrackerUpload)
{
try
{
DailyTrackerUpload[] arrDailyTrackerUpload = { objDailyTrackerUpload };
AcceesModel obj = new AcceesModel();
DataTable tbCategories = validateTable(obj.ToDataTable<DailyTrackerUpload>(arrDailyTrackerUpload));
DataSet ds = obj.getDataSet("CollectionManualUpdate", tbCategories, objDailyTrackerUpload.DailyTrackerId.ToString(), Convert.ToString(Session["userID"]), false);
if (ds.Tables[0].Rows[0][0].ToString() == "0")
return "Error!";
else
return objDailyTrackerUpload.DailyTrackerId.ToString();
}
catch (Exception ex)
{
return "Error";
}
}
public DataTable validateTable(DataTable tbCategories)
{
DataTable tbvalidateTable = new DataTable("dtDailyTracker");
tbvalidateTable.Columns.Add("ApplicationID", typeof(long));
tbvalidateTable.Columns.Add("Branch", typeof(String));
tbvalidateTable.Columns.Add("MerchantName", typeof(String));
tbvalidateTable.Columns.Add("Department", typeof(String));
tbvalidateTable.Columns.Add("ActivityType", typeof(String));
tbvalidateTable.Columns.Add("ActivitySource", typeof(String));
tbvalidateTable.Columns.Add("SubSource", typeof(String));
tbvalidateTable.Columns.Add("ActivityBy", typeof(String));
tbvalidateTable.Columns.Add("ActivityDate", typeof(String));
tbvalidateTable.Columns.Add("ActivityTime", typeof(String));
tbvalidateTable.Columns.Add("TimeSpent", typeof(String));
tbvalidateTable.Columns.Add("FeedbackCode", typeof(String));
tbvalidateTable.Columns.Add("SubFeedbackCode", typeof(String));
tbvalidateTable.Columns.Add("Proofs", typeof(String));
tbvalidateTable.Columns.Add("ForwardedTo", typeof(String));
tbvalidateTable.Columns.Add("ForwardedDate", typeof(String));
tbvalidateTable.Columns.Add("NextActionDate", typeof(String));
tbvalidateTable.Columns.Add("NextActionBy", typeof(String));
tbvalidateTable.Columns.Add("PartnerBank", typeof(String));
tbvalidateTable.Columns.Add("DateOfInstallation", typeof(String));
tbvalidateTable.Columns.Add("No_Of_EDC", typeof(String));
tbvalidateTable.Columns.Add("Type_Of_EDC", typeof(String));
tbvalidateTable.Columns.Add("MID", typeof(String));
tbvalidateTable.Columns.Add("TID", typeof(String));
tbvalidateTable.Columns.Add("Remarks", typeof(String));
tbvalidateTable.Columns.Add("AddedBy", typeof(String));
DataRow toInsert = tbvalidateTable.NewRow();
foreach (DataRow dtRow in tbCategories.Rows)
{
if (dtRow["ApplicationID"].ToString() != "0")
toInsert["ApplicationID"] = dtRow["ApplicationID"].ToString();
if (dtRow["Branch"].ToString() != "0")
toInsert["Branch"] = dtRow["Branch"].ToString();
else
toInsert["Branch"] = "";
if (!string.IsNullOrEmpty(dtRow["MerchantName"].ToString()))
toInsert["MerchantName"] = dtRow["MerchantName"].ToString();
else
toInsert["MerchantName"] = "";
if (dtRow["Department"].ToString() != "0")
toInsert["Department"] = dtRow["Department"].ToString();
else
toInsert["Department"] = "";
if (dtRow["ActivityType"].ToString() != "0")
toInsert["ActivityType"] = dtRow["ActivityType"].ToString();
else
toInsert["ActivityType"] = "";
if (dtRow["ActivitySource"].ToString() != "0")
toInsert["ActivitySource"] = dtRow["ActivitySource"].ToString();
else
toInsert["ActivitySource"] = "";
if (dtRow["SubSource"].ToString() != "0")
toInsert["SubSource"] = dtRow["SubSource"].ToString();
else
toInsert["SubSource"] = "";
if (!string.IsNullOrEmpty(dtRow["ActivityBy"].ToString()))
toInsert["ActivityBy"] = dtRow["ActivityBy"].ToString();
else
toInsert["ActivityBy"] = "";
if (dtRow["ActivityDate"].ToString() != "0")
toInsert["ActivityDate"] = dtRow["ActivityDate"].ToString();
else
toInsert["ActivityDate"] = "";
if (dtRow["ActivityTime"].ToString() != "0")
toInsert["ActivityTime"] = dtRow["ActivityTime"].ToString();
else
toInsert["ActivityTime"] = "";
if (!string.IsNullOrEmpty(dtRow["TimeSpent"].ToString()))
toInsert["TimeSpent"] = dtRow["TimeSpent"].ToString();
else
toInsert["TimeSpent"] = "";
if (!string.IsNullOrEmpty(dtRow["Proofs"].ToString()))
toInsert["Proofs"] = dtRow["Proofs"].ToString();
else
toInsert["Proofs"] = "";
if (dtRow["FeedbackCode"].ToString() != "0")
toInsert["FeedbackCode"] = dtRow["FeedbackCode"].ToString();
else
toInsert["FeedbackCode"] = "";
if (dtRow["SubFeedbackCode"].ToString() != "0")
toInsert["SubFeedbackCode"] = dtRow["SubFeedbackCode"].ToString();
else
toInsert["SubFeedbackCode"] = "";
if (dtRow["ForwardedTo"].ToString() != "0")
toInsert["ForwardedTo"] = dtRow["ForwardedTo"].ToString();
else
toInsert["ForwardedTo"] = "";
if (dtRow["ForwardedDate"].ToString() != "0")
toInsert["ForwardedDate"] = dtRow["ForwardedDate"].ToString();
else
toInsert["ForwardedDate"] = "";
if (dtRow["NextActionDate"].ToString() != "0")
toInsert["NextActionDate"] = dtRow["NextActionDate"].ToString();
else
toInsert["NextActionDate"] = "";
if (dtRow["NextActionBy"].ToString() != "0")
toInsert["NextActionBy"] = dtRow["NextActionBy"].ToString();
else
toInsert["NextActionBy"] = "";
if (dtRow["PartnerBank"].ToString() != "0")
toInsert["PartnerBank"] = dtRow["PartnerBank"].ToString();
else
toInsert["PartnerBank"] = "";
if (dtRow["DateOfInstallation"].ToString() != "0")
toInsert["DateOfInstallation"] = dtRow["DateOfInstallation"].ToString();
else
toInsert["DateOfInstallation"] = "";
if (dtRow["No_Of_EDC"].ToString() != "0")
toInsert["No_Of_EDC"] = dtRow["No_Of_EDC"].ToString();
else
toInsert["No_Of_EDC"] = "";
if (dtRow["Type_Of_EDC"].ToString() != "0")
toInsert["Type_Of_EDC"] = dtRow["Type_Of_EDC"].ToString();
else
toInsert["Type_Of_EDC"] = "";
if (dtRow["MID"].ToString() != "0")
toInsert["MID"] = dtRow["MID"].ToString();
else
toInsert["MID"] = "";
if (dtRow["TID"].ToString() != "0")
toInsert["TID"] = dtRow["Department"].ToString();
else
toInsert["TID"] = "";
if (!string.IsNullOrEmpty(dtRow["Remarks"].ToString()))
toInsert["Remarks"] = dtRow["Remarks"].ToString();
else
toInsert["Remarks"] = "";
toInsert["AddedBy"] = Convert.ToString(Session["userID"]);
tbvalidateTable.Rows.Add(toInsert);
tbvalidateTable.AcceptChanges();
}
return tbvalidateTable;
}
[System.Web.Http.Authorize]
[System.Web.Http.HttpPost]
public ActionResult FileUpload(HttpPostedFileBase file, string data, String docType)
{
try
{
string fileName = Path.GetFileName(file.FileName);
string folderpath = Server.MapPath("~/Images") + "/" + data + "/" + docType;
string path = Path.Combine(folderpath, fileName);
bool folderExists = Directory.Exists(folderpath);
if (!folderExists)
Directory.CreateDirectory(folderpath);
if (Directory.GetFiles(folderpath).Length > 0)
{
DirectoryInfo directory = new DirectoryInfo(folderpath);
foreach (System.IO.DirectoryInfo subDirectory in directory.GetDirectories()) subDirectory.Delete(true);
}
if (System.IO.File.Exists(path))
{
System.IO.File.Delete(path);
}
file.SaveAs(path);
ModelState.Clear();
AcceesModel obj = new AcceesModel();
string result = obj.GetResult("setDailyUpload '" + data + "','" + path + "','" + Convert.ToString(Session["userID"]) + "'");
return Content(result);
}
catch (Exception ex)
{
return Content("Error : " + ex.Message);
}
}
}
}
namespace RndApp.Controllers.api
{
public class DailyTrackerController : ApiController
{
//[System.Web.Http.Authorize]
//[System.Web.Http.HttpGet]
//public string GetSubCodes(string SelectType, int id)
//{
// AcceesModel obj = new AcceesModel();
// return obj.GetResult("GetSubCodeCollection '" + SelectType + "'," + id);
//}
[System.Web.Http.Authorize]
[System.Web.Http.HttpGet]
public string GetSubCodes(int unique, String userid)
{
AcceesModel obj = new AcceesModel();
return obj.GetResult("GetSubCodeCollection '" + userid + "'," + unique);
}
[System.Web.Http.Authorize]
[System.Web.Http.HttpGet]
public string GetApplicationList(string userid)
{
AcceesModel obj = new AcceesModel();
long chkNumber = 0;
bool canConvert = long.TryParse(userid, out chkNumber);
if (canConvert)
return obj.GetResult("GetApplcaitionOrMerchant '" + userid + "','" + "NUMBER" + "'");
else
return obj.GetResult("GetApplcaitionOrMerchant '" + userid + "','" + "VAR" + "'");
}
[System.Web.Http.Authorize]
[System.Web.Http.HttpGet]
public string GetDailyTrackerList(string userid)
{
AcceesModel obj = new AcceesModel();
return obj.GetResult("GetDailyTrackerList '" + userid + "'");
}
[System.Web.Http.Authorize]
[System.Web.Http.HttpGet]
public string GetDailyUploadById(String userid)
{
AcceesModel obj = new AcceesModel();
return obj.GetResult("GetDailyUploadById '" + userid + "'");
}
[System.Web.Http.Authorize]
[System.Web.Http.HttpGet]
public string RemoveDailyDocs(String userid)
{
AcceesModel obj = new AcceesModel();
return obj.GetResult("RemoveDailyDocs '" + userid + "'");
}
}
}