コード例 #1
0
        public override void Run()
        {
            string             acqInfoString = string.Empty;
            string             sessionId     = string.Empty;
            AcquisitionService acqService    = new AcquisitionService();
            ExactTimer         timer         = new ExactTimer();
            int timeOut = 600;

            try
            {
                LaunchNotification();
                string PatientId = CommonLib.CreatePatient();

                XMLParameter acqInfo = new XMLParameter("acq_info");
                acqInfo.AddParameter("device_id", "AcqImgFiles.dll");
                acqInfo.AddParameter("line_id", "308C0000");
                acqInfo.AddParameter("patient_internal_id", PatientId);
                acqInfo.AddParameter("series_performing_physician_name", "performing_physician_name");
                acqInfoString = acqInfo.GenerateXML();
            }
            catch (Exception ex)
            {
                LogRecordType lr = new LogRecordType();
                lr.FunctionName = this.mFunctionName;
                lr.Lable        = this.mLabel;
                string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                lr.Passed  = false;

                Log.AddRecord(lr);

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

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

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

                try
                {
                    int       attemp    = 0;
                    int       errorCode = 272; //the error code for session existed.
                    XMLResult result    = new XMLResult();

                    timer.Start();

                    while (errorCode == 272)
                    {
                        result    = new XMLResult(acqService.InvokeMethod("startAcquisition", new object[] { acqInfoString }));
                        errorCode = result.Code;
                    }

                    sessionId = result.SingleResult;
                    XMLResult acqResult = acqService.getAcquisitionResult(sessionId);

                    while (acqResult.IsErrorOccured && attemp < timeOut)  //loop while the result code is 0, and the time out is 60s
                    {
                        acqResult = acqService.getAcquisitionResult(sessionId);
                        System.Threading.Thread.Sleep(100);
                        attemp++;
                    }

                    timer.Stop();

                    lr.ResponseTime = timer.Duration;
                    lr.Passed       = !(acqResult.IsErrorOccured);

                    if (!lr.Passed)
                    {
                        if (attemp >= timeOut)
                        {
                            lr.Message = "the service did not return after 60s. " + acqResult.Message;
                        }
                        else
                        {
                            lr.Message = acqResult.Message;
                        }

                        this.mFailed++;
                    }
                    else
                    {
                        lr.Message          = result.SingleResult + "code: " + result.Code;
                        this.mExectuedTime += lr.ResponseTime;
                    }
                }
                catch (Exception ex)
                {
                    this.mFailed++;
                    lr.Passed = false;
                    string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                    lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                }

                this.mExecuted = i;
                Log.AddRecord(lr);
                if (i == this.mRepeat)
                {
                    FinishNotification();
                }
                this.RiseSingleCallCompleteEvent(lr.ResponseTime, lr.Passed);
            }

            this.RiseTestCaseCompleteEvent();
        }
コード例 #2
0
        public override void Run()
        {
            string newPSId                     = string.Empty;
            string setPSInfoString             = string.Empty;
            string getPSInfoString             = string.Empty;
            PresentationStateService psService = new PresentationStateService();

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

                Log.AddRecord(lr);

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

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

            double userCaseResponse = 0;

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

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

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


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

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

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

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

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

            this.RiseTestCaseCompleteEvent();
        }
