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