PS below list of Cr's we should work in New_WBRecordingScheduler
1. Check if oracle connection is working fine
1.1: if yes fetch record an save to xml file
1.2: if no - then exit from connecting oracle instance further keep 5 minutes sleep timer to check if oracle db is accessible and repeat above steps.
2. Check if recording server sql db connection is working fine
2.1: if yes- read xml file and push sessions for recording note: Use separate procedures to insert records to both WB Record Sessions and linking table
2.2: if no - then exit from connecting sql instance further keep 5 minutes sleep timer to check if sql db is accessible and continue record insertions accordingly.
3: Keep record insertion logs
4. Then send mail - with attachment
5. SQL exception log we are not capturing- should do that
I need to implement in code handled in oracle but the problem i am facing is am checking connection in sql if its available for 5-10 min it has to return and save in sql db
public string[] GetPriorityRecordingSessionsbeta()
{
string[] strArray = new string[3];
var yes = CheckConnection();
if (yes)
{
DateTime utc1 = this.objDTC.ConvertLocalTimeToUTC(Convert.ToDateTime(this.d_1.ToShortDateString()), ConfigurationManager.AppSettings["TimeZone"].ToString());
DateTime utc2 = this.objDTC.ConvertLocalTimeToUTC(Convert.ToDateTime(this.d_2.ToShortDateString()), ConfigurationManager.AppSettings["TimeZone"].ToString());
ELBASEDAL elbasedal = new ELBASEDAL();
try
{
OracleParameter[] parameters = new OracleParameter[3]
{
elbasedal.CreateInParameter("ifromdate", OracleType.VarChar, (object) utc1.ToString()),
elbasedal.CreateInParameter("itodate", OracleType.VarChar, (object) utc2.ToString()),
elbasedal.CreateOutParameter("cursor_s", OracleType.Cursor)
};
DataTable tableStoreProcedure = elbasedal.GetDataTableStoreProcedure("DAILY_REPORTS_PACKAGE.getPriorityRecDetails", parameters);
if (tableStoreProcedure.Rows.Count > 0)
{
try
{
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConnectionString"].ToString());
SqlParameter sqlParameter1 = new SqlParameter("@OSessionID", SqlDbType.VarChar, 100);
sqlParameter1.Direction = ParameterDirection.Output;
SqlParameter sqlParameter2 = sqlParameter1;
SqlParameter sqlParameter3 = new SqlParameter("@OResult", SqlDbType.Int);
sqlParameter3.Direction = ParameterDirection.Output;
SqlParameter sqlParameter4 = sqlParameter3;
foreach (DataRow row in (InternalDataCollectionBase)tableStoreProcedure.Rows)
{
XMLSessiondetailsLogger("session details logged successfully", row["SESSION_ID"].ToString(), row["WB_SESSION_ID"].ToString(), row["recording_priority"].ToString(), row["Subject_Name"].ToString(), row["Topic_Name"].ToString(), row["Question"].ToString(), row["Student_Name"].ToString(), row["Tutor_Name"].ToString(), row["Franchise_Name"].ToString(), row["Project_Name"].ToString(), row["rec_url"].ToString());
var checksql = CheckConnectionsql();
if (checksql)
{
// if (connection.State == ConnectionState.Closed)
// connection.Open();
this.cmd = new SqlCommand("InsertWBRecDetails", connection);
this.cmd.CommandType = CommandType.StoredProcedure;
this.cmd.Parameters.AddWithValue("@App_SessionID", (object)Convert.ToString(row["SESSION_ID"]));
this.cmd.Parameters.AddWithValue("@Wb_Sessionid", (object)Convert.ToString(row["WB_SESSION_ID"]));
this.cmd.Parameters.AddWithValue("@Priority", (object)Convert.ToInt32(row["recording_priority"]));
this.cmd.Parameters.AddWithValue("@Subject_Name", (object)Convert.ToString(row["Subject_Name"]));
this.cmd.Parameters.AddWithValue("@Topic_Name", (object)Convert.ToString(row["Topic_Name"]));
this.cmd.Parameters.AddWithValue("@Question", (object)Convert.ToString(row["Question"]));
this.cmd.Parameters.AddWithValue("@Student_Name", (object)Convert.ToString(row["Student_Name"]));
this.cmd.Parameters.AddWithValue("@Tutor_Name", (object)Convert.ToString(row["Tutor_Name"]));
this.cmd.Parameters.AddWithValue("@School_Name", (object)Convert.ToString(row["Franchise_Name"]));
this.cmd.Parameters.AddWithValue("@Project_Name", (object)Convert.ToString(row["Project_Name"]));
this.cmd.Parameters.AddWithValue("@RecordingURL", (object)Convert.ToString(row["rec_url"]));
this.cmd.Parameters.Add(sqlParameter4);
this.cmd.Parameters.Add(sqlParameter2);
this.cmd.ExecuteNonQuery();
if (sqlParameter4.Value.ToString() == "1")
{
this.outfail = sqlParameter2.Value.ToString() + ",";
this.outfail1 += this.outfail.ToString();
this.bfcount1 += this.bfcount + 1;
strArray[0] = this.bfcount1.ToString();
}
else if (sqlParameter4.Value.ToString() == "0")
{
this.outsuccess = sqlParameter2.Value.ToString() + ",";
this.outsuccess1 += this.outsuccess.ToString();
this.bscount1 += this.bscount + 1;
strArray[1] = this.bscount1.ToString();
}
this.cmd.Parameters.Clear();
connection.Close();
}
else
{
Console.WriteLine("Failed to start pre-processing. so il sleep task for every 10 min {0}", loop);
//repeat 4 times every 10min
if (loop < 4)
{
// 10 min task sleep
Thread.Sleep(600000);
loop++;
GetPriorityRecordingSessionsbeta();
}
else
{
xmlStatusLogger("fetching Session details from database Failed");
FailuremailSender();
}
}
}
this.createloggerbeta(this.outsuccess1, "0");
this.createloggerbeta(this.outfail1, "1");
strArray[2] = this.outfail1.TrimEnd(',').ToString();
this.outfail1 = string.Empty;
this.outsuccess1 = string.Empty;
}
catch (Exception ex)
{
this.objerr.WriteXMLErrorLog(ex);
}
}
}
catch (Exception ex)
{
this.objerr.WriteXMLErrorLog(ex);
}
}
else
{
Console.WriteLine("Failed to start pre-processing. so il sleep task for every 10 min {0}", loop);
//repeat 4 times every 10min
if (loop < 4)
{
// 10 min task sleep
Thread.Sleep(600000);
loop++;
GetPriorityRecordingSessionsbeta();
}
else
{
xmlStatusLogger("fetching Session details from database Failed");
FailuremailSender();
}
}
return strArray;
}
In below code am facing issue it will return to main method again the process will start from the beginning if oracle things happened means it process in sql only
Here what i am doing is fetching the details from oracle and inserting in sql db before this am checking both oracle sql connection availability but both functionalities happening inside one method
so i how can i achieve this?
else
{
Console.WriteLine("Failed to start pre-processing. so il sleep task for every 10 min {0}", loop);
//repeat 4 times every 10min
if (loop < 4)
{
// 10 min task sleep
Thread.Sleep(600000);
loop++;
GetPriorityRecordingSessionsbeta();
}
else
{
xmlStatusLogger("fetching Session details from database Failed");
FailuremailSender();
}
}