コード例 #3
0
        public override void Run()
        {
            string           openObjInfo = string.Empty;
            string           psId        = string.Empty;
            KDIS7ImageWindow iw          = new KDIS7ImageWindow();
            KDIS7ATAssistant ka          = new KDIS7ATAssistant();

            ApplicationService appService = new ApplicationService();

            try
            {
                string        PatientId    = CommonLib.CreatePatient();
                ImportService import       = new ImportService();
                XMLResult     importResult = import.importObject(PatientId, string.Empty, @"c:\PASPerformance\001.png", null, true, string.Empty);
                psId = importResult.MultiResults[1].GetParameterValueByIndex(0);

                XMLParameter pa = new XMLParameter("two_dimension_viewer");
                pa.AddParameter("internal_id", psId);

                openObjInfo = pa.GenerateXML();
            }
            catch (Exception ex)
            {
                LogRecordType lr = new LogRecordType();
                lr.FunctionName = this.mFunctionName;
                lr.Lable        = this.mLabel;
                string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                lr.Passed  = false;

                Log.AddRecord(lr);

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

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

                return;
            }

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

                try
                {
                    XMLResult result = new XMLResult(appService.InvokeMethod("openObjects", new object[] { openObjInfo }));

                    bool imageOpened = iw.ItemByID(psId).WaitProperty("ShownOnScreen", true, 30);

                    System.Threading.Thread.Sleep(3000);

                    ka.CleanApp("Default");

                    lr.ResponseTime = appService.ResponseTime;
                    lr.Passed       = (!(result.IsErrorOccured) && imageOpened);

                    if (!lr.Passed)
                    {
                        if (result.IsErrorOccured)
                        {
                            lr.Message = "Call openObjects returns error: " + result.Message;
                        }
                        else
                        {
                            lr.Message = "Failed to open CSI.";
                        }

                        this.mFailed++;
                    }
                    else
                    {
                        lr.Message          = result.SingleResult;
                        this.mExectuedTime += lr.ResponseTime;
                    }
                }
                catch (Exception ex)
                {
                    this.mFailed++;
                    lr.Passed = false;
                    string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                    lr.Message = "Call openObjects throws exception: " + ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                }

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

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

            this.RiseTestCaseCompleteEvent();
        }
コード例 #4
0
        public override void Run()
        {
            string PatientStarts = string.Empty;
            Random random        = new Random(Guid.NewGuid().GetHashCode());

            PatientStarts += Convert.ToChar(random.Next(65, 91));
            PatientStarts += Convert.ToChar(random.Next(65, 91));
            PatientStarts += Convert.ToChar(random.Next(65, 91));
            PatientStarts += Convert.ToChar(random.Next(65, 91));

            PatientService ps = new PatientService();

            XMLParameter pa = new XMLParameter("patient");

            pa.AddParameter("patient_id", "$_R");
            pa.AddParameter("dpms_id", "$_R");
            pa.AddParameter("first_name", "$_R");
            pa.AddParameter("last_name", "$_R");
            pa.AddParameter("middle_name", "$_R");
            pa.AddParameter("prefix", "Mr");
            pa.AddParameter("suffix", "X");
            pa.AddParameter("birth_date", "2010-10-22");
            pa.AddParameter("sex", "female");
            pa.AddParameter("pregnancy", "not pregnant");
            pa.AddParameter("insurance_number", "1234567");
            pa.AddParameter("address", "Test address");
            pa.AddParameter("town", "test town");
            pa.AddParameter("postal_code", "female");
            pa.AddParameter("cellular_phone", "female");
            pa.AddParameter("home_phone", "female");
            pa.AddParameter("work_phone", "female");
            pa.AddParameter("comments", "user comments");
            pa.AddParameter("email", "*****@*****.**");
            pa.AddParameter("photo", "");

            string PatientInfo = pa.GenerateXML();

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

                try
                {
                    XMLResult result = new XMLResult(ps.InvokeMethod("createPatient", new object[] { PatientInfo.Replace("$_R", PatientStarts + (i + 1).ToString()) }));
                    lr.ResponseTime = ps.ResponseTime;
                    lr.Passed       = !(result.IsErrorOccured);

                    if (!lr.Passed)
                    {
                        lr.Message = result.Message;
                        this.mFailed++;
                    }
                    else
                    {
                        lr.Message          = result.SingleResult;
                        this.mExectuedTime += lr.ResponseTime;
                    }
                }
                catch (Exception ex)
                {
                    this.mFailed++;
                    lr.Passed = false;
                    string innerText = ex.InnerException == null ? string.Empty : ex.InnerException.Message;
                    lr.Message = ex.Message + innerText == string.Empty ? string.Empty : "(" + innerText + ")";
                }

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

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

            this.RiseTestCaseCompleteEvent();
        }