//Case 1043: 1.3.17_workflow_ImportCeph_GetImageInfo_RadilogIsNotSaved
        public void Run_WorkFlow_ImportCeph_RadioLog_Case1043()
        {
            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");

                PatientService patientSvc = new PatientService();
                ImportService importSvc = new ImportService();
                ImageService imageSvc = new ImageService();

                string radioLogBeforeImport = string.Empty;
                string radioLogAfterImport = string.Empty;
                string imageID = null;

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

                XMLParameter epGetImagInfo = new XMLParameter();
                for (int i = 0; i < ids.ExpectedValues.Count; i++)
                {
                    if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo")
                    {
                        epGetImagInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                    }
                }

                try
                {
                    #region Step1: Create Image
                    if (isCreatePatient)
                    {
                        CheckPoint pCreate = new CheckPoint("Create Patient", "Test create");
                        r.CheckPoints.Add(pCreate);

                        XMLResult rtCreatePatient = patientSvc.createPatient(pa);
                        if (!rtCreatePatient.IsErrorOccured)
                        {
                            patientUID = rtCreatePatient.SingleResult;
                            pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID);
                            pCreate.Result = TestResult.Pass;
                        }
                    }
                    #endregion

                    #region Step2: Get patient radio log info before import
                    CheckPoint cpGetPatientBeforeImport = new CheckPoint("GetPatient", "Get Patient Info before import image");
                    r.CheckPoints.Add(cpGetPatientBeforeImport);

                    XMLResult rtGetPatientBeforeImport = patientSvc.getPatient(patientUID);
                    if (rtGetPatientBeforeImport.IsErrorOccured)
                    {
                        cpGetPatientBeforeImport.Result = TestResult.Fail;
                        cpGetPatientBeforeImport.Outputs.AddParameter("Get Patient Info before import image returns error", "GetPatient", rtGetPatientBeforeImport.ResultContent);
                    }
                    else
                    {
                        cpGetPatientBeforeImport.Result = TestResult.Pass;
                        cpGetPatientBeforeImport.Outputs.AddParameter("Get Patient Info before import image returns ok", "GetPatient", rtGetPatientBeforeImport.ResultContent);

                        radioLogBeforeImport = rtGetPatientBeforeImport.MultiResults[0].GetParameterValueByName("cumulative_dose");  //get the cumulative_dose info
                    }
                    #endregion

                    #region Step3: Import Image
                    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);
                        }
                        else if (ia.GetParameterName(c) == "archivePath")
                        {
                            archivePath = ia.GetParameterValue(c);
                        }
                        else if (ia.GetParameterName(c) == "move")
                        {
                            if (ia.GetParameterValue(c) == "true")
                            {
                                move = true;
                            }
                        }
                    }

                    XMLResult rtlImport = importSvc.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 (rtlImport.IsErrorOccured)
                    {
                        pImport.Result = TestResult.Fail;
                        pImport.Outputs.AddParameter("Import image fail", "Import", rtlImport.Message);
                        pImport.Outputs.AddParameter("Import image returns error code", "Import", rtlImport.Code.ToString());
                    }
                    else
                    {
                        // Check the return contiains image id and ps id
                        imageID = rtlImport.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", rtlImport.ResultContent);
                        }

                        string psID = null;
                        psID = rtlImport.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", rtlImport.ResultContent);
                        }
                        else
                        {
                            pImport.Result = TestResult.Pass;
                            pImport.Outputs.AddParameter("import image returns OK", "Import", rtlImport.ResultContent);
                        }
                    }
                    #endregion

                    #region Step4: Call GetImageInfo to check the radio log info
                    CheckPoint cpGetImageInfo = new CheckPoint("GetImageInfo", "Get the image info of the imported image");
                    r.CheckPoints.Add(cpGetImageInfo);

                    XMLParameter pGetImageInfo = new XMLParameter("image");
                    pGetImageInfo.AddParameter("internal_id", imageID);
                    XMLResult rtGetImageInfo = imageSvc.getImageInfo(pGetImageInfo);

                    if (rtGetImageInfo.IsErrorOccured)
                    {
                        cpGetImageInfo.Result = TestResult.Fail;
                        cpGetImageInfo.Outputs.AddParameter("Get the image info of the imported image return error", "GetImageInfo", rtGetImageInfo.ResultContent);
                    }
                    else
                    {
                        cpGetImageInfo.Outputs.AddParameter("Get Image Info return success", "getImageInfo", rtGetImageInfo.Message);

                        //Check the return info contain the expected key and value: <parameter key="XXX" value="XXX" />
                        foreach (XMLParameterNode node in epGetImagInfo.Parameters)
                        {
                            if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\""))
                            {
                                cpGetImageInfo.Result = TestResult.Fail;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info returns wrong key-value info for: " + node.ParameterName, "GetImageInfo", rtGetImageInfo.ResultContent);
                                continue;
                            }
                            else
                            {
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info returns correct key-value info for: " + node.ParameterName, "GetImageInfo", "ok");
                            }
                        }

                        if (cpGetImageInfo.Result != TestResult.Fail)
                        {
                            cpGetImageInfo.Result = TestResult.Pass;
                            cpGetImageInfo.Outputs.AddParameter("Get Image Info return all correct info", "GetImageInfo", rtGetImageInfo.ResultContent);
                        }
                    }
                    #endregion

                    #region Step5: Get patient radio log info after import
                    CheckPoint cpGetPatientAfterImport = new CheckPoint("GetPatient", "Get Patient Info after import image");
                    r.CheckPoints.Add(cpGetPatientAfterImport);

                    XMLResult rtGetPatientAfterImport = patientSvc.getPatient(patientUID);
                    if (rtGetPatientAfterImport.IsErrorOccured)
                    {
                        cpGetPatientAfterImport.Result = TestResult.Fail;
                        cpGetPatientAfterImport.Outputs.AddParameter("Get Patient Info after import image returns error", "GetPatient", rtGetPatientAfterImport.ResultContent);
                    }
                    else
                    {
                        cpGetPatientAfterImport.Result = TestResult.Pass;
                        cpGetPatientAfterImport.Outputs.AddParameter("Get Patient Info after import image returns ok", "GetPatient", rtGetPatientAfterImport.ResultContent);

                        radioLogAfterImport = rtGetPatientAfterImport.MultiResults[0].GetParameterValueByName("cumulative_dose");  //get the cumulative_dose info
                    }
                    #endregion

                    #region Step6: Check the patient radio log info not changes after import image
                    CheckPoint cpPatientRadioLogInfo = new CheckPoint("Patient Radiolog Info", "Check patient radio log info not changes aftert import image");
                    r.CheckPoints.Add(cpPatientRadioLogInfo);

                    if (radioLogAfterImport == radioLogBeforeImport)
                    {
                        cpPatientRadioLogInfo.Result = TestResult.Pass;
                        cpPatientRadioLogInfo.Outputs.AddParameter("Patient radio log info not changes aftert import image", "Patient Radiolog Info", "Before import value is: " + radioLogBeforeImport + ". After import value is: " + radioLogAfterImport);
                    }
                    else
                    {
                        cpPatientRadioLogInfo.Result = TestResult.Fail;
                        cpPatientRadioLogInfo.Outputs.AddParameter("Patient radio log info  changes aftert import image", "Patient Radiolog Info", "Before import value is: " + radioLogBeforeImport + ". After import value is: " + radioLogAfterImport);
                    }
                    #endregion

                    #region Step7: Delete Patient
                    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;
                        }
                    }
                    #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 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 1178: 1.3.6_WorkFlow_N04_createImage_getImageInfo_getImageDescription_setImageInfo_getImageInfo_getImageDescription_deleteImage
        public void Run_Image_WorkFlow_Case1178()
        {
            int runCount = 0;
            string imageinternalUid = string.Empty;

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Test Image Service: createImage -> getImageInfo & getImageDescription -> setImageInfo ->  getImageInfo & getImageDescription -> deleteImage");

                try
                {
                    ImageService imageService = new ImageService();

                    #region Parameter Initialize
                    XMLParameter p_CreateImage = new XMLParameter("image");
                    XMLParameter p_SetImageInfo = new XMLParameter("image");
                    //XMLParameter p_SetImage_series = new XMLParameter("series");
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "createImage_image")
                        {
                            p_CreateImage.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                        if (ids.InputParameters.GetParameter(i).Step == "setImageInfo")
                        {
                            p_SetImageInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                        //if (ids.InputParameters.GetParameter(i).Step == "setImageInfo_series")
                        //{
                        //    p_SetImage_series.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        //}
                    }

                    XMLParameter ep_getImageInfoAfterCreate = new XMLParameter("image");
                    XMLParameter ep_getImageDescriptionAfterCreate = new XMLParameter("image");
                    //XMLParameter ep_getImageDescriptionAfterCreate_series = new XMLParameter("series");
                    XMLParameter ep_getImageInfoAfterSet = new XMLParameter("image");
                    XMLParameter ep_getImageDescriptionAfterSet = new XMLParameter("image");
                    //XMLParameter ep_getImageDescriptionAfterSet_series = new XMLParameter("series");
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_AfterCreate")
                        {
                            ep_getImageInfoAfterCreate.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription_AfterCreate")
                        {
                            ep_getImageDescriptionAfterCreate.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                        }
                        //else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription_AfterCreate_series")
                        //{
                        //    ep_getImageDescriptionAfterCreate_series.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                        //}
                        else if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_AfterSet")
                        {
                            ep_getImageInfoAfterSet.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription_AfterSet")
                        {
                            ep_getImageDescriptionAfterSet.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                        }
                        //else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription_AfterSet_series")
                        //{
                        //    ep_getImageDescriptionAfterSet_series.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                        //}
                    }
                    #endregion

                    #region Step 1: Call ImageService.createImage to create a new image
                    CheckPoint cp_CreateImage = new CheckPoint("Image create", "Call imageService.createImage to create a new image");
                    r.CheckPoints.Add(cp_CreateImage);

                    XMLResult rt_CreateImage = imageService.createImage(p_CreateImage);
                    if (rt_CreateImage.IsErrorOccured)
                    {
                        cp_CreateImage.Result = TestResult.Fail;
                        cp_CreateImage.Outputs.AddParameter("create", "Create image returns error", rt_CreateImage.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    else
                    {
                        cp_CreateImage.Result = TestResult.Pass;
                        cp_CreateImage.Outputs.AddParameter("create", "Create image returns success", rt_CreateImage.Message);
                        imageinternalUid = rt_CreateImage.SingleResult;
                    }
                    #endregion

                    #region Step 2: Call imageService.getImageInfo to check the return value
                    CheckPoint cp_GetImageInfoAfterCreate = new CheckPoint("Get Image Info", "Call imageService.GetImageInfo to get Image Info after the image is created");
                    r.CheckPoints.Add(cp_GetImageInfoAfterCreate);

                    XMLParameter p_GetImageInfoAfterCreate = new XMLParameter("image");
                    p_GetImageInfoAfterCreate.AddParameter("internal_id", imageinternalUid);

                    XMLResult rt_GetImageInfoAfterCreate = imageService.getImageInfo(p_GetImageInfoAfterCreate);
                    if (rt_GetImageInfoAfterCreate.IsErrorOccured)
                    {
                        cp_GetImageInfoAfterCreate.Result = TestResult.Fail;
                        cp_GetImageInfoAfterCreate.Outputs.AddParameter("getImageInfo", "Get image info after create returns error", rt_GetImageInfoAfterCreate.Message);

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

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

                            int i = 0;
                            for (i = 0; i < rt_GetImageInfoAfterCreate.MultiResults[0].Parameters.Count; i++)
                            {
                                if (psNode.ParameterName == rt_GetImageInfoAfterCreate.MultiResults[0].Parameters[i].ParameterName)
                                {
                                    isKeyShow = true;
                                    isValueEqual = string.Equals(psNode.ParameterValue, rt_GetImageInfoAfterCreate.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_GetImageInfoAfterCreate.Result = TestResult.Fail;

                                if (isKeyShow)
                                {
                                    System.Diagnostics.Debug.Print("The return value in getImageInfo does not match the expected.");
                                    cp_GetImageInfoAfterCreate.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after create image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetImageInfoAfterCreate.MultiResults[0].Parameters[i].ParameterValue);
                                }
                                else
                                {
                                    System.Diagnostics.Debug.Print("The return value in getImageInfo does not contain the node: " + psNode.ParameterName);
                                    cp_GetImageInfoAfterCreate.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after create image", "The return value in getImageInfo does not contain the node: " + psNode.ParameterName);
                                }

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

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

                            System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected.");
                            cp_GetImageInfoAfterCreate.Outputs.AddParameter("getImageInfo", "Get image info after create returns success", rt_GetImageInfoAfterCreate.Message);
                            cp_GetImageInfoAfterCreate.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after create", "The return values in getImageInfo all match the expected");
                        }
                    }
                    #endregion

                    #region Step 3: Call ImageService.getImageDescription to check the return value
                    CheckPoint cp_GetImageDescriptionAfterCreate = new CheckPoint("Get Image Description", "Call Call imageService.GetImageDescription to get Image description after the image is created");
                    r.CheckPoints.Add(cp_GetImageDescriptionAfterCreate);

                    XMLResult rt_GetImageDescriptionAfterCreate = imageService.getImageDescription(imageinternalUid);
                    if (rt_GetImageDescriptionAfterCreate.IsErrorOccured)
                    {
                        cp_GetImageDescriptionAfterCreate.Result = TestResult.Fail;
                        cp_GetImageDescriptionAfterCreate.Outputs.AddParameter("getImageDescription", "Get image description after create returns error", rt_GetImageDescriptionAfterCreate.Message);

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

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

                            int i = 0;
                            for (i = 0; i < rt_GetImageDescriptionAfterCreate.MultiResults[0].Parameters.Count; i++)
                            {
                                if (psNode.ParameterName == rt_GetImageDescriptionAfterCreate.MultiResults[0].Parameters[i].ParameterName)
                                {
                                    isKeyShow = true;
                                    isValueEqual = string.Equals(psNode.ParameterValue, rt_GetImageDescriptionAfterCreate.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_GetImageDescriptionAfterCreate.Result = TestResult.Fail;

                                if (isKeyShow)
                                {
                                    System.Diagnostics.Debug.Print("The return value in getImageDescription does not match the expected.");
                                    cp_GetImageDescriptionAfterCreate.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after create image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetImageDescriptionAfterCreate.MultiResults[0].Parameters[i].ParameterValue);
                                }
                                else
                                {
                                    System.Diagnostics.Debug.Print("The return value in getImageDescription does not contain the node: " + psNode.ParameterName);
                                    cp_GetImageDescriptionAfterCreate.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after create image", "The return value in getImageDescription does not contain the node: " + psNode.ParameterName);
                                }
                                break; // End current foreach loop, not compare the follwing nodes
                            }
                        }

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

                            System.Diagnostics.Debug.Print("The return values in getImageDescription all match the expected.");
                            cp_GetImageDescriptionAfterCreate.Outputs.AddParameter("getImageDescription", "Get image Description after create returns success", rt_GetImageDescriptionAfterCreate.Message);
                            cp_GetImageDescriptionAfterCreate.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after create", "The return values in getImageDescription all match the expected");
                        }
                    }
                    #endregion

                    #region Step 4: Call imageService.setImageInfo to set image info
                    CheckPoint cp_SetImageInfoAfterCreate = new CheckPoint("Set Image Info", "Call  imageService.SetImageInfo to set Image Info after the image is created");
                    r.CheckPoints.Add(cp_SetImageInfoAfterCreate);

                    XMLResult rt_SetImageInfoAfterCreate = imageService.setImageInfo(p_SetImageInfo, imageinternalUid);
                    if (rt_SetImageInfoAfterCreate.IsErrorOccured)
                    {
                        cp_SetImageInfoAfterCreate.Result = TestResult.Fail;
                        cp_SetImageInfoAfterCreate.Outputs.AddParameter("setImageInfo", "Set image info after create returns error", rt_SetImageInfoAfterCreate.Message);

                        goto CLEANUP;
                    }
                    else
                    {
                        cp_SetImageInfoAfterCreate.Result = TestResult.Pass;
                        cp_SetImageInfoAfterCreate.Outputs.AddParameter("setImageInfo", "Set image info after create returns success", rt_SetImageInfoAfterCreate.Message);
                    }
                    #endregion

                    #region Step 5: Call imageService.getImageInfo to check the return value
                    CheckPoint cp_GetImageInfoAfterSet = new CheckPoint("Get Image Info", "Call imageService.GetImageInfo to get Image Info after set the image info");
                    r.CheckPoints.Add(cp_GetImageInfoAfterSet);

                    XMLParameter p_GetImageInfoAfterSet = new XMLParameter("image");
                    p_GetImageInfoAfterSet.AddParameter("internal_id", imageinternalUid);

                    XMLResult rt_GetImageInfoAfterSet = imageService.getImageInfo(p_GetImageInfoAfterSet);
                    if (rt_GetImageInfoAfterSet.IsErrorOccured)
                    {
                        cp_GetImageInfoAfterSet.Result = TestResult.Fail;
                        cp_GetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Get image info after set returns error", rt_GetImageInfoAfterSet.Message);

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

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

                            int i = 0;
                            for (i = 0; i < rt_GetImageInfoAfterSet.MultiResults[0].Parameters.Count; i++)
                            {
                                if (psNode.ParameterName == rt_GetImageInfoAfterSet.MultiResults[0].Parameters[i].ParameterName)
                                {
                                    isKeyShow = true;
                                    isValueEqual = string.Equals(psNode.ParameterValue, rt_GetImageInfoAfterSet.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_GetImageInfoAfterSet.Result = TestResult.Fail;

                                if (isKeyShow)
                                {
                                    System.Diagnostics.Debug.Print("The return value in getImageInfo does not match the expected.");
                                    cp_GetImageInfoAfterSet.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after set image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetImageInfoAfterSet.MultiResults[0].Parameters[i].ParameterValue);
                                }
                                else
                                {
                                    System.Diagnostics.Debug.Print("The return value in getImageInfo does not contain the node: " + psNode.ParameterName);
                                    cp_GetImageInfoAfterSet.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after set image", "The return value in getImageInfo does not contain the node: " + psNode.ParameterName);
                                }

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

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

                            System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected.");
                            cp_GetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Get image info after set returns success", rt_GetImageInfoAfterSet.Message);
                            cp_GetImageInfoAfterSet.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after set", "The return values in getImageInfo all match the expected");
                        }
                    }
                    #endregion

                    #region Step 6: Call ImageService.getImageDescription to check the return value
                    CheckPoint cp_GetImageDescriptionAfterSet = new CheckPoint("Get Image Description", "Call Call imageService.GetImageDescription to get Image description after the image is setd");
                    r.CheckPoints.Add(cp_GetImageDescriptionAfterSet);

                    XMLResult rt_GetImageDescriptionAfterSet = imageService.getImageDescription(imageinternalUid);
                    if (rt_GetImageDescriptionAfterSet.IsErrorOccured)
                    {
                        cp_GetImageDescriptionAfterSet.Result = TestResult.Fail;
                        cp_GetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Get image description after set returns error", rt_GetImageDescriptionAfterSet.Message);

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

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

                            int i = 0;
                            for (i = 0; i < rt_GetImageDescriptionAfterSet.MultiResults[0].Parameters.Count; i++)
                            {
                                if (psNode.ParameterName == rt_GetImageDescriptionAfterSet.MultiResults[0].Parameters[i].ParameterName)
                                {
                                    isKeyShow = true;
                                    isValueEqual = string.Equals(psNode.ParameterValue, rt_GetImageDescriptionAfterSet.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_GetImageDescriptionAfterSet.Result = TestResult.Fail;

                                if (isKeyShow)
                                {
                                    System.Diagnostics.Debug.Print("The return value in getImageDescription does not match the expected.");
                                    cp_GetImageDescriptionAfterSet.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after set image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetImageDescriptionAfterSet.MultiResults[0].Parameters[i].ParameterValue);
                                }
                                else
                                {
                                    System.Diagnostics.Debug.Print("The return value in getImageDescription does not contain the node: " + psNode.ParameterName);
                                    cp_GetImageDescriptionAfterSet.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after set image", "The return value in getImageDescription does not contain the node: " + psNode.ParameterName);
                                }
                                break; // End current foreach loop, not compare the follwing nodes
                            }
                        }

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

                            System.Diagnostics.Debug.Print("The return values in getImageDescription all match the expected.");
                            cp_GetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Get image Description after set returns success", rt_GetImageDescriptionAfterSet.Message);
                            cp_GetImageDescriptionAfterSet.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after set", "The return values in getImageDescription all match the expected");
                        }
                    }
                    #endregion

                CLEANUP:
                    #region Step 7: Call ImageService.deleteImage to delete the 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(imageinternalUid, 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);
                        break; // There is error, end test case
                    }
                    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 198: 1.3.6_GetImageInfo_Exception
        public void Run_Image_GetImageInfo_Exception_Case198()
        {
            int runCount = 0;

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

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

                try
                {
                    // Input parameter
                    XMLParameter getImageInfoParam = new XMLParameter("image");
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Key == "internal_id")
                        {
                            getImageInfoParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                    }

                    // Output value
                    string epErrorCode = string.Empty;
                    string epErrorMessage = string.Empty;
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Key == "error_code")
                        {
                            epErrorCode = ids.ExpectedValues.GetParameter(i).Value;
                        }
                        else if (ids.ExpectedValues.GetParameter(i).Key == "error_message")
                        {
                            epErrorMessage = ids.ExpectedValues.GetParameter(i).Value;
                        }
                    }

                    #region Step 1: Call ImageService.getImageInfo to get the image info
                    CheckPoint pGetImageInfo = new CheckPoint("getImageInfo", "Call ImageService.getImageInfo to get the image info");
                    r.CheckPoints.Add(pGetImageInfo);

                    ImageService imageService = new ImageService();
                    XMLResult getImageInfoResult = imageService.getImageInfo(getImageInfoParam);

                    if (getImageInfoResult.IsErrorOccured)
                    {
                        if (getImageInfoResult.Code.ToString() == epErrorCode && getImageInfoResult.Message.Contains(epErrorMessage))
                        {
                            pGetImageInfo.Result = TestResult.Pass;
                            pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo returns error as expected", "Return Code: " + getImageInfoResult.Code + "; Return message: " + getImageInfoResult.Message);
                        }
                        else
                        {
                            pGetImageInfo.Result = TestResult.Fail;
                            pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo doesnot return error as expected", "Return Code: " + getImageInfoResult.Code + "; Return message: " + getImageInfoResult.Message);

                            SaveRound(r);
                            break; // There is error, end test case
                        }
                    }
                    else
                    {
                        pGetImageInfo.Result = TestResult.Fail;
                        pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo doesnot return error", "Return Code: " + getImageInfoResult.Code + "; Return message: " + getImageInfoResult.Message);

                        SaveRound(r);
                        break; // There is error, end test case
                    }
                    #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 1558:  1.1.04.01 SetImage_N01_Call setImage when the original archived image file is accessible
        public void Run_Image_SetInfo_Normal_Case1558()
        {
            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 objectFileFullPath = string.Empty;
                    string archivePath = string.Empty;

                    XMLParameter pSetImageInfo = new XMLParameter("image");
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        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")
                            {
                                archivePath = 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

                    #region Step 0: Create a patient for import
                    patientInternalId = PatientService.Utility_CreatePatientForSpecificCase("case1558");

                    if (string.IsNullOrEmpty(patientInternalId))
                    {
                        goto CLEANUP;
                    }
                    #endregion

                    string imageInternalID = string.Empty;
                    string currentPSID = string.Empty;
                    ImportService importService = new ImportService();

                    #region Step 1: Call ImportService.importObject to import a image
                    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, archivePath, 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

                    string imagePathAfterImport = string.Empty;
                    string archivedPathAfterImport = string.Empty;
                    string archiveTagAfterImport = string.Empty;
                    ImageService imageSvc = new ImageService();

                    #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 = imageSvc.getImageDescription(imageInternalID);
                    imagePathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("path");
                    archivedPathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("archive_path");
                    archiveTagAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("tags");

                    if (string.IsNullOrEmpty(imagePathAfterImport) && archivedPathAfterImport.Equals(archivePath) && string.IsNullOrEmpty(archiveTagAfterImport)) //getImageDescription should return not tags info
                    {
                        cpGetImageDescriptionAfterImport.Result = TestResult.Pass;
                        cpGetImageDescriptionAfterImport.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is correct after import image" + rtGetImageDescriptionAfterImport.ResultContent);
                    }
                    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 = imageSvc.getImageInfo(pGetImageInfoAfterImport);

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

                    if (string.IsNullOrEmpty(imagePathAfterImport) && string.IsNullOrEmpty(archivedPathAfterImport) && string.IsNullOrEmpty(archiveTagAfterImport)) //&& archivePath.Equals(archivedPathAfterImport) && 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." + rtGetImageInfo.ResultContent);
                    }
                    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 2-3: Check the image info in listObject retrun after import, such as path, archivePath and tags
                    CheckPoint cpListObject = new CheckPoint("listObjects", "Call PatientService.listObjects to check the archive tag");
                    r.CheckPoints.Add(cpListObject);

                    NewPatientService patientSvcV2 = new NewPatientService();
                    PatientListObjectsRequestType pListObjects = new PatientListObjectsRequestType();
                    pListObjects.current = true;
                    pListObjects.currentSpecified = true;
                    pListObjects.patientInternalId = patientInternalId;
                    pListObjects.type = PatientListObjectsType.presentationState;
                    PatientListObjectsResponseType rtListObjectAfterImport = patientSvcV2.listObjects(pListObjects);

                    if (!patientSvcV2.LastReturnXMLValidateResult.isValid)
                    {
                        cpListObject.Result = TestResult.Fail;
                        cpListObject.Outputs.AddParameter("listObjects", "Check listObjects after import", "The listObjects return XML is not valid per XSD. Returned:" + patientSvcV2.LastReturnXML);
                    }
                    else
                    {
                        bool isArchivePathCorrect = string.Equals(rtListObjectAfterImport.presentationStates[0].image.archivePath, archivePath);
                        bool isPathCorrect = string.IsNullOrEmpty(rtListObjectAfterImport.presentationStates[0].image.path);
                        bool isTagCorrect = string.Equals(rtListObjectAfterImport.presentationStates[0].image.tags, "archived");

                        if (!isArchivePathCorrect || !isTagCorrect || !isPathCorrect)
                        {
                            cpListObject.Result = TestResult.Fail;
                            cpListObject.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag or archivedPath info is wrong in the return. Actually get: " + patientSvcV2.LastReturnXML);
                        }
                        else
                        {
                            cpListObject.Result = TestResult.Pass;
                            cpListObject.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag and archivedPath info is correct in the return.");
                        }
                    }
                    #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 = imageSvc.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);
                    #endregion

                        // 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
                        //6. The listObject return contains correct archive tag

                        #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 = imageSvc.listPresentationState(pListPS, imageInternalID).SingleResult;

                        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 archivedTagAfterSet = 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 = imageSvc.getImageDescription(imageInternalID);
                        imagePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("path");
                        archivePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("archive_path");
                        archivedTagAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("tags");

                        if (imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archivedTagAfterSet)) // 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 = imageSvc.getImageInfo(pGetImageInfoAfterSet);

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

                        if (imagePathAfterSet.Contains(Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory")) && imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archivedTagAfterSet))
                        {
                            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(archivePath))
                        {
                            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

                        #region Step 9: Check the image info in listObject retrun after set, such as path, archivePath and tags
                        CheckPoint cpListObjectAfterSet = new CheckPoint("listObjects", "Call PatientService.listObjects to check the archive tag after set");
                        r.CheckPoints.Add(cpListObjectAfterSet);

                        PatientListObjectsResponseType rtListObjectAfterSet = patientSvcV2.listObjects(pListObjects);
                        if (!patientSvcV2.LastReturnXMLValidateResult.isValid)
                        {
                            cpListObjectAfterSet.Result = TestResult.Fail;
                            cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check listObjects after set", "The listObjects return XML is not valid per XSD. Returned:" + patientSvcV2.LastReturnXML);
                        }
                        else
                        {
                            //bool isPathCorrect = rtListObjectAfterSet.presentationStates[0].image.path.Contains(Utility.GetCSDMConfig(CSDMConfigSection.remote, "patientDirectory")) && rtListObjectAfterSet.presentationStates[0].image.path.Contains(imageInternalID);
                            bool isArchivePathCorrect = string.IsNullOrEmpty(rtListObjectAfterSet.presentationStates[0].image.archivePath);
                            bool isTagCorrect = string.IsNullOrEmpty(rtListObjectAfterSet.presentationStates[0].image.tags);

                            if (!isArchivePathCorrect)
                            {
                                cpListObjectAfterSet.Result = TestResult.Fail;
                                cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The archivedPath info is wrong in the return. Actually get: " + patientSvcV2.LastReturnXML);
                            }
                            else if (!isTagCorrect)
                            {
                                cpListObjectAfterSet.Result = TestResult.Fail;
                                cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag info is wrong in the return. Actually get: " + patientSvcV2.LastReturnXML);
                            }
                            //else if (!isPathCorrect)
                            //{
                            //    cpListObjectAfterSet.Result = TestResult.Fail;
                            //    cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The path info is wrong in the return. Actually get: " + patientSvc.LastReturnXML);
                            //}
                            else
                            {
                                cpListObjectAfterSet.Result = TestResult.Pass;
                                cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag and archivedPath info is correct in the return.");
                            }
                        }
                        #endregion
                    }

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

                        XMLResult rt_DeleteImage = imageSvc.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

                CLEANUP:
                    #region Step 11: Delete the patient used in this case
                    if (!string.IsNullOrEmpty(patientInternalId))
                    {
                        CheckPoint cp_DeletePatient = new CheckPoint("Step 11: Delete Patient", "Call patientService.deletePatient to delete the patient");
                        r.CheckPoints.Add(cp_DeletePatient);

                        XMLResult rt_DeletePatient = PatientService.Utility_DeletePatientForSpecificCase(patientInternalId);
                        if (rt_DeletePatient.IsErrorOccured)
                        {
                            cp_DeletePatient.Result = TestResult.Fail;
                            cp_DeletePatient.Outputs.AddParameter("delete patient", "Delete patient returns error", rt_DeletePatient.Message);
                        }
                        else
                        {
                            cp_DeletePatient.Result = TestResult.Pass;
                            cp_DeletePatient.Outputs.AddParameter("delete patient", "Delete patient returns success", rt_DeletePatient.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.ToString());
                    SaveRound(r);
                }
            }

            Output();
        }
        // Case 1562: 1.1.04.05 SetImage_WorkFlow_02_Call setImage when archive path is NOT accessible and then call again when its  accessible
        public void Run_Image_SetInfo_WorkFlow_Case1562()
        {
            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 objectFileFullPath = string.Empty;
                    string archivedPath = string.Empty;

                    XMLParameter pSetImageInfo = new XMLParameter("image");
                    XMLParameter pSetImageInfoWithError = new XMLParameter("image");
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "importImage")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id")
                            {
                                patientInternalId = ids.InputParameters.GetParameter(i).Value;
                            }
                            else 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_error")
                        {
                            pSetImageInfoWithError.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                        else if (ids.InputParameters.GetParameter(i).Step == "setImageInfo_correct")
                        {
                            pSetImageInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                        }
                    }
                    #endregion

                    #region Step 1: Call ImportService.importObject to import a image
                    string imageInternalID = string.Empty;
                    string currentPSID = string.Empty;
                    ImportService importService = new ImportService();

                    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

                    ImageService imageService = new ImageService();

                    #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) && string.IsNullOrEmpty(archivedPathAfterImport) && string.IsNullOrEmpty(archiveTagAfterImport))  // archivedPathAfterImport == archivedPath, 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-1: Call imageService.SetImageInfo to save the archived image but the archive path is wrong
                    CheckPoint cpSetImageInfowithError = new CheckPoint("Set Image Info", "Call ImageService.SetImageInfo to save the archived image as normal image, with wrong path");
                    r.CheckPoints.Add(cpSetImageInfowithError);

                    XMLResult rtSetImageInfowithError = imageService.setImageInfo(pSetImageInfoWithError, imageInternalID);

                    if (rtSetImageInfowithError.IsErrorOccured)
                    {
                        cpSetImageInfowithError.Result = TestResult.Pass;
                        cpSetImageInfowithError.Outputs.AddParameter("SetImageInfo returns error as expected", "SetImageInfo", rtSetImageInfowithError.Message);
                    }
                    else
                    {
                        cpSetImageInfowithError.Result = TestResult.Fail;
                        cpSetImageInfowithError.Outputs.AddParameter("SetImageInfo returns success unexpectly", "SetImageInfo", rtSetImageInfowithError.Message);
                    }
                    #endregion

                    System.Threading.Thread.Sleep(1000);

                    #region Step 3-2: Call ImageService.SetImageInfo to save the archived image as normal image again
                    CheckPoint cpSetImageInfo = new CheckPoint("Set Image Info", "Call ImageService.SetImageInfo to save the archived image as normal image again, with correct path");
                    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 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 sample: 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

                    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 1172: 1.3.6_GetImageInfo_N03_4 valid ID
        public void Run_Image_GetInfo_4ID_Case1172()
        {
            int runCount = 0;

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

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

                try
                {
                    // Input parameter
                    XMLParameter getImageInfoParam = new XMLParameter("image");
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        getImageInfoParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }

                    // Output value
                    XMLParameter getImageInfoReturn_1 = new XMLParameter("image");
                    XMLParameter getImageInfoReturn_2 = new XMLParameter("image");
                    XMLParameter getImageInfoReturn_3 = new XMLParameter("image");
                    XMLParameter getImageInfoReturn_4 = new XMLParameter("image");
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_1")
                        {
                            if (ids.ExpectedValues.GetParameter(i).Key == "path") // to handle different path, such as in different OS or user changes the install dr
                            {
                                string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value;
                                getImageInfoReturn_1.AddParameter(ids.ExpectedValues.GetParameter(i).Key, path);
                            }
                            else
                            {
                                getImageInfoReturn_1.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                            }
                        }
                        if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_2")
                        {
                            if (ids.ExpectedValues.GetParameter(i).Key == "path") // to handle different path, such as in different OS or user changes the install dr
                            {
                                string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value;
                                getImageInfoReturn_2.AddParameter(ids.ExpectedValues.GetParameter(i).Key, path);
                            }
                            else
                            {
                                getImageInfoReturn_2.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                            }
                        }
                        if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_3")
                        {
                            if (ids.ExpectedValues.GetParameter(i).Key == "path") // to handle different path, such as in different OS or user changes the install dr
                            {
                                string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value;
                                getImageInfoReturn_3.AddParameter(ids.ExpectedValues.GetParameter(i).Key, path);
                            }
                            else
                            {
                                getImageInfoReturn_3.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                            }
                        }
                        if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_4")
                        {
                            if (ids.ExpectedValues.GetParameter(i).Key == "path") // to handle different path, such as in different OS or user changes the install dr
                            {
                                string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value;
                                getImageInfoReturn_4.AddParameter(ids.ExpectedValues.GetParameter(i).Key, path);
                            }
                            else
                            {
                                getImageInfoReturn_4.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                            }
                        }
                    }

                    #region Step 1: Call ImageService.getImageInfo to get the image info
                    CheckPoint pGetImageInfo = new CheckPoint("getImageInfo", "Call ImageService.getImageInfo to get the image info");
                    r.CheckPoints.Add(pGetImageInfo);

                    ImageService imageService = new ImageService();
                    XMLResult getImageInfoResult = imageService.getImageInfo(getImageInfoParam);

                    if (getImageInfoResult.IsErrorOccured)
                    {
                        pGetImageInfo.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call ImageService.getImageInfo to get the image info returns error.");
                        pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo to get the image info", getImageInfoResult.Message);

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

                        System.Diagnostics.Debug.Print("Call ImageService.getImageInfo to get the image info succeeds.");
                        pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo to get the image info", getImageInfoResult.Message);
                    }
                    #endregion

                    bool isValueEqual = false;
                    bool isKeyShow = false;

                    #region Step 2: Check the values in ImageService.getImageInfo return for the 1st image are correct
                    CheckPoint pImageInfo_1 = new CheckPoint("ImageInfo", "Check the values in ImageService.getImageInfo return for the 1st image");
                    r.CheckPoints.Add(pImageInfo_1);

                    // Check the return for the 1st image
                    foreach (XMLParameterNode psNode in getImageInfoReturn_1.Parameters)
                    {
                        isValueEqual = false;
                        isKeyShow = false;

                        int i = 0;
                        for (i = 0; i < getImageInfoResult.MultiResults[0].Parameters.Count; i++)
                        {
                            if (psNode.ParameterName == getImageInfoResult.MultiResults[0].Parameters[i].ParameterName)
                            {
                                isKeyShow = true;
                                isValueEqual = string.Equals(psNode.ParameterValue, getImageInfoResult.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
                        {
                            pImageInfo_1.Result = TestResult.Fail;

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

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

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

                        System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected.");
                        pImageInfo_1.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 1st image", "The return values in getImageInfo all match the expected");
                    }
                    #endregion

                    #region Step 3: Check the values in ImageService.getImageInfo return for the 2nd image are correct
                    CheckPoint pImageInfo_2 = new CheckPoint("ImageInfo", "Check the values in ImageService.getImageInfo return for the 2nd image");
                    r.CheckPoints.Add(pImageInfo_2);

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

                        int i = 0;
                        for (i = 0; i < getImageInfoResult.MultiResults[1].Parameters.Count; i++)
                        {
                            if (psNode.ParameterName == getImageInfoResult.MultiResults[1].Parameters[i].ParameterName)
                            {
                                isKeyShow = true;
                                isValueEqual = string.Equals(psNode.ParameterValue, getImageInfoResult.MultiResults[1].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
                        {
                            pImageInfo_2.Result = TestResult.Fail;

                            if (isKeyShow)
                            {
                                System.Diagnostics.Debug.Print("The return value in getImageInfo does not match the expected.");
                                pImageInfo_2.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 2nd image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + getImageInfoResult.MultiResults[1].Parameters[i].ParameterValue);
                            }
                            else
                            {
                                System.Diagnostics.Debug.Print("The return value in getImageInfo does not contain the node: " + psNode.ParameterName);
                                pImageInfo_2.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 2nd image", "The return value in getImageInfo does not contain the node: " + psNode.ParameterName);
                            }

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

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

                        System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected.");
                        pImageInfo_2.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 2nd image", "The return values in getImageInfo all match the expected");
                    }
                    #endregion

                    #region Step 4: Check the values in ImageService.getImageInfo return for the 3rd image are correct
                    CheckPoint pImageInfo_3 = new CheckPoint("ImageInfo", "Check the values in ImageService.getImageInfo return for the 3rd image");
                    r.CheckPoints.Add(pImageInfo_3);

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

                        int i = 0;
                        for (i = 0; i < getImageInfoResult.MultiResults[2].Parameters.Count; i++)
                        {
                            if (psNode.ParameterName == getImageInfoResult.MultiResults[2].Parameters[i].ParameterName)
                            {
                                isKeyShow = true;
                                isValueEqual = string.Equals(psNode.ParameterValue, getImageInfoResult.MultiResults[2].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
                        {
                            pImageInfo_3.Result = TestResult.Fail;

                            if (isKeyShow)
                            {
                                System.Diagnostics.Debug.Print("The return value in getImageInfo does not match the expected.");
                                pImageInfo_3.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 3rd image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + getImageInfoResult.MultiResults[2].Parameters[i].ParameterValue);
                            }
                            else
                            {
                                System.Diagnostics.Debug.Print("The return value in getImageInfo does not contain the node: " + psNode.ParameterName);
                                pImageInfo_3.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 3rd image", "The return value in getImageInfo does not contain the node: " + psNode.ParameterName);
                            }

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

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

                        System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected.");
                        pImageInfo_3.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 3rd image", "The return values in getImageInfo all match the expected");
                    }
                    #endregion

                    #region Step 5: Check the values in ImageService.getImageInfo return for the 4th image are correct
                    CheckPoint pImageInfo_4 = new CheckPoint("ImageInfo", "Check the values in ImageService.getImageInfo return for the 4th image");
                    r.CheckPoints.Add(pImageInfo_4);

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

                        int i = 0;
                        for (i = 0; i < getImageInfoResult.MultiResults[3].Parameters.Count; i++)
                        {
                            if (psNode.ParameterName == getImageInfoResult.MultiResults[3].Parameters[i].ParameterName)
                            {
                                isKeyShow = true;
                                isValueEqual = string.Equals(psNode.ParameterValue, getImageInfoResult.MultiResults[3].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
                        {
                            pImageInfo_4.Result = TestResult.Fail;

                            if (isKeyShow)
                            {
                                System.Diagnostics.Debug.Print("The return value in getImageInfo does not match the expected.");
                                pImageInfo_4.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 4th image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + getImageInfoResult.MultiResults[3].Parameters[i].ParameterValue);
                            }
                            else
                            {
                                System.Diagnostics.Debug.Print("The return value in getImageInfo does not contain the node: " + psNode.ParameterName);
                                pImageInfo_4.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 4th image", "The return value in getImageInfo does not contain the node: " + psNode.ParameterName);
                            }

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

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

                        System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected.");
                        pImageInfo_4.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 4th image", "The return values in getImageInfo 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();
        }
        public void Run_Acquisition_RotateAdjustRetaken_Case1640()
        {
            int runCount = 0;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;

                ReceiveNotification rn = new ReceiveNotification();
                List<string> topics = new List<string>();
                topics.Add("topic.imageCreated");
                string stopTopic = "teststop";
                string stopContent = "teststop";
                rn.startListon(topics, stopTopic, stopContent);

                string acqType = string.Empty;
                Round r = this.NewRound(runCount.ToString(), "7600CR Acquisition");
                CheckPoint pAcq = new CheckPoint("Acquire Image", "Acquisition CR7600");
                r.CheckPoints.Add(pAcq);
                AcquisitionService acqs = new AcquisitionService();
                XMLParameter acq = new XMLParameter("acq_info");
                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")
                    {
                        acqType = ids.InputParameters.GetParameter(i).Value;
                    }
                }

                XMLResult rslAcq = acqs.startAcquisition(acq);
                if (rslAcq.IsErrorOccured)
                {
                    System.Diagnostics.Debug.Print("Acquire fail:");
                    pAcq.Result = TestResult.Fail;
                    pAcq.Outputs.AddParameter("Acquire image error", "startAcquisition", rslAcq.Message);
                    SaveRound(r);
                    continue;
                }
                System.Threading.Thread.Sleep(15000);

                System.Diagnostics.Process p = new System.Diagnostics.Process();
                switch (acqType)
                {
                    case "rotate":
                        p.StartInfo.FileName = "7600helperRotate.exe";
                        break;
                    case "adjust":
                        p.StartInfo.FileName = "7600helperAdjust.exe";
                        break;
                    case "retaken":
                        p.StartInfo.FileName = "7600helperRetaken.exe";
                        break;
                }
                p.Start();
                p.WaitForExit();

                int retrynum = 24;
                int n = 0;
                while (rn.getRecievedNumber() == 0)
                {
                    n++;
                    if (n < retrynum)
                    {
                        System.Threading.Thread.Sleep(5000);
                    }
                    else
                        break;
                }

                if (n == retrynum)
                {
                    pAcq.Result = TestResult.Fail;
                    pAcq.Outputs.AddParameter("Acquire 7600", "Notification Fail", @"Recieve Notification Timeout(120 seconds)");
                    SaveRound(r);
                    continue;
                }

                System.Threading.Thread.Sleep(15000);
                ApplicationService apps = new ApplicationService();
                apps.sendGenericNotification(stopTopic, stopContent);
                System.Threading.Thread.Sleep(1000);
                List<string> mmm = rn.getNotificationContent();
                ImageService imgs = new ImageService();
                if (acqType == "retaken")
                {
                    int notificationNum = mmm.Count;
                    if (notificationNum != 3)
                    {
                        pAcq.Result = TestResult.Fail;
                        pAcq.Outputs.AddParameter("Acquire 7600", "Notification number not correct", " Actual:" + notificationNum.ToString() + "Expect:3");
                        SaveRound(r);
                        continue;
                    }
                    foreach (string msg in mmm)
                    {
                        string[] token = msg.Split('=');
                        string imageid = token[token.Length - 1];
                        XMLParameter cImg = new XMLParameter("image");
                        cImg.AddParameter("internal_id", imageid);
                        XMLResult rslGetRetaken = imgs.getImageInfo(cImg);
                        if (rslGetRetaken.IsErrorOccured)
                        {
                            pAcq.Result = TestResult.Fail;
                            pAcq.Outputs.AddParameter("Acquire 7600", "Get Retaken Image Fail", rslGetRetaken.Message);
                            SaveRound(r);
                            goto error;
                        }
                    }

                    goto retaken;
                error:
                    continue;
                }

                string[] token1 = mmm[0].Split('=');
                string imageid1 = token1[token1.Length - 1];

                XMLParameter img = new XMLParameter("image");
                img.AddParameter("internal_id", imageid1);
                XMLResult rslGet = imgs.getImageInfo(img);
                if (rslGet.IsErrorOccured)
                {
                    pAcq.Result = TestResult.Fail;
                    pAcq.Outputs.AddParameter("Acquire 7600", "GetImage Fail", rslGet.Message);
                    SaveRound(r);
                    continue;
                }
                XMLParameter filter = new XMLParameter("filter");
                filter.AddParameter("current", "true");
                XMLResult rslListPS = imgs.listPresentationState(filter, imageid1);
                string psid = rslListPS.SingleResult;

                PresentationStateService pss = new PresentationStateService();
                XMLResult rslget = pss.getPresentationState(psid);
                string processingXml = rslget.MultiResults[0].Parameters[0].ParameterValue.Trim();
                ProcessingXMLParser parser = new ProcessingXMLParser(processingXml);
                ProcessingXMLInfo pinfo = parser.parse();

                if (acqType == "rotate" && pinfo.Rotate180Enabled != "true")
                {
                    pAcq.Result = TestResult.Fail;
                    pAcq.Outputs.AddParameter("Acquire 7600", "ProcessingXML not correct", "Rotate180 is " + pinfo.Rotate180Enabled);
                    SaveRound(r);
                    continue;
                }

                if (acqType == "adjust" && pinfo.BrightnessEnabled != "true" && pinfo.BrightnessValue == "0")
                {
                    pAcq.Result = TestResult.Fail;
                    pAcq.Outputs.AddParameter("Acquire 7600", "ProcessingXML not correct", "BrightnessValue is 0");
                    SaveRound(r);
                    continue;
                }
            retaken:
                pAcq.Result = TestResult.Pass;
                pAcq.Outputs.AddParameter("Acquire 7600", "Success", "OK");
                SaveRound(r);
            }
            Output();
        }
        //Case 1598: 1.1.06.21_ImportDir_MainDirectory_N01
        public void Run_Import_ImportDir_MainDirectory_Case1598()
        {
            int runCount = 0;
            NotificationSim.ReceiveNotification rn = new ReceiveNotification();
            System.Collections.Generic.List<string> topics = new System.Collections.Generic.List<string>();
            topics.Add("topic.postImportCompleted");
            string stopTopic = "teststop";
            string stopContent = "teststop";
            rn.startListon(topics, stopTopic, stopContent);

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "ImportMainDir");
                CheckPoint pimp = new CheckPoint("ImportDir", "Import Additional Dir");
                r.CheckPoints.Add(pimp);

                //create patient for import
                PatientService ps = new PatientService();
                XMLParameter cInputPatient = new XMLParameter("patient");
                cInputPatient.AddParameter("first_name", "test");
                cInputPatient.AddParameter("last_name", "importmaindir");
                XMLResult rslCreate = ps.createPatient(cInputPatient);

                if (rslCreate.IsErrorOccured)
                {
                    pimp.Result = TestResult.Fail;
                    pimp.Outputs.AddParameter("Import Main Dir", "Create Patient Fail", rslCreate.Message);
                    SaveRound(r);
                    continue;
                }
                string patientid = rslCreate.SingleResult;
                try
                {
                    string kdis6dir = ids.InputParameters.GetParameter("kdis6_dir").Value;

                    int retrynum = int.Parse(ids.InputParameters.GetParameter("retrynum").Value);
                    string flag = "import";
                    ImportService imps = new ImportService();
                    XMLResult rslimport = imps.importDir(patientid, kdis6dir, flag);

                    if (rslimport.Code != 800)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "Import Fail", rslimport.Message);
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    int n = 0;
                    while (rn.getRecievedNumber() == 0)
                    {
                        n++;
                        if (n < retrynum)
                        {
                            System.Threading.Thread.Sleep(5000);
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (n == retrynum)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "Notification Fail", "No notification recieved after retry " + n.ToString() + " times.");
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    ApplicationService app = new ApplicationService();
                    app.sendGenericNotification(stopTopic, stopContent);
                    System.Threading.Thread.Sleep(1000);
                    System.Collections.Generic.List<string> mmm = rn.getNotificationContent();
                    System.Collections.Generic.List<string> imageids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("Image", mmm[0]);
                    System.Collections.Generic.List<string> fmsids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("FMS", mmm[0]);
                    System.Collections.Generic.List<string> analysisids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("Analysis", mmm[0]);

                    int expectedimgcount = int.Parse(ids.ExpectedValues.GetParameter("imgnum").Value);
                    int expectedfmscount = int.Parse(ids.ExpectedValues.GetParameter("fmsnum").Value);
                    int expectedanalysiscount = int.Parse(ids.ExpectedValues.GetParameter("analysisnum").Value);

                    //check counts
                    if (imageids.Count != expectedimgcount)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "Image Count is not correct", "Actual:" + imageids.Count.ToString() + ",Expected:" + expectedimgcount.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (fmsids.Count != expectedfmscount)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "FMS Count is not correct", "Actual:" + fmsids.Count.ToString() + ",Expected:" + expectedfmscount.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (analysisids.Count != expectedanalysiscount)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "Analysis Count is not correct", "Actual:" + analysisids.Count.ToString() + ",Expected:" + expectedanalysiscount.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    //get image info
                    ImageService imgs = new ImageService();
                    foreach (string imgid in imageids)
                    {
                        XMLParameter cInputImage = new XMLParameter("image");
                        cInputImage.AddParameter("internal_id", imgid);
                        XMLResult rslget = imgs.getImageInfo(cInputImage);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "GetImage Fail", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }
                    }
                    //get FMS info
                    FMSService fmss = new FMSService();
                    foreach (string fmsid in fmsids)
                    {
                        XMLResult rslget = fmss.getFMSInfo(fmsid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "GetFMS Fail", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }
                        rslget = fmss.getFMSDescription(fmsid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "GetFMS Fail", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }
                    }
                    //get Analysis info
                    AnalysisService anas = new AnalysisService();
                    foreach (string analysisid in analysisids)
                    {
                        XMLResult rslget = anas.getAnalysisInfo(analysisid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "GetAnalysis Fail", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }
                        rslget = anas.getAnalysisDescription(analysisid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "GetAnalysis Fail", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }
                    }

                    //check list object
                    NewPatientService nps = new NewPatientService();
                    PatientListObjectsRequestType request = new PatientListObjectsRequestType();
                    request.currentSpecified = true;
                    request.current = true;
                    request.patientInternalId = patientid;
                    request.type = PatientListObjectsType.all;
                    PatientListObjectsResponseType response = nps.listObjects(request);
                    //to refresh code 800 to 0
                    response = nps.listObjects(request);

                    if (!nps.LastReturnXMLValidateResult.isValid)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail", "Response is not complied with schema");
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (response.status.code != 0)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,message: ", response.status.message);
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    int expectedcurrentps = int.Parse(ids.ExpectedValues.GetParameter("curpsnum").Value);
                    int expectedcurrentfms = int.Parse(ids.ExpectedValues.GetParameter("curfmsnum").Value);
                    int expectedcurrentanalysis = int.Parse(ids.ExpectedValues.GetParameter("curanalysisnum").Value);
                    if (response.presentationStates.Length != expectedcurrentps)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current image count not correct: ", "actural:" + response.presentationStates.Length.ToString() + " expect:" + expectedcurrentps.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }
                    //get PS
                    PresentationStateService pss = new PresentationStateService();
                    foreach (PresentationStateType pst in response.presentationStates)
                    {
                        XMLResult rslget = pss.getPresentationState(pst.uid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "get PS fail: ", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }

                    }

                    if (response.analysiss != null)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current analysis count not correct: ", "Expect no analysis will be returned");
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (response.fmss.Length != expectedcurrentfms)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current fms count not correct: ", "actural:" + response.fmss.Length.ToString() + " expect:" + expectedcurrentfms.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    //list noncurrent objects

                    request.currentSpecified = true;
                    request.current = false;
                    request.patientInternalId = patientid;
                    request.type = PatientListObjectsType.all;

                    response = nps.listObjects(request);

                    int expectednoncurrentps = int.Parse(ids.ExpectedValues.GetParameter("noncurpsnum").Value);
                    int expectednoncurrentfms = int.Parse(ids.ExpectedValues.GetParameter("noncurfmsnum").Value);
                    int expectednoncurrentanalysis = int.Parse(ids.ExpectedValues.GetParameter("noncuranalysisnum").Value);
                    if (response.presentationStates.Length != expectednoncurrentps)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail, non current ps count not correct: ", "actual:" + response.presentationStates.Length.ToString() + " expect:" + expectednoncurrentanalysis.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }
                    //get PS
                    foreach (PresentationStateType pst in response.presentationStates)
                    {
                        XMLResult rslget = pss.getPresentationState(pst.uid);
                        if (rslget.IsErrorOccured)
                        {
                            pimp.Result = TestResult.Fail;
                            pimp.Outputs.AddParameter("Import Main Dir", "get PS fail: ", rslget.Message);
                            SaveRound(r);
                            ps.deletePatient(patientid);
                            goto error;
                        }

                    }

                    //check 3d object

                    if (response.volumes.Length != int.Parse(ids.ExpectedValues.GetParameter("expect3dnum").Value))
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "Import 3d objects fail: ", "Count is " + response.volumes.Length.ToString() + ",expect:" + ids.ExpectedValues.GetParameter("expect3dnum").Value);
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (response.analysiss.Length != expectednoncurrentanalysis)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,non current analysis count not correct: ", "actual:" + response.analysiss.Length.ToString() + " expect:" + expectednoncurrentanalysis.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    if (response.fmss.Length != expectednoncurrentfms)
                    {
                        pimp.Result = TestResult.Fail;
                        pimp.Outputs.AddParameter("Import Main Dir", "list object fail,non current fms count not correct: ", "actual:" + response.fmss.Length.ToString() + " expect:" + expectednoncurrentfms.ToString());
                        SaveRound(r);
                        ps.deletePatient(patientid);
                        continue;
                    }

                    //Finally the test success
                    pimp.Result = TestResult.Pass;
                    pimp.Outputs.AddParameter("Import Main Dir", "Success", "OK");
                    SaveRound(r);
                    ps.deletePatient(patientid);
                }
                catch (Exception e)
                {
                    ps.deletePatient(patientid);
                    pimp.Result = TestResult.Fail;
                    pimp.Outputs.AddParameter("Import Main Dir", "Fail", "Exception caught,message:" + e.Message);
                    SaveRound(r);
                }

            }
            error:
            Output();
        }
        // Case 721: 1.3.10_ImportImage_N02_Archived image
        public void Run_Import_ArchivedImage_Case721()
        {
            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);
                    }
                }

                XMLParameter epGetImagInfo = new XMLParameter();
                XMLParameter epGetImageDescription = new XMLParameter();

                for (int i = 0; i < ids.ExpectedValues.Count; i++)
                {
                    if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo")
                    {
                        epGetImagInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                    }
                    else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription")
                    {
                        epGetImageDescription.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                    }
                }

                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 expected key and value
                        ImageService imageSvc = new ImageService();

                        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 return info contain the expected key and value: parameter key="XXX" value="XXX"
                            foreach (XMLParameterNode node in epGetImagInfo.Parameters)
                            {
                                if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\""))
                                {
                                    cpGetImageInfo.Result = TestResult.Fail;
                                    cpGetImageInfo.Outputs.AddParameter("Get Image Info returns wrong key-value info for: " + node.ParameterName, "GetImageInfo", rtGetImageInfo.ResultContent);
                                    continue;
                                }
                                else
                                {
                                    cpGetImageInfo.Outputs.AddParameter("Get Image Info returns correct key-value info for: " + node.ParameterName, "GetImageInfo", "ok");
                                }
                            }

                            if (cpGetImageInfo.Result != TestResult.Fail)
                            {
                                cpGetImageInfo.Result = TestResult.Pass;
                                cpGetImageInfo.Outputs.AddParameter("Get Image Info return all correct info", "GetImageInfo", rtGetImageInfo.ResultContent);
                            }
                        }
                        #endregion

                        #region Call getImageDescription to check expected key and value
                        CheckPoint cpGetImageDescription = new CheckPoint("GetImageDescription", "Call GetImageDescription to check the info in return value");
                        r.CheckPoints.Add(cpGetImageDescription);

                        XMLResult rtGetImageDescription = imageSvc.getImageDescription(imageID);
                        if (rtGetImageDescription.IsErrorOccured)
                        {
                            cpGetImageDescription.Result = TestResult.Fail;
                            cpGetImageDescription.Outputs.AddParameter("Get Image Description returns error", "getImageDescription", rtGetImageDescription.ResultContent);
                        }
                        else
                        {
                            cpGetImageDescription.Outputs.AddParameter("Get Image Description return success", "getImageDescription", rtGetImageDescription.Message);

                            //Check the return info contain the expected key and value: parameter key="XXX" value="XXX"
                            foreach (XMLParameterNode node in epGetImageDescription.Parameters)
                            {
                                if (!rtGetImageDescription.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\""))
                                {
                                    cpGetImageDescription.Result = TestResult.Fail;
                                    cpGetImageDescription.Outputs.AddParameter("Get Image Description returns wrong key-value info for: " + node.ParameterName, "GetImageDescription", rtGetImageDescription.ResultContent);
                                    continue;
                                }
                                else
                                {
                                    cpGetImageDescription.Outputs.AddParameter("Get Image Description returns correct key-value info for: " + node.ParameterName, "GetImageDescription", "ok");
                                }
                            }

                            if (cpGetImageDescription.Result != TestResult.Fail)
                            {
                                cpGetImageDescription.Result = TestResult.Pass;
                                cpGetImageDescription.Outputs.AddParameter("Get Image Description returns all correct info", "GetImageDescription", rtGetImageDescription.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();
        }
        // 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();
        }
        public void Run_Acquisition_New_Ceph_4_Case1672()
        {
            int runCount = 0;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                string acquireType = string.Empty;
                Round r = this.NewRound(runCount.ToString(), "Acquisition");
                ApplicationService apps = new ApplicationService();
                //start 2D simulator and register 2D simulator to CSDM with same port number
                Start2DSimulator s2d = new Start2DSimulator(10000);
                System.Threading.Thread.Sleep(20);
                apps.registerApplication("2DViewer", "localhost", 10000, true);

                //get acquire information and expect information
                XMLParameter acq = new XMLParameter("acq_info");
                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;
                    }
                }
                Dictionary<string, string> expectVal = new Dictionary<string, string>();
                for (int j = 0; j < ids.ExpectedValues.Count; j++)
                {
                    if (ids.InputParameters.GetParameter(j).Step == "acquire")
                    {
                        expectVal.Add(ids.ExpectedValues.GetParameter(j).Key, ids.ExpectedValues.GetParameter(j).Value);
                    }
                }

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

                string stopMessageType = "teststop";
                string stopMessageContent = "teststop";

                string hostadd = PAS.AutoTest.TestUtility.Utility.GetCSDMConfig(PAS.AutoTest.TestUtility.CSDMConfigSection.remote, "host");
                string portnoti = PAS.AutoTest.TestUtility.Utility.GetCSDMConfig(PAS.AutoTest.TestUtility.CSDMConfigSection.remote, "notificationPort");
                NotificationSim.ReceiveNotification rn = new NotificationSim.ReceiveNotification(hostadd, int.Parse(portnoti));

                System.Collections.Generic.List<string> rms = new System.Collections.Generic.List<string>();
                rms.Add("topic.acquisitionCompleted");
                rn.startListon(rms, stopMessageType, stopMessageContent);

                AcquisitionService acqs = new AcquisitionService();
                XMLResult rslAcqRVG = acqs.startAcquisition(acq);
                string acq_session_id = "";

                System.Threading.Thread.Sleep(1000);
                switch (acquireType)
                {
                    case "PANO":
                        System.Diagnostics.Debug.Print("PANO Acquire");
                        //Utility.AcqPanoImage(300);
                        System.Threading.Thread tx = new System.Threading.Thread(Utility.AcquirePanoOne);
                        tx.Start();
                        break;
                    case "CEPH":
                        System.Diagnostics.Debug.Print("CEPH Acquire");
                        //Utility.AcqCephImage(50);
                        System.Threading.Thread tx1 = new System.Threading.Thread(Utility.AcquireCephOne);
                        tx1.Start();
                        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);
                    continue;
                }
                else
                {
                    acq_session_id = rslAcqRVG.SingleResult;
                    pAcquire.Result = TestResult.Pass;
                    pAcquire.Outputs.AddParameter("Acquire image success", "startAcquisition", rslAcqRVG.ResultContent);

                    //start an advanced simulator to receive the specified command
                    int port = 10000;
                    string sRet = "";
                    TwoDSim.AdvanceSimulator asi = new TwoDSim.AdvanceSimulator(port);
                    asi.StartSimulater("0,OK;open_acquired_objects");
                    sRet = asi.StopSimulator(120000);

                    CheckPoint pCheckMessage = new CheckPoint("Check Command", "Acquisition SOCKET Message");
                    r.CheckPoints.Add(pCheckMessage);
                    if (sRet == "")
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("NO COMMAND", "Check Command", "TIMEOUT: The socket message doesn't received");
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        pCheckMessage.Outputs.AddParameter("open_acquired_objects COMMAND parameter", "Record Command", sRet);
                    }

                    ParseMessageContent cn = new ParseMessageContent(sRet);

                    //get patient internal id from command message
                    string patient_uid = cn.getValueFromKey("-patient_internal_id");
                    bool gotPatientId = false;
                    foreach (KeyValuePair<string, string> kvp in expectVal)
                    {
                        if (kvp.Key == "patient_internal_id" && kvp.Value == patient_uid)
                        {
                            gotPatientId = true;
                        }
                    }
                    if (!gotPatientId)
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("Patient ID Check ERROR", "Check Command", "The socket message content with WRONG patient ID");
                        SaveRound(r);
                        continue;
                    }

                    string image_internal_id_from_acqResult = "";
                    string ps_internal_id_from_acqResult = "";
                    string image_internal_id_from_mapfile = "";
                    string ps_internal_id_from_mapfile = "";

                    //get acquisition session id from command message
                    string session_uid_from_command = cn.getValueFromKey("-session_id");
                    if (acq_session_id != session_uid_from_command)
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("Session ID Check ERROR", "Check Command", "The session id from command not equals the id from startAcquisition!");
                        SaveRound(r);
                        continue;
                    }
                    int timeout = 0;
                    do
                    {
                        XMLResult rslgetAcqResult = acqs.getAcquisitionResult(session_uid_from_command);
                        //timeout added
                        if (!rslgetAcqResult.IsErrorOccured && rslgetAcqResult.Code == 0)
                        {
                            pCheckMessage.Outputs.AddParameter("Show the content after getAcquisitionResult", "Output getAcquisitionResult", rslgetAcqResult.ResultContent);
                            ParseXMLContent rslacqResult = new ParseXMLContent(rslgetAcqResult.ResultContent);
                            image_internal_id_from_acqResult = rslacqResult.getStringWithPathAndType("trophy/object_info", "image", "value");
                            ps_internal_id_from_acqResult = rslacqResult.getStringWithPathAndType("trophy/object_info", "presentation_state", "value");
                            break;
                        }
                        timeout++;
                        System.Threading.Thread.Sleep(1000);
                    } while (timeout < 120);
                    if (timeout >= 120)
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("Try too many times", "Check getAcquisitionResult", "TIMEOUT of getAcquisitionResult");
                        break;
                    }

                    //parser the mapping xml content from command message
                    string mapping_xml = cn.getValueFromKey("-mapping_xml");
                    string mapping_content = base64tools.DecodeString4base(mapping_xml);
                    pCheckMessage.Outputs.AddParameter("Show the decode mapping file content", "Output mappingfile", mapping_content);
                    string target_path = "";

                    if (mapping_content != null)
                    {
                        ParseXMLContent pc = new ParseXMLContent(mapping_content);
                        pc.getValueFromPath("path_mapping/instance");
                        string type = pc.getValueByKey("type");

                        int indexKey = type.IndexOf(";");
                        if (indexKey != -1)
                            type = type.Substring(0, indexKey);

                        bool gotType = false;
                        foreach (KeyValuePair<string, string> kvp in expectVal)
                        {
                            if (kvp.Key == "type" && kvp.Value == type)
                            {
                                gotType = true;
                            }
                        }
                        if (!gotType)
                        {
                            pCheckMessage.Result = TestResult.Fail;
                            pCheckMessage.Outputs.AddParameter("Type Check ERROR", "Check Command ", "The socket message content with WRONG type");
                            SaveRound(r);
                            continue;
                        }

                        string original_path = pc.getValueByKey("original_path");

                        //check the acquired image has been put into correct position.
                        target_path = pc.getValueByKey("target_path");
                        int indexPath = target_path.IndexOf(";");
                        if (indexPath != -1)
                            target_path = target_path.Substring(0, indexPath);
                        //now the Processing data file not provide correct after send command
                        bool dicomfileexist = Utility.isFileExisted(target_path);
                        if (!dicomfileexist)
                        {
                            pCheckMessage.Result = TestResult.Fail;
                            pCheckMessage.Outputs.AddParameter("Dicom File Check ERROR", "Check Command", "The acquired image not in cache place");
                            SaveRound(r);
                            continue;
                        }

                        image_internal_id_from_mapfile = pc.getWithPathAndTypeFromMappingFile("path_mapping", "Image", "instance_internal_id");
                        ps_internal_id_from_mapfile = pc.getWithPathAndTypeFromMappingFile("path_mapping", "Image", "ps_internal_id");
                    }
                    if (image_internal_id_from_acqResult != image_internal_id_from_mapfile)
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("Message and Interface result", "Check Command", "The image id from command not equals the id from getAcquisitionResult!");
                        SaveRound(r);
                        continue;
                    }
                    if (ps_internal_id_from_acqResult != ps_internal_id_from_mapfile)
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("Message and Interface result", "Check Command", "The presentation id from command not equals the id from getAcquisitionResult!");
                        SaveRound(r);
                        continue;
                    }

                    //parser the trophy xml content from command message
                    string acq_out_xml = cn.getValueFromKey("-acq_out_xml");
                    string acq_out = base64tools.DecodeString4base(acq_out_xml);
                    pCheckMessage.Outputs.AddParameter("XML From SDK", "Output acquisition SDK content", acq_out);
                    pCheckMessage.Result = TestResult.Pass;
                    pCheckMessage.Outputs.AddParameter("Message and Interface result", "Check Command", "All ID is matched");

                    CheckPoint pCheckGetImage = new CheckPoint("Check NOTIFICATION", "Acquisition complete Message");
                    r.CheckPoints.Add(pCheckGetImage);
                    apps.sendGenericNotification(stopMessageType, stopMessageContent);
                    System.Threading.Thread.Sleep(1000);

                    //check getImageInfo
                    int getn = rn.getNotificationNumber();
                    if (getn == 2)
                    {

                        XMLParameter getImage = new XMLParameter("image");
                        int indexImage = image_internal_id_from_acqResult.IndexOf(";");
                        if (indexImage != -1)
                            image_internal_id_from_acqResult = image_internal_id_from_acqResult.Substring(0, indexImage);
                        getImage.AddParameter("internal_id", image_internal_id_from_acqResult);
                        ImageService imagesrv = new ImageService();
                        XMLResult getImageRsl = imagesrv.getImageInfo(getImage);
                        //match items
                        pCheckGetImage.Outputs.AddParameter("Get Image Info result", "Get Return XML", getImageRsl.ResultContent);
                        int matchValueCount = 0;
                        for (int i = 0; i < getImageRsl.DicomArrayResult.Length; i++)
                        {
                            if (getImageRsl.DicomArrayResult.Parameters[i].ParameterName == "internal_id"
                                && getImageRsl.DicomArrayResult.Parameters[i].ParameterValue == image_internal_id_from_acqResult)
                            {
                                matchValueCount++;
                            }

                            if (getImageRsl.DicomArrayResult.Parameters[i].ParameterName == "patient_internal_id"
                                && getImageRsl.DicomArrayResult.Parameters[i].ParameterValue == patient_uid)
                            {
                                matchValueCount++;
                            }
                            target_path = target_path.Replace('\\', '/');
                            if (getImageRsl.DicomArrayResult.Parameters[i].ParameterName == "path"
                                && getImageRsl.DicomArrayResult.Parameters[i].ParameterValue == target_path)
                            {
                                matchValueCount++;
                            }
                        }
                        if (matchValueCount == 3)
                        {
                            pCheckGetImage.Result = TestResult.Pass;
                            pCheckGetImage.Outputs.AddParameter("Get Image Info result", "Check Return XML", "All ID is matched");
                        }
                        else
                        {
                            pCheckGetImage.Result = TestResult.Fail;
                            pCheckGetImage.Outputs.AddParameter("Get Image Info result", "Check Return XML", "Some ID is not matched");
                        }

                    }
                    else
                    {
                        pCheckGetImage.Result = TestResult.Fail;
                        pCheckGetImage.Outputs.AddParameter("Notification not received", "Check Return", "No acquisition complete Message be received");
                    }

                }
                SaveRound(r);
            }
            Output();
        }
        public void Run_Acquisition_GetImageInfo_Case1173()
        {
            int runCount = 0;
            string acquireType = string.Empty;

            ApplicationService app = new ApplicationService();
            NotificationSim.ReceiveNotification rn = new NotificationSim.ReceiveNotification();
            System.Collections.Generic.List<string> topics = new System.Collections.Generic.List<string>();
            topics.Add("topic.acquisitionCompleted");
            topics.Add("topic.imageCreated");

            string stopTopic = "teststop";
            string stopContent = "teststop";
            rn.startListon(topics, stopTopic, stopContent);

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

                AcquisitionService acqs = new AcquisitionService();

                XMLParameter acq = new XMLParameter("acq_info");
                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;
                    }
                }

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

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

                switch (acquireType)
                {
                    case "CR7600":
                        System.Diagnostics.Debug.Print("CR7600 Acquire");
                        System.Diagnostics.Process p = System.Diagnostics.Process.Start("7600helper.exe");
                        p.WaitForExit();
                        break;
                    default:
                        System.Diagnostics.Debug.Print("NOT CR7600 Acquire");
                        break;
                }
                System.Threading.Thread.Sleep(60000);//Wait acqpanel exit
                app.sendGenericNotification(stopTopic, stopContent);
                System.Threading.Thread.Sleep(1000);

                if (rslAcqRVG.IsErrorOccured)
                {
                    System.Diagnostics.Debug.Print("Acquire fail:");
                    pAcquire.Result = TestResult.Fail;
                    pAcquire.Outputs.AddParameter("Acquire image error", "startAcquisition", rslAcqRVG.Message);
                    continue;
                }
                else
                {
                    pAcquire.Outputs.AddParameter("Acquire session ID", "startAcquisition", rslAcqRVG.SingleResult);
                    int msgnum = rn.getNotificationNumber();
                    if (msgnum != 3)
                    {
                        pAcquire.Result = TestResult.Fail;
                        pAcquire.Outputs.AddParameter("Notification Error", "startAcquisition", "RecievedMessageNo:" + msgnum.ToString() + ",Expected:3");
                        continue;
                    }

                    System.Collections.Generic.List<string> mmm = rn.getNotificationContent();
                    string[] token = mmm[0].Split('=');
                    string imageid = token[token.Length - 1];
                    ImageService imgs = new ImageService();
                    XMLParameter cInputImgid = new XMLParameter("image");
                    cInputImgid.AddParameter("internal_id", imageid);
                    XMLResult getRsl = imgs.getImageInfo(cInputImgid);
                    if (!getRsl.IsErrorOccured)
                    {
                        pAcquire.Result = TestResult.Pass;
                        pAcquire.Outputs.AddParameter("Acquistion Success", "startAcquisition", "Message:OK");
                    }
                    else
                    {
                        pAcquire.Result = TestResult.Fail;
                        pAcquire.Outputs.AddParameter("GetImageInfo Error", "startAcquisition", "Message:" + getRsl.Message);
                        continue;
                    }

                }

                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 1624: 1.3.6_WorkFlow_N05_Import DICOM Image_Check DICOM Info
        public void Run_Image_Import_GetInfo_Case1624()
        {
            int runCount = 0;

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

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

                try
                {
                    // Input parameter
                    string patientID = null;
                    string objectFileFullPath = null;
                    string imageID = null;
                    for (int i = 0; i < ids.InputParameters.Count; i++)
                    {
                        if (ids.InputParameters.GetParameter(i).Step == "import")
                        {
                            if (ids.InputParameters.GetParameter(i).Key == "patientID")
                            {
                                patientID = ids.InputParameters.GetParameter(i).Value;
                            }
                            else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath")
                            {
                                objectFileFullPath = ids.InputParameters.GetParameter(i).Value;
                            }
                        }
                    }

                    // Output value
                    XMLParameter getImageInfoReturnValue = new XMLParameter("image");
                    for (int i = 0; i < ids.ExpectedValues.Count; i++)
                    {
                        if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo")
                        {
                            if (ids.ExpectedValues.GetParameter(i).Key == "path") // to handle different path, such as in different OS or user changes the install dr
                            {
                                string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value;
                                getImageInfoReturnValue.AddParameter(ids.ExpectedValues.GetParameter(i).Key, path);
                            }
                            else
                            {
                                getImageInfoReturnValue.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value);
                            }
                        }
                    }

                    #region Step: mport the image
                    ImportService importSvc = new ImportService();
                    XMLResult rtImport = importSvc.CallImportAndCheck(r, patientID, objectFileFullPath, null);
                    if (rtImport.IsErrorOccured)
                    {
                        continue;
                    }
                    else
                    {
                        imageID = rtImport.SingleResult;
                    }
                    #endregion

                    #region Step 1: Call ImageService.getImageInfo to get the image info
                    CheckPoint pGetImageInfo = new CheckPoint("getImageInfo", "Call ImageService.getImageInfo to get the image info");
                    r.CheckPoints.Add(pGetImageInfo);

                    ImageService imageService = new ImageService();
                    XMLParameter getImageInfoParam = new XMLParameter("image");
                    getImageInfoParam.AddParameter("internal_id", imageID);
                    XMLResult getImageInfoResult = imageService.getImageInfo(getImageInfoParam);

                    if (getImageInfoResult.IsErrorOccured)
                    {
                        pGetImageInfo.Result = TestResult.Fail;

                        System.Diagnostics.Debug.Print("Call ImageService.getImageInfo to get the image info returns error.");
                        pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo to get the image info", getImageInfoResult.Message);

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

                        System.Diagnostics.Debug.Print("Call ImageService.getImageInfo to get the image info succeeds.");
                        pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo to get the image info", getImageInfoResult.Message);
                    }
                    #endregion

                    #region Step 2: Check the values in ImageService.getImageInfo return are correct
                    CheckPoint pImageInfo = new CheckPoint("ImageInfo", "Check the values in ImageService.getImageInfo return");
                    r.CheckPoints.Add(pImageInfo);

                    string dicom_info = null;
                    for (int i = 0; i < getImageInfoResult.DicomArrayResult.Parameters.Count; i++)
                    {
                        if (getImageInfoResult.DicomArrayResult.Parameters[i].ParameterName == "dicom_info")
                        {
                            dicom_info = getImageInfoResult.DicomArrayResult.Parameters[i].ParameterValue;
                            break; // End current for loop to search node
                        }
                    }

                    foreach (XMLParameterNode psNode in getImageInfoReturnValue.Parameters)
                    {
                        if (!dicom_info.Contains("<parameter key=\"" + psNode.ParameterName + "\" value=\"" + psNode.ParameterValue + "\" />"))   //example: <parameter key="dcm_modality" value="IO" />
                        {
                            pImageInfo.Result = TestResult.Fail;
                            pImageInfo.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + dicom_info);
                        }
                    }

                    if (pImageInfo.Result != TestResult.Fail)
                    {
                        pImageInfo.Result = TestResult.Pass;
                        pImageInfo.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return", "The return values in getImageInfo all match the expected. Get:" + getImageInfoResult.ResultContent);
                    }
                    #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 void Run_Acquisition_New_FMS_2_Case1670()
        {
            int runCount = 0;
            string acquireType = string.Empty;
            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Acquisition");

                ApplicationService apps = new ApplicationService();
                //start 2D simulator and register 2D simulator to CSDM with same port number
                Start2DSimulator s2d = new Start2DSimulator(10000);
                System.Threading.Thread.Sleep(20);
                apps.registerApplication("2DViewer", "localhost", 10000, true);

                //get acquire information and expect information
                XMLParameter acq = new XMLParameter("acq_info");
                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;
                    }
                }
                Dictionary<string, string> expectVal = new Dictionary<string, string>();
                for (int j = 0; j < ids.ExpectedValues.Count; j++)
                {
                    if (ids.InputParameters.GetParameter(j).Step == "acquire")
                    {
                        expectVal.Add(ids.ExpectedValues.GetParameter(j).Key, ids.ExpectedValues.GetParameter(j).Value);
                    }
                }

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

                //start stomp message listener
                string stopMessageType = "teststop";
                string stopMessageContent = "teststop";

                string hostadd = PAS.AutoTest.TestUtility.Utility.GetCSDMConfig(PAS.AutoTest.TestUtility.CSDMConfigSection.remote, "host");
                string portnoti = PAS.AutoTest.TestUtility.Utility.GetCSDMConfig(PAS.AutoTest.TestUtility.CSDMConfigSection.remote, "notificationPort");
                NotificationSim.ReceiveNotification rn = new NotificationSim.ReceiveNotification(hostadd, int.Parse(portnoti));

                System.Collections.Generic.List<string> rms = new System.Collections.Generic.List<string>();
                rms.Add("topic.acquisitionCompleted");
                rn.startListon(rms, stopMessageType, stopMessageContent);

                AcquisitionService acqs = new AcquisitionService();
                XMLResult rslAcqRVG = acqs.startAcquisition(acq);

                switch (acquireType)
                {
                    case "FMS":
                        System.Diagnostics.Debug.Print("FMS Acquire");
                        //Utility.AcqFMS(40, 300);
                        System.Threading.Thread tx = new System.Threading.Thread(Utility.AcquireFMSOne);
                        tx.Start();
                        break;
                    default:
                        System.Diagnostics.Debug.Print("NOT FMS/PANO/CEPH/CR Acquire");
                        break;
                }

                string acq_session_id = "";
                //System.Threading.Thread.Sleep(50);
                if (rslAcqRVG.IsErrorOccured)
                {
                    System.Diagnostics.Debug.Print("Acquire fail:");
                    pAcquire.Result = TestResult.Fail;
                    pAcquire.Outputs.AddParameter("Acquire image error", "startAcquisition", rslAcqRVG.Message);
                    continue;
                }
                else
                {
                    acq_session_id = rslAcqRVG.SingleResult;
                    pAcquire.Result = TestResult.Pass;
                    pAcquire.Outputs.AddParameter("Acquire image success", "startAcquisition", rslAcqRVG.ResultContent);

                    //start an advanced simulator to receive the specified command
                    int port = 10000;
                    string sRet = "";
                    TwoDSim.AdvanceSimulator asi = new TwoDSim.AdvanceSimulator(port);
                    asi.StartSimulater("0,OK;open_acquired_objects");
                    sRet = asi.StopSimulator(120000);

                    CheckPoint pCheckMessage = new CheckPoint("Check Command", "Acquisition SOCKET Message");
                    r.CheckPoints.Add(pCheckMessage);
                    if (sRet == "")
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("NO COMMAND ERROR", "Check Command", "TIMEOUT: The socket message doesn't received");
                        SaveRound(r);
                        continue;
                    }
                    else
                    {
                        pCheckMessage.Outputs.AddParameter("open_acquired_objects COMMAND parameter", "Record Command", sRet);
                    }

                    ParseMessageContent cn = new ParseMessageContent(sRet);

                    //get patient internal id from command message
                    string patient_uid = cn.getValueFromKey("-patient_internal_id");
                    bool gotPatientId = false;
                    foreach (KeyValuePair<string, string> kvp in expectVal)
                    {
                        if (kvp.Key == "patient_internal_id" && kvp.Value == patient_uid)
                        {
                            gotPatientId = true;
                        }
                    }
                    if (!gotPatientId)
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("Patient ID Check ERROR", "Check Command", "The socket message content with WRONG patient ID");
                        SaveRound(r);
                        continue;
                    }

                    string fms_internal_id_from_acqResult = "";
                    string fms_internal_id_from_mapfile = "";
                    string image_internal_id_from_acqResult = "";
                    string ps_internal_id_from_acqResult = "";
                    string image_internal_id_from_mapfile = "";
                    string ps_internal_id_from_mapfile = "";

                    //get acquisition session id from command message
                    string session_uid_from_command = cn.getValueFromKey("-session_id");
                    if (acq_session_id != session_uid_from_command)
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("Session ID Check EROR", "Check Command", "The session id from command not equals the id from startAcquisition!");
                        SaveRound(r);
                        continue;
                    }

                    int timeout = 0;
                    do
                    {
                        XMLResult rslgetAcqResult = acqs.getAcquisitionResult(session_uid_from_command);

                        if (!rslgetAcqResult.IsErrorOccured && rslgetAcqResult.Code == 0)
                        {
                            pCheckMessage.Outputs.AddParameter("Show the content after getAcquisitionResult", "Output getAcquisitionResult", rslgetAcqResult.ResultContent);
                            ParseXMLContent rslForFMS = new ParseXMLContent(rslgetAcqResult.ResultContent);
                            fms_internal_id_from_acqResult = rslForFMS.getStringWithPathAndType("trophy/object_info", "fms", "value");
                            image_internal_id_from_acqResult = rslForFMS.getStringWithPathAndType("trophy/object_info", "image", "value");
                            ps_internal_id_from_acqResult = rslForFMS.getStringWithPathAndType("trophy/object_info", "presentation_state", "value");
                            break;
                        }
                        timeout++;
                        System.Threading.Thread.Sleep(1000);
                    } while (timeout < 300);
                    if (timeout >= 300)
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("Try too many times", "Check getAcquisitionResult", "TIMEOUT of getAcquisitionResult");
                        break;
                    }

                    string fmsfilepath = "";
                    string original_path = "";
                    //parser the mapping xml content from command message
                    string mapping_xml = cn.getValueFromKey("-mapping_xml");
                    string mapping_content = base64tools.DecodeString4base(mapping_xml);
                    pCheckMessage.Outputs.AddParameter("Show the decode mapping file content", "Output mappingfile", mapping_content);
                    string target_path = "";
                    string keep_target_path = "";
                    if (mapping_content != null)
                    {
                        ParseXMLContent pc = new ParseXMLContent(mapping_content);
                        pc.getValueFromPath("path_mapping/instance");
                        string type = pc.getValueByKey("type");
                        bool gotType = false;
                        foreach (KeyValuePair<string, string> kvp in expectVal)
                        {
                            if (kvp.Key == "type" && type.Contains(kvp.Value))
                            {
                                gotType = true;
                            }
                        }
                        if (!gotType)
                        {
                            pCheckMessage.Result = TestResult.Fail;
                            pCheckMessage.Outputs.AddParameter("Type Check ERROR", "Check Command", "The socket message content with WRONG type");
                            SaveRound(r);
                            continue;
                        }

                        original_path = pc.getValueByKey("original_path");

                        //check the acquired image has been put into correct position.
                        target_path = pc.getValueByKey("target_path");
                        keep_target_path = target_path;
                        int needCheckFile = 0;
                        int checkedFile = 0;
                        do
                        {
                            string sub_target_path = target_path;
                            int indexKey = sub_target_path.IndexOf(";");
                            if (indexKey != -1)
                            {
                                sub_target_path = sub_target_path.Substring(0, indexKey);
                                target_path = target_path.Substring(indexKey + 1);

                                //temp in here to skip the processing file check.
                                if (sub_target_path.Contains(".xml"))
                                {
                                    continue;
                                }

                                needCheckFile++;
                                bool dicomfileexist = Utility.isFileExisted(sub_target_path);
                                if (sub_target_path.Contains(".fms"))
                                    fmsfilepath = sub_target_path;

                                if (!dicomfileexist)
                                {
                                    pCheckMessage.Result = TestResult.Fail;
                                    pCheckMessage.Outputs.AddParameter("Dicom File {" + sub_target_path + "} Check ERROR", "Check Command", "The acquired image not in cache place");
                                    SaveRound(r);
                                    continue;
                                }
                                checkedFile++;
                            }
                        } while (target_path != "");

                        if (needCheckFile != checkedFile)
                        {
                            pCheckMessage.Result = TestResult.Fail;
                            pCheckMessage.Outputs.AddParameter("Files Check ERROR", "Check Command", "No all files contained in Message are exist");
                            SaveRound(r);
                            continue;
                        }

                        //get all image uid from mapping file
                        image_internal_id_from_mapfile = pc.getWithPathAndTypeFromMappingFile("path_mapping", "Image", "instance_internal_id");
                        //get all ps uid from mapping file
                        ps_internal_id_from_mapfile = pc.getWithPathAndTypeFromMappingFile("path_mapping", "Image", "ps_internal_id");
                        //get FMS uid from mapping file
                        fms_internal_id_from_mapfile = pc.getWithPathAndTypeFromMappingFile("path_mapping", "FMS", "instance_internal_id");

                        string processdatafilecontent = pc.getWithPathAndTypeFromMappingFile("path_mapping", "ProcessingDataFile", "content");
                        int countForProcessing = 0;
                        do
                        {
                            string sub_processdatafilecontent = processdatafilecontent;
                            int indexKey3 = sub_processdatafilecontent.IndexOf(";");
                            if (indexKey3 != -1)
                            {

                                sub_processdatafilecontent = sub_processdatafilecontent.Substring(0, indexKey3);
                                processdatafilecontent = processdatafilecontent.Substring(indexKey3 + 1);
                                if (sub_processdatafilecontent != "")
                                {
                                    countForProcessing++;
                                    string processingXMLcontent = base64tools.DecodeString4base(sub_processdatafilecontent);
                                    pCheckMessage.Outputs.AddParameter("Processing Data File from SDK", "Processing Content " + countForProcessing, processingXMLcontent);
                                }
                            }
                        } while (processdatafilecontent != "");

                    }
                    if (image_internal_id_from_acqResult != image_internal_id_from_mapfile)
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("Message and Interface result", "Check Command", "The image id from command not equals the id from getAcquisitionResult!");
                        SaveRound(r);
                        continue;
                    }
                    if (ps_internal_id_from_acqResult != ps_internal_id_from_mapfile)
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("Message and Interface result", "Check Command", "The presentation id from command not equals the id from getAcquisitionResult!");
                        SaveRound(r);
                        continue;
                    }
                    if (fms_internal_id_from_acqResult != fms_internal_id_from_mapfile)
                    {
                        pCheckMessage.Result = TestResult.Fail;
                        pCheckMessage.Outputs.AddParameter("Message and Interface result", "Check Command", "The FMS id from command not equals the id from getAcquisitionResult!");
                        SaveRound(r);
                        continue;
                    }

                    //parser the trophy xml content from command message
                    string acq_out_xml = cn.getValueFromKey("-acq_out_xml");
                    string acq_out = base64tools.DecodeString4base(acq_out_xml);
                    pCheckMessage.Outputs.AddParameter("XML From SDK", "Check Command", acq_out);

                    //Check the FMS contain the correct image that compare with mapping files
                    ParseXMLContent pc1 = new ParseXMLContent(fmsfilepath, "File");
                    string psIDInFMS = pc1.getStringFromPath("FMS_DATA/ItemData/Identifier");
                    int checkPSIDInResult = 0;
                    int psInFMSContent = 0;
                    do
                    {
                        string sub_psID = psIDInFMS;
                        int indexKey = sub_psID.IndexOf(";");
                        if (indexKey != -1)
                        {
                            psInFMSContent++;
                            sub_psID = sub_psID.Substring(0, indexKey);
                            psIDInFMS = psIDInFMS.Substring(indexKey + 1);
                        }
                        if (ps_internal_id_from_acqResult.Contains(sub_psID))
                        {
                            checkPSIDInResult++;
                        }

                    } while (psIDInFMS != "");
                    if (checkPSIDInResult == psInFMSContent)
                    {
                        pCheckMessage.Outputs.AddParameter("Message and Interface result", "Check Command", "All IMAGEs in FMS are matched with mapping file");
                    }
                    else
                    {
                        pCheckMessage.Outputs.AddParameter("Message and Interface result", "Check Command", "NOT All IMAGEs in FMS are matched with mapping file");
                    }
                    //Check the FMS contain the correct image end

                    System.Threading.Thread.Sleep(5000);
                    CheckPoint pCheckGetImage = new CheckPoint("Check NOTIFICATION", "Acquisition complete Message");
                    r.CheckPoints.Add(pCheckGetImage);
                    apps.sendGenericNotification(stopMessageType, stopMessageContent);
                    System.Threading.Thread.Sleep(1000);
                    //check getFMSInfo
                    int getn = rn.getRecievedNumber();
                    if (getn == 2)
                    {
                        FMSService fmss = new FMSService();
                        int indexKey = fms_internal_id_from_mapfile.IndexOf(";");
                        if (indexKey != -1)
                        {
                            fms_internal_id_from_mapfile = fms_internal_id_from_mapfile.Substring(0, indexKey);
                        }

                        //check get FMS description with content
                        XMLResult fmsDesRsl = fmss.getFMSDescription(fms_internal_id_from_mapfile);
                        string psids = "";
                        if (fmsDesRsl.IsErrorOccured || fmsDesRsl.Code != 0)
                        {
                            pCheckGetImage.Result = TestResult.Fail;
                            pCheckGetImage.Outputs.AddParameter("Get FMS Info result", "Get Return XML", fmsDesRsl.ResultContent);
                            continue;
                        }
                        else
                        {
                            ParseXMLContent pc2 = new ParseXMLContent(fmsDesRsl.ResultContent);
                            pc2.getValueFromPath("trophy/presentationstate");
                            psids = pc2.getValueByKey("internal_id");
                        }
                        int checkPSIDInFMSDes = 0;
                        int psInGetFMSDes = 0;
                        do
                        {
                            string sub_psID = psids;
                            int indKey = sub_psID.IndexOf(";");
                            if (indKey != -1)
                            {
                                psInGetFMSDes++;
                                sub_psID = sub_psID.Substring(0, indKey);
                                psids = psids.Substring(indKey + 1);
                            }
                            if (ps_internal_id_from_acqResult.Contains(sub_psID))
                            {
                                checkPSIDInFMSDes++;
                            }

                        } while (psids != "");

                        if (checkPSIDInFMSDes == psInGetFMSDes)
                        {
                            pCheckGetImage.Outputs.AddParameter("Check the presentation ids again with getAcquisitionResult", "Check the presentation ids", "ALL IDs is equal with aspect");
                        }
                        else
                        {
                            pCheckGetImage.Result = TestResult.Fail;
                            pCheckGetImage.Outputs.AddParameter("Check the presentation ids again with getAcquisitionResult", "Check the presentation ids", "Some IDs is not equal with aspect");
                            continue;
                        }

                        //got the first image to check
                        XMLParameter getImage = new XMLParameter("image");
                        int indexImage = image_internal_id_from_acqResult.IndexOf(";");
                        if (indexImage != -1)
                            image_internal_id_from_acqResult = image_internal_id_from_acqResult.Substring(0, indexImage);
                        getImage.AddParameter("internal_id", image_internal_id_from_acqResult);
                        ImageService imagesrv = new ImageService();
                        XMLResult getImageRsl = imagesrv.getImageInfo(getImage);
                        //match items
                        pCheckGetImage.Outputs.AddParameter("Get Image Info result", "Get Return XML", getImageRsl.ResultContent);
                        int matchValueCount = 0;
                        for (int i = 0; i < getImageRsl.DicomArrayResult.Length; i++)
                        {
                            if (getImageRsl.DicomArrayResult.Parameters[i].ParameterName == "internal_id"
                                && getImageRsl.DicomArrayResult.Parameters[i].ParameterValue == image_internal_id_from_acqResult)
                            {
                                matchValueCount++;
                            }

                            if (getImageRsl.DicomArrayResult.Parameters[i].ParameterName == "patient_internal_id"
                                && getImageRsl.DicomArrayResult.Parameters[i].ParameterValue == patient_uid)
                            {
                                matchValueCount++;
                            }
                            keep_target_path = keep_target_path.Replace('\\', '/');
                            if (getImageRsl.DicomArrayResult.Parameters[i].ParameterName == "path"
                                && keep_target_path.Contains(getImageRsl.DicomArrayResult.Parameters[i].ParameterValue))
                            {
                                matchValueCount++;
                            }
                        }
                        if (matchValueCount == 3)
                        {
                            pCheckGetImage.Result = TestResult.Pass;
                            pCheckGetImage.Outputs.AddParameter("Get Image Info result", "Check Return XML", "All ID is matched");
                        }
                        else
                        {
                            pCheckGetImage.Result = TestResult.Fail;
                            pCheckGetImage.Outputs.AddParameter("Get Image Info result", "Check Return XML", "Some ID is not matched");
                        }

                    }
                    else
                    {
                        pCheckGetImage.Result = TestResult.Fail;
                        pCheckGetImage.Outputs.AddParameter("Notification not received", "Check Return", "No acquisition complete Message be received");
                    }

                    pCheckMessage.Result = TestResult.Pass;
                }
                SaveRound(r);
            }
            Output();
        }