public bool Enrolluser(Hashtable htblTestData) { clsGlobalVariable.strExceptionReport = string.Empty; string statusCode = string.Empty; string result = string.Empty; clsGeneric oGeneric = new clsGeneric(); string URI = string.Empty; List <string> lCourseId = new List <string>(); bool _Flag = false; string _UserID = string.Empty; try { clsPage oPage = new clsPage(iWebdriver); _orgID = oPage.GetOrganizationID(); clsAPI.orgID = _orgID; lCourseId = oPage.GetCourseId(htblTestData["CourseName"].ToString()); Users oUser = new Users(); GetAPICredentials oGetAPICredentials = new GetAPICredentials(); oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.orgCredential.Replace("$", _orgID), oUser, "H2", "", ""); var orgCredential = JsonConvert.DeserializeObject <GetAPICredentials>(result); Crypto3DES _des = new Crypto3DES(ApplicationSettings.EComModuleEncKey()); _ecomTransactionKey = _des.Decrypt3DES(orgCredential.TransactionKey); _ecomLoginKey = _des.Decrypt3DES(orgCredential.LoginID); oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.user.Replace("{orgid}", _orgID), oUser, "H1", _ecomLoginKey, _ecomTransactionKey); var oUserData = JsonConvert.DeserializeObject <List <Users> >(result); for (int iUser = 0; iUser < oUserData.Count; iUser++) { if (oUserData[iUser].Profile.F015.ToString() == htblTestData["UserEmail"].ToString().Trim()) { _UserID = oUserData[iUser].ID; break; } } oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetSessionID.Replace("{orgid}", _orgID).Replace("{CourseID}", lCourseId[0].ToString().Trim()), oUser, "H1", _ecomLoginKey, _ecomTransactionKey); var oSessionData = JsonConvert.DeserializeObject <List <clsAPISession> >(result); if (result == "") { return(false); } _SessionID = oSessionData[0].SessionID; UserEnrollment oUserEnrollment = new ILMS.UserEnrollment(); oUserEnrollment.userid = _UserID; oGeneric.GetApiResponseCodeData(out statusCode, out result, "POST", ApplicationSettings.APIURI() + clsAPI.SessionEnrollment.Replace("{orgid}", _orgID).Replace("{CourseID}", lCourseId[0].ToString().Trim()).Replace("{SessionID}", _SessionID), oUserEnrollment, "H1", _ecomLoginKey, _ecomTransactionKey); Thread.Sleep(clsGlobalVariable.iWaitHigh); if (htblTestData["TestCaseType"].ToString().ToUpper() == "NEGATIVE") { if (result.ToUpper().Contains("!DOCTYPE")) { clsGlobalVariable.strExceptionReport = "Resource not found"; return(true); } if (result.Contains("Invalid URI")) { return(true); } var oError = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result); SuperAdminCoursePushDownErrorCode oErrorCode = new SuperAdminCoursePushDownErrorCode(); foreach (string strErrorCode in oErrorCode.coursePushDownErrorCode) { if (strErrorCode == oError[0].ErrorCode) { _Flag = true; } } if (_Flag == true) { return(true); } else { clsGlobalVariable.strExceptionReport = "Negative Case Failed!"; return(false); } } do { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.SessionEnrollment.Replace("{orgid}", _orgID).Replace("{CourseID}", lCourseId[0].ToString().Trim()).Replace("{SessionID}", _SessionID), oUserEnrollment, "H1", _ecomLoginKey, _ecomTransactionKey); } while (result == ""); var oCourseData = JsonConvert.DeserializeObject <List <SessionEnrollment> >(result); for (int iUser = 0; iUser < oCourseData.Count; iUser++) { if (oCourseData[iUser].User.Profile_Basic.F015.ToString() == htblTestData["UserEmail"].ToString().Trim()) { _UserID = oCourseData[iUser].User.ID; _Flag = true; break; } else { _Flag = false; } } } catch (Exception e) { clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name); return(false); } return(_Flag); }
public bool AddRegion(Hashtable hTable) { clsGlobalVariable.strExceptionReport = string.Empty; string statusCode = string.Empty; string result = string.Empty; string GroupResult = string.Empty; clsGeneric oGeneric = new clsGeneric(); string URI = string.Empty; string strGroupID = string.Empty; List <string> lCourseId = new List <string>(); bool _Flag = false; string _UserID = string.Empty; try { clsPage oPage = new clsPage(iWebdriver); clsRegionApi oRegion = new clsRegionApi(); _orgID = oPage.GetOrganizationID(); clsAPI.orgID = _orgID; oRegion.name = hTable["Name"].ToString(); GetAPICredentials oGetAPICredentials = new GetAPICredentials(); oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.orgCredential.Replace("$", _orgID), oGetAPICredentials, "H2", "", ""); var orgCredential = JsonConvert.DeserializeObject <GetAPICredentials>(result); Crypto3DES _des = new Crypto3DES(ApplicationSettings.EComModuleEncKey()); _ecomTransactionKey = _des.Decrypt3DES(orgCredential.TransactionKey); _ecomLoginKey = _des.Decrypt3DES(orgCredential.LoginID); oGeneric.GetApiResponseCodeData(out statusCode, out result, "POST", ApplicationSettings.APIURI() + clsAPI.Region.Replace("{orgid}", _orgID), oRegion, "H1", _ecomLoginKey, _ecomTransactionKey); Thread.Sleep(clsGlobalVariable.iWaitMedium); if (hTable["TestCaseType"].ToString().ToUpper() == "POSITIVE") { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.Region.Replace("{orgid}", _orgID), oRegion, "H1", _ecomLoginKey, _ecomTransactionKey); var RegionData = JsonConvert.DeserializeObject <List <GetRegion> >(result); _Flag = RegionData.Any(cus => cus.Name == hTable["Name"].ToString()); return(_Flag); } else { if (result.Contains("ErrorCode") || result.Contains("Invalid URI.")) { if (result.Contains("Invalid URI.")) { return(true); } SuperAdminCoursePushDownErrorCode oError = new SuperAdminCoursePushDownErrorCode(); var error = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result); foreach (string errorcode in oError.coursePushDownErrorCode) { for (int i = 0; i < error.Count; i++) { if (error[i].ErrorCode == errorcode) { _Flag = true; } else { _Flag = false; } } if (_Flag == true) { break; } } return(_Flag); } } } catch (Exception e) { clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name); return(false); } return(_Flag); }
public bool Enrolluser(object[] lStrValue) { clsGlobalVariable.strExceptionReport = string.Empty; string statusCode = string.Empty; string result = string.Empty; clsGeneric oGeneric = new clsGeneric(); string URI = string.Empty; Hashtable htblTestData = new Hashtable(); htblTestData = oGeneric.GetTestData(lStrValue); List <string> lCourseId = new List <string>(); bool _Flag = false; string _UserID = string.Empty; try { clsPage oPage = new clsPage(iWebdriver); _orgID = oPage.GetOrganizationID(); clsAPI.orgID = _orgID; lCourseId = oPage.GetCourseId(htblTestData["CourseName"].ToString()); Users oUser = new Users(); GetAPICredentials oGetAPICredentials = new GetAPICredentials(); oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.orgCredential.Replace("$", _orgID), oUser, "H2", "", ""); var orgCredential = JsonConvert.DeserializeObject <GetAPICredentials>(result); Crypto3DES _des = new Crypto3DES(ApplicationSettings.EComModuleEncKey()); _ecomTransactionKey = _des.Decrypt3DES(orgCredential.TransactionKey); _ecomLoginKey = _des.Decrypt3DES(orgCredential.LoginID); if (htblTestData["Status"].ToString().ToUpper().Contains("INACTIVE")) { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.user.Replace("{orgid}", _orgID) + "?F015=" + htblTestData["UserEmail"].ToString() + "*&userstatus=inactive", oUser, "H1", _ecomLoginKey, _ecomTransactionKey); } else if (htblTestData["Status"].ToString().ToUpper().Contains("DELETED")) { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.user.Replace("{orgid}", _orgID) + "?F015=" + htblTestData["UserEmail"].ToString() + "*&userstatus=Deleted", oUser, "H1", _ecomLoginKey, _ecomTransactionKey); } else { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.user.Replace("{orgid}", _orgID), oUser, "H1", _ecomLoginKey, _ecomTransactionKey); } var oUserData = JsonConvert.DeserializeObject <List <Users> >(result); for (int iUser = 0; iUser < oUserData.Count; iUser++) { if (oUserData[iUser].Profile.F015.ToString() == htblTestData["UserEmail"].ToString().Trim()) { _UserID = oUserData[iUser].ID; break; } } UserEnrollment oUserEnrollment = new ILMS.UserEnrollment(); oUserEnrollment.userid = _UserID; oGeneric.GetApiResponseCodeData(out statusCode, out result, "POST", ApplicationSettings.APIURI() + clsAPI.CourseEnrollment.Replace("{orgid}", _orgID).Replace("{CourseID}", lCourseId[0].ToString().Trim()), oUserEnrollment, "H1", _ecomLoginKey, _ecomTransactionKey); Thread.Sleep(clsGlobalVariable.iWaitHigh); if (htblTestData["TestCaseType"].ToString().ToUpper() == "NEGATIVE") { if (result.ToUpper().Contains("!DOCTYPE")) { clsGlobalVariable.strExceptionReport = "Resource not found"; return(true); } var oError = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result); SuperAdminCoursePushDownErrorCode oErrorCode = new SuperAdminCoursePushDownErrorCode(); foreach (string strErrorCode in oErrorCode.coursePushDownErrorCode) { if (strErrorCode == oError[0].ErrorCode) { _Flag = true; } } if (_Flag == true) { return(true); } else { clsGlobalVariable.strExceptionReport = "Negative Case Failed!"; return(false); } } do { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.CourseEnrollment.Replace("{orgid}", _orgID).Replace("{CourseID}", lCourseId[0].ToString().Trim()), oUserEnrollment, "H1", _ecomLoginKey, _ecomTransactionKey); } while (result == ""); if (htblTestData["Status"].ToString().ToUpper() == "INACTIVE") { do { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetTranscript.Replace("{orgid}", _orgID).Replace("{UserID}", _UserID.ToString().Trim()), oUserEnrollment, "H1", _ecomLoginKey, _ecomTransactionKey); } while (result == ""); var oTranscriptData = JsonConvert.DeserializeObject <List <clsAPITranscript> >(result); for (int icount = 0; icount < oTranscriptData.Count; icount++) { if (oTranscriptData[icount].CourseName.ToString().ToUpper().Equals(htblTestData["CourseName"].ToString().ToUpper())) { return(true); } } return(false); } var oCourseData = JsonConvert.DeserializeObject <List <CourseData> >(result); for (int iUser = 0; iUser < oCourseData.Count; iUser++) { if (oCourseData[iUser].User.Profile_Basic.F015.ToString() == htblTestData["UserEmail"].ToString().Trim()) { _UserID = oUserData[iUser].ID; _Flag = true; break; } else { _Flag = false; } } try { if (htblTestData["Status"].ToString().ToUpper() == "Deleted".ToUpper()) { if (_Flag == true) { return(true); } else { return(false); } } } catch { } if (_Flag == true) { iWebdriver.Navigate().GoToUrl(oPage.SetUrl(htblTestData["url"].ToString())); clsGlobalVariable.strExceptionReport = string.Empty; string tag = ApplicationSettings.ElementByPath(); object[] objparam = new object[] { ApplicationSettings.EleUserName(), ApplicationSettings.ElePassword(), ApplicationSettings.EleLogin() }; System.Threading.Thread.Sleep(clsGlobalVariable.iWaitMedium); if (iWebdriver.GetType().Name.Contains("InternetExplorer") && clsGlobalVariable.IEFlag == true) { iWebdriver.Navigate().GoToUrl("javascript:document.getElementById('overridelink').click()"); clsGlobalVariable.IEFlag = false; } try { System.Threading.Thread.Sleep(clsGlobalVariable.iWaitHigh); iWebdriver.FindElement((By)oGeneric.InvokeMethodwith_Param(tag, new object[] { objparam[0].ToString() })).SendKeys(htblTestData["UserEmail"].ToString()); iWebdriver.FindElement((By)oGeneric.InvokeMethodwith_Param(tag, new object[] { objparam[1].ToString() })).SendKeys(htblTestData["Password"].ToString()); iWebdriver.FindElement((By)oGeneric.InvokeMethodwith_Param(tag, new object[] { objparam[2].ToString() })).Click(); iWebdriver.SwitchTo().DefaultContent(); iWebdriver.SwitchTo().Frame(clsPageObject.frmLCLeftFrame); iWebdriver.SwitchTo().Frame(clsPageObject.frmLCRightFrameFinal); if (iWebdriver.FindElement(By.XPath(clsPageObject.scormCourseName.Replace("$", htblTestData["CourseName"].ToString()))).Displayed) { return(true); } else { clsGlobalVariable.strExceptionReport = "User is not enrolled in " + htblTestData["CourseName"].ToString(); return(false); } } catch (Exception ex) { clsGlobalVariable.strExceptionReport = "User is not enrolled in " + htblTestData["CourseName"].ToString(); return(false); } } else { return(false); } } catch (Exception ex) { } return(_Flag); }
public bool Enrolluser(object[] lStrValue) { clsGlobalVariable.strExceptionReport = string.Empty; string statusCode = string.Empty; string result = string.Empty; clsGeneric oGeneric = new clsGeneric(); string URI = string.Empty; Hashtable htblTestData = new Hashtable(); htblTestData = oGeneric.GetTestData(lStrValue); string lCourseId = string.Empty; bool _Flag = false; string _UserID = string.Empty; try { clsPage oPage = new clsPage(iWebdriver); _orgID = oPage.GetOrganizationID(); clsAPI.orgID = _orgID; lCourseId = oPage.GetCurriculumId(htblTestData["CurriculumName"].ToString()); Users oUser = new Users(); GetAPICredentials oGetAPICredentials = new GetAPICredentials(); oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.orgCredential.Replace("$", _orgID), oUser, "H2", "", ""); var orgCredential = JsonConvert.DeserializeObject <GetAPICredentials>(result); Crypto3DES _des = new Crypto3DES(ApplicationSettings.EComModuleEncKey()); _ecomTransactionKey = _des.Decrypt3DES(orgCredential.TransactionKey); _ecomLoginKey = _des.Decrypt3DES(orgCredential.LoginID); if (htblTestData["Status"].ToString().ToUpper().Contains("INACTIVE")) { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.user.Replace("{orgid}", _orgID) + "?F015=" + htblTestData["UserEmail"].ToString() + "*&userstatus=inactive", oUser, "H1", _ecomLoginKey, _ecomTransactionKey); } else if (htblTestData["Status"].ToString().ToUpper().Contains("DELETED")) { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.user.Replace("{orgid}", _orgID) + "?F015=" + htblTestData["UserEmail"].ToString() + "*&userstatus=Deleted", oUser, "H1", _ecomLoginKey, _ecomTransactionKey); } else { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.user.Replace("{orgid}", _orgID), oUser, "H1", _ecomLoginKey, _ecomTransactionKey); } var oUserData = JsonConvert.DeserializeObject <List <Users> >(result); for (int iUser = 0; iUser < oUserData.Count; iUser++) { if (oUserData[iUser].Profile.F015.ToString() == htblTestData["UserEmail"].ToString().Trim()) { _UserID = oUserData[iUser].ID; break; } } UserEnrollment oUserEnrollment = new ILMS.UserEnrollment(); oUserEnrollment.userid = _UserID; oGeneric.GetApiResponseCodeData(out statusCode, out result, "POST", ApplicationSettings.APIURI() + clsAPI.CurriculumEnrollment.Replace("{orgid}", _orgID).Replace("{CourseID}", lCourseId.ToString()), oUserEnrollment, "H1", _ecomLoginKey, _ecomTransactionKey); Thread.Sleep(clsGlobalVariable.iWaitHigh); if (htblTestData["TestCaseType"].ToString().ToUpper() == "NEGATIVE") { if (result.ToUpper().Contains("!DOCTYPE")) { clsGlobalVariable.strExceptionReport = "Resource not found"; return(true); } var oError = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result); SuperAdminCoursePushDownErrorCode oErrorCode = new SuperAdminCoursePushDownErrorCode(); foreach (string strErrorCode in oErrorCode.coursePushDownErrorCode) { if (strErrorCode == oError[0].ErrorCode) { _Flag = true; } } if (_Flag == true) { return(true); } else { clsGlobalVariable.strExceptionReport = "Negative Case Failed!"; return(false); } } try { if (htblTestData["Status"].ToString().ToUpper() == "Deleted".ToUpper()) { if (_Flag == true) { return(true); } else { return(false); } } } catch { } do { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.CurriculumEnrollment.Replace("{orgid}", _orgID).Replace("{CourseID}", lCourseId.ToString().Trim()), oUserEnrollment, "H1", _ecomLoginKey, _ecomTransactionKey); } while (result == ""); if (htblTestData["Status"].ToString().ToUpper() == "INACTIVE") { do { oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetTranscript.Replace("{orgid}", _orgID).Replace("{UserID}", _UserID.ToString().Trim()), oUserEnrollment, "H1", _ecomLoginKey, _ecomTransactionKey); } while (result == ""); var oTranscriptData = JsonConvert.DeserializeObject <List <clsAPITranscript> >(result); for (int icount = 0; icount < oTranscriptData.Count; icount++) { if (oTranscriptData[icount].CourseName.ToString().ToUpper().Equals(htblTestData["CurriculumName"].ToString().ToUpper())) { return(true); } else { return(false); } } } var oCourseData = JsonConvert.DeserializeObject <List <CourseData> >(result); for (int iUser = 0; iUser < oCourseData.Count; iUser++) { if (oCourseData[iUser].User.Profile_Basic.F015.ToString() == htblTestData["UserEmail"].ToString().Trim()) { _UserID = oUserData[iUser].ID; _Flag = true; break; } else { _Flag = false; } } if (_Flag == true) { return(true); } else { return(false); } } catch (Exception ex) { clsGlobalVariable.strExceptionReport = "User not enrolled in curriculum."; return(false); } }
public bool APICreateOrganization(object[] lStrvalue) { string header = string.Empty; string statusCode = string.Empty; string result = string.Empty; clsGeneric oGeneric = new clsGeneric(); string URI = string.Empty; Hashtable htblTestData = new Hashtable(); htblTestData = oGeneric.GetTestData(lStrvalue); bool _Flag = false; CreateOrganization oCreateOrganization = new CreateOrganization(); CreateOrganizationUserData oCreateOrganizationUserData = new CreateOrganizationUserData(); try { oCreateOrganization.Name = htblTestData["OrganizationName"].ToString().Trim(); oCreateOrganization.FolderName = htblTestData["FolderName"].ToString().Trim(); oCreateOrganizationUserData.F001 = htblTestData["UserFirstName"].ToString().Trim(); oCreateOrganizationUserData.F002 = htblTestData["UserLastName"].ToString().Trim(); oCreateOrganizationUserData.F003 = htblTestData["UserMiddleName"].ToString().Trim(); oCreateOrganizationUserData.F008 = htblTestData["Address1"].ToString().Trim(); oCreateOrganizationUserData.F009 = htblTestData["Address2"].ToString().Trim(); oCreateOrganizationUserData.F010 = htblTestData["City"].ToString().Trim(); oCreateOrganizationUserData.F011 = htblTestData["Country"].ToString().Trim(); oCreateOrganizationUserData.F012 = htblTestData["State"].ToString().Trim(); oCreateOrganizationUserData.F013 = htblTestData["Region"].ToString().Trim(); oCreateOrganizationUserData.F014 = htblTestData["ZipCode"].ToString().Trim(); oCreateOrganizationUserData.F015 = htblTestData["EmailID"].ToString().Trim(); oCreateOrganizationUserData.F016 = htblTestData["Password"].ToString().Trim(); oCreateOrganizationUserData.F017 = htblTestData["Phone"].ToString().Trim(); oCreateOrganizationUserData.F018 = htblTestData["Fax"].ToString().Trim(); oCreateOrganizationUserData.F023 = htblTestData["TimeZone"].ToString().Trim(); oCreateOrganization.OrganizationAdmin = oCreateOrganizationUserData; oGeneric.GetApiResponseCodeData(out statusCode, out result, htblTestData["MethodType"].ToString().Trim(), clsAPI.apiURI + htblTestData["URI"].ToString().Trim(), oCreateOrganization, htblTestData["HeaderType"].ToString().Trim(), "", ""); if (htblTestData["TestCaseType"].ToString().ToUpper() == "POSITIVE") { if (result.ToUpper().Contains("!DOCTYPE")) { clsGlobalVariable.strExceptionReport = "Resource not found"; return(true); } if (statusCode.Contains("20")) { var oResult = JsonConvert.DeserializeObject <CreateOrganizationUserDataOutput>(result); if (oResult.OrganizationName == htblTestData["OrganizationName"].ToString().Trim()) { return(true); } else { clsGlobalVariable.strExceptionReport = "Organization Not Found"; return(false); } } } else if (htblTestData["TestCaseType"].ToString().ToUpper() == "NEGATIVE") { if (result.ToUpper().Contains("!DOCTYPE")) { return(true); } if (statusCode.Contains("40") || statusCode.Contains("50")) { if (statusCode.Contains("404") || statusCode.Contains("500") || statusCode.Contains("405")) { return(true); } var oError = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result); SuperAdminCoursePushDownErrorCode oErrorCode = new SuperAdminCoursePushDownErrorCode(); foreach (string strErrorCode in oErrorCode.coursePushDownErrorCode) { for (int iError = 0; iError < oError.Count; iError++) { if (strErrorCode == oError[iError].ErrorCode) { _Flag = true; } } } if (_Flag == true) { return(true); } else { return(false); } } else { clsGlobalVariable.strExceptionReport = "Resource or URI Wrong!"; return(false); } } return(true); } catch (Exception e) { clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name); return(false); } }
/// <summary> /// Function to create organization ,Copy super admin course to created org and create ecom manager /// </summary> /// <param name="lStrvalue">XML Parameter</param> /// <returns></returns> public bool APICreateOrganizationCopyCourse(object[] lStrvalue) { clsGlobalVariable.strExceptionReport = string.Empty; string statusCode = string.Empty; string result = string.Empty; clsGeneric oGeneric = new clsGeneric(); string URI = string.Empty; Hashtable htblTestData = new Hashtable(); htblTestData = oGeneric.GetTestData(lStrvalue); bool _Flag = false; clsCoursePushDown clData = new clsCoursePushDown(); Organization organization = new Organization(); organization.Name = htblTestData["OrganizationName"].ToString(); User user = new User(); user.F001 = htblTestData["UserFirstName"].ToString(); user.F003 = htblTestData["UserLastName"].ToString(); user.F015 = htblTestData["UserEmail"].ToString(); user.F023 = htblTestData["TimeZone"].ToString(); user.F006 = htblTestData["Language"].ToString(); List <SuperAdminCourseRecords> lstRecords = new List <SuperAdminCourseRecords>(); string[] strCourses = htblTestData["SuperAdminCourseId"].ToString().Split(','); foreach (string strCourseID in strCourses) { SuperAdminCourseRecords course = new SuperAdminCourseRecords(); course.NumberOfSeats = htblTestData["Seats"].ToString(); course.SuperAdminCourseID = string.Empty; course.SuperAdminCourseID = strCourseID; lstRecords.Add(course); } clData.Organization = organization; clData.User = user; clData.SuperAdminCourseRecords = lstRecords; clData.OrderID = htblTestData["OrderID"].ToString(); clData.PurchaseDate = htblTestData["PurchaseDate"].ToString(); try { oGeneric.GetApiResponseCodeData(out statusCode, out result, htblTestData["MethodType"].ToString(), ApplicationSettings.APIURI() + htblTestData["URI"].ToString(), clData, htblTestData["HeaderType"].ToString(), "", ""); if (htblTestData["TestCaseType"].ToString().ToUpper() == "POSITIVE") { if (result.ToUpper().Contains("!DOCTYPE")) { clsGlobalVariable.strExceptionReport = "Resource not found"; return(true); } if (statusCode.Contains("201")) { RequestID oRequest = JsonConvert.DeserializeObject <RequestID>(result); URI = ApplicationSettings.APIURI() + htblTestData["URI"].ToString() + "/" + oRequest.requestID.ToString(); result = string.Empty; // oGeneric.GetApiResponseCodeData(out statusCode, out result, "Get", URI, clData, htblTestData["HeaderType"].ToString(), "", ""); Thread.Sleep(20000); AccountRequests oRequestData; do { Thread.Sleep(10000); oGeneric.GetApiResponseCodeData(out statusCode, out result, "Get", URI, clData, htblTestData["HeaderType"].ToString(), "", ""); Application.DoEvents(); oRequestData = JsonConvert.DeserializeObject <AccountRequests>(result); } while (oRequestData.NewlyCreatedOrganizaitonInformation.OrganizationID == "0"); int courseCounter = 0; clsAPI.orgID = oRequestData.NewlyCreatedOrganizaitonInformation.OrganizationID; clsAPI.userid = oRequestData.NewlyCreatedeComMgrInformation.UserID; foreach (string strCourseID in strCourses) { if (strCourseID == oRequestData.CourseResults[courseCounter].SuperAdminCourseID.ToString()) { courseCounter++; _Flag = true; } else { courseCounter++; _Flag = false; } } if (_Flag == true) { return(true); } else { return(false); } } else { var oError = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result); clsGlobalVariable.strExceptionReport = "Invalid URI: Error Code: " + oError[0].ErrorCode + "\n Error Description: " + oError[0].ErrorMessage; return(false); } } else if (htblTestData["TestCaseType"].ToString().ToUpper() == "NEGATIVE") { if (result.ToUpper().Contains("!DOCTYPE")) { clsGlobalVariable.strExceptionReport = "Resource not found"; return(true); } if (statusCode.Contains("4") || statusCode.Contains("5")) { if (statusCode.Contains("404") || statusCode.Contains("500") || statusCode.Contains("405")) { clsGlobalVariable.strExceptionReport = "Resource not found"; return(true); } var oError = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result); SuperAdminCoursePushDownErrorCode oErrorCode = new SuperAdminCoursePushDownErrorCode(); foreach (string strErrorCode in oErrorCode.coursePushDownErrorCode) { if (strErrorCode == oError[0].ErrorCode) { _Flag = true; } } if (_Flag == true) { return(true); } else { clsGlobalVariable.strExceptionReport = "Negative Case Failed!"; return(false); } } else { clsGlobalVariable.strExceptionReport = "Resource or URI Wrong!"; return(false); } } return(true); } catch (Exception e) { clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name); return(false); } }
public bool APICopyCourseForExistingOrganization(object[] lStrvalue) { string header = string.Empty; string statusCode = string.Empty; string result = string.Empty; clsGeneric oGeneric = new clsGeneric(); string URI = string.Empty; Hashtable htblTestData = new Hashtable(); htblTestData = oGeneric.GetTestData(lStrvalue); bool _Flag = false; CopyCourseWithExistingOrganization oCopyCourseWithExistingOrganization = new CopyCourseWithExistingOrganization(); SuperAdminCourseRecords oSuperAdminCourseRecords = new SuperAdminCourseRecords(); List <SuperAdminCourseRecords> lstRecords = new List <SuperAdminCourseRecords>(); string[] strCourses = htblTestData["CourseName"].ToString().Split(','); try { foreach (string strCourseID in strCourses) { SuperAdminCourseRecords course = new SuperAdminCourseRecords(); course.NumberOfSeats = htblTestData["Seats"].ToString(); course.SuperAdminCourseID = string.Empty; course.SuperAdminCourseID = strCourseID; lstRecords.Add(course); } oCopyCourseWithExistingOrganization.UserID = htblTestData["USERID"].ToString(); oCopyCourseWithExistingOrganization.SuperAdminCourseRecords = lstRecords; oCopyCourseWithExistingOrganization.OrderID = htblTestData["USERID"].ToString(); oCopyCourseWithExistingOrganization.PurchaseDate = htblTestData["PurchaseDate"].ToString(); #region if ((htblTestData["orgID"].ToString().Trim() == "")) { lstRecords.Clear(); lstRecords = new List <SuperAdminCourseRecords>(); foreach (string strCourseID in strCourses) { SuperAdminCourseRecords course = new SuperAdminCourseRecords(); course.NumberOfSeats = htblTestData["Seats"].ToString(); course.SuperAdminCourseID = string.Empty; course.SuperAdminCourseID = strCourseID; lstRecords.Add(course); } oCopyCourseWithExistingOrganization.SuperAdminCourseRecords = lstRecords; oCopyCourseWithExistingOrganization.UserID = clsAPI.userid; GetAPICredentials oGetAPICredentials = new GetAPICredentials(); oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.orgCredential.Replace("$", clsAPI.orgID), oCopyCourseWithExistingOrganization, "H2", "", ""); var orgCredential = JsonConvert.DeserializeObject <GetAPICredentials>(result); Crypto3DES _des = new Crypto3DES(ApplicationSettings.EComModuleEncKey()); _ecomTransactionKey = _des.Decrypt3DES(orgCredential.TransactionKey); _ecomLoginKey = _des.Decrypt3DES(orgCredential.LoginID); oGeneric.GetApiResponseCodeData(out statusCode, out result, htblTestData["MethodType"].ToString(), ApplicationSettings.APIURI() + htblTestData["URI"].ToString(), oCopyCourseWithExistingOrganization, htblTestData["HeaderType"].ToString(), _ecomLoginKey, _ecomTransactionKey); } else { #endregion _ecomTransactionKey = ApplicationSettings.TransactionKey(); _ecomLoginKey = ApplicationSettings.APILoginID(); clsAPI.orgID = htblTestData["orgID"].ToString(); oGeneric.GetApiResponseCodeData(out statusCode, out result, htblTestData["MethodType"].ToString(), ApplicationSettings.APIURI() + htblTestData["URI"].ToString(), oCopyCourseWithExistingOrganization, htblTestData["HeaderType"].ToString(), _ecomLoginKey, _ecomTransactionKey); } if (htblTestData["TestCaseType"].ToString().ToUpper() == "POSITIVE") { if (result.ToUpper().Contains("!DOCTYPE")) { clsGlobalVariable.strExceptionReport = "Resource not found"; return(true); } if (statusCode.Contains("201")) { header = htblTestData["HeaderType"].ToString(); RequestID oRequest = JsonConvert.DeserializeObject <RequestID>(result); URI = ApplicationSettings.APIURI() + clsAPI.apiStatus + oRequest.requestID.ToString(); result = string.Empty; oGeneric.GetApiResponseCodeData(out statusCode, out result, "Get", URI, oCopyCourseWithExistingOrganization, "H2", "", ""); AccountRequests oRequestData = JsonConvert.DeserializeObject <AccountRequests>(result); int courseCounter = 0; foreach (string strCourseID in strCourses) { if (strCourseID == oRequestData.CourseResults[courseCounter].SuperAdminCourseID.ToString()) { courseCounter++; _Flag = true; } else { courseCounter++; _Flag = false; } } if (_Flag == true) { return(true); } else { return(false); } } else { var oError = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result); clsGlobalVariable.strExceptionReport = "Invalid URI: Error Code: " + oError[0].ErrorCode + "\n Error Description: " + oError[0].ErrorMessage; return(false); } } else if (htblTestData["TestCaseType"].ToString().ToUpper() == "NEGATIVE") { if (result.ToUpper().Contains("!DOCTYPE")) { clsGlobalVariable.strExceptionReport = "Resource not found"; return(true); } if (statusCode.Contains("4") || statusCode.Contains("5")) { if (statusCode.Contains("404") || statusCode.Contains("500") || statusCode.Contains("405")) { clsGlobalVariable.strExceptionReport = "Resource not found"; return(true); } var oError = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result); SuperAdminCoursePushDownErrorCode oErrorCode = new SuperAdminCoursePushDownErrorCode(); foreach (string strErrorCode in oErrorCode.coursePushDownErrorCode) { if (strErrorCode == oError[0].ErrorCode) { _Flag = true; } } if (_Flag == true) { return(true); } else { clsGlobalVariable.strExceptionReport = "Negative Case Failed!"; return(false); } } else { clsGlobalVariable.strExceptionReport = "Resource or URI Wrong!"; return(false); } } return(true); } catch (Exception e) { clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name); return(false); } }
//Created by Niranjan //Modified by Sandeep //Modified by Niranjan - 20/7/2016 public bool APICreateUser(object[] lStrvalue) { //UsersData odata = new UsersData(); try { clsGlobalVariable.strExceptionReport = string.Empty; string statusCode = string.Empty; string result = string.Empty; //string allCourseResultresult = string.Empty; //string singleCourseresult = string.Empty; clsGeneric oGeneric = new clsGeneric(); string URI = string.Empty; Hashtable htblTestData = new Hashtable(); htblTestData = oGeneric.GetTestData(lStrvalue); bool _Flag = false; User userID = new User(); GetAPICredentials oGetAPICredentials = new GetAPICredentials(); //Get Org ID at runtime clsPage oPage = new clsPage(iWebdriver); _orgID = oPage.GetOrganizationID(); clsAPI.orgID = _orgID; Thread.Sleep(clsGlobalVariable.iWaitHigh); oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", clsAPI.apiURI + clsAPI.orgCredential.Replace("$", clsAPI.orgID), oGetAPICredentials, "H2", "", ""); var orgCredential = JsonConvert.DeserializeObject <GetAPICredentials>(result); Crypto3DES _des = new Crypto3DES(ApplicationSettings.EComModuleEncKey()); _ecomTransactionKey = _des.Decrypt3DES(orgCredential.TransactionKey); _ecomLoginKey = _des.Decrypt3DES(orgCredential.LoginID); UpdateUser ouser = new UpdateUser(); CreateUser cuser = new CreateUser(); XDocument doc = XDocument.Load(clsGlobalVariable.ProjectDirectory + htblTestData["FieldsToBeUpdated"].ToString()); List <UpdateUser> oList = doc.Root.Elements() .Select(x => new UpdateUser() { Key = x.Attribute("Key").Value, Value = x.Attribute("Value").Value }).ToList(); for (int i = 0; i <= oList.Count; i++) { cuser.userProfileData = oList; } cuser.sendRegistrationMail = "true"; cuser.changePasswordAtNextLogin = "******"; //Update Fields Value oGeneric.GetApiResponseCodeData(out statusCode, out result, "POST", clsAPI.apiURI + clsAPI.user.Replace("{orgid}", clsAPI.orgID), cuser, "H1", _ecomLoginKey, _ecomTransactionKey); //1st code checks whether the test cases is Negative or Positive if (htblTestData["TestCaseType"].ToString().ToUpper() == "NEGATIVE") { //If Negative then we expect an error code if (result.Contains("ErrorCode") || result.Contains("Invalid URI.")) { if (result.Contains("Invalid URI.")) { return(true); } //The error code can be from API of Course Pushdown SuperAdminCoursePushDownErrorCode oError = new SuperAdminCoursePushDownErrorCode(); var error = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result); foreach (string errorcode in oError.coursePushDownErrorCode) { for (int i = 0; i < error.Count; i++) { if (error[i].ErrorCode == errorcode) { _Flag = true; } else { _Flag = false; } } if (_Flag == true) { break; } } if (_Flag == false) { //If Not from Course Push Down then The error code can be from General APIs GeneralAPIErrCodes oError1 = new GeneralAPIErrCodes(); var error1 = JsonConvert.DeserializeObject <List <GeneralAPIErrCodes> >(result); foreach (string errorcode in oError1.allAPIErrorCodes) { for (int i = 0; i < error.Count; i++) { if (error[i].ErrorCode == errorcode) { _Flag = true; if (_Flag == true) { break; } } else { _Flag = false; } } if (_Flag == true) { break; } } } } if (_Flag == true) { return(_Flag); } } else { //If the test case is positive control will come here and then user should be created without any error code if (statusCode == "Created/201") { _Flag = true; } else { _Flag = false; } } return(_Flag); } catch (Exception e) { clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name); return(false); } }