Beispiel #1
0
        public bool GetSession(object[] oObject)
        {
            string _UserID = string.Empty;

            clsGlobalVariable.strExceptionReport = string.Empty;
            string        statusCode       = string.Empty;
            string        statusCodeUpdate = string.Empty;
            string        result           = string.Empty;
            string        resultput        = string.Empty;
            clsGeneric    oGeneric         = new clsGeneric();
            string        URI       = string.Empty;
            string        courseID  = string.Empty;
            bool          _flag     = false;
            List <string> lCourseId = new List <string>();
            string        resultnew = string.Empty;
            string        sessionId = string.Empty;

            Hashtable hTable = new Hashtable();

            hTable = oGeneric.GetTestData(oObject);

            clsPage oPage = new clsPage(iWebdriver);

            lCourseId = oPage.GetCourseId(hTable["CourseName"].ToString());
            clsGenericAPI oclsGenericAPI = new clsGenericAPI();


            _orgID       = oPage.GetOrganizationID();
            clsAPI.orgID = _orgID;
            oclsGenericAPI.GetORGCredentials(out _ecomTransactionKey, out _ecomLoginKey, _orgID);
            User oUser = new User();

            try
            {
                if (hTable["FunctionFor"].ToString().ToUpper() == "ALL")
                {
                    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);
                    }
                    if (oSessionData.Count > 0)
                    {
                        _flag = true;
                    }
                }
                else if (hTable["FunctionFor"].ToString().ToUpper() == "ROOMNAME")
                {
                    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);

                    for (int iSessionCounter = 0; iSessionCounter < oSessionData.Count; iSessionCounter++)
                    {
                        if (oSessionData[iSessionCounter].RoomName == hTable["RoomName"].ToString())
                        {
                            sessionId = oSessionData[iSessionCounter].SessionID; break;
                        }
                    }

                    if (sessionId == "")
                    {
                        return(false);
                    }

                    oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetSessionID.Replace("{orgid}", _orgID).Replace("{CourseID}", lCourseId[0].ToString().Trim()) + "/" + sessionId, oUser, "H1", _ecomLoginKey, _ecomTransactionKey);

                    var oSessionDatanew = JsonConvert.DeserializeObject <List <clsAPISession> >(result);
                    if (oSessionDatanew.Count == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetSessionID.Replace("{orgid}", _orgID).Replace("{CourseID}", lCourseId[0].ToString().Trim()) + "?sessionstartdate=" + hTable["StartDate"] + "&sessionenddate=" + hTable["EndDate"], oUser, "H1", _ecomLoginKey, _ecomTransactionKey);

                    if (hTable["TestCaseType"].ToString().ToUpper() == "NEGATIVE")
                    {
                        if (statusCode.Contains("204") || statusCode.Contains("200"))
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    var oSessionData = JsonConvert.DeserializeObject <List <clsAPISession> >(result);

                    if (result == "")
                    {
                        return(false);
                    }
                    if (oSessionData.Count > 0)
                    {
                        _flag = true;
                    }
                }
            }
            catch (Exception e)
            {
                clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name);

                return(false);
            }


            return(_flag);
        }
