-
Notifications
You must be signed in to change notification settings - Fork 0
/
ISIS.cs
199 lines (188 loc) · 8.8 KB
/
ISIS.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
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using ISDL;
using System.Data.SqlClient;
using System.Data;
using System.Threading;
using System.IO;
using System.Web;
namespace ISBL
{
public class ISIS
{
#region Private Variables
private ISDL.Connect conn = new ISDL.Connect(); //Return the connection string from web config
// private SqlDataReader myDataReader;
//private Boolean blnMLValidation;
#endregion
#region Constructors
public ISIS()
{
conn.setConnection("ocrsConnection");
}
#endregion
#region public function
public String GetDataSetID(String strDSName)
{
String strDBID;
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand();
try
{
cmd.Connection = conn.Connection;
cmd.CommandText = "sp_GetDSID";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@strDSName", SqlDbType.VarChar, 1000);
cmd.Parameters["@strDSName"].Value = strDSName;
conn.Open();
conn.callingMethod = "ISBL.ISIS.GetDataSetID";
strDBID = cmd.ExecuteScalar().ToString();
return strDBID;
}
catch (Exception ex)
{
throw ex;
}
finally
{
conn.Close();
cmd.Dispose();
}
}
public String InsertSearchBeforeLog(String strLoginName, String strDBIDs, String strName, String strSponsor, String strUniversity, String strPassport, String strCountry)
{
SqlCommand cmd = new SqlCommand();
String strSearchID = "";
try
{
cmd.Connection = conn.Connection;
cmd.CommandText = "sp_isis_goc_before_searchlog_Insert";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@search_by_login_name", SqlDbType.VarChar, 15);
cmd.Parameters.Add("@search_at_date_time", SqlDbType.DateTime);
cmd.Parameters.Add("@search_on_dataset_ids", SqlDbType.VarChar, 100);
cmd.Parameters.Add("@parameter_name", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@parameter_sponsor_name", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@parameter_university_name", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@parameter_passport_no", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@parameter_country", SqlDbType.VarChar, 50);
cmd.Parameters["@search_by_login_name"].Value = strLoginName;
cmd.Parameters["@search_at_date_time"].Value = DateTime.Now;
cmd.Parameters["@search_on_dataset_ids"].Value = strDBIDs;
cmd.Parameters["@parameter_name"].Value = strName;
cmd.Parameters["@parameter_sponsor_name"].Value = strSponsor;
cmd.Parameters["@parameter_university_name"].Value = strUniversity;
cmd.Parameters["@parameter_passport_no"].Value = strPassport;
cmd.Parameters["@parameter_country"].Value = strCountry;
conn.Open();
conn.callingMethod = "ISBL.ISIS.InsertSearchBeforeLog";
strSearchID = cmd.ExecuteScalar().ToString();
return strSearchID;
}
catch (Exception ex)
{
ISBL.User oISBLUser = new ISBL.User();
string strErrorType = "Error in InsertSearchBeforeLog";
InsertErrorLog("0", ex.Message, strErrorType);
string strTo = System.Configuration.ConfigurationManager.AppSettings["GOCRecepientEmail"].ToString();
string strFrom = "globalonecheck@integrascreen.com";
string strSubject = "Error Occured in GOC";
string strBody = "Hello GOC Team </br></br>The following error encountered for the user : " + oISBLUser.LoginName + "</br></br>The details of the error are as follows :</br></br>" + ex.Message;
SendGOCErrorMail(strTo, strFrom, strSubject, strBody, true);
return "false";
}
finally
{
conn.Close();
cmd.Dispose();
}
}
public String InsertSuccessLog(String strSearchSerialNo, String strSearchType)
{
SqlCommand cmd = new SqlCommand();
String status = "";
try
{
cmd.Connection = conn.Connection;
cmd.CommandText = "sp_isis_goc_final_searchlog_insert";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@search_serial_no", SqlDbType.Int);
cmd.Parameters.Add("@search_type", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@created_date_time", SqlDbType.DateTime);
cmd.Parameters["@search_serial_no"].Value = Convert.ToInt32(strSearchSerialNo);
cmd.Parameters["@search_type"].Value = strSearchType;
cmd.Parameters["@created_date_time"].Value = DateTime.Now;
conn.Open();
conn.callingMethod = "ISBL.ISIS.InsertSuccessLog";
status = cmd.ExecuteScalar().ToString();
return status;
}
catch(Exception ex)
{
ISBL.User oISBLUser = new ISBL.User();
string strErrorType="Error in InsertSuccessLog";
InsertErrorLog(strSearchSerialNo, ex.Message, strErrorType);
string strTo = System.Configuration.ConfigurationManager.AppSettings["GOCRecepientEmail"].ToString();
string strFrom = "globalonecheck@integrascreen.com";
string strSubject = "Error Occured in GOC";
string strBody = "Hello GOC Team </br></br>The following error encountered for the user : " + oISBLUser.LoginName + "</br></br>The details of the error are as follows :</br></br>" + ex.Message;
SendGOCErrorMail(strTo, strFrom, strSubject, strBody, true);
return "false";
}
finally
{
conn.Close();
cmd.Dispose();
}
}
public String InsertErrorLog(String strSearchSerialNo, String strErrorMesg, String strErrorType)
{
SqlCommand cmd = new SqlCommand();
String status = "";
try
{
cmd.Connection = conn.Connection;
cmd.CommandText = "sp_isis_goc_errorlog_Insert";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@search_serial_no", SqlDbType.Int);
cmd.Parameters.Add("@error_type", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@error_message", SqlDbType.VarChar, 200);
cmd.Parameters.Add("@error_date_time", SqlDbType.DateTime);
cmd.Parameters["@search_serial_no"].Value = Convert.ToInt32(strSearchSerialNo);
cmd.Parameters["@error_type"].Value = strErrorType;
cmd.Parameters["@error_message"].Value = strErrorMesg;
cmd.Parameters["@error_date_time"].Value = DateTime.Now;
conn.Open();
conn.callingMethod = "ISBL.ISIS.InsertErrorLog";
status = cmd.ExecuteScalar().ToString();
return status;
}
catch(Exception ex)
{
ISBL.User oISBLUser = new ISBL.User();
string strTo = System.Configuration.ConfigurationManager.AppSettings["GOCRecepientEmail"].ToString();
string strFrom = "globalonecheck@integrascreen.com";
string strSubject = "Error Occured in GOCErrorLog";
string strBody = "Hello GOC Team </br></br>The following error encountered for the user : " + oISBLUser.LoginName + "</br></br>The details of the error are as follows :</br></br>" + ex.Message;
SendGOCErrorMail(strTo, strFrom, strSubject, strBody, true);
return "false";
}
finally
{
conn.Close();
cmd.Dispose();
}
}
public void SendGOCErrorMail(String strTo, string strFrom, string strSubject, string strBody, bool IsBodyHTML)
{
ISBL.General oISBLGen = new ISBL.General();
Thread threadSendMails = new Thread(delegate() { oISBLGen.sendemail(strTo, strFrom, strSubject, strBody, IsBodyHTML); });
threadSendMails.IsBackground = true;
threadSendMails.Start();
//oISBLGen = null;
}
#endregion
}
}