//Case 47: 1.3.12_CreateAnalysis_Normal
        public void Run_Analysis_Acq_CreateAnalysis_Normal_Case47()
        {
            int runCount = 0;
            string analysisContent = "<trophy type=\"analysis\" version=\"1.0\">          <trophyheader>        <accesslog>            <creation date=\"2011-10-25\" time=\"10:54:17\" applicationname=\"kdis2dviewer\" applicationversion=\"7.0\" />            <modification date=\"2011/10/25\" time=\"10:54:18\" applicationname=\"kdis2dviewer\" applicationversion=\"7.0\" />        </accesslog>    </trophyheader>    <templateheader>        <object subtype=\"analysis\" instance=\"true\" name=\"Test Analysis\" uid=\"\" />        <comments />        <icon filepath=\"analysisicon.jpg\" />        <icon>            <ObjectData>base64imagedata</ObjectData>        </icon>        <icon id=\"thumbnailid\" />        <AnalysisProp name=\"1112222\" comments=\"\" date=\"2011-10-25\" time=\"10:54:17\" arrangementmode=\"0\" />    </templateheader>    <page index=\"0\" Dx=\"1280\" Dy=\"1024\" backgroundColour=\"RGB(0,0,0)\">        <Frame index=\"1\" type=\"floating panel\" x=\"938\" y=\"201\" w=\"200\" h=\"239\" Zorder=\"\">            <PanelProp paneltype=\"control panel xray\" id=\"control panel xray\" showstate=\"maximized\" />        </Frame>        <Frame index=\"2\" type=\"floating panel\" x=\"938\" y=\"201\" w=\"200\" h=\"240\" Zorder=\"\">            <PanelProp paneltype=\"control panel color\" id=\"control panel color\" showstate=\"maximized\" />        </Frame>        <Frame index=\"3\" type=\"image\" x=\"349\" y=\"299\" w=\"266\" h=\"355\" Zorder=\"\">            <PanelProp paneltype=\"image\" id=\"@@PSID0\" showstate=\"selected\" IdV0=\"76b3ec9d-1374-4a13-9950-6cf3f5ebc1e6\" />        </Frame>        <Frame index=\"4\" type=\"image\" x=\"818\" y=\"299\" w=\"266\" h=\"354\" Zorder=\"\">            <PanelProp paneltype=\"image\" id=\"@@PSID1\" showstate=\"deselected\" IdV0=\"eb87d761-accf-4531-b4fc-9ee9861f15fd\" />        </Frame>    </page></trophy>";

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                Round r = this.NewRound(runCount.ToString(), "Acquisition for Analysis");

                CheckPoint pAnalysis = new CheckPoint("Create Analysis", "Create Analysis");
                r.CheckPoints.Add(pAnalysis);

                XMLParameter acq = new XMLParameter("acq_info");
                string PatientID = string.Empty;
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "acquire")
                    {
                        if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id")
                            PatientID = ids.InputParameters.GetParameter(i).Value;
                        acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }
                string retPsID = string.Empty;
                string repStr = "@@PSID";
                XMLParameterCollection anaUidsXML = new XMLParameterCollection();
                XMLParameter anaUids = new XMLParameter("presentationstate");

                for (int acqTime = 0; acqTime < 2; acqTime++)
                {
                    retPsID = AcquisitionService.AcquireImage(acq);
                    if (retPsID != string.Empty)
                    {
                        analysisContent = analysisContent.Replace(repStr + acqTime, retPsID);
                        anaUids.AddParameter("internal_id", retPsID);
                    }
                }
                anaUidsXML.Add(anaUids);
                AnalysisService ass = new AnalysisService();

                XMLResult rslCreateAnalysis = ass.createAnalysis(analysisContent, false, true, PatientID, @"D:\Test\DICOM_Imag_Lib\ImportImage\thumb.PNG", anaUidsXML);

                if (rslCreateAnalysis.IsErrorOccured)
                {
                    pAnalysis.Result = TestResult.Fail;
                    pAnalysis.Outputs.AddParameter("Create Analysis", "Analysis Service", rslCreateAnalysis.Message);
                }
                else
                {
                    pAnalysis.Result = TestResult.Pass;
                    pAnalysis.Outputs.AddParameter("Create Analysis ID:", "Analysis Service", rslCreateAnalysis.SingleResult);
                }
                ass.deleteAnalysis(rslCreateAnalysis.SingleResult);
                SaveRound(r);
            }
            Output();
        }
        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 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();
        }
        //Case 1073: 1.3.7_GetPresentationStateInfo_N06_Import image and check the DICOM info value is correct in GetPSInfo return
        public void Run_PS_Import_GetPSInfo_Case1073()
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;

                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    string patientID = null;
                    string objectFileFullPath = null;
                    XMLParameter getPSInfoReturnParam = new XMLParameter("DICOM INFO in getPSInfo return");

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "import")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patientInternalID")
                            {
                                patientID = ids.InputParameters.GetParameter(i).Value;
                            }
                            if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                    }

                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "getPSInfo")
                        {
                            // Add the key to check and the expected value
                            getPSInfoReturnParam.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                        }
                    }

                    #region Step 1: import the image
                    CheckPoint pImport = new CheckPoint("Import", "Import the prepared DICOM image file");
                    r.CheckPoints.Add(pImport);

                    ImportService import = new ImportService();
                    XMLResult importResult = import.importObject(patientID, null, objectFileFullPath, null, true, null);

                    if (importResult.IsErrorOccured)
                    {
                        pImport.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call import service to import DICOM image file returns error.");
                        pImport.Outputs.AddParameter("import", "Import DICOM image file", importResult.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        pImport.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call import service to import DICOM image file succeeds.");
                        pImport.Outputs.AddParameter("import", "Import DICOM image file", importResult.Message);
                    }
                    #endregion

                    #region Step 2: call getPSInfo
                    CheckPoint pGetPSInfo = new CheckPoint("GetPSInfo", "Get the presentionstate info");
                    r.CheckPoints.Add(pGetPSInfo);

                    PresentationStateService psService = new PresentationStateService();

                    XMLParameterCollection getPSInfoParam = new XMLParameterCollection();

                    for (int i = 0; i < importResult.MultiResults.Count; i++)
                    {
                        if (importResult.MultiResults[i].Name.ToLower() == "presentationstate")
                        {
                            getPSInfoParam.Add(importResult.MultiResults[i]);
                            break; // get the PS ID, end for loop
                        }
                    }

                    XMLResult getPSResult = psService.getPresentationStateInfo(getPSInfoParam);

                    if (getPSResult.IsErrorOccured)
                    {
                        pGetPSInfo.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call getPSInfo returns error.");
                        pGetPSInfo.Outputs.AddParameter("getPSInfo", "Get the presentionstate info", importResult.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        pGetPSInfo.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call getPSInfo succeeds.");
                        pGetPSInfo.Outputs.AddParameter("import", "Get the presentionstate info", importResult.Message);
                    }
                    #endregion

                    #region Step 3: check the dicom info in getPSInfo return
                    CheckPoint pDICOMInfo = new CheckPoint("DICOMInfo", "Check the DICOM info in the returned presentionstate info");
                    r.CheckPoints.Add(pDICOMInfo);

                    bool isValueEqual = false;
                    bool isKeyShow = false;

                    foreach (XMLParameterNode psNode in getPSInfoReturnParam.Parameters)
                    {
                        isValueEqual = false;
                        isKeyShow = false;

                        int i = 0;
                        for (i = 0; i < getPSResult.DicomArrayResult.Parameters.Count; i++)
                        {
                            if (getPSResult.DicomArrayResult.Parameters[i].ParameterName.ToLower() == "dicom_info")
                            {
                                if (getPSResult.DicomArrayResult.Parameters[i].ParameterValue.Contains("<parameter key=\"" + psNode.ParameterName + "\" value=\"" + psNode.ParameterValue + "\" />"))   // <parameter key="dcm_modality" value="PX" />
                                {
                                    isKeyShow = true;
                                    isValueEqual = true;
                                    break;
                                }
                            }
                            //if (psNode.ParameterName == getPSResult.DicomArrayResult.Parameters[i].ParameterName)  // need change here to check the dicom info
                            //{
                            //    isKeyShow = true;
                            //    isValueEqual = string.Equals(psNode.ParameterValue, getPSResult.DicomArrayResult.Parameters[i].ParameterValue);
                            //    break; // End current for loop to search node
                            //}
                        }

                        if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress
                        {
                            pDICOMInfo.Result = TestResult.Fail;

                            if (isKeyShow)
                            {
                                System.Diagnostics.Debug.Print("The return value in getPSInfo does not match the expected.");
                                pDICOMInfo.Outputs.AddParameter("DICOMInfo", "Check the DICOM info in the returned presentionstate info", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + getPSResult.MultiResults[0].Parameters[i].ParameterValue);
                            }
                            else
                            {
                                System.Diagnostics.Debug.Print("The return value in getPSInfo does not contain the node: " + psNode.ParameterName);
                                pDICOMInfo.Outputs.AddParameter("DICOMInfo", "Check the DICOM info in the returned presentionstate info", "The return value in getPSInfo does not contain the node: " + psNode.ParameterName);
                            }

                            break; // End current foreach loop, not compare the follwing nodes
                        }
                    }

                    if (isValueEqual)
                    {
                        pDICOMInfo.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("The return values in getPSInfo all match the expected.");
                        pDICOMInfo.Outputs.AddParameter("DICOMInfo", "Check the DICOM info in the returned presentionstate info", "The return values in getPSInfo all match the expected");
                    }
                    #endregion

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message);
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }

            Output();
        }
        //Case 1089: 1.3.7_GetPresentationStateInfo_N07_Acq image and then check the DICOM info value is correct in getPSInfo return
        public void Run_PS_Acq_GetPSInfo_Case1089()
        {
            int runCount = 0;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Acquisition");
                AcquisitionService acqs = new AcquisitionService();
                PresentationStateService pss = new PresentationStateService();

                XMLParameter acq = new XMLParameter("acq_info");
                XMLParameter psa = new XMLParameter("presentationstate");

                XMLParameterCollection psaCollection = new XMLParameterCollection();

                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "acquire")
                    {
                        acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }

                CheckPoint pAcquire = new CheckPoint("Acquire Image", "Acquisition RVG");
                r.CheckPoints.Add(pAcquire);
                System.Diagnostics.Debug.Print("Acquire start");

                XMLResult rslAcqRVG = acqs.startAcquisition(acq);
                System.Threading.Thread.Sleep(3000);
                if (rslAcqRVG.IsErrorOccured)
                {
                    System.Diagnostics.Debug.Print("Acquire fail:");
                    pAcquire.Result = TestResult.Fail;
                    pAcquire.Outputs.AddParameter("Acquire image error", "startAcquisition", rslAcqRVG.Message);
                }
                else
                {
                    pAcquire.Outputs.AddParameter("Acquire session ID", "startAcquisition", rslAcqRVG.SingleResult);
                    int DORVGcount = 0;
                    XMLResult getAcqRVG = new XMLResult();
                    do
                    {
                        System.Threading.Thread.Sleep(3000);
                        System.Diagnostics.Debug.Print("get acquire in do");
                        DORVGcount++;
                        getAcqRVG = acqs.getAcquisitionResult(rslAcqRVG.SingleResult);
                        if (!getAcqRVG.IsErrorOccured)
                        {
                            string psUid = string.Empty;

                            ParseXMLContent parser = new ParseXMLContent(getAcqRVG.ResultContent); // To parse the return XML

                            string imageID = parser.getStringWithPathAndType("trophy/object_info", "image", "value");
                            string[] imageIDs = imageID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                            int imageCount = imageIDs.Length;

                            string psID = parser.getStringWithPathAndType("trophy/object_info", "presentation_state", "value");
                            string[] psIDs = psID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                            int psCount = psIDs.Length;

                            if (imageCount == 1 && psCount == 1)
                            {
                                pAcquire.Result = TestResult.Pass;
                                pAcquire.Outputs.AddParameter("getAcquisitionResult", "Acquisition", getAcqRVG.ResultContent);

                                psUid = psIDs[0];

                                psa.AddParameter("internal_id", psUid);
                                XMLParameter psPreferences = new XMLParameter("preferences");
                                psaCollection.Add(psa);
                                psaCollection.Add(psPreferences);

                                XMLResult psinforeturn = pss.getPresentationStateInfo(psaCollection);

                                CheckPoint pGetPSinfo = new CheckPoint("Get Presentation State", "PS Desc");
                                r.CheckPoints.Add(pGetPSinfo);
                                for (int findvalue = 0; findvalue < psinforeturn.DicomArrayResult.Length; findvalue++)
                                {
                                    XMLParameterNode psnode = psinforeturn.DicomArrayResult.Parameters[findvalue];
                                    if (psnode.ParameterName == "acquired" && psnode.ParameterValue == "true")
                                    {
                                        pGetPSinfo.Result = TestResult.Pass;
                                        pGetPSinfo.Outputs.AddParameter("get presentation state", "get presentation state info as expect", "The acquired node value is true for newly acq image");
                                        break;
                                    }
                                }
                                if (pGetPSinfo.Result != TestResult.Pass)
                                {
                                    pGetPSinfo.Result = TestResult.Fail;
                                    pGetPSinfo.Outputs.AddParameter("get presentation state", "get presentation state info not as expect", "The acquired node value is NOT true for newly acq image. Actually get: " + psinforeturn.ResultContent);
                                }
                            }
                            else
                            {
                                pAcquire.Result = TestResult.Fail;
                                pAcquire.Outputs.AddParameter("getAcquisitionResult", "Acquisition", "Wrong return XML: " + getAcqRVG.ResultContent);
                            }

                            break; // The test case is finished, end the "do" loop
                        }
                        if (getAcqRVG.IsErrorOccured && getAcqRVG.Code != 499)
                            continue;
                        if (getAcqRVG.Code != 0 && getAcqRVG.Code != 499)
                        {
                            pAcquire.Result = TestResult.Fail;
                            pAcquire.Outputs.AddParameter("Get acquire image error", "getAcquisitionResult", getAcqRVG.Message);
                        }
                        System.Diagnostics.Debug.Print("get acquireResult:" + DORVGcount);
                        if (DORVGcount > 60)
                        {
                            pAcquire.Result = TestResult.Fail;
                            pAcquire.Outputs.AddParameter("Get acquire image error", "getAcquisitionResult", "Acquire great with 3 minutes, timeout!");
                            break;
                        }
                    } while (true);
                }
                SaveRound(r);
            }
            Output();
        }
        //Case 1091: 1.3.7_WorkFlow_AcquireRVG+SetImageInfo+GetPresentationStateInfo_RadioLogInformation
        public void Run_PS_Acq_Radiolog_Case1091()
        {
            //int runCount = this.Input.Repetition;

            int runCount = 0; // this is the initial run count. Use this count to repeat different test data set.

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Test round");

                //Mark the check point here to indicate what's the check point here
                CheckPoint p1 = new CheckPoint("createPatient", "Setup environment of createPatient");
                CheckPoint p2 = new CheckPoint("startAcquisition", "Setup environment of acquisition");
                CheckPoint p3 = new CheckPoint("getAcquisitionResult", "Setup environment of image and PS id");
                CheckPoint p4 = new CheckPoint("setImageInfo", "Setup environment of setImageInfo");
                CheckPoint p5 = new CheckPoint("getImageInfo", "Test getImageInfo");
                CheckPoint p6 = new CheckPoint("getPresentationStateInfo", "Test getPresentationStateInfo");

                r.CheckPoints.Add(p1);
                r.CheckPoints.Add(p2);
                r.CheckPoints.Add(p3);
                r.CheckPoints.Add(p4);
                r.CheckPoints.Add(p5);
                r.CheckPoints.Add(p6);

                //create required PAS service instaces here
                PatientService pats = new PatientService();
                AcquisitionService acq = new AcquisitionService();
                ImageService img = new ImageService();
                PresentationStateService ps = new PresentationStateService();

                //create input parameters here, it may include XML path type and string type value
                XMLParameter pa1 = new XMLParameter("patient");
                XMLParameter pa2 = new XMLParameter("acq_info");
                XMLParameter pa3 = new XMLParameter("getAcquisitionResult");
                XMLParameter pa4 = new XMLParameter("image");
                XMLParameter pa5 = new XMLParameter("image");
                XMLParameter pt6 = new XMLParameter("presentationstate");
                XMLParameterCollection pa6 = new XMLParameterCollection();

                try
                {

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        switch (ids.InputParameters.GetParameter(i).Step)
                        {
                            case "createPatient":
                                pa1.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "acquire":
                                pa2.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "setImageInfo":
                                pa4.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            default:
                                Console.WriteLine("There is no valid selection when parse input parameters.");
                                break;
                        }
                    }

                    //If we need change parameter by specific logic, please put code here

                    //Get service result
                    //Step1 result

                    XMLResult step1_result = pats.createPatient(pa1);

                    //Log step1 service output
                    if (step1_result.IsErrorOccured)
                    {
                        p1.Result = TestResult.Fail;
                        p1.Outputs.AddParameter("createPatient", "Error", step1_result.ResultContent);
                        SaveRound(r);
                        continue;
                    }

                    p1.Result = TestResult.Pass;
                    p1.Outputs.AddParameter("createPatient", "Success", step1_result.ResultContent);

                    //Change input parameter according the output of Step1
                    pa2.AddParameter("patient_internal_id", step1_result.SingleResult);

                    //Step2 result

                    //if acquireType isn't emtpy string, skip step2, here is only RVG acquisition
                    bool acqflag = true;
                    XMLResult step3_result = new XMLResult();
                    if (pa2.GetParameterValueByName("acquireType") == null || pa2.GetParameterValueByName("acquireType") == "")
                    {
                        XMLResult rslAcqRVG = acq.startAcquisition(pa2);
                        System.Threading.Thread.Sleep(3000);
                        if (rslAcqRVG.IsErrorOccured)
                        {
                            System.Diagnostics.Debug.Print("Acquire fail:");
                            p2.Result = TestResult.Fail;
                            p2.Outputs.AddParameter("acquire", "Acquire image error", rslAcqRVG.Message);
                        }
                        else
                        {
                            p2.Result = TestResult.Pass;
                            p2.Outputs.AddParameter("acquire", "Acquire session ID", rslAcqRVG.SingleResult);
                            int DORVGcount = 0;
                            do
                            {
                                System.Threading.Thread.Sleep(3000);
                                System.Diagnostics.Debug.Print("get acquire in do");
                                DORVGcount++;
                                step3_result = acq.getAcquisitionResult(rslAcqRVG.SingleResult);
                                if (!step3_result.IsErrorOccured)
                                {
                                    // move this to out of do-while loop as need check the return value is correct or not there
                                    //p3.Result = TestResult.Pass;
                                    //p3.Outputs.AddParameter("acquire", "Get acquire image", step3_result.Message);
                                    acqflag = false;
                                    break;
                                }
                                if (step3_result.Code != 501)
                                {
                                    continue;
                                }
                                else
                                {
                                    p3.Result = TestResult.Fail;
                                    p3.Outputs.AddParameter("acquire", "Get acquire image error", step3_result.Message);
                                    acqflag = false;
                                }
                                System.Diagnostics.Debug.Print("get acquireResult:" + DORVGcount);
                                if (DORVGcount > 60)
                                {
                                    p3.Result = TestResult.Fail;
                                    p3.Outputs.AddParameter("acquire", "Get acquire image error", "Acquire greate with 3 minutes, timeout!");
                                    acqflag = false;
                                    break;
                                }
                            } while (acqflag);
                        }
                    }

                    //Change input parameter according the output of Step3
                    // if step3 is skipped, step4,step5,setp6 input has no need parameter of internal_id

                    //2012-11-28/19006723: Chanege as ther getAcquisitionResult result change, need new way to get the image ID and PS ID
                    string imgInternalID = string.Empty;
                    string psInternalID = string.Empty;

                    ParseXMLContent parser = new ParseXMLContent(step3_result.ResultContent); // To parse the return XML

                    string imageID = parser.getStringWithPathAndType("trophy/object_info", "image", "value");
                    string[] imageIDs = imageID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    int imageCount = imageIDs.Length;

                    string psID = parser.getStringWithPathAndType("trophy/object_info", "presentation_state", "value");
                    string[] psIDs = psID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    int psCount = psIDs.Length;

                    if (imageCount == 1 && psCount == 1)
                    {
                        p3.Result = TestResult.Pass;
                        p3.Outputs.AddParameter("acquire", "getAcquisitionResult return OK", step3_result.ResultContent);

                        imgInternalID = imageIDs[0];
                        psInternalID = psIDs[0];

                        pa5.AddParameter("internal_id", imgInternalID);
                        pt6.AddParameter("internal_id", psInternalID);
                    }
                    else
                    {
                        p3.Result = TestResult.Fail;
                        p3.Outputs.AddParameter("acquire", "getAcquisitionResult return ERROR", step3_result.ResultContent);
                        SaveRound(r);
                        continue; // Not run below steps
                    }

                    //if (step3_result.MultiResults.Count > 0)
                    //{
                    //    for (int j = 0; j < step3_result.MultiResults.Count; j++)
                    //    {
                    //        for (int i = 0; i < step3_result.MultiResults[j].Parameters.Count; i++)
                    //        {
                    //            if (step3_result.MultiResults[j].Parameters[i].ParameterName == "image_internal_id")
                    //            {
                    //                imgInternalID = step3_result.MultiResults[j].Parameters[i].ParameterValue;
                    //                pa5.AddParameter("internal_id", step3_result.MultiResults[j].Parameters[i].ParameterValue);
                    //            }
                    //            if (step3_result.MultiResults[j].Parameters[i].ParameterName == "presentation_state_internal_id")
                    //            {
                    //                pt6.AddParameter("internal_id", step3_result.MultiResults[j].Parameters[i].ParameterValue);
                    //            }
                    //        }
                    //    }
                    //}

                    //Step4 result
                    XMLResult step4_result = img.setImageInfo(pa4, imgInternalID);

                    //Log step4 service output
                    if (step4_result.IsErrorOccured)
                    {
                        p4.Result = TestResult.Fail;
                        p4.Outputs.AddParameter("setImageInfo", "Error", step4_result.ResultContent);
                        SaveRound(r);
                        continue;
                    }

                    p4.Result = TestResult.Pass;
                    p4.Outputs.AddParameter("setImageInfo", "Success", step4_result.ResultContent);

                    //Step5 result
                    XMLResult step5_result = img.getImageInfo(pa5);

                    //Log step3 service output
                    //Compare the Expected parameters of getImageInfo and output result of getImageInfo
                    //count of compare matched parameters
                    int compCount = 0;
                    //count of expected parameters on getImageInfo
                    int expectedParameterCount = 0;
                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getImageInfo")
                        {
                            expectedParameterCount++;
                        }
                    }

                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getImageInfo" && ids.ExpectedValues.Parameters[index].Value == step5_result.DicomArrayResult.GetParameterValueByName(ids.ExpectedValues.Parameters[index].Key))
                        {
                            compCount++;
                        }
                    }

                    if (step5_result.IsErrorOccured || compCount != expectedParameterCount)
                    {
                        p5.Result = TestResult.Fail;
                        p5.Outputs.AddParameter("getImageInfo", "Error", step5_result.ResultContent);
                        SaveRound(r);
                        continue;
                    }

                    p5.Result = TestResult.Pass;
                    p5.Outputs.AddParameter("getImageInfo", "Success", step5_result.ResultContent);

                    //Change input parameter according the output of Step6

                    //generate input parameter collection of step6
                    pa6.Add(pt6);
                    //Step6 result

                    XMLResult step6_result = ps.getPresentationStateInfo(pa6);

                    //Log step6 service output
                    //Compare the Expected parameters of getPresentationStateInfo and output result of getPresentationStateInfo
                    compCount = 0;
                    //count of expected parameters on getPresentationStateInfo
                    expectedParameterCount = 0;
                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getPresentationStateInfo")
                        { expectedParameterCount++; }
                    }

                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getPresentationStateInfo" && ids.ExpectedValues.Parameters[index].Value == step6_result.DicomArrayResult.GetParameterValueByName(ids.ExpectedValues.Parameters[index].Key))
                        { compCount++; }
                    }

                    if (step6_result.IsErrorOccured || compCount != expectedParameterCount)
                    {
                        p6.Result = TestResult.Fail;
                        p6.Outputs.AddParameter("getPresentationStateInfo", "Error", step6_result.ResultContent);
                    }
                    else
                    {
                        p6.Result = TestResult.Pass;
                        p6.Outputs.AddParameter("getPresentationStateInfo", "Success", step6_result.ResultContent);
                    }

                    //Save data for each round
                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint p = new CheckPoint("Excepption", "Exception thrown when case run: "+ex.ToString());
                    r.CheckPoints.Add(p);
                    SaveRound(r);
                }
            }

            //Save service log as xml file
            Output();
        }
        //Case 1502: 1.9.3.1_deleteCrossSection_localizer_has_three_parents_and_delete_all_parents
        public void Run_3D_deleteCrossSection_deleteallparents_Case1502()
        {
            int runCount = 0;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "delete_all_cs_shared_localizer");
                CheckPoint pCreate = new CheckPoint("Workflow", "delete_all_cs_shared_localizer");
                r.CheckPoints.Add(pCreate);

                CrossSectionService cs = new CrossSectionService();

                XMLParameterCollection csInputData1 = new XMLParameterCollection();
                XMLParameterCollection csInputData2 = new XMLParameterCollection();
                XMLParameterCollection csInputData3 = new XMLParameterCollection();

                XMLParameter cs1 = new XMLParameter("crosssection");
                XMLParameter cs2 = new XMLParameter("crosssection");
                XMLParameter cs3 = new XMLParameter("crosssection");

                XMLParameter cs1_slicepath = new XMLParameter("slices_path_list");
                XMLParameter cs2_slicepath = new XMLParameter("slices_path_list");
                XMLParameter cs3_slicepath = new XMLParameter("slices_path_list");

                XMLParameter cs1_slices_dicom_info_list = new XMLParameter("slices_dicom_info_list");
                XMLParameter cs2_slices_dicom_info_list = new XMLParameter("slices_dicom_info_list");
                XMLParameter cs3_slices_dicom_info_list = new XMLParameter("slices_dicom_info_list");

                XMLParameter cs1_ps_xml_annotation_list = new XMLParameter("slices_ps_xml_annotation_list");
                XMLParameter cs2_ps_xml_annotation_list = new XMLParameter("slices_ps_xml_annotation_list");
                XMLParameter cs3_ps_xml_annotation_list = new XMLParameter("slices_ps_xml_annotation_list");

                XMLParameter cs1_ps_xml_general_list = new XMLParameter("slices_ps_xml_general_list");
                XMLParameter cs2_ps_xml_general_list = new XMLParameter("slices_ps_xml_general_list");
                XMLParameter cs3_ps_xml_general_list = new XMLParameter("slices_ps_xml_general_list");

                XMLParameter cs1_ps_xml_processing_list = new XMLParameter("slices_ps_xml_processing_list");
                XMLParameter cs2_ps_xml_processing_list = new XMLParameter("slices_ps_xml_processing_list");
                XMLParameter cs3_ps_xml_processing_list = new XMLParameter("slices_ps_xml_processing_list");

                string volume1 = string.Empty;
                string volume2 = string.Empty;
                string volume3 = string.Empty;

                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    switch (ids.InputParameters.GetParameter(i).Step)
                    {
                        case "volume1":
                            volume1 = ids.InputParameters.GetParameter(i).Value;
                            break;

                        case "createcs_crosssection":
                            cs1.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            cs2.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            cs3.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            break;
                        case "createcs_slices_dicom_info_list":
                            cs1_slices_dicom_info_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            cs2_slices_dicom_info_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            cs3_slices_dicom_info_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            break;
                        case "createcs_slices_ps_xml_annotation_list":
                            cs1_ps_xml_annotation_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            cs2_ps_xml_annotation_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            cs3_ps_xml_annotation_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            break;
                        case "createcs_slices_ps_xml_general_list":
                            cs1_ps_xml_general_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            cs2_ps_xml_general_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            cs3_ps_xml_general_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            break;
                        case "createcs_slices_ps_xml_processing_list":
                            cs1_ps_xml_processing_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            cs2_ps_xml_processing_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            cs3_ps_xml_processing_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            break;
                        case "createcs1_crosssection":
                            cs1.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            break;
                        case "createcs2_crosssection":
                            cs2.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            break;
                        case "createcs3_crosssection":
                            cs3.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            break;
                        case "createcs1_slices_path_list":
                            cs1_slicepath.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            break;
                        case "createcs2_slices_path_list":
                            cs2_slicepath.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            break;
                        case "createcs3_slices_path_list":
                            cs3_slicepath.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                            break;

                    }
                }
                csInputData1.Add(cs1);
                csInputData1.Add(cs1_slicepath);
                csInputData1.Add(cs1_slices_dicom_info_list);
                csInputData1.Add(cs1_ps_xml_annotation_list);
                csInputData1.Add(cs1_ps_xml_general_list);
                csInputData1.Add(cs1_ps_xml_processing_list);

                csInputData2.Add(cs2);
                csInputData2.Add(cs2_slicepath);
                csInputData2.Add(cs2_slices_dicom_info_list);
                csInputData2.Add(cs2_ps_xml_annotation_list);
                csInputData2.Add(cs2_ps_xml_general_list);
                csInputData2.Add(cs2_ps_xml_processing_list);

                csInputData3.Add(cs3);
                csInputData3.Add(cs3_slicepath);
                csInputData3.Add(cs3_slices_dicom_info_list);
                csInputData3.Add(cs3_ps_xml_annotation_list);
                csInputData3.Add(cs3_ps_xml_general_list);
                csInputData3.Add(cs3_ps_xml_processing_list);
                string test = csInputData1.GenerateXML();
                XMLResult rslCreate1 = cs.createCrossSection(volume1, csInputData1);
                XMLResult rslCreate2 = cs.createCrossSection(volume1, csInputData2);
                XMLResult rslCreate3 = cs.createCrossSection(volume1, csInputData3);

                string csid1 = rslCreate1.SingleResult;
                string csid2 = rslCreate2.SingleResult;
                string csid3 = rslCreate3.SingleResult;

                XMLResult rslList = cs.listImagesOfCrossSection(csid1);
                string first_localizer = rslList.SingleResult;

                XMLResult rslDelete1 = cs.deleteCrossSection(csid1);
                XMLResult rslDelete2 = cs.deleteCrossSection(csid2);
                XMLResult rslDelete3 = cs.deleteCrossSection(csid3);

                ImageService imgsvr = new ImageService();
                XMLParameter cInputImage = new XMLParameter("image");
                cInputImage.AddParameter("internal_id", first_localizer);

                XMLResult rslget = imgsvr.getImageInfo(cInputImage);

                if (!rslCreate1.IsErrorOccured && !rslCreate2.IsErrorOccured && !rslCreate3.IsErrorOccured && !rslDelete1.IsErrorOccured && !rslDelete2.IsErrorOccured && !rslDelete3.IsErrorOccured && rslget.Code == 1006)
                {

                    pCreate.Result = TestResult.Pass;
                    pCreate.Outputs.AddParameter("Workflow", "delete all crosssection shared localizer", "OK");

                }
                else
                {
                    pCreate.Result = TestResult.Fail;
                    string msg = "Create:" + rslCreate1.Message + "," + rslCreate2.Message + "," + rslCreate3.Message + ".Delete:" + rslDelete1.Message + rslDelete2.Message + rslDelete3.Message + ". GetImageCode:" + rslget.Code;
                    pCreate.Outputs.AddParameter("Workflow", "delete all crosssection shared localizer", msg);

                }

                SaveRound(r);
                Output();

            }
        }
        //Case 1364: 1.9.1_WorkFlow_CreateVolume_GetVolumeInfo_customdata
        public void Run_3D_CreateVolume_GetVolumeInfo_Customdata_Case1364()
        {
            int runCount = 0;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "WorkFlow CreateVolume_GetVolume_CustomData");

                try
                {
                    VolumeService vs = new VolumeService();
                    string volumeID = null;
                    XMLParameterCollection cInputData = new XMLParameterCollection();
                    XMLParameter cSeriesData = new XMLParameter("series");
                    XMLParameter cVolumeData = new XMLParameter("volume");
                    XMLParameter cSlicePathData = new XMLParameter("slices_path_list");
                    string studyUID = string.Empty;
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        switch (ids.InputParameters.GetParameter(i).Step)
                        {
                            case "na":
                                studyUID = ids.InputParameters.GetParameter(i).Value;
                                break;
                            case "series":
                                cSeriesData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                                break;
                            case "volume":
                                cVolumeData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                                break;
                            case "slices_path_list":
                                cSlicePathData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                                break;

                        }
                    }

                    string ep_3dscanmode = null;
                    string ep_3dscanobject = null;
                    string ep_3dfunctionalmode = null;

                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "get")
                        {
                            switch (ids.ExpectedValues.GetParameter(i).Key)
                            {
                                case "3dscanmode":
                                    ep_3dscanmode = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "3dscanobject":
                                    ep_3dscanobject = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                case "3dfunctionalmode":
                                    ep_3dfunctionalmode = ids.ExpectedValues.GetParameter(i).Value;
                                    break;
                                default:
                                    break;
                            }
                        }
                    }

                    CheckPoint pCreate = new CheckPoint("Create", "WorkFlow CreateVolume_GetVolume_CustomData");
                    r.CheckPoints.Add(pCreate);

                    cInputData.Add(cSeriesData);
                    cInputData.Add(cVolumeData);
                    cInputData.Add(cSlicePathData);
                    XMLResult rslCreate = vs.createVolume(studyUID, cInputData);

                    if (!rslCreate.IsErrorOccured)
                    {
                        pCreate.Result = TestResult.Pass;
                        volumeID = rslCreate.SingleResult;
                        pCreate.Outputs.AddParameter("Create", "CreateVolume_GetVolume_CustomData Success", volumeID);
                    }
                    else
                    {
                        pCreate.Result = TestResult.Fail;
                        pCreate.Outputs.AddParameter("Create", "CreateVolume_GetVolume_CustomData Fail", rslCreate.ResultContent);
                        SaveRound(r);
                        continue;
                    }

                    CheckPoint pGet = new CheckPoint("Get", "WorkFlow CreateVolume_GetVolume_CustomData");
                    r.CheckPoints.Add(pGet);

                    XMLParameter filter = new XMLParameter("volume");
                    filter.AddParameter("internal_id", volumeID);
                    filter.AddParameter("path_type", "all");

                    string str1 = string.Empty;
                    string str2 = string.Empty;
                    string str3 = string.Empty;
                    XMLResult rslget = vs.getVolumeInfo(filter);
                    foreach (XMLParameter p in rslget.MultiResults)
                    {
                        if (p.Name == "volume")
                        {
                            str1 = p.GetParameterValue("3dscanmode");
                            str2 = p.GetParameterValue("3dscanobject");
                            str3 = p.GetParameterValue("3dfunctionalmode");
                        }
                    }

                    if (!rslget.IsErrorOccured && str1 == ep_3dscanmode && str2 == ep_3dscanobject && str3 == ep_3dfunctionalmode)
                    {
                        pGet.Result = TestResult.Pass;
                        pGet.Outputs.AddParameter("Get", "CreateVolume_GetVolume_CustomData Success", rslget.ResultContent);
                        vs.deleteVolume(volumeID);
                    }
                    else
                    {
                        pGet.Result = TestResult.Fail;
                        pGet.Outputs.AddParameter("Get", "CreateVolume_GetVolume_CustomData Fail", rslget.ResultContent);
                    }

                    vs.deleteVolume(volumeID);

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message: ", ex.Message);
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }

            Output();
        }
 public XMLResult createAnalysis(string analysisXml, bool current, bool currentSpecified, string patientInternalID, string thumbnail, XMLParameterCollection uidsXml)
 {
     this.lastResult = new XMLResult(this.InvokeMethod("createAnalysis", new object[] { analysisXml, current, currentSpecified, patientInternalID, thumbnail, uidsXml.GenerateXML() }));
     return this.lastResult;
 }
 public XMLResult setFMSDescription(XMLParameterCollection fmsDescription, string fmsInternalID)
 {
     this.lastResult = new XMLResult(this.InvokeMethod("setFMSDescription", new object[] { fmsDescription.GenerateXML(), fmsInternalID }));
       return this.lastResult;
 }
        //Case 164: 1.3.8_GetFMSDescription_Normal
        public void Run_FMS_GetFMSDescription_Normal_Case164()
        {
            int runCount = 0;
            string acquireType = string.Empty;
            string setFmsDescriptionValue = string.Empty;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Acquisition");
                AcquisitionService acqs = new AcquisitionService();
                FMSService fmss = new FMSService();
                ImageService igs = new ImageService();
                PresentationStateService pss = new PresentationStateService();

                XMLParameter acq = new XMLParameter("acq_info");
                XMLParameterCollection FmsDescColl = new XMLParameterCollection();
                XMLParameter FmsDesc = new XMLParameter("fms");
                XMLParameter FmsPs = new XMLParameter("presentationstate");
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "acquire")
                    {
                        acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "acquireType")
                    {
                        acquireType = ids.InputParameters.GetParameter(i).Key;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "FMSDesc")
                    {
                        FmsDesc.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        setFmsDescriptionValue = ids.InputParameters.GetParameter(i).Value.Replace("\r", "");
                    }
                }

                CheckPoint pAcquire = new CheckPoint("Acquire Image", "Acquisition FMS");
                r.CheckPoints.Add(pAcquire);
                System.Diagnostics.Debug.Print("Acquire start");

                XMLResult rslAcqRVG = acqs.startAcquisition(acq);
                System.Threading.Thread.Sleep(3000);

                switch (acquireType)
                {
                    case "FMS":
                        System.Diagnostics.Debug.Print("FMS Acquire");
                        Utility.AcqFMS(22, 60);
                        break;
                    default:
                        System.Diagnostics.Debug.Print("NOT FMS/PANO/CEPH/CR Acquire");
                        break;
                }

                if (rslAcqRVG.IsErrorOccured)
                {
                    System.Diagnostics.Debug.Print("Acquire fail:");
                    pAcquire.Result = TestResult.Fail;
                    pAcquire.Outputs.AddParameter("Acquire image error", "startAcquisition", rslAcqRVG.Message);
                }
                else
                {
                    pAcquire.Outputs.AddParameter("Acquire session ID", "startAcquisition", rslAcqRVG.SingleResult);
                    int DORVGcount = 0;
                    XMLResult getAcqRVG = new XMLResult();
                    do
                    {
                        System.Threading.Thread.Sleep(3000);
                        System.Diagnostics.Debug.Print("get acquire in do");
                        DORVGcount++;
                        getAcqRVG = acqs.getAcquisitionResult(rslAcqRVG.SingleResult);
                        if (!getAcqRVG.IsErrorOccured)
                        {
                            ParseXMLContent parser = new ParseXMLContent(getAcqRVG.ResultContent); // To parse the return XML

                            string fmsID = parser.getStringWithPathAndType("trophy/object_info", "fms", "value");
                            string[] fmsIDs = fmsID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                            int fmsCount = fmsIDs.Length;

                            string imageID = parser.getStringWithPathAndType("trophy/object_info", "image", "value");
                            string[] imageIDs = imageID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                            int imageCount = imageIDs.Length;

                            string psID = parser.getStringWithPathAndType("trophy/object_info", "presentation_state", "value");
                            string[] psIDs = psID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                            int psCount = psIDs.Length;

                            if (fmsCount == 1 && imageCount >= 1 && psCount >= 1 && imageCount == psCount)
                            {
                                pAcquire.Result = TestResult.Pass;

                                FmsDescColl.Add(FmsDesc);
                                FmsDescColl.Add(FmsPs);

                                CheckPoint pFMS = new CheckPoint("Set FMS Description", "FMS Service");
                                r.CheckPoints.Add(pFMS);

                                string FMSInternalID = fmsIDs[0];
                                XMLResult rslSetFmsDesc = fmss.setFMSDescription(FmsDescColl, FMSInternalID);

                                if (rslSetFmsDesc.IsErrorOccured)
                                {
                                    pFMS.Result = TestResult.Fail;
                                    pFMS.Outputs.AddParameter("Set FMS Result", "FMS Service", rslSetFmsDesc.ResultContent);
                                }

                                XMLResult rslGetFmsDesc = fmss.getFMSDescription(FMSInternalID);
                                if (rslGetFmsDesc.IsErrorOccured)
                                {
                                    pFMS.Result = TestResult.Fail;
                                    pFMS.Outputs.AddParameter("Get FMS Description Fail", "FMS Service", rslGetFmsDesc.ResultContent);
                                }
                                else
                                {
                                    for (int rslCount = 0; rslCount < rslGetFmsDesc.MultiResults.Count; rslCount++)
                                    {
                                        if (rslGetFmsDesc.MultiResults[rslCount].Name == "fms")
                                        {
                                            if (rslGetFmsDesc.MultiResults[rslCount].Parameters[0].ParameterName == "xml_description"
                                              && rslGetFmsDesc.MultiResults[rslCount].Parameters[0].ParameterValue == setFmsDescriptionValue)
                                            {
                                                pFMS.Result = TestResult.Pass;
                                                pFMS.Outputs.AddParameter("Get FMS Description Success", "FMS Service", "Match the setting value");
                                            }
                                        }

                                        if (rslGetFmsDesc.MultiResults[rslCount].Name == "presentationstate")
                                        {
                                            for (int i = 0; i < rslGetFmsDesc.MultiResults[rslCount].Parameters.Count; i++)
                                            {
                                                if (!psID.Contains(rslGetFmsDesc.MultiResults[rslCount].Parameters[i].ParameterValue))
                                                {
                                                    pFMS.Result = TestResult.Fail;
                                                    pFMS.Outputs.AddParameter("Get FMS Description Success", "FMS Service", "Setting PSID is not match");
                                                    break;
                                                }
                                            }
                                        }

                                    }//Check the return value for fms section and ps section
                                }//Get FMS Description end

                                XMLResult delFmsRls = fmss.deleteFMS("true", FMSInternalID);
                                if (delFmsRls.IsErrorOccured)
                                {
                                    pFMS.Result = TestResult.Fail;
                                    pFMS.Outputs.AddParameter("Delete FMS Result", "FMS Service", delFmsRls.Message);
                                    pFMS.Outputs.AddParameter("Delete FMS", "FMS Service", "Delete FMS Error");
                                    break;
                                }

                                pFMS.Result = TestResult.Pass;
                                pFMS.Outputs.AddParameter("Delete FMS Result", "FMS Service", delFmsRls.ResultContent);
                                pFMS.Outputs.AddParameter("Delete FMS and images", "FMS Service", "All images and fms has been deleted");
                            }
                            else
                            {
                                pAcquire.Result = TestResult.Fail;
                                pAcquire.Outputs.AddParameter("getAcquisitionResult", "FMS Service", "No Image or PS id return");
                            }
                            break;
                        }

                        if (getAcqRVG.Code != 0 && getAcqRVG.Code != 499)
                        {
                            pAcquire.Result = TestResult.Fail;
                            pAcquire.Outputs.AddParameter("Get acquire image error", "getAcquisitionResult", getAcqRVG.Message);
                            break;
                        }
                        if (getAcqRVG.IsErrorOccured && getAcqRVG.Code != 499)
                            continue;
                        System.Diagnostics.Debug.Print("get acquireResult:" + DORVGcount);
                        if (DORVGcount > 60)
                        {
                            pAcquire.Result = TestResult.Fail;
                            pAcquire.Outputs.AddParameter("Get acquire image error", "getAcquisitionResult", "Acquire great with 3 minutes, timeout!");
                            break;
                        }
                    } while (true);
                }
                SaveRound(r);
            }
            Output();
        }
 public XMLResult createVolume(string studyId,XMLParameterCollection volumeInfo)
 {
     this.lastResult = new XMLResult(this.InvokeMethod("createVolume", new object[] { studyId, volumeInfo.GenerateXML() }));
     return this.lastResult;
 }
        //Case962: 1.3.12_DeleteAnalysis_N2_Delete Analysis with FMS
        public void Run_Analysis_Acq_DeleteAnalysiswithFMS_Case962()
        {
            int runCount = 0;
            string analysisContent = "<trophy type=\"analysis\" version=\"1.0\">    <trophyheader>        <accesslog>            <creation date=\"2011/10/26\" time=\"14:33:59\" applicationname=\"kdis2dviewer\" applicationversion=\"7.0\" />            <modification date=\"2011/10/26\" time=\"14:33:59\" applicationname=\"kdis2dviewer\" applicationversion=\"7.0\" />        </accesslog>    </trophyheader>    <templateheader>        <object subtype=\"analysis\" instance=\"true\" name=\"2011/10/26 14:33:59\" uid=\"a680942f-ae84-4a18-8dab-cd766bda64da\" />        <comments />        <icon filepath=\"analysisicon.jpg\" />        <icon>            <ObjectData>base64imagedata</ObjectData>        </icon>        <icon id=\"thumbnailid\" />        <AnalysisProp name=\"2011/10/26 14:33:59\" comments=\"\" date=\"2011/10/26\" time=\"14:33:59\" arrangementmode=\"0\" />    </templateheader>    <page index=\"0\" Dx=\"1280\" Dy=\"1024\" backgroundColour=\"RGB(0,0,0)\">        <Frame index=\"1\" type=\"floating panel\" x=\"914\" y=\"142\" w=\"200\" h=\"239\" Zorder=\"\">            <PanelProp paneltype=\"control panel xray\" id=\"control panel xray\" showstate=\"maximized\" />        </Frame>        <Frame index=\"2\" type=\"floating panel\" x=\"914\" y=\"142\" w=\"200\" h=\"240\" Zorder=\"\">            <PanelProp paneltype=\"control panel color\" id=\"control panel color\" showstate=\"maximized\" />        </Frame>        <Frame index=\"3\" type=\"fms\" x=\"697\" y=\"255\" w=\"457\" h=\"323\" Zorder=\"\">            <PanelProp paneltype=\"fms\" id=\"@@FMSID0\" showstate=\"selected\" IdV0=\"@@FMSID0\" />        </Frame>        <Frame index=\"4\" type=\"fms\" x=\"229\" y=\"255\" w=\"457\" h=\"323\" Zorder=\"\">            <PanelProp paneltype=\"fms\" id=\"@@FMSID1\" showstate=\"deselected\" IdV0=\"@@FMSID1\" />        </Frame>    </page></trophy>";
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                Round r = this.NewRound(runCount.ToString(), "Acquisition for Analysis");

                XMLParameter acq = new XMLParameter("acq_info");
                string PatientID = string.Empty;
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "acquire")
                    {
                        if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id")
                        {
                            PatientID = ids.InputParameters.GetParameter(i).Value;
                        }
                        acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }
                string retFmsID = string.Empty;
                string repStr = "@@FMSID";
                XMLParameterCollection anaUidsXML = new XMLParameterCollection();
                XMLParameter anaUids = new XMLParameter("fms");

                for (int acqTime = 0; acqTime < 2; acqTime++)
                {
                    CheckPoint pAcquire = new CheckPoint("Acquire FMS", "Acquire FMS");
                    r.CheckPoints.Add(pAcquire);
                    System.Diagnostics.Debug.Print("Acquire start");

                    retFmsID = AcquisitionService.AcquireFMS(acq);

                    if (!string.IsNullOrEmpty(retFmsID))
                    {
                        pAcquire.Result = TestResult.Pass;
                        pAcquire.Outputs.AddParameter("Acquire FMS", "Acq return correct.", "FMS ID :" + retFmsID);
                        analysisContent = analysisContent.Replace(repStr + acqTime, retFmsID);
                        anaUids.AddParameter("internal_id", retFmsID);
                    }
                    else
                    {
                        pAcquire.Result = TestResult.Fail;
                        pAcquire.Outputs.AddParameter("Acquire FMS", "Acq return error.", "FMS ID :" + retFmsID);
                        goto CLEANUP;
                    }
                }

                CheckPoint pCreateAnalysis = new CheckPoint("Create Analysis", "Create Analysis");
                r.CheckPoints.Add(pCreateAnalysis);

                anaUidsXML.Add(anaUids);
                AnalysisService ass = new AnalysisService();

                XMLResult rslCreateAnalysis = ass.createAnalysis(analysisContent, false, true, PatientID, @"D:\Test\DICOM_Imag_Lib\ImportImage\thumb.PNG", anaUidsXML);

                if (rslCreateAnalysis.IsErrorOccured)
                {
                    pCreateAnalysis.Result = TestResult.Fail;
                    pCreateAnalysis.Outputs.AddParameter("Create Analysis Failed", "Analysis Service", rslCreateAnalysis.ResultContent);
                    break;
                }
                else
                {
                    pCreateAnalysis.Outputs.AddParameter("Create Analysis ID:", "Analysis Service", rslCreateAnalysis.ResultContent);
                }
                XMLResult rsldelAnalysis = ass.deleteAnalysis(rslCreateAnalysis.SingleResult);
                if (rsldelAnalysis.IsErrorOccured)
                {
                    pCreateAnalysis.Result = TestResult.Fail;
                    pCreateAnalysis.Outputs.AddParameter("Delete Analysis Failed", "Analysis Service", rslCreateAnalysis.ResultContent);
                }
                else
                {
                    pCreateAnalysis.Result = TestResult.Pass;
                    pCreateAnalysis.Outputs.AddParameter("Delete Analysis Success", "Analysis Service", rslCreateAnalysis.ResultContent);
                }

            CLEANUP:
                SaveRound(r);
            }
            Output();
        }
        // Case 1560:  1.1.04.03 SetImage_N03_Call setImage for archived image in FMS
        public void Run_Image_SetInfo_ImageInFMS_Case1560()
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    #region Parameter initialize
                    string patientInternalId = string.Empty;
                    string fmsFullPath = string.Empty;
                    string objectFileFullPath = string.Empty;
                    string archivedPath = string.Empty;

                    XMLParameter pSetImageInfo = new XMLParameter("image");
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "importFMS")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id")
                            {
                                patientInternalId = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                fmsFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "importImage")
                        {

                            if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "archivePath")
                            {
                                archivedPath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "setImageInfo")
                        {
                            pSetImageInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                    }
                    #endregion

                    ImportService importService = new ImportService();
                    FMSService fmsSvc = new FMSService();
                    ImageService imageService = new ImageService();

                    #region Step 1-1: Call ImportService.importObject to import FMS
                    string fmsID = string.Empty;

                    CheckPoint cpImportFMS = new CheckPoint("Import Image", "Call ImportService.importObject to import a FMS");
                    r.CheckPoints.Add(cpImportFMS);

                    XMLResult rtImportFMS = importService.importObject(patientInternalId, null, fmsFullPath, null, true, "false");
                    if (rtImportFMS.IsErrorOccured)
                    {
                        cpImportFMS.Result = TestResult.Fail;
                        cpImportFMS.Outputs.AddParameter("Import image returns error", "Import image", rtImportFMS.Message);

                        SaveRound(r);
                        continue; // There is error when create image, end current run
                    }
                    else
                    {
                        cpImportFMS.Result = TestResult.Pass;
                        cpImportFMS.Outputs.AddParameter("Import image returns success", "Import image", rtImportFMS.Message);

                        foreach (XMLParameter p in rtImportFMS.MultiResults)
                        {
                            if (p.Name == "fms")
                            {
                                fmsID = p.Parameters[0].ParameterValue;
                                break;
                            }
                        }
                    }
                    #endregion

                    #region Step 1-2: Call ImportService.importObject to import a image
                    string imageInternalID = string.Empty;
                    string currentPSID = string.Empty;

                    CheckPoint cpImportImage = new CheckPoint("Import Image", "Call ImportService.importObject to import an archived  image");
                    r.CheckPoints.Add(cpImportImage);

                    XMLResult rtImportImage = importService.importObject(patientInternalId, null, objectFileFullPath, archivedPath, true, "false");
                    if (rtImportImage.IsErrorOccured)
                    {
                        cpImportImage.Result = TestResult.Fail;
                        cpImportImage.Outputs.AddParameter("Import image returns error", "Import image", rtImportImage.Message);

                        SaveRound(r);
                        continue; // There is error when create image, end current run
                    }
                    else
                    {
                        cpImportImage.Result = TestResult.Pass;
                        cpImportImage.Outputs.AddParameter("Import image returns success", "Import image", rtImportImage.Message);

                        imageInternalID = rtImportImage.MultiResults[0].Parameters[0].ParameterValue;
                        currentPSID = rtImportImage.MultiResults[1].Parameters[0].ParameterValue;
                    }
                    #endregion

                    #region Step 1-3: Add image into FMS
                    CheckPoint cpSetFMS = new CheckPoint("Set FMS", " Call setFMSDescription to add the archived image into it");
                    r.CheckPoints.Add(cpImportFMS);

                    XMLParameterCollection pSetFMSDescription = new XMLParameterCollection();

                    XMLParameter pFMSDes = new XMLParameter("fms");
                    pFMSDes.AddParameter("xml_description", "");

                    XMLParameter pFMSPS = new XMLParameter("presentationstate");
                    foreach (XMLParameter p in rtImportFMS.MultiResults) //Add original PS
                    {
                        if (p.Name == "presentationstate")
                        {
                            pFMSPS.AddParameter("internal_id", p.Parameters[0].ParameterValue);
                        }
                    }
                    pFMSPS.AddParameter("internal_id", currentPSID);

                    pSetFMSDescription.Add(pFMSDes);
                    pSetFMSDescription.Add(pFMSPS);

                    XMLResult rtSetFMS = fmsSvc.setFMSDescription(pSetFMSDescription, fmsID);

                    if (rtSetFMS.IsErrorOccured)
                    {
                        cpSetFMS.Result = TestResult.Fail;
                        cpSetFMS.Outputs.AddParameter("Set FMS", "setFMSDescription return error: ", rtSetFMS.ResultContent);
                    }
                    else
                    {
                        cpSetFMS.Result = TestResult.Pass;
                    }
                    #endregion

                    #region Step 2-1: Check the getImageDescription return is correct after import image
                    CheckPoint cpGetImageDescriptionAfterImport = new CheckPoint("Check getImageDescription return", "Check getImageDescription return is corerct or not after import image");
                    r.CheckPoints.Add(cpGetImageDescriptionAfterImport);

                    XMLResult rtGetImageDescriptionAfterImport = imageService.getImageDescription(imageInternalID);
                    string imagePathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("path");
                    string archivedPathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("archive_path");
                    string archiveTagAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("tags");

                    if (imagePathAfterImport == string.Empty && archivedPathAfterImport == archivedPath && string.IsNullOrEmpty(archiveTagAfterImport))
                    {
                        cpGetImageDescriptionAfterImport.Result = TestResult.Pass;
                        cpGetImageDescriptionAfterImport.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is correct after import image");
                    }
                    else
                    {
                        cpGetImageDescriptionAfterImport.Result = TestResult.Fail;
                        cpGetImageDescriptionAfterImport.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is not correct after import image. Actually get: " + rtGetImageDescriptionAfterImport.ResultContent);
                    }
                    #endregion

                    #region Step 2-2: Check the info is correct in getImageInfo return after import image
                    CheckPoint cpGetImageInfoAfterImport = new CheckPoint("Check getImageInfo return", "Check getImageInfo return is corerct or not import the image");
                    r.CheckPoints.Add(cpGetImageInfoAfterImport);

                    XMLParameter pGetImageInfoAfterImport = new XMLParameter("image");
                    pGetImageInfoAfterImport.AddParameter("internal_id", imageInternalID);
                    XMLResult rtGetImageInfo = imageService.getImageInfo(pGetImageInfoAfterImport);

                    imagePathAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("path");
                    archivedPathAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("archive_path");
                    archiveTagAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("tags");

                    if (string.IsNullOrEmpty(imagePathAfterImport)) //&& archivedPathAfterImport == archivedPath && archiveTagAfterImport == "archived", will be supported in new service
                    {
                        cpGetImageInfoAfterImport.Result = TestResult.Pass;
                        cpGetImageInfoAfterImport.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is correct after import image");
                    }
                    else
                    {
                        cpGetImageInfoAfterImport.Result = TestResult.Fail;
                        cpGetImageInfoAfterImport.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is not correct after import image. Actually get: " + rtGetImageInfo.ResultContent);
                    }
                    #endregion

                    #region Step 3: Call ImageService.SetImageInfo to save the archived image as normal image
                    CheckPoint cpSetImageInfo = new CheckPoint("Set Image Info", "Call ImageService.SetImageInfo to save the archived image as normal image");
                    r.CheckPoints.Add(cpSetImageInfo);

                    XMLResult rtSetImageInfo = imageService.setImageInfo(pSetImageInfo, imageInternalID);

                    if (rtSetImageInfo.IsErrorOccured)
                    {
                        cpSetImageInfo.Result = TestResult.Fail;
                        cpSetImageInfo.Outputs.AddParameter("SetImageInfo returns error", "SetImageInfo", rtSetImageInfo.Message);
                    }
                    else
                    {
                        cpSetImageInfo.Result = TestResult.Pass;
                        cpSetImageInfo.Outputs.AddParameter("SetImageInfo returns success", "SetImageInfo", rtSetImageInfo.Message);

                        // Wait the file is transferred to server DB
                        System.Threading.Thread.Sleep(3000);

                        // Below to check the info is correct after setImageInfo. Check points includes:
                        //1. The Image ID and PS ID are not changed
                        //2. GetImageDescription return correct image path and archive path, correct archive flag
                        //3. GetImageInfo return correct image path, correct archive flag
                        //4. Use the image path to check the image file is in server DB
                        //5. The original archived image is not deleted

                        //#region Step 3: Check the image is set, not newly created
                        ////PatientService patientSvc = new PatientService();
                        ////patientSvc.listObjects();
                        ////NewPatientService newPatientSvc = new NewPatientService();
                        ////newPatientSvc.listObjects();
                        //#endregion

                        #region Step 4: Check the ps is set, not newly created after set image
                        CheckPoint cpPSID = new CheckPoint("Check PS ID", "Check the PS ID is not changed after call setImageInfo");
                        r.CheckPoints.Add(cpPSID);

                        XMLParameter pListPS = new XMLParameter("filter");
                        pListPS.AddParameter("current", "true");
                        string currentPSIDAfterSet = imageService.listPresentationState(pListPS, imageInternalID).SingleResult; // may need change

                        if (currentPSIDAfterSet == currentPSID)
                        {
                            cpPSID.Result = TestResult.Pass;
                            cpPSID.Outputs.AddParameter("listPresentationState", "Check PS ID", "The PS ID is not changed");
                        }
                        else
                        {
                            cpPSID.Result = TestResult.Fail;
                            cpPSID.Outputs.AddParameter("listPresentationState", "Check PS ID", "The PS ID is changed. Expect: " + currentPSID + "; Actually new PS ID: " + currentPSIDAfterSet);
                        }
                        #endregion

                        string imagePathAfterSet = string.Empty;
                        string archivePathAfterSet = string.Empty;
                        string archiveTagAfterSet = string.Empty;

                        #region Step 5: Check the getImageDescription return is correct after set image
                        CheckPoint cpGetImageDescriptionAfterSet = new CheckPoint("Check getImageDescription return", "Check getImageDescription return is corerct or not after call setImageInfo");
                        r.CheckPoints.Add(cpGetImageDescriptionAfterSet);

                        XMLResult rtGetImageDescriptionAfterSet = imageService.getImageDescription(imageInternalID);
                        imagePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("path");
                        archivePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("archive_path");
                        archiveTagAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("tags");

                        if (imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archiveTagAfterSet)) // imagePathAfterSet sampe: C:/Documents and Settings/All Users/Application Data/TW/PAS/pas_data/patient/03/8af0a7e63310cc65013310d46d0e0003/1956bc28-ca5e-4720-a857-d4de18fc1479/02962f27-e4be-4d59-b112-9663a2f2572b.dcm"
                        {
                            cpGetImageDescriptionAfterSet.Result = TestResult.Pass;
                            cpGetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is correct after set image");
                        }
                        else
                        {
                            cpGetImageDescriptionAfterSet.Result = TestResult.Fail;
                            cpGetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is not correct after set image. Actually get: " + rtGetImageDescriptionAfterSet.ResultContent);
                        }
                        #endregion

                        #region Step 6: Check the getImageinfo return is correct after set image
                        CheckPoint cpGetImageInfoAfterSet = new CheckPoint("Check getImageInfo return", "Check getImageInfo return is corerct or not after call setImageInfo");
                        r.CheckPoints.Add(cpGetImageInfoAfterSet);

                        XMLParameter pGetImageInfoAfterSet = new XMLParameter("image");
                        pGetImageInfoAfterSet.AddParameter("internal_id", imageInternalID);
                        XMLResult rtGetImageInfoAfterSet = imageService.getImageInfo(pGetImageInfoAfterSet);

                        imagePathAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("path");
                        archivePathAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("archive_path");
                        archiveTagAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("tags");

                        if (imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archiveTagAfterSet))
                        {
                            cpGetImageInfoAfterSet.Result = TestResult.Pass;
                            cpGetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is correct after set image");
                        }
                        else
                        {
                            cpGetImageInfoAfterSet.Result = TestResult.Fail;
                            cpGetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is not correct after set image. Actually get: " + rtGetImageInfoAfterSet.ResultContent);
                        }
                        #endregion

                        #region Step 7: Check the file exist in server DB
                        CheckPoint cpImageInDB = new CheckPoint("Check file in DB", "Check the file exist in server DB after call setImageInfo");
                        r.CheckPoints.Add(cpImageInDB);

                        if (Utility.IsImageExistInServerDB(imagePathAfterSet))
                        {
                            cpImageInDB.Result = TestResult.Pass;
                            cpImageInDB.Outputs.AddParameter("Check the file exist in server DB after call setImageInfo", "Check file in DB", "File exist");
                        }
                        else
                        {
                            cpImageInDB.Result = TestResult.Fail;
                            cpImageInDB.Outputs.AddParameter("Check the file exist in server DB after call setImageInfo", "Check file in DB", "File NOT exist");
                        }
                        #endregion

                        #region Step 8: Check the original archived image is not deleted
                        CheckPoint cpOriginalArchivedImage = new CheckPoint("Check original archived file", "Check the original archived image is not deleted after call setImageInfo");
                        r.CheckPoints.Add(cpOriginalArchivedImage);

                        if (System.IO.File.Exists(archivedPath))
                        {
                            cpOriginalArchivedImage.Result = TestResult.Pass;
                            cpOriginalArchivedImage.Outputs.AddParameter("Check the original archived image is not deleted after call setImageInfo", "Check original archived file", "File exist");
                        }
                        else
                        {
                            cpOriginalArchivedImage.Result = TestResult.Fail;
                            cpOriginalArchivedImage.Outputs.AddParameter("Check the original archived image is not deleted after call setImageInfo", "Check original archived file", "File NOT exist");
                        }
                        #endregion
                    }
                    #endregion

                    #region Step 9: Call ImageService.deleteImage to delete the created image
                    CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image");
                    r.CheckPoints.Add(cp_DeleteImage);

                    XMLResult rt_DeleteImage = imageService.deleteImage(imageInternalID, new XMLParameter("preferences"));
                    if (rt_DeleteImage.IsErrorOccured)
                    {
                        cp_DeleteImage.Result = TestResult.Fail;
                        cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message);
                    }
                    else
                    {
                        cp_DeleteImage.Result = TestResult.Pass;
                        cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message);
                    }
                    #endregion

                    #region Step 10: Call FMSService.deleteFMS to delete the FMS
                    CheckPoint cp_DeleteFMS = new CheckPoint("Delete FMS", "Call fmsService.deleteFMS to delete the FMS");
                    r.CheckPoints.Add(cp_DeleteFMS);

                    XMLResult rt_DeleteFMS = fmsSvc.deleteFMS("true", fmsID);
                    if (rt_DeleteFMS.IsErrorOccured)
                    {
                        cp_DeleteFMS.Result = TestResult.Fail;
                        cp_DeleteFMS.Outputs.AddParameter("delete fms", "Delete fms returns error", rt_DeleteFMS.Message);
                    }
                    else
                    {
                        cp_DeleteFMS.Result = TestResult.Pass;
                        cp_DeleteFMS.Outputs.AddParameter("delete fms", "Delete fms returns success", rt_DeleteFMS.Message);
                    }
                    #endregion

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Result = TestResult.Fail;
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message);
                    SaveRound(r);
                }
            }

            Output();
        }
        //Case 1477: 1.9.3.5_getCrossSectionInfo
        //public void Run_3D_CreateVolume_GetVolumeInfo_DeleteVolume_Case1368() //Case 1368: 1.9.1_Create_Get_Delete_Volume_Normal
        //{
        //    int runCount = 0;
        //    foreach (InputDataSet ids in this.Input.DataSets)
        //    {
        //        runCount++;
        //        Round r = this.NewRound(runCount.ToString(), "3D Unit Create_Get_Delete_Volume");
        //        CheckPoint pCreate = new CheckPoint("3D Unit", "3D Unit Create_Get_Delete_Volume");
        //        r.CheckPoints.Add(pCreate);
        //        VolumeService vs = new VolumeService();
        //        XMLParameterCollection cInputData = new XMLParameterCollection();
        //        XMLParameter cSeriesData = new XMLParameter("series");
        //        XMLParameter cVolumeData = new XMLParameter("volume");
        //        XMLParameter cSlicePathData = new XMLParameter("slices_path_list");
        //        string studyUID = string.Empty;
        //        for (int i = 0; i < ids.InputParameters.Count; i++)
        //        {
        //            switch (ids.InputParameters.GetParameter(i).Step)
        //            {
        //                case "na":
        //                    studyUID = ids.InputParameters.GetParameter(i).Value;
        //                    break;
        //                case "series":
        //                    cSeriesData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
        //                    break;
        //                case "volume":
        //                    cVolumeData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
        //                    break;
        //                case "slices_path_list":
        //                    cSlicePathData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
        //                    break;
        //            }
        //        }
        //        cInputData.Add(cSeriesData);
        //        cInputData.Add(cVolumeData);
        //        cInputData.Add(cSlicePathData);
        //        string test = cInputData.GenerateXML();
        //        XMLResult rslCreate = vs.createVolume(studyUID, cInputData);
        //        string volumeID = rslCreate.SingleResult;
        //        XMLParameter filter = new XMLParameter("volume");
        //        filter.AddParameter("internal_id", volumeID);
        //        filter.AddParameter("path_type", "all");
        //        XMLResult rslget = vs.getVolumeInfo(filter);
        //        XMLResult rsldel = vs.deleteVolume(volumeID);
        //        if (!rslCreate.IsErrorOccured && !rslget.IsErrorOccured && !rsldel.IsErrorOccured)
        //        {
        //            pCreate.Result = TestResult.Pass;
        //            pCreate.Outputs.AddParameter("3D Unit", "CRU Volume Success", volumeID);
        //        }
        //        else
        //        {
        //            pCreate.Result = TestResult.Fail;
        //            pCreate.Outputs.AddParameter("3D Unit", "CreateVolume", "Create:" + rslCreate.Message + " Get:" + rslget.Message + " delete:" + rsldel.Message);
        //        }
        //        SaveRound(r);
        //        Output();
        //    }
        //}
        public void Run_3D_GetCrossSectionInfo_Case1477()
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;

                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    //Input parameters
                    string p_volumeUID = null;
                    XMLParameterCollection p_createCrossSection = new XMLParameterCollection();
                    XMLParameter crosssection = new XMLParameter("crosssection");
                    XMLParameter slicesPathList = new XMLParameter("slices_path_list");
                    XMLParameter slicesPSAnnotationList = new XMLParameter("slices_ps_xml_annotation_list");
                    XMLParameter slicesPSGeneralList = new XMLParameter("slices_ps_xml_general_list");
                    XMLParameter slicesPSProcessingList = new XMLParameter("slices_ps_xml_processing_list");

                    XMLParameter slicesThumbnailList = new XMLParameter("slices_ps_thumbnail_path_list");

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "create_volumeUID")
                        {
                            p_volumeUID = ids.InputParameters.GetParameter(i).Value;
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_crosssection")
                        {
                            crosssection.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_path_list")
                        {
                            slicesPathList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_xml_annotation_list")
                        {
                            slicesPSAnnotationList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_xml_general_list")
                        {
                            slicesPSGeneralList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_xml_processing_list")
                        {
                            slicesPSProcessingList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_thumbnail_path_list")
                        {
                            slicesThumbnailList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                    }

                    p_createCrossSection.Add(crosssection);
                    p_createCrossSection.Add(slicesPathList);
                    p_createCrossSection.Add(slicesPSAnnotationList);
                    p_createCrossSection.Add(slicesPSGeneralList);
                    p_createCrossSection.Add(slicesPSProcessingList);
                    p_createCrossSection.Add(slicesThumbnailList);

                    //Expected values
                    XMLParameter getCrossSectionInfoReturnParam = new XMLParameter("crosssection");
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "getCrossSectionInfo")
                        {
                            // Add the key to check and the expected value
                            getCrossSectionInfoReturnParam.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                        }
                    }

                    CrossSectionService crossSectionSvc = new CrossSectionService();
                    #region Step 1: Call CrossSectionService.CreateCrossSection to create a new crosssection
                    CheckPoint cp_Create = new CheckPoint("Create", "Step 1: Call CrossSectionService.CreateCrossSection to create a new crosssection");
                    r.CheckPoints.Add(cp_Create);

                    XMLResult rt_Create = crossSectionSvc.createCrossSection(p_volumeUID, p_createCrossSection);

                    if (rt_Create.IsErrorOccured)
                    {
                        cp_Create.Result = TestResult.Fail;
                        cp_Create.Outputs.AddParameter("Create", "Create a new crosssection returns error", rt_Create.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        cp_Create.Outputs.AddParameter("Create", "Create a new crosssection returns succeess", rt_Create.Message);

                        //Check the "internal_id" in return is present
                        bool isInternalIDCorrect = true;

                        if (rt_Create.SingleResult == null || rt_Create.SingleResult == String.Empty)
                        {
                            isInternalIDCorrect = false;
                        }

                        if (!isInternalIDCorrect)
                        {
                            cp_Create.Result = TestResult.Fail;
                            cp_Create.Outputs.AddParameter("Create", "Create a new crosssection returns wrong internal_id: ", rt_Create.Message);

                            SaveRound(r);
                            break; // There is error, end test case
                        }
                        else
                        {
                            cp_Create.Result = TestResult.Pass;
                            cp_Create.Outputs.AddParameter("Create", "Create a new crosssection returns correct internal_id: ", rt_Create.SingleResult);
                        }
                    }
                    #endregion

                    //System.Threading.Thread.Sleep(3000);  // Add for defect EK_HI00167289, remove this after it's fixed.

                    #region Step 2: Call CrossSectionService.GetCrossSectionInfo to get the crosssection info
                    CheckPoint cpGetCrossSectionInfo = new CheckPoint("GetCrossSectionInfo", "Step 2: Call CrossSectionService.GetCrossSectionInfo to get the crosssection info");
                    r.CheckPoints.Add(cpGetCrossSectionInfo);

                    string p_crossSectionUID = rt_Create.SingleResult;
                    XMLResult rtGetCrossSectionInfo = crossSectionSvc.getCrossSectionInfo(p_crossSectionUID);

                    if (rtGetCrossSectionInfo.IsErrorOccured)
                    {
                        cpGetCrossSectionInfo.Result = TestResult.Fail;
                        cpGetCrossSectionInfo.Outputs.AddParameter("GetCrossSectionInfo", "GetCrossSectionInfo returns error", rtGetCrossSectionInfo.Message);

                        goto CLEANUP;
                    }
                    else // Check the return value details
                    {
                        bool isValueEqual = false;
                        bool isKeyShow = false;

                        foreach (XMLParameterNode psNode in getCrossSectionInfoReturnParam.Parameters)
                        {
                            isValueEqual = false;
                            isKeyShow = false;

                            int i = 0;
                            for (i = 0; i < rtGetCrossSectionInfo.MultiResults[0].Parameters.Count; i++)
                            {
                                if (psNode.ParameterName.ToLower() == rtGetCrossSectionInfo.MultiResults[0].Parameters[i].ParameterName.ToLower())
                                {
                                    isKeyShow = true;
                                    isValueEqual = string.Equals(psNode.ParameterValue, rtGetCrossSectionInfo.MultiResults[0].Parameters[i].ParameterValue);
                                    break; // End current for loop to search node
                                }
                            }

                            if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress
                            {
                                cpGetCrossSectionInfo.Result = TestResult.Fail;

                                if (isKeyShow)
                                {
                                    cpGetCrossSectionInfo.Outputs.AddParameter("GetCrossSectionInfo", "Check the Cross Section info in getCrossSectionInfo return", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rtGetCrossSectionInfo.MultiResults[0].Parameters[i].ParameterValue);
                                }
                                else
                                {
                                    cpGetCrossSectionInfo.Outputs.AddParameter("GetCrossSectionInfo", "Check the Cross Section info in getCrossSectionInfo return", "The return value does not contain the node: " + psNode.ParameterName);
                                }

                                break; // End current foreach loop, not compare the follwing nodes
                            }
                        }

                        if (isValueEqual)
                        {
                            cpGetCrossSectionInfo.Result = TestResult.Pass;
                            cpGetCrossSectionInfo.Outputs.AddParameter("GetCrossSectionInfo", "Check the Cross Section info in getCrossSectionInfo return", "The return values in getCrossSectionInfo all match the expected");
                        }
                    }
                    #endregion

                CLEANUP:
                    #region Step 3: Clean up, delete the crossSection
                    crossSectionSvc.deleteCrossSection(p_crossSectionUID);
                    #endregion

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.ToString());
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }

            Output();
        }
 public XMLResult setAnalysisDescription(string analysisInternalID, string analysisXml, bool current, XMLParameterCollection uidsXml)
 {
     this.lastResult = new XMLResult(this.InvokeMethod("setAnalysisDescription", new object[] { analysisInternalID, analysisXml, current, true, uidsXml.GenerateXML() }));
     return this.lastResult;
 }
        //Case 1503: 1.9.3.1_createCrossSection_localizer_dicom_series_instance_uid_exist
        public void Run_3D_createCrossSection_localizeruid_exist_Case1503()
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;

                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    //Input parameters
                    string crossectionUID_FirstTime = string.Empty;
                    string crossectionUID_SecondTime = string.Empty;

                    string ep_first_localizer_dicom_series_instance_uid = string.Empty;
                    string ep_second_localizer_dicom_series_instance_uid = string.Empty;

                    string p_volumeUID = null;
                    XMLParameterCollection p_createCrossSectionFirstTime = new XMLParameterCollection();
                    XMLParameterCollection p_createCrossSectionSecondTime = new XMLParameterCollection();

                    XMLParameter crosssectionFirstTime = new XMLParameter("crosssection");
                    XMLParameter crosssectionSecondTime = new XMLParameter("crosssection");

                    XMLParameter slicesPathList = new XMLParameter("slices_path_list");
                    XMLParameter slicesPSAnnotationList = new XMLParameter("slices_ps_xml_annotation_list");
                    XMLParameter slicesPSGeneralList = new XMLParameter("slices_ps_xml_general_list");
                    XMLParameter slicesPSProcessingList = new XMLParameter("slices_ps_xml_processing_list");

                    XMLParameter slicesThumbnailList = new XMLParameter("slices_ps_thumbnail_path_list");

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "create_volumeUID")
                        {
                            p_volumeUID = ids.InputParameters.GetParameter(i).Value;
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_crossSection")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "slices_dicom_series_instance_uid")
                            {
                                crosssectionFirstTime.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value + "_firsttime", false);
                                crosssectionSecondTime.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value + "_secondtime", false);
                            }
                            else
                            {
                                crosssectionFirstTime.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                                crosssectionSecondTime.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                                if (ids.InputParameters.GetParameter(i).Key == "first_localizer_dicom_series_instance_uid")
                                {
                                    ep_first_localizer_dicom_series_instance_uid = ids.InputParameters.GetParameter(i).Value; // Record the first_localizer_dicom_series_instance_uid value to check later
                                }
                                else if (ids.InputParameters.GetParameter(i).Key == "second_localizer_dicom_series_instance_uid")
                                {
                                    ep_second_localizer_dicom_series_instance_uid = ids.InputParameters.GetParameter(i).Value; // Record the second_localizer_dicom_series_instance_uid value to check later
                                }
                            }
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_path_list")
                        {
                            slicesPathList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_xml_annotation_list")
                        {
                            slicesPSAnnotationList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_xml_general_list")
                        {
                            slicesPSGeneralList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_xml_processing_list")
                        {
                            slicesPSProcessingList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_thumbnail_path_list")
                        {
                            slicesThumbnailList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                    }

                    p_createCrossSectionFirstTime.Add(crosssectionFirstTime);
                    p_createCrossSectionFirstTime.Add(slicesPathList);
                    p_createCrossSectionFirstTime.Add(slicesPSAnnotationList);
                    p_createCrossSectionFirstTime.Add(slicesPSGeneralList);
                    p_createCrossSectionFirstTime.Add(slicesPSProcessingList);
                    p_createCrossSectionFirstTime.Add(slicesThumbnailList);

                    p_createCrossSectionSecondTime.Add(crosssectionSecondTime);
                    p_createCrossSectionSecondTime.Add(slicesPathList);
                    p_createCrossSectionSecondTime.Add(slicesPSAnnotationList);
                    p_createCrossSectionSecondTime.Add(slicesPSGeneralList);
                    p_createCrossSectionSecondTime.Add(slicesPSProcessingList);
                    p_createCrossSectionSecondTime.Add(slicesThumbnailList);

                    //Output parameter

                    CrossSectionService crossSectionSvc = new CrossSectionService();
                    #region Step 1: Call CrossSectionService.CreateCrossSection to create a new crosssection
                    CheckPoint cp_Create_FirstTime = new CheckPoint("Create", "Step 1: Call CrossSectionService.CreateCrossSection to create a new crosssection");
                    r.CheckPoints.Add(cp_Create_FirstTime);

                    XMLResult rt_Create_FirstTime = crossSectionSvc.createCrossSection(p_volumeUID, p_createCrossSectionFirstTime);

                    if (rt_Create_FirstTime.IsErrorOccured)
                    {
                        cp_Create_FirstTime.Result = TestResult.Fail;
                        cp_Create_FirstTime.Outputs.AddParameter("Create a new crosssection returns error", "Create", rt_Create_FirstTime.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        cp_Create_FirstTime.Outputs.AddParameter("Create  a new crosssection returns succeess", "Create", rt_Create_FirstTime.Message);

                        //Check the "internal_id" in return is present
                        bool isInternalIDCorrect = true;

                        if (rt_Create_FirstTime.SingleResult == null || rt_Create_FirstTime.SingleResult == String.Empty)
                        {
                            isInternalIDCorrect = false;
                        }

                        if (!isInternalIDCorrect)
                        {
                            cp_Create_FirstTime.Result = TestResult.Fail;
                            cp_Create_FirstTime.Outputs.AddParameter("Create  a new crosssection returns wrong internal_id: ", "Create", rt_Create_FirstTime.Message);

                            SaveRound(r);
                            break; // There is error, end test case
                        }
                        else
                        {
                            cp_Create_FirstTime.Result = TestResult.Pass;
                            cp_Create_FirstTime.Outputs.AddParameter("Create  a new crosssection returns correct internal_id: ", "Create", rt_Create_FirstTime.SingleResult);
                        }
                    }
                    #endregion

                    #region Step 2: Create for the second time to resue the localizer
                    CheckPoint cp_Create_SecondTime = new CheckPoint("Create", "Step 2: Call CrossSectionService.CreateCrossSection agian to create new crosssection, given the same localizer uid"); // Create for the second time to resue the localizer
                    r.CheckPoints.Add(cp_Create_SecondTime);
                    XMLResult rt_Create_SecondTime = crossSectionSvc.createCrossSection(p_volumeUID, p_createCrossSectionSecondTime);

                    if (rt_Create_SecondTime.IsErrorOccured)
                    {
                        cp_Create_SecondTime.Result = TestResult.Fail;
                        cp_Create_SecondTime.Outputs.AddParameter("Create  a new crosssection returns error", "Create", rt_Create_SecondTime.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        cp_Create_SecondTime.Outputs.AddParameter("Create  a new crosssection returns succeess", "Create", rt_Create_SecondTime.Message);

                        //Check the "internal_id" in return is present
                        bool isInternalIDCorrect = true;

                        if (rt_Create_SecondTime.SingleResult == null || rt_Create_SecondTime.SingleResult == String.Empty)
                        {
                            isInternalIDCorrect = false;
                        }

                        if (!isInternalIDCorrect)
                        {
                            cp_Create_SecondTime.Result = TestResult.Fail;
                            cp_Create_SecondTime.Outputs.AddParameter("Create  a new crosssection returns wrong internal_id: ", "Create", rt_Create_SecondTime.Message);

                            SaveRound(r);
                            break; // There is error, end test case
                        }
                        else
                        {
                            cp_Create_SecondTime.Result = TestResult.Pass;
                            cp_Create_SecondTime.Outputs.AddParameter("Create a new crosssection returns correct internal_id: ", "Create", rt_Create_SecondTime.SingleResult);
                        }
                    }
                    #endregion

                    #region Step 3: Check the crossSection info is correct
                    CheckPoint cp_CheckCrossSectionCompleteInfo = new CheckPoint("Create", "Step 3-1: Call CrossSectionService.getCrossSectionCompleteInfo to check the localizer info");
                    r.CheckPoints.Add(cp_CheckCrossSectionCompleteInfo);

                    crossectionUID_FirstTime = rt_Create_FirstTime.SingleResult;
                    crossectionUID_SecondTime = rt_Create_SecondTime.SingleResult;

                    // call getCrossSectionCompleteInfo
                    XMLResult rt_getCrossSectionCompleteInfoForFirstCreate = crossSectionSvc.getCrossSectionCompleteInfo(crossectionUID_FirstTime);
                    XMLResult rt_getCrossSectionCompleteInfoForSecondCreate = crossSectionSvc.getCrossSectionCompleteInfo(crossectionUID_SecondTime);

                    string first_localizer_dicom_series = "<parameter key=\"first_localizer_dicom_series_instance_uid\" value=\"" + ep_first_localizer_dicom_series_instance_uid + "\" />";   //<parameter key="first_localizer_dicom_series_instance_uid" value="%loc1_dicom_series_instance_uid%" />
                    string second_localizer_dicom_series = "<parameter key=\"second_localizer_dicom_series_instance_uid\" value=\"" + ep_second_localizer_dicom_series_instance_uid + "\" />"; //<parameter key="second_localizer_dicom_series_instance_uid" value="%loc2_dicom_series_instance_uid%" />
                    if (rt_getCrossSectionCompleteInfoForFirstCreate.ResultContent.Contains(first_localizer_dicom_series) && rt_getCrossSectionCompleteInfoForFirstCreate.ResultContent.Contains(second_localizer_dicom_series) && rt_getCrossSectionCompleteInfoForSecondCreate.ResultContent.Contains(first_localizer_dicom_series) && rt_getCrossSectionCompleteInfoForSecondCreate.ResultContent.Contains(second_localizer_dicom_series))
                    {
                        cp_CheckCrossSectionCompleteInfo.Outputs.AddParameter("The localizer info in GetCrossSectionCompleteInfo is correct", "GetCrossSectionCompleteInfo", "");
                        cp_CheckCrossSectionCompleteInfo.Result = TestResult.Pass;
                    }
                    else
                    {
                        cp_CheckCrossSectionCompleteInfo.Outputs.AddParameter("The localizer info in GetCrossSectionCompleteInfo is wrong", "GetCrossSectionCompleteInfo", "");
                        cp_CheckCrossSectionCompleteInfo.Result = TestResult.Fail;
                    }
                    cp_CheckCrossSectionCompleteInfo.Outputs.AddParameter("The GetCrossSectionCompleteInfo return for the first CrossSection is: ", "GetCrossSectionCompleteInfo", rt_getCrossSectionCompleteInfoForFirstCreate.ResultContent);
                    cp_CheckCrossSectionCompleteInfo.Outputs.AddParameter("The GetCrossSectionCompleteInfo return for the second CrossSection is: ", "GetCrossSectionCompleteInfo", rt_getCrossSectionCompleteInfoForSecondCreate.ResultContent);

                    // Call listImagesOfCrossSection
                    CheckPoint cp_CheckListImagesOfCrossSection = new CheckPoint("Create", "Step 3-2: Call CrossSectionService.listImagesOfCrossSection to check the localizer info");
                    r.CheckPoints.Add(cp_CheckListImagesOfCrossSection);

                    XMLResult rt_listImagesOfCrossSectionForFirstCreate = crossSectionSvc.listImagesOfCrossSection(crossectionUID_FirstTime);
                    XMLResult rt_listImagesOfCrossSectionForSecondCreate = crossSectionSvc.listImagesOfCrossSection(crossectionUID_SecondTime);

                    /**************************************
                     retrun sample:
                         <trophy type="result" version="1.0">
                            <status code="%error_code%" message="%error_message%" />
                            <images_list>
                                <parameter key="first_localizer_internal_id" value="%image_uid%" />
                                <parameter key="second_localizer_internal_id" value="%image_uid%" />
                                <parameter key="slice_internal_id" value="%image_uid%" />
                                ...
                            </images_list>
                         </trophy>
                     * *************************************/

                    string first_localizer_internal_id_FirstCreate = string.Empty;
                    string second_localizer_internal_id_FirstCreate = string.Empty;
                    string first_localizer_internal_id_SecondCreate = string.Empty;
                    string second_localizer_internal_id_SecondCreate = string.Empty;

                    foreach (XMLParameterNode node in rt_listImagesOfCrossSectionForFirstCreate.MultiResults[0].Parameters)
                    {
                        switch (node.ParameterName)
                        {
                            case "first_localizer_internal_id":
                                first_localizer_internal_id_FirstCreate = node.ParameterValue;
                                break;
                            case "second_localizer_internal_id":
                                second_localizer_internal_id_FirstCreate = node.ParameterValue;
                                break;
                            default:
                                break;
                        }
                    }
                    foreach (XMLParameterNode node in rt_listImagesOfCrossSectionForSecondCreate.MultiResults[0].Parameters)
                    {
                        switch (node.ParameterName)
                        {
                            case "first_localizer_internal_id":
                                first_localizer_internal_id_SecondCreate = node.ParameterValue;
                                break;
                            case "second_localizer_internal_id":
                                second_localizer_internal_id_SecondCreate = node.ParameterValue;
                                break;
                            default:
                                break;
                        }
                    }
                    if (first_localizer_internal_id_FirstCreate == first_localizer_internal_id_SecondCreate && second_localizer_internal_id_FirstCreate == second_localizer_internal_id_SecondCreate)
                    {
                        cp_CheckListImagesOfCrossSection.Outputs.AddParameter("The localizer info in listImagesOfCrossSection is correct", "listImagesOfCrossSection", "");
                        cp_CheckListImagesOfCrossSection.Result = TestResult.Pass;
                    }
                    else
                    {
                        cp_CheckListImagesOfCrossSection.Outputs.AddParameter("The localizer info in listImagesOfCrossSection is wrong", "listImagesOfCrossSection", "");
                        cp_CheckListImagesOfCrossSection.Result = TestResult.Fail;
                    }
                    cp_CheckListImagesOfCrossSection.Outputs.AddParameter("The localizer info in listImagesOfCrossSection for the first crossSection is: ", "listImagesOfCrossSection", rt_listImagesOfCrossSectionForFirstCreate.ResultContent);
                    cp_CheckListImagesOfCrossSection.Outputs.AddParameter("The localizer info in listImagesOfCrossSection for the second crossSection is: ", "listImagesOfCrossSection", rt_listImagesOfCrossSectionForSecondCreate.ResultContent);

                    #endregion

                    #region Step 4: Call CrossSectionService.deleteCrossSection to delete the created crosssection
                    System.Collections.Generic.List<string> crossSectionUIDList = new System.Collections.Generic.List<string>();
                    crossSectionUIDList.Add(crossectionUID_FirstTime);
                    crossSectionUIDList.Add(crossectionUID_SecondTime);

                    foreach (string p_crossectionUID in crossSectionUIDList)
                    {
                        CheckPoint cp_Delete = new CheckPoint("Delete", "Step 4: Call CrossSectionService.deleteCrossSection to delete the created crosssection");
                        r.CheckPoints.Add(cp_Delete);

                        XMLResult rt_Delete = crossSectionSvc.deleteCrossSection(p_crossectionUID);

                        if (rt_Delete.IsErrorOccured)
                        {
                            cp_Delete.Result = TestResult.Fail;
                            cp_Delete.Outputs.AddParameter("Delete the created crosssection returns error", "Delete", rt_Delete.Message);

                            SaveRound(r);
                            break; // There is error, end test case
                        }
                        else
                        {
                            cp_Delete.Result = TestResult.Pass;
                            cp_Delete.Outputs.AddParameter("Delete the created crosssection returns succeess. ID is: ", "Delete", p_crossectionUID);
                        }
                    }
                    #endregion

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.ToString());
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }

            Output();
        }
        public void Run_WorkFlow_3Dv_createVolume_with_created_and_set_a3d_Case1660()  //  //case 1.9.1_WorkFlow_3Dv_createVolume_with_created_and_set_a3d
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    #region Parameter initialize

                    string volumeID = "";
                    //for create volume
                    XMLParameter cSeriesData = new XMLParameter("series");
                    XMLParameter cVolumeData = new XMLParameter("volume");
                    XMLParameter cSlicePathData = new XMLParameter("slices_path_list");
                    //for create study
                    XMLParameter studyPara = new XMLParameter("request");
                    XMLParameter xmlAnalysisInfo = new XMLParameter("analysis3d");

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        switch (ids.InputParameters.GetParameter(i).Step)
                        {
                            case "series":
                                cSeriesData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                                break;
                            case "volume":
                                cVolumeData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                                break;
                            case "slices_path_list":
                                cSlicePathData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                                break;
                            case "study":
                                studyPara.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "seta3d":
                                xmlAnalysisInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                        }
                    }
                    #endregion

                    #region Step 0: Create Study
                    string studyUID = string.Empty;
                    StudyService stusrv = new StudyService();
                    XMLResult stuRsl = stusrv.createStudy(studyPara);
                    if (stuRsl.IsErrorOccured)
                    {
                        continue;
                    }
                    else
                    {
                        studyUID = stuRsl.SingleResult;
                    }

                    #endregion

                    #region Step 1: Create Volume
                    CheckPoint cpCreateVolume = new CheckPoint("Create Volume Info", "Call createVolume");
                    r.CheckPoints.Add(cpCreateVolume);
                    XMLParameterCollection cInputData = new XMLParameterCollection();


                    cInputData.Add(cSeriesData);
                    cInputData.Add(cVolumeData);
                    cInputData.Add(cSlicePathData);
                    VolumeService volumesrv = new VolumeService();
                    XMLResult rslCreate = volumesrv.createVolume(studyUID, cInputData);
                    if (rslCreate.IsErrorOccured)
                    {
                        cpCreateVolume.Result = TestResult.Fail;
                        cpCreateVolume.Outputs.AddParameter("Create Volume Info", "Call createVolume", rslCreate.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        cpCreateVolume.Result = TestResult.Pass;
                        cpCreateVolume.Outputs.AddParameter("Create Volume Info", "Call createVolume", rslCreate.ResultContent);
                        volumeID = rslCreate.SingleResult;
                    }
                    #endregion

                    #region Step 2: Create Analysis3D
                    CheckPoint cpCreateA3d = new CheckPoint("Create Analysis3D", "Call createAnalysis3D");
                    r.CheckPoints.Add(cpCreateA3d);
                    Analysis3DService a3dsrv = new Analysis3DService();
                    XMLParameter a3dpara = new XMLParameter("analysis3d");
                    a3dpara.AddParameter("analysis3D_xml", "analysis3D_xml");
                    XMLResult a3dcreateRsl = a3dsrv.createAnalysis3D(volumeID, a3dpara);
                    string a3duid = "";
                    if (a3dcreateRsl.IsErrorOccured)
                    {
                        cpCreateA3d.Result = TestResult.Fail;
                        cpCreateA3d.Outputs.AddParameter("Create Analysis3D", "Call createAnalysis3D", a3dcreateRsl.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        cpCreateA3d.Result = TestResult.Pass;
                        cpCreateA3d.Outputs.AddParameter("Create Analysis3D", "Call createAnalysis3D", a3dcreateRsl.ResultContent);
                        a3duid = a3dcreateRsl.SingleResult;
                    }

                    #endregion

                    #region Step 3: Set Analysis3D
                    CheckPoint cpSetA3d = new CheckPoint("Set Analysis3D", "Call setAnalysis3DInfo");
                    r.CheckPoints.Add(cpSetA3d);
                    XMLResult seta3dRsl = a3dsrv.setAnalysis3DInfo(a3duid, xmlAnalysisInfo);
                    if (seta3dRsl.IsErrorOccured)
                    {
                        cpSetA3d.Result = TestResult.Fail;
                        cpSetA3d.Outputs.AddParameter("Set Analysis3D", "Call setAnalysis3DInfo", seta3dRsl.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        XMLResult geta3dRsl = a3dsrv.getAnalysis3DInfo(a3duid);

                        int matchCount = 0;

                        for (int j = 0; j < geta3dRsl.MultiResults[0].Length; j++)
                        {
                            if (geta3dRsl.MultiResults[0].Parameters[j].ParameterName == "name"
                                && geta3dRsl.MultiResults[0].Parameters[j].ParameterValue == "modified analysis 3d")
                            {
                                matchCount++;
                            }
                            if (geta3dRsl.MultiResults[0].Parameters[j].ParameterName == "comments"
                                && geta3dRsl.MultiResults[0].Parameters[j].ParameterValue == "set with some modification")
                            {
                                matchCount++;
                            }
                            if (geta3dRsl.MultiResults[0].Parameters[j].ParameterName == "current"
                                && geta3dRsl.MultiResults[0].Parameters[j].ParameterValue == "true")
                            {
                                matchCount++;
                            }
                            if (geta3dRsl.MultiResults[0].Parameters[j].ParameterName == "object_creation_date"
                                && geta3dRsl.MultiResults[0].Parameters[j].ParameterValue == "2012-12-05T15:25:00+08:00")
                            {
                                matchCount++;
                            }

                        }

                        if (matchCount == 4)
                        {
                            cpSetA3d.Result = TestResult.Pass;
                            cpSetA3d.Outputs.AddParameter("Set Analysis3D", "Call setAnalysis3DInfo", seta3dRsl.ResultContent);
                        }
                        else
                        {
                            cpSetA3d.Result = TestResult.Fail;
                            cpSetA3d.Outputs.AddParameter("Set Analysis3D", "Call setAnalysis3DInfo", "The set value is not equal with get");
                        }


                    }

                    #endregion

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Result = TestResult.Fail;
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message);
                    SaveRound(r);
                }
            }

            Output();
        }
        // Case 1159: 1.9.3.2_deleteCrossSection
        public void Run_3D_DeleteCrossSection_Case1159()
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;

                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    //Input parameters
                    string p_volumeUID = null;
                    XMLParameterCollection p_createCrossSection = new XMLParameterCollection();
                    XMLParameter crosssection = new XMLParameter("crosssection");
                    XMLParameter slicesPathList = new XMLParameter("slices_path_list");
                    XMLParameter slicesPSAnnotationList = new XMLParameter("slices_ps_xml_annotation_list");
                    XMLParameter slicesPSGeneralList = new XMLParameter("slices_ps_xml_general_list");
                    XMLParameter slicesPSProcessingList = new XMLParameter("slices_ps_xml_processing_list");

                    XMLParameter slicesThumbnailList = new XMLParameter("slices_ps_thumbnail_path_list");

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "create_volumeUID")
                        {
                            p_volumeUID = ids.InputParameters.GetParameter(i).Value;
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_crosssection")
                        {
                            crosssection.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_path_list")
                        {
                            slicesPathList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_xml_annotation_list")
                        {
                            slicesPSAnnotationList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_xml_general_list")
                        {
                            slicesPSGeneralList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_xml_processing_list")
                        {
                            slicesPSProcessingList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "create_slices_ps_thumbnail_path_list")
                        {
                            slicesThumbnailList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false);
                        }
                    }

                    p_createCrossSection.Add(crosssection);
                    p_createCrossSection.Add(slicesPathList);
                    p_createCrossSection.Add(slicesPSAnnotationList);
                    p_createCrossSection.Add(slicesPSGeneralList);
                    p_createCrossSection.Add(slicesPSProcessingList);
                    p_createCrossSection.Add(slicesThumbnailList);

                    CrossSectionService crossSectionSvc = new CrossSectionService();
                    #region Step 1: Call CrossSectionService.CreateCrossSection to create a new crosssection
                    CheckPoint cp_Create = new CheckPoint("Create", "Step 1: Call CrossSectionService.CreateCrossSection to create a new crosssection");
                    r.CheckPoints.Add(cp_Create);

                    XMLResult rt_Create = crossSectionSvc.createCrossSection(p_volumeUID, p_createCrossSection);

                    if (rt_Create.IsErrorOccured)
                    {
                        cp_Create.Result = TestResult.Fail;
                        cp_Create.Outputs.AddParameter("Create", "Create a new crosssection returns error", rt_Create.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        cp_Create.Outputs.AddParameter("Create", "Create a new crosssection returns succeess", rt_Create.Message);

                        //Check the "internal_id" in return is present
                        bool isInternalIDCorrect = true;

                        if (rt_Create.SingleResult == null || rt_Create.SingleResult == String.Empty)
                        {
                            isInternalIDCorrect = false;
                        }

                        if (!isInternalIDCorrect)
                        {
                            cp_Create.Result = TestResult.Fail;
                            cp_Create.Outputs.AddParameter("Create", "Create a new crosssection returns wrong internal_id: ", rt_Create.Message);

                            SaveRound(r);
                            break; // There is error, end test case
                        }
                        else
                        {
                            cp_Create.Result = TestResult.Pass;
                            cp_Create.Outputs.AddParameter("Create", "Create a new crosssection returns correct internal_id: ", rt_Create.SingleResult);
                        }
                    }
                    #endregion

                    #region Step 2: Call CrossSectionService.deleteCrossSection to delete the created crosssection
                    string p_crossectionUID = rt_Create.SingleResult;
                    CheckPoint cp_Delete = new CheckPoint("Delete", "Step 2: Call CrossSectionService.deleteCrossSection to delete the created crosssection");
                    r.CheckPoints.Add(cp_Delete);

                    XMLResult rt_Delete = crossSectionSvc.deleteCrossSection(p_crossectionUID);

                    if (rt_Delete.IsErrorOccured)
                    {
                        cp_Delete.Result = TestResult.Fail;
                        cp_Delete.Outputs.AddParameter("Delete", "Delete the created crosssection returns error", rt_Delete.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        //Check the "internal_id" in return is present
                        bool isActuallyDeleted = true;
                        // To add the check

                        if (!isActuallyDeleted)
                        {
                            cp_Delete.Result = TestResult.Fail;
                            cp_Delete.Outputs.AddParameter("Delete", "The crosssection is not corroctly deleted", rt_Delete.Message);

                            SaveRound(r);
                            break; // There is error, end test case
                        }
                        else
                        {
                            cp_Delete.Result = TestResult.Pass;
                            cp_Delete.Outputs.AddParameter("Delete", "Delete the created crosssection returns succeess", rt_Delete.Message);
                        }
                    }
                    #endregion

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.ToString());
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }

            Output();
        }
        public void Run_WorkFlow_3Dv_createCross_link_a3d_Case1686()  //  //case 1.9.3_WorkFlow_3Dv_createCross_link_a3d
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    #region Parameter initialize

                    string volumeID = "";
                    //for create volume
                    XMLParameter cSeriesData = new XMLParameter("series");
                    XMLParameter cVolumeData = new XMLParameter("volume");
                    XMLParameter cSlicePathData = new XMLParameter("slices_path_list");
                    //for create study
                    XMLParameter studyPara = new XMLParameter("request");
                    XMLParameter xmlAnalysisInfo = new XMLParameter("analysis3d");
                    //for create cross section
                    XMLParameter crosssection = new XMLParameter("crosssection");
                    XMLParameter slicesPathList = new XMLParameter("slices_path_list");
                    XMLParameter slicesPSAnnotationList = new XMLParameter("slices_ps_xml_annotation_list");
                    XMLParameter slicesPSGeneralList = new XMLParameter("slices_ps_xml_general_list");
                    XMLParameter slicesPSProcessingList = new XMLParameter("slices_ps_xml_processing_list");
                    XMLParameter slicesThumbnailList = new XMLParameter("slices_ps_thumbnail_path_list");

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        switch (ids.InputParameters.GetParameter(i).Step)
                        {
                            case "series":
                                cSeriesData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "volume":
                                cVolumeData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "slices_path_list":
                                cSlicePathData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "study":
                                studyPara.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "seta3d":
                                xmlAnalysisInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "create_crossSection":
                                crosssection.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "create_slices_path_list":
                                slicesPathList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "create_slices_ps_xml_annotation_list":
                                slicesPSAnnotationList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "create_slices_ps_xml_general_list":
                                slicesPSGeneralList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "create_slices_ps_xml_processing_list":
                                slicesPSProcessingList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "create_slices_ps_thumbnail_path_list":
                                slicesThumbnailList.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                        }
                    }
                    #endregion

                    #region Step 0: Create Study
                    string studyUID = string.Empty;
                    StudyService stusrv = new StudyService();
                    XMLResult stuRsl = stusrv.createStudy(studyPara);
                    if (stuRsl.IsErrorOccured)
                    {
                        continue;
                    }
                    else
                    {
                        studyUID = stuRsl.SingleResult;
                    }

                    #endregion

                    #region Step 1: Create Volume
                    CheckPoint cpCreateVolume = new CheckPoint("Create Volume Info", "Call createVolume");
                    r.CheckPoints.Add(cpCreateVolume);
                    XMLParameterCollection cInputData = new XMLParameterCollection();


                    cInputData.Add(cSeriesData);
                    cInputData.Add(cVolumeData);
                    cInputData.Add(cSlicePathData);
                    VolumeService volumesrv = new VolumeService();
                    XMLResult rslCreate = volumesrv.createVolume(studyUID, cInputData);
                    if (rslCreate.IsErrorOccured)
                    {
                        cpCreateVolume.Result = TestResult.Fail;
                        cpCreateVolume.Outputs.AddParameter("Create Volume Info", "Call createVolume", rslCreate.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        cpCreateVolume.Result = TestResult.Pass;
                        cpCreateVolume.Outputs.AddParameter("Create Volume Info", "Call createVolume", rslCreate.ResultContent);
                        volumeID = rslCreate.SingleResult;
                    }
                    #endregion

                    #region Step 2: Create Analysis3D
                    CheckPoint cpCreateA3d = new CheckPoint("Create Analysis3D", "Call createAnalysis3D");
                    r.CheckPoints.Add(cpCreateA3d);
                    Analysis3DService a3dsrv = new Analysis3DService();
                    XMLParameter a3dpara = new XMLParameter("analysis3d");
                    a3dpara.AddParameter("analysis3D_xml", "analysis3D_xml");
                    XMLResult a3dcreateRsl = a3dsrv.createAnalysis3D(volumeID, a3dpara);
                    string a3duid = "";
                    if (a3dcreateRsl.IsErrorOccured)
                    {
                        cpCreateA3d.Result = TestResult.Fail;
                        cpCreateA3d.Outputs.AddParameter("Create Analysis3D", "Call createAnalysis3D", a3dcreateRsl.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        cpCreateA3d.Result = TestResult.Pass;
                        cpCreateA3d.Outputs.AddParameter("Create Analysis3D", "Call createAnalysis3D", a3dcreateRsl.ResultContent);
                        a3duid = a3dcreateRsl.SingleResult;
                    }

                    #endregion

                    #region Step 3: Create Cross Section
                    CheckPoint cpCreateCSS = new CheckPoint("Create Analysis3D", "Call createAnalysis3D");
                    r.CheckPoints.Add(cpCreateCSS);


                    XMLParameterCollection p_createCrossSection = new XMLParameterCollection();
                    p_createCrossSection.Add(crosssection);
                    p_createCrossSection.Add(slicesPathList);
                    p_createCrossSection.Add(slicesPSAnnotationList);
                    p_createCrossSection.Add(slicesPSGeneralList);
                    p_createCrossSection.Add(slicesPSProcessingList);
                    p_createCrossSection.Add(slicesThumbnailList);

                    CrossSectionService crossSectionSvc = new CrossSectionService();
                    XMLResult rt_Create = crossSectionSvc.createCrossSection(volumeID, p_createCrossSection);

                    if (rt_Create.IsErrorOccured)
                    {
                        cpCreateCSS.Result = TestResult.Fail;
                        cpCreateCSS.Outputs.AddParameter("Create", "Create a new crosssection returns error", rt_Create.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        cpCreateCSS.Outputs.AddParameter("Create", "Create a new crosssection returns succeess", rt_Create.Message);

                        //Check the "internal_id" in return is present
                        bool isInternalIDCorrect = true;

                        if (rt_Create.SingleResult == null || rt_Create.SingleResult == String.Empty)
                        {
                            isInternalIDCorrect = false;
                        }

                        if (!isInternalIDCorrect)
                        {
                            cpCreateCSS.Result = TestResult.Fail;
                            cpCreateCSS.Outputs.AddParameter("Create", "Create a new crosssection returns wrong internal_id: ", rt_Create.Message);

                            SaveRound(r);
                            break; // There is error, end test case
                        }
                        else
                        {
                            cpCreateCSS.Result = TestResult.Pass;
                            cpCreateCSS.Outputs.AddParameter("Create", "Create a new crosssection returns correct internal_id: ", rt_Create.SingleResult);

                            string crosssectionuid = rt_Create.SingleResult;

                            CheckPoint cplinkcstoa3d = new CheckPoint("link CrossSection To Analysis3D", "Call linkCrossSectionToAnalysis3D");
                            r.CheckPoints.Add(cplinkcstoa3d);

                            //link cs to a3d
                            XMLResult linkRsl = a3dsrv.linkCrossSectionToAnalysis3D(a3duid, crosssectionuid);
                            if (linkRsl.IsErrorOccured)
                            {
                                cplinkcstoa3d.Result = TestResult.Fail;
                                cplinkcstoa3d.Outputs.AddParameter("Link Fail", "Link Cross Section to Analysis3D", "Return ERROR");
                            }
                            else
                            {
                                XMLResult getcsuidfroma3d = a3dsrv.listCrossSectionsOfAnalysis3D(a3duid);
                                if (!getcsuidfroma3d.IsErrorOccured)
                                {
                                    if (crosssectionuid == getcsuidfroma3d.SingleResult)
                                    {
                                        cplinkcstoa3d.Result = TestResult.Pass;
                                        cplinkcstoa3d.Outputs.AddParameter("Link Success", "Link Cross Section to Analysis3D", "Return Cross Section is matched with link");
                                    }
                                }
                            }
                        }
                    }
                    #endregion

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Result = TestResult.Fail;
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message);
                    SaveRound(r);
                }
            }

            Output();
        }
 public XMLResult createCrossSection(string volumeUID, XMLParameterCollection crossSectionInfo)
 {
     this.lastResult = new XMLResult(this.InvokeMethod("createCrossSection", new object[] { volumeUID, crossSectionInfo.GenerateXML() }));
     return this.lastResult;
 }
        public void Run_WorkFlow_3Dv_createA3D_Case1688()  //  //case 1.9.2_WorkFlow_3Dv_createA3D
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    #region Parameter initialize

                    string volumeID = "";
                    string criteriaOfAnalysis = "";
                    //for create volume
                    XMLParameter cSeriesData = new XMLParameter("series");
                    XMLParameter cVolumeData = new XMLParameter("volume");
                    XMLParameter cSlicePathData = new XMLParameter("slices_path_list");
                    //for create study
                    XMLParameter studyPara = new XMLParameter("request");
                    XMLParameter xmlAnalysisInfo = new XMLParameter("analysis3d");

                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        switch (ids.InputParameters.GetParameter(i).Step)
                        {
                            case "series":
                                cSeriesData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "volume":
                                cVolumeData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "slices_path_list":
                                cSlicePathData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "study":
                                studyPara.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "Analyses3D")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "criteria")
                            {
                                criteriaOfAnalysis = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                    }
                    #endregion

                    #region Step 0: Create Study
                    string studyUID = string.Empty;
                    StudyService stusrv = new StudyService();
                    XMLResult stuRsl = stusrv.createStudy(studyPara);
                    if (stuRsl.IsErrorOccured)
                    {
                        continue;
                    }
                    else
                    {
                        studyUID = stuRsl.SingleResult;
                    }

                    #endregion

                    #region Step 1: Create Volume
                    CheckPoint cpCreateVolume = new CheckPoint("Create Volume Info", "Call createVolume");
                    r.CheckPoints.Add(cpCreateVolume);
                    XMLParameterCollection cInputData = new XMLParameterCollection();

                    cInputData.Add(cSeriesData);
                    cInputData.Add(cVolumeData);
                    cInputData.Add(cSlicePathData);
                    VolumeService volumesrv = new VolumeService();
                    XMLResult rslCreate = volumesrv.createVolume(studyUID, cInputData);
                    if (rslCreate.IsErrorOccured)
                    {
                        cpCreateVolume.Result = TestResult.Fail;
                        cpCreateVolume.Outputs.AddParameter("Create Volume Info", "Call createVolume", rslCreate.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        cpCreateVolume.Result = TestResult.Pass;
                        cpCreateVolume.Outputs.AddParameter("Create Volume Info", "Call createVolume", rslCreate.ResultContent);
                        volumeID = rslCreate.SingleResult;
                    }
                    #endregion

                    #region Step 2: Create Analysis3D
                    CheckPoint cpCreateA3d = new CheckPoint("Create Analysis3D", "Call createAnalysis3D");
                    r.CheckPoints.Add(cpCreateA3d);
                    Analysis3DService a3dsrv = new Analysis3DService();
                    XMLParameter a3dpara = new XMLParameter("analysis3d");
                    a3dpara.AddParameter("analysis3D_xml", "analysis3D_xml");
                    XMLResult a3dcreateRsl = a3dsrv.createAnalysis3D(volumeID, a3dpara);
                    string a3duid = "";
                    if (a3dcreateRsl.IsErrorOccured)
                    {
                        cpCreateA3d.Result = TestResult.Fail;
                        cpCreateA3d.Outputs.AddParameter("Create Analysis3D", "Call createAnalysis3D", a3dcreateRsl.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        cpCreateA3d.Result = TestResult.Pass;
                        cpCreateA3d.Outputs.AddParameter("Create Analysis3D", "Call createAnalysis3D", a3dcreateRsl.ResultContent);
                        a3duid = a3dcreateRsl.SingleResult;
                    }

                    #endregion

                    #region Step 3: listAnalyses3DOfVolume
                    CheckPoint cpGetA3dofVolume = new CheckPoint("Get Analysis3D from volume", "Call listAnalyses3DOfVolume");
                    r.CheckPoints.Add(cpGetA3dofVolume);

                    XMLResult geta3dfromvolume = volumesrv.listAnalyses3DOfVolume(volumeID, criteriaOfAnalysis);

                    if (geta3dfromvolume.IsErrorOccured)
                    {
                        cpGetA3dofVolume.Result = TestResult.Fail;
                        cpGetA3dofVolume.Outputs.AddParameter("Get Analysis3D from volume", "Call listAnalyses3DOfVolume", geta3dfromvolume.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        if (a3duid == geta3dfromvolume.SingleResult)
                        {
                            cpGetA3dofVolume.Result = TestResult.Pass;
                            cpGetA3dofVolume.Outputs.AddParameter("Get Analysis3D from volume", "Call listAnalyses3DOfVolume", geta3dfromvolume.ResultContent);
                        }
                    }

                    #endregion
                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Result = TestResult.Fail;
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message);
                    SaveRound(r);
                }
            }

            Output();
        }
        //Case 78: 1.3.7_GetPresentationStateInfo_Exception
        public void Run_PS_GetPresentationStateInfo_Exception_Case78()
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Test PresentationState Service: getPresentationStateInfo");

                try
                {
                    #region Parameter initialize
                    //Input parameters
                    XMLParameterCollection p_getPresentationStateInfo = new XMLParameterCollection();
                    XMLParameter p_PSID = new XMLParameter("presentationstate");
                    XMLParameter p_Preferences = new XMLParameter("preferences");
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "getPresentationStateInfo")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "internal_id")
                            {
                                p_PSID.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "teeth_number_notation")
                            {
                                p_Preferences.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                            }
                        }
                    }
                    p_getPresentationStateInfo.Add(p_PSID);
                    p_getPresentationStateInfo.Add(p_Preferences);

                    // Output value
                    bool ep_isReturnOK = true;
                    string ep_ReturnValue = string.Empty;
                    string ep_imageID = string.Empty;
                    XMLParameter ep_getPresentationStateInfo = new XMLParameter("presentationstate");
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "getPresentationStateInfo")
                        {
                            switch (ids.ExpectedValues.GetParameter(i).Key)
                            {
                                case "returnState":
                                    {
                                        if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("pass"))
                                        {
                                            ep_isReturnOK = true;
                                        }
                                        else if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("fail"))
                                        {
                                            ep_isReturnOK = false;
                                        }
                                        break;
                                    }
                                case "returnMessage":
                                    {
                                        ep_ReturnValue = ids.ExpectedValues.GetParameter(i).Value;
                                        break;
                                    }
                                default:
                                    {
                                        ep_getPresentationStateInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                                        break;
                                    }
                            }
                        }
                    }
                    #endregion

                    PresentationStateService psService = new PresentationStateService();

                    #region Step 1: Call PresentationStateService.GetPresentationStateInfo to get a PS for the image
                    CheckPoint cp_GetPresentationStateInfo = new CheckPoint("Get PS Info", "Call PresentationStateService.GetPresentationStateInfo to get ps info");
                    r.CheckPoints.Add(cp_GetPresentationStateInfo);

                    XMLResult rt_GetPresentationStateInfo = psService.getPresentationStateInfo(p_getPresentationStateInfo);
                    if (true == ep_isReturnOK) // Expect the call returns OK
                    {
                        if (rt_GetPresentationStateInfo.IsErrorOccured)
                        {
                            cp_GetPresentationStateInfo.Result = TestResult.Fail;
                            cp_GetPresentationStateInfo.Outputs.AddParameter("get", "Get PS returns error", rt_GetPresentationStateInfo.Message);
                        }
                        else
                        {
                            cp_GetPresentationStateInfo.Result = TestResult.Pass;
                            cp_GetPresentationStateInfo.Outputs.AddParameter("get", "Get PS returns succeed", rt_GetPresentationStateInfo.Message);

                            // Check the return value is correct
                            #region Step 2: Check the values in PresentationStateService.getPresentationStateInfo return are correct
                            CheckPoint cp_getPSInfoReturn = new CheckPoint("Get PS Info", "Check the values in PresentationStateService.GetPresentationStateInfo return");
                            r.CheckPoints.Add(cp_getPSInfoReturn);

                            bool isValueEqual = false;
                            bool isKeyShow = false;

                            foreach (XMLParameterNode psNode in ep_getPresentationStateInfo.Parameters)
                            {
                                isValueEqual = false;
                                isKeyShow = false;

                                int i = 0;
                                for (i = 0; i < rt_GetPresentationStateInfo.MultiResults[0].Parameters.Count; i++)
                                {
                                    if (psNode.ParameterName == rt_GetPresentationStateInfo.MultiResults[0].Parameters[i].ParameterName)
                                    {
                                        isKeyShow = true;
                                        isValueEqual = string.Equals(psNode.ParameterValue, rt_GetPresentationStateInfo.MultiResults[0].Parameters[i].ParameterValue);
                                        break; // End current for loop to search node
                                    }
                                }

                                if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress
                                {
                                    cp_getPSInfoReturn.Result = TestResult.Fail;

                                    if (isKeyShow)
                                    {
                                        System.Diagnostics.Debug.Print("The return value in getPresentationStateInfo does not match the expected.");
                                        cp_getPSInfoReturn.Outputs.AddParameter("PS Info", "Check the values in PresentationStateService.getPresentationStateInfo return", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetPresentationStateInfo.MultiResults[0].Parameters[i].ParameterValue);
                                    }
                                    else
                                    {
                                        System.Diagnostics.Debug.Print("The return value in getPresentationStateInfo does not contain the node: " + psNode.ParameterName);
                                        cp_getPSInfoReturn.Outputs.AddParameter("PS Info", "Check the values in PresentationStateService.getPresentationStateInfo return", "The return value does not contain the node: " + psNode.ParameterName);
                                    }

                                    break; // End current foreach loop, not compare the follwing nodes
                                }
                            }

                            if (isValueEqual)
                            {
                                cp_getPSInfoReturn.Result = TestResult.Pass;

                                System.Diagnostics.Debug.Print("The return values in getPresentationStateInfo all match the expected.");
                                cp_getPSInfoReturn.Outputs.AddParameter("PS Info", "Check the values in PresentationStateService.getPresentationStateInfo return", "The return values all match the expected");
                            }
                            #endregion
                        }
                    }
                    else // Expect the call return error
                    {
                        if (rt_GetPresentationStateInfo.IsErrorOccured) // There is error
                        {
                            if (rt_GetPresentationStateInfo.Message.ToLower().Contains(ep_ReturnValue.ToLower()))
                            {
                                cp_GetPresentationStateInfo.Result = TestResult.Pass;
                                cp_GetPresentationStateInfo.Outputs.AddParameter("get", "Get PS Info returns error as expected", rt_GetPresentationStateInfo.Message);
                            }
                            else
                            {
                                cp_GetPresentationStateInfo.Result = TestResult.Fail;
                                cp_GetPresentationStateInfo.Outputs.AddParameter("get", "Get PS Info returns error message not match the expected. ", "Expect: " + ep_ReturnValue + "; Actually returns: " + rt_GetPresentationStateInfo.Message);
                            }
                        }
                        else // There is no error
                        {
                            cp_GetPresentationStateInfo.Result = TestResult.Fail;
                            cp_GetPresentationStateInfo.Outputs.AddParameter("get", "Get PS Info not returns error as expected. ", "Actually returns: " + rt_GetPresentationStateInfo.Message);
                        }
                    }
                    #endregion

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message);
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }

            Output();
        }
        //Case 980: 1.3.17_workflow_CSI select a patient, open an image and then close it
        public void Run_WorkFlow_CSIOpenImageAndClose_Case980()
        {
            // Test Case added for work flow: CSI select a patient to list all the image, click to open one of them and then save and close it.

            PatientService patientService = new PatientService();
            AcquisitionService acquisitionService = new AcquisitionService();
            PresentationStateService presentationStateService = new PresentationStateService();
            AnalysisService analysisService = new AnalysisService();

            string patientUID = null;
            XMLParameter setAsynAcqPatientInfoParam = new XMLParameter("acq_info");
            XMLParameter listObjectForPSParam = new XMLParameter("filter");
            XMLParameterCollection getPresentionStateInfoParam = new XMLParameterCollection();
            XMLParameter listObjectForVolumeParam = new XMLParameter("filter");
            XMLParameter listObjectForFMSParam = new XMLParameter("filter");
            XMLParameter listObjectForOtherParam = new XMLParameter("filter");

            XMLParameter setPresentationStateParam = new XMLParameter("presentationstate");
            XMLParameter setPresentationStateInfoParam = new XMLParameter("presentationstate");

            XMLParameter listObjectForAnalysisParam = new XMLParameter("filter");
            XMLParameter setAnalysisInfoParam = new XMLParameter("analysis");

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                Round r = new Round();

                try
                {
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "getPatient")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patientInternalID")
                            {
                                patientUID = ids.InputParameters.GetParameter(i).Value;
                            }
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "setAsynAcqPatientInfo")
                        {
                            setAsynAcqPatientInfoParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "listObjectForPS")
                        {
                            listObjectForPSParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "listObjectForVolume")
                        {
                            listObjectForVolumeParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "listObjectForFMS")
                        {
                            listObjectForFMSParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "listObjectForOther")
                        {
                            listObjectForOtherParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "listObjectForAnalysis")
                        {
                            listObjectForAnalysisParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "setPresentationStateInfo")
                        {
                            setPresentationStateInfoParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }

                        if (ids.InputParameters.GetParameter(i).Step == "setAnalysisInfo")
                        {
                            setAnalysisInfoParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                    }

                    #region Step 1: Check the specific patient exists in Database
                    CheckPoint pGetPatient = new CheckPoint("getPatient", "Step 1: Get the specific patient info");
                    r.CheckPoints.Add(pGetPatient);

                    XMLResult getPatientResult = patientService.getPatient(patientUID);

                    if (getPatientResult.IsErrorOccured)
                    {
                        pGetPatient.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Get the specific patient info fail:");
                        pGetPatient.Outputs.AddParameter("getPatient", "get the specific patient info", getPatientResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pGetPatient.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Get the specific patient info succeed:");
                        pGetPatient.Outputs.AddParameter("getPatient", "get the specific patient info", getPatientResult.Message);
                    }
                    #endregion

                    // Step 2 - Step 7 are what to do after select a patient

                    #region Step 2: set asyn acq patient with the specific patient
                    CheckPoint pSetAsynAcqPatientInfo = new CheckPoint("setAsynAcqPatientInfo", "Step 2: call setAsynAcqPatientInfo to set asyn acq patient info");
                    r.CheckPoints.Add(pSetAsynAcqPatientInfo);

                    XMLResult setAsynAcqPatientInfoResult = acquisitionService.setAsynAcqPatientInfo(setAsynAcqPatientInfoParam);

                    if (setAsynAcqPatientInfoResult.IsErrorOccured)
                    {
                        pSetAsynAcqPatientInfo.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Set asyn acq PatientInfo fail:");
                        pSetAsynAcqPatientInfo.Outputs.AddParameter("setAsynAcqPatientInfo", "set asyn acq patient info", setAsynAcqPatientInfoResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pSetAsynAcqPatientInfo.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Set asyn acq PatientInfo succeed:");
                        pSetAsynAcqPatientInfo.Outputs.AddParameter("setAsynAcqPatientInfo", "set asyn acq patient info", setAsynAcqPatientInfoResult.Message);
                    }
                    #endregion

                    #region Step 3: Call listObject to get the presentation state list of the patient
                    CheckPoint pListObjectForPS = new CheckPoint("listObjectForPS", "Step 3: call listObject to get PS info");
                    r.CheckPoints.Add(pListObjectForPS);

                    XMLResult listObjectForPSResult = patientService.listObjects(listObjectForPSParam);

                    if (listObjectForPSResult.IsErrorOccured)
                    {
                        pListObjectForPS.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get PS info fail:");
                        pListObjectForPS.Outputs.AddParameter("listObject", "listObject to get PS", listObjectForPSResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForPS.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get PS info succeed:");
                        pListObjectForPS.Outputs.AddParameter("listObject", "listObject to get PS", listObjectForPSResult.Message);

                    }
                    #endregion

                    #region Step 4: Call getPresentationStateInfo to get the presentationstate info according to the presentationstate internal_id

                    CheckPoint pGetPresentionStateInfo = new CheckPoint("getPresentionStateInfo", "Step 4: call getPresentationStateInfo to get presention state info");
                    r.CheckPoints.Add(pGetPresentionStateInfo);

                    foreach (XMLParameter param in listObjectForPSResult.MultiResults)
                    {
                        getPresentionStateInfoParam.Add(param);
                    }

                    XMLResult getPresentationStateInfoResult = presentationStateService.getPresentationStateInfo(getPresentionStateInfoParam);

                    if (getPresentationStateInfoResult.IsErrorOccured)
                    {
                        pGetPresentionStateInfo.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call getPresentationStateInfo to get PS info fail:");
                        pGetPresentionStateInfo.Outputs.AddParameter("getPresentationStateInfo", "getPresentationStateInfo to get PS info", getPresentationStateInfoResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pGetPresentionStateInfo.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call getPresentationStateInfo to get PS info succeed:");
                        pGetPresentionStateInfo.Outputs.AddParameter("getPresentationStateInfo", "getPresentationStateInfo to get PS info", getPresentationStateInfoResult.Message);

                    }
                    #endregion

                    #region Step 5: Call listObject to get the volume list of the patient
                    CheckPoint pListObjectForVolume = new CheckPoint("listObjectForVolume", "Step 5: call listObject to get volume info");
                    r.CheckPoints.Add(pListObjectForVolume);

                    XMLResult listObjectForVolumeResult = patientService.listObjects(listObjectForVolumeParam);

                    if (listObjectForVolumeResult.IsErrorOccured)
                    {
                        pListObjectForVolume.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get volume info fail:");
                        pListObjectForVolume.Outputs.AddParameter("listObject", "listObject to get volume", listObjectForVolumeResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForVolume.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get volume info succeed:");
                        pListObjectForVolume.Outputs.AddParameter("listObject", "listObject to get volume", listObjectForVolumeResult.Message);

                    }
                    #endregion

                    #region Step 6: Call listObject to get the FMS list of the patient
                    CheckPoint pListObjectForFMS = new CheckPoint("listObjectForFMS", "Step 6: call listObject to get FMS info");
                    r.CheckPoints.Add(pListObjectForFMS);

                    XMLResult listObjectForFMSResult = patientService.listObjects(listObjectForFMSParam);

                    if (listObjectForFMSResult.IsErrorOccured)
                    {
                        pListObjectForFMS.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get FMS info fail:");
                        pListObjectForFMS.Outputs.AddParameter("listObject", "listObject to get FMS", listObjectForFMSResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForFMS.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get FMS info succeed:");
                        pListObjectForFMS.Outputs.AddParameter("listObject", "listObject to get FMS", listObjectForFMSResult.Message);

                    }
                    #endregion

                    #region Step 7: Call listObject to get the other info of the patient
                    CheckPoint pListObjectForOther = new CheckPoint("listObjectForOther", "Step 7: call listObject to get other info");
                    r.CheckPoints.Add(pListObjectForOther);

                    XMLResult listObjectForOtherResult = patientService.listObjects(listObjectForOtherParam);

                    if (listObjectForOtherResult.IsErrorOccured)
                    {
                        pListObjectForOther.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get other info fail:");
                        pListObjectForOther.Outputs.AddParameter("listObject", "listObject to get other", listObjectForOtherResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForOther.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get other info succeed:");
                        pListObjectForOther.Outputs.AddParameter("listObject", "listObject to get other", listObjectForOtherResult.Message);

                    }
                    #endregion

                    // After double click an image to open it, it will repeat step 3 to step 7
                    // When open image, it will call getPresentationState to get the presentation state, which can be used in setPresentationState step later
                    string presentationStateInternalID = null;
                    XMLParameterCollection setPresentationStateParamList = new XMLParameterCollection();

                    foreach (XMLParameterNode psNode in listObjectForPSResult.ArrayResult.Parameters)
                    {
                        presentationStateInternalID = psNode.ParameterValue;

                        XMLResult getPresentationStateResult = presentationStateService.getPresentationState(presentationStateInternalID);

                        setPresentationStateParam = getPresentationStateResult.ArrayResult;
                        setPresentationStateParamList.Add(setPresentationStateParam);
                    }

                    // Close the image, it will do step 8 to step 10
                    #region Step 8: Call setPresentationState to set presentation state, not change the presentation state value, just set it back
                    CheckPoint pSetPresentationState = new CheckPoint("setPresentationState", "Step 8: call setPresentationState to set the presentation state after close the image");
                    r.CheckPoints.Add(pSetPresentationState);

                    XMLResult setPresentationStateResult = new XMLResult();

                    foreach (XMLParameter presentationStateInfo in setPresentationStateParamList)
                    {
                        setPresentationStateResult = presentationStateService.setPresentationState(presentationStateInfo, presentationStateInternalID);

                        if (setPresentationStateResult.IsErrorOccured)
                        {
                            pSetPresentationState.Result = TestResult.Fail;
                            break;
                        }
                        else
                        {
                            pSetPresentationState.Result = TestResult.Pass;
                        }

                    }

                    if (pSetPresentationState.Result == TestResult.Fail)
                    {
                        System.Diagnostics.Debug.Print("Call setPresentationState to set presentation state fail:");
                        pSetPresentationState.Outputs.AddParameter("setPresentationState", "setPresentationState to set presentation state", setPresentationStateResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        System.Diagnostics.Debug.Print("Call setPresentationState to set presentation state succeed:");
                        pSetPresentationState.Outputs.AddParameter("setPresentationState", "setPresentationState to set presentation state", setPresentationStateResult.Message);
                    }
                    #endregion

                    #region Step 9: Call setPresentationStateInfo to set the presentation state info
                    CheckPoint pSetPresentationStateInfo = new CheckPoint("setPresentationStateInfo", "Step 9: call setPresentationStateInfo to set the presentation state info after close the image");
                    r.CheckPoints.Add(pSetPresentationStateInfo);

                    XMLResult setPresentationStateInfoResult = new XMLResult();

                    foreach (XMLParameter presentationStateInfoParam in getPresentationStateInfoResult.MultiResults)
                    {
                        presentationStateInternalID = presentationStateInfoParam.GetParameterValueByName("internal_id");

                        setPresentationStateInfoResult = presentationStateService.setPresentationStateInfo(setPresentationStateInfoParam, presentationStateInternalID);

                        if (setPresentationStateInfoResult.IsErrorOccured)
                        {
                            pSetPresentationStateInfo.Result = TestResult.Fail;
                            break;
                        }
                        else
                        {
                            pSetPresentationStateInfo.Result = TestResult.Pass;
                        }
                    }

                    if (pSetPresentationStateInfo.Result == TestResult.Fail)
                    {
                        System.Diagnostics.Debug.Print("Call setPresentationStateInfo to set presentation state info fail:");
                        pSetPresentationStateInfo.Outputs.AddParameter("setPresentationStateInfo", "setPresentationState to set presentation state info", setPresentationStateInfoResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        System.Diagnostics.Debug.Print("Call setPresentationStateInfo to set presentation state info succeed:");
                        pSetPresentationStateInfo.Outputs.AddParameter("setPresentationState", "setPresentationState to set presentation state info", setPresentationStateInfoResult.Message);
                    }
                    #endregion

                    #region Step 10: Call listObject to get the presentation state
                    CheckPoint pListObjectForPS2 = new CheckPoint("listObjectForPS", "Step 10: call listObject to get PS info after close image");
                    r.CheckPoints.Add(pListObjectForPS2);

                    XMLResult listObjectForPSResult2 = patientService.listObjects(listObjectForPSParam);

                    if (listObjectForPSResult2.IsErrorOccured)
                    {
                        pListObjectForPS.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get PS info fail:");
                        pListObjectForPS2.Outputs.AddParameter("listObject", "listObject to get PS", listObjectForPSResult2.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForPS2.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get PS info succeed:");
                        pListObjectForPS2.Outputs.AddParameter("listObject", "listObject to get PS", listObjectForPSResult2.Message);

                    }
                    #endregion

                    #region Step 11: Call getPresentationStateInfo to get the presentation state info
                    CheckPoint pGetPresentionStateInfo2 = new CheckPoint("getPresentionStateInfo", "Step 11: call getPresentationStateInfo to get presention state info after close image");
                    r.CheckPoints.Add(pGetPresentionStateInfo2);

                    XMLResult getPresentationStateInfoResult2 = presentationStateService.getPresentationStateInfo(getPresentionStateInfoParam);

                    if (getPresentationStateInfoResult2.IsErrorOccured)
                    {
                        pGetPresentionStateInfo2.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call getPresentationStateInfo to get PS info fail:");
                        pGetPresentionStateInfo2.Outputs.AddParameter("getPresentationStateInfo", "getPresentationStateInfo to get PS info", getPresentationStateInfoResult2.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pGetPresentionStateInfo2.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call getPresentationStateInfo to get PS info succeed:");
                        pGetPresentionStateInfo2.Outputs.AddParameter("getPresentationStateInfo", "getPresentationStateInfo to get PS info", getPresentationStateInfoResult2.Message);

                    }
                    #endregion

                    // Close the viewer
                    #region Step 12: Call listObject to get the analysis
                    CheckPoint pListObjectForAnalysis = new CheckPoint("listObjectForAnalysis", "Step 12: call listObject to get analysis info");
                    r.CheckPoints.Add(pListObjectForAnalysis);

                    XMLResult listObjectForAnalysisResult = patientService.listObjects(listObjectForAnalysisParam);

                    if (listObjectForAnalysisResult.IsErrorOccured)
                    {
                        pListObjectForAnalysis.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call listObject to get analysis info fail:");
                        pListObjectForAnalysis.Outputs.AddParameter("listObject", "listObject to get analysis", listObjectForAnalysisResult.Message);

                        SaveRound(r);
                        break;
                    }
                    else
                    {
                        pListObjectForAnalysis.Result = TestResult.Pass;

                        System.Diagnostics.Debug.Print("Call listObject to get analysis info succeed:");
                        pListObjectForAnalysis.Outputs.AddParameter("listObject", "listObject to get analysis", listObjectForAnalysisResult.Message);
                    }
                    #endregion

                    string analysisId = null;
                    analysisId = listObjectForAnalysisResult.SingleResult;

                    if (analysisId == null || analysisId == string.Empty)
                    {
                        // Below Step are excuted when there is no analysis before

                        #region Step 13: createAnalysis
                        CheckPoint pCreateAnalysis = new CheckPoint("createAnalysis", "Step 13: call createAnalysis to create new analysis");
                        r.CheckPoints.Add(pCreateAnalysis);

                        XMLResult createAnalysisResult = new XMLResult();

                        XMLParameter analysisXml = new XMLParameter("analysis");
                        XMLParameterCollection uidsXml = new XMLParameterCollection();
                        XMLParameter presentationStateUids = new XMLParameter("presentationstate");
                        XMLParameter fmsUids = new XMLParameter("fms");
                        uidsXml.Add(presentationStateUids);
                        uidsXml.Add(fmsUids);

                        createAnalysisResult = analysisService.createAnalysis(analysisXml.GenerateXML().ToString(), true, true, patientUID, null, uidsXml);
                        // public XMLResult createAnalysis(string analysisXml, bool current, bool currentSpecified, string patientInternalID, string thumbnail, XMLParameterCollection uidsXml);
                        if (createAnalysisResult.IsErrorOccured)
                        {
                            System.Diagnostics.Debug.Print("Call createAnalysis to create analysis fail:");
                            pCreateAnalysis.Outputs.AddParameter("createAnalysis", "createAnalysis to create analysis", createAnalysisResult.Message);

                            SaveRound(r);
                            break;
                        }
                        else
                        {
                            System.Diagnostics.Debug.Print("Call createAnalysis to create analysis succeed:");
                            pCreateAnalysis.Outputs.AddParameter("createAnalysis", "createAnalysis to create analysis", createAnalysisResult.Message);
                        }
                        #endregion

                        #region Step 14: Call AnalysisService.setAnalysisInfo to set the analysis info
                        CheckPoint pSetAnalysisInfo = new CheckPoint("setAnalysisInfo", "Step 14: call setAnalysisInfo to set the analysis info");
                        r.CheckPoints.Add(pSetAnalysisInfo);

                        XMLResult setAnalysisInfoResult = new XMLResult();

                        analysisId = createAnalysisResult.MultiResults[0].GetParameterValueByName("internal_id");

                        setAnalysisInfoResult = analysisService.setAnalysisInfo(analysisId, setAnalysisInfoParam);

                        if (setAnalysisInfoResult.IsErrorOccured)
                        {
                            System.Diagnostics.Debug.Print("Call setAnalysisInfo to set analysis info fail:");
                            pSetAnalysisInfo.Outputs.AddParameter("setAnalysisInfo", "setAnalysisInfo to set analysis info", setAnalysisInfoResult.Message);

                            SaveRound(r);
                            break;
                        }
                        else
                        {
                            System.Diagnostics.Debug.Print("Call setAnalysisInfo to set analysis info succeed:");
                            pSetAnalysisInfo.Outputs.AddParameter("setAnalysisInfo", "setAnalysisInfo to set analysis info", setAnalysisInfoResult.Message);
                        }
                        #endregion
                    }

                    else
                    {
                        // Below Step 15 to Step 17 are excuted when there is analysis exist before...

                        #region Step 15: Call AnalysisService.getAnalysisInfo to get the analysis info
                        CheckPoint pGetAnalysisInfo = new CheckPoint("getAnalysisInfo", "Step 15: call getAnalysisInfo to get the analysis info");
                        r.CheckPoints.Add(pGetAnalysisInfo);

                        XMLResult getAnalysisInfoResult = new XMLResult();

                        getAnalysisInfoResult = analysisService.getAnalysisInfo(analysisId);

                        if (getAnalysisInfoResult.IsErrorOccured)
                        {
                            pGetAnalysisInfo.Result = TestResult.Fail;
                            System.Diagnostics.Debug.Print("Call getAnalysisInfo to get analysis info fail:");
                            pGetAnalysisInfo.Outputs.AddParameter("getAnalysisInfo", "getAnalysisInfo to get analysis info", getAnalysisInfoResult.Message);

                            SaveRound(r);
                            break;
                        }
                        else
                        {
                            pGetAnalysisInfo.Result = TestResult.Pass;
                            System.Diagnostics.Debug.Print("Call getAnalysisInfo to get analysis info succeed:");
                            pGetAnalysisInfo.Outputs.AddParameter("getAnalysisInfo", "getAnalysisInfo to get analysis info", getAnalysisInfoResult.Message);
                        }
                        #endregion

                        #region Step 16: Call AnalysisService.setAnalysisDescription to set analysis description
                        CheckPoint pSetAnalysisDescription = new CheckPoint("setAnalysisDescription", "Step 16: call setAnalysisDescription to set the analysis description");
                        r.CheckPoints.Add(pSetAnalysisDescription);

                        XMLResult setAnalysisDescriptionResult = new XMLResult();

                        XMLParameter analysisXml = new XMLParameter("analysis");
                        XMLParameterCollection uidsXml = new XMLParameterCollection();
                        XMLParameter presentationStateUids = new XMLParameter("presentationstate");
                        XMLParameter fmsUids = new XMLParameter("fms");
                        uidsXml.Add(presentationStateUids);
                        uidsXml.Add(fmsUids);

                        setAnalysisDescriptionResult = analysisService.setAnalysisDescription(analysisId, analysisXml.GenerateXML(), false, uidsXml);

                        if (setAnalysisDescriptionResult.IsErrorOccured)
                        {
                            pSetAnalysisDescription.Result = TestResult.Fail;
                            System.Diagnostics.Debug.Print("Call setAnalysisDescription to set the analysis description fail:");
                            pSetAnalysisDescription.Outputs.AddParameter("setAnalysisDescription", "call set the analysis description", setAnalysisDescriptionResult.Message);

                            SaveRound(r);
                            break;
                        }
                        else
                        {
                            pSetAnalysisDescription.Result = TestResult.Pass;
                            System.Diagnostics.Debug.Print("Call setAnalysisDescription to set the analysis description succeed:");
                            pSetAnalysisDescription.Outputs.AddParameter("setAnalysisDescription", "call set the analysis description", setAnalysisDescriptionResult.Message);
                        }
                        #endregion

                        #region Step 17: Call AnalysisService.setAnalysisInfo to set the analysis info
                        CheckPoint pSetAnalysisInfo = new CheckPoint("setAnalysisInfo", "Step 17: call setAnalysisInfo to set the analysis info");
                        r.CheckPoints.Add(pSetAnalysisInfo);

                        XMLResult setAnalysisInfoResult = new XMLResult();

                        setAnalysisInfoResult = analysisService.setAnalysisInfo(analysisId, setAnalysisInfoParam);

                        if (setAnalysisInfoResult.IsErrorOccured)
                        {
                            pSetAnalysisInfo.Result = TestResult.Fail;
                            System.Diagnostics.Debug.Print("Call setAnalysisInfo to set analysis info fail:");
                            pSetAnalysisInfo.Outputs.AddParameter("setAnalysisInfo", "setAnalysisInfo to set analysis info", setAnalysisInfoResult.Message);

                            SaveRound(r);
                            break;
                        }
                        else
                        {
                            pSetAnalysisInfo.Result = TestResult.Pass;
                            System.Diagnostics.Debug.Print("Call setAnalysisInfo to set analysis info succeed:");
                            pSetAnalysisInfo.Outputs.AddParameter("setAnalysisInfo", "setAnalysisInfo to set analysis info", setAnalysisInfoResult.Message);
                        }
                        #endregion
                    }

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message);
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }

            Output();
        }
        //Case 1094: 1.3.7_WorkFlow_ImportDICOMImage+GetPresentationStateInfo_RadioLogInformation
        public void Run_PS_ImportDicom_RadioLog_Case1094()
        {
            //int runCount = this.Input.Repetition;

            int runCount = 0; // this is the initial run count. Use this count to repeat different test data set.

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Test round");

                //Mark the check point here to indicate what's the check point here
                CheckPoint p1 = new CheckPoint("createPatient", "Setup environment of createPatient");
                CheckPoint p2 = new CheckPoint("importObject", "Setup environment of importObject");
                CheckPoint p3 = new CheckPoint("getImageInfo", "Test getImageInfo");
                CheckPoint p4 = new CheckPoint("getPresentationStateInfo", "Test getPresentationStateInfo");

                r.CheckPoints.Add(p1);
                r.CheckPoints.Add(p2);
                r.CheckPoints.Add(p3);
                r.CheckPoints.Add(p4);

                //create required PAS service instaces here
                PatientService pats = new PatientService();
                ImportService ims = new ImportService();
                ImageService img = new ImageService();
                PresentationStateService ps = new PresentationStateService();

                //create input parameters here, it may include XML path type and string type value
                XMLParameter pa1 = new XMLParameter("patient");
                XMLParameter pa2 = new XMLParameter("importObject");
                XMLParameter pa3 = new XMLParameter("image");
                XMLParameter ps4 = new XMLParameter("presentationstate");
                XMLParameterCollection pa4 = new XMLParameterCollection();

                try
                {
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        switch (ids.InputParameters.GetParameter(i).Step)
                        {
                            case "createPatient":
                                pa1.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            case "importObject":
                                pa2.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                                break;
                            default:
                                Console.WriteLine("There is no valid selection when parse input parameters.");
                                break;
                        }
                    }

                    //If we need change parameter by specific logic, please put code here

                    //Get service result
                    //Step1 result

                    XMLResult step1_result = pats.createPatient(pa1);

                    //Log step1 service output
                    if (step1_result.IsErrorOccured)
                    {
                        p1.Result = TestResult.Fail;
                        p1.Outputs.AddParameter("Step 1: createPatient", "Error", step1_result.ResultContent);
                        SaveRound(r);
                        continue;
                    }

                    p1.Result = TestResult.Pass;
                    p1.Outputs.AddParameter("Step 1: createPatient", "Success", step1_result.ResultContent);

                    //Change input parameter according the output of Step1
                    pa2.AddParameter("patientInternalId", step1_result.SingleResult);

                    //Step2 result

                    //if objectFileFullPath is empty string, skip step2
                    if (pa2.GetParameterValueByName("objectFileFullPath") != null && pa2.GetParameterValueByName("objectFileFullPath") != "")
                    {
                        XMLResult step2_result = ims.importObject(pa2.GetParameterValueByName("patientInternalId"), "", pa2.GetParameterValueByName("objectFileFullPath"), "", false, "");

                        //Log step2 service output
                        if (step2_result.IsErrorOccured)
                        {
                            p2.Result = TestResult.Fail;
                            p2.Outputs.AddParameter("Step 2: importObject", "Error", step2_result.ResultContent);
                            SaveRound(r);
                            continue;
                        }

                        p2.Result = TestResult.Pass;
                        p2.Outputs.AddParameter("Step 2: importObject", "Success", step2_result.ResultContent);

                        //Change input parameter according the output of Step2
                        // if step2 is skipped, step3 input has no need parameter of internal_id

                        for (int i = 0; i < step2_result.MultiResults.Count; i++)
                        {
                            if (step2_result.MultiResults[i].Name == "image")
                            {
                                pa3.AddParameter("internal_id", step2_result.MultiResults[i].GetParameterValueByIndex(i));
                            }
                            if (step2_result.MultiResults[i].Name == "presentationstate")
                            {
                                pa4.Add(step2_result.MultiResults[i]);
                            }
                        }
                    }

                    //Step3 result
                    XMLResult step3_result = img.getImageInfo(pa3);

                    if (step3_result.IsErrorOccured)
                    {
                        p3.Result = TestResult.Fail;
                        p3.Outputs.AddParameter("Step 3: getImageInfo", "The call 'getImageInfo' returns error: ", step3_result.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        p3.Result = TestResult.Pass; // Assume test pass at first, check the details later to update this
                    }

                    //Log step3 service output
                    int expectedParameterCount = 0;
                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getImageInfo")
                        {
                            expectedParameterCount++;
                        }
                    }

                    string dicom_info_getImageInfo = step3_result.DicomArrayResult.GetParameterValueByName("dicom_info");

                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getImageInfo")
                        {
                            // The dicom_info in return does not match the expected key and value
                            if (false == dicom_info_getImageInfo.Contains("<parameter key=\"" + ids.ExpectedValues.Parameters[index].Key + "\" value=\"" + ids.ExpectedValues.Parameters[index].Value + "\" />"))
                            {
                                p3.Result = TestResult.Fail;
                                p3.Outputs.AddParameter("Step 3: getImageInfo", "Error: the expect value does not match: " + ids.ExpectedValues.Parameters[index].Key + ". Actually get dicom_Info: ", dicom_info_getImageInfo);
                                break;
                            }
                        }
                    }
                    if (p3.Result == TestResult.Pass)
                    {
                        p3.Outputs.AddParameter("Step 3: getImageInfo", "The dicom info all match the expected value", dicom_info_getImageInfo);
                    }

                    //Step4 result
                    XMLResult step4_result = ps.getPresentationStateInfo(pa4);

                    if (step4_result.IsErrorOccured)
                    {
                        p4.Result = TestResult.Fail;
                        p4.Outputs.AddParameter("Step 4: getPresentationStateInfo", "The call 'getPresentationStateInfo' returns error: ", step4_result.Message);
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        p4.Result = TestResult.Pass;
                    }

                    expectedParameterCount = 0;  //count of expected parameters on getPresentationStateInfo
                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getPresentationStateInfo")
                        {
                            expectedParameterCount++;
                        }
                    }

                    string dicom_info_getPSInfo = step4_result.DicomArrayResult.GetParameterValueByName("dicom_info");

                    for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++)
                    {
                        if (ids.ExpectedValues.Parameters[index].Step == "getPresentationStateInfo")
                        {
                            if (false == dicom_info_getPSInfo.Contains("<parameter key=\"" + ids.ExpectedValues.Parameters[index].Key + "\" value=\"" + ids.ExpectedValues.Parameters[index].Value + "\" />"))
                            {
                                p4.Result = TestResult.Fail;
                                p4.Outputs.AddParameter("Step 4: getPresentationStateInfo", "Error: the expect dicom value does not match: " + ids.ExpectedValues.Parameters[index].Key + ". Actually get dicom_Info: ", dicom_info_getPSInfo);
                                break;
                            }
                        }
                    }

                    if (p4.Result == TestResult.Pass)
                    {
                        p4.Outputs.AddParameter("Step 4: getPresentationStateInfo", "Success: the expect dicom value all match the expected", dicom_info_getPSInfo);
                    }

                    SaveRound(r);

                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message: ", ex.Message);
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }

            //Save service log as xml file
            Output();
        }
 public XMLResult getPresentationStateInfo(XMLParameterCollection presentationStateUidList)
 {
     this.lastResult = new XMLResult(this.InvokeMethod("getPresentationStateInfo", new object[] { presentationStateUidList.GenerateXML() }));
     return this.lastResult;
 }
        //Case 10: 1.3.7_SetPresentationStateInfo_Normal
        public void Run_PS_SetPresentationStateInfo_Normal_Case10()
        {
            int runCount = 0;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), ids.Description);

                try
                {
                    #region Parameter initialize
                    bool isImportImage = false;
                    string psID = null;
                    string imageID = null;

                    //Input parameters
                    string p_Import_patientId = null;
                    string p_Import_objectFileFullPath = null;
                    XMLParameter p_setPresentationStateInfo = new XMLParameter("presentationstate");
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "import")
                        {
                            isImportImage = true;
                            if (ids.InputParameters.GetParameter(i).Key == "patientInternalId")
                            {
                                p_Import_patientId = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                p_Import_objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "setPresentationStateInfo")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "presentationStateInternalID")
                            {
                                psID = ids.InputParameters.GetParameter(i).Value;
                            }
                            else
                            {
                                p_setPresentationStateInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                            }
                        }
                    }

                    // Output value
                    bool ep_isSetPSInfoReturnOK = true;
                    string ep_SetPSInfoReturnMessage = string.Empty;
                    XMLParameter ep_getPresentationStateInfo = new XMLParameter();
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "setPresentationStateInfo")
                        {
                            switch (ids.ExpectedValues.GetParameter(i).Key)
                            {
                                case "returnState":
                                    {
                                        if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("pass"))
                                        {
                                            ep_isSetPSInfoReturnOK = true;
                                        }
                                        else if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("fail"))
                                        {
                                            ep_isSetPSInfoReturnOK = false;
                                        }
                                        break;
                                    }
                                case "returnMessage":
                                    {
                                        ep_SetPSInfoReturnMessage = ids.ExpectedValues.GetParameter(i).Value;
                                        break;
                                    }
                                default:
                                    break;
                            }
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Step == "getPresentationStateInfo")
                        {
                            ep_getPresentationStateInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                        }
                    }
                    #endregion

                    ImportService importService = new ImportService();
                    PresentationStateService psService = new PresentationStateService();

                    if (isImportImage)
                    {
                        #region Step 1: Call ImportService.ImportObject to import an image and create a PS
                        CheckPoint cp_Import = new CheckPoint("Import Image", "Call ImportService.ImportObject to import an image");
                        r.CheckPoints.Add(cp_Import);

                        XMLResult rt_Import = importService.importObject(p_Import_patientId, null, p_Import_objectFileFullPath, null, true, "FALSE");
                        if (rt_Import.IsErrorOccured)
                        {
                            cp_Import.Result = TestResult.Fail;
                            cp_Import.Outputs.AddParameter("import", "Import image returns error", rt_Import.Message);

                            SaveRound(r);
                            continue; // Error happens, end current Test Set
                        }
                        else
                        {
                            cp_Import.Result = TestResult.Pass;
                            cp_Import.Outputs.AddParameter("import", "Import image returns success as expected", rt_Import.Message);

                            imageID = rt_Import.MultiResults[0].Parameters[0].ParameterValue; // This one is the ImageID
                            psID = rt_Import.MultiResults[1].Parameters[0].ParameterValue; // This one is the PS ID
                        }
                        #endregion
                    }

                    #region Step 2: Call PresentationStateService.SetPresentationStateInfo to set the PSInfo for the image
                    CheckPoint cp_SetPresentationStateInfo = new CheckPoint("Set PSInfo", "Call PresentationStateService.SetPresentationStateInfo to set ps info");
                    r.CheckPoints.Add(cp_SetPresentationStateInfo);

                    XMLResult rt_SetPresentationStateInfo = psService.setPresentationStateInfo(p_setPresentationStateInfo, psID);
                    if (ep_isSetPSInfoReturnOK) // Expect the call return OK
                    {
                        if (rt_SetPresentationStateInfo.IsErrorOccured)
                        {
                            cp_SetPresentationStateInfo.Result = TestResult.Fail;
                            cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns error", rt_SetPresentationStateInfo.Message);

                            SaveRound(r);
                            continue; // Error happens, end current Test Set
                        }
                        else
                        {
                            cp_SetPresentationStateInfo.Result = TestResult.Pass;
                            cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns success as expected", rt_SetPresentationStateInfo.Message);

                            #region Step 3: Call PresentationStateService.GetPresentationStateInfo to get the PSInfo for the image
                            CheckPoint cp_GetPresentationStateInfo = new CheckPoint("Get PSInfo", "Call PresentationStateService.GetPresentationStateInfo and check the return state");
                            r.CheckPoints.Add(cp_GetPresentationStateInfo);

                            XMLParameterCollection p_GetPresentationStateInfo = new XMLParameterCollection();
                            XMLParameter p_GetPSInfo_ID = new XMLParameter("presentationstate");
                            p_GetPSInfo_ID.AddParameter("internal_id", psID); // Add current psID as the input param
                            XMLParameter p_GetPSInfo_Preferences = new XMLParameter("preferences");
                            p_GetPresentationStateInfo.Add(p_GetPSInfo_ID);
                            p_GetPresentationStateInfo.Add(p_GetPSInfo_Preferences);

                            XMLResult rt_GetPresentationStateInfo = psService.getPresentationStateInfo(p_GetPresentationStateInfo);

                            if (rt_GetPresentationStateInfo.IsErrorOccured)
                            {
                                cp_GetPresentationStateInfo.Result = TestResult.Fail;
                                cp_GetPresentationStateInfo.Outputs.AddParameter("state", "Get PSInfo returns error", rt_GetPresentationStateInfo.Message);

                                SaveRound(r);
                                continue; // Error happens, end current Test Get
                            }
                            else
                            {
                                cp_GetPresentationStateInfo.Result = TestResult.Pass;
                                cp_GetPresentationStateInfo.Outputs.AddParameter("state", "Get PSInfo returns succeed", rt_GetPresentationStateInfo.Message);

                                // Check the return value is correct
                                #region Step 4: Check the values in PresentationStateService.getPresentationStateInfo return are correct
                                CheckPoint cp_getPSInfoReturnValues = new CheckPoint("Get PSInfo", "Check the values in PresentationStateService.GetPresentationStateInfo return");
                                r.CheckPoints.Add(cp_getPSInfoReturnValues);

                                // Add two check values dynamically
                                ep_getPresentationStateInfo.AddParameter("internal_id", psID);
                                ep_getPresentationStateInfo.AddParameter("image_internal_id", imageID);

                                bool isValueEqual = false;
                                bool isKeyShow = false;
                                foreach (XMLParameterNode psNode in ep_getPresentationStateInfo.Parameters)
                                {
                                    isValueEqual = false;
                                    isKeyShow = false;

                                    int i = 0;
                                    for (i = 0; i < rt_GetPresentationStateInfo.DicomArrayResult.Parameters.Count; i++)
                                    {
                                        if (psNode.ParameterName == rt_GetPresentationStateInfo.DicomArrayResult.Parameters[i].ParameterName)
                                        {
                                            isKeyShow = true;
                                            isValueEqual = string.Equals(psNode.ParameterValue, rt_GetPresentationStateInfo.DicomArrayResult.Parameters[i].ParameterValue.Replace("\r", "").Replace("\n", ""));
                                            break; // Find the node, end current for loop to search node
                                        }
                                    }

                                    if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress
                                    {
                                        cp_getPSInfoReturnValues.Result = TestResult.Fail;

                                        if (isKeyShow)
                                        {
                                            System.Diagnostics.Debug.Print("The return value in getPresentationStateInfo does not match the expected.");
                                            cp_getPSInfoReturnValues.Outputs.AddParameter("PSInfo Info", "Check the values in PresentationStateService.getPresentationStateInfo return", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetPresentationStateInfo.MultiResults[0].Parameters[i].ParameterValue);
                                        }
                                        else
                                        {
                                            System.Diagnostics.Debug.Print("The return value in getPresentationStateInfo does not contain the node: " + psNode.ParameterName);
                                            cp_getPSInfoReturnValues.Outputs.AddParameter("PSInfo Info", "Check the values in PresentationStateService.getPresentationStateInfo return", "The return value does not contain the node: " + psNode.ParameterName);
                                        }

                                        break; // End current foreach loop, not compare the follwing nodes
                                    }
                                }

                                if (isValueEqual)
                                {
                                    cp_getPSInfoReturnValues.Result = TestResult.Pass;

                                    System.Diagnostics.Debug.Print("The return values in getPresentationStateInfoInfo all match the expected.");
                                    cp_getPSInfoReturnValues.Outputs.AddParameter("PSInfo Info", "Check the values in PresentationStateService.getPresentationStateInfoInfo return", "The return values all match the expected");
                                }
                                #endregion
                            }
                            #endregion
                        }
                    }
                    else // Expect the call return error
                    {
                        if (rt_SetPresentationStateInfo.IsErrorOccured) // There is error
                        {
                            if (rt_SetPresentationStateInfo.Message.ToLower().Contains(ep_SetPSInfoReturnMessage.ToLower()))
                            {
                                cp_SetPresentationStateInfo.Result = TestResult.Pass;
                                cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns error as expected", rt_SetPresentationStateInfo.Message);
                            }
                            else
                            {
                                cp_SetPresentationStateInfo.Result = TestResult.Fail;
                                cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns error message not match the expected. ", "Expect: " + ep_SetPSInfoReturnMessage + "; Actually returns: " + rt_SetPresentationStateInfo.Message);

                                SaveRound(r);
                                continue; // Error happens, end current Test Get
                            }
                        }
                        else // There is no error
                        {
                            cp_SetPresentationStateInfo.Result = TestResult.Fail;
                            cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PS not returns error as expected. ", "Actually returns: " + rt_SetPresentationStateInfo.Message);

                            SaveRound(r);
                            continue; // Error happens, end current Test Get
                        }
                    }
                    #endregion

                    if (isImportImage)
                    {
                        #region Step 5: Call ImageService.deleteImage to delete the created image
                        ImageService imageService = new ImageService();
                        CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image");
                        r.CheckPoints.Add(cp_DeleteImage);

                        XMLResult rt_DeleteImage = imageService.deleteImage(imageID, new XMLParameter("preferences"));
                        if (rt_DeleteImage.IsErrorOccured)
                        {
                            cp_DeleteImage.Result = TestResult.Fail;
                            cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message);

                            SaveRound(r);
                            continue; // End current test set
                        }
                        else
                        {
                            cp_DeleteImage.Result = TestResult.Pass;
                            cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message);
                        }
                        #endregion
                    }
                    SaveRound(r);

                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message);
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }

            Output();
        }
        // Case 1203: 1.3.10_ImportImage_N07_Import single 8100 dicom thin layer slice
        public void Run_Import_8100Slice_Case1203()
        {
            int runCount = 0;
            string patientUID = string.Empty;
            bool isCreatePatient = false;
            bool isDeletePatient = true;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                isCreatePatient = false;
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Import image");

                ImportService ims = new ImportService();
                XMLParameter pa = new XMLParameter("patient");
                XMLParameter ia = new XMLParameter("import");
                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "create")
                    {
                        pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        isCreatePatient = true;
                    }
                    if (ids.InputParameters.GetParameter(i).Step == "import")
                    {
                        ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }

                string epGetImageInfoImageType = null;
                string epGetImageInfoAnatomicRegion = null;
                string epGetImageInfoAnatomicRegionModifiers = null;
                string epGetPSInfoImageType = null;
                string epGetPSInfoAnatomicRegion = null;
                string epGetPSInfoAnatomicRegionModifiers = null;

                for (int i = 0; i < ids.ExpectedValues.Count; i++)
                {
                    if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo")
                    {
                        switch (ids.ExpectedValues.GetParameter(i).Key)
                        {
                            case "image_type":
                                epGetImageInfoImageType = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_anatomic_region":
                                epGetImageInfoAnatomicRegion = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_anatomic_region_modifiers":
                                epGetImageInfoAnatomicRegionModifiers = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            default:
                                break;
                        }
                    }
                    else if (ids.ExpectedValues.GetParameter(i).Step == "getPresentationStateInfo")
                    {
                        switch (ids.ExpectedValues.GetParameter(i).Key)
                        {
                            case "image_type":
                                epGetPSInfoImageType = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_anatomic_region":
                                epGetPSInfoAnatomicRegion = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            case "dcm_anatomic_region_modifiers":
                                epGetPSInfoAnatomicRegionModifiers = ids.ExpectedValues.GetParameter(i).Value;
                                break;
                            default:
                                break;
                        }
                    }
                }

                try
                {
                    PatientService patientSvc = new PatientService();
                    if (isCreatePatient)
                    {
                        CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                        r.CheckPoints.Add(pCreate);

                        XMLResult result = patientSvc.createPatient(pa);
                        if (!result.IsErrorOccured)
                        {
                            patientUID = result.SingleResult;
                            pCreate.Result = TestResult.Pass;
                            pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID);
                        }
                        else
                        {
                            pCreate.Result = TestResult.Fail;
                            pCreate.Outputs.AddParameter("Create patient returns error", "Create Patient", result.ResultContent);
                        }
                    }

                    CheckPoint pImport = new CheckPoint("Import Image", "Test import");
                    r.CheckPoints.Add(pImport);

                    string filePath = string.Empty;
                    string archivePath = string.Empty;
                    bool move = false;
                    for (int c = 0; c < ia.Length; c++)
                    {
                        if (ia.GetParameterName(c) == "path")
                            filePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "archivePath")
                            archivePath = ia.GetParameterValue(c);
                        if (ia.GetParameterName(c) == "move")
                        {
                            if (ia.GetParameterValue(c) == "true")
                                move = true;
                        }
                    }

                    XMLResult rslImport = ims.importObject(patientUID, "", filePath, archivePath, move, "false");

                    //import return sample:
                    //   <trophy type="result" version="1.0">
                    //           <status code="0" message="ok" />
                    //           <image><parameter key="internal_id" value="2bfb416b-037e-41e7-aaef-8d2bd08b1ae7" /></image>
                    //           <presentationstate><parameter key="internal_id" value="75675345-a164-4088-b6d3-1b2ae86b703b" /></presentationstate>
                    // </trophy>

                    if (rslImport.IsErrorOccured)
                    {
                        pImport.Result = TestResult.Fail;
                        pImport.Outputs.AddParameter("Import image fail", "Import", rslImport.Message);
                        pImport.Outputs.AddParameter("Import image returns error code", "Import", rslImport.Code.ToString());
                    }
                    else
                    {
                        // Check the return contiains image id and ps id
                        string imageID = null;
                        imageID = rslImport.MultiResults[0].GetParameterValueByName("internal_id"); // image internal_id
                        if (imageID == null || imageID == string.Empty)
                        {
                            pImport.Result = TestResult.Fail;
                            pImport.Outputs.AddParameter("Import image returns wrong image internal id", "Import", rslImport.ResultContent);
                        }

                        string psID = null;
                        psID = rslImport.MultiResults[1].GetParameterValueByName("internal_id"); // ps internal_id
                        if (psID == null || psID == string.Empty)
                        {
                            pImport.Result = TestResult.Fail;
                            pImport.Outputs.AddParameter("import image returns wrong ps internal id", "Import", rslImport.ResultContent);
                        }
                        else
                        {
                            pImport.Result = TestResult.Pass;
                            pImport.Outputs.AddParameter("import image returns OK", "Import", rslImport.ResultContent);
                        }

                        #region Call getImageInfo to check image_type and anatomic_region
                        ImageService imageSvc = new ImageService();
                        PresentationStateService psSvc = new PresentationStateService();

                        XMLParameter pGetImageInfo = new XMLParameter("image");
                        pGetImageInfo.AddParameter("internal_id", imageID);

                        CheckPoint cpGetImageInfo = new CheckPoint("GetImageInfo", "Call GetImageInfo to check the dcm_anatomic_region value");
                        r.CheckPoints.Add(cpGetImageInfo);

                        XMLResult rtGetImageInfo = imageSvc.getImageInfo(pGetImageInfo);
                        if (rtGetImageInfo.IsErrorOccured)
                        {
                            cpGetImageInfo.Result = TestResult.Fail;
                            cpGetImageInfo.Outputs.AddParameter("Get Image Info return error", "getImageInfo", rtGetImageInfo.ResultContent);
                        }
                        else
                        {
                            cpGetImageInfo.Outputs.AddParameter("Get Image Info return success", "getImageInfo", rtGetImageInfo.Message);

                            // Check the image_type, anatomic_region values in return are correct
                            if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"image_type\" value=\"" + epGetImageInfoImageType + "\""))  //parameter key="image_type" value="PANOV6"
                            {
                                cpGetImageInfo.Result = TestResult.Fail;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info return wrong image_type info", "getImageInfo", rtGetImageInfo.ResultContent);
                            }
                            else if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region\" value=\"" + epGetImageInfoAnatomicRegion + "\""))  // parameter key="dcm_anatomic_region" value="Jaw region"
                            {
                                cpGetImageInfo.Result = TestResult.Fail;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info return wrong dcm_anatomic_region info", "getImageInfo", rtGetImageInfo.ResultContent);
                            }
                            else if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region_modifiers\" value=\"" + epGetImageInfoAnatomicRegionModifiers + "\""))  // parameter key="dcm_anatomic_region_modifiers" value="Molar 1"
                            {
                                cpGetImageInfo.Result = TestResult.Fail;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info return wrong dcm_anatomic_region_modifiers info", "getImageInfo", rtGetImageInfo.ResultContent);
                            }
                            else
                            {
                                cpGetImageInfo.Result = TestResult.Pass;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info return correct info", "getImageInfo", rtGetImageInfo.ResultContent);
                            }
                        }

                        XMLParameterCollection pGetPSInfo = new XMLParameterCollection();
                        XMLParameter psList = new XMLParameter("presentationstate");
                        psList.AddParameter("internal_id", psID);
                        pGetPSInfo.Add(psList);

                        CheckPoint cpGetPSInfo = new CheckPoint("GetPSInfo", "Call GetPSInfo to check the dcm_anatomic_region value");
                        r.CheckPoints.Add(cpGetPSInfo);

                        XMLResult rtGetPSInfo = psSvc.getPresentationStateInfo(pGetPSInfo);
                        if (rtGetPSInfo.IsErrorOccured)
                        {
                            cpGetPSInfo.Result = TestResult.Fail;
                            cpGetPSInfo.Outputs.AddParameter("Get PS Info return error", "GetPSInfo", rtGetPSInfo.ResultContent);
                        }
                        else
                        {
                            cpGetPSInfo.Outputs.AddParameter("Get PS Info return success", "GetPSInfo", rtGetPSInfo.Message);

                            // Check the image_type, anatomic_region values in return are correct
                            if (!rtGetPSInfo.ResultContent.Contains("parameter key=\"image_type\" value=\"" + epGetPSInfoImageType + "\"")) //parameter key="image_type" value="PANOV6"
                            {
                                cpGetPSInfo.Result = TestResult.Fail;
                                cpGetPSInfo.Outputs.AddParameter("Get PS Info return wrong image_type info", "GetPSInfo", rtGetPSInfo.ResultContent);
                            }
                            else if (!rtGetPSInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region\" value=\"" + epGetPSInfoAnatomicRegion + "\""))  // parameter key="dcm_anatomic_region" value="Jaw region"
                            {
                                cpGetPSInfo.Result = TestResult.Fail;
                                cpGetPSInfo.Outputs.AddParameter("Get PS Info return wrong dcm_anatomic_region info", "GetPSInfo", rtGetPSInfo.ResultContent);
                            }
                            else if (!rtGetPSInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region_modifiers\" value=\"" + epGetPSInfoAnatomicRegionModifiers + "\""))  // parameter key="dcm_anatomic_region_modifiers" value="Molar 1"
                            {
                                cpGetPSInfo.Result = TestResult.Fail;
                                cpGetPSInfo.Outputs.AddParameter("Get PS Info return wrong dcm_anatomic_region_modifiers info", "GetPSInfo", rtGetPSInfo.ResultContent);
                            }
                            else
                            {
                                cpGetPSInfo.Result = TestResult.Pass;
                                cpGetPSInfo.Outputs.AddParameter("Get PS Info return correct info", "GetPSInfo", rtGetPSInfo.ResultContent);
                            }
                        }

                        CheckPoint cpGetPS = new CheckPoint("GetPS", "Call GetPS to check the ps xml info");
                        r.CheckPoints.Add(cpGetPS);

                        XMLResult rtGetPS = psSvc.getPresentationState(psID);
                        if (rtGetPS.IsErrorOccured)
                        {
                            cpGetPS.Result = TestResult.Fail;
                            cpGetPS.Outputs.AddParameter("Get PS return error", "GetPS", rtGetPS.ResultContent);
                        }
                        else
                        {
                            cpGetPS.Outputs.AddParameter("Get PS return success", "GetPS", rtGetPS.Message);

                            if (rtGetPS.ResultContent.Contains("parameter key=\"general.xml\"") && rtGetPS.ResultContent.Contains("parameter key=\"processing.xml\"") && rtGetPS.ResultContent.Contains("parameter key=\"annotation.xml\"")) // Should return empty ps info for this case as there is not
                            {
                                cpGetPS.Result = TestResult.Pass;
                                cpGetPS.Outputs.AddParameter("Get PS return correct info", "GetPS", rtGetPS.ResultContent);
                            }
                            else
                            {
                                cpGetPS.Result = TestResult.Fail;
                                cpGetPS.Outputs.AddParameter("Get PS return wrong content", "GetPS", rtGetPS.ResultContent);
                            }
                        }
                        #endregion
                    }

                    if (isDeletePatient)
                    {
                        CheckPoint cpDelete = new CheckPoint("Delete Patient", "Test delete patient");
                        r.CheckPoints.Add(cpDelete);
                        XMLResult rltDelete = patientSvc.deletePatient(patientUID);
                        if (rltDelete.IsErrorOccured)
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns error", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Fail;
                        }
                        else
                        {
                            cpDelete.Outputs.AddParameter("Delete created patient returns OK", "Delete Patient", rltDelete.Message);
                            cpDelete.Result = TestResult.Pass;
                        }
                    }

                    SaveRound(r);
                }
                catch (Exception ex)
                {
                    CheckPoint cp = new CheckPoint();
                    r.CheckPoints.Add(cp);
                    cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message);
                    cp.Result = TestResult.Fail;
                    SaveRound(r);
                }
            }
            Output();
        }