Beispiel #2
0
        public bool GetCurricula(object[] oObject)
        {
            string _UserID = string.Empty;

            clsGlobalVariable.strExceptionReport = string.Empty;
            string     statusCode       = string.Empty;
            string     statusCodeUpdate = string.Empty;
            string     result           = string.Empty;
            string     resultput        = string.Empty;
            clsGeneric oGeneric         = new clsGeneric();
            string     URI       = string.Empty;
            string     courseID  = string.Empty;
            bool       _flag     = false;
            string     lCourseId = string.Empty;
            string     resultnew = string.Empty;
            string     sessionId = string.Empty;

            Hashtable hTable = new Hashtable();

            hTable = oGeneric.GetTestData(oObject);

            clsPage oPage = new clsPage(iWebdriver);

            lCourseId = oPage.GetCurriculumId(hTable["CourseName"].ToString());
            clsGenericAPI oclsGenericAPI = new clsGenericAPI();


            _orgID       = oPage.GetOrganizationID();
            clsAPI.orgID = _orgID;
            oclsGenericAPI.GetORGCredentials(out _ecomTransactionKey, out _ecomLoginKey, _orgID);
            User oUser = new User();

            try
            {
                if (hTable["FunctionFor"].ToString().ToUpper() == "ALL")
                {
                    oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetCuriculla.Replace("{orgid}", _orgID).Replace("{CourseID}", lCourseId), oUser, "H1", _ecomLoginKey, _ecomTransactionKey);


                    var oCurriculaData = JsonConvert.DeserializeObject <List <curiculla> >(result);

                    if (result == "")
                    {
                        return(false);
                    }
                    if (oCurriculaData.Count > 0)
                    {
                        _flag = true;
                    }
                }
                else if (hTable["FunctionFor"].ToString().ToUpper() == "SPECIFIC")
                {
                    oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetCuriculla.Replace("{orgid}", _orgID) + "/" + lCourseId, oUser, "H1", _ecomLoginKey, _ecomTransactionKey);


                    var oSessionData = JsonConvert.DeserializeObject <List <curiculla> >(result);


                    if (oSessionData.Count == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    DefaultDueDateSettings oDefaultDueDateSettings = new DefaultDueDateSettings();

                    oDefaultDueDateSettings.DefaultDueDate      = hTable["DefaultDueDate"].ToString();
                    oDefaultDueDateSettings.DaysAfterEnrollment = hTable["DaysAfterEnrollment"].ToString();
                    oGeneric.GetApiResponseCodeData(out statusCode, out result, "PUT", ApplicationSettings.APIURI() + clsAPI.GetCuriculla.Replace("{orgid}", _orgID) + "/" + lCourseId + "/DueDate", oDefaultDueDateSettings, "H1", _ecomLoginKey, _ecomTransactionKey);

                    if (hTable["TestCaseType"].ToString().ToUpper() == "NEGATIVE")
                    {
                        if (statusCode.Contains("204") || statusCode.Contains("200"))
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }

                    if (statusCode.Contains("204") || statusCode.Contains("200"))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception er) { }


            return(_flag);
        }
