Anda di halaman 1dari 15

//-----------------------------------------------------------------------

// <copyright file="HOPSFunctionality.cs" company="Microsoft">


// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// <summary>
// </summary>
//-----------------------------------------------------------------------
namespace DataAccessHMTool
{
#region Namespaces
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.UI;
using System.Xml;
using HMToolUtilities;
#endregion
/// <summary>
/// Summary description for HOPSFunctionality
/// </summary>
public class HOPSFunctionality
{
/// <summary>
/// Static variable for blah blah :)
/// </summary>
private static int i = 0;
/// <summary>
/// int variable for generate random pageid
/// </summary>
private int randomPageID = 0;
/// <summary>
/// Load variable to load the page
/// </summary>
private Load objLoad = new Load();
/// <summary>
/// string variable for taking DCMachine name
/// </summary>
private string strDCMachineName = string.Empty;
/// <summary>
/// String variable for taking OFE machine name
/// </summary>
private string strOFEMachineName = string.Empty;
/// <summary>
/// Filelog variable to generate log information
/// </summary>
private FileLog file = new FileLog();
/// <summary>
/// Variable for accessing data from database table
/// </summary>
private DataAccess objAccess = new DataAccess();
/// <summary>
/// variable for component utility
/// </summary>
private ComponentUtility objUtil = new ComponentUtility();
////bool mpsRequest;
#region ETL Functionality
//// Check ETL Servers populating data in ROLogDB
////public bool CheckETLServer()
////{
//// string dbName = "RelevanceOptimizationLog"
//// DateTime dbTime;
//// DateTime udcDate;
//// bool result = false;
//// try
//// {
//// udcDate = (DateTime)objUtil.GetUDCDate(dbName);
//// for (int index = 1; index <= ETLServers; index++)
//// {
//// dbTime = (DateTime)objUtil.GetOptDateTime(dbName);
//// if (dbTime != null)
//// {
//// if (dbTime >= (udcDate - new TimeSpan(0, 5, 0)))
//// {
//// result = true;
//// message.AppendLine("ETL Server " + index + " is
aggregating the Data in to the DB. System Datetime: " + sysTime.ToString() + "\t
AggregationDateTime: " + dbTime.ToString();
//// }
//// else
//// {
//// result = false;
//// message.AppendLine("ETL Server " + index + " is
not aggregating the Data in to the DB. System Datetime: " + sysTime.ToString() +
"\t AggregationDateTime: " + dbTime.ToString();
//// }
//// }
//// else
//// {
//// result = false;
//// message.AppendLine("ETL Server " + index + " is not
aggregating the Data in to the DB";
//// }
//// }
//// if (result == true)
//// {
//// message.AppendLine("All ETL Servers are aggregating the
Data in to the DB";
//// }
//// else
//// {
//// message.AppendLine("All ETL Servers are aggregating the
Data in to the DB";
//// }
//// }
//// catch (SqlException ex)
//// {
//// result = false;
//// message.AppendLine("Server Not Accessable. Check SQL DataBas
e Permissions and the db is accessible";
//// }
//// catch (Exception ex)
//// {
//// result = false;
//// message.AppendLine("ETL Servers are not aggregating the Data
in to the DB");
//// }
//// catch (Exception Ex)
//// {
//// result = false;
//// }
////}
//// Check COSMOS Working
////public void CheckCOSMOSConnection()
////{
//// string csvKey = string.Empty;
//// csvKey = environment + "_CSVFileShare";
//// DateTime min = DateTime.Now.AddMinutes(2.0);
//// int minToWait = min.Minute;
//// try
//// {
//// csvKey = csvKey + @"\EtlPostData";
//// DirectoryInfo share = new DirectoryInfo(csvKey);
//// DirectoryInfo[] dirDetails = share.GetDirectories();
//// if (dirDetails.Length == 0)
//// {
//// file.WriteFile(DateTime.Now.ToShortDateString() + " " +
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":"
+ DateTime.Now.Millisecond + "Cosmos folder is missing in the share: " + csvKey
+ Environment.NewLine);
//// }
//// while (dirDetails.Length > 2)
//// {
//// if (minToWait < DateTime.Now.Minute)
//// break;
//// dirDetails = share.GetDirectories();
//// }
//// if (dirDetails.Length <= 2)
//// {
//// file.WriteFile(DateTime.Now.ToShortDateString() + " " +
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":"
+ DateTime.Now.Millisecond + "ETL is uploading the data in to the cosmos " + Env
ironment.NewLine);
//// }
//// else
//// {
//// file.WriteFile(DateTime.Now.ToShortDateString() + " " +
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":"
+ DateTime.Now.Millisecond + "ETL is not uploading the data in to the cosmos " +
Environment.NewLine);
//// }
//// }
//// catch (DirectoryNotFoundException Ex)
//// {
//// file.WriteFile(DateTime.Now.ToShortDateString() + " " + Date
Time.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + Da
teTime.Now.Millisecond + "Cosmos folder is missing in the share: " + csvKey + En
vironment.NewLine);
//// }
//// catch (Exception Ex)
//// {
//// file.WriteFile(DateTime.Now.ToShortDateString() + " " + Date
Time.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + Da
teTime.Now.Millisecond + Ex.Message + Environment.NewLine);
//// }
//// finally
//// {
//// VerifyContentUsage();
//// }
////}
#endregion
#region ROLogDB Functionality
/// <summary>
/// Check Content Usage Click View Data
/// </summary>
/// <param name="strEnvironment">Environment name</param>
public void VerifyContentUsage(string strEnvironment)
{
string databaseName = "RelevanceOptimizationLog";
string tableName = "ContentUsage";
DataTable tableCount;
string query = "SELECT PageID FROM RelevanceOptimizationLog.ContentU
sage WHERE PageID=" + this.randomPageID;
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " + DateTim
e.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + DateT
ime.Now.Millisecond + "Started RoLogDB Functionality check for HOPS in " + strEn
vironment + Environment.NewLine);
try
{
tableCount = this.objAccess.GetData(query, databaseName, tableNa
me);
if (tableCount.Rows.Count > 0)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " +
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":"
+ DateTime.Now.Millisecond + "Data dumped into Relevance Optimization Log DB fo
r PageID: " + this.randomPageID + Environment.NewLine);
}
else
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " +
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":"
+ DateTime.Now.Millisecond + "No records found for the PageID: " + this.randomP
ageID + Environment.NewLine);
}
}
catch (SqlException ex)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " + Dat
eTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + D
ateTime.Now.Millisecond + ex.Message + Environment.NewLine);
}
catch (Exception ex)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " + Dat
eTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + D
ateTime.Now.Millisecond + ex.Message + Environment.NewLine);
}
finally
{
this.CheckOptimizedContent(strEnvironment);
}
}
#endregion
#region RODB Functionality
/// <summary>
/// Check Optimization Content
/// </summary>
/// <param name="strEnvironment">Environment name</param>
public void CheckOptimizedContent(string strEnvironment)
{
string databaseName = "RelevanceOptimization";
string tableName = "OptimizedContent";
DataTable datatableCount = new DataTable();
string query = "SELECT PageID FROM ContentUsage WHERE PageID=" + thi
s.randomPageID;
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " + DateTim
e.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + DateT
ime.Now.Millisecond + "Started RODB functionality check for HOPS service in " +
strEnvironment + Environment.NewLine);
try
{
datatableCount = this.objAccess.GetData(query, databaseName, tab
leName);
if (datatableCount.Rows.Count > 0)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " +
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":"
+ DateTime.Now.Millisecond + "Data dumped into Relevance Optimization Log DB fo
r a given PageID: " + this.randomPageID + Environment.NewLine);
}
else
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " +
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":"
+ DateTime.Now.Millisecond + "There are no records for a given PageID: " + this
.randomPageID + Environment.NewLine);
}
}
catch (SqlException ex)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " + Dat
eTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + D
ateTime.Now.Millisecond + ex.Message + Environment.NewLine);
}
catch (Exception ex)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " + Dat
eTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + D
ateTime.Now.Millisecond + ex.Message + Environment.NewLine);
}
finally
{
if (i == 0)
{
////TODO:Read from Globalconfig
////DCClickRequest(strEnvironment);
i++;
}
else
{
this.OFEGetData();
}
}
}
#endregion
#region OFE Functionality
/// <summary>
/// Get OFE Data by passing CPGID
/// </summary>
public void OFEGetData()
{
try
{
string ofeGetDataURL = string.Empty;
bool validURL = true;
bool blnresponse = true;
string cpgid = string.Empty;
HttpWebResponse webresponse = null;
ofeGetDataURL = "http://" + this.strOFEMachineName + "/OFE/Servi
ce.svc/GetData?CpgId=" + cpgid + "&pageid=30";
webresponse = this.objUtil.VerifyResponse(ofeGetDataURL, validUR
L, out blnresponse);
if (webresponse.ContentLength > -1)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " +
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":"
+ DateTime.Now.Millisecond + "OFE Get Data API is working fine " + Environment.
NewLine);
}
}
catch (Exception ex)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " + Dat
eTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + D
ateTime.Now.Millisecond + ex.Message + Environment.NewLine);
}
finally
{
if (i == 0)
{
this.OFEGetFeed();
i++;
}
}
}
/// <summary>
/// Get OFE Feed
/// </summary>
public void OFEGetFeed()
{
try
{
string ofeGetFeedURL = string.Empty;
bool validURL = false;
bool blnresponse = true;
HttpWebResponse webresponse = null;
this.randomPageID = this.RandomNumber(1, 100000);
ofeGetFeedURL = "http://" + this.strOFEMachineName + "/ofe/Servi
ce.svc/GetFeed?FeedUrl=http://" + this.strOFEMachineName + "/OFE/3_Feed.xmL&OptF
eedSchema=3_Feed&FeedHash=TryingMSNCP&UserGroup=A:default&PageId=" + this.random
PageID;
webresponse = this.objUtil.VerifyResponse(ofeGetFeedURL, validUR
L, out blnresponse);
if (webresponse.ContentLength > -1)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " +
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":"
+ DateTime.Now.Millisecond + "OFE Get Feed API is working fine " + Environment.
NewLine);
}
}
catch (Exception ex)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " + Dat
eTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + D
ateTime.Now.Millisecond + ex.Message + Environment.NewLine);
}
finally
{
this.VerifyActiveFeeds();
}
}
/// <summary>
/// Verification of Active Feeds
/// </summary>
public void VerifyActiveFeeds()
{
int contentFeedQueueCount = 0;
int contentFeedCount = 0;
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " + DateTim
e.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + DateT
ime.Now.Millisecond + "Started Verifying active feeds in RODB for HOPS service i
n " + Environment.NewLine);
try
{
contentFeedQueueCount = this.objAccess.GetCountForACondition(Dat
aAccess.HOPS_RoDBName, "ContentFeedQueue", this.randomPageID);
contentFeedCount = this.objAccess.GetCountForACondition(DataAcce
ss.HOPS_RoDBName, "ContentFeed", this.randomPageID);
if (contentFeedQueueCount != 0 && contentFeedCount != 0)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " +
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":"
+ DateTime.Now.Millisecond + "Active Feeds are present in Content Feed table in
" + Environment.NewLine);
}
else
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " +
DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":"
+ DateTime.Now.Millisecond + "Relevance Optimization DB don't have has the Rece
nt Optimization content. Number of Active Feeds in Content Feed: " + contentFeed
Count + "and Content Feed Queue table: " + contentFeedQueueCount + "do not match
in Environement: " + Environment.NewLine);
}
}
catch (SqlException ex)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " + Dat
eTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + D
ateTime.Now.Millisecond + ex.Message + Environment.NewLine);
}
catch (Exception ex)
{
this.file.WriteFile(DateTime.Now.ToShortDateString() + " " + Dat
eTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + D
ateTime.Now.Millisecond + ex.Message + Environment.NewLine);
}
}
#endregion
#region DC Functionality
/// <summary>
/// To Open a file
/// </summary>
/// <param name="environmentName">Environment Name</param>
/// <param name="componentName">Component Name</param>
public void VerifyHOPS(string environmentName, string componentName)
{
////bool isFileOpened = false;
////string fileName = string.Empty;
try
{
////fileName = file.GetFilePath();
////file.CreateFile(fileName);
////file.OpenFile(fileName);
ReportLogger.Log(string.Format("Checking HOPS DC Functionality i
n Environment {0}", environmentName));
this.randomPageID = this.RandomNumber(1, 100000);
this.DCRun(environmentName, componentName);
}
catch (Exception ex)
{
////file.WriteFile(DateTime.Now.ToShortDateString() + " " + Date
Time.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" + Da
teTime.Now.Millisecond + ex.Message + Environment.NewLine);
ReportLogger.Log(string.Format("Exception Occured while verifyin
g DC Functionality.Error Message:{0}", ex.Message));
}
////finally
////{
////}
}
/// <summary>
/// DC Service Check
/// </summary>
/// <param name="environmentName"> Environment Name </param>
/// <param name="componentName">Component Name</param>
private void DCRun(string environmentName, string componentName)
{
Dictionary<string, NameValueCollection> envDetails = GlobalConfigura
tion.Initialize(environmentName, componentName);
NameValueCollection datacollectorKeys = GlobalConfiguration.GetServe
rNames(Constants.DC, envDetails);
HttpStatusCode statusCode = 0;
try
{
foreach (string server in datacollectorKeys.AllKeys)
{
if (server.StartsWith(Constants.ServerName))
{
statusCode = HttpRequestGenerator.SendHttpWebRequest(str
ing.Format(Constants.BaseDCUrl, datacollectorKeys[server]));
if (statusCode != HttpStatusCode.NoContent)
{
ReportLogger.Log("HOPS Data Collection is Running!")
;
}
else
{
ReportLogger.Log("HOPS Data Collection is down");
}
}
break;
}
}
catch (Exception ex)
{
ReportLogger.Log(string.Format("Exception Occured while verifyin
g DC Functionaltiy.Error Message:{0}", ex.Message));
}
finally
{
this.DCPageRequest(environmentName, datacollectorKeys);
}
}
/// <summary>
/// Generating a Page ID Randomly
/// </summary>
/// <param name="min"> Minimum Value</param>
/// <param name="max">Maximum Value</param>
/// <returns>returns random number</returns>
private int RandomNumber(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}
/// <summary>
/// Gets the PageViewUrlWithDefaultParameters.
/// </summary>
/// <value>Gets the PageViewUrlWithDefaultParameters.</value>
private string PageViewUrlWithDefaultParameters
{
get
{
StringBuilder url = new StringBuilder();
url.Append(
string.Format(
"parsergroup={0}&obs={1}&user_id={2}&du={3}&pp=1&su={4}&ps=1
62&pi={5}&di=194&pn={6}&cm={7}&gt1={8}&Ce={9}&hl={10}&optkey={11}&gp={12}&fk={13
}&mk={14}&sip={5}&usergroup={16}&pageid={17}",
"hops",
"nhp_pv",
"09260acb1c404f398f42e8fa9a9712ca",
"http%3a%2f%2fg.msn.com%2f0AD00006%2f1519393.1%3fHCType%3d1%
26msim%3dBR1MSNWEBA13%26psim%3d33_Feed%26tsim%3d19%253a51%253a36%26hsim%3d4",
"http%3a%2f%2fbr1msnweba04%2fsite%2fSimRSS_BR1MSNWEBA13%2f33
_Feed.xml_HOPS",
"231",
"62",
"CM_HOPS",
"blankgt1",
"0",
"33_headline4+--+19%3a51%3a36",
"optKeyGrp2",
"P",
"B",
"en-us",
"127.0.0.1",
"P",
this.randomPageID));
return url.ToString();
}
}
/// <summary>
/// Gets the PageViewUrlWithDefaultParameters.
/// </summary>
/// <value>Gets the PageViewUrlWithDefaultParameters.</value>
private string ClickViewUrlWithDefaultParameters
{
get
{
StringBuilder url = new StringBuilder();
url.Append(
string.Format(
"parsergroup={0}&obs={1}&user_id={2}&du={3}&pp=1&su={4}&ps=1
62&pi={5}&di=194&pn={6}&cm={7}&gt1={8}&Ce={9}&hl={10}&optkey={11}&gp={12}&fk={13
}&mk={14}&sip={5}&usergroup={16}&pageid={17}",
"hops",
"msnhp_pv",
"09260acb1c404f398f42e8fa9a9712ca",
"http%3a%2f%2fg.msn.com%2f0AD00006%2f1519393.1%3fHCType%3d1%
26msim%3dBR1MSNWEBA13%26psim%3d33_Feed%26tsim%3d19%253a51%253a36%26hsim%3d4",
"http%3a%2f%2fbr1msnweba04%2fsite%2fSimRSS_BR1MSNWEBA13%2f33
_Feed.xml_HOPS",
"231",
"62",
"CM_HOPS",
"blankgt1",
"0",
"33_headline4+--+19%3a51%3a36",
"optKeyGrp2",
"P",
"B",
"en-us",
"127.0.0.1",
"P",
this.randomPageID));
return url.ToString();
}
}
/// <summary>
/// Verifys that DC should generate CSV file.
/// </summary>
/// <param name="url">DC url to generate csv file.</param>
/// <param name="cookieValue">Cookie value.</param>
/// <param name="csvFileShare">CSV File Share.</param>
/// <returns>Csv file created/not created status.</returns>
private bool IsDcGeneratingCsvFile(string url, string cookieValue, strin
g csvFileShare)
{
string[] filesBeforeRequest = HMToolUtilities.ComponentUtility.GetCs
vFiles(csvFileShare);
HttpRequestGenerator.SendHttpWebRequest(url, cookieValue);
HMToolUtilities.ComponentUtility.SleepBySeconds(3);
return HMToolUtilities.ComponentUtility.CheckBooleanWithSpinLock(
() => (HttpRequestGenerator.SendHttpWebRequest(url, cookieValue)
!= HttpStatusCode.NoContent && HMToolUtilities.ComponentUtility.GetCsvFiles(csv
FileShare).Length > filesBeforeRequest.Length),
true,
30,
300);
}
/// <summary>
/// Sends DC Page View Request
/// </summary>
/// <param name="strEnvironment">Environment Name</param>
/// <param name="datacollectorKeys">Gets the DC keys associated with Nam
e or index</param>
private void DCPageRequest(string strEnvironment, NameValueCollection da
tacollectorKeys)
{
string datacollectorServerName = string.Empty;
string csvFileShareLocation = string.Empty;
try
{
foreach (string server in datacollectorKeys.AllKeys)
{
if (server.StartsWith(Constants.ServerName))
{
datacollectorServerName = datacollectorKeys[server];
csvFileShareLocation = datacollectorKeys["CsvFileShare"]
;
string datacollectorURL = string.Format(Constants.BaseDC
Url, datacollectorServerName);
if (HttpRequestGenerator.SendHttpWebRequest(string.Forma
t("{0}?{1}", datacollectorURL, this.PageViewUrlWithDefaultParameters)) != HttpSt
atusCode.NoContent)
{
ReportLogger.Log(string.Format("DC Page View Request
Sent Successfully for the PageID:", this.randomPageID));
}
else
{
ReportLogger.Log("DC Page View Request Failed to sen
t Successfully");
}
}
}
}
catch (Exception ex)
{
ReportLogger.Log(string.Format("ErrorEventArgs while giving DC P
ageview Request in the server {0}.Error Message:{1}", datacollectorServerName, e
x.Message));
}
finally
{
this.VerifyCSVFileGeneration(strEnvironment, datacollectorServer
Name, csvFileShareLocation, this.PageViewUrlWithDefaultParameters);
}
}
/// <summary>
/// Sends DC Click View Request
/// </summary>
/// <param name="strEnvironment"> Environment Name</param>
/// <param name="datacollectorKeys">Gets the DC keys associated with Nam
e or index</param>
private void DCClickRequest(string strEnvironment, NameValueCollection d
atacollectorKeys)
{
string datacollectorServerName = string.Empty;
string csvFileShareLocation = string.Empty;
try
{
foreach (string server in datacollectorKeys.AllKeys)
{
if (server.StartsWith(Constants.ServerName))
{
datacollectorServerName = datacollectorKeys[server];
csvFileShareLocation = datacollectorKeys["CsvFileShare"]
;
string datacollectorURL = string.Format(Constants.BaseDC
Url, datacollectorServerName);
if (HttpRequestGenerator.SendHttpWebRequest(string.Forma
t("{0}?{1}", datacollectorURL, this.ClickViewUrlWithDefaultParameters)) != HttpS
tatusCode.NoContent)
{
ReportLogger.Log(string.Format("DC Click View Reques
t Sent Successfully for the PageID:", this.randomPageID));
}
else
{
ReportLogger.Log("DC Click View Request Failed to se
nt Successfully");
}
}
}
}
catch (Exception ex)
{
ReportLogger.Log(string.Format("ErrorEventArgs while giving DC C
lickview Request in the server {0}.Error Message:{1}", datacollectorServerName,
ex.Message));
}
finally
{
this.VerifyCSVFileGeneration(strEnvironment, datacollectorServer
Name, csvFileShareLocation, this.ClickViewUrlWithDefaultParameters);
}
}
/// <summary>
/// Verification of CSV File Genaration
/// </summary>
/// <param name="strEnvironment">Environment Name</param>
/// <param name="datacollectorServerName">DC Server Name</param>
/// <param name="csvFileShareLocation">CSV File Share location</param>
/// <param name="defaultParams">Default Parameters</param>
private void VerifyCSVFileGeneration(string strEnvironment, string datac
ollectorServerName, string csvFileShareLocation, string defaultParams)
{
FileStream csvFileStream = null;
StreamReader csvFileReader = null;
try
{
string datacollectorURL = string.Format(Constants.BaseDCUrl, dat
acollectorServerName);
if (this.IsDcGeneratingCsvFile(string.Format("{0}?{1}", datacoll
ectorURL, defaultParams), null, csvFileShareLocation) == true)
{
csvFileStream = new FileStream(HMToolUtilities.ComponentUtil
ity.GetCsvFiles(csvFileShareLocation)[0], FileMode.Open, FileAccess.Read);
csvFileReader = new StreamReader(csvFileStream);
char[] buffer = new char[11];
csvFileReader.Read(buffer, 0, 11);
string csvDate = new string(buffer);
DateTime dt = DateTime.Now;
string[] form = dt.Date.GetDateTimeFormats();
string currentDate = "\"";
currentDate += form[5].ToString();
if (string.Compare(currentDate, csvDate) == 0)
{
ReportLogger.Log(string.Format("AggregationDate in csv f
ile is same as today's date.Current Date: {0}.Aggregation DateTime:{1}", current
Date, csvDate));
}
else
{
ReportLogger.Log(string.Format("AggregationDate in csv f
ile is not same as today's date.Current Date: {0}.Aggregation DateTime:{1}", cur
rentDate, csvDate));
}
}
}
catch (Exception ex)
{
ReportLogger.Log(String.Format("Error Occured while reading csv
file.Error Message {0}", ex.Message));
}
finally
{
////CheckCOSMOSConnection();
csvFileStream.Close();
csvFileReader.Close();
this.VerifyContentUsage(strEnvironment);
}
#endregion
////#region MPS Functionality
//// MPS Rendering Call
////public void MPSServiceCall()
////{
// try
// {
// string mpsURL = string.Empty;
// bool validURL = true;
// bool blnresponse = true;
// mpsRequest = false;
// HttpWebResponse webresponse = null;
// randomPageID = RandomNumber(1, 100000);
// mpsURL = "http://" + GetMPSMachineName() + "/ModulePresent
ation/TestOFE15.aspx?FeedUrl=http://" + GetSubComponent() + "/OFE/3_Feed.xmL&Fee
dHash=FromCP&UserGroup=:1&PageId=" + randomPageID;
// webresponse = objUtil.VerifyResponse(mpsURL, validURL, out
blnresponse);
// if (webresponse.ContentLength > -1)
// {
// // Verification Active Feeds for MPS
// //int contentFeedQueueCount = 0;
// //int contentFeedCount = 0;
// //contentFeedQueueCount = objUtil.GetRowsCountOfTable(
);
// //contentFeedCount = objUtil.GetRowsCountOfTable();
// //if (contentFeedQueueCount != null && contentFeedCoun
t != null)
// file.WriteFile(DateTime.Now.ToShortDateString() + " "
+ DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":
" + DateTime.Now.Millisecond + "MPS Working fine" + Environment.NewLine);
// }
// }
// catch (Exception ex)
// {
// file.WriteFile(DateTime.Now.ToShortDateString() + " " + Da
teTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + ":" +
DateTime.Now.Millisecond + ex.Message + Environment.NewLine);
// }
// finally
// {
// VerifyActiveFeeds();
// }
////}
////#endregion
}
}
}

Anda mungkin juga menyukai