static void Main(string[] args) { DateTime sDate = DateTime.Now; //TODO:Add/Remove test suites var handle = GetConsoleWindow(); // Hide ShowWindow(handle, SW_HIDE); // Show // ShowWindow(handle, SW_SHOW); //TODO:Single Execution Rpt. _writer = new LogWriter(); _Assert = new AssertClass(_writer); _writer.CreateXmlFile(LogSummaryFile, "Summary"); _writer.CreateXmlFile(LogDetailedFile, "Detailed"); _writer.LoadLogWriter(LogSummaryFile, LogDetailedFile); root = _writer.create_node("TestCase"); String getDLLPath = ConfigurationManager.AppSettings["ServiceDLLPath"]; List <string> className = new List <string>(); className.Add("FolderServiceTests"); className.Add("UserProgramWebServiceTest"); //className.Add("AccountServiceTestNew"); className.Add("CountryLookupServiceTest"); className.Add("LookupServiceTests"); className.Add("EmailServiceTests"); //className.Add("PersonalAddressBookWebServiceTest"); className.Add("DomainServiceTest"); className.Add("ActivityDataCaptureServiceTest"); className.Add("ConversationWebServiceTest"); //className.Add("ResourceWebServiceTest"); //className.Add("AuthenticationWebServiceTests"); //className.Add("UserProfileServiceTestNew"); //className.Add("RegistrationServiceTests"); ////className.Add("SubscriptionWebServiceTest"); ////className.Add("EventWebServiceTest"); ///throwing exception ////className.Add("LearningWebServiceTest"); ///throwing exception List <string> ExcludeclassName = new List <string>(); ExcludeclassName.Add("MyClassInitialize"); ExcludeclassName.Add("MyClassCleanup"); ExcludeclassName.Add("DataInitialize"); Assembly a = Assembly.LoadFrom(getDLLPath); Type[] tArray = a.GetTypes(); Type type = null; Type myType = null;// typeof(AccountServiceTestNew); Type[] types = new Type[5]; types[0] = typeof(string); types[1] = typeof(string); types[2] = typeof(LogWriter); types[3] = typeof(XElement); types[4] = typeof(AssertClass); object[] parm = new object[] { LogSummaryFile, LogDetailedFile, _writer, root, _Assert }; foreach (Type myClass in tArray) { if (className.Contains(myClass.Name)) { myType = CommonMethods.Convert(myClass); MethodInfo[] methods = myType.GetMethods(); object obj = null; ConstructorInfo ci = myType.GetConstructor(types); //Invoke the method //returnObject = mi.Invoke(responder, parameterForTheMethod); if (ci != null) { object instance = ci.Invoke(parm); foreach (MethodInfo method in methods) { if (method.ReturnType == typeof(void)) { bool isFound = false; if (method.GetParameters().Count() == 0) { for (int i = 0; i < ExcludeclassName.Count; i++) { if (method.Name.Contains(ExcludeclassName[i])) { isFound = true; } } if (method.Name != myClass.Name && isFound == false) { MethodInfo methodInfo = myType.GetMethod(method.Name.ToString()); methodInfo.Invoke(instance, null); } } } } } #region "For default const" //object obj = Activator.CreateInstance(myClass); //if (obj != null) //{ // foreach (MethodInfo method in methods) // { // if (method.ReturnType == typeof(void)) // { // bool isFound = false; // if (method.GetParameters().Count() == 0) // { // for (int i = 0; i < ExcludeclassName.Count; i++) // { // if (method.Name.Contains(ExcludeclassName[i])) // { // isFound = true; // } // } // //if (method.Name == myClass.Name && isFound == false) // //{ // // method.Invoke(obj, parm); // //} // if (method.Name != myClass.Name && isFound == false) // { // method.Invoke(obj, null); // } // } // } // } //} #endregion } } DateTime eDate = DateTime.Now; //TODO:Email Body string Str = "<html>"; Str += "<head>"; Str += "<title>SBWS Automation Test Report</title>"; Str += "</head>"; Str += "<body>"; Str += "<table border=0 width=95% cellpadding=0 cellspacing=0>"; Str += "<tr>"; Str += "<td>" + "Hi Team,<br/><br/>Kindly Find the below attached SBWS report. <br/> Thanks & Regards <br/><br/> SBWS Automation Team" + "</td>"; Str += "</tr>"; Str += "<tr>"; Str += "<td>" + "Start Time:" + sDate + " End Time:" + eDate + "</td>"; Str += "</tr>"; Str += "</table>"; Str += "</body>"; Str += "</html>"; StringBuilder addRecipent = new StringBuilder(); addRecipent.Append("[email protected],"); addRecipent.Append("[email protected],"); addRecipent.Append("[email protected],"); addRecipent.Append("*****@*****.**"); //TODO:Call the application to export the XML to EXCEL //string getVars = "?downloadFile=" + LogSummaryFile.ToString().Remove(0,3); //WebRequest request = WebRequest.Create(string.Format("http://localhost:2395/Default.aspx{0}", getVars)); // Return the response. //WebResponse myResponse = request.GetResponse(); //BinaryFormatter bf = new BinaryFormatter(); //MemoryStream ms = new MemoryStream(); //byte[] bt = ms.ToArray(); //FileStream fs = new FileStream("c:\\abcd.xls", FileMode.Create); //BinaryWriter bwe = new BinaryWriter(myResponse.GetResponseStream()); //bwe.Write(bt); //bwe.Close(); //fs.Close(); //myResponse.Close(); //WebRequest request = WebRequest.Create("http://localhost:2395/Default.aspx?downloadFile=" + @LogSummaryFile); //_Default objWebApp = new _Default(); //objWebApp.DisplayReports(LogSummaryFile); //objWebApp.exportReport(".xls", "application/vnd.xls", LogSummaryFile); // ConvertXMLtoEXCEL(LogSummaryFile); //Send report try { //SendEmail(addRecipent.ToString(), "SBWS Daily Execution Test Report", Str, LogSummaryFile, @"C:\SBWS-Automation_CQ\Summary.xsl"); } catch (Exception ex) { //Show error on Console App. ShowWindow(handle, SW_SHOW); Console.WriteLine("Error:" + ex.Message); Console.ReadLine(); } }