Beispiel #3
0
        public bool ActivateDeactiveCourse(string courseName, string FlagActiveInactive)
        {
            bool   _flag    = false;
            string courseId = string.Empty;

            try
            {
                clsGlobalVariable.strExceptionReport = string.Empty;
                string            statusCode         = string.Empty;
                string            result             = string.Empty;
                GetAPICredentials oGetAPICredentials = new GetAPICredentials();

                //Get Org ID at runtime
                clsPage oPage = new clsPage(iWebdriver);
                _orgID       = oPage.GetOrganizationID();
                clsAPI.orgID = _orgID;

                clsGeneric oGeneric = new clsGeneric();

                Thread.Sleep(clsGlobalVariable.iWaitHigh);

                //Get Org ID at runtime
                clsGenericAPI oGenericAPI = new clsGenericAPI();
                /////////////geting or credential
                oGenericAPI.GetORGCredentials(out _ecomTransactionKey, out _ecomLoginKey, _orgID);


                //////getting all courses
                oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", clsAPI.apiURI + clsAPI.GetAllCourses.Replace("{orgid}", clsAPI.orgID), oGetAPICredentials, "H1", _ecomLoginKey, _ecomTransactionKey);

                var courseData = JsonConvert.DeserializeObject <List <clsAPICourse> >(result);

                for (int iUser = 0; iUser < courseData.Count; iUser++)
                {
                    if (courseData[iUser].Name == courseName.ToString())
                    {
                        courseId = courseData[iUser].ID;
                        break;
                    }
                }

                /////////////////////////////activating deactivating course
                if (FlagActiveInactive.ToUpper() == "ACTIVATE")
                {
                    oGeneric.GetApiResponseCodeData(out statusCode, out result, "PUT", clsAPI.apiURI + clsAPI.GetSingleCourse.Replace("{orgid}", clsAPI.orgID).Replace("{CourseID}", courseId) + "/Activate", oGetAPICredentials, "H1", _ecomLoginKey, _ecomTransactionKey);
                }
                else
                {
                    oGeneric.GetApiResponseCodeData(out statusCode, out result, "DELETE", clsAPI.apiURI + clsAPI.GetSingleCourse.Replace("{orgid}", clsAPI.orgID).Replace("{CourseID}", courseId) + "/Activate", oGetAPICredentials, "H1", _ecomLoginKey, _ecomTransactionKey);
                }
                if (statusCode.Contains("204"))
                {
                    _flag = true;
                }
            }
            catch (Exception e)
            {
                clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name);

                return(false);
            }



            return(_flag);
        }
        /// <summary>
        /// update transcript function for put api request
        /// </summary>
        /// <param name="hTable">input from transcript function</param>
        /// <returns>true/false</returns>
        private bool UpdateTranscript(Hashtable hTable)
        {
            string _UserID = string.Empty;

            clsGlobalVariable.strExceptionReport = string.Empty;
            string     statusCode       = string.Empty;
            string     statusCodeUpdate = string.Empty;
            string     result           = string.Empty;
            string     resultput        = string.Empty;
            clsGeneric oGeneric         = new clsGeneric();
            string     URI      = string.Empty;
            string     courseID = string.Empty;
            bool       _flag    = false;

            try
            {
                Transcript       oTranscript       = new ILMS.Transcript();
                clsAPITranscript oclsAPITranscript = new clsAPITranscript();


                clsPage oPage = new clsPage(iWebdriver);

                _orgID       = oPage.GetOrganizationID();
                clsAPI.orgID = _orgID;


                Users oUser = new Users();

                GetAPICredentials oGetAPICredentials = new GetAPICredentials();
                ////////////////////get api credentials for organization

                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);


                #region get user id by there type

                if (hTable["UserStatus"].ToString().ToUpper().Contains("INACTIVE"))
                {
                    oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.user.Replace("{orgid}", _orgID) + "?F015=" + hTable["UserEmail"].ToString() + "*&userstatus=inactive", oUser, "H1", _ecomLoginKey, _ecomTransactionKey);
                }
                else if (hTable["UserStatus"].ToString().ToUpper().Contains("DELETED"))
                {
                    oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.user.Replace("{orgid}", _orgID) + "?F015=" + hTable["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() == hTable["UserMailID"].ToString().Trim())
                    {
                        _UserID = oUserData[iUser].ID;
                        break;
                    }
                }

                #endregion

                #region course
                if (hTable["TranscriptFor"].ToString().ToUpper() == "COURSE")
                {
                    try
                    {
                        courseID = GetID(hTable["CourseName"].ToString(), hTable["TranscriptFor"].ToString());
                        ///old transcript
                        oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetSpecificCourseTranscript.Replace("{orgID}", clsAPI.orgID).Replace("{userID}", _UserID).Replace("{courseID}", courseID), oclsAPITranscript, "H1", _ecomLoginKey, _ecomTransactionKey);


                        oTranscript.CompletionDate              = hTable["CompletionDate"].ToString();
                        oTranscript.EnrollmentDate              = hTable["EnrollmentDate"].ToString();
                        oTranscript.Score                       = hTable["Score"].ToString();
                        oTranscript.StartDate                   = hTable["StartDate"].ToString();
                        oTranscript.Status                      = hTable["Status"].ToString();
                        oTranscript.LicenseExpirationDate       = hTable["LicenseExpirationDate"].ToString();
                        oTranscript.RequirementType             = hTable["RequirementType"].ToString();
                        oTranscript.DueDate                     = hTable["DueDate"].ToString();
                        oTranscript.CertificationExpirationDate = hTable["CertificationExpirationDate"].ToString();

                        /////update transcript
                        string resultupdate = string.Empty;
                        string resultnew    = string.Empty;
                        oGeneric.GetApiResponseCodeData(out statusCodeUpdate, out resultupdate, "PUT", ApplicationSettings.APIURI() + clsAPI.GetSpecificCourseTranscript.Replace("{orgID}", clsAPI.orgID).Replace("{userID}", _UserID).Replace("{courseID}", courseID), oclsAPITranscript, "H1", _ecomLoginKey, _ecomTransactionKey);

                        Thread.Sleep(clsGlobalVariable.iWaitHigh);
                        oGeneric.GetApiResponseCodeData(out statusCode, out resultnew, "GET", ApplicationSettings.APIURI() + clsAPI.GetSpecificCourseTranscript.Replace("{orgID}", clsAPI.orgID).Replace("{userID}", _UserID).Replace("{courseID}", courseID), oclsAPITranscript, "H1", _ecomLoginKey, _ecomTransactionKey);
                        var status    = JsonConvert.DeserializeObject <List <clsAPITranscript> >(resultnew);
                        var statusold = JsonConvert.DeserializeObject <List <clsAPITranscript> >(result);

                        _flag = VerifyTranscriptUpdate(result, resultnew, statusCodeUpdate, hTable);
                    }
                    catch (Exception e)
                    {
                        clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name);

                        return(false);
                    }
                }
                #endregion
                #region session
                else if (hTable["TranscriptFor"].ToString().ToUpper() == "SESSION")
                {
                    List <string> lCourseId = new List <string>();
                    string        resultnew = string.Empty;
                    lCourseId = oPage.GetCourseId(hTable["CourseName"].ToString());
                    clsGenericAPI oclsGenericAPI = new clsGenericAPI();
                    oclsGenericAPI.GetORGCredentials(out _ecomTransactionKey, out _ecomLoginKey, _orgID);


                    if (lCourseId.Count > 0)
                    {
                        oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetSessionID.Replace("{orgid}", _orgID).Replace("{CourseID}", lCourseId[0].ToString()), oUser, "H1", _ecomLoginKey, _ecomTransactionKey);


                        var oSessionData = JsonConvert.DeserializeObject <List <clsAPISession> >(result);

                        if (result == "")
                        {
                            return(false);
                        }

                        _SessionID = oSessionData[0].SessionID;

                        oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetSpecificSessionTranscript.Replace("{orgID}", _orgID).Replace("{CourseID}", lCourseId[0].ToString()).Replace("{sessionID}", _SessionID).Replace("{userID}", _UserID), oUser, "H1", _ecomLoginKey, _ecomTransactionKey);


                        _flag = VerifyTranscriptUpdate(result, resultnew, statusCodeUpdate, hTable);
                    }
                    else
                    {
                        return(false);
                    }
                }
                #endregion
                #region Curricula
                else
                {
                    string resultnew = string.Empty;
                    courseID = oPage.GetCurriculumId(hTable["CourseName"].ToString());


                    try
                    {//////////////////////getting transcript
                        oTranscript.CompletionDate              = hTable["CompletionDate"].ToString();
                        oTranscript.EnrollmentDate              = hTable["EnrollmentDate"].ToString();
                        oTranscript.Score                       = hTable["Score"].ToString();
                        oTranscript.StartDate                   = hTable["StartDate"].ToString();
                        oTranscript.Status                      = hTable["Status"].ToString();
                        oTranscript.LicenseExpirationDate       = hTable["LicenseExpirationDate"].ToString();
                        oTranscript.RequirementType             = hTable["RequirementType"].ToString();
                        oTranscript.DueDate                     = hTable["DueDate"].ToString();
                        oTranscript.CertificationExpirationDate = hTable["CertificationExpirationDate"].ToString();

                        oGeneric.GetApiResponseCodeData(out statusCode, out result, "GET", ApplicationSettings.APIURI() + clsAPI.GetSpecificCurriculumTranscript.Replace("{orgID}", _orgID).Replace("{userID}", _UserID).Replace("{courseID}", courseID), oclsAPITranscript, "H1", _ecomLoginKey, _ecomTransactionKey);

                        var status = JsonConvert.DeserializeObject <List <clsAPITranscript> >(result);


                        oGeneric.GetApiResponseCodeData(out statusCodeUpdate, out resultput, "PUT", ApplicationSettings.APIURI() + clsAPI.GetSpecificCurriculumTranscript.Replace("{orgID}", _orgID).Replace("{userID}", _UserID).Replace("{courseID}", courseID), oclsAPITranscript, "H1", _ecomLoginKey, _ecomTransactionKey);
                        Thread.Sleep(clsGlobalVariable.iWaitHigh);

                        oGeneric.GetApiResponseCodeData(out statusCode, out resultnew, "GET", ApplicationSettings.APIURI() + clsAPI.GetSpecificCurriculumTranscript.Replace("{orgID}", _orgID).Replace("{userID}", _UserID).Replace("{courseID}", courseID), oclsAPITranscript, "H1", _ecomLoginKey, _ecomTransactionKey);
                        var statusold = JsonConvert.DeserializeObject <List <clsAPITranscript> >(result);


                        _flag = VerifyTranscriptUpdate(result, resultnew, statusCodeUpdate, hTable);
                    }
                    catch { clsGlobalVariable.strExceptionReport = "Get transcript scenario failed"; return(false); }
                    return(_flag);
                }
                #endregion
            }
            catch (Exception e)
            {
                clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name);

                return(false);
            }



            return(_flag);
        }