public override void Run()
        {
            string newPSId = string.Empty;
            string setPSInfoString = string.Empty;
            string getPSInfoString = string.Empty;
            PresentationStateService psService = new PresentationStateService();

            try
            {
                //create a new patient and import a new image to get a new ps id.
                string newPatientId = CommonLib.CreatePatient();
                ImportService import = new ImportService();
                XMLResult r = import.importObject(newPatientId, string.Empty, @"c:\PASPerformance\001.png", null, true, string.Empty);
                newPSId = r.MultiResults[1].GetParameterValueByIndex(0);
                XMLParameter psId = new XMLParameter("presentationstate");
                psId.AddParameter("internal_id", newPSId);
                getPSInfoString = psId.GenerateXML();
                XMLParameterCollection c = new XMLParameterCollection();
                c.Add(psId);
                setPSInfoString = psService.getPresentationStateInfo(c).ArrayResult.GenerateXML();
            }
            catch (Exception ex)
            {
                LogRecordType lr = new LogRecordType();
                lr.FunctionName = this.mFunctionName;
                lr.Lable = this.mLabel;
                string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                lr.Passed = false;

                Log.AddRecord(lr);

                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed, true);
                this.RiseTestCaseCompleteEvent();

                this.mExecuted = this.mRepeat;
                this.mFailed = this.mRepeat;
                return;
            }

            double userCaseResponse=0;

            for (int i = 1; i <= this.mRepeat; i++)
            {
                LogRecordType lr = new LogRecordType();
                lr.Lable = this.mLabel;
                lr.FunctionName = this.mFunctionName;

                try
                {
                    //get ps info
                    XMLResult getResult=new XMLResult (psService.InvokeMethod ("getPresentationStateInfo", new object []{getPSInfoString }));

                    //if get presentation infor failed.
                    if (getResult.IsErrorOccured)
                    {
                        lr.Message = "Get PS info faild. Message: " + getResult.Message;
                        lr.ResponseTime = psService.ResponseTime;
                        lr.Passed = false;
                        Log.AddRecord(lr);
                        this.mFailed++;
                        continue;
                    }
                    else  //if get ps info successed
                    {
                        userCaseResponse = psService.ResponseTime;
                    }

                    //set ps info
                    XMLResult setResult = new XMLResult(psService.InvokeMethod("setPresentationStateInfo", new object[] { setPSInfoString, newPSId}));

                    //if set ps info failed
                    if (setResult.IsErrorOccured)
                    {
                        lr.Message = "Set PS info failed. Message: " + setResult.Message;
                        lr.ResponseTime = psService.ResponseTime;
                        lr.Passed = false;
                        Log.AddRecord(lr);
                        this.mFailed++;
                        continue;
                    }
                    else  //if set ps info successed.
                    {
                        userCaseResponse += psService.ResponseTime;
                    }

                    lr.ResponseTime = userCaseResponse;
                    this.ExecutedTime += userCaseResponse;
                }
                catch (Exception ex)
                {
                    this.mFailed++;
                    lr.Passed = false;
                    string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                    lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                }

                this.mExecuted = i;
                Log.AddRecord(lr);

                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed);
            }

            this.RiseTestCaseCompleteEvent();
        }
        public override void Run()
        {
            string newPatientId = string.Empty;
            string psId = string.Empty;
            string PsInfoString = string.Empty;

            PresentationStateService ps = new PresentationStateService();

            try
            {
                //create a new patient and import a new image to get a new ps id.
                newPatientId = CommonLib.CreatePatient();
                ImportService import = new ImportService();
                XMLResult importResult = import.importObject(newPatientId, string.Empty, @"c:\PASPerformance\001.png", null,  true, string.Empty);
                psId = importResult.MultiResults[1].GetParameterValueByIndex(0);

                //Get PS info string.
                PsInfoString = ps.getPresentationState(psId).ArrayResult.GenerateXML();
            }
            catch (Exception ex)
            {
                LogRecordType lr = new LogRecordType();
                lr.FunctionName = this.mFunctionName;
                lr.Lable = this.mLabel;
                string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                lr.Passed = false;

                Log.AddRecord(lr);

                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed, true);
                this.RiseTestCaseCompleteEvent();

                this.mExecuted = this.mRepeat;
                this.mFailed = this.mRepeat;

                return;
            }

            for (int i = 1; i <= this.mRepeat; i++)
            {
                LogRecordType lr = new LogRecordType();
                lr.Lable = this.mLabel;
                lr.FunctionName = this.mFunctionName;

                double userCaseResponse = 0;

                try
                {
                    //get ps
                    XMLResult getPsResult = ps.getPresentationState(psId);

                    if (getPsResult.IsErrorOccured)
                    {
                        lr.Passed = false;
                        lr.Message = getPsResult.Message;
                        lr.ResponseTime = ps.ResponseTime;
                        Log.AddRecord(lr);

                        this.mFailed++;
                        continue;
                    }
                    else
                        userCaseResponse = ps.ResponseTime;

                    //set ps
                    XMLResult setPsResult = new XMLResult(ps.InvokeMethod("setPresentationState", new object[] { PsInfoString, psId }));

                    if (setPsResult.IsErrorOccured)
                    {
                        lr.Passed = false;
                        lr.Message = setPsResult.Message;
                        lr.ResponseTime = ps.ResponseTime;
                        Log.AddRecord(lr);

                        this.mFailed++;
                        continue;
                    }
                    else
                        userCaseResponse += ps.ResponseTime;

                    //if no exception.
                    lr.Passed = true;
                    lr.ResponseTime = userCaseResponse;

                    this.mExectuedTime += userCaseResponse;
                }
                catch (Exception ex)
                {
                    lr.Passed = false;
                    string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                    lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";

                    this.mFailed++;
                }

                Log.AddRecord(lr);
                this.mExecuted = i;

                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed);
            }

            this.RiseTestCaseCompleteEvent();